Search in sources :

Example 1 with XYChartSelection

use of eu.fthevenet.util.javafx.charts.XYChartSelection in project selenium_java by sergueik.

the class ChartViewportsState method setSelection.

public void setSelection(Map<Chart<Double>, XYChartSelection<ZonedDateTime, Double>> selectionMap, boolean toHistory) {
    this.suspendAxisListeners();
    try {
        selectionMap.forEach((chart, xyChartSelection) -> get(chart).ifPresent(y -> y.setSelection(xyChartSelection, toHistory)));
        selectionMap.entrySet().stream().findFirst().ifPresent(entry -> {
            ZonedDateTime newStartX = roundDateTime(entry.getValue().getStartX());
            ZonedDateTime newEndX = roundDateTime(entry.getValue().getEndX());
            boolean dontPlotChart = newStartX.isEqual(startX.get()) && newEndX.isEqual(endX.get());
            this.startX.set(newStartX);
            this.endX.set(newEndX);
            selectionMap.forEach((chart, xyChartSelection) -> get(chart).ifPresent(y -> y.setSelection(xyChartSelection, toHistory)));
            parent.invalidateAll(toHistory, dontPlotChart, false);
        });
        timeRange.set(TimeRangePicker.TimeRange.of(startX.getValue(), endX.getValue()));
    } finally {
        this.resumeAxisListeners();
    }
}
Also used : TimeRangePicker(eu.fthevenet.util.javafx.controls.TimeRangePicker) ReadOnlyObjectProperty(javafx.beans.property.ReadOnlyObjectProperty) ValueAxis(javafx.scene.chart.ValueAxis) ZonedDateTime(java.time.ZonedDateTime) HashMap(java.util.HashMap) Logger(org.apache.logging.log4j.Logger) ReadOnlyObjectWrapper(javafx.beans.property.ReadOnlyObjectWrapper) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) Map(java.util.Map) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) Optional(java.util.Optional) Chart(eu.fthevenet.binjr.data.workspace.Chart) XYChartSelection(eu.fthevenet.util.javafx.charts.XYChartSelection) ChangeListener(javafx.beans.value.ChangeListener) LogManager(org.apache.logging.log4j.LogManager) ZonedDateTime(java.time.ZonedDateTime)

Aggregations

Chart (eu.fthevenet.binjr.data.workspace.Chart)1 XYChartSelection (eu.fthevenet.util.javafx.charts.XYChartSelection)1 TimeRangePicker (eu.fthevenet.util.javafx.controls.TimeRangePicker)1 ZonedDateTime (java.time.ZonedDateTime)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ReadOnlyObjectProperty (javafx.beans.property.ReadOnlyObjectProperty)1 ReadOnlyObjectWrapper (javafx.beans.property.ReadOnlyObjectWrapper)1 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)1 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)1 ChangeListener (javafx.beans.value.ChangeListener)1 ValueAxis (javafx.scene.chart.ValueAxis)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1