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);
}
});
}
}
Aggregations