|
@@ -0,0 +1,83 @@
|
|
|
+package ui.view;
|
|
|
+
|
|
|
+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.SwingConstants;
|
|
|
+import java.awt.BorderLayout;
|
|
|
+
|
|
|
+public class StatisticGraphPanel extends JPanel {
|
|
|
+
|
|
|
+ private static final long serialVersionUID = 1L;
|
|
|
+
|
|
|
+ // Model/Controller
|
|
|
+ private Model model;
|
|
|
+ private Control controller;
|
|
|
+
|
|
|
+ // Components
|
|
|
+ private StatisticGraph sGraph;
|
|
|
+ private final JLabel graphNameLabel;
|
|
|
+ private final JLabel maximumLabel = new JLabel("0");
|
|
|
+
|
|
|
+ // Variables
|
|
|
+ String graphName;
|
|
|
+ private final JPanel Legendpanel = new JPanel();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Constructor.
|
|
|
+ *
|
|
|
+ * @param mod
|
|
|
+ * the Model
|
|
|
+ * @param cont
|
|
|
+ * the Controller
|
|
|
+ */
|
|
|
+ public StatisticGraphPanel(Model mod, Control cont, String name) {
|
|
|
+ super();
|
|
|
+ this.model = mod;
|
|
|
+ this.controller = cont;
|
|
|
+ this.sGraph = new StatisticGraph(mod, cont);
|
|
|
+ this.graphName = name;
|
|
|
+ setLayout(new BorderLayout(0, 0));
|
|
|
+
|
|
|
+ /**** add everything *****/
|
|
|
+ // Statistic Graph
|
|
|
+ this.add(sGraph);
|
|
|
+ // Graph Name
|
|
|
+ graphNameLabel = new JLabel(graphName);
|
|
|
+ graphNameLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
|
|
+ this.add(graphNameLabel, BorderLayout.NORTH);
|
|
|
+ // Y Maximum
|
|
|
+ maximumLabel.setVerticalAlignment(SwingConstants.TOP);
|
|
|
+ this.add(maximumLabel, BorderLayout.WEST);
|
|
|
+ // Legend Panel
|
|
|
+ add(Legendpanel, BorderLayout.SOUTH);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Adds the Set to the Graph.
|
|
|
+ *
|
|
|
+ * @param set
|
|
|
+ */
|
|
|
+ public void addObjec(TrackedDataSet set) {
|
|
|
+ sGraph.addObject(set);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Repaint the Graph.
|
|
|
+ *
|
|
|
+ * public void repaint() { sGraph.repaint(); }
|
|
|
+ */
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Set the Maximum Label
|
|
|
+ *
|
|
|
+ * @param max
|
|
|
+ */
|
|
|
+ public void setMaximumLabel(int max) {
|
|
|
+ maximumLabel.setText(Integer.toString(max));
|
|
|
+ }
|
|
|
+}
|