|
@@ -12,10 +12,14 @@ import javax.swing.SwingConstants;
|
|
|
import javax.swing.Timer;
|
|
|
|
|
|
import java.awt.BorderLayout;
|
|
|
-
|
|
|
+import java.awt.Color;
|
|
|
import java.awt.Dimension;
|
|
|
+import java.awt.FlowLayout;
|
|
|
import java.awt.event.ActionEvent;
|
|
|
import java.awt.event.ActionListener;
|
|
|
+import java.awt.event.MouseAdapter;
|
|
|
+import java.awt.event.MouseEvent;
|
|
|
+import java.awt.event.MouseListener;
|
|
|
import java.util.Hashtable;
|
|
|
|
|
|
public class StatisticGraphPanel extends JPanel {
|
|
@@ -35,7 +39,7 @@ public class StatisticGraphPanel extends JPanel {
|
|
|
|
|
|
// Variables
|
|
|
String graphName;
|
|
|
- private final JPanel Legendpanel = new JPanel();
|
|
|
+ private final JPanel legendPanel = new JPanel();
|
|
|
private JPanel that;
|
|
|
private Hashtable<String, StatisticGraphPanel> graphHashtable;
|
|
|
|
|
@@ -70,6 +74,10 @@ public class StatisticGraphPanel extends JPanel {
|
|
|
// Maximum Label
|
|
|
maximumLabel.setVerticalAlignment(SwingConstants.TOP);
|
|
|
maximumLabel.setMinimumSize(new Dimension(30, 10));
|
|
|
+
|
|
|
+ // Legend Panel
|
|
|
+ makeLegendPanel();
|
|
|
+
|
|
|
// ******************** Component Listener ****************//
|
|
|
|
|
|
that = this;
|
|
@@ -93,7 +101,8 @@ public class StatisticGraphPanel extends JPanel {
|
|
|
this.add(sGraph);
|
|
|
this.add(topPanel, BorderLayout.NORTH);
|
|
|
this.add(maximumLabel, BorderLayout.WEST);
|
|
|
- this.add(Legendpanel, BorderLayout.SOUTH);
|
|
|
+ this.add(legendPanel, BorderLayout.SOUTH);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -122,4 +131,26 @@ public class StatisticGraphPanel extends JPanel {
|
|
|
public String getGraphName() {
|
|
|
return this.graphName;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Make the LegendPane.
|
|
|
+ */
|
|
|
+ public void makeLegendPanel() {
|
|
|
+ for (TrackedDataSet set: sGraph.objects) {
|
|
|
+ JLabel b = new JLabel(set.getCpsObject().getName());
|
|
|
+ b.setBackground(Color.CYAN);
|
|
|
+ b.setOpaque(true);
|
|
|
+ JPanel p = new JPanel();
|
|
|
+ p.add(b);
|
|
|
+ b.addMouseListener(new MouseAdapter() {
|
|
|
+ @Override
|
|
|
+ public void mousePressed(MouseEvent e) {
|
|
|
+ if (e.BUTTON3 == e.getButton())
|
|
|
+ legendPanel.remove(p);
|
|
|
+ that.updateUI();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ legendPanel.add(p);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|