TomTroppmann 3 years ago
parent
commit
440ffbabc4

+ 7 - 7
src/TypeAdapter/PositionAdapter.java

@@ -9,28 +9,28 @@ import com.google.gson.JsonPrimitive;
 import com.google.gson.JsonSerializationContext;
 import com.google.gson.JsonSerializer;
 
-import classes.Position;
+import classes.Vector2dInt;
 
-public class PositionAdapter implements JsonSerializer<Position>, JsonDeserializer<Position> {
+public class PositionAdapter implements JsonSerializer<Vector2dInt>, JsonDeserializer<Vector2dInt> {
 
 	@Override
-	public JsonElement serialize(Position arg0, Type arg1, JsonSerializationContext arg2) {
-		return new JsonPrimitive(arg0.x + ":" + arg0.y);
+	public JsonElement serialize(Vector2dInt arg0, Type arg1, JsonSerializationContext arg2) {
+		return new JsonPrimitive(arg0.getX() + ":" + arg0.getY());
 	}
 
 	@Override
-	public Position deserialize(JsonElement arg0, Type arg1, JsonDeserializationContext arg2) {
+	public Vector2dInt deserialize(JsonElement arg0, Type arg1, JsonDeserializationContext arg2) {
 		try {
 			String arg = arg0.getAsString();
 			int mid = arg.indexOf(':');
 			int x = Integer.parseInt(arg.substring(0, mid));
 			int y = Integer.parseInt(arg.substring(mid + 1, arg.length()));
-			return new Position(x, y);
+			return new Vector2dInt(x, y);
 
 		} catch (NumberFormatException e) {
 			System.err.println(e);
 		}
-		return new Position(-1, -1);
+		return new Vector2dInt(-1, -1);
 	}
 
 }

+ 3 - 3
src/api/TopologieAlgorithmFramework.java

@@ -878,8 +878,8 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 			//generate Switch
 			AbstractCanvasObject fromObject =  accessIntToObject.get(cable.first);
 			AbstractCanvasObject toObject =  accessIntToObject.get(cable.second);
-			int middleX = (fromObject.getPosition().x +   toObject.getPosition().x)/2;
-			int middleY = (fromObject.getPosition().y +   toObject.getPosition().y)/2;
+			int middleX = (fromObject.getPosition().getX() +   toObject.getPosition().getX())/2;
+			int middleY = (fromObject.getPosition().getY() +   toObject.getPosition().getY())/2;
 			HolonSwitch newSwitch = new HolonSwitch("AddedSwitch");
 			newSwitch.setId(IdCounter.nextId(CounterType.Element));
 			newSwitch.setPosition(middleX, middleY);
@@ -1284,7 +1284,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 			return "{" + first + "," + second + "}";
 	    }
 	    public double getLength() {
-	    	return accessIntToObject.get(first).getPosition().Distance(accessIntToObject.get(second).getPosition());
+	    	return accessIntToObject.get(first).getPosition().getDistance(accessIntToObject.get(second).getPosition());
 	    }
 	}
 }

+ 4 - 4
src/classes/AbstractCanvasObject.java

