On Thu, 20 Jun 2024 17:44:41 GMT, Markus Mack <[email protected]> wrote:
>> This PR provides the test case given in the JBS issue, and a simple fix for
>> the index calculation when inserting data after previous data with duplicate
>> categories.
>>
>> Also, I've added a comment to `BarChart`s javadoc, clarifying the behavior
>> that was apparently assumed (but broken) previously.
>>
>> The index lookup is skipped for performance reasons if there are no
>> duplicates, corresponding to the previous implementation.
>> Further optimizations would be possible, but probably are not really helpful
>> without more extensive changes. The previous code already loops over all
>> categories to check if they are present, typically nested in a loop adding
>> many data items, thus already scaling quadratically when adding lots of
>> mostly unique data points.
>
> Markus Mack has updated the pull request incrementally with one additional
> commit since the last revision:
>
> JavaDoc formatting
This code does not work:
Exception in thread "JavaFX Application Thread"
java.lang.IndexOutOfBoundsException: Index 2 out of bounds for length 1
at
java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at
java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at
java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at
javafx.base/com.sun.javafx.collections.ObservableListWrapper.doAdd(ObservableListWrapper.java:98)
at
javafx.base/javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:196)
at
javafx.controls/javafx.scene.chart.BarChart.dataItemAdded(BarChart.java:218)
at
javafx.controls/javafx.scene.chart.XYChart.dataItemsChanged(XYChart.java:558)
at
javafx.controls/javafx.scene.chart.XYChart$Series$1.onChanged(XYChart.java:1556)
at
javafx.base/com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:162)
at
javafx.base/com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:71)
at
javafx.base/javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:246)
at
javafx.base/javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:482)
at
javafx.base/javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
at
javafx.base/javafx.collections.ObservableListBase.endChange(ObservableListBase.java:210)
at
javafx.base/javafx.collections.ModifiableObservableListBase.add(ModifiableObservableListBase.java:200)
at java.base/java.util.AbstractList.add(AbstractList.java:113)
at
monkey_tester/com.oracle.tools.fx.monkey.pages.BarChartPage.addDuplicateCategory(BarChartPage.java:86)
at
monkey_tester/com.oracle.tools.fx.monkey.util.FX.lambda$2(FX.java:145)
at
javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232)
at
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189)
at
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at
javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.base/javafx.event.Event.fireEvent(Event.java:199)
at javafx.controls/javafx.scene.control.MenuItem.fire(MenuItem.java:459)
at
javafx.controls/com.sun.javafx.scene.control.ContextMenuContent$MenuItemContainer.doSelect(ContextMenuContent.java:1426)
at
javafx.controls/com.sun.javafx.scene.control.ContextMenuContent$MenuItemContainer.lambda$12(ContextMenuContent.java:1379)
at
javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
at
javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232)
at
javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189)
at
javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at
javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at
javafx.base/com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at
javafx.base/com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.base/javafx.event.Event.fireEvent(Event.java:199)
at
javafx.graphics/javafx.scene.Scene$MouseHandler.process(Scene.java:3987)
at javafx.graphics/javafx.scene.Scene.processMouseEvent(Scene.java:1893)
at
javafx.graphics/javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2711)
at
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:411)
at
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:1)
at
java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
at
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$2(GlassViewEventHandler.java:450)
at
javafx.graphics/com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:430)
at
javafx.graphics/com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:449)
at javafx.graphics/com.sun.glass.ui.View.handleMouseEvent(View.java:551)
at javafx.graphics/com.sun.glass.ui.View.notifyMouse(View.java:937)
at
javafx.graphics/com.sun.glass.ui.mac.MacView.notifyMouse(MacView.java:128)
To reproduce:
- run the **latest** Monkey Tester
- select BarChart
- just in case, I am going to attach a screenshot of the settings
- right click on chart, select "Add Duplicate Category" item **twice**
- right click, select "Add Series with Duplicate Category"
- BOOM

-------------
PR Comment: https://git.openjdk.org/jfx/pull/1476#issuecomment-2181282900