Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Out of bounds error on applying style to a selection #43

Closed
ghost opened this issue Apr 19, 2014 · 10 comments
Closed

Out of bounds error on applying style to a selection #43

ghost opened this issue Apr 19, 2014 · 10 comments

Comments

@ghost
Copy link

ghost commented Apr 19, 2014

I was applying a style to a selection. after this selection there was a couple of new lines.. so I guess it has to do with the line terminator?

Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: 6 not in [0, 6)
at org.fxmisc.richtext.Paragraph.subSequence(Paragraph.java:229)
at org.fxmisc.richtext.Paragraph.restyle(Paragraph.java:262)
at org.fxmisc.richtext.EditableStyledDocument.setStyleSpans(EditableStyledDocument.java:257)
at org.fxmisc.richtext.StyledTextArea.setStyleSpans(StyledTextArea.java:522)
at TextComponentElements.TextEditor.applySizeToSelection(TextEditor.java:1336)
at TextComponentElements.TextEditor.applySize(TextEditor.java:1321)
at TextComponentElements.TextEditor$32.handle(TextEditor.java:889)
at TextComponentElements.TextEditor$32.handle(TextEditor.java:885)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:204)
at javafx.scene.Scene$ClickGenerator.postProcess(Scene.java:3456)
at javafx.scene.Scene$ClickGenerator.access$8300(Scene.java:3387)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3755)
at javafx.scene.Scene$MouseHandler.access$1800(Scene.java:3471)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1695)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2486)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:314)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:243)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:345)
at com.sun.glass.ui.View.handleMouseEvent(View.java:526)
at com.sun.glass.ui.View.notifyMouse(View.java:898)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)

@ghost
Copy link
Author

ghost commented Apr 19, 2014

not able to reproduce it again though...

@TomasMikula
Copy link
Member

Thanks for reporting. I can see the problem. It occurs when the selection ends at the very beginning of a line. And yes, it is related to line terminators.

@ghost
Copy link
Author

ghost commented Apr 19, 2014

cool!

On Fri, Apr 18, 2014 at 6:53 PM, TomasMikula [email protected]:

Thanks for reporting. I can see the problem. It occurs when the selection
ends at the very beginning of a line. And yes, it is related to line
terminators.


Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-40857828
.

@ghost
Copy link
Author

ghost commented Apr 19, 2014

will give it a shot it now

On Fri, Apr 18, 2014 at 8:05 PM, TomasMikula [email protected]:

Closed #43 #43 via
aa0abddhttps://github.com/TomasMikula/RichTextFX/commit/aa0abdd75835a8af5c43264265b2d41ac13e49a3
.


Reply to this email directly or view it on GitHubhttps://github.com//issues/43
.

@ghost
Copy link
Author

ghost commented Apr 19, 2014

Got another error:

