Prechádzať zdrojové kódy

Merge branch 'updateInProgress' into XChart-integration

Conflicts:
	src/ui/controller/LoadController.java
	src/ui/view/GroupNodeCanvas.java
	src/ui/view/MyCanvas.java
	src/utility/ImageImport.java
TomTroppmann 3 rokov pred
rodič
commit
59a6753092
62 zmenil súbory, kde vykonal 764 pridanie a 688 odobranie
  1. BIN
      exampleNetworks/undersupplied_holon_model_eval.holon
  2. 7 7
      src/TypeAdapter/PositionAdapter.java
  3. 2 2
      src/addOns/Randomizer.java
  4. 1 1
      src/addOns/Utility/EmailNotification.java
  5. 1 1
      src/addOns/Utility/HolonElementSketch.java
  6. 1 1
      src/algorithm/binary/AcoAlgorithm.java
  7. 2 2
      src/algorithm/objectiveFunction/ObjectiveFunctionByCarlos.java
  8. 1 1
      src/algorithm/objectiveFunction/TopologieObjectiveFunction.java
  9. 1 1
      src/algorithm/topologie/AcoAlgorithm.java
  10. 1 1
      src/algorithm/topologie/GaAlgorithm.java
  11. 1 1
      src/algorithm/topologie/PsoAlgorithm.java
  12. 2 2
      src/api/AlgorithmFrameworkFlex.java
  13. 6 5
      src/api/TopologieAlgorithmFramework.java
  14. 8 5
      src/classes/AbstractCanvasObject.java
  15. 1 1
      src/classes/Edge.java
  16. 3 1
      src/classes/GroupNode.java
  17. 11 9
      src/classes/HolonBody.java
  18. 3 2
      src/classes/HolonElement.java
  19. 39 10
      src/classes/IdCounter.java
  20. 0 50
      src/classes/IdCounterElem.java
  21. 3 1
      src/classes/Node.java
  22. 0 94
      src/classes/Position.java
  23. 4 2
      src/classes/UnitGraphPoint.java
  24. 0 108
      src/classes/Vector2d.java
  25. 1 1
      src/classes/comparator/UnitGraphPointComperator.java
  26. 10 10
      src/ui/controller/CanvasController.java
  27. 1 1
      src/ui/controller/CategoryController.java
  28. 12 9
      src/ui/controller/ClipboardController.java
  29. 1 1
      src/ui/controller/Control.java
  30. 4 3
      src/ui/controller/HolonCanvasController.java
  31. 6 4
      src/ui/controller/LoadController.java
  32. 15 19
      src/ui/controller/NodeController.java
  33. 6 4
      src/ui/controller/SaveController.java
  34. 2 2
      src/ui/model/Model.java
  35. 1 1
      src/ui/view/AboutUsPopUp.java
  36. 26 26
      src/ui/view/AbstractCanvas.java
  37. 1 1
      src/ui/view/AddElementPopUp.java
  38. 1 1
      src/ui/view/AddObjectPopUp.java
  39. 1 1
      src/ui/view/AddOnWindow.java
  40. 1 1
      src/ui/view/BackgroundPopUp.java
  41. 1 1
      src/ui/view/CanvasResizePopUp.java
  42. 1 1
      src/ui/view/Console.java
  43. 1 1
      src/ui/view/CreateTemplatePopUp.java
  44. 1 1
      src/ui/view/FlexWindow.java
  45. 5 5
      src/ui/view/GUI.java
  46. 94 105
      src/ui/view/GroupNodeCanvas.java
  47. 1 1
      src/ui/view/HolonInformationPanel.java
  48. 82 92
      src/ui/view/MyCanvas.java
  49. 1 1
      src/ui/view/Outliner.java
  50. 1 1
      src/ui/view/TimePanel.java
  51. 69 69
      src/ui/view/UnitGraph.java
  52. 1 1
      src/utility/Action.java
  53. 1 1
      src/utility/Event.java
  54. 1 1
      src/utility/FloatLog.java
  55. 1 1
      src/utility/ImageImport.java
  56. 1 1
      src/utility/Random.java
  57. 1 1
      src/utility/StringFormat.java
  58. 153 0
      src/utility/Vector2Float.java
  59. 145 0
      src/utility/Vector2Int.java
  60. 3 2
      tests/tests/PraktikumHolonsAdapter.java
  61. 2 1
      tests/tests/PraktikumHolonsTestCanvasController.java
  62. 11 8
      tests/tests/PraktikumHolonsTestClasses.java

BIN
exampleNetworks/undersupplied_holon_model_eval.holon


+ 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 utility.Vector2Int;
 
