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.JButton; import javax.swing.SwingConstants; import java.awt.BorderLayout; import javax.swing.border.LineBorder; import java.awt.Color; 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"); private JPanel topPanel = new JPanel(); private JButton closeButton = new JButton("X"); // 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(); setBorder(new LineBorder(new Color(0, 0, 0), 1, true)); 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 and Close Button graphNameLabel = new JLabel(graphName); topPanel.add(graphNameLabel); topPanel.add(closeButton); topPanel.setBorder(null); this.add(topPanel, 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)); } }