|
@@ -5,12 +5,13 @@ import javax.swing.JPanel;
|
|
|
import classes.TrackedDataSet;
|
|
|
import ui.controller.Control;
|
|
|
import ui.model.Model;
|
|
|
+
|
|
|
import javax.swing.JLabel;
|
|
|
-import javax.swing.BoxLayout;
|
|
|
import javax.swing.JButton;
|
|
|
import javax.swing.SwingConstants;
|
|
|
import java.awt.BorderLayout;
|
|
|
import javax.swing.border.LineBorder;
|
|
|
+
|
|
|
import java.awt.Color;
|
|
|
import java.awt.Dimension;
|
|
|
import java.awt.event.ActionEvent;
|
|
@@ -45,7 +46,6 @@ public class StatisticGraphPanel extends JPanel {
|
|
|
*/
|
|
|
public StatisticGraphPanel(Model mod, Control cont, String name) {
|
|
|
super();
|
|
|
- setBorder(new LineBorder(new Color(0, 0, 0), 1, true));
|
|
|
this.model = mod;
|
|
|
this.controller = cont;
|
|
|
this.sGraph = new StatisticGraph(mod, cont);
|
|
@@ -53,36 +53,44 @@ public class StatisticGraphPanel extends JPanel {
|
|
|
setLayout(new BorderLayout(0, 0));
|
|
|
|
|
|
// ******************** Component Propertys ***************//
|
|
|
- //Graph Name
|
|
|
+ // Graph Name
|
|
|
graphNameLabel = new JLabel(graphName);
|
|
|
graphNameLabel.setHorizontalTextPosition(JLabel.CENTER);
|
|
|
|
|
|
- //Panel on top (Name and Close Button)
|
|
|
+ // Panel on top (Name and Close Button)
|
|
|
topPanel.setLayout(new BorderLayout(0, 0));
|
|
|
topPanel.add(graphNameLabel, BorderLayout.CENTER);
|
|
|
topPanel.add(closeButton, BorderLayout.EAST);
|
|
|
topPanel.setBorder(null);
|
|
|
-
|
|
|
- //Maximum Label
|
|
|
+
|
|
|
+ // Maximum Label
|
|
|
maximumLabel.setVerticalAlignment(SwingConstants.TOP);
|
|
|
- maximumLabel.setPreferredSize(new Dimension(30,10));
|
|
|
+ maximumLabel.setPreferredSize(new Dimension(30, 10));
|
|
|
// ******************** Component Listener ****************//
|
|
|
-
|
|
|
+
|
|
|
JPanel that = this;
|
|
|
closeButton.addActionListener(new ActionListener() {
|
|
|
@Override
|
|
|
public void actionPerformed(ActionEvent e) {
|
|
|
JPanel parent = (JPanel) that.getParent();
|
|
|
+ for (int i = 0; i < parent.getComponentCount(); i++) {
|
|
|
+ if (parent.getComponent(i).equals(that)) {
|
|
|
+ parent.remove(parent.getComponent(i+1));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
parent.remove(that);
|
|
|
- parent.revalidate();
|
|
|
+ parent.updateUI();
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// ******************** add everything ********************//
|
|
|
this.add(sGraph);
|
|
|
this.add(topPanel, BorderLayout.NORTH);
|
|
|
this.add(maximumLabel, BorderLayout.WEST);
|
|
|
this.add(Legendpanel, BorderLayout.SOUTH);
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -96,9 +104,10 @@ public class StatisticGraphPanel extends JPanel {
|
|
|
|
|
|
/**
|
|
|
* Repaint the Graph.
|
|
|
- *
|
|
|
- * public void repaint() { sGraph.repaint(); }
|
|
|
*/
|
|
|
+ public void repaintGraph() {
|
|
|
+ sGraph.repaint();
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* Set the Maximum Label
|