Sfoglia il codice sorgente

multiple elements graph

Kevin Trometer 8 anni fa
parent
commit
e21824e764
1 ha cambiato i file con 9 aggiunte e 7 eliminazioni
  1. 9 7
      src/ui/view/UnitGraph.java

+ 9 - 7
src/ui/view/UnitGraph.java

@@ -19,6 +19,8 @@ import java.awt.Point;
 
 import javax.swing.JPanel;
 
+import com.sun.org.apache.xerces.internal.util.SynchronizedSymbolTable;
+
 import classes.HolonElement;
 import ui.controller.Control;
 import ui.model.Model;
@@ -102,9 +104,6 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 
 		if (isElement) {
 			if (arrayOfFloats != null) {
-				// array fillen
-				fillArrayofValue();
-
 				// Draw the Lines
 				g2.setStroke(new BasicStroke(2));
 				g2.setColor(Color.BLACK);
@@ -315,7 +314,7 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 					&& (tempP.getX() != this.getWidth() / scaleX || tempP != pointList.getLast())) {
 				pointList.remove(tempP);
 			}
-
+			
 			repaint();
 		}
 	}
@@ -398,6 +397,8 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 			pointDrag = false;
 			tempP = null;
 		}
+		// array fillen
+		fillArrayofValue();
 	}
 
 	public void componentResized(ComponentEvent e) {
@@ -569,14 +570,15 @@ class UnitGraph extends JPanel implements MouseListener, MouseMotionListener, Co
 	/**
 	 * Fills the Arrays of each HolonElement
 	 */
+	@SuppressWarnings("unchecked")
 	public void fillArrayofValue() {
 		for (HolonElement he : tempElements) {
 			MAXIMUM = he.getEnergy();
-			arrayOfFloats = he.getEnergyAt();
-			he.setGraphPoints(pointList);
+			he.setGraphPoints((LinkedList<Point>) pointList.clone());
 			for (int i = 0; i < arrayOfFloats.length; i++) {
-				arrayOfFloats[i] = convertToValueY(getYValueAt_2((int) (i * width / (model.getIterations() - 1))));
+				he.getEnergyAt()[i] = convertToValueY(getYValueAt_2((int) (i * width / (model.getIterations() - 1))));
 			}
+			arrayOfFloats = he.getEnergyAt();
 		}
 	}