Skip to content

Commit 8ff9334

Browse files
committed
Use XYCollections instead of standard JFX FXCollections
1 parent 3960c2f commit 8ff9334

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

MAVGCL/src/main/java/com/comino/flight/ui/widgets/charts/xy/XYChartWidget.java

+35-9
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262
import com.comino.flight.ui.widgets.charts.annotations.XYSigmaAnnotation;
6363
import com.comino.flight.ui.widgets.charts.annotations.XYSlamAnnotation;
6464
import com.comino.flight.ui.widgets.charts.annotations.XYTrajectoryAnnonation;
65+
import com.comino.flight.ui.widgets.charts.utils.XYCollections;
6566
import com.comino.flight.ui.widgets.charts.utils.XYDataPool;
67+
import com.comino.flight.ui.widgets.charts.utils.XYObservableListWrapper;
6668
import com.comino.flight.ui.widgets.charts.utils.XYStatistics;
6769
import com.comino.jfx.extensions.SectionLineChart;
6870
import com.comino.jfx.extensions.XYAnnotations.Layer;
@@ -88,6 +90,7 @@
8890
import javafx.scene.SnapshotParameters;
8991
import javafx.scene.chart.NumberAxis;
9092
import javafx.scene.chart.XYChart;
93+
import javafx.scene.chart.XYChart.Data;
9194
import javafx.scene.control.Button;
9295
import javafx.scene.control.CheckBox;
9396
import javafx.scene.control.ChoiceBox;
@@ -613,15 +616,32 @@ public void handle(MouseEvent click) {
613616
});
614617

615618
replay.addListener((v, ov, nv) -> {
619+
// if(isDisabled())
620+
// return;
621+
// refreshRequest = true;
622+
// if(nv.intValue()<=5) {
623+
// current_x0_pt = 0;
624+
// Platform.runLater(() -> updateGraph(true, 1) );
625+
// } else
626+
// Platform.runLater(() -> updateGraph(false,nv.intValue()) );
627+
// dataService.setCurrent(nv.intValue());
616628
if(isDisabled())
617629
return;
618-
refreshRequest = true;
619-
if(nv.intValue()<=5) {
620-
current_x0_pt = 0;
621-
Platform.runLater(() -> updateGraph(true, 1) );
622-
} else
623-
Platform.runLater(() -> updateGraph(false,nv.intValue()) );
624-
dataService.setCurrent(nv.intValue());
630+
631+
if(nv.intValue()<0) {
632+
current_x0_pt = dataService.calculateX0Index(-nv.intValue());
633+
if(current_x0_pt>0)
634+
current_x_pt = dataService.calculateX1Index(-nv.intValue());
635+
else {
636+
current_x_pt = -nv.intValue();
637+
}
638+
639+
dataService.setCurrent(-nv.intValue());
640+
updateGraph(true, -nv.intValue());
641+
} else {
642+
updateGraph(false, nv.intValue());
643+
dataService.setCurrent(nv.intValue());
644+
}
625645
});
626646

627647
annotation.selectedProperty().addListener((v, ov, nv) -> {
@@ -904,6 +924,9 @@ private void updateGraph(boolean refresh, int max_x0) {
904924
max_x = mList.size();
905925

906926
slot_tms = System.currentTimeMillis();
927+
928+
((XYObservableListWrapper<?>)series1.getData()).begin();
929+
((XYObservableListWrapper<?>)series2.getData()).begin();
907930

908931
while(current_x_pt<max_x && ((System.currentTimeMillis()-slot_tms) < REFRESH_SLOT || refreshRequest)) {
909932
//System.out.println(current_x_pt+"<"+max_x+":"+resolution_ms);
@@ -950,6 +973,9 @@ private void updateGraph(boolean refresh, int max_x0) {
950973
}
951974
current_x_pt++;
952975
}
976+
977+
((XYObservableListWrapper<?>)series1.getData()).end();
978+
((XYObservableListWrapper<?>)series2.getData()).end();
953979

954980
sigma1.setPosition(p1[0], p1[1],s1.stddev_xy);
955981
sigma2.setPosition(p2[0], p2[1],s2.stddev_xy);
@@ -960,10 +986,10 @@ private void updateGraph(boolean refresh, int max_x0) {
960986

961987

962988
public XYChartWidget setup(IMAVController control) {
963-
series1 = new XYChart.Series<Number,Number>();
989+
series1 = new XYChart.Series<Number,Number>(XYCollections.<Data<Number,Number>>observableArrayList());
964990

965991
xychart.getData().add(series1);
966-
series2 = new XYChart.Series<Number,Number>();
992+
series2 = new XYChart.Series<Number,Number>(XYCollections.<Data<Number,Number>>observableArrayList());
967993
xychart.getData().add(series2);
968994

969995
this.control = control;

0 commit comments

Comments
 (0)