Exception in thread "JavaFX Application Thread" java.lang.IndexOutOfBoundsException: 37 not in [0, 27]
at org.fxmisc.richtext.Paragraph.subSequence(Paragraph.java:234)
at org.fxmisc.richtext.Paragraph.subSequence(Paragraph.java:191)
at org.fxmisc.richtext.StyledDocumentBase.lambda$subSequence$10(StyledDocumentBase.java:78)
at org.fxmisc.richtext.StyledDocumentBase$$Lambda$55/635908559.subrange(Unknown Source)
at org.fxmisc.richtext.StyledDocumentBase.sub(StyledDocumentBase.java:237)
at org.fxmisc.richtext.StyledDocumentBase.subSequence(StyledDocumentBase.java:75)
at org.fxmisc.richtext.EditableStyledDocument.lambda$new$16(EditableStyledDocument.java:126)
at org.fxmisc.richtext.EditableStyledDocument$$Lambda$9/1594832699.combine(Unknown Source)
at org.reactfx.EventStreams$13.tryEmit(EventStreams.java:361)
at org.reactfx.EventStreams$ZippedStream$Pocket.valueUpdated(EventStreams.java:553)
at org.reactfx.EventStreams$Pocket.setValue(EventStreams.java:644)
at org.reactfx.EventStreams$ExclusivePocket.push(EventStreams.java:671)
at org.reactfx.EventStreams$Pocket.lambda$fillFrom$25(EventStreams.java:659)
at org.reactfx.EventStreams$Pocket$$Lambda$26/1386485445.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/273678114.accept(Unknown Source)
at org.reactfx.ListHelper$SingleElemHelper.forEach(ListHelper.java:81)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.EventStreams$12.lambda$subscribeToInputs$19(EventStreams.java:335)
at org.reactfx.EventStreams$12$$Lambda$27/865650772.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/273678114.accept(Unknown Source)
at org.reactfx.ListHelper$MultiElemHelper.forEach(ListHelper.java:118)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.EventSource.push(EventSource.java:15)
at org.fxmisc.richtext.EditableStyledDocument.beginStyleChange(EditableStyledDocument.java:374)
at org.fxmisc.richtext.EditableStyledDocument.setStyle(EditableStyledDocument.java:190)
at org.fxmisc.richtext.StyledTextArea.setStyle(StyledTextArea.java:490)
at TextComponentElements.TextEditorViewPort.scrollInPlainText(TextEditorViewPort.java:315)
at TextComponentElements.TextEditorViewPort$1.handle(TextEditorViewPort.java:368)
at TextComponentElements.TextEditorViewPort$1.handle(TextEditorViewPort.java:355)
at com.sun.javafx.event.CompositeEventHandler$NormalEventFilterRecord.handleCapturingEvent(CompositeEventHandler.java:282)
at com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:98)
at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:223)
at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:180)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:43)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:52)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:204)
at javafx.scene.Scene.processGestureEvent(Scene.java:1773)
at javafx.scene.Scene.access$300(Scene.java:201)
at javafx.scene.Scene$ScenePeerListener.scrollEvent(Scene.java:2564)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$2.run(GlassViewEventHandler.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$2.run(GlassViewEventHandler.java:385)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleScrollEvent(GlassViewEventHandler.java:385)
at com.sun.glass.ui.View.notifyScroll(View.java:920)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)
Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Value arrived out of order: 1
at org.reactfx.EventStreams$ExclusivePocket.push(EventStreams.java:669)
at org.reactfx.EventStreams$Pocket.lambda$fillFrom$25(EventStreams.java:659)
at org.reactfx.EventStreams$Pocket$$Lambda$26/1386485445.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/273678114.accept(Unknown Source)
at org.reactfx.ListHelper$MultiElemHelper.forEach(ListHelper.java:118)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.EventStreams$12.lambda$subscribeToInputs$19(EventStreams.java:335)
at org.reactfx.EventStreams$12$$Lambda$27/865650772.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/273678114.accept(Unknown Source)
at org.reactfx.ListHelper$SingleElemHelper.forEach(ListHelper.java:81)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.EventSource.push(EventSource.java:15)
at org.fxmisc.richtext.EditableStyledDocument.replace(EditableStyledDocument.java:396)
at org.fxmisc.richtext.EditableStyledDocument.replaceText(EditableStyledDocument.java:165)
at org.fxmisc.richtext.StyledTextArea.replaceText(StyledTextArea.java:572)
at org.fxmisc.richtext.TextEditingArea.replaceText(TextEditingArea.java:231)
at TextComponentElements.TextEditorViewPort.scrollInPlainText(TextEditorViewPort.java:309)
at TextComponentElements.TextEditorViewPort$1.handle(TextEditorViewPort.java:368)
at TextComponentElements.TextEditorViewPort$1.handle(TextEditorViewPort.java:355)
at com.sun.javafx.event.CompositeEventHandler$NormalEventFilterRecord.handleCapturingEvent(CompositeEventHandler.java:282)
at com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:98)
at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:223)
at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:180)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:43)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:52)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:204)
at javafx.scene.Scene.processGestureEvent(Scene.java:1773)
at javafx.scene.Scene.access$300(Scene.java:201)
at javafx.scene.Scene$ScenePeerListener.scrollEvent(Scene.java:2564)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$2.run(GlassViewEventHandler.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$2.run(GlassViewEventHandler.java:385)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleScrollEvent(GlassViewEventHandler.java:385)
at com.sun.glass.ui.View.notifyScroll(View.java:920)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)
Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Value arrived out of order: 1
at org.reactfx.EventStreams$ExclusivePocket.push(EventStreams.java:669)
at org.reactfx.EventStreams$Pocket.lambda$fillFrom$25(EventStreams.java:659)
at org.reactfx.EventStreams$Pocket$$Lambda$26/1386485445.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/273678114.accept(Unknown Source)
at org.reactfx.ListHelper$MultiElemHelper.forEach(ListHelper.java:118)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.EventStreams$12.lambda$subscribeToInputs$19(EventStreams.java:335)
at org.reactfx.EventStreams$12$$Lambda$27/865650772.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/273678114.accept(Unknown Source)
at org.reactfx.ListHelper$SingleElemHelper.forEach(ListHelper.java:81)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.EventSource.push(EventSource.java:15)
at org.fxmisc.richtext.EditableStyledDocument.replace(EditableStyledDocument.java:396)
at org.fxmisc.richtext.EditableStyledDocument.replaceText(EditableStyledDocument.java:165)
at org.fxmisc.richtext.StyledTextArea.replaceText(StyledTextArea.java:572)
at org.fxmisc.richtext.TextEditingArea.replaceText(TextEditingArea.java:231)
at TextComponentElements.TextEditorViewPort.scrollInPlainText(TextEditorViewPort.java:309)
at TextComponentElements.TextEditorViewPort$1.handle(TextEditorViewPort.java:368)
at TextComponentElements.TextEditorViewPort$1.handle(TextEditorViewPort.java:355)
at com.sun.javafx.event.CompositeEventHandler$NormalEventFilterRecord.handleCapturingEvent(CompositeEventHandler.java:282)
at com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:98)
at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:223)
at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:180)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:43)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:52)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:204)
at javafx.scene.Scene.processGestureEvent(Scene.java:1773)
at javafx.scene.Scene.access$300(Scene.java:201)
at javafx.scene.Scene$ScenePeerListener.scrollEvent(Scene.java:2564)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$2.run(GlassViewEventHandler.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$2.run(GlassViewEventHandler.java:385)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleScrollEvent(GlassViewEventHandler.java:385)
at com.sun.glass.ui.View.notifyScroll(View.java:920)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)
Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Value arrived out of order: 1
at org.reactfx.EventStreams$ExclusivePocket.push(EventStreams.java:669)
at org.reactfx.EventStreams$Pocket.lambda$fillFrom$25(EventStreams.java:659)
at org.reactfx.EventStreams$Pocket$$Lambda$26/1386485445.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/273678114.accept(Unknown Source)
at org.reactfx.ListHelper$MultiElemHelper.forEach(ListHelper.java:118)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.EventStreams$12.lambda$subscribeToInputs$19(EventStreams.java:335)
at org.reactfx.EventStreams$12$$Lambda$27/865650772.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/273678114.accept(Unknown Source)
at org.reactfx.ListHelper$SingleElemHelper.forEach(ListHelper.java:81)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.EventSource.push(EventSource.java:15)
at org.fxmisc.richtext.EditableStyledDocument.replace(EditableStyledDocument.java:396)
at org.fxmisc.richtext.EditableStyledDocument.replaceText(EditableStyledDocument.java:165)
at org.fxmisc.richtext.StyledTextArea.replaceText(StyledTextArea.java:572)
at org.fxmisc.richtext.TextEditingArea.replaceText(TextEditingArea.java:231)
at TextComponentElements.TextEditorViewPort.scrollInPlainText(TextEditorViewPort.java:309)
at TextComponentElements.TextEditorViewPort$1.handle(TextEditorViewPort.java:368)
at TextComponentElements.TextEditorViewPort$1.handle(TextEditorViewPort.java:355)
at com.sun.javafx.event.CompositeEventHandler$NormalEventFilterRecord.handleCapturingEvent(CompositeEventHandler.java:282)
at com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:98)
at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:223)
at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:180)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:43)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:52)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:204)
at javafx.scene.Scene.processGestureEvent(Scene.java:1773)
at javafx.scene.Scene.access$300(Scene.java:201)
at javafx.scene.Scene$ScenePeerListener.scrollEvent(Scene.java:2564)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$2.run(GlassViewEventHandler.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$2.run(GlassViewEventHandler.java:385)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleScrollEvent(GlassViewEventHandler.java:385)
at com.sun.glass.ui.View.notifyScroll(View.java:920)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)
Exception in thread "JavaFX Application Thread" java.lang.IllegalStateException: Value arrived out of order: 1
at org.reactfx.EventStreams$ExclusivePocket.push(EventStreams.java:669)
at org.reactfx.EventStreams$Pocket.lambda$fillFrom$25(EventStreams.java:659)
at org.reactfx.EventStreams$Pocket$$Lambda$26/1386485445.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/273678114.accept(Unknown Source)
at org.reactfx.ListHelper$MultiElemHelper.forEach(ListHelper.java:118)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.EventStreams$12.lambda$subscribeToInputs$19(EventStreams.java:335)
at org.reactfx.EventStreams$12$$Lambda$27/865650772.accept(Unknown Source)
at org.reactfx.EventStreamBase.lambda$emit$0(EventStreamBase.java:10)
at org.reactfx.EventStreamBase$$Lambda$53/273678114.accept(Unknown Source)
at org.reactfx.ListHelper$SingleElemHelper.forEach(ListHelper.java:81)
at org.reactfx.ListHelper.forEach(ListHelper.java:29)
at org.reactfx.EventStreamBase.emit(EventStreamBase.java:10)
at org.reactfx.EventSource.push(EventSource.java:15)
at org.fxmisc.richtext.EditableStyledDocument.replace(EditableStyledDocument.java:396)
at org.fxmisc.richtext.EditableStyledDocument.replaceText(EditableStyledDocument.java:165)
at org.fxmisc.richtext.StyledTextArea.replaceText(StyledTextArea.java:572)
at org.fxmisc.richtext.TextEditingArea.replaceText(TextEditingArea.java:231)
at TextComponentElements.TextEditorViewPort.scrollInPlainText(TextEditorViewPort.java:309)
at TextComponentElements.TextEditorViewPort$1.handle(TextEditorViewPort.java:368)
at TextComponentElements.TextEditorViewPort$1.handle(TextEditorViewPort.java:355)
at com.sun.javafx.event.CompositeEventHandler$NormalEventFilterRecord.handleCapturingEvent(CompositeEventHandler.java:282)
at com.sun.javafx.event.CompositeEventHandler.dispatchCapturingEvent(CompositeEventHandler.java:98)
at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:223)
at com.sun.javafx.event.EventHandlerManager.dispatchCapturingEvent(EventHandlerManager.java:180)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchCapturingEvent(CompositeEventDispatcher.java:43)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:52)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:204)
at javafx.scene.Scene.processGestureEvent(Scene.java:1773)
at javafx.scene.Scene.access$300(Scene.java:201)
at javafx.scene.Scene$ScenePeerListener.scrollEvent(Scene.java:2564)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$2.run(GlassViewEventHandler.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$2.run(GlassViewEventHandler.java:385)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleScrollEvent(GlassViewEventHandler.java:385)
at com.sun.glass.ui.View.notifyScroll(View.java:920)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$300(WinApplication.java:39)
at com.sun.glass.ui.win.WinApplication$4$1.run(WinApplication.java:112)
at java.lang.Thread.run(Thread.java:744)

@TomasMikula
Copy link
Member

Can you post steps to reproduce the problem?

Are you sure you are passing a valid range (i.e. within document bounds) to setStyle?

I added some range checks to the code. They will not fix the problem, just make it fail faster if you pass invalid range.

@ghost
Copy link
Author

ghost commented Apr 19, 2014

Found out why. this is the process:

1-I am trying to allow the user to store text values--each is a styled document (so it has many styles for example).

2-the user can swap the strings between these styled documents.

To get around the issue of length, i am doing a replace, and I require that a selection is made. and I keep refreshing the selection, by a "selectRange" method. I pull the segments from an array,, and i call it "scrolTempSegment".

this is the code:

    lastPlainIndex++;
    if (lastPlainIndex > editor.selectedSegments.size() - 1) {
        lastPlainIndex = 0;
    }
    scrollTemSegment = editor.selectedSegments.get(lastPlainIndex);                
    rangeOfSelection = richTextArea.getSelection();
            StyledDocument         subStyledDoc=richTextArea.getDocument().subSequence(rangeOfSelection);
            //we replace the text
            int start = rangeOfSelection.getStart();
            int end = rangeOfSelection.getEnd();

            richTextArea.replaceText(rangeOfSelection, scrollTemSegment.plainText);
            richTextArea.selectRange(start, richTextArea.getCaretPosition());
            rangeOfSelection = richTextArea.getSelection();
            ArrayList<StyledTextElement> styledElements = getStyledTextElements(subStyledDoc, editor);

            for (StyledTextElement stlElm : styledElements) {
                richTextArea.setStyle(stlElm.indexStart, stlElm.indexEnd, stlElm.styleInfo.completeInLineCSS.get());
            }

@TomasMikula
Copy link
Member

I don't understand what exactly you are trying to do, but I suspect at least one problem with this code:
If scrollTemSegment.plainText's length is less than the length of subStyledDoc and you try to apply subStyledDoc's style to newly inserted scrollTemSegment.plainText, you will reach beyond the end of scrollTemSegment.plainText and possibly beyond the end of text area, resulting in an error.

Also, I don't know what exactly getStyledTextElements is doing, but just note that any style ranges you get from subStyledDoc are relative to that sub-document (i.e. starting at 0), not relative to richTextArea.

Maybe this will do what you are trying to do:

rangeOfSelection = richTextArea.getSelection();
StyleSpans<String> styles = richTextArea.getStyleSpans(rangeOfSelection);
richTextArea.replaceText(rangeOfSelection, scrollTemSegment.plainText);
int start = rangeOfSelection.getStart();
int newTextLen = scrollTemSegment.plainText.length();
rangeOfSelection = new IndexRange(start, start + newTextLen);
richTextArea.selectRange(rangeOfSelection);
int len = Math.min(newTextLen, styles.length());
richTextArea.setStyleSpans(start, styles.subView(0, len));

But note that if scrollTemSegment.plainText is longer than the original selection, you will not get style applied beyond the original selection length.

@ghost
Copy link
Author

ghost commented Apr 19, 2014

Yes this works without errors. Thanks!

This is the use case:
I am building an interactive clip board, one that you can access via scroll action. So instead of multiple copy/paste operations. If all you want is to see how a document looks like with this or that text... why no scroll? More to come later ;)

@ghost
Copy link
Author

ghost commented Apr 19, 2014

the getStyledTextElements was a method that I ended up not using I guess...

The StyledTextElement is basically an styledText but with some additional information, like where it starts and ends, it styles, which view port it came from, etc. This info will be used for saving a file format, that I haven't got into yet .

Also, I using it to construct textflow objects so that I can use them as graphic nodes for a tree menu item. Kind of reverse engineering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant