Search in sources :

Example 1 with DelayedAction

use of eu.fthevenet.util.javafx.controls.DelayedAction in project selenium_java by sergueik.

the class WorksheetController method plotChart.

private void plotChart(ChartViewPort<Double> viewPort, XYChartSelection<ZonedDateTime, Double> currentSelection, boolean forceRefresh) {
    try (Profiler p = Profiler.start("Adding series to chart " + viewPort.getDataStore().getName(), logger::trace)) {
        worksheetMaskerPane.setVisible(true);
        AsyncTaskManager.getInstance().submit(() -> {
            viewPort.getDataStore().fetchDataFromSources(currentSelection.getStartX(), currentSelection.getEndX(), forceRefresh);
            return viewPort.getDataStore().getSeries().stream().filter(series -> {
                if (series.getProcessor() == null) {
                    logger.warn("Series " + series.getDisplayName() + " does not contain any data to plot");
                    return false;
                }
                if (!series.isSelected()) {
                    logger.debug(() -> "Series " + series.getDisplayName() + " is not selected");
                    return false;
                }
                return true;
            }).map(ts -> makeXYChartSeries(viewPort.getDataStore(), ts)).collect(Collectors.toList());
        }, event -> {
            if (!closed.get()) {
                worksheetMaskerPane.setVisible(false);
                viewPort.getChart().getData().setAll((Collection<? extends XYChart.Series<ZonedDateTime, Double>>) event.getSource().getValue());
                // Force a redraw of the charts and their Y Axis considering their proper width.
                new DelayedAction(() -> viewPort.getChart().resize(0.0, 0.0), Duration.millis(50)).submit();
            }
        }, event -> {
            if (!closed.get()) {
                worksheetMaskerPane.setVisible(false);
                Dialogs.notifyException("Failed to retrieve data from source", event.getSource().getException(), root);
            }
        });
    }
}
Also used : TimeRangePicker(eu.fthevenet.util.javafx.controls.TimeRangePicker) HPos(javafx.geometry.HPos) Pos(javafx.geometry.Pos) BindingManager(eu.fthevenet.util.javafx.bindings.BindingManager) Initializable(javafx.fxml.Initializable) DoubleBinding(javafx.beans.binding.DoubleBinding) javafx.scene.layout(javafx.scene.layout) Dialogs(eu.fthevenet.binjr.dialogs.Dialogs) CacheHint(javafx.scene.CacheHint) javafx.scene.control(javafx.scene.control) URL(java.net.URL) ZonedDateTime(java.time.ZonedDateTime) NoAdapterFoundException(eu.fthevenet.binjr.data.exceptions.NoAdapterFoundException) Side(javafx.geometry.Side) InvalidationListener(javafx.beans.InvalidationListener) ColorTableCell(eu.fthevenet.util.javafx.controls.ColorTableCell) MaskerPane(org.controlsfx.control.MaskerPane) ListChangeListener(javafx.collections.ListChangeListener) ImageIO(javax.imageio.ImageIO) eu.fthevenet.binjr.data.workspace(eu.fthevenet.binjr.data.workspace) DelayedAction(eu.fthevenet.util.javafx.controls.DelayedAction) USE_COMPUTED_SIZE(javafx.scene.layout.Region.USE_COMPUTED_SIZE) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) ReadOnlyDoubleProperty(javafx.beans.property.ReadOnlyDoubleProperty) AsyncTaskManager(eu.fthevenet.binjr.data.async.AsyncTaskManager) Group(javafx.scene.Group) Collectors(java.util.stream.Collectors) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) DataAdapter(eu.fthevenet.binjr.data.adapters.DataAdapter) Duration(javafx.util.Duration) Logger(org.apache.logging.log4j.Logger) TimeSeriesBinding(eu.fthevenet.binjr.data.adapters.TimeSeriesBinding) javafx.scene.chart(javafx.scene.chart) CheckBoxTableCell(javafx.scene.control.cell.CheckBoxTableCell) ObservableList(javafx.collections.ObservableList) Path(javafx.scene.shape.Path) Profiler(eu.fthevenet.util.logging.Profiler) java.util(java.util) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Bindings(javafx.beans.binding.Bindings) Function(java.util.function.Function) Supplier(java.util.function.Supplier) VPos(javafx.geometry.VPos) FXMLLoader(javafx.fxml.FXMLLoader) GlobalPreferences(eu.fthevenet.binjr.preferences.GlobalPreferences) TextAlignment(javafx.scene.text.TextAlignment) Chart(eu.fthevenet.binjr.data.workspace.Chart) DecimalFormatTableCellFactory(eu.fthevenet.util.javafx.controls.DecimalFormatTableCellFactory) Color(javafx.scene.paint.Color) javafx.scene.input(javafx.scene.input) Node(javafx.scene.Node) Property(javafx.beans.property.Property) WritableImage(javafx.scene.image.WritableImage) IOException(java.io.IOException) File(java.io.File) Consumer(java.util.function.Consumer) eu.fthevenet.util.javafx.charts(eu.fthevenet.util.javafx.charts) FileChooser(javafx.stage.FileChooser) ActionEvent(javafx.event.ActionEvent) Stage(javafx.stage.Stage) DateTimeFormatter(java.time.format.DateTimeFormatter) SwingFXUtils(javafx.embed.swing.SwingFXUtils) ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) LogManager(org.apache.logging.log4j.LogManager) Profiler(eu.fthevenet.util.logging.Profiler) ZonedDateTime(java.time.ZonedDateTime) DelayedAction(eu.fthevenet.util.javafx.controls.DelayedAction)

Aggregations

DataAdapter (eu.fthevenet.binjr.data.adapters.DataAdapter)1 TimeSeriesBinding (eu.fthevenet.binjr.data.adapters.TimeSeriesBinding)1 AsyncTaskManager (eu.fthevenet.binjr.data.async.AsyncTaskManager)1 NoAdapterFoundException (eu.fthevenet.binjr.data.exceptions.NoAdapterFoundException)1 eu.fthevenet.binjr.data.workspace (eu.fthevenet.binjr.data.workspace)1 Chart (eu.fthevenet.binjr.data.workspace.Chart)1 Dialogs (eu.fthevenet.binjr.dialogs.Dialogs)1 GlobalPreferences (eu.fthevenet.binjr.preferences.GlobalPreferences)1 BindingManager (eu.fthevenet.util.javafx.bindings.BindingManager)1 eu.fthevenet.util.javafx.charts (eu.fthevenet.util.javafx.charts)1 ColorTableCell (eu.fthevenet.util.javafx.controls.ColorTableCell)1 DecimalFormatTableCellFactory (eu.fthevenet.util.javafx.controls.DecimalFormatTableCellFactory)1 DelayedAction (eu.fthevenet.util.javafx.controls.DelayedAction)1 TimeRangePicker (eu.fthevenet.util.javafx.controls.TimeRangePicker)1 Profiler (eu.fthevenet.util.logging.Profiler)1 File (java.io.File)1 IOException (java.io.IOException)1 URL (java.net.URL)1 ZonedDateTime (java.time.ZonedDateTime)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1