Kevin Trometer vor 8 Jahren
Ursprung
Commit
fd9b8a6937
2 geänderte Dateien mit 11 neuen und 29 gelöschten Zeilen
  1. 8 7
      src/ui/view/StatisticGraph.java
  2. 3 22
      src/ui/view/StatisticGraphPanel.java

+ 8 - 7
src/ui/view/StatisticGraph.java

@@ -57,7 +57,7 @@ public class StatisticGraph extends JPanel {
 	public StatisticGraph(final Model model, Control control) {
 		this.controller = control;
 		this.model = model;
-	
+		
 		this.setBackground(Color.WHITE);
 	}
 
@@ -94,6 +94,7 @@ public class StatisticGraph extends JPanel {
 
 			// Calculate the Maximum
 			calcMaximum();
+			((StatisticGraphPanel)this.getParent()).setMaximumLabel(maximum);
 
 			// Calculate values for each set and add them
 			addValues();
@@ -181,7 +182,7 @@ public class StatisticGraph extends JPanel {
 			case TrackedDataSet.CONSUMPTION:
 				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
 					if (h.getEnergy() < 0) {
-						val += h.getEnergy();
+						val += h.getEnergy()*h.getAmount();
 					}
 				}
 				val *= -1;
@@ -189,7 +190,7 @@ public class StatisticGraph extends JPanel {
 			case TrackedDataSet.PRODUCTION:
 				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
 					if (h.getEnergy() > 0) {
-						val += h.getEnergy();
+						val += h.getEnergy()*h.getAmount();
 					}
 				}
 
@@ -220,16 +221,16 @@ public class StatisticGraph extends JPanel {
 			switch (set.getProperty()) {
 			case TrackedDataSet.CONSUMPTION:
 				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
-					if (h.getEnergy() < 0) {
-						val += Math.abs(h.getEnergyAt()[model.getCurIteration()]);
+					if (h.getEnergy() < 0 && h.getActive()) {
+						val += Math.abs(h.getEnergyAt()[model.getCurIteration()])*h.getAmount();
 					}
 					set.setValAt(val, model.getCurIteration());
 				}
 				break;
 			case TrackedDataSet.PRODUCTION:
 				for (HolonElement h : ((HolonObject) set.getCpsObject()).getElements()) {
-					if (h.getEnergy() > 0) {
-						val += Math.abs(h.getEnergyAt()[model.getCurIteration()]);
+					if (h.getEnergy() > 0 && h.getActive()) {
+						val += Math.abs(h.getEnergyAt()[model.getCurIteration()])*h.getAmount();
 					}
 					set.setValAt(val, model.getCurIteration());
 				}

+ 3 - 22
src/ui/view/StatisticGraphPanel.java

@@ -12,9 +12,7 @@ import javax.swing.SwingConstants;
 import javax.swing.Timer;
 
 import java.awt.BorderLayout;
-import javax.swing.border.LineBorder;
 
-import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
@@ -67,7 +65,7 @@ public class StatisticGraphPanel extends JPanel {
 
 		// Maximum Label
 		maximumLabel.setVerticalAlignment(SwingConstants.TOP);
-		maximumLabel.setPreferredSize(new Dimension(30, 10));
+		maximumLabel.setMinimumSize(new Dimension(30, 10));
 		// ******************** Component Listener ****************//
 
 		JPanel that = this;
@@ -91,16 +89,6 @@ public class StatisticGraphPanel extends JPanel {
 		this.add(topPanel, BorderLayout.NORTH);
 		this.add(maximumLabel, BorderLayout.WEST);
 		this.add(Legendpanel, BorderLayout.SOUTH);
-
-		Timer t = new Timer(200, new ActionListener() {
-
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				that.repaint();
-			}
-		});
-		t.start();
-
 	}
 
 	/**
@@ -112,20 +100,13 @@ public class StatisticGraphPanel extends JPanel {
 		sGraph.addObject(set);
 	}
 
-	/**
-	 * Repaint the Graph.
-	 */
-	public void repaintGraph() {
-		sGraph.repaint();
-	}
-
 	/**
 	 * Set the Maximum Label
 	 *
 	 * @param max
 	 */
-	public void setMaximumLabel(int max) {
-		maximumLabel.setText(Integer.toString(max));
+	public void setMaximumLabel(double max) {
+		maximumLabel.setText(Double.toString(max));
 	}
 
 	/**