@@ -33,7 +33,7 @@ public abstract class AbstractCanvasObject {
 	ArrayList<Edge> connections = new ArrayList<>();
 	/* Position with a X and Y value */
 	@Expose
-	Position position = new Position(0,0);
+	Vector2dInt position = new Vector2dInt(0,0);
 	/*
 	 * Energy input and output of each object in the grid Where the Object is
 	 * Stored
@@ -196,7 +196,7 @@ public abstract class AbstractCanvasObject {
 	 *            Y-Coord
 	 */
 	public void setPosition(int x, int y) {
-		setPosition(new Position(x, y));
+		setPosition(new Vector2dInt(x, y));
 	}
 
 	/**
@@ -204,7 +204,7 @@ public abstract class AbstractCanvasObject {
 	 *
 	 * @return Position Position of this Object
 	 */
-	public Position getPosition() {
+	public Vector2dInt getPosition() {
 		return position;
 	}
 
@@ -213,7 +213,7 @@ public abstract class AbstractCanvasObject {
 	 *
 	 * @param pos Coordinates
 	 */
-	public void setPosition(Position pos) {
+	public void setPosition(Vector2dInt pos) {
 		this.position = pos;
 	}
 

+ 1 - 1
src/classes/Edge.java

@@ -36,7 +36,7 @@ public class Edge {
      * @return
      */
     public float getLength() {
-    	return (float)a.getPosition().Distance(b.getPosition());
+    	return (float)a.getPosition().getDistance(b.getPosition());
     }
 
     @Expose

+ 9 - 9
src/classes/HolonBody.java

@@ -7,8 +7,8 @@ import java.awt.Graphics2D;
 
 public class HolonBody implements Comparable<HolonBody> {
 
-	public Vector2d velocity;
-	public Vector2d position;
+	public Vector2dFloat velocity;
+	public Vector2dFloat position;
 	private float mass;
 	private float radius;
 	private Color color;
@@ -27,8 +27,8 @@ public class HolonBody implements Comparable<HolonBody> {
 	}
 
 	public HolonBody(float x, float y, float radius, float mass, Color color) {
-		this.velocity = new Vector2d(0, 0);
-		this.position = new Vector2d(x, y);
+		this.velocity = new Vector2dFloat(0, 0);
+		this.position = new Vector2dFloat(x, y);
 		this.setMass(mass);
 		this.setRadius(radius);
 		this.color = color;
@@ -76,7 +76,7 @@ public class HolonBody implements Comparable<HolonBody> {
 	public void resolveCollision(HolonBody body) {
 
 		// get the mtd
-		Vector2d delta = (position.subtract(body.position));
+		Vector2dFloat delta = (position.subtract(body.position));
 		float r = getRadius() + body.getRadius();
 		float dist2 = delta.dot(delta);
 
@@ -85,7 +85,7 @@ public class HolonBody implements Comparable<HolonBody> {
 
 		float d = delta.getLength();
 
-		Vector2d mtd;
+		Vector2dFloat mtd;
 		if (d != 0.0f) {
 			// minimum translation distance to push bodies apart after
 			// intersecting
@@ -95,7 +95,7 @@ public class HolonBody implements Comparable<HolonBody> {
 			// Special case. Bodies are exactly on top of eachother. Don't want
 			// to divide by zero.
 			d = body.getRadius() + getRadius() - 1.0f;
-			delta = new Vector2d(body.getRadius() + getRadius(), 0.0f);
+			delta = new Vector2dFloat(body.getRadius() + getRadius(), 0.0f);
 
 			mtd = delta.multiply(((getRadius() + body.getRadius()) - d) / d);
 		}
@@ -109,7 +109,7 @@ public class HolonBody implements Comparable<HolonBody> {
 		body.position = body.position.subtract(mtd.multiply(im2 / (im1 + im2)));
 
 		// impact speed
-		Vector2d v = (this.velocity.subtract(body.velocity));
+		Vector2dFloat v = (this.velocity.subtract(body.velocity));
 		float vn = v.dot(mtd.normalize());
 
 		// sphere intersecting but moving away from each other already
@@ -119,7 +119,7 @@ public class HolonBody implements Comparable<HolonBody> {
 		// collision impulse
 		float restitution = 0.85f;
 		float i = (-(1.0f + restitution) * vn) / (im1 + im2);
-		Vector2d impulse = mtd.multiply(i);
+		Vector2dFloat impulse = mtd.multiply(i);
 
 		// change in momentum
 		this.velocity = this.velocity.add(impulse.multiply(im1));

+ 0 - 94
src/classes/Position.java

@@ -1,94 +0,0 @@
-package classes;
-
-import java.awt.Point;
-
-/**
- * Coordinates of an Object on the canvas with a (int) x-coord and a (int).
- * y-coord
- * 
- * @author Gruppe14
- *
- */
-public class Position {
-	/** Coordinate*/
-	public int x,y;
-
-	/**
-	 * Constructor with an positive x and y coord on the canvas.
-	 * 
-	 * @param x Coord
-	 * @param y Coord
-	 */
-	public Position(int x, int y) {
-		this.x = x;
-		this.y = y;
-	}
-	/**
-	 * Convert a Point to a Position;
-	 * @param p Point
-	 */
-	public Position(Point p)
-	{
-		this.x = (int)p.getX();
-		this.y = (int)p.getY();
-	}
-	/**
-	 * Default constructor without defined position.
-	 */
-	public Position() {
-		this.x = -1;
-		this.y = -1;
-	}
-	/**
-	 * Return the Distance squared to a other Position.
-	 * Faster then Distance because no Sqrt() needed.
-	 * @param other the other Position.
-	 * @return squared distance to the Position
-	 */
-	public double squareDistance(Position other)
-	{
-		//The Distance in X
-		double xDis = x - other.x;
-		//The Distance in Y
-		double yDis = y - other.y;
-		return xDis * xDis + yDis * yDis;	
-	}
-	/**
-	 * Return the Distance to a other Position.
-	 * @param other the other Position.
-	 * @return distance to the Position.
-	 */
-	public double Distance(Position other)
-	{
-		return Math.sqrt(squareDistance(other));
-	}
-	
-	/**
-	 * Clamp the X Value two a upper or lower bound
-	 * @param min lower bound
-	 * @param max upper bound
-	 */
-	public void clampX(int min, int max)
-	{
-		if(x < min) x = min;
-		if(x > max) x = max;
-	}
-	/**
-	 * Clamp the Y Value two a upper or lower bound
-	 * @param min lower bound
-	 * @param max upper bound
-	 */
-	public void clampY(int min, int max)
-	{
-		if(y < min) y = min;
-		if(y > max) y = max;
-	}
-	/**
-	 * Returns a String that represents the value of this Position.
-	 * @return a string representation of this Position.
-	 */
-	@Override
-	public String toString() {
-		return "Position[x=" + x + ",y="+ y +"]";
-	}
-}

+ 2 - 2
src/classes/UnitGraphPoint.java

@@ -15,7 +15,7 @@ public class UnitGraphPoint {
 	/** To determine if this point has changed to only write back points that are changed.*/
 	public boolean changed;
 	/** The displayed Position of the UnitGraphPoint*/
-	public Position displayedPosition;
+	public Vector2dInt displayedPosition;
 	
 	/** Default Constructor */
 	public UnitGraphPoint(double x, double y, boolean changed){
@@ -41,7 +41,7 @@ public class UnitGraphPoint {
 	public void calcDisplayedPosition(int border, int widthWithBorder, int heightWithBorder) {
     	//Relativ to Border
     	//1-p.y because its on the Top
-		displayedPosition =  new Position((int) (x * widthWithBorder) + border, (int) ((1-y) * heightWithBorder) + border);
+		displayedPosition =  new Vector2dInt((int) (x * widthWithBorder) + border, (int) ((1-y) * heightWithBorder) + border);
     }
 	
 	public Point.Double getPoint()

+ 0 - 108
src/classes/Vector2d.java

@@ -1,108 +0,0 @@
-package classes;
-
-public class Vector2d {
-
-	private float x;
-	private float y;
-
-	public Vector2d()
-	{
-		this.setX(0);
-		this.setY(0);
-	}
-
-	public Vector2d(float x, float y)
-	{
-		this.setX(x);
-		this.setY(y);
-	}
-
-	public void setX(float x) {
-		this.x = x;
-	}
-
-	public float getX() {
-		return x;
-	}
-
-	public void setY(float y) {
-		this.y = y;
-	}
-
-	public float getY() {
-		return y;
-	}
-
-	public void set(float x, float y)
-	{
-		this.setX(x);
-		this.setY(y);
-	}
-
-
-	public float dot(Vector2d v2)
-	{
-		float result = 0.0f;
-		result = this.getX() * v2.getX() + this.getY() * v2.getY();
-		return result;
-	}
-
-	public float getLength()
-	{
-		return (float)Math.sqrt(getX()*getX() + getY()*getY());
-	}
-
-	public float getDistance(Vector2d v2)
-	{
-		return (float) Math.sqrt((v2.getX() - getX()) * (v2.getX() - getX()) + (v2.getY() - getY()) * (v2.getY() - getY()));
-	}
-
-
-	public Vector2d add(Vector2d v2)
-	{
-		Vector2d result = new Vector2d();
-		result.setX(getX() + v2.getX());
-		result.setY(getY() + v2.getY());
-		return result;
-	}
-
-	public Vector2d subtract(Vector2d v2)
-	{
-		Vector2d result = new Vector2d();
-		result.setX(this.getX() - v2.getX());
-		result.setY(this.getY() - v2.getY());
-		return result;
-	}
-
-	public Vector2d multiply(float scaleFactor)
-	{
-		Vector2d result = new Vector2d();
-		result.setX(this.getX() * scaleFactor);
-		result.setY(this.getY() * scaleFactor);
-		return result;
-	}
-
-	public Vector2d normalize()
-	{
-		float len = getLength();
-		if (len != 0.0f)
-		{
-			this.setX(this.getX() / len);
-			this.setY(this.getY() / len);
-		}
-		else
-		{
-			this.setX(0.0f);
-			this.setY(0.0f);
-		}
-
-		return this;
-	}
-
-	public String toString()
-	{
-		return "X: " + getX() + " Y: " + getY();
-	}
-
-
-}

+ 146 - 0
src/classes/Vector2dFloat.java

@@ -0,0 +1,146 @@
+package classes;
+
+public class Vector2dFloat {
+
+	private float x;
+	private float y;
+
+	public Vector2dFloat()
+	{
+		x = y = 0;
+	}
+
+	public Vector2dFloat(float x, float y)
+	{
+		setX(x);
+		setY(y);
+	}
+
+	public void setX(float x) {
+		this.x = x;
+	}
+
+	public float getX() {
+		return x;
+	}
+
+	public void setY(float y) {
+		this.y = y;
+	}
+
+	public float getY() {
+		return y;
+	}
+
+	public void set(float x, float y)
+	{
+		setX(x);
+		setY(y);
+	}
+
+
+	public float dot(Vector2dFloat other)
+	{
+		float result = 0.0f;
+		result = x * other.getX() + y * other.getY();
+		return result;
+	}
+
+	public float getLength()
+	{
+		return (float)Math.sqrt(x * x + y * y);
+	}
+
+	/**
+	 * Return the Distance to a other Position.
+	 * @param other the other Position.
+	 * @return distance to the Position.
+	 */
+	public float getDistance(Vector2dFloat other)
+	{
+		return (float) Math.sqrt(getSquaredDistance(other));
+	}
+	/**
+	 * Return the Distance squared to a other Position.
+	 * Faster then Distance because no Sqrt() needed.
+	 * @param other the other Position.
+	 * @return squared distance to the Position
+	 */
+	public float getSquaredDistance(Vector2dFloat other)
+	{
+		float xDistance = other.getX() - x;
+		float yDistance = other.getY() - y;
+		return xDistance * xDistance + yDistance * yDistance;
+	}
+
+	public Vector2dFloat add(Vector2dFloat other)
+	{
+		Vector2dFloat result = new Vector2dFloat();
+		result.setX(x + other.getX());
+		result.setY(y + other.getY());
+		return result;
+	}
+
+	public Vector2dFloat subtract(Vector2dFloat other)
+	{
+		Vector2dFloat result = new Vector2dFloat();
+		result.setX(x - other.getX());
+		result.setY(y - other.getY());
+		return result;
+	}
+
+	public Vector2dFloat multiply(float scaleFactor)
+	{
+		Vector2dFloat result = new Vector2dFloat();
+		result.setX(x * scaleFactor);
+		result.setY(y * scaleFactor);
+		return result;
+	}
+
+	public Vector2dFloat normalize()
+	{
+		float len = getLength();
+		if (len != 0.0f)
+		{
+			this.setX(x / len);
+			this.setY(y / len);
+		}
+		else
+		{
+			this.setX(0.0f);
+			this.setY(0.0f);
+		}
+
+		return this;
+	}
+
+	
+	/**
+	 * Clamp the X Value two a upper or lower bound
+	 * @param min lower bound
+	 * @param max upper bound
+	 */
+	public void clampX(float min, float max)
+	{
+		if(x < min) setX(min);
+		else if(x > max) setX(max);
+	}
+	/**
+	 * Clamp the Y Value two a upper or lower bound
+	 * @param min lower bound
+	 * @param max upper bound
+	 */
+	public void clampY(float min, float max)
+	{
+		if(y < min) setY(min);
+		else if(y > max) setY(max);
+	}
+	
+	
+	public String toString()
+	{
+		return "X: " + x + " Y: " + y;
+	}
+
+
+}

+ 134 - 0
src/classes/Vector2dInt.java

@@ -0,0 +1,134 @@
+package classes;
+
+import java.awt.Point;
+
+/**
+ * Coordinates of an Object on the canvas with a (int) x-coord and a (int).
+ * y-coord
+ * 
+ * @author Gruppe14
+ *
+ */
+public class Vector2dInt {
+	private int x;
+	private int y;
+
+	public Vector2dInt()
+	{
+		x = y = 0;
+	}
+
+	public Vector2dInt(int x, int y)
+	{
+		setX(x);
+		setY(y);
+	}
+
+	public void setX(int x) {
+		this.x = x;
+	}
+
+	public int getX() {
+		return x;
+	}
+
+	public void setY(int y) {
+		this.y = y;
+	}
+
+	public int getY() {
+		return y;
+	}
+
+	public void set(int x, int y)
+	{
+		setX(x);
+		setY(y);
+	}
+
+
+	public float dot(Vector2dInt other)
+	{
+		float result = 0.0f;
+		result = x * other.getX() + y * other.getY();
+		return result;
+	}
+
+	public float getLength()
+	{
+		return (float)Math.sqrt(x * x + y * y);
+	}
+
+	/**
+	 * Return the Distance to a other Position.
+	 * @param other the other Position.
+	 * @return distance to the Position.
+	 */
+	public float getDistance(Vector2dInt other)
+	{
+		return (float) Math.sqrt(getSquaredDistance(other));
+	}
+	/**
+	 * Return the Distance squared to a other Position.
+	 * Faster then Distance because no Sqrt() needed.
+	 * @param other the other Position.
+	 * @return squared distance to the Position
+	 */
+	public float getSquaredDistance(Vector2dInt other)
+	{
+		int xDistance = other.getX() - x;
+		int yDistance = other.getY() - y;
+		return xDistance * xDistance + yDistance * yDistance;
+	}
+
+	public Vector2dInt add(Vector2dInt other)
+	{
+		Vector2dInt result = new Vector2dInt();
+		result.setX(x + other.getX());
+		result.setY(y + other.getY());
+		return result;
+	}
+
+	public Vector2dInt subtract(Vector2dInt other)
+	{
+		Vector2dInt result = new Vector2dInt();
+		result.setX(x - other.getX());
+		result.setY(y - other.getY());
+		return result;
+	}
+
+	public Vector2dInt multiply(int scaleFactor)
+	{
+		Vector2dInt result = new Vector2dInt();
+		result.setX(x * scaleFactor);
+		result.setY(y * scaleFactor);
+		return result;
+	}
+	
+	/**
+	 * Clamp the X Value two a upper or lower bound
+	 * @param min lower bound
+	 * @param max upper bound
+	 */
+	public void clampX(int min, int max)
+	{
+		if(x < min) setX(min);
+		else if(x > max) setX(max);
+	}
+	/**
+	 * Clamp the Y Value two a upper or lower bound
+	 * @param min lower bound
+	 * @param max upper bound
+	 */
+	public void clampY(int min, int max)
+	{
+		if(y < min) setY(min);
+		else if(y > max) setY(max);
+	}
+	
+	
+	public String toString()
+	{
+		return "X: " + x + " Y: " + y;
+	}
+}

+ 1 - 1
src/classes/comparator/UnitGraphPointComperator.java

@@ -9,7 +9,7 @@ public class UnitGraphPointComperator implements Comparator<UnitGraphPoint>{
 
 	@Override
 	public int compare(UnitGraphPoint o1, UnitGraphPoint o2) {
-		return o1.displayedPosition.x - o2.displayedPosition.x;
+		return o1.displayedPosition.getX() - o2.displayedPosition.getX();
 	}
 
 }

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

@@ -11,7 +11,7 @@ import classes.GroupNode;
 import classes.AbstractCanvasObject;
 import classes.HolonObject;
 import classes.HolonSwitch;
-import classes.Position;
+import classes.Vector2dInt;
 import interfaces.ObjectListener;
 import ui.model.Model;
 
@@ -53,10 +53,10 @@ public class CanvasController {
 		 */
 		if(!(object instanceof Node) && replace){
 			/** 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 treshold for replacement */
 			int treshhold = model.getScale()/2;
@@ -74,10 +74,10 @@ public class CanvasController {
 				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){
@@ -202,11 +202,11 @@ public class CanvasController {
 
 		// Location whre to copy the Elements
 		for (AbstractCanvasObject cps : model.getClipboradObjects()) {
-			if (cps.getPosition().x < x) {
-				x = cps.getPosition().x;
+			if (cps.getPosition().getX() < x) {
+				x = cps.getPosition().getX();
 			}
-			if (cps.getPosition().y < y) {
-				y = cps.getPosition().y;
+			if (cps.getPosition().getY() < y) {
+				y = cps.getPosition().getY();
 			}
 		}
 
@@ -220,7 +220,7 @@ public class CanvasController {
 			} else {
 				tCps = new Node("Node");
 			}
-			tCps.setPosition(new Position(p.x + (cps.getPosition().x - x), p.y + (cps.getPosition().y - y)));
+			tCps.setPosition(new Vector2dInt(p.x + (cps.getPosition().x - x), p.y + (cps.getPosition().y - y)));
 			tCps.setSav(cps.getSav());
 			tempList.add(tCps);
 			addObject(tCps, false);

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

@@ -57,8 +57,8 @@ public class ClipboardController {
         store.initNumeration();
 
         file.add("SAV", new JsonPrimitive((upperNode == null ? "CVS" : "" + upperNode.getId())));
-        Position pos = uppC.calculatePos(model.getSelectedCpsObjects());
-        file.add("CENTER", model.getGson().toJsonTree(pos, Position.class));
+        Vector2dInt pos = uppC.calculatePos(model.getSelectedCpsObjects());
+        file.add("CENTER", model.getGson().toJsonTree(pos, Vector2dInt.class));
 
         for (AbstractCanvasObject abs : model.getSelectedCpsObjects()) {
             queue.add(abs);
@@ -130,7 +130,7 @@ public class ClipboardController {
         eleIDMap = new HashMap<>();
         sav = json.get("SAV").getAsString();
 
-        Position old = model.getGson().getAdapter(Position.class).fromJsonTree(json.get("CENTER"));
+        Vector2dInt old = model.getGson().getAdapter(Vector2dInt.class).fromJsonTree(json.get("CENTER"));
         point = new Point(old.x - p.x, old.y - p.y);
 
         forwardObjects(keys, json, objDispatch, eleDispatch, upperNode);
@@ -437,7 +437,7 @@ public class ClipboardController {
         if (y > model.getCanvasX())
             y = model.getCanvasY() - model.getScaleDiv2() - 1;
 
-        temp.setPosition(new Position(x, y));
+        temp.setPosition(new Vector2dInt(x, y));
 
     }
 

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

@@ -37,7 +37,7 @@ public class HolonCanvasController {
 		insertionSizeSort(sortedSize);
 		sortedDist.addAll(bodies);
 
-		ArrayList<Vector2d> pos = insertionDistSort(sortedDist);
+		ArrayList<Vector2dFloat> pos = insertionDistSort(sortedDist);
 		for (int i = 0; i < subCount; i++) {
 			int ID = sortedSize.get(subCount - 1 - i).getId();
 			for (j = 0; j < subCount; j++) {
@@ -179,8 +179,8 @@ public class HolonCanvasController {
 	}
 
 	// Insertion sort for HolonBody distance
-	private ArrayList<Vector2d> insertionDistSort(ArrayList<HolonBody> a) {
-		ArrayList<Vector2d> pos = new ArrayList<>();
+	private ArrayList<Vector2dFloat> insertionDistSort(ArrayList<HolonBody> a) {
+		ArrayList<Vector2dFloat> pos = new ArrayList<>();
 		for (int p = 1; p < subCount; p++) {
 			HolonBody tmp = a.get(p);
 			int j = p;

+ 6 - 6
src/ui/controller/NodeController.java

@@ -4,7 +4,7 @@ import classes.AbstractCanvasObject;
 import classes.Edge;
 import classes.Node;
 import classes.GroupNode;
-import classes.Position;
+import classes.Vector2dInt;
 import ui.model.Model;
 
 import java.awt.*;
@@ -47,8 +47,8 @@ class NodeController {
     		cvs.deleteObjectOnCanvas(node);
     		return;
     	}
-		Position old = calculatePos(node.getNodes());
-		Position p = node.getPosition();
+		Vector2dInt old = calculatePos(node.getNodes());
+		Vector2dInt p = node.getPosition();
 		point = new Point(old.x - p.x, old.y - p.y);
 
 		unmakeNodesOfNodes(node, upperNode);
@@ -128,9 +128,9 @@ class NodeController {
 	/**
 	 * Calculate new Position of the Upper Node
 	 */
-    Position calculatePos(ArrayList<AbstractCanvasObject> toGroup) {
+    Vector2dInt calculatePos(ArrayList<AbstractCanvasObject> toGroup) {
 
-		Position pos = new Position(0, 0);
+		Vector2dInt pos = new Vector2dInt(0, 0);
 
 		// sum(x0 .. xn) / numOfPos, y analog
 		for (AbstractCanvasObject abs : toGroup) {
@@ -287,7 +287,7 @@ class NodeController {
 		if (y > model.getCanvasX())
 			y = model.getCanvasY() - model.getScaleDiv2() - 1;
 
-		temp.setPosition(new Position(x, y));
+		temp.setPosition(new Vector2dInt(x, y));
 
 	}
 }

+ 2 - 2
src/ui/model/Model.java

@@ -25,7 +25,7 @@ import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Node;
 import classes.Pair;
-import classes.Position;
+import classes.Vector2dInt;
 import interfaces.GraphListener;
 import interfaces.ObjectListener;
 import ui.view.DefaulTable;
@@ -812,7 +812,7 @@ public class Model {
         builder.excludeFieldsWithoutExposeAnnotation();
         builder.setPrettyPrinting();
         builder.registerTypeAdapter(AbstractCanvasObject.class, new AbstractCpsObjectAdapter());
-        builder.registerTypeAdapter(Position.class, new PositionAdapter());
+        builder.registerTypeAdapter(Vector2dInt.class, new PositionAdapter());
         builder.registerTypeAdapter(Color.class, new ColorAdapter());
         builder.registerTypeAdapter(Pair.class, new PairAdapter());
         // use the builder and make a instance of the Gson

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

@@ -23,7 +23,7 @@ import classes.GroupNode;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.Node;
-import classes.Position;
+import classes.Vector2dInt;
 import ui.controller.Control;
 import ui.controller.UpdateController;
 import ui.model.Model;
@@ -73,7 +73,7 @@ public abstract class AbstractCanvas extends JPanel {
 	JPopupMenu popmenu = new JPopupMenu();
 	// Tooltip
 	boolean toolTip; // Tooltip on or off
-	Position toolTipPos = new Position(); // Tooltip Position
+	Vector2dInt toolTipPos = new Vector2dInt(); // Tooltip Position
 	String toolTipText = "";
 	ArrayList<HolonElement> dataSelected = new ArrayList<>();
 	ArrayList<AbstractCanvasObject> tempSelected = new ArrayList<>();
@@ -85,11 +85,11 @@ public abstract class AbstractCanvas extends JPanel {
 	boolean doMark = false; // for double click
 	Edge edgeHighlight = null;
 	Point mousePosition = new Point(); // Mouse Position when
-	ArrayList<Position> savePos;
+	ArrayList<Vector2dInt> savePos;
 	// edge Object Start Point
 	int cx, cy;
 	int sx, sy; // Mark Coords
-	Position unPos;
+	Vector2dInt unPos;
 	// Animation
 	Timer animT; // animation Timer
 	int animDuration = ANIMTIME; // animation Duration
@@ -307,7 +307,7 @@ public abstract class AbstractCanvas extends JPanel {
 		AbstractCanvasObject toBeReplaced = null;
 		
 		/** Position of object that might be replaced */
-		Position p;
+		Vector2dInt p;
 		
 		/** for each cps on Canvas */
 		if(draggedCps == null || !(draggedCps instanceof Node) && !(draggedCps instanceof Node)){
@@ -383,7 +383,7 @@ public abstract class AbstractCanvas extends JPanel {
 	 */
 	protected void align(AbstractCanvasObject cps, int distance) {
 		/** Position of the AbstractCpsObject which should be aligned */
-		Position p = cps.getPosition();
+		Vector2dInt p = cps.getPosition();
 		
 		//calculate how many pixels the cps should be decreased to align
 		/** x offset relative to a grid with lines every distance pixels */

+ 27 - 27
src/ui/view/GroupNodeCanvas.java

@@ -33,8 +33,8 @@ import classes.GroupNode;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Node;
-import classes.Position;
-import classes.Vector2d;
+import classes.Vector2dInt;
+import classes.Vector2dFloat;
 import ui.controller.Control;
 import ui.controller.UpdateController;
 import ui.model.Consumer;
@@ -86,7 +86,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
         for (AbstractCanvasObject cps : upperNode.getNodes()) {
             if (cps.getPosition().x < model.getScaleDiv2() + upperNode.getLeftBorder() + 5) {
                 cps.setPosition(
-                        new Position(upperNode.getLeftBorder() + 5 + model.getScaleDiv2(), cps.getPosition().y));
+                        new Vector2dInt(upperNode.getLeftBorder() + 5 + model.getScaleDiv2(), cps.getPosition().y));
             }
         }
 
@@ -122,7 +122,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
         
         itemGroup.addActionListener(actionEvent -> {
             // calculate uppernode pos (taken from the controller)
-            unPos = new Position(0, 0);
+            unPos = new Vector2dInt(0, 0);
             animCps = new ArrayList<>();
             for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
                 animCps.add(cps); // add to animation Cps ArrayList
@@ -135,7 +135,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
             // save old Position
             savePos = new ArrayList<>();
             for (int i = 0; i < animCps.size(); i++) {
-                savePos.add(new Position(0, 0));
+                savePos.add(new Vector2dInt(0, 0));
                 savePos.get(i).x = animCps.get(i).getPosition().x;
                 savePos.get(i).y = animCps.get(i).getPosition().y;
             }
@@ -176,7 +176,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
             controller.ungroupGroupNode((GroupNode) tempCps, upperNode);
 
             for (int i = 0; i < animCps.size(); i++) {
-                savePos.add(new Position(0, 0));
+                savePos.add(new Vector2dInt(0, 0));
                 savePos.get(i).x = animCps.get(i).getPosition().x;
                 savePos.get(i).y = animCps.get(i).getPosition().y;
             }
@@ -184,7 +184,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
                 int x = tempCps.getPosition().x;
                 int y = tempCps.getPosition().y;
 
-                cps.setPosition(new Position(x, y));
+                cps.setPosition(new Vector2dInt(x, y));
             }
 
             animT = new javax.swing.Timer(animDelay, actionEvent1 -> {
@@ -305,13 +305,13 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		}
 	}
 	private void paintCanvasObject(Graphics2D g, DecoratedHolonObject decoratedHolonObject){
-		Position pos = decoratedHolonObject.getModel().getPosition();
+		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());
 		drawCanvasObject(g, decoratedHolonObject.getModel().getImage(), pos);
 	}
-	private void drawCanvasObjectString(Graphics2D g, Position posOfCanvasObject, float energy) {
+	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);
@@ -326,7 +326,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		drawCanvasObjectString(g, sup.getModel().getPosition(), sup.getEnergyToSupplyNetwork());
 	}
 	
-	private void drawCanvasObject(Graphics2D g, String Image, Position pos) {
+	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(),
@@ -335,8 +335,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 	
 	private void paintCable(Graphics2D g, DecoratedCable cable, boolean isSelected)
 	{
-		Position start = cable.getModel().getA().getPosition();
-		Position end =  cable.getModel().getB().getPosition();
+		Vector2dInt start = cable.getModel().getA().getPosition();
+		Vector2dInt end =  cable.getModel().getB().getPosition();
 		float currentEnergy = cable.getFlowEnergy();
 		float capacity = cable.getModel().getCapacity();
 		boolean unlimited = cable.getModel().isUnlimitedCapacity();
@@ -354,7 +354,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 			g.setColor(Color.lightGray);
 		}
 		g.drawLine(start.x, start.y, end.x, end.y);
-		Position middle = new Position((start.x + end.x) / 2, (start.y + end.y) / 2);
+		Vector2dInt middle = new Vector2dInt((start.x + end.x) / 2, (start.y + end.y) / 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);
 	}
@@ -363,13 +363,13 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		drawCanvasObject(g, dSwitch.getState() == SwitchState.Open ? HolonSwitch.getSwitchOpenImage(): HolonSwitch.getSwitchClosedImage() , dSwitch.getModel().getPosition());
 	}
 	private void paintGroupNode(Graphics2D g, DecoratedGroupNode dGroupNode) {
-		Position pos = dGroupNode.getModel().getPosition();
+		Vector2dInt pos = dGroupNode.getModel().getPosition();
 		g.setColor(Color.lightGray);
 		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
 		drawCanvasObject(g, "/Images/upper_node.png" , pos);
 		paintGroupNodeBar(g, dGroupNode, pos);
 	}
-	private void paintGroupNodeBar(Graphics2D g, DecoratedGroupNode dGroupNode , Position pos) {
+	private void paintGroupNodeBar(Graphics2D g, DecoratedGroupNode dGroupNode , Vector2dInt pos) {
 		// +1, -2, -1 little Adjustment for pixel perfect alignment
 		int barWidth = (int) (controller.getScale());
 		int barHeight = (int) (controller.getScale() / 5);
@@ -422,8 +422,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 			System.out.println(" wrongCable: " + " start:"  +eCable.getStart() + " end:"  +eCable.getFinish() + " state:" + eCable.getState());
 			return;
 		}
-		Position start = eCable.getStart().getPosition();
-		Position end = eCable.getFinish().getPosition();
+		Vector2dInt start = eCable.getStart().getPosition();
+		Vector2dInt end = eCable.getFinish().getPosition();
 		float currentEnergy = eCable.getCable().getFlowEnergy();
 		float capacity = eCable.getCable().getModel().getCapacity();
 		boolean unlimited = eCable.getCable().getModel().isUnlimitedCapacity();
@@ -441,20 +441,20 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		case DOWN:
 		case DOWNDOWN:
 			g.drawLine(start.x, start.y, end.x, end.y);
-			Position middle = new Position((start.x + end.x) / 2, (start.y + end.y) / 2);
+			Vector2dInt middle = new Vector2dInt((start.x + end.x) / 2, (start.y + end.y) / 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);
 			break;
 		case DOWNUP:
 		case UP:
-			Vector2d vStart = new Vector2d(start.x, start.y);
-			Vector2d vEnd = new Vector2d(end.x, end.y);
+			Vector2dFloat vStart = new Vector2dFloat(start.x, start.y);
+			Vector2dFloat vEnd = new Vector2dFloat(end.x, end.y);
 			float stretchFactor = 4 * model.getScale();
 			stretchFactor =  (stretchFactor > vStart.getDistance(vEnd))? vStart.getDistance(vEnd) : stretchFactor;
-			Vector2d vPosition = vStart.add((vEnd.subtract(vStart)).normalize().multiply(stretchFactor));
-			Position result = new Position(Math.round(vPosition.getX()),Math.round(vPosition.getY()));
+			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);
-			Position middle1 = new Position((start.x +result.x) / 2, (start.y + +result.y) / 2);
+			Vector2dInt middle1 = new Vector2dInt((start.x +result.x) / 2, (start.y + +result.y) / 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);
 			drawCanvasObject(g, "/Images/arrowUp.png" , result);
@@ -464,7 +464,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 			break;
 		}
 	}
-	private void paintSupplyBar(Graphics2D g, float percentage, Color color, Position pos) {
+	private void paintSupplyBar(Graphics2D g, float percentage, Color color, Vector2dInt pos) {
 		// +1, -2, -1 little Adjustment for pixel perfect alignment
 		int barWidth = (int) (controller.getScale());
 		int barHeight = (int) (controller.getScale() / 5);
@@ -568,7 +568,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		Color transparentGrey = new Color(128, 174, 247, 40);
 		for(AbstractCanvasObject aCps:  model.getSelectedCpsObjects()) {
 			if(aCps instanceof Node) {
-				Position pos = aCps.getPosition();
+				Vector2dInt pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
 				g2d.fillOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 				g2d.setColor(Color.LIGHT_GRAY);
@@ -576,7 +576,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 				g2d.drawOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 			}
 			else {
-				Position pos = aCps.getPosition();
+				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.setColor(Color.LIGHT_GRAY);
@@ -588,7 +588,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		//maybeReplace:
 		if(mayBeReplaced != null){
 			g2d.setColor(Color.RED);
-			Position pos = mayBeReplaced.getPosition();
+			Vector2dInt pos = mayBeReplaced.getPosition();
 			g.drawImage(ImageImport.loadImage("/Images/replace.png") , 
 					pos.x + controller.getScaleDiv2(),
 					pos.y - controller.getScale(),

+ 21 - 21
src/ui/view/MyCanvas.java

@@ -32,7 +32,7 @@ import classes.GroupNode;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Node;
-import classes.Position;
+import classes.Vector2dInt;
 import ui.controller.Control;
 import ui.controller.UpdateController;
 import ui.model.Consumer;
@@ -104,7 +104,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		
 		itemGroup.addActionListener(actionEvent -> {
 			// calculate uppernode pos (taken from the controller)
-				unPos = new Position(0, 0);
+				unPos = new Vector2dInt(0, 0);
 				animCps = new ArrayList<>();
 				for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
 					animCps.add(cps); // add to animation Cps ArrayList
@@ -117,7 +117,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 				// save old Position
 				savePos = new ArrayList<>();
 				for (int i = 0; i < animCps.size(); i++) {
-					savePos.add(new Position(0, 0));
+					savePos.add(new Vector2dInt(0, 0));
 					savePos.get(i).x = animCps.get(i).getPosition().x;
 					savePos.get(i).y = animCps.get(i).getPosition().y;
 				}
@@ -163,7 +163,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 					controller.ungroupGroupNode((GroupNode) tempCps, null);
 
 					for (int i = 0; i < animCps.size(); i++) {
-						savePos.add(new Position(0, 0));
+						savePos.add(new Vector2dInt(0, 0));
 						savePos.get(i).x = animCps.get(i).getPosition().x;
 						savePos.get(i).y = animCps.get(i).getPosition().y;
 					}
@@ -171,7 +171,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 						int x = tempCps.getPosition().x;
 						int y = tempCps.getPosition().y;
 
-						cps.setPosition(new Position(x, y));
+						cps.setPosition(new Vector2dInt(x, y));
 					}
 
 					animT = new javax.swing.Timer(
@@ -180,7 +180,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 								model.getSelectedCpsObjects().clear();
 								if (animDuration - animDelay >= 0) {
 									for (int i = 0; i < animCps.size(); i++) {
-										Position pos = animCps.get(i).getPosition();
+										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;
@@ -326,13 +326,13 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		}
 	}
 	private void paintCanvasObject(Graphics2D g, DecoratedHolonObject decoratedHolonObject){
-		Position pos = decoratedHolonObject.getModel().getPosition();
+		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());
 		drawCanvasObject(g, decoratedHolonObject.getModel().getImage(), pos);
 	}
-	private void drawCanvasObjectString(Graphics2D g, Position posOfCanvasObject, float energy) {
+	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);
@@ -347,7 +347,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		drawCanvasObjectString(g, sup.getModel().getPosition(), sup.getEnergyToSupplyNetwork());
 	}
 	
-	private void drawCanvasObject(Graphics2D g, String Image, Position pos) {
+	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(),
@@ -356,8 +356,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 	
 	private void paintCable(Graphics2D g, DecoratedCable cable, boolean isSelected)
 	{
-		Position start = cable.getModel().getA().getPosition();
-		Position end =  cable.getModel().getB().getPosition();
+		Vector2dInt start = cable.getModel().getA().getPosition();
+		Vector2dInt end =  cable.getModel().getB().getPosition();
 		float currentEnergy = cable.getFlowEnergy();
 		float capacity = cable.getModel().getCapacity();
 		boolean unlimited = cable.getModel().isUnlimitedCapacity();
@@ -376,7 +376,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		}
 		g.drawLine(start.x, start.y, end.x, end.y);
 		if(showConnectionInformation) {			
-			Position middle = new Position((start.x + end.x) / 2, (start.y + end.y) / 2);
+			Vector2dInt middle = new Vector2dInt((start.x + end.x) / 2, (start.y + end.y) / 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);
 		}
@@ -387,8 +387,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 	}
 	
 	private void paintExitCable(Graphics2D g, ExitCable eCable) {
-		Position start = eCable.getStart().getPosition();
-		Position end = eCable.getFinish().getPosition();
+		Vector2dInt start = eCable.getStart().getPosition();
+		Vector2dInt end = eCable.getFinish().getPosition();
 		float currentEnergy = eCable.getCable().getFlowEnergy();
 		float capacity = eCable.getCable().getModel().getCapacity();
 		boolean unlimited = eCable.getCable().getModel().isUnlimitedCapacity();
@@ -403,18 +403,18 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 			break;
 		}
 		g.drawLine(start.x, start.y, end.x, end.y);
-		Position middle = new Position((start.x + end.x) / 2, (start.y + end.y) / 2);
+		Vector2dInt middle = new Vector2dInt((start.x + end.x) / 2, (start.y + end.y) / 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);
 	}
 	private void paintGroupNode(Graphics2D g, DecoratedGroupNode dGroupNode) {
-		Position pos = dGroupNode.getModel().getPosition();
+		Vector2dInt pos = dGroupNode.getModel().getPosition();
 		g.setColor(Color.lightGray);
 		g.fillRect(pos.x - controller.getScaleDiv2(), pos.y - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
 		drawCanvasObject(g, "/Images/upper_node.png" , pos);
 		paintGroupNodeBar(g, dGroupNode, pos);
 	}
-	private void paintGroupNodeBar(Graphics2D g, DecoratedGroupNode dGroupNode , Position pos) {
+	private void paintGroupNodeBar(Graphics2D g, DecoratedGroupNode dGroupNode , Vector2dInt pos) {
 		// +1, -2, -1 little Adjustment for pixel perfect alignment
 		int barWidth = (int) (controller.getScale());
 		int barHeight = (int) (controller.getScale() / 5);
@@ -461,7 +461,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		}
 		return percentages;
 	}
-	private void paintSupplyBar(Graphics2D g, float percentage, Color color, Position pos) {
+	private void paintSupplyBar(Graphics2D g, float percentage, Color color, Vector2dInt pos) {
 		// +1, -2, -1 little Adjustment for pixel perfect alignment
 		int barWidth = (int) (controller.getScale());
 		int barHeight = (int) (controller.getScale() / 5);
@@ -566,7 +566,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		Color transparentGrey = new Color(128, 174, 247, 40);
 		for(AbstractCanvasObject aCps:  model.getSelectedCpsObjects()) {
 			if(aCps instanceof Node) {
-				Position pos = aCps.getPosition();
+				Vector2dInt pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
 				g2d.fillOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 				g2d.setColor(Color.LIGHT_GRAY);
@@ -574,7 +574,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 				g2d.drawOval(pos.x - (int) (controller.getScaleDiv2()), pos.y - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 			}
 			else {
-				Position pos = aCps.getPosition();
+				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.setColor(Color.LIGHT_GRAY);
@@ -586,7 +586,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		//maybeReplace:
 		if(mayBeReplaced != null){
 			g2d.setColor(Color.RED);
-			Position pos = mayBeReplaced.getPosition();
+			Vector2dInt pos = mayBeReplaced.getPosition();
 			g2d.drawImage(ImageImport.loadImage("/Images/replace.png") , 
 					pos.x + controller.getScaleDiv2(),
 					pos.y - controller.getScale(),

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

@@ -18,7 +18,7 @@ import java.util.ListIterator;
 
 import javax.swing.JPanel;
 
-import classes.Position;
+import classes.Vector2dInt;
 import classes.UnitGraphPoint;
 import interfaces.GraphEditable;
 import interfaces.GraphEditable.Graphtype;
@@ -56,7 +56,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	private LinkedList<UnitGraphPoint> actualGraphPoints = new LinkedList<UnitGraphPoint>();
 	private Graphtype actualGraphType;
 	private GraphEditable actualElement;
-	Position editPosition;
+	Vector2dInt editPosition;
 	boolean editMode = false;
 	private enum pointType {Normal, StartPoint, EndPoint};
 	pointType editPoint = pointType.Normal;
@@ -213,8 +213,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     		int lPeriod = this.getLocalPeriod();
     		where = ((double) cur%lPeriod)/((double) lPeriod);
     	}
-    	Position oben = new Position(border + (int)(where * widthWithBorder), 0);
-    	Position unten = new Position(border + (int)(where * widthWithBorder), 2 * border + heightWithBorder);
+    	Vector2dInt oben = new Vector2dInt(border + (int)(where * widthWithBorder), 0);
+    	Vector2dInt unten = new Vector2dInt(border + (int)(where * widthWithBorder), 2 * border + heightWithBorder);
     	drawLine(g,oben,unten);
     	
     }
@@ -227,7 +227,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param start the Position of one end of the line to draw. 
      * @param end the other Ends Position of the Line to draw.
      */
-    private void drawLine(Graphics2D g, Position start, Position end)
+    private void drawLine(Graphics2D g, Vector2dInt start, Vector2dInt end)
     {
     	Path2D.Double path = new Path2D.Double();
     	path.moveTo(start.x, start.y);
@@ -241,7 +241,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * Initialize a Cubic BezierCurve.
      * @param start The Position to start the Curve.
      */
-    private Path2D.Double initBezier(Position start) {
+    private Path2D.Double initBezier(Vector2dInt start) {
     	//Good Source for basic understanding for Bezier Curves
         //http://www.theappguruz.com/blog/bezier-curve-in-games
     	Path2D.Double path = new Path2D.Double();
@@ -256,7 +256,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param actaul the actual Position of the Path.
      * @param target the end Position of the Curve.
      */
-    private void curveTo(Path2D.Double path, Position actual, Position target) {
+    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);
     }
@@ -267,7 +267,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param g to draw.
      * @param p the position of the Dot.
      */
-    private void drawDot(Graphics2D g, Position p)
+    private void drawDot(Graphics2D g, Vector2dInt p)
     {    	
     	g.fillOval(p.x -dotSize/2, p.y-dotSize/2, dotSize, dotSize);
     }
@@ -281,17 +281,17 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      */
     private void drawBoolGraph(Graphics2D g) {
     	if(actualGraphPoints.size() <= 1) return;
-    	LinkedList<Position> cornerPoints =  new LinkedList<Position>();
+    	LinkedList<Vector2dInt> cornerPoints =  new LinkedList<Vector2dInt>();
      	ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
-     	Position actual = actualGraphPoints.getFirst().displayedPosition;
+     	Vector2dInt actual = actualGraphPoints.getFirst().displayedPosition;
      	Path2D.Double path = new Path2D.Double();
      	path.moveTo(actual.x, actual.y);
      	while (iter.hasNext())
     	{
-    		Position target = iter.next().displayedPosition;
+    		Vector2dInt target = iter.next().displayedPosition;
     		//BooleanConnection
     		path.lineTo(target.x, actual.y); //line to corner
-    		cornerPoints.add(new Position(target.x, actual.y)); //save corner
+    		cornerPoints.add(new Vector2dInt(target.x, actual.y)); //save corner
     		path.lineTo(target.x, target.y); //line to next Point
     		
     		actual = target;
@@ -299,7 +299,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      	g.draw(path);
      	//Draw the Points on the Corner that dont exist in Data but should be visual
      	g.setColor(dotColor);
-     	for(Position p: cornerPoints)
+     	for(Vector2dInt p: cornerPoints)
      	{
      		drawDot(g, p);
      	}
@@ -312,8 +312,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param g2D to draw.
      */
     private void drawBoolGraphInEditMode(Graphics2D g) {
-    	LinkedList<Position> before = new LinkedList<Position>();
-     	LinkedList<Position> after = new LinkedList<Position>();
+    	LinkedList<Vector2dInt> before = new LinkedList<Vector2dInt>();
+     	LinkedList<Vector2dInt> after = new LinkedList<Vector2dInt>();
      	for(UnitGraphPoint p: actualGraphPoints)
      	{
      		if(p.displayedPosition.x < editPosition.x)
@@ -326,7 +326,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      	g.setColor(Color.BLACK);
      	drawBoolGraphFromList(g, after);
      	//EditGraph
-     	LinkedList<Position> middle = new LinkedList<Position>();
+     	LinkedList<Vector2dInt> middle = new LinkedList<Vector2dInt>();
      	if(!before.isEmpty()) middle.add(before.getLast());
      	middle.add(editPosition);
     	if(!after.isEmpty()) middle.add(after.getFirst());
@@ -367,25 +367,25 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param g2D to draw.
      * @param list the PositionList to draw a BoolGraph
      */
-	private void drawBoolGraphFromList(Graphics2D g, LinkedList<Position> list) {
+	private void drawBoolGraphFromList(Graphics2D g, LinkedList<Vector2dInt> list) {
 		if(list.size() <= 1) return;
-     	ListIterator<Position> iter = list.listIterator();
-      	LinkedList<Position> cornerPoints =  new LinkedList<Position>();
-     	Position actual = list.getFirst();
+     	ListIterator<Vector2dInt> iter = list.listIterator();
+      	LinkedList<Vector2dInt> cornerPoints =  new LinkedList<Vector2dInt>();
+     	Vector2dInt actual = list.getFirst();
      	Path2D.Double path = new Path2D.Double();
      	path.moveTo(actual.x, actual.y);
      	while (iter.hasNext())
     	{
-    		Position target = iter.next();
+    		Vector2dInt target = iter.next();
     		//BooleanConnection
     		path.lineTo(target.x, actual.y); //line to corner
-    		cornerPoints.add(new Position(target.x, actual.y)); //save corner
+    		cornerPoints.add(new Vector2dInt(target.x, actual.y)); //save corner
     		path.lineTo(target.x, target.y); //line to next Point
     		actual = target;
     	}
      	g.draw(path);
     	g.setColor(dotColor);
-     	for(Position p: cornerPoints)
+     	for(Vector2dInt p: cornerPoints)
      	{
      		drawDot(g, p);
      	}
@@ -400,11 +400,11 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     private void drawDoubleGraph(Graphics2D g) {
     	if(actualGraphPoints.isEmpty()) throw new IndexOutOfBoundsException("A Graph Without Points is not supportet jet");
     	ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
-    	Position actual = iter.next().displayedPosition;
+    	Vector2dInt actual = iter.next().displayedPosition;
     	Path2D.Double path = this.initBezier(actual);
     	while (iter.hasNext())
     	{
-    		Position target = iter.next().displayedPosition;
+    		Vector2dInt target = iter.next().displayedPosition;
     		this.curveTo(path, actual, target);
     		actual = target;
     	}
@@ -418,8 +418,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param g2D to draw.
      */
     private void drawDoubleGraphInEditMode(Graphics2D g) {
-     	LinkedList<Position> before = new LinkedList<Position>();
-     	LinkedList<Position> after = new LinkedList<Position>();
+     	LinkedList<Vector2dInt> before = new LinkedList<Vector2dInt>();
+     	LinkedList<Vector2dInt> after = new LinkedList<Vector2dInt>();
      	for(UnitGraphPoint p: actualGraphPoints)
      	{
      		if(p.displayedPosition.x < editPosition.x)
@@ -430,7 +430,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      	drawUnitGraphFromList(g, before);
      	drawUnitGraphFromList(g, after);
      	//EditGraph
-     	LinkedList<Position> middle = new LinkedList<Position>();
+     	LinkedList<Vector2dInt> middle = new LinkedList<Vector2dInt>();
      	if(!before.isEmpty()) middle.add(before.getLast());
      	middle.add(editPosition);
     	if(!after.isEmpty()) middle.add(after.getFirst());
@@ -446,14 +446,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param g2D to draw.
      * @param list the PositionList to draw a DoubleGraph
      */
-	private void drawUnitGraphFromList(Graphics2D g, LinkedList<Position> list) {
+	private void drawUnitGraphFromList(Graphics2D g, LinkedList<Vector2dInt> list) {
 		if(list.size() <= 1) return;
-     	ListIterator<Position> iter = list.listIterator();
-     	Position actual = list.getFirst();
+     	ListIterator<Vector2dInt> iter = list.listIterator();
+     	Vector2dInt actual = list.getFirst();
      	Path2D.Double path = this.initBezier(actual);
      	while (iter.hasNext())
     	{
-    		Position target = iter.next();
+    		Vector2dInt target = iter.next();
     		curveTo(path, actual, target);
     		actual = target;
     	}
@@ -509,7 +509,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * Remove a UnitGraphPoint from the UnitGraphPoint list ({@link #actualGraphPoints} when its near a given Position.
      * @param mPosition
      */
-    private void removePointNearPosition(Position mPosition) {
+    private void removePointNearPosition(Vector2dInt mPosition) {
     	ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
     	while (iter.hasNext())
     	{
@@ -526,7 +526,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * Determine if the Point is a StartPoint , EndPoint or a NormalPoint a.k.a. in between Points.
      * @param mPosition The Position to check.
      */
-    private void  detectStartEndPoint(Position mPosition)
+    private void  detectStartEndPoint(Vector2dInt mPosition)
     {
     	UnitGraphPoint first = actualGraphPoints.getFirst();
     	UnitGraphPoint last = actualGraphPoints.getLast();
@@ -541,7 +541,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param target
      * @return
      */
-	private boolean near(Position actual, Position target) {
+	private boolean near(Vector2dInt actual, Vector2dInt target) {
 		switch(actualGraphType)
 		{
 		case boolGraph: //Distance only with X 
@@ -558,9 +558,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * When the Mouse Drag a Point it updates each time the position.
 	 * @param newPosition
 	 */
-    private void updateEditPointPosition(Position newPosition) {
+    private void updateEditPointPosition(Vector2dInt newPosition) {
     	//make it in the bounds of the UnitGraph no Point out of the Border
-    	Position currentPosition = setInBounds(newPosition);
+    	Vector2dInt currentPosition = setInBounds(newPosition);
     	if(editPoint != pointType.Normal) attachToBorder(currentPosition);
     	if(actualGraphType == Graphtype.boolGraph) snapBoolean(currentPosition);
     	this.editPosition = currentPosition;
@@ -572,7 +572,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param p the Position
 	 * @return the updated Position.
      */
-	private Position setInBounds(Position p) {
+	private Vector2dInt setInBounds(Vector2dInt p) {
 		p.clampX(border, border + widthWithBorder);
 		p.clampY(border, border + heightWithBorder);
 		return p;
@@ -585,7 +585,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * @param p the Position
 	 * @return the updated Position.
 	 */
-	private Position snapBoolean(Position p)
+	private Vector2dInt snapBoolean(Vector2dInt p)
 	{
 		if (p.y < border + heightWithBorder / 2) {
 			p.y = border;
@@ -601,7 +601,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * @param p the Position
 	 * @return the updated Position.
 	 */
-	private Position attachToBorder(Position p)
+	private Vector2dInt attachToBorder(Vector2dInt p)
 	{
 		switch(editPoint)
 		{
@@ -621,13 +621,13 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * Its sorted based on the xValues.
 	 * @param pos The new UnitGraphPoints Position
 	 */
-    private void insertNewGraphPoint(Position pos)
+    private void insertNewGraphPoint(Vector2dInt pos)
     {
     	setInBounds(pos);
     	ListIterator<UnitGraphPoint> iter2 = actualGraphPoints.listIterator();
     	while (iter2.hasNext())
     	{
-    		Position tempPosition = iter2.next().displayedPosition;
+    		Vector2dInt tempPosition = iter2.next().displayedPosition;
     		if(pos.x <= tempPosition.x)
     		{
     			//previous to go back a position to make the new point before the the Position with greater X
@@ -646,7 +646,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param pos the normal pos with xValues from 0..Width and yValues from 0..Height
      * @return a UnitGraphPoint
      */
-	private UnitGraphPoint generateUnitGraphPoint(Position pos) {
+	private UnitGraphPoint generateUnitGraphPoint(Vector2dInt pos) {
 		UnitGraphPoint temp = new UnitGraphPoint((double) (pos.x - border) / (double) widthWithBorder,
 				1 - (double) (pos.y - border) / (double) heightWithBorder, true);
 		temp.displayedPosition = pos;
@@ -658,7 +658,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      */
 	@Override
     public void mouseDragged(MouseEvent e) {
-    	updateEditPointPosition(new Position(e.getPoint()));
+    	updateEditPointPosition(new Vector2dInt(e.getPoint()));
     	repaint();
     }
 
@@ -685,7 +685,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      */
     @Override
     public void mousePressed(MouseEvent e) {
-		Position mPosition = new Position(e.getPoint());
+		Vector2dInt mPosition = new Vector2dInt(e.getPoint());
 		if (e.getButton() == MouseEvent.BUTTON3) {
 			// RightMouseButtonEvent
 			detectStartEndPoint(mPosition);

+ 2 - 2
tests/tests/PraktikumHolonsTestClasses.java

@@ -153,8 +153,8 @@ public class PraktikumHolonsTestClasses {
 	*/
 	@Test
 	public void testPosition() {
-		Position pos1 = new Position(100, 200);
-		Position pos2 = new Position();
+		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);