-public class PositionAdapter implements JsonSerializer<Position>, JsonDeserializer<Position> {
+public class PositionAdapter implements JsonSerializer<Vector2Int>, JsonDeserializer<Vector2Int> {
 
 	@Override
-	public JsonElement serialize(Position arg0, Type arg1, JsonSerializationContext arg2) {
-		return new JsonPrimitive(arg0.x + ":" + arg0.y);
+	public JsonElement serialize(Vector2Int arg0, Type arg1, JsonSerializationContext arg2) {
+		return new JsonPrimitive(arg0.getX() + ":" + arg0.getY());
 	}
 
 	@Override
-	public Position deserialize(JsonElement arg0, Type arg1, JsonDeserializationContext arg2) {
+	public Vector2Int 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 Vector2Int(x, y);
 
 		} catch (NumberFormatException e) {
 			System.err.println(e);
 		}
-		return new Position(-1, -1);
+		return new Vector2Int(-1, -1);
 	}
 
 }

+ 2 - 2
src/addOns/Randomizer.java

@@ -45,8 +45,8 @@ import classes.GroupNode;
 import classes.HolonElement;
 import classes.HolonObject;
 import ui.controller.Control;
-import util.ImageImport;
-import util.Random;
+import utility.ImageImport;
+import utility.Random;
 
 public class Randomizer implements AddOn {
 	private Control  control;

+ 1 - 1
src/addOns/Utility/EmailNotification.java

@@ -16,7 +16,7 @@ import javax.swing.JTextField;
 
 import org.apache.commons.mail.*;
 
-import util.ImageImport;
+import utility.ImageImport;
 
 
 public class EmailNotification {

+ 1 - 1
src/addOns/Utility/HolonElementSketch.java

@@ -4,7 +4,7 @@ import classes.Constrain;
 import classes.Flexibility;
 import classes.HolonElement;
 import classes.HolonElement.Priority;
-import util.Random;
+import utility.Random;
 import classes.HolonObject;
 
 public class HolonElementSketch {

+ 1 - 1
src/algorithm/binary/AcoAlgorithm.java

@@ -6,7 +6,7 @@ import java.util.ListIterator;
 
 import javax.swing.JFrame;
 import api.AlgorithmFrameworkFlex;
-import util.StringFormat;
+import utility.StringFormat;
 
 public class AcoAlgorithm extends AlgorithmFrameworkFlex{
 	

+ 2 - 2
src/algorithm/objectiveFunction/ObjectiveFunctionByCarlos.java

@@ -16,9 +16,9 @@ public class ObjectiveFunctionByCarlos {
 	
 	//kappas for squashing function
 //	
-	static double k_eb = 1050000.f, k_state = 10000, k_pro = 2000, k_perf = 11000, k_holon= 150000;
+	//static double k_eb = 1050000.f, k_state = 10000, k_pro = 2000, k_perf = 11000, k_holon= 150000;
 //  oversupplied
-//	static double k_eb = 750000.f, k_state = 20000, k_pro = 3000, k_perf = 15000, k_holon= 200000;
+	static double k_eb = 750000.f, k_state = 20000, k_pro = 3000, k_perf = 15000, k_holon= 200000;
 	
 //	old values undersupplied 
 //	static double k_eb = 1000000.f, k_state = 15000, k_pro = 2100, k_perf = 12000, k_holon= 200000;

+ 1 - 1
src/algorithm/objectiveFunction/TopologieObjectiveFunction.java

@@ -4,7 +4,7 @@ package algorithm.objectiveFunction;
 import ui.model.DecoratedHolonObject;
 import ui.model.DecoratedNetwork;
 import ui.model.DecoratedState;
-import util.FloatLog;
+import utility.FloatLog;
 
 import java.util.Locale;
 import algorithm.objectiveFunction.GraphMetrics.Graph;

+ 1 - 1
src/algorithm/topologie/AcoAlgorithm.java

@@ -8,7 +8,7 @@ import java.util.ListIterator;
 import algorithm.objectiveFunction.TopologieObjectiveFunction;
 import api.TopologieAlgorithmFramework;
 import ui.model.DecoratedState;
-import util.Random;
+import utility.Random;
 
 public class AcoAlgorithm extends TopologieAlgorithmFramework {
 

+ 1 - 1
src/algorithm/topologie/GaAlgorithm.java

@@ -9,7 +9,7 @@ import java.util.TreeSet;
 import algorithm.objectiveFunction.TopologieObjectiveFunction;
 import api.TopologieAlgorithmFramework;
 import ui.model.DecoratedState;
-import util.Random;
+import utility.Random;
 
 public class GaAlgorithm extends TopologieAlgorithmFramework {
 

+ 1 - 1
src/algorithm/topologie/PsoAlgorithm.java

@@ -9,7 +9,7 @@ import java.util.stream.Collectors;
 import algorithm.objectiveFunction.TopologieObjectiveFunction;
 import api.TopologieAlgorithmFramework;
 import ui.model.DecoratedState;
-import util.Random;
+import utility.Random;
 
 public class PsoAlgorithm extends TopologieAlgorithmFramework {
 

+ 2 - 2
src/api/AlgorithmFrameworkFlex.java

@@ -61,8 +61,8 @@ import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.DecoratedSwitch.SwitchState;
 import ui.model.DecoratedNetwork;
 import ui.view.Console;
-import util.ImageImport;
-import util.StringFormat;
+import utility.ImageImport;
+import utility.StringFormat;
 
 public abstract class AlgorithmFrameworkFlex implements AddOn{
 	//Algo

+ 6 - 5
src/api/TopologieAlgorithmFramework.java

@@ -46,8 +46,9 @@ import classes.Edge;
 import classes.GroupNode;
 import classes.HolonObject;
 import classes.HolonSwitch;
-import classes.IdCounterElem;
+import classes.IdCounter;
 import classes.Node;
+import classes.IdCounter.CounterType;
 import ui.controller.Control;
 import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedState;
@@ -877,10 +878,10 @@ 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(IdCounterElem.nextId());
+			newSwitch.setId(IdCounter.nextId(CounterType.Element));
 			newSwitch.setPosition(middleX, middleY);
 			//If fromObject is in Group
 			if(accessGroupNode.containsKey(fromObject)) {
@@ -1283,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());
 	    }
 	}
 }

+ 8 - 5
src/classes/AbstractCanvasObject.java

@@ -2,6 +2,9 @@ package classes;
 
 import com.google.gson.annotations.Expose;
 
+import classes.IdCounter.CounterType;
+import utility.Vector2Int;
+
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.Set;
@@ -31,7 +34,7 @@ public abstract class AbstractCanvasObject {
 	ArrayList<Edge> connections = new ArrayList<>();
 	/* Position with a X and Y value */
 	@Expose
-	Position position = new Position(0,0);
+	Vector2Int position = new Vector2Int(0,0);
 	/*
 	 * Energy input and output of each object in the grid Where the Object is
 	 * Stored
@@ -65,7 +68,7 @@ public abstract class AbstractCanvasObject {
 		setObjName(obj.getObjName());
 		setName(obj.getObjName());
 		setConnections(new ArrayList<>());
-		setId(IdCounter.nextId());
+		setId(IdCounter.nextId(CounterType.Object));
 		setImage(obj.getImage());
 	}
 	
@@ -194,7 +197,7 @@ public abstract class AbstractCanvasObject {
 	 *            Y-Coord
 	 */
 	public void setPosition(int x, int y) {
-		setPosition(new Position(x, y));
+		setPosition(new Vector2Int(x, y));
 	}
 
 	/**
@@ -202,7 +205,7 @@ public abstract class AbstractCanvasObject {
 	 *
 	 * @return Position Position of this Object
 	 */
-	public Position getPosition() {
+	public Vector2Int getPosition() {
 		return position;
 	}
 
@@ -211,7 +214,7 @@ public abstract class AbstractCanvasObject {
 	 *
 	 * @param pos Coordinates
 	 */
-	public void setPosition(Position pos) {
+	public void setPosition(Vector2Int 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

+ 3 - 1
src/classes/GroupNode.java

@@ -2,6 +2,8 @@ package classes;
 
 import com.google.gson.annotations.Expose;
 
+import classes.IdCounter.CounterType;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 
@@ -26,7 +28,7 @@ public class GroupNode extends AbstractCanvasObject {
 		this.setConnections(new ArrayList<>());
 		this.setImage("/Images/upper_node.png");
 		this.setSav("CVS");
-		this.setId(IdCounter.nextId());
+		this.setId(IdCounter.nextId(CounterType.Object));
 		this.setNodes(new ArrayList<>());
 		this.setNodesIdx(new HashMap<>());
 	}

+ 11 - 9
src/classes/HolonBody.java

@@ -5,10 +5,12 @@ import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.Graphics2D;
 
+import utility.Vector2Float;
+
 public class HolonBody implements Comparable<HolonBody> {
 
-	public Vector2d velocity;
-	public Vector2d position;
+	public Vector2Float velocity;
+	public Vector2Float position;
 	private float mass;
 	private float radius;
 	private Color color;
@@ -27,8 +29,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 Vector2Float(0, 0);
+		this.position = new Vector2Float(x, y);
 		this.setMass(mass);
 		this.setRadius(radius);
 		this.color = color;
@@ -76,7 +78,7 @@ public class HolonBody implements Comparable<HolonBody> {
 	public void resolveCollision(HolonBody body) {
 
 		// get the mtd
-		Vector2d delta = (position.subtract(body.position));
+		Vector2Float delta = (position.subtract(body.position));
 		float r = getRadius() + body.getRadius();
 		float dist2 = delta.dot(delta);
 
@@ -85,7 +87,7 @@ public class HolonBody implements Comparable<HolonBody> {
 
 		float d = delta.getLength();
 
-		Vector2d mtd;
+		Vector2Float mtd;
 		if (d != 0.0f) {
 			// minimum translation distance to push bodies apart after
 			// intersecting
@@ -95,7 +97,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 Vector2Float(body.getRadius() + getRadius(), 0.0f);
 
 			mtd = delta.multiply(((getRadius() + body.getRadius()) - d) / d);
 		}
@@ -109,7 +111,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));
+		Vector2Float v = (this.velocity.subtract(body.velocity));
 		float vn = v.dot(mtd.normalize());
 
 		// sphere intersecting but moving away from each other already
@@ -119,7 +121,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);
+		Vector2Float impulse = mtd.multiply(i);
 
 		// change in momentum
 		this.velocity = this.velocity.add(impulse.multiply(im1));

+ 3 - 2
src/classes/HolonElement.java

@@ -2,6 +2,7 @@ package classes;
 
 import com.google.gson.annotations.Expose;
 
+import classes.IdCounter.CounterType;
 import interfaces.GraphEditable;
 import interfaces.LocalMode;
 import ui.controller.FlexManager;
@@ -91,7 +92,7 @@ public class HolonElement implements LocalMode, GraphEditable{
      */
     public HolonElement(HolonObject parentObject, String eleName, int amount, float energy) {
     	
-    	this(parentObject, eleName, amount, energy, IdCounterElem.nextId());
+    	this(parentObject, eleName, amount, energy, IdCounter.nextId(CounterType.Element));
     }
     
 
@@ -133,7 +134,7 @@ public class HolonElement implements LocalMode, GraphEditable{
         }
         sampleGraph();
         setSaving(null);
-        setId(IdCounterElem.nextId());
+        setId(IdCounter.nextId(CounterType.Element));
 
     }
 

+ 39 - 10
src/classes/IdCounter.java

@@ -10,15 +10,25 @@ import com.google.gson.annotations.Expose;
  */
 public class IdCounter {
 	@Expose
-	private static int counter = 1;
+	private static int counterObjects = 1;
+	@Expose
+	private static int counterElements = 1;
 
+	public enum CounterType {
+		Object, Element
+	}
 	/**
 	 * Return the next ID and increment the ID counter by 1.
 	 * @return the next ID
 	 */
-	public static synchronized int nextId() {
-		return counter++;
-
+	public static synchronized int nextId(CounterType type) {
+		switch(type){
+			case Element:
+				return counterObjects++;
+			case Object:
+			default:
+				return counterElements++;
+		}
 	}
 
 	/**
@@ -26,8 +36,14 @@ public class IdCounter {
 	 * 
 	 * @return the counter
 	 */
-	public static int getCounter() {
-		return counter;
+	public static int actualId(CounterType type) {
+		switch(type){
+			case Element:
+				return counterObjects;
+			case Object:
+			default:
+				return counterElements;
+		}
 	}
 
 	/**
@@ -36,14 +52,27 @@ public class IdCounter {
 	 * @param counter
 	 *            the counter to set
 	 */
-	public static void setCounter(int counter) {
-		IdCounter.counter = counter;
+	public static void setCounter(int counter, CounterType type) {
+		
+		switch(type){
+		case Element:
+			counterElements = counter;
+		case Object:
+		default:
+			counterObjects = counter;
+	}
 	}
 
 	/**
 	 * Reset the Counter.
 	 */
-	public static void resetCounter() {
-		counter = 1;
+	public static void resetObjectCounter(CounterType type) {
+		switch(type){
+			case Element:
+				counterObjects = 1;
+			case Object:
+			default:
+				counterElements = 1;
+		}
 	}
 }

+ 0 - 50
src/classes/IdCounterElem.java

@@ -1,50 +0,0 @@
-package classes;
-
-import com.google.gson.annotations.Expose;
-
-/**
- * ID-Counter for all Holon Elements.
- * 
- * @author Gruppe14
- */
-public class IdCounterElem {
-	@Expose
-	private static int counter = 1;
-
-	/**
-	 * Return the next ID and increment the ID counter by 1.
-	 * 
-	 * @return the next ID
-	 */
-	public static synchronized int nextId() {
-		return counter++;
-
-	}
-
-	/**
-	 * Return the Counter.
-	 * 
-	 * @return the counter
-	 */
-	public static int getCounter() {
-		return counter;
-	}
-
-	/**
-	 * Set the Counter.
-	 * 
-	 * @param counter
-	 *            the counter to set
-	 */
-	public static void setCounter(int counter) {
-		IdCounterElem.counter = counter;
-	}
-
-	/**
-	 * Reset the Counter.
-	 */
-	public static void resetCounter() {
-		counter = 1;
-	}
-
-}

+ 3 - 1
src/classes/Node.java

@@ -2,6 +2,8 @@ package classes;
 
 import java.util.ArrayList;
 
+import classes.IdCounter.CounterType;
+
 /**
  * The class "CpsNode" represents empty Objects in the system. They are just
  * nodes between Objects
@@ -22,7 +24,7 @@ public class Node extends AbstractCanvasObject {
 		this.setConnections(new ArrayList<Edge>());
 		this.setImage("/Images/node.png");
 		this.setSav("CVS");
-		this.setId(IdCounter.nextId());
+		this.setId(IdCounter.nextId(CounterType.Object));
 	}
 	
 	public Node(Node node){

+ 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 +"]";
-	}
-}

+ 4 - 2
src/classes/UnitGraphPoint.java

@@ -3,6 +3,8 @@ package classes;
 import java.awt.Point;
 import java.awt.geom.Point2D;
 
+import utility.Vector2Int;
+
 /**
  * A class for saving all points of a Object with a editable state.
  * e.g HolonElement, HolonSwitch
@@ -15,7 +17,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 Vector2Int displayedPosition;
 	
 	/** Default Constructor */
 	public UnitGraphPoint(double x, double y, boolean changed){
@@ -41,7 +43,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 Vector2Int((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();
-	}
-
-
-}

+ 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,9 +11,9 @@ import classes.GroupNode;
 import classes.AbstractCanvasObject;
 import classes.HolonObject;
 import classes.HolonSwitch;
-import classes.Position;
 import interfaces.ObjectListener;
 import ui.model.Model;
+import utility.Vector2Int;
 
 /**
  * Controller for the Canvas.
@@ -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 Vector2Int(p.x + (cps.getPosition().getX() - x), p.y + (cps.getPosition().getY() - y)));
 			tCps.setSav(cps.getSav());
 			tempList.add(tCps);
 			addObject(tCps, false);

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

@@ -9,7 +9,7 @@ import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Pair;
 import ui.model.Model;
-import util.Event;
+import utility.Event;
 
 /**
  * Controller for the Categories.

+ 12 - 9
src/ui/controller/ClipboardController.java

@@ -1,12 +1,15 @@
 package ui.controller;
 
 import classes.*;
+import classes.IdCounter.CounterType;
+
 import com.google.gson.*;
 import ui.controller.SaveController.EDGETYPE;
 import ui.controller.SaveController.GRAPHTYPE;
 import ui.controller.SaveController.NUMTYPE;
 import ui.controller.SaveController.TYPE;
 import ui.model.Model;
+import utility.Vector2Int;
 
 import java.awt.*;
 import java.awt.datatransfer.*;
@@ -55,8 +58,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));
+        Vector2Int pos = uppC.calculatePos(model.getSelectedCpsObjects());
+        file.add("CENTER", model.getGson().toJsonTree(pos, Vector2Int.class));
 
         for (AbstractCanvasObject abs : model.getSelectedCpsObjects()) {
             queue.add(abs);
@@ -128,8 +131,8 @@ public class ClipboardController {
         eleIDMap = new HashMap<>();
         sav = json.get("SAV").getAsString();
 
-        Position old = model.getGson().getAdapter(Position.class).fromJsonTree(json.get("CENTER"));
-        point = new Point(old.x - p.x, old.y - p.y);
+        Vector2Int old = model.getGson().getAdapter(Vector2Int.class).fromJsonTree(json.get("CENTER"));
+        point = new Point(old.getX() - p.x, old.getY() - p.y);
 
         forwardObjects(keys, json, objDispatch, eleDispatch, upperNode);
         // for selecting Cps
@@ -403,7 +406,7 @@ public class ClipboardController {
      */
     private void objIDMapper(AbstractCanvasObject temp) {
         int id = temp.getId();
-        temp.setId(IdCounter.nextId());
+        temp.setId(IdCounter.nextId(CounterType.Object));
         // oldID -> currentID
         objIDMap.put(id, temp.getId());
     }
@@ -413,15 +416,15 @@ public class ClipboardController {
      */
     private void eleIDMapper(HolonElement temp) {
         int id = temp.getId();
-        temp.setId(IdCounterElem.nextId());
+        temp.setId(IdCounter.nextId(CounterType.Element));
         // oldID -> currentID
         eleIDMap.put(id, temp.getId());
 
     }
 
     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;
@@ -435,7 +438,7 @@ public class ClipboardController {
         if (y > model.getCanvasX())
             y = model.getCanvasY() - model.getScaleDiv2() - 1;
 
-        temp.setPosition(new Position(x, y));
+        temp.setPosition(new Vector2Int(x, y));
 
     }
 

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

@@ -23,7 +23,7 @@ import ui.model.Model;
 import ui.model.Model.FairnessModel;
 import ui.view.CreateTemplatePopUp;
 import ui.view.GUI;
-import util.Event;
+import utility.Event;
 
 /**
  * The Class represents the controller in the model, controller view Pattern.

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

@@ -2,6 +2,7 @@ package ui.controller;
 
 import classes.*;
 import ui.model.Model;
+import utility.Vector2Float;
 
 import java.awt.*;
 import java.util.ArrayList;
@@ -37,7 +38,7 @@ public class HolonCanvasController {
 		insertionSizeSort(sortedSize);
 		sortedDist.addAll(bodies);
 
-		ArrayList<Vector2d> pos = insertionDistSort(sortedDist);
+		ArrayList<Vector2Float> 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 +180,8 @@ public class HolonCanvasController {
 	}
 
 	// Insertion sort for HolonBody distance
-	private ArrayList<Vector2d> insertionDistSort(ArrayList<HolonBody> a) {
-		ArrayList<Vector2d> pos = new ArrayList<>();
+	private ArrayList<Vector2Float> insertionDistSort(ArrayList<HolonBody> a) {
+		ArrayList<Vector2Float> pos = new ArrayList<>();
 		for (int p = 1; p < subCount; p++) {
 			HolonBody tmp = a.get(p);
 			int j = p;

+ 6 - 4
src/ui/controller/LoadController.java

@@ -2,6 +2,7 @@ package ui.controller;
 
 import classes.*;
 import classes.HolonElement.Priority;
+import classes.IdCounter.CounterType;
 
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
@@ -14,6 +15,7 @@ import org.apache.commons.compress.archivers.ArchiveInputStream;
 import org.apache.commons.compress.archivers.ArchiveStreamFactory;
 import org.apache.commons.compress.utils.IOUtils;
 
+import ui.controller.LoadController.MODE;
 import ui.model.Model;
 
 import java.awt.geom.Point2D;
@@ -199,8 +201,8 @@ public class LoadController {
                 model.setHashcodeMap(new HashMap<>());
                 model.setCanvasX(json.get("CANVAS_SIZE_X").getAsInt());
                 model.setCanvasX(json.get("CANVAS_SIZE_Y").getAsInt());
-                IdCounter.setCounter(json.get("IDCOUNTER").getAsInt());
-                IdCounterElem.setCounter(json.get("IDCOUNTERELEMENT").getAsInt());
+                IdCounter.setCounter(json.get("IDCOUNTER").getAsInt(), CounterType.Object);
+                IdCounter.setCounter(json.get("IDCOUNTERELEMENT").getAsInt(), CounterType.Element);
                 break;
             case PARTIAL:
                 model.setCvsObjIdx(new HashMap<>());
@@ -209,8 +211,8 @@ public class LoadController {
                 model.setHashcodeMap(new HashMap<>());
                 model.setCanvasX(json.get("CANVAS_SIZE_X").getAsInt());
                 model.setCanvasX(json.get("CANVAS_SIZE_Y").getAsInt());
-                IdCounter.setCounter(json.get("IDCOUNTER").getAsInt());
-                IdCounterElem.setCounter(json.get("IDCOUNTERELEMENT").getAsInt());
+                IdCounter.setCounter(json.get("IDCOUNTER").getAsInt(), CounterType.Object);
+                IdCounter.setCounter(json.get("IDCOUNTERELEMENT").getAsInt(), CounterType.Element);
                 break;
             case CATEGORY:
                 model.setCgIdx(new HashMap<>());

+ 15 - 19
src/ui/controller/NodeController.java

@@ -4,8 +4,8 @@ import classes.AbstractCanvasObject;
 import classes.Edge;
 import classes.Node;
 import classes.GroupNode;
-import classes.Position;
 import ui.model.Model;
+import utility.Vector2Int;
 
 import java.awt.*;
 import java.util.ArrayList;
@@ -47,9 +47,9 @@ class NodeController {
     		cvs.deleteObjectOnCanvas(node);
     		return;
     	}
-		Position old = calculatePos(node.getNodes());
-		Position p = node.getPosition();
-		point = new Point(old.x - p.x, old.y - p.y);
+		Vector2Int old = calculatePos(node.getNodes());
+		Vector2Int p = node.getPosition();
+		point = new Point(old.getX() - p.getX(), old.getY() - p.getY());
 
 		unmakeNodesOfNodes(node, upperNode);
 		if (upperNode == null)
@@ -128,19 +128,15 @@ class NodeController {
 	/**
 	 * Calculate new Position of the Upper Node
 	 */
-    Position calculatePos(ArrayList<AbstractCanvasObject> toGroup) {
+    Vector2Int calculatePos(ArrayList<AbstractCanvasObject> toGroup) {
 
-		Position pos = new Position(0, 0);
+		Vector2Int pos = new Vector2Int(0, 0);
 
 		// 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;
@@ -287,7 +283,7 @@ class NodeController {
 		if (y > model.getCanvasX())
 			y = model.getCanvasY() - model.getScaleDiv2() - 1;
 
-		temp.setPosition(new Position(x, y));
+		temp.setPosition(new Vector2Int(x, y));
 
 	}
 }

+ 6 - 4
src/ui/controller/SaveController.java

@@ -1,6 +1,8 @@
 package ui.controller;
 
 import classes.*;
+import classes.IdCounter.CounterType;
+
 import com.google.gson.JsonObject;
 import com.google.gson.JsonPrimitive;
 import com.google.gson.reflect.TypeToken;
@@ -134,15 +136,15 @@ public class SaveController {
         switch (mode) {
             case COMPLETE:
                 file.add("MODE", new JsonPrimitive(mode.name()));
-                file.add("IDCOUNTER", new JsonPrimitive(IdCounter.getCounter()));
-                file.add("IDCOUNTERELEMENT", new JsonPrimitive(IdCounterElem.getCounter()));
+                file.add("IDCOUNTER", new JsonPrimitive(IdCounter.actualId(CounterType.Object)));
+                file.add("IDCOUNTERELEMENT", new JsonPrimitive(IdCounter.actualId(CounterType.Element)));
                 file.add("CANVAS_SIZE_X", new JsonPrimitive(model.getCanvasX()));
                 file.add("CANVAS_SIZE_Y", new JsonPrimitive(model.getCanvasY()));
                 break;
             case PARTIAL:
                 file.add("MODE", new JsonPrimitive(mode.name()));
-                file.add("IDCOUNTER", new JsonPrimitive(IdCounter.getCounter()));
-                file.add("IDCOUNTERELEMENT", new JsonPrimitive(IdCounterElem.getCounter()));
+                file.add("IDCOUNTER", new JsonPrimitive(IdCounter.actualId(CounterType.Object)));
+                file.add("IDCOUNTERELEMENT", new JsonPrimitive(IdCounter.actualId(CounterType.Element)));
                 file.add("CANVAS_SIZE_X", new JsonPrimitive(model.getCanvasX()));
                 file.add("CANVAS_SIZE_Y", new JsonPrimitive(model.getCanvasY()));
                 break;

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

@@ -25,11 +25,11 @@ import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Node;
 import classes.Pair;
-import classes.Position;
 import interfaces.GraphListener;
 import interfaces.ObjectListener;
 import ui.view.DefaulTable;
 import ui.view.PropertyTable;
+import utility.Vector2Int;
 
 /**
  * The Class Model is the class where everything is saved. All changes made to
@@ -793,7 +793,7 @@ public class Model {
         builder.excludeFieldsWithoutExposeAnnotation();
         builder.setPrettyPrinting();
         builder.registerTypeAdapter(AbstractCanvasObject.class, new AbstractCpsObjectAdapter());
-        builder.registerTypeAdapter(Position.class, new PositionAdapter());
+        builder.registerTypeAdapter(Vector2Int.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

+ 1 - 1
src/ui/view/AboutUsPopUp.java

@@ -2,7 +2,7 @@ package ui.view;
 
 import javax.swing.*;
 
-import util.ImageImport;
+import utility.ImageImport;
 
 import java.awt.*;
 

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

@@ -23,10 +23,10 @@ import classes.GroupNode;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.Node;
-import classes.Position;
 import ui.controller.Control;
 import ui.controller.UpdateController;
 import ui.model.Model;
+import utility.Vector2Int;
 
 /**
  * Collection of methods and values needed in both <code>MyCanvas</code> and
@@ -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
+	Vector2Int toolTipPos = new Vector2Int(); // 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<Vector2Int> savePos;
 	// edge Object Start Point
 	int cx, cy;
 	int sx, sy; // Mark Coords
-	Position unPos;
+	Vector2Int unPos;
 	// Animation
 	Timer animT; // animation Timer
 	int animDuration = ANIMTIME; // animation Duration
@@ -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();
 		}
 
@@ -307,7 +307,7 @@ public abstract class AbstractCanvas extends JPanel {
 		AbstractCanvasObject toBeReplaced = null;
 		
 		/** Position of object that might be replaced */
-		Position p;
+		Vector2Int p;
 		
 		/** for each cps on Canvas */
 		if(draggedCps == null || !(draggedCps instanceof Node) && !(draggedCps instanceof Node)){
@@ -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)));
@@ -383,14 +383,14 @@ 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();
+		Vector2Int 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 */
-		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);
 	}
 	
 	/**

+ 1 - 1
src/ui/view/AddElementPopUp.java

@@ -3,7 +3,7 @@ package ui.view;
 import classes.AbstractCanvasObject;
 import classes.HolonElement;
 import classes.HolonObject;
-import util.ImageImport;
+import utility.ImageImport;
 
 import javax.swing.*;
 import javax.swing.border.EmptyBorder;

+ 1 - 1
src/ui/view/AddObjectPopUp.java

@@ -36,7 +36,7 @@ import classes.HolonElement;
 import classes.HolonObject;
 import classes.Pair;
 import ui.controller.Control;
-import util.ImageImport;
+import utility.ImageImport;
 
 /**
  * Popup for adding a Holon Object to a Category.

+ 1 - 1
src/ui/view/AddOnWindow.java

@@ -27,7 +27,7 @@ import javax.tools.ToolProvider;
 
 import api.AddOn;
 import ui.controller.Control;
-import util.ImageImport;
+import utility.ImageImport;
 
 public class AddOnWindow extends JFrame{
 	private AddOn actual;

+ 1 - 1
src/ui/view/BackgroundPopUp.java

@@ -3,7 +3,7 @@ package ui.view;
 import classes.GroupNode;
 import ui.controller.Control;
 import ui.model.Model;
-import util.ImageImport;
+import utility.ImageImport;
 
 import javax.swing.*;
 import javax.swing.filechooser.FileNameExtensionFilter;

+ 1 - 1
src/ui/view/CanvasResizePopUp.java

@@ -2,7 +2,7 @@ package ui.view;
 
 import ui.controller.Control;
 import ui.model.Model;
-import util.ImageImport;
+import utility.ImageImport;
 
 import javax.swing.*;
 import java.awt.*;

+ 1 - 1
src/ui/view/Console.java

@@ -11,7 +11,7 @@ import javax.swing.JTextArea;
 import javax.swing.JToolBar;
 import javax.swing.text.DefaultCaret;
 
-import util.ImageImport;
+import utility.ImageImport;
 /**
  * Little new swing object to print data to a console.
  * @author tom

+ 1 - 1
src/ui/view/CreateTemplatePopUp.java

@@ -25,7 +25,7 @@ import classes.HolonObject;
 import classes.Pair;
 import ui.controller.Control;
 import ui.model.Model;
-import util.ImageImport;
+import utility.ImageImport;
 
 /**
  * PopUp for creating Holon Object Template.

+ 1 - 1
src/ui/view/FlexWindow.java

@@ -61,7 +61,7 @@ import ui.controller.FlexManager;
 import ui.controller.FlexManager.FlexState;
 import ui.controller.FlexManager.FlexWrapper;
 import ui.model.Model;
-import util.ImageImport;
+import utility.ImageImport;
 
 
 public class FlexWindow extends JFrame {

+ 5 - 5
src/ui/view/GUI.java

@@ -84,7 +84,7 @@ import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.IdCounter;
-import classes.IdCounterElem;
+import classes.IdCounter.CounterType;
 import interfaces.GraphEditable;
 import ui.controller.Control;
 import ui.controller.UpdateController;
@@ -92,8 +92,8 @@ import ui.model.DecoratedState;
 import ui.model.Model;
 import ui.model.Model.FairnessModel;
 import ui.view.CreateNewDialog.Option;
-import util.Event;
-import util.ImageImport;
+import utility.Event;
+import utility.ImageImport;
 
 /**
  * Graphical User Interface.
@@ -1914,8 +1914,8 @@ public class GUI{
 			elementGraph.setText("None");
 			canvas.tempCps = null;
 			canvas.repaint();
-			IdCounter.resetCounter();
-			IdCounterElem.resetCounter();
+			IdCounter.resetObjectCounter(CounterType.Object);
+			IdCounter.resetObjectCounter(CounterType.Element);
 		});
 
 		mntmOpen.addActionListener(new ActionListener() {

+ 94 - 105
src/ui/view/GroupNodeCanvas.java

@@ -33,8 +33,6 @@ import classes.GroupNode;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Node;
-import classes.Position;
-import classes.Vector2d;
 import ui.controller.Control;
 import ui.controller.UpdateController;
 import ui.model.Consumer;
@@ -45,10 +43,12 @@ import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.DecoratedSwitch;
 import ui.model.ExitCable;
 import ui.model.DecoratedSwitch.SwitchState;
-import util.ImageImport;
 import ui.model.Model;
 import ui.model.Passiv;
 import ui.model.Supplier;
+import utility.ImageImport;
+import utility.Vector2Float;
+import utility.Vector2Int;
 
 /**
  * This Class is the Canvas. All Objects will be visualized here
@@ -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 Position(upperNode.getLeftBorder() + 5 + model.getScaleDiv2(), cps.getPosition().y));
+                        new Vector2Int(upperNode.getLeftBorder() + 5 + model.getScaleDiv2(), cps.getPosition().getY()));
             }
         }
 
@@ -122,31 +122,27 @@ 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 Vector2Int(0, 0);
             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 Position(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;
+                    	Vector2Int pos = currentAnimCps.getPosition();
+                    	Vector2Int difference = pos.subtract(unPos);
+                    	Vector2Int 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 Position(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 Position(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;
+                        Vector2Int pos = animCps.get(i).getPosition();
+                    	Vector2Int difference = pos.subtract(savePos.get(i));
+                    	Vector2Int 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();
@@ -305,16 +294,16 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		}
 	}
 	private void paintCanvasObject(Graphics2D g, DecoratedHolonObject decoratedHolonObject){
-		Position pos = decoratedHolonObject.getModel().getPosition();
+		Vector2Int 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, Position posOfCanvasObject, float energy) {
+	private void drawCanvasObjectString(Graphics2D g, Vector2Int 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);
@@ -326,17 +315,17 @@ 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, Vector2Int 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);
 	}
 	
 	private void paintCable(Graphics2D g, DecoratedCable cable, boolean isSelected)
 	{
-		Position start = cable.getModel().getA().getPosition();
-		Position end =  cable.getModel().getB().getPosition();
+		Vector2Int start = cable.getModel().getA().getPosition();
+		Vector2Int end =  cable.getModel().getB().getPosition();
 		float currentEnergy = cable.getFlowEnergy();
 		float capacity = cable.getModel().getCapacity();
 		boolean unlimited = cable.getModel().isUnlimitedCapacity();
@@ -353,28 +342,28 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		if(isSelected){
 			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);
+		g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
+		Vector2Int middle = new Vector2Int((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)
 	{
 		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();
+		Vector2Int 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);
 	}
-	private void paintGroupNodeBar(Graphics2D g, DecoratedGroupNode dGroupNode , Position pos) {
+	private void paintGroupNodeBar(Graphics2D g, DecoratedGroupNode dGroupNode , Vector2Int pos) {
 		// +1, -2, -1 little Adjustment for pixel perfect alignment
 		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 ;)
@@ -422,8 +411,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();
+		Vector2Int start = eCable.getStart().getPosition();
+		Vector2Int end = eCable.getFinish().getPosition();
 		float currentEnergy = eCable.getCable().getFlowEnergy();
 		float capacity = eCable.getCable().getModel().getCapacity();
 		boolean unlimited = eCable.getCable().getModel().isUnlimitedCapacity();
@@ -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);
-			Position middle = new Position((start.x + end.x) / 2, (start.y + end.y) / 2);
+			g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
+			Vector2Int middle = new Vector2Int((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:
-			Vector2d vStart = new Vector2d(start.x, start.y);
-			Vector2d vEnd = new Vector2d(end.x, end.y);
+			Vector2Float vStart = new Vector2Float(start.getX(), start.getY());
+			Vector2Float vEnd = new Vector2Float(end.getX(), end.getY());
 			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()));
-			g.drawLine(start.x, start.y, result.x, result.y);
-			Position middle1 = new Position((start.x +result.x) / 2, (start.y + +result.y) / 2);
+			Vector2Float vPosition = vStart.add((vEnd.subtract(vStart)).normalize().multiply(stretchFactor));
+			Vector2Int result = new Vector2Int(Math.round(vPosition.getX()),Math.round(vPosition.getY()));
+			g.drawLine(start.getX(), start.getY(), result.getX(), result.getY());
+			Vector2Int middle1 = new Vector2Int((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:
@@ -464,22 +453,22 @@ 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, Vector2Int pos) {
 		// +1, -2, -1 little Adjustment for pixel perfect alignment
 		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
@@ -568,30 +557,30 @@ 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();
+				Vector2Int 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 {
-				Position pos = aCps.getPosition();
+				Vector2Int 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));				
 			}
 
 		}
 		//maybeReplace:
 		if(mayBeReplaced != null){
 			g2d.setColor(Color.RED);
-			Position pos = mayBeReplaced.getPosition();
+			Vector2Int 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

+ 1 - 1
src/ui/view/HolonInformationPanel.java

@@ -52,10 +52,10 @@ import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedGroupNode.PriorityCounts;
 import ui.model.DecoratedHolonObject;
 import ui.model.DecoratedHolonObject.HolonObjectState;
+import utility.StringFormat;
 import ui.model.Model;
 import ui.model.Passiv;
 import ui.model.Supplier;
-import util.StringFormat;
 
 public class HolonInformationPanel extends JPanel {
 

+ 82 - 92
src/ui/view/MyCanvas.java

@@ -32,7 +32,6 @@ import classes.GroupNode;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Node;
-import classes.Position;
 import preferences.ColorPreference;
 import ui.controller.Control;
 import ui.controller.UpdateController;
@@ -44,11 +43,12 @@ import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.DecoratedSwitch;
 import ui.model.ExitCable;
 import ui.model.DecoratedSwitch.SwitchState;
-import util.ImageImport;
 import ui.model.Model;
 import ui.model.Passiv;
 import ui.model.Supplier;
 import ui.model.VisualRepresentationalState;
+import utility.ImageImport;
+import utility.Vector2Int;
 
 /**
  * This Class is the Canvas. All Objects will be visualized here
@@ -105,31 +105,27 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		
 		itemGroup.addActionListener(actionEvent -> {
 			// calculate uppernode pos (taken from the controller)
-				unPos = new Position(0, 0);
+				unPos = new Vector2Int(0, 0);
 				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 Position(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;
+							Vector2Int pos = animCpObject.getPosition();
+	                    	Vector2Int difference = pos.subtract(unPos);
+	                    	Vector2Int result = pos.subtract(difference.divide(animSteps));
+	                    	pos.set(result);
 						}
 						repaint();
 						animDuration -= animDelay;
@@ -139,8 +135,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();
@@ -164,15 +159,13 @@ 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.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 Position(x, y));
+						cps.setPosition(new Vector2Int(x, y));
 					}
 
 					animT = new javax.swing.Timer(
@@ -181,11 +174,10 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 								controller.clearSelection();
 								if (animDuration - animDelay >= 0) {
 									for (int i = 0; i < animCps.size(); i++) {
-										Position 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;
+										Vector2Int pos =  animCps.get(i).getPosition();
+				                    	Vector2Int difference = pos.subtract(savePos.get(i));
+				                    	Vector2Int result = pos.subtract(difference.divide(animSteps));
+				                    	pos.set(result);
 									}
 									repaint();
 									animDuration -= animDelay;
@@ -195,10 +187,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();
@@ -327,16 +317,16 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		}
 	}
 	private void paintCanvasObject(Graphics2D g, DecoratedHolonObject decoratedHolonObject){
-		Position pos = decoratedHolonObject.getModel().getPosition();
+		Vector2Int 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, Position posOfCanvasObject, float energy) {
+	private void drawCanvasObjectString(Graphics2D g, Vector2Int 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);
@@ -348,17 +338,17 @@ 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, Vector2Int 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);
 	}
 	
 	private void paintCable(Graphics2D g, DecoratedCable cable, boolean isSelected)
 	{
-		Position start = cable.getModel().getA().getPosition();
-		Position end =  cable.getModel().getB().getPosition();
+		Vector2Int start = cable.getModel().getA().getPosition();
+		Vector2Int end =  cable.getModel().getB().getPosition();
 		float currentEnergy = cable.getFlowEnergy();
 		float capacity = cable.getModel().getCapacity();
 		boolean unlimited = cable.getModel().isUnlimitedCapacity();
@@ -375,11 +365,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) {			
-			Position middle = new Position((start.x + end.x) / 2, (start.y + end.y) / 2);
+			Vector2Int middle = new Vector2Int((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)
@@ -388,8 +378,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();
+		Vector2Int start = eCable.getStart().getPosition();
+		Vector2Int end = eCable.getFinish().getPosition();
 		float currentEnergy = eCable.getCable().getFlowEnergy();
 		float capacity = eCable.getCable().getModel().getCapacity();
 		boolean unlimited = eCable.getCable().getModel().isUnlimitedCapacity();
@@ -403,24 +393,24 @@ 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);
-		Position middle = new Position((start.x + end.x) / 2, (start.y + end.y) / 2);
+		g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
+		Vector2Int middle = new Vector2Int((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) {
-		Position pos = dGroupNode.getModel().getPosition();
+		Vector2Int 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);
 	}
-	private void paintGroupNodeBar(Graphics2D g, DecoratedGroupNode dGroupNode , Position pos) {
+	private void paintGroupNodeBar(Graphics2D g, DecoratedGroupNode dGroupNode , Vector2Int pos) {
 		// +1, -2, -1 little Adjustment for pixel perfect alignment
 		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);
@@ -432,13 +422,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 ;)
@@ -462,22 +452,22 @@ 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, Vector2Int pos) {
 		// +1, -2, -1 little Adjustment for pixel perfect alignment
 		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);
 		
 	}
 	
@@ -511,7 +501,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
@@ -567,30 +557,30 @@ 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();
+				Vector2Int 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 {
-				Position pos = aCps.getPosition();
+				Vector2Int 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));				
 			}
 
 		}
 		//maybeReplace:
 		if(mayBeReplaced != null){
 			g2d.setColor(Color.RED);
-			Position pos = mayBeReplaced.getPosition();
+			Vector2Int 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
@@ -630,8 +620,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;
@@ -712,7 +702,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];

+ 1 - 1
src/ui/view/Outliner.java

@@ -20,7 +20,7 @@ import ui.controller.Control;
 import ui.model.Consumer;
 import ui.model.DecoratedCable;
 import ui.model.DecoratedHolonObject.HolonObjectState;
-import util.ImageImport;
+import utility.ImageImport;
 import ui.model.DecoratedNetwork;
 import ui.model.DecoratedState;
 import ui.model.DecoratedSwitch;

+ 1 - 1
src/ui/view/TimePanel.java

@@ -34,7 +34,7 @@ import javax.swing.event.ChangeListener;
 import javax.swing.plaf.basic.BasicSliderUI;
 
 import ui.controller.Control;
-import util.ImageImport;
+import utility.ImageImport;
 /**
  * This Class represents a Panel where the User can start and stop the
  * Simulation. He Can also reset the Simulation and click through every

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

@@ -18,13 +18,13 @@ import java.util.ListIterator;
 
 import javax.swing.JPanel;
 
-import classes.Position;
 import classes.UnitGraphPoint;
 import interfaces.GraphEditable;
 import interfaces.GraphEditable.Graphtype;
 import interfaces.LocalMode;
 import ui.controller.Control;
 import ui.model.Model;
+import utility.Vector2Int;
 
 /**
  * This Class represents a Graph where the User can model the behavior of
@@ -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;
+	Vector2Int 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);
+    	Vector2Int oben = new Vector2Int(border + (int)(where * widthWithBorder), 0);
+    	Vector2Int unten = new Vector2Int(border + (int)(where * widthWithBorder), 2 * border + heightWithBorder);
     	drawLine(g,oben,unten);
     	
     }
@@ -227,11 +227,11 @@ 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, Vector2Int start, Vector2Int 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);
     }
     
@@ -241,11 +241,11 @@ 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(Vector2Int start) {
     	//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;
     }
     /**
@@ -256,9 +256,9 @@ 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) {
-         double mitte = (actual.x + target.x)* 0.5;
-         path.curveTo(mitte, actual.y, mitte, target.y, target.x, target.y);
+    private void curveTo(Path2D.Double path, Vector2Int actual, Vector2Int target) {
+         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)}
@@ -267,9 +267,9 @@ 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, Vector2Int 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);
     }
     
     
@@ -281,25 +281,25 @@ 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<Vector2Int> cornerPoints =  new LinkedList<Vector2Int>();
      	ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
-     	Position actual = actualGraphPoints.getFirst().displayedPosition;
+     	Vector2Int 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())
     	{
-    		Position target = iter.next().displayedPosition;
+    		Vector2Int target = iter.next().displayedPosition;
     		//BooleanConnection
-    		path.lineTo(target.x, actual.y); //line to corner
-    		cornerPoints.add(new Position(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 Vector2Int(target.getX(), actual.getY())); //save corner
+    		path.lineTo(target.getX(), target.getY()); //line to next Point
     		
     		actual = target;
     	}
      	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(Vector2Int p: cornerPoints)
      	{
      		drawDot(g, p);
      	}
@@ -312,11 +312,11 @@ 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<Vector2Int> before = new LinkedList<Vector2Int>();
+     	LinkedList<Vector2Int> after = new LinkedList<Vector2Int>();
      	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);
@@ -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<Vector2Int> middle = new LinkedList<Vector2Int>();
      	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<Vector2Int> list) {
 		if(list.size() <= 1) return;
-     	ListIterator<Position> iter = list.listIterator();
-      	LinkedList<Position> cornerPoints =  new LinkedList<Position>();
-     	Position actual = list.getFirst();
+     	ListIterator<Vector2Int> iter = list.listIterator();
+      	LinkedList<Vector2Int> cornerPoints =  new LinkedList<Vector2Int>();
+     	Vector2Int actual = list.getFirst();
      	Path2D.Double path = new Path2D.Double();
-     	path.moveTo(actual.x, actual.y);
+     	path.moveTo(actual.getX(), actual.getY());
      	while (iter.hasNext())
     	{
-    		Position target = iter.next();
+    		Vector2Int target = iter.next();
     		//BooleanConnection
-    		path.lineTo(target.x, actual.y); //line to corner
-    		cornerPoints.add(new Position(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 Vector2Int(target.getX(), actual.getY())); //save corner
+    		path.lineTo(target.getX(), target.getY()); //line to next Point
     		actual = target;
     	}
      	g.draw(path);
     	g.setColor(dotColor);
-     	for(Position p: cornerPoints)
+     	for(Vector2Int 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;
+    	Vector2Int actual = iter.next().displayedPosition;
     	Path2D.Double path = this.initBezier(actual);
     	while (iter.hasNext())
     	{
-    		Position target = iter.next().displayedPosition;
+    		Vector2Int target = iter.next().displayedPosition;
     		this.curveTo(path, actual, target);
     		actual = target;
     	}
@@ -418,11 +418,11 @@ 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<Vector2Int> before = new LinkedList<Vector2Int>();
+     	LinkedList<Vector2Int> after = new LinkedList<Vector2Int>();
      	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);
@@ -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<Vector2Int> middle = new LinkedList<Vector2Int>();
      	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<Vector2Int> list) {
 		if(list.size() <= 1) return;
-     	ListIterator<Position> iter = list.listIterator();
-     	Position actual = list.getFirst();
+     	ListIterator<Vector2Int> iter = list.listIterator();
+     	Vector2Int actual = list.getFirst();
      	Path2D.Double path = this.initBezier(actual);
      	while (iter.hasNext())
     	{
-    		Position target = iter.next();
+    		Vector2Int 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(Vector2Int 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(Vector2Int mPosition)
     {
     	UnitGraphPoint first = actualGraphPoints.getFirst();
     	UnitGraphPoint last = actualGraphPoints.getLast();
@@ -541,14 +541,14 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param target
      * @return
      */
-	private boolean near(Position actual, Position target) {
+	private boolean near(Vector2Int actual, Vector2Int target) {
 		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;
 		}	
@@ -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(Vector2Int newPosition) {
     	//make it in the bounds of the UnitGraph no Point out of the Border
-    	Position currentPosition = setInBounds(newPosition);
+    	Vector2Int 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 Vector2Int setInBounds(Vector2Int p) {
 		p.clampX(border, border + widthWithBorder);
 		p.clampY(border, border + heightWithBorder);
 		return p;
@@ -585,12 +585,12 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * @param p the Position
 	 * @return the updated Position.
 	 */
-	private Position snapBoolean(Position p)
+	private Vector2Int snapBoolean(Vector2Int 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;
 	}
@@ -601,15 +601,15 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * @param p the Position
 	 * @return the updated Position.
 	 */
-	private Position attachToBorder(Position p)
+	private Vector2Int attachToBorder(Vector2Int p)
 	{
 		switch(editPoint)
 		{
 		case StartPoint:
-			p.x = border;
+			p.setX(border);
 			break;
 		case EndPoint:
-			p.x = border + widthWithBorder;
+			p.setX(border + widthWithBorder);
 			break;
 		default:
 			break;
@@ -621,14 +621,14 @@ 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(Vector2Int pos)
     {
     	setInBounds(pos);
     	ListIterator<UnitGraphPoint> iter2 = actualGraphPoints.listIterator();
     	while (iter2.hasNext())
     	{
-    		Position tempPosition = iter2.next().displayedPosition;
-    		if(pos.x <= tempPosition.x)
+    		Vector2Int tempPosition = iter2.next().displayedPosition;
+    		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();
@@ -646,9 +646,9 @@ 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) {
-		UnitGraphPoint temp = new UnitGraphPoint((double) (pos.x - border) / (double) widthWithBorder,
-				1 - (double) (pos.y - border) / (double) heightWithBorder, true);
+	private UnitGraphPoint generateUnitGraphPoint(Vector2Int pos) {
+		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 Position(e.getPoint()));
+    	updateEditPointPosition(new Vector2Int(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) {
-		Position mPosition = new Position(e.getPoint());
+		Vector2Int mPosition = new Vector2Int(e.getPoint().x, e.getPoint().y);
 		if (e.getButton() == MouseEvent.BUTTON3) {
 			// RightMouseButtonEvent
 			detectStartEndPoint(mPosition);

+ 1 - 1
src/util/Action.java → src/utility/Action.java

@@ -1,4 +1,4 @@
-package util;
+package utility;
 
 import java.util.HashSet;
 import java.util.Set;

+ 1 - 1
src/util/Event.java → src/utility/Event.java

@@ -1,4 +1,4 @@
-package util;
+package utility;
 import java.util.HashSet;
 import java.util.Set;
 

+ 1 - 1
src/util/FloatLog.java → src/utility/FloatLog.java

@@ -1,4 +1,4 @@
-package util;
+package utility;
 
 import java.util.HashMap;
 import java.util.stream.Collectors;

+ 1 - 1
src/util/ImageImport.java → src/utility/ImageImport.java

@@ -1,4 +1,4 @@
-package util;
+package utility;
 
 import java.awt.Image;
 import java.awt.image.BufferedImage;

+ 1 - 1
src/util/Random.java → src/utility/Random.java

@@ -1,4 +1,4 @@
-package util;
+package utility;
 
 
 

+ 1 - 1
src/util/StringFormat.java → src/utility/StringFormat.java

@@ -1,4 +1,4 @@
-package util;
+package utility;
 
 import java.math.RoundingMode;
 import java.text.DecimalFormat;

+ 153 - 0
src/utility/Vector2Float.java

@@ -0,0 +1,153 @@
+package utility;
+
+public class Vector2Float {
+
+	private float x;
+	private float y;
+
+	public Vector2Float()
+	{
+		x = y = 0;
+	}
+
+	public Vector2Float(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(Vector2Float 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(Vector2Float 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(Vector2Float other)
+	{
+		float xDistance = other.getX() - x;
+		float yDistance = other.getY() - y;
+		return xDistance * xDistance + yDistance * yDistance;
+	}
+
+	public Vector2Float add(Vector2Float other)
+	{
+		Vector2Float result = new Vector2Float();
+		result.setX(x + other.getX());
+		result.setY(y + other.getY());
+		return result;
+	}
+
+	public Vector2Float subtract(Vector2Float other)
+	{
+		Vector2Float result = new Vector2Float();
+		result.setX(x - other.getX());
+		result.setY(y - other.getY());
+		return result;
+	}
+
+	public Vector2Float multiply(float scaleFactor)
+	{
+		Vector2Float result = new Vector2Float();
+		result.setX(x * scaleFactor);
+		result.setY(y * scaleFactor);
+		return result;
+	}
+	public Vector2Float divide(float divideFactor)
+	{
+		Vector2Float result = new Vector2Float();
+		result.setX(x / divideFactor);
+		result.setY(y / divideFactor);
+		return result;
+	}
+
+	public Vector2Float 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;
+	}
+
+
+}

+ 145 - 0
src/utility/Vector2Int.java

@@ -0,0 +1,145 @@
+package utility;
+
+
+/**
+ * 
+ * @author Tom Troppmann
+ *
+ */
+public class Vector2Int {
+	private int x;
+	private int y;
+
+	public Vector2Int()
+	{
+		x = y = 0;
+	}
+
+	public Vector2Int(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 void set(Vector2Int other)
+	{
+		setX(other.x);
+		setY(other.y);
+	}
+
+
+	public float dot(Vector2Int 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(Vector2Int 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(Vector2Int other)
+	{
+		int xDistance = other.getX() - x;
+		int yDistance = other.getY() - y;
+		return xDistance * xDistance + yDistance * yDistance;
+	}
+
+	public Vector2Int add(Vector2Int other)
+	{
+		Vector2Int result = new Vector2Int();
+		result.setX(x + other.getX());
+		result.setY(y + other.getY());
+		return result;
+	}
+
+	public Vector2Int subtract(Vector2Int other)
+	{
+		Vector2Int result = new Vector2Int();
+		result.setX(x - other.getX());
+		result.setY(y - other.getY());
+		return result;
+	}
+
+	public Vector2Int multiply(float scaleFactor)
+	{
+		Vector2Int result = new Vector2Int();
+		result.setX((int)(x * scaleFactor));
+		result.setY((int)(y * scaleFactor));
+		return result;
+	}
+	
+	public Vector2Int divide(float divideFactor)
+	{
+		return this.multiply(1.0f/divideFactor);
+	}
+	
+	/**
+	 * 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;
+	}
+	
+	public Vector2Int clone() {
+		return new Vector2Int(x, y);
+	}
+}

+ 3 - 2
tests/tests/PraktikumHolonsAdapter.java

@@ -7,7 +7,8 @@ import classes.Category;
 import classes.AbstractCanvasObject;
 import classes.HolonElement;
 import classes.HolonObject;
-import classes.IdCounterElem;
+import classes.IdCounter;
+import classes.IdCounter.CounterType;
 
 /**
  * This Class Generates Stuff for the Tests.
@@ -43,7 +44,7 @@ public class PraktikumHolonsAdapter {
 	 */
 	public void generateElements(ArrayList<HolonElement> arr) {
 		for (int i = 1; i < 18279; i++) {
-			arr.add(new HolonElement(null, generate(i), 1, 10, IdCounterElem.nextId()));
+			arr.add(new HolonElement(null, generate(i), 1, 10, IdCounter.nextId(CounterType.Element)));
 		}
 	}
 	

+ 2 - 1
tests/tests/PraktikumHolonsTestCanvasController.java

@@ -5,6 +5,7 @@ import classes.Edge;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.IdCounter;
+import classes.IdCounter.CounterType;
 import ui.controller.CanvasController;
 import ui.controller.CategoryController;
 import ui.controller.Control;
@@ -39,7 +40,7 @@ public class PraktikumHolonsTestCanvasController {
 		mp = new MultiPurposeController(model);
 		cg = new CategoryController(model, mp, new Control(model));
 		controller = new CanvasController(model, mp);
-		IdCounter.setCounter(1); 
+		IdCounter.resetObjectCounter(CounterType.Object); 
 	}
 
 	/**

+ 11 - 8
tests/tests/PraktikumHolonsTestClasses.java

@@ -1,6 +1,9 @@
 package tests;
 
 import classes.*;
+import classes.IdCounter.CounterType;
+import utility.Vector2Int;
+
 import org.junit.Test;
 
 import java.util.ArrayList;
@@ -51,7 +54,7 @@ public class PraktikumHolonsTestClasses {
 		HolonObject test1 = new HolonObject("Test1");
 		HolonObject test2 = new HolonObject("Test2");
 		HolonObject test3 = new HolonObject(test1);
-		HolonElement ele = new HolonElement(test1, "Element", 1, 10, IdCounterElem.nextId());
+		HolonElement ele = new HolonElement(test1, "Element", 1, 10, IdCounter.nextId(CounterType.Element));
 		ArrayList<HolonElement> arr = new ArrayList<>();
 		assertTrue("Should be Empty", test1.getElements().isEmpty());
 		test1.setElements(arr);
@@ -134,8 +137,8 @@ public class PraktikumHolonsTestClasses {
 	 */
 	@Test
 	public void testHolonElement() {
-		HolonElement ele1 = new HolonElement(null, "TV", 2, -20f, IdCounterElem.nextId());
-		HolonElement ele2 = new HolonElement(null, "Fridge", 1, -50f, IdCounterElem.nextId());
+		HolonElement ele1 = new HolonElement(null, "TV", 2, -20f, IdCounter.nextId(CounterType.Element));
+		HolonElement ele2 = new HolonElement(null, "Fridge", 1, -50f, IdCounter.nextId(CounterType.Element));
         assertTrue("Array not empty",  ele1.getEnergyAtTimeStep(0) == -40);
         assertTrue("Array not empty", ele1.getEnergyAtTimeStep(2) == -40);
         assertTrue("Name not correct", ele1.getEleName().equals("TV"));
@@ -151,12 +154,12 @@ public class PraktikumHolonsTestClasses {
 	*/
 	@Test
 	public void testPosition() {
-		Position pos1 = new Position(100, 200);
-		Position pos2 = new Position();
+		Vector2Int pos1 = new Vector2Int(100, 200);
+		Vector2Int pos2 = new Vector2Int();
 
-		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);
 	}
 	
 }