Quellcode durchsuchen

graph deletes correct

Kevin Trometer vor 8 Jahren
Ursprung
Commit
9c4c0f8ec6
3 geänderte Dateien mit 25 neuen und 14 gelöschten Zeilen
  1. 2 0
      src/ui/view/StatisticGraph.java
  2. 21 12
      src/ui/view/StatisticGraphPanel.java
  3. 2 2
      src/ui/view/splitPane.java

+ 2 - 0
src/ui/view/StatisticGraph.java

@@ -58,6 +58,8 @@ public class StatisticGraph extends JPanel {
 		this.controller = control;
 		this.model = model;
 
+		
+	
 		this.setBackground(Color.WHITE);
 	}
 

+ 21 - 12
src/ui/view/StatisticGraphPanel.java

@@ -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

+ 2 - 2
src/ui/view/splitPane.java

@@ -352,11 +352,11 @@ public class splitPane extends JSplitPane implements GraphListener {
 					 }
 				 }
 				 */
-				 StatisticGraph tmp = new StatisticGraph(controller.getModel(), controller);
+				 StatisticGraphPanel tmp = new StatisticGraphPanel(controller.getModel(), controller, graphNrTxtField.getText());
 				 tmp.setPreferredSize(new Dimension(280,120));
 				 tmp.setMaximumSize(new Dimension(1000,120));
 				 tmp.setMinimumSize(new Dimension(100,45));
-				 tmp.setBorder(new LineBorder(new Color(0, 0, 0), 2));
+				 tmp.setBorder(new LineBorder(new Color(0, 0, 0), 1));
 				 graphPanel.add(tmp);
 				 graphPanel.add(Box.createRigidArea(new Dimension(50,50)));
 				 graphPanel.revalidate();