Browse Source

Vector2dInt integration

TomTroppmann 3 years ago
parent
commit
63ab96653a

+ 7 - 0
src/classes/Vector2dFloat.java

@@ -96,6 +96,13 @@ public class Vector2dFloat {
 		result.setY(y * scaleFactor);
 		return result;
 	}
+	public Vector2dFloat divide(float divideFactor)
+	{
+		Vector2dFloat result = new Vector2dFloat();
+		result.setX(x / divideFactor);
+		result.setY(y / divideFactor);
+		return result;
+	}
 
 	public Vector2dFloat normalize()
 	{

+ 17 - 3
src/classes/Vector2dInt.java

@@ -45,6 +45,11 @@ public class Vector2dInt {
 		setX(x);
 		setY(y);
 	}
+	public void set(Vector2dInt other)
+	{
+		setX(other.x);
+		setY(other.y);
+	}
 
 
 	public float dot(Vector2dInt other)
@@ -97,14 +102,19 @@ public class Vector2dInt {
 		return result;
 	}
 
-	public Vector2dInt multiply(int scaleFactor)
+	public Vector2dInt multiply(float scaleFactor)
 	{
 		Vector2dInt result = new Vector2dInt();
-		result.setX(x * scaleFactor);
-		result.setY(y * scaleFactor);
+		result.setX((int)(x * scaleFactor));
+		result.setY((int)(y * scaleFactor));
 		return result;
 	}
 	
+	public Vector2dInt divide(float divideFactor)
+	{
+		return this.multiply(1.0f/divideFactor);
+	}
+	
 	/**
 	 * Clamp the X Value two a upper or lower bound
 	 * @param min lower bound
@@ -131,4 +141,8 @@ public class Vector2dInt {
 	{
 		return "X: " + x + " Y: " + y;
 	}
+	
+	public Vector2dInt clone() {
+		return new Vector2dInt(x, y);
+	}
 }

+ 1 - 1
src/ui/controller/CanvasController.java

@@ -220,7 +220,7 @@ public class CanvasController {
 			} else {
 				tCps = new Node("Node");
 			}
-			tCps.setPosition(new Vector2dInt(p.x + (cps.getPosition().x - x), p.y + (cps.getPosition().y - y)));
+			tCps.setPosition(new Vector2dInt(p.x + (cps.getPosition().getX() - x), p.y + (cps.getPosition().getY() - y)));
 			tCps.setSav(cps.getSav());
 			tempList.add(tCps);
 			addObject(tCps, false);

+ 3 - 3
src/ui/controller/ClipboardController.java

@@ -131,7 +131,7 @@ public class ClipboardController {
         sav = json.get("SAV").getAsString();
 
         Vector2dInt old = model.getGson().getAdapter(Vector2dInt.class).fromJsonTree(json.get("CENTER"));
-        point = new Point(old.x - p.x, old.y - p.y);
+        point = new Point(old.getX() - p.x, old.getY() - p.y);
 
         forwardObjects(keys, json, objDispatch, eleDispatch, upperNode);
         // for selecting Cps
@@ -422,8 +422,8 @@ public class ClipboardController {
     }
 
     private void updatePosition(AbstractCanvasObject temp, GroupNode upperNode) {
-        int x = temp.getPosition().x - point.x;
-        int y = temp.getPosition().y - point.y;
+        int x = temp.getPosition().getX() - point.x;
+        int y = temp.getPosition().getY() - point.y;
 
         if (y < 0)
             y = 0 + model.getScaleDiv2() + 1;

+ 9 - 13
src/ui/controller/NodeController.java

@@ -49,7 +49,7 @@ class NodeController {
     	}
 		Vector2dInt old = calculatePos(node.getNodes());
 		Vector2dInt p = node.getPosition();
-		point = new Point(old.x - p.x, old.y - p.y);
+		point = new Point(old.getX() - p.getX(), old.getY() - p.getY());
 
 		unmakeNodesOfNodes(node, upperNode);
 		if (upperNode == null)
@@ -134,13 +134,9 @@ class NodeController {
 
 		// sum(x0 .. xn) / numOfPos, y analog
 		for (AbstractCanvasObject abs : toGroup) {
-			pos.x += abs.getPosition().x;
-			pos.y += abs.getPosition().y;
+			pos = pos.add(abs.getPosition());
 		}
-		pos.x /= toGroup.size();
-		pos.y /= toGroup.size();
-
-		return pos;
+		return pos.divide(toGroup.size());
 	}
 
 	/**
@@ -180,10 +176,10 @@ class NodeController {
 		 */
 		if(replace && !(object instanceof Node) ){
 			/** x of the dragged Object */
-			int x = object.getPosition().x;
+			int x = object.getPosition().getX();
 		
 			/** y of the dragged Object */
-			int y = object.getPosition().y;
+			int y = object.getPosition().getY();
 			
 			/** distance threshold for replacement */
 			int treshhold = model.getScale()/2;
@@ -201,10 +197,10 @@ class NodeController {
 				if(cps == object)continue;
 			
 				/** x of object that might get replaced */
-				int c_x = cps.getPosition().x;
+				int c_x = cps.getPosition().getX();
 				
 				/** y of object that might get replaced */
-				int c_y = cps.getPosition().y;
+				int c_y = cps.getPosition().getY();
 				
 				/** if near enough */
 				if(Math.abs(x-c_x)<treshhold && Math.abs(y-c_y)<treshhold){
@@ -272,8 +268,8 @@ class NodeController {
 	 * If Position is out of boundaries adjust it
 	 */
 	private void updatePosition(AbstractCanvasObject temp, GroupNode upperNode) {
-		int x = temp.getPosition().x - point.x;
-		int y = temp.getPosition().y - point.y;
+		int x = temp.getPosition().getX() - point.x;
+		int y = temp.getPosition().getY() - point.y;
 
 		if (y < 0)
 			y = 0 + model.getScaleDiv2() + 1;

+ 20 - 20
src/ui/view/AbstractCanvas.java

@@ -142,8 +142,8 @@ public abstract class AbstractCanvas extends JPanel {
 			// width
 
 			// fixed x and y Position to the screen
-			int fixXPos = toolTipPos.x - (textWidth >> 1) + model.getScaleDiv2();
-			int fixYPos = toolTipPos.y;
+			int fixXPos = toolTipPos.getX() - (textWidth >> 1) + model.getScaleDiv2();
+			int fixYPos = toolTipPos.getY();
 
 			if (fixXPos < 0) {
 				fixXPos = 0;
@@ -225,19 +225,19 @@ public abstract class AbstractCanvas extends JPanel {
 	int[] determineMousePositionOnEdge(Edge p) {
 		int lx, ly, hx, hy;
 
-		if (p.getA().getPosition().x > p.getB().getPosition().x) {
-			hx = p.getA().getPosition().x + model.getScaleDiv2() + 7;
-			lx = p.getB().getPosition().x + model.getScaleDiv2() - 7;
+		if (p.getA().getPosition().getX() > p.getB().getPosition().getX()) {
+			hx = p.getA().getPosition().getX() + model.getScaleDiv2() + 7;
+			lx = p.getB().getPosition().getX() + model.getScaleDiv2() - 7;
 		} else {
-			lx = p.getA().getPosition().x + model.getScaleDiv2() - 7;
-			hx = p.getB().getPosition().x + model.getScaleDiv2() + 7;
+			lx = p.getA().getPosition().getX() + model.getScaleDiv2() - 7;
+			hx = p.getB().getPosition().getX() + model.getScaleDiv2() + 7;
 		}
-		if (p.getA().getPosition().y > p.getB().getPosition().y) {
-			hy = p.getA().getPosition().y + model.getScaleDiv2() + 7;
-			ly = p.getB().getPosition().y + model.getScaleDiv2() - 7;
+		if (p.getA().getPosition().getY() > p.getB().getPosition().getY()) {
+			hy = p.getA().getPosition().getY() + model.getScaleDiv2() + 7;
+			ly = p.getB().getPosition().getY() + model.getScaleDiv2() - 7;
 		} else {
-			ly = p.getA().getPosition().y + model.getScaleDiv2() - 7;
-			hy = p.getB().getPosition().y + model.getScaleDiv2() + 7;
+			ly = p.getA().getPosition().getY() + model.getScaleDiv2() - 7;
+			hy = p.getB().getPosition().getY() + model.getScaleDiv2() + 7;
 		}
 
 		return new int[] { lx, ly, hx, hy };
@@ -268,8 +268,8 @@ public abstract class AbstractCanvas extends JPanel {
 	boolean setToolTipInfoAndPosition(boolean on, AbstractCanvasObject cps) {
 		if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
 			on = true;
-			toolTipPos.x = cps.getPosition().x - controller.getScaleDiv2();
-			toolTipPos.y = cps.getPosition().y + controller.getScaleDiv2();
+			toolTipPos.setX(cps.getPosition().getX() - controller.getScaleDiv2());
+			toolTipPos.setY(cps.getPosition().getY() + controller.getScaleDiv2());
 			toolTipText = cps.getName() + ", " + cps.getId();
 		}
 
@@ -319,7 +319,7 @@ public abstract class AbstractCanvas extends JPanel {
 				p = cps.getPosition();
 				
 				/** if near enough */
-				if(Math.abs(x-p.x)<treshhold && Math.abs(y-p.y)<treshhold){
+				if(Math.abs(x-p.getX())<treshhold && Math.abs(y-p.getY())<treshhold){
 					replaceCounter++;
 					toBeReplaced = cps;
 					
@@ -362,9 +362,9 @@ public abstract class AbstractCanvas extends JPanel {
 		if(mayBeReplaced != null){
 			g2.setColor(Color.RED);
 			g2.fillRect(
-					(int) (mayBeReplaced.getPosition().x
+					(int) (mayBeReplaced.getPosition().getX()
 							- controller.getScaleDiv2() - (scalediv20 + 3)),
-					(int) (mayBeReplaced.getPosition().y
+					(int) (mayBeReplaced.getPosition().getY()
 							- controller.getScaleDiv2() - (scalediv20 + 3)),
 					(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
 					(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
@@ -387,10 +387,10 @@ public abstract class AbstractCanvas extends JPanel {
 		
 		//calculate how many pixels the cps should be decreased to align
 		/** x offset relative to a grid with lines every distance pixels */
-		int x_off = cps.getPosition().x % distance;
+		int x_off = cps.getPosition().getX() % distance;
 		
 		/** y offset relative to a grid with lines every distance pixels */
-		int y_off = cps.getPosition().y % distance;
+		int y_off = cps.getPosition().getY() % distance;
 		
 		//align to the other Line, if it is nearer
 		if(x_off > distance/2)
@@ -399,7 +399,7 @@ public abstract class AbstractCanvas extends JPanel {
 			y_off -= distance;
 		
 		/** set new Position */
-		cps.setPosition(p.x-x_off, p.y-y_off);
+		cps.setPosition(p.getX()-x_off, p.getY()-y_off);
 	}
 	
 	/**

+ 75 - 86
src/ui/view/GroupNodeCanvas.java

@@ -84,9 +84,9 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
         // Cps objecte aus dem border links schieben
         upperNode.setLeftBorder(/*(int) (50 + scalediv20 + scalediv20 + 10)*/ 0);
         for (AbstractCanvasObject cps : upperNode.getNodes()) {
-            if (cps.getPosition().x < model.getScaleDiv2() + upperNode.getLeftBorder() + 5) {
+            if (cps.getPosition().getX() < model.getScaleDiv2() + upperNode.getLeftBorder() + 5) {
                 cps.setPosition(
-                        new Vector2dInt(upperNode.getLeftBorder() + 5 + model.getScaleDiv2(), cps.getPosition().y));
+                        new Vector2dInt(upperNode.getLeftBorder() + 5 + model.getScaleDiv2(), cps.getPosition().getY()));
             }
         }
 
@@ -126,27 +126,23 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
             animCps = new ArrayList<>();
             for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
                 animCps.add(cps); // add to animation Cps ArrayList
-                unPos.x += cps.getPosition().x;
-                unPos.y += cps.getPosition().y;
+                unPos = unPos.add(cps.getPosition());
             }
-            unPos.x /= animCps.size();
-            unPos.y /= animCps.size();
+            unPos = unPos.divide(animCps.size());
 
             // save old Position
             savePos = new ArrayList<>();
             for (int i = 0; i < animCps.size(); i++) {
-                savePos.add(new Vector2dInt(0, 0));
-                savePos.get(i).x = animCps.get(i).getPosition().x;
-                savePos.get(i).y = animCps.get(i).getPosition().y;
+                savePos.add(animCps.get(i).getPosition().clone());
             }
 
             animT = new javax.swing.Timer(animDelay, actionEvent1 -> {
                 if (animDuration - animDelay > 0 && animCps.size() > 1) {
                     for (AbstractCanvasObject currentAnimCps : animCps) {
-                        double x1 = currentAnimCps.getPosition().x - unPos.x;
-                        double y1 = currentAnimCps.getPosition().y - unPos.y;
-                        currentAnimCps.getPosition().x -= x1 / animSteps;
-                        currentAnimCps.getPosition().y -= y1 / animSteps;
+                    	Vector2dInt pos = currentAnimCps.getPosition();
+                    	Vector2dInt difference = pos.subtract(unPos);
+                    	Vector2dInt result = pos.subtract(difference.divide(animSteps));
+                    	pos.set(result);
                     }
                     repaint();
                     animDuration -= animDelay;
@@ -156,8 +152,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
                     animSteps = animDuration / animDelay;
                     animT.stop();
                     for (int i = 0; i < animCps.size(); i++) {
-                        animCps.get(i).getPosition().x = savePos.get(i).x;
-                        animCps.get(i).getPosition().y = savePos.get(i).y;
+                        animCps.get(i).getPosition().set(savePos.get(i));
                     }
                     controller.addUpperNode("GroupNode", upperNode, model.getSelectedCpsObjects());
                     controller.calculateStateAndVisualForCurrentTimeStep();
@@ -176,24 +171,19 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
             controller.ungroupGroupNode((GroupNode) tempCps, upperNode);
 
             for (int i = 0; i < animCps.size(); i++) {
-                savePos.add(new Vector2dInt(0, 0));
-                savePos.get(i).x = animCps.get(i).getPosition().x;
-                savePos.get(i).y = animCps.get(i).getPosition().y;
+                savePos.add(animCps.get(i).getPosition().clone());
             }
             for (AbstractCanvasObject cps : animCps) {
-                int x = tempCps.getPosition().x;
-                int y = tempCps.getPosition().y;
-
-                cps.setPosition(new Vector2dInt(x, y));
+                cps.setPosition(tempCps.getPosition().clone());
             }
 
             animT = new javax.swing.Timer(animDelay, actionEvent1 -> {
                 if (animDuration - animDelay >= 0) {
                     for (int i = 0; i < animCps.size(); i++) {
-                        double x1 = animCps.get(i).getPosition().x - savePos.get(i).x;
-                        double y1 = animCps.get(i).getPosition().y - savePos.get(i).y;
-                        animCps.get(i).getPosition().x -= x1 / animSteps;
-                        animCps.get(i).getPosition().y -= y1 / animSteps;
+                        Vector2dInt pos = animCps.get(i).getPosition();
+                    	Vector2dInt difference = pos.subtract(savePos.get(i));
+                    	Vector2dInt result = pos.subtract(difference.divide(animSteps));
+                    	pos.set(result);
                     }
                     repaint();
                     animDuration -= animDelay;
@@ -203,8 +193,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
                     animSteps = animDuration / animDelay;
                     animT.stop();
                     for (int i = 0; i < animCps.size(); i++) {
-                        animCps.get(i).getPosition().x = savePos.get(i).x;
-                        animCps.get(i).getPosition().y = savePos.get(i).y;
+                        animCps.get(i).getPosition().set(savePos.get(i));
                     }
 
                     controller.calculateStateAndVisualForCurrentTimeStep();
@@ -308,13 +297,13 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		Vector2dInt pos = decoratedHolonObject.getModel().getPosition();
 		Color statecolor = getStateColor(decoratedHolonObject.getState());
 		g.setColor(statecolor);
-		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
+		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
 		drawCanvasObject(g, decoratedHolonObject.getModel().getImage(), pos);
 	}
 	private void drawCanvasObjectString(Graphics2D g, Vector2dInt posOfCanvasObject, float energy) {
 		g.setColor(Color.BLACK);
 		g.setFont(new Font("TimesNewRoman", Font.PLAIN, (int) (controller.getScale() / 4f) )); 
-		g.drawString((energy > 0)? "+" + Float.toString(energy): Float.toString(energy), posOfCanvasObject.x - controller.getScaleDiv2(), posOfCanvasObject.y - controller.getScaleDiv2() - 1);
+		g.drawString((energy > 0)? "+" + Float.toString(energy): Float.toString(energy), posOfCanvasObject.getX() - controller.getScaleDiv2(), posOfCanvasObject.getY() - controller.getScaleDiv2() - 1);
 	}
 	private void paintConsumer(Graphics2D g, Consumer con){
 		paintCanvasObject(g, con);
@@ -328,8 +317,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 	
 	private void drawCanvasObject(Graphics2D g, String Image, Vector2dInt pos) {
 		g.drawImage(ImageImport.loadImage(Image, controller.getScale(), controller.getScale()) , 
-				pos.x - controller.getScaleDiv2(),
-				pos.y - controller.getScaleDiv2(),
+				pos.getX() - controller.getScaleDiv2(),
+				pos.getY() - controller.getScaleDiv2(),
 				controller.getScale(), controller.getScale() , null);
 	}
 	
@@ -353,10 +342,10 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		if(isSelected){
 			g.setColor(Color.lightGray);
 		}
-		g.drawLine(start.x, start.y, end.x, end.y);
-		Vector2dInt middle = new Vector2dInt((start.x + end.x) / 2, (start.y + end.y) / 2);
+		g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
+		Vector2dInt middle = new Vector2dInt((start.getX() + end.getX()) / 2, (start.getY() + end.getY()) / 2);
 		g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) )); 
-		g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.x, middle.y);
+		g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.getX(), middle.getY());
 	}
 	private void paintSwitch(Graphics2D g, DecoratedSwitch dSwitch)
 	{
@@ -365,7 +354,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 	private void paintGroupNode(Graphics2D g, DecoratedGroupNode dGroupNode) {
 		Vector2dInt pos = dGroupNode.getModel().getPosition();
 		g.setColor(Color.lightGray);
-		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
+		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
 		drawCanvasObject(g, "/Images/upper_node.png" , pos);
 		paintGroupNodeBar(g, dGroupNode, pos);
 	}
@@ -374,7 +363,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		int barWidth = (int) (controller.getScale());
 		int barHeight = (int) (controller.getScale() / 5);
 		g.setColor(Color.WHITE);
-		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
+		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
 		float[] percentages = getGroupNodeBarPercentages(dGroupNode);
 		Color[] colors = new Color[6];
 		colors[0] = getStateColor(HolonObjectState.PRODUCER);
@@ -386,13 +375,13 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 				
 		for(int i = 5; i>=0; i--) {
 			g.setColor(colors[i]);
-			g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) (barWidth * percentages[i] - 1), barHeight);		
+			g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) (barWidth * percentages[i] - 1), barHeight);		
 		}
 //		g.setColor(color);
-//		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
+//		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
 		g.setColor(Color.BLACK);
 		g.setStroke(new BasicStroke(1));
-		g.drawRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
+		g.drawRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
 	}
 	/**
 	 * HardCoded Stuff dont try at Home ;)
@@ -440,23 +429,23 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		switch(eCable.getState()) {
 		case DOWN:
 		case DOWNDOWN:
-			g.drawLine(start.x, start.y, end.x, end.y);
-			Vector2dInt middle = new Vector2dInt((start.x + end.x) / 2, (start.y + end.y) / 2);
+			g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
+			Vector2dInt middle = new Vector2dInt((start.getX() + end.getX()) / 2, (start.getY() + end.getY()) / 2);
 			g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) )); 
-			g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.x, middle.y);
+			g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.getX(), middle.getY());
 			break;
 		case DOWNUP:
 		case UP:
-			Vector2dFloat vStart = new Vector2dFloat(start.x, start.y);
-			Vector2dFloat vEnd = new Vector2dFloat(end.x, end.y);
+			Vector2dFloat vStart = new Vector2dFloat(start.getX(), start.getY());
+			Vector2dFloat vEnd = new Vector2dFloat(end.getX(), end.getY());
 			float stretchFactor = 4 * model.getScale();
 			stretchFactor =  (stretchFactor > vStart.getDistance(vEnd))? vStart.getDistance(vEnd) : stretchFactor;
 			Vector2dFloat vPosition = vStart.add((vEnd.subtract(vStart)).normalize().multiply(stretchFactor));
 			Vector2dInt result = new Vector2dInt(Math.round(vPosition.getX()),Math.round(vPosition.getY()));
-			g.drawLine(start.x, start.y, result.x, result.y);
-			Vector2dInt middle1 = new Vector2dInt((start.x +result.x) / 2, (start.y + +result.y) / 2);
+			g.drawLine(start.getX(), start.getY(), result.getX(), result.getY());
+			Vector2dInt middle1 = new Vector2dInt((start.getX() +result.getX()) / 2, (start.getY() + +result.getY()) / 2);
 			g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) )); 
-			g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle1.x, middle1.y);
+			g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle1.getX(), middle1.getY());
 			drawCanvasObject(g, "/Images/arrowUp.png" , result);
 			break;
 		default:
@@ -469,17 +458,17 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		int barWidth = (int) (controller.getScale());
 		int barHeight = (int) (controller.getScale() / 5);
 		g.setColor(Color.WHITE);
-		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
+		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
 		g.setColor(color);
-		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
+		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
 		g.setColor(Color.BLACK);
 		g.setStroke(new BasicStroke(1));
-		g.drawRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
+		g.drawRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
 		g.setFont(new Font("TimesNewRoman", Font.PLAIN, (int) (barHeight * 1.5) - 2)); 
 		String percentageString = (Math.round((percentage * 100))) + "%";
 		int stringWidth = (int) g.getFontMetrics().getStringBounds(percentageString, g).getWidth();
 		if(percentage > 1.0f) g.setColor(Color.WHITE); //Just to see better on purple
-		g.drawString(percentageString, pos.x + 1 - stringWidth / 2, pos.y + controller.getScaleDiv2() - 1+ barHeight);
+		g.drawString(percentageString, pos.getX() + 1 - stringWidth / 2, pos.getY() + controller.getScaleDiv2() - 1+ barHeight);
 		
 	}
 	
@@ -513,7 +502,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		if (drawEdge) {
 			g2d.setColor(Color.BLACK);
 			g2d.setStroke(new BasicStroke(1));
-			g2d.drawLine(tempCps.getPosition().x, tempCps.getPosition().y, x, y);
+			g2d.drawLine(tempCps.getPosition().getX(), tempCps.getPosition().getY(), x, y);
 		}
 		//<--
 		//SelectedCable
@@ -570,18 +559,18 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 			if(aCps instanceof Node) {
 				Vector2dInt pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
-				g2d.fillOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
+				g2d.fillOval(pos.getX() - (int) (controller.getScaleDiv2()), pos.getY() - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 				g2d.setColor(Color.LIGHT_GRAY);
 				g2d.setStroke(new BasicStroke(2));
-				g2d.drawOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
+				g2d.drawOval(pos.getX() - (int) (controller.getScaleDiv2()), pos.getY() - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 			}
 			else {
 				Vector2dInt pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
-				g2d.fillRect(pos.x - (int) (controller.getScaleDiv2()* 1.5f), pos.y - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
+				g2d.fillRect(pos.getX() - (int) (controller.getScaleDiv2()* 1.5f), pos.getY() - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
 				g2d.setColor(Color.LIGHT_GRAY);
 				g2d.setStroke(new BasicStroke(2));
-				g2d.drawRect(pos.x - (int) (controller.getScaleDiv2()* 1.5f), pos.y - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));				
+				g2d.drawRect(pos.getX() - (int) (controller.getScaleDiv2()* 1.5f), pos.getY() - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));				
 			}
 
 		}
@@ -590,8 +579,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 			g2d.setColor(Color.RED);
 			Vector2dInt pos = mayBeReplaced.getPosition();
 			g.drawImage(ImageImport.loadImage("/Images/replace.png") , 
-					pos.x + controller.getScaleDiv2(),
-					pos.y - controller.getScale(),
+					pos.getX() + controller.getScaleDiv2(),
+					pos.getY() - controller.getScale(),
 					controller.getScaleDiv2(), controller.getScaleDiv2(), null);
 		}
 		//<-- OldCode
@@ -634,8 +623,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 
         if (e.getX() > upperNode.getLeftBorder()) {
             for (AbstractCanvasObject cps : upperNode.getNodes()) {
-                cx = cps.getPosition().x - model.getScaleDiv2();
-                cy = cps.getPosition().y - model.getScaleDiv2();
+                cx = cps.getPosition().getX() - model.getScaleDiv2();
+                cy = cps.getPosition().getY() - model.getScaleDiv2();
                 if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
                     tempCps = cps;
 
@@ -751,7 +740,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
             /**
              * check if tempCps could replace an Object on the UpperNodeanvas
              */
-            if(model.getSelectedCpsObjects().size() == 1 && checkForReplacement(upperNode.getNodes(), tempCps, tempCps.getPosition().x, tempCps.getPosition().y)){
+            if(model.getSelectedCpsObjects().size() == 1 && checkForReplacement(upperNode.getNodes(), tempCps, tempCps.getPosition().getX(), tempCps.getPosition().getY())){
             	/**
             	 * if UpperNode would be replaced, close its tabs
             	 */
@@ -823,22 +812,22 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
                         y = this.getHeight() - controller.getScaleDiv2();
 
                     // Distance
-                    xDist = x - tempCps.getPosition().x;
-                    yDist = y - tempCps.getPosition().y;
+                    xDist = x - tempCps.getPosition().getX();
+                    yDist = y - tempCps.getPosition().getY();
 
                     tempCps.setPosition(x, y); // Drag Position
 
                     // TipText Position and name
                     toolTip = true;
                     toolTipText = tempCps.getName() + ", " + tempCps.getId();
-                    toolTipPos.x = tempCps.getPosition().x - model.getScaleDiv2();
-                    toolTipPos.y = tempCps.getPosition().y + model.getScaleDiv2();
+                    toolTipPos.setX(tempCps.getPosition().getX() - model.getScaleDiv2());
+                    toolTipPos.setY(tempCps.getPosition().getY() - model.getScaleDiv2());
 
                     // All Selected Objects
                     for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
                         if (cps != tempCps) {
-                            x = (int) (cps.getPosition().x + xDist);
-                            y = (int) (cps.getPosition().y + yDist);
+                            x = (int) (cps.getPosition().getX() + xDist);
+                            y = (int) (cps.getPosition().getY() + yDist);
 
                             // Make sure its in bounds
                             if (x < upperNode.getLeftBorder() + 5 + controller.getScaleDiv2())
@@ -881,8 +870,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
                     y1 = y;
                     y2 = sy;
                 }
-                if (x1 <= cps.getPosition().x + model.getScaleDiv2() && y1 <= cps.getPosition().y + model.getScaleDiv2()
-                        && x2 >= cps.getPosition().x && y2 >= cps.getPosition().y) {
+                if (x1 <= cps.getPosition().getX() + model.getScaleDiv2() && y1 <= cps.getPosition().getY() + model.getScaleDiv2()
+                        && x2 >= cps.getPosition().getX() && y2 >= cps.getPosition().getY()) {
                     tempSelected.add(cps);
 
                 }
@@ -931,8 +920,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
         boolean on = false;
         for (AbstractCanvasObject cps : upperNode.getNodes()) {
 
-            cx = cps.getPosition().x - controller.getScaleDiv2();
-            cy = cps.getPosition().y - controller.getScaleDiv2();
+            cx = cps.getPosition().getX() - controller.getScaleDiv2();
+            cy = cps.getPosition().getY() - controller.getScaleDiv2();
 
             on = setToolTipInfoAndPosition(on, cps);
         }
@@ -951,8 +940,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
             if (x - 50 <= cx && y - 50 <= cy && x >= cx && y >= cy) {
 
                 on = true;
-                toolTipPos.x = cx - 25;
-                toolTipPos.y = cy + 50;
+                toolTipPos.setX(cx - 25);
+                toolTipPos.setY(cy + 50);
                 toolTipText = cps.getName() + ", " + cps.getId();
 
             }
@@ -978,8 +967,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
         Edge e = null;
         for (AbstractCanvasObject cps : upperNode.getNodes()) {
 
-            cx = cps.getPosition().x - controller.getScaleDiv2();
-            cy = cps.getPosition().y - controller.getScaleDiv2();
+            cx = cps.getPosition().getX() - controller.getScaleDiv2();
+            cy = cps.getPosition().getY() - controller.getScaleDiv2();
 
             if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy
                     && cps != tempCps) {
@@ -1142,8 +1131,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 
 //TODO: is this right
 //        for (CpsEdge p : upperNode.getNodeEdges()) {
-//            Line2D l = new Line2D.Float(p.getA().getPosition().x, p.getA().getPosition().y, p.getB().getPosition().x,
-//                    p.getB().getPosition().y);
+//            Line2D l = new Line2D.Float(p.getA().getPosition().getX(), p.getA().getPosition().getY(), p.getB().getPosition().getX(),
+//                    p.getB().getPosition().getY());
 //
 //            int[] positions = determineMousePositionOnEdge(p);
 //            lx = positions[0];
@@ -1182,21 +1171,21 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
                 // 5 + (50 + scalediv20 + 10) * count), 50, 50, null);
                 if (doTest) {
                     Line2D l = new Line2D.Float((upperNode.getLeftBorder() >> 1) - 25,
-                            (int) (scalediv20 + 5 + 25 + (50 + scalediv20 + 10) * count), obj.getPosition().x,
-                            obj.getPosition().y);
-                    if ((upperNode.getLeftBorder() >> 1) > obj.getPosition().x) {
+                            (int) (scalediv20 + 5 + 25 + (50 + scalediv20 + 10) * count), obj.getPosition().getX(),
+                            obj.getPosition().getY());
+                    if ((upperNode.getLeftBorder() >> 1) > obj.getPosition().getX()) {
                         hx = (upperNode.getLeftBorder() >> 1) - 25 + model.getScaleDiv2() + 7;
-                        lx = obj.getPosition().x + model.getScaleDiv2() - 7;
+                        lx = obj.getPosition().getX() + model.getScaleDiv2() - 7;
                     } else {
                         lx = (upperNode.getLeftBorder() >> 1) - 25 + model.getScaleDiv2() - 7;
-                        hx = obj.getPosition().x + model.getScaleDiv2() + 7;
+                        hx = obj.getPosition().getX() + model.getScaleDiv2() + 7;
                     }
-                    if ((int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) > obj.getPosition().y) {
+                    if ((int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) > obj.getPosition().getY()) {
                         hy = (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + model.getScaleDiv2() + 7;
-                        ly = obj.getPosition().y + model.getScaleDiv2() - 7;
+                        ly = obj.getPosition().getY() + model.getScaleDiv2() - 7;
                     } else {
                         ly = (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count) + model.getScaleDiv2() - 7;
-                        hy = obj.getPosition().y + model.getScaleDiv2() + 7;
+                        hy = obj.getPosition().getY() + model.getScaleDiv2() + 7;
                     }
 
                     // distance from a point to a line and between both Objects

+ 65 - 75
src/ui/view/MyCanvas.java

@@ -108,27 +108,23 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 				animCps = new ArrayList<>();
 				for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
 					animCps.add(cps); // add to animation Cps ArrayList
-					unPos.x += cps.getPosition().x;
-					unPos.y += cps.getPosition().y;
+					unPos = unPos.add(cps.getPosition());
 				}
-				unPos.x /= animCps.size();
-				unPos.y /= animCps.size();
+				unPos = unPos.divide(animCps.size());
 
 				// save old Position
 				savePos = new ArrayList<>();
 				for (int i = 0; i < animCps.size(); i++) {
-					savePos.add(new Vector2dInt(0, 0));
-					savePos.get(i).x = animCps.get(i).getPosition().x;
-					savePos.get(i).y = animCps.get(i).getPosition().y;
+					savePos.add(animCps.get(i).getPosition().clone());
 				}
 
 				animT = new javax.swing.Timer(animDelay, actionEvent1 -> {
 					if (animDuration - animDelay > 0 && animCps.size() > 1) {
 						for (AbstractCanvasObject animCpObject : animCps) {
-							double x1 = animCpObject.getPosition().x - unPos.x;
-							double y1 = animCpObject.getPosition().y - unPos.y;
-							animCpObject.getPosition().x -= x1 / animSteps;
-							animCpObject.getPosition().y -= y1 / animSteps;
+							Vector2dInt pos = animCpObject.getPosition();
+	                    	Vector2dInt difference = pos.subtract(unPos);
+	                    	Vector2dInt result = pos.subtract(difference.divide(animSteps));
+	                    	pos.set(result);
 						}
 						repaint();
 						animDuration -= animDelay;
@@ -138,8 +134,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 						animSteps = animDuration / animDelay;
 						animT.stop();
 						for (int i = 0; i < animCps.size(); i++) {
-							animCps.get(i).getPosition().x = savePos.get(i).x;
-							animCps.get(i).getPosition().y = savePos.get(i).y;
+							animCps.get(i).getPosition().set(savePos.get(i));
 						}
 						controller.addUpperNode("GroupNode", null, animCps);
 						controller.calculateStateAndVisualForCurrentTimeStep();
@@ -163,13 +158,11 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 					controller.ungroupGroupNode((GroupNode) tempCps, null);
 
 					for (int i = 0; i < animCps.size(); i++) {
-						savePos.add(new Vector2dInt(0, 0));
-						savePos.get(i).x = animCps.get(i).getPosition().x;
-						savePos.get(i).y = animCps.get(i).getPosition().y;
+						savePos.add(animCps.get(i).getPosition().clone());
 					}
 					for (AbstractCanvasObject cps : animCps) {
-						int x = tempCps.getPosition().x;
-						int y = tempCps.getPosition().y;
+						int x = tempCps.getPosition().getX();
+						int y = tempCps.getPosition().getY();
 
 						cps.setPosition(new Vector2dInt(x, y));
 					}
@@ -180,11 +173,10 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 								model.getSelectedCpsObjects().clear();
 								if (animDuration - animDelay >= 0) {
 									for (int i = 0; i < animCps.size(); i++) {
-										Vector2dInt pos = animCps.get(i).getPosition();
-										double x1 = pos.x - savePos.get(i).x;
-										double y1 = pos.y - savePos.get(i).y;
-										animCps.get(i).getPosition().x -= x1 / animSteps;
-										animCps.get(i).getPosition().y -= y1 / animSteps;
+										Vector2dInt pos =  animCps.get(i).getPosition();
+				                    	Vector2dInt difference = pos.subtract(savePos.get(i));
+				                    	Vector2dInt result = pos.subtract(difference.divide(animSteps));
+				                    	pos.set(result);
 									}
 									repaint();
 									animDuration -= animDelay;
@@ -194,10 +186,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 									animSteps = animDuration / animDelay;
 									animT.stop();
 									for (int i = 0; i < animCps.size(); i++) {
-										animCps.get(i).getPosition().x = savePos
-												.get(i).x;
-										animCps.get(i).getPosition().y = savePos
-												.get(i).y;
+										animCps.get(i).getPosition().set(savePos
+												.get(i));
 									}
 									controller.calculateStateAndVisualForCurrentTimeStep();
 									triggerUpdateController();
@@ -329,13 +319,13 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		Vector2dInt pos = decoratedHolonObject.getModel().getPosition();
 		Color statecolor = getStateColor(decoratedHolonObject.getState());
 		g.setColor(statecolor);
-		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
+		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
 		drawCanvasObject(g, decoratedHolonObject.getModel().getImage(), pos);
 	}
 	private void drawCanvasObjectString(Graphics2D g, Vector2dInt posOfCanvasObject, float energy) {
 		g.setColor(Color.BLACK);
 		g.setFont(new Font("TimesNewRoman", Font.PLAIN, (int) (controller.getScale() / 4f) )); 
-		g.drawString((energy > 0)? "+" + Float.toString(energy): Float.toString(energy), posOfCanvasObject.x - controller.getScaleDiv2(), posOfCanvasObject.y - controller.getScaleDiv2() - 1);
+		g.drawString((energy > 0)? "+" + Float.toString(energy): Float.toString(energy), posOfCanvasObject.getX() - controller.getScaleDiv2(), posOfCanvasObject.getY() - controller.getScaleDiv2() - 1);
 	}
 	private void paintConsumer(Graphics2D g, Consumer con){
 		paintCanvasObject(g, con);
@@ -349,8 +339,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 	
 	private void drawCanvasObject(Graphics2D g, String Image, Vector2dInt pos) {
 		g.drawImage(ImageImport.loadImage(Image, controller.getScale(), controller.getScale()) , 
-				pos.x - controller.getScaleDiv2(),
-				pos.y - controller.getScaleDiv2(),
+				pos.getX() - controller.getScaleDiv2(),
+				pos.getY() - controller.getScaleDiv2(),
 				controller.getScale(), controller.getScale() , null);
 	}
 	
@@ -374,11 +364,11 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		if(isSelected){
 			g.setColor(Color.lightGray);
 		}
-		g.drawLine(start.x, start.y, end.x, end.y);
+		g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
 		if(showConnectionInformation) {			
-			Vector2dInt middle = new Vector2dInt((start.x + end.x) / 2, (start.y + end.y) / 2);
+			Vector2dInt middle = new Vector2dInt((start.getX() + end.getX()) / 2, (start.getY() + end.getY()) / 2);
 			g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) )); 
-			g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.x, middle.y);
+			g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.getX(), middle.getY());
 		}
 	}
 	private void paintSwitch(Graphics2D g, DecoratedSwitch dSwitch)
@@ -402,15 +392,15 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 			g.setStroke(new BasicStroke(unlimited?2f:(currentEnergy / capacity * 2f) + 1));
 			break;
 		}
-		g.drawLine(start.x, start.y, end.x, end.y);
-		Vector2dInt middle = new Vector2dInt((start.x + end.x) / 2, (start.y + end.y) / 2);
+		g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
+		Vector2dInt middle = new Vector2dInt((start.getX() + end.getX()) / 2, (start.getY() + end.getY()) / 2);
 		g.setFont(new Font("TimesRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10) )); 
-		g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.x, middle.y);
+		g.drawString(currentEnergy + "/" + (unlimited?"\u221E":capacity) , middle.getX(), middle.getY());
 	}
 	private void paintGroupNode(Graphics2D g, DecoratedGroupNode dGroupNode) {
 		Vector2dInt pos = dGroupNode.getModel().getPosition();
 		g.setColor(Color.lightGray);
-		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
+		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
 		drawCanvasObject(g, "/Images/upper_node.png" , pos);
 		paintGroupNodeBar(g, dGroupNode, pos);
 	}
@@ -419,7 +409,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		int barWidth = (int) (controller.getScale());
 		int barHeight = (int) (controller.getScale() / 5);
 		g.setColor(Color.WHITE);
-		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
+		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
 		float[] percentages = getGroupNodeBarPercentages(dGroupNode);
 		Color[] colors = new Color[6];
 		colors[0] = getStateColor(HolonObjectState.PRODUCER);
@@ -431,13 +421,13 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 				
 		for(int i = 5; i>=0; i--) {
 			g.setColor(colors[i]);
-			g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) (barWidth * percentages[i] - 1), barHeight);		
+			g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) (barWidth * percentages[i] - 1), barHeight);		
 		}
 //		g.setColor(color);
-//		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
+//		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
 		g.setColor(Color.BLACK);
 		g.setStroke(new BasicStroke(1));
-		g.drawRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
+		g.drawRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
 	}
 	/**
 	 * HardCoded Stuff dont try at Home ;)
@@ -466,17 +456,17 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		int barWidth = (int) (controller.getScale());
 		int barHeight = (int) (controller.getScale() / 5);
 		g.setColor(Color.WHITE);
-		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
+		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) barWidth, barHeight);
 		g.setColor(color);
-		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
+		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, (int) (barWidth * (percentage < 1 ? percentage : 1.0f) - 1), barHeight);
 		g.setColor(Color.BLACK);
 		g.setStroke(new BasicStroke(1));
-		g.drawRect(pos.x - controller.getScaleDiv2(), pos.y + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
+		g.drawRect(pos.getX() - controller.getScaleDiv2(), pos.getY() + controller.getScaleDiv2() - 1, barWidth - 1 , barHeight);
 		g.setFont(new Font("TimesNewRoman", Font.PLAIN, (int) (barHeight * 1.5) - 2)); 
 		String percentageString = (Math.round((percentage * 100))) + "%";
 		int stringWidth = (int) g.getFontMetrics().getStringBounds(percentageString, g).getWidth();
 		if(percentage > 1.0f) g.setColor(Color.WHITE); //Just to see better on purple
-		g.drawString(percentageString, pos.x + 1 - stringWidth / 2, pos.y + controller.getScaleDiv2() - 1+ barHeight);
+		g.drawString(percentageString, pos.getX() + 1 - stringWidth / 2, pos.getY() + controller.getScaleDiv2() - 1+ barHeight);
 		
 	}
 	
@@ -510,7 +500,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		if (drawEdge) {
 			g2d.setColor(Color.BLACK);
 			g2d.setStroke(new BasicStroke(1));
-			g2d.drawLine(tempCps.getPosition().x, tempCps.getPosition().y, x, y);
+			g2d.drawLine(tempCps.getPosition().getX(), tempCps.getPosition().getY(), x, y);
 		}
 		//<--
 		//SelectedCable
@@ -568,18 +558,18 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 			if(aCps instanceof Node) {
 				Vector2dInt pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
-				g2d.fillOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
+				g2d.fillOval(pos.getX() - (int) (controller.getScaleDiv2()), pos.getY() - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 				g2d.setColor(Color.LIGHT_GRAY);
 				g2d.setStroke(new BasicStroke(2));
-				g2d.drawOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
+				g2d.drawOval(pos.getX() - (int) (controller.getScaleDiv2()), pos.getY() - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 			}
 			else {
 				Vector2dInt pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
-				g2d.fillRect(pos.x - (int) (controller.getScaleDiv2()* 1.5f), pos.y - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
+				g2d.fillRect(pos.getX() - (int) (controller.getScaleDiv2()* 1.5f), pos.getY() - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));
 				g2d.setColor(Color.LIGHT_GRAY);
 				g2d.setStroke(new BasicStroke(2));
-				g2d.drawRect(pos.x - (int) (controller.getScaleDiv2()* 1.5f), pos.y - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));				
+				g2d.drawRect(pos.getX() - (int) (controller.getScaleDiv2()* 1.5f), pos.getY() - (int) (controller.getScaleDiv2()* 1.5f), (int) (controller.getScale()* 1.5f) , (int) (controller.getScale()* 1.5f));				
 			}
 
 		}
@@ -588,8 +578,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 			g2d.setColor(Color.RED);
 			Vector2dInt pos = mayBeReplaced.getPosition();
 			g2d.drawImage(ImageImport.loadImage("/Images/replace.png") , 
-					pos.x + controller.getScaleDiv2(),
-					pos.y - controller.getScale(),
+					pos.getX() + controller.getScaleDiv2(),
+					pos.getY() - controller.getScale(),
 					controller.getScaleDiv2(), controller.getScaleDiv2(), null);
 		}
 		//<-- OldCode
@@ -629,8 +619,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		controller.setSelecteEdge(null);
 		// Object Selection
 		for (AbstractCanvasObject cps : model.getObjectsOnCanvas()) {
-			cx = cps.getPosition().x - controller.getScaleDiv2();
-			cy = cps.getPosition().y - controller.getScaleDiv2();
+			cx = cps.getPosition().getX() - controller.getScaleDiv2();
+			cy = cps.getPosition().getY() - controller.getScaleDiv2();
 			if (x - controller.getScale() <= cx
 					&& y - controller.getScale() <= cy && x >= cx && y >= cy) {
 				tempCps = cps;
@@ -711,7 +701,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 			 * check if a unique tempCps could replace an Object on the canvas
 			 */
 			if(model.getSelectedCpsObjects().size()==1 
-					&& checkForReplacement(model.getObjectsOnCanvas(), tempCps, tempCps.getPosition().x, tempCps.getPosition().y)){
+					&& checkForReplacement(model.getObjectsOnCanvas(), tempCps, tempCps.getPosition().getX(), tempCps.getPosition().getY())){
 				/**
             	 * if UpperNode would be replaced, close its tabs
             	 */
@@ -788,23 +778,23 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 					y = this.getHeight() - scaleDiv2;
 
 				// Distance
-				xDist = x - tempCps.getPosition().x;
-				yDist = y - tempCps.getPosition().y;
+				xDist = x - tempCps.getPosition().getX();
+				yDist = y - tempCps.getPosition().getY();
 
 				tempCps.setPosition(x, y); // Drag Position
 				// ToolTipText Position and name
 				toolTip = true;
 				toolTipText = tempCps.getName() + ", " + tempCps.getId();
-				toolTipPos.x = tempCps.getPosition().x
-						- scaleDiv2;
-				toolTipPos.y = tempCps.getPosition().y
-						+ scaleDiv2;
+				toolTipPos.setX(tempCps.getPosition().getX()
+						- scaleDiv2);
+				toolTipPos.setY(tempCps.getPosition().getY()
+						+ scaleDiv2);
 
 				// All Selected Objects
 				for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
 					if (cps != tempCps) {
-						x = (int) (cps.getPosition().x + xDist);
-						y = (int) (cps.getPosition().y + yDist);
+						x = (int) (cps.getPosition().getX() + xDist);
+						y = (int) (cps.getPosition().getY() + yDist);
 
 						// Make sure its in bounds
 						if (x <= scaleDiv2)
@@ -847,10 +837,10 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 					y1 = y;
 					y2 = sy;
 				}
-				if (x1 <= cps.getPosition().x + model.getScaleDiv2()
-						&& y1 <= cps.getPosition().y + model.getScaleDiv2()
-						&& x2 >= cps.getPosition().x
-						&& y2 >= cps.getPosition().y) {
+				if (x1 <= cps.getPosition().getX() + model.getScaleDiv2()
+						&& y1 <= cps.getPosition().getY() + model.getScaleDiv2()
+						&& x2 >= cps.getPosition().getX()
+						&& y2 >= cps.getPosition().getY()) {
 					tempSelected.add(cps);
 
 				}
@@ -870,8 +860,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		// Everything for the tooltip :)
 		boolean on = false;
 		for (AbstractCanvasObject cps : model.getObjectsOnCanvas()) {
-			cx = cps.getPosition().x - controller.getScaleDiv2();
-			cy = cps.getPosition().y - controller.getScaleDiv2();
+			cx = cps.getPosition().getX() - controller.getScaleDiv2();
+			cy = cps.getPosition().getY() - controller.getScaleDiv2();
 
 			on = setToolTipInfoAndPosition(on, cps);
 		}
@@ -894,8 +884,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 			Edge e = null;
 
 			for (AbstractCanvasObject cps : model.getObjectsOnCanvas()) {
-				cx = cps.getPosition().x - controller.getScaleDiv2();
-				cy = cps.getPosition().y - controller.getScaleDiv2();
+				cx = cps.getPosition().getX() - controller.getScaleDiv2();
+				cy = cps.getPosition().getY() - controller.getScaleDiv2();
 				if (x - controller.getScale() <= cx
 						&& y - controller.getScale() <= cy && x >= cx
 						&& y >= cy && cps != tempCps) {
@@ -1016,9 +1006,9 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		x += controller.getScaleDiv2();
 		y += controller.getScaleDiv2();
 		for (Edge p : model.getEdgesOnCanvas()) {
-			Line2D l = new Line2D.Float(p.getA().getPosition().x, p.getA()
-					.getPosition().y, p.getB().getPosition().x, p.getB()
-					.getPosition().y);
+			Line2D l = new Line2D.Float(p.getA().getPosition().getX(), p.getA()
+					.getPosition().getY(), p.getB().getPosition().getX(), p.getB()
+					.getPosition().getY());
 
 			int[] positions = determineMousePositionOnEdge(p);
 			int lx = positions[0];

+ 28 - 28
src/ui/view/UnitGraph.java

@@ -230,8 +230,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     private void drawLine(Graphics2D g, Vector2dInt start, Vector2dInt end)
     {
     	Path2D.Double path = new Path2D.Double();
-    	path.moveTo(start.x, start.y);
-    	path.lineTo(end.x, end.y);
+    	path.moveTo(start.getX(), start.getY());
+    	path.lineTo(end.getX(), end.getY());
     	g.draw(path);
     }
     
@@ -245,7 +245,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     	//Good Source for basic understanding for Bezier Curves
         //http://www.theappguruz.com/blog/bezier-curve-in-games
     	Path2D.Double path = new Path2D.Double();
-    	path.moveTo(start.x, start.y);
+    	path.moveTo(start.getX(), start.getY());
 		return path;
     }
     /**
@@ -257,8 +257,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param target the end Position of the Curve.
      */
     private void curveTo(Path2D.Double path, Vector2dInt actual, Vector2dInt target) {
-         double mitte = (actual.x + target.x)* 0.5;
-         path.curveTo(mitte, actual.y, mitte, target.y, target.x, target.y);
+         double mitte = (actual.getX() + target.getX())* 0.5;
+         path.curveTo(mitte, actual.getY(), mitte, target.getY(), target.getX(), target.getY());
     }
     /**
      * Helper Method to draw the UnitGraphPanel. {@link UnitGraph#paintComponent(Graphics)}
@@ -269,7 +269,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      */
     private void drawDot(Graphics2D g, Vector2dInt p)
     {    	
-    	g.fillOval(p.x -dotSize/2, p.y-dotSize/2, dotSize, dotSize);
+    	g.fillOval(p.getX() -dotSize/2, p.getY()-dotSize/2, dotSize, dotSize);
     }
     
     
@@ -285,14 +285,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      	ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
      	Vector2dInt actual = actualGraphPoints.getFirst().displayedPosition;
      	Path2D.Double path = new Path2D.Double();
-     	path.moveTo(actual.x, actual.y);
+     	path.moveTo(actual.getX(), actual.getY());
      	while (iter.hasNext())
     	{
     		Vector2dInt target = iter.next().displayedPosition;
     		//BooleanConnection
-    		path.lineTo(target.x, actual.y); //line to corner
-    		cornerPoints.add(new Vector2dInt(target.x, actual.y)); //save corner
-    		path.lineTo(target.x, target.y); //line to next Point
+    		path.lineTo(target.getX(), actual.getY()); //line to corner
+    		cornerPoints.add(new Vector2dInt(target.getX(), actual.getY())); //save corner
+    		path.lineTo(target.getX(), target.getY()); //line to next Point
     		
     		actual = target;
     	}
@@ -316,7 +316,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      	LinkedList<Vector2dInt> after = new LinkedList<Vector2dInt>();
      	for(UnitGraphPoint p: actualGraphPoints)
      	{
-     		if(p.displayedPosition.x < editPosition.x)
+     		if(p.displayedPosition.getX() < editPosition.getX())
      			before.add(p.displayedPosition);
      		else
      			after.add(p.displayedPosition);
@@ -373,14 +373,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
       	LinkedList<Vector2dInt> cornerPoints =  new LinkedList<Vector2dInt>();
      	Vector2dInt actual = list.getFirst();
      	Path2D.Double path = new Path2D.Double();
-     	path.moveTo(actual.x, actual.y);
+     	path.moveTo(actual.getX(), actual.getY());
      	while (iter.hasNext())
     	{
     		Vector2dInt target = iter.next();
     		//BooleanConnection
-    		path.lineTo(target.x, actual.y); //line to corner
-    		cornerPoints.add(new Vector2dInt(target.x, actual.y)); //save corner
-    		path.lineTo(target.x, target.y); //line to next Point
+    		path.lineTo(target.getX(), actual.getY()); //line to corner
+    		cornerPoints.add(new Vector2dInt(target.getX(), actual.getY())); //save corner
+    		path.lineTo(target.getX(), target.getY()); //line to next Point
     		actual = target;
     	}
      	g.draw(path);
@@ -422,7 +422,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      	LinkedList<Vector2dInt> after = new LinkedList<Vector2dInt>();
      	for(UnitGraphPoint p: actualGraphPoints)
      	{
-     		if(p.displayedPosition.x < editPosition.x)
+     		if(p.displayedPosition.getX() < editPosition.getX())
      			before.add(p.displayedPosition);
      		else
      			after.add(p.displayedPosition);
@@ -545,10 +545,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		switch(actualGraphType)
 		{
 		case boolGraph: //Distance only with X 
-			int xDis = target.x - actual.x;
+			int xDis = target.getX() - actual.getX();
 			return xDis * xDis  < clickThreshholdSquared;
 		case doubleGraph:
-			return actual.squareDistance(target) < clickThreshholdSquared;
+			return actual.getSquaredDistance(target) < clickThreshholdSquared;
 		default:
 			return false;
 		}	
@@ -587,10 +587,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 */
 	private Vector2dInt snapBoolean(Vector2dInt p)
 	{
-		if (p.y < border + heightWithBorder / 2) {
-			p.y = border;
+		if (p.getY() < border + heightWithBorder / 2) {
+			p.setY(border);
 		} else {
-			p.y = border + heightWithBorder;
+			p.setY(border + heightWithBorder);
 		}
 		return p;
 	}
@@ -606,10 +606,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		switch(editPoint)
 		{
 		case StartPoint:
-			p.x = border;
+			p.setX(border);
 			break;
 		case EndPoint:
-			p.x = border + widthWithBorder;
+			p.setX(border + widthWithBorder);
 			break;
 		default:
 			break;
@@ -628,7 +628,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     	while (iter2.hasNext())
     	{
     		Vector2dInt tempPosition = iter2.next().displayedPosition;
-    		if(pos.x <= tempPosition.x)
+    		if(pos.getX() <= tempPosition.getX())
     		{
     			//previous to go back a position to make the new point before the the Position with greater X
     			iter2.previous();
@@ -647,8 +647,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @return a UnitGraphPoint
      */
 	private UnitGraphPoint generateUnitGraphPoint(Vector2dInt pos) {
-		UnitGraphPoint temp = new UnitGraphPoint((double) (pos.x - border) / (double) widthWithBorder,
-				1 - (double) (pos.y - border) / (double) heightWithBorder, true);
+		UnitGraphPoint temp = new UnitGraphPoint((double) (pos.getX() - border) / (double) widthWithBorder,
+				1 - (double) (pos.getY() - border) / (double) heightWithBorder, true);
 		temp.displayedPosition = pos;
 		return temp;
 	}
@@ -658,7 +658,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      */
 	@Override
     public void mouseDragged(MouseEvent e) {
-    	updateEditPointPosition(new Vector2dInt(e.getPoint()));
+    	updateEditPointPosition(new Vector2dInt(e.getPoint().x, e.getPoint().y));
     	repaint();
     }
 
@@ -685,7 +685,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      */
     @Override
     public void mousePressed(MouseEvent e) {
-		Vector2dInt mPosition = new Vector2dInt(e.getPoint());
+		Vector2dInt mPosition = new Vector2dInt(e.getPoint().x, e.getPoint().y);
 		if (e.getButton() == MouseEvent.BUTTON3) {
 			// RightMouseButtonEvent
 			detectStartEndPoint(mPosition);

+ 3 - 3
tests/tests/PraktikumHolonsTestClasses.java

@@ -156,9 +156,9 @@ public class PraktikumHolonsTestClasses {
 		Vector2dInt pos1 = new Vector2dInt(100, 200);
 		Vector2dInt pos2 = new Vector2dInt();
 
-		assertTrue("Wrong coordinates", pos1.x == 100 && pos1.y == 200);
-		assertTrue("Are the Same", pos1.x != pos2.x);
-		assertTrue("not (-1,-1)", pos2.x == -1 && pos2.y == -1);
+		assertTrue("Wrong coordinates", pos1.getX() == 100 && pos1.getY() == 200);
+		assertTrue("Are the Same", pos1.getX() != pos2.getX());
+		assertTrue("not (-1,-1)", pos2.getX() == -1 && pos2.getY() == -1);
 	}
 	
 }