2
私はclear()
チャートからデータを削除する方法を使用しています。JavaFXチャート - Java.lang.IllegalArgumentException:重複シリーズが追加されました
@FXML
public void restartButtonClicked() {
System.out.println("Restarting...");
timeLine.getKeyFrames().clear();
axesTest.getData().clear();
}
が、ボタンがクリック得れば - それは動作します..しかし、二度目、私はつもりだしながら、それをクリックして、それが例外をスロー:
Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: Duplicate series added
at javafx.scene.chart.XYChart.lambda$new$550(Unknown Source)
at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(Unknown Source)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(Unknown Source)
at javafx.collections.ObservableListBase.fireChange(Unknown Source)
at javafx.collections.ListChangeBuilder.commit(Unknown Source)
at javafx.collections.ListChangeBuilder.endChange(Unknown Source)
at javafx.collections.ObservableListBase.endChange(Unknown Source)
at javafx.collections.ModifiableObservableListBase.addAll(Unknown Source)
at sample.Controller.startButtonClicked(Controller.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Node.fireEvent(Unknown Source)
at javafx.scene.control.Button.fire(Unknown Source)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(Unknown Source)
at java.lang.Thread.run(Unknown Source)
だから、問題はとして138ラインであります同様の方法からのコードの159行で:
@SuppressWarnings("unchecked")
@FXML
public void startButtonClicked(ActionEvent event) {
if (comboBox.getValue() == null) {
System.out.print("Nie wybrano opcji.");
} else {
if(comboBox.getValue().equals("Gaussian Wave : non-Dispersive")) {
System.out.println("Gaussian Wave : non-Dispersive");
axesTest.setTitle("Gaussian Wave : non-Dispersive");
series.setName("bla");
series1.setName("ssad");
series2.setName("asf");
seriesList.add(series);
seriesList.add(series1);
seriesList.add(series2);
timeLine = new Timeline();
gaussianWave = new GaussianWave(seriesList, axes, timeLine);
seriesList = gaussianWave.draw();
gaussianWave.update(axesTest);
axesTest.getData().retainAll();
axesTest.getData().addAll(seriesList);
} else if(comboBox.getValue().equals("Gaussian Wave : Dispersive")) {
System.out.println("Gaussian Wave : Dispersive");
axesTest.setTitle("Gaussian Wave : Dispersive");
series.setName("bla");
series1.setName("ssad");
series2.setName("asf");
seriesList.add(series);
seriesList.add(series1);
seriesList.add(series2);
timeLine = new Timeline();
gaussianWaveDispersive = new GaussianWaveDispersive(seriesList, axes, timeLine);
seriesList = gaussianWaveDispersive.draw();
gaussianWaveDispersive.update(axesTest);
axesTest.getData().retainAll();
axesTest.getData().addAll(seriesList);
}
}
}
と問題がである:
axesTest.getData().addAll(seriesList);
グラフからすべてのデータを消去した後にこの例外が発生するのはなぜですか?どうすればこの問題を解決できますか?
ええ、あなたは正しいです! 'seriesList'のデータをクリアしませんでした。この2行は 'axesTest'に' Data'を格納することを意味します。 – yerpy