mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-24 22:48:34 +00:00
Added Refresh button to twa delta charts plotting
This commit is contained in:
+36
-1
@@ -3,9 +3,13 @@ package com.sap.sailing.windestimation.datavisualization;
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Shape;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.geom.Ellipse2D;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
@@ -40,27 +44,54 @@ public class SingleDimensionAggregatesPlottingFrame extends JFrame {
|
||||
private XYSeries valuesSeries;
|
||||
private XYSeries stdSeries;
|
||||
private XYSeries zeroMeanStdSeries;
|
||||
private final CountDownLatch windowClosedLatch = new CountDownLatch(1);
|
||||
|
||||
public SingleDimensionAggregatesPlottingFrame(
|
||||
AggregatedSingleDimensionBasedTwdTransitionPersistenceManager persistenceManager) {
|
||||
super(persistenceManager.getCollectionName());
|
||||
this.persistenceManager = persistenceManager;
|
||||
addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowClosed(WindowEvent event) {
|
||||
windowClosedLatch.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent e) {
|
||||
setLayout(null);
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
initializeDataWithCharts();
|
||||
}
|
||||
|
||||
private void initializeDataWithCharts() {
|
||||
createSeries();
|
||||
fillSeries();
|
||||
DefaultTableXYDataset mainDataset = createMainDataset();
|
||||
DefaultTableXYDataset histoDataset = createHistoDataset();
|
||||
mainChart = createMainChart(mainDataset);
|
||||
histoChart = createHistoChart(histoDataset);
|
||||
// Create Panel
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
ChartPanel mainChartPanel = new ChartPanel(mainChart);
|
||||
ChartPanel histoChartPanel = new ChartPanel(histoChart);
|
||||
JButton refreshButton = new JButton("Refresh charts");
|
||||
refreshButton.addActionListener(event -> refreshCharts());
|
||||
panel.add(refreshButton);
|
||||
panel.add(mainChartPanel);
|
||||
panel.add(histoChartPanel);
|
||||
setContentPane(panel);
|
||||
}
|
||||
|
||||
public void refreshCharts() {
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
initializeDataWithCharts();
|
||||
revalidate();
|
||||
});
|
||||
}
|
||||
|
||||
private void createSeries() {
|
||||
meanSeries = new XYSeries("Mean", true, false);
|
||||
medianSeries = new XYSeries("Median", true, false);
|
||||
@@ -191,4 +222,8 @@ public class SingleDimensionAggregatesPlottingFrame extends JFrame {
|
||||
});
|
||||
}
|
||||
|
||||
public void awaitWindowClosed() throws InterruptedException {
|
||||
windowClosedLatch.await();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user