Prechádzať zdrojové kódy

Refactoring Vector2

TomTroppmann 2 rokov pred
rodič
commit
74c1eabd57

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

+ 5 - 4
src/classes/AbstractCanvasObject.java

@@ -3,6 +3,7 @@ package classes;
 import com.google.gson.annotations.Expose;
 
 import classes.IdCounter.CounterType;
+import utility.Vector2Int;
 
 import java.util.ArrayList;
 import java.util.HashSet;
@@ -33,7 +34,7 @@ public abstract class AbstractCanvasObject {
 	ArrayList<Edge> connections = new ArrayList<>();
 	/* Position with a X and Y value */
 	@Expose
-	Vector2dInt position = new Vector2dInt(0,0);
+	Vector2Int position = new Vector2Int(0,0);
 	/*
 	 * Energy input and output of each object in the grid Where the Object is
 	 * Stored
@@ -196,7 +197,7 @@ public abstract class AbstractCanvasObject {
 	 *            Y-Coord
 	 */
 	public void setPosition(int x, int y) {
-		setPosition(new Vector2dInt(x, y));
+		setPosition(new Vector2Int(x, y));
 	}
 
 	/**
@@ -204,7 +205,7 @@ public abstract class AbstractCanvasObject {
 	 *
 	 * @return Position Position of this Object
 	 */
-	public Vector2dInt getPosition() {
+	public Vector2Int getPosition() {
 		return position;
 	}
 
@@ -213,7 +214,7 @@ public abstract class AbstractCanvasObject {
 	 *
 	 * @param pos Coordinates
 	 */
-	public void setPosition(Vector2dInt pos) {
+	public void setPosition(Vector2Int pos) {
 		this.position = pos;
 	}
 

+ 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 Vector2dFloat velocity;
-	public Vector2dFloat 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 Vector2dFloat(0, 0);
-		this.position = new Vector2dFloat(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
-		Vector2dFloat 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();
 
-		Vector2dFloat 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 Vector2dFloat(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
-		Vector2dFloat 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);
-		Vector2dFloat impulse = mtd.multiply(i);
+		Vector2Float impulse = mtd.multiply(i);
 
 		// change in momentum
 		this.velocity = this.velocity.add(impulse.multiply(im1));

+ 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 Vector2dInt 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 Vector2dInt((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()

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

@@ -11,9 +11,9 @@ import classes.GroupNode;
 import classes.AbstractCanvasObject;
 import classes.HolonObject;
 import classes.HolonSwitch;
-import classes.Vector2dInt;
 import interfaces.ObjectListener;
 import ui.model.Model;
+import utility.Vector2Int;
 
 /**
  * Controller for the Canvas.
@@ -220,7 +220,7 @@ public class CanvasController {
 			} else {
 				tCps = new Node("Node");
 			}
-			tCps.setPosition(new Vector2dInt(p.x + (cps.getPosition().getX() - x), p.y + (cps.getPosition().getY() - 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);

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

@@ -9,6 +9,7 @@ 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.*;
@@ -57,8 +58,8 @@ public class ClipboardController {
         store.initNumeration();
 
         file.add("SAV", new JsonPrimitive((upperNode == null ? "CVS" : "" + upperNode.getId())));
-        Vector2dInt pos = uppC.calculatePos(model.getSelectedCpsObjects());
-        file.add("CENTER", model.getGson().toJsonTree(pos, Vector2dInt.class));
+        Vector2Int pos = uppC.calculatePos(model.getSelectedCpsObjects());
+        file.add("CENTER", model.getGson().toJsonTree(pos, Vector2Int.class));
 
         for (AbstractCanvasObject abs : model.getSelectedCpsObjects()) {
             queue.add(abs);
@@ -130,7 +131,7 @@ public class ClipboardController {
         eleIDMap = new HashMap<>();
         sav = json.get("SAV").getAsString();
 
-        Vector2dInt old = model.getGson().getAdapter(Vector2dInt.class).fromJsonTree(json.get("CENTER"));
+        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);
@@ -437,7 +438,7 @@ public class ClipboardController {
         if (y > model.getCanvasX())
             y = model.getCanvasY() - model.getScaleDiv2() - 1;
 
-        temp.setPosition(new Vector2dInt(x, y));
+        temp.setPosition(new Vector2Int(x, y));
 
     }
 

+ 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<Vector2dFloat> 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<Vector2dFloat> insertionDistSort(ArrayList<HolonBody> a) {
-		ArrayList<Vector2dFloat> 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 - 6
src/ui/controller/NodeController.java

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

+ 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.Vector2dInt;
 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
@@ -812,7 +812,7 @@ public class Model {
         builder.excludeFieldsWithoutExposeAnnotation();
         builder.setPrettyPrinting();
         builder.registerTypeAdapter(AbstractCanvasObject.class, new AbstractCpsObjectAdapter());
-        builder.registerTypeAdapter(Vector2dInt.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

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

@@ -23,10 +23,10 @@ import classes.GroupNode;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.Node;
-import classes.Vector2dInt;
 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
-	Vector2dInt toolTipPos = new Vector2dInt(); // 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<Vector2dInt> savePos;
+	ArrayList<Vector2Int> savePos;
 	// edge Object Start Point
 	int cx, cy;
 	int sx, sy; // Mark Coords
-	Vector2dInt unPos;
+	Vector2Int unPos;
 	// Animation
 	Timer animT; // animation Timer
 	int animDuration = ANIMTIME; // animation Duration
@@ -307,7 +307,7 @@ public abstract class AbstractCanvas extends JPanel {
 		AbstractCanvasObject toBeReplaced = null;
 		
 		/** Position of object that might be replaced */
-		Vector2dInt p;
+		Vector2Int p;
 		
 		/** for each cps on Canvas */
 		if(draggedCps == null || !(draggedCps instanceof Node) && !(draggedCps instanceof Node)){
@@ -383,7 +383,7 @@ public abstract class AbstractCanvas extends JPanel {
 	 */
 	protected void align(AbstractCanvasObject cps, int distance) {
 		/** Position of the AbstractCpsObject which should be aligned */
-		Vector2dInt 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 */

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

@@ -33,8 +33,6 @@ import classes.GroupNode;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Node;
-import classes.Vector2dInt;
-import classes.Vector2dFloat;
 import ui.controller.Control;
 import ui.controller.UpdateController;
 import ui.model.Consumer;
@@ -49,6 +47,8 @@ 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
@@ -86,7 +86,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
         for (AbstractCanvasObject cps : upperNode.getNodes()) {
             if (cps.getPosition().getX() < model.getScaleDiv2() + upperNode.getLeftBorder() + 5) {
                 cps.setPosition(
-                        new Vector2dInt(upperNode.getLeftBorder() + 5 + model.getScaleDiv2(), cps.getPosition().getY()));
+                        new Vector2Int(upperNode.getLeftBorder() + 5 + model.getScaleDiv2(), cps.getPosition().getY()));
             }
         }
 
@@ -122,7 +122,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
         
         itemGroup.addActionListener(actionEvent -> {
             // calculate uppernode pos (taken from the controller)
-            unPos = new Vector2dInt(0, 0);
+            unPos = new Vector2Int(0, 0);
             animCps = new ArrayList<>();
             for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
                 animCps.add(cps); // add to animation Cps ArrayList
@@ -139,9 +139,9 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
             animT = new javax.swing.Timer(animDelay, actionEvent1 -> {
                 if (animDuration - animDelay > 0 && animCps.size() > 1) {
                     for (AbstractCanvasObject currentAnimCps : animCps) {
-                    	Vector2dInt pos = currentAnimCps.getPosition();
-                    	Vector2dInt difference = pos.subtract(unPos);
-                    	Vector2dInt result = pos.subtract(difference.divide(animSteps));
+                    	Vector2Int pos = currentAnimCps.getPosition();
+                    	Vector2Int difference = pos.subtract(unPos);
+                    	Vector2Int result = pos.subtract(difference.divide(animSteps));
                     	pos.set(result);
                     }
                     repaint();
@@ -180,9 +180,9 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
             animT = new javax.swing.Timer(animDelay, actionEvent1 -> {
                 if (animDuration - animDelay >= 0) {
                     for (int i = 0; i < animCps.size(); i++) {
-                        Vector2dInt pos = animCps.get(i).getPosition();
-                    	Vector2dInt difference = pos.subtract(savePos.get(i));
-                    	Vector2dInt result = pos.subtract(difference.divide(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();
@@ -294,13 +294,13 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		}
 	}
 	private void paintCanvasObject(Graphics2D g, DecoratedHolonObject decoratedHolonObject){
-		Vector2dInt pos = decoratedHolonObject.getModel().getPosition();
+		Vector2Int pos = decoratedHolonObject.getModel().getPosition();
 		Color statecolor = getStateColor(decoratedHolonObject.getState());
 		g.setColor(statecolor);
 		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
 		drawCanvasObject(g, decoratedHolonObject.getModel().getImage(), pos);
 	}
-	private void drawCanvasObjectString(Graphics2D g, Vector2dInt posOfCanvasObject, float energy) {
+	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.getX() - controller.getScaleDiv2(), posOfCanvasObject.getY() - controller.getScaleDiv2() - 1);
@@ -315,7 +315,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		drawCanvasObjectString(g, sup.getModel().getPosition(), sup.getEnergyToSupplyNetwork());
 	}
 	
-	private void drawCanvasObject(Graphics2D g, String Image, Vector2dInt pos) {
+	private void drawCanvasObject(Graphics2D g, String Image, Vector2Int pos) {
 		g.drawImage(ImageImport.loadImage(Image, controller.getScale(), controller.getScale()) , 
 				pos.getX() - controller.getScaleDiv2(),
 				pos.getY() - controller.getScaleDiv2(),
@@ -324,8 +324,8 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 	
 	private void paintCable(Graphics2D g, DecoratedCable cable, boolean isSelected)
 	{
-		Vector2dInt start = cable.getModel().getA().getPosition();
-		Vector2dInt 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();
@@ -343,7 +343,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 			g.setColor(Color.lightGray);
 		}
 		g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
-		Vector2dInt middle = new Vector2dInt((start.getX() + end.getX()) / 2, (start.getY() + end.getY()) / 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.getX(), middle.getY());
 	}
@@ -352,13 +352,13 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		drawCanvasObject(g, dSwitch.getState() == SwitchState.Open ? HolonSwitch.getSwitchOpenImage(): HolonSwitch.getSwitchClosedImage() , dSwitch.getModel().getPosition());
 	}
 	private void paintGroupNode(Graphics2D g, DecoratedGroupNode dGroupNode) {
-		Vector2dInt pos = dGroupNode.getModel().getPosition();
+		Vector2Int pos = dGroupNode.getModel().getPosition();
 		g.setColor(Color.lightGray);
 		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 , Vector2dInt 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);
@@ -411,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;
 		}
-		Vector2dInt start = eCable.getStart().getPosition();
-		Vector2dInt 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();
@@ -430,20 +430,20 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		case DOWN:
 		case DOWNDOWN:
 			g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
-			Vector2dInt middle = new Vector2dInt((start.getX() + end.getX()) / 2, (start.getY() + end.getY()) / 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.getX(), middle.getY());
 			break;
 		case DOWNUP:
 		case UP:
-			Vector2dFloat vStart = new Vector2dFloat(start.getX(), start.getY());
-			Vector2dFloat vEnd = new Vector2dFloat(end.getX(), end.getY());
+			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;
-			Vector2dFloat vPosition = vStart.add((vEnd.subtract(vStart)).normalize().multiply(stretchFactor));
-			Vector2dInt result = new Vector2dInt(Math.round(vPosition.getX()),Math.round(vPosition.getY()));
+			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());
-			Vector2dInt middle1 = new Vector2dInt((start.getX() +result.getX()) / 2, (start.getY() + +result.getY()) / 2);
+			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.getX(), middle1.getY());
 			drawCanvasObject(g, "/Images/arrowUp.png" , result);
@@ -453,7 +453,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 			break;
 		}
 	}
-	private void paintSupplyBar(Graphics2D g, float percentage, Color color, Vector2dInt 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);
@@ -557,7 +557,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		Color transparentGrey = new Color(128, 174, 247, 40);
 		for(AbstractCanvasObject aCps:  model.getSelectedCpsObjects()) {
 			if(aCps instanceof Node) {
-				Vector2dInt pos = aCps.getPosition();
+				Vector2Int pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
 				g2d.fillOval(pos.getX() - (int) (controller.getScaleDiv2()), pos.getY() - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 				g2d.setColor(Color.LIGHT_GRAY);
@@ -565,7 +565,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 				g2d.drawOval(pos.getX() - (int) (controller.getScaleDiv2()), pos.getY() - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 			}
 			else {
-				Vector2dInt pos = aCps.getPosition();
+				Vector2Int pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
 				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);
@@ -577,7 +577,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		//maybeReplace:
 		if(mayBeReplaced != null){
 			g2d.setColor(Color.RED);
-			Vector2dInt pos = mayBeReplaced.getPosition();
+			Vector2Int pos = mayBeReplaced.getPosition();
 			g.drawImage(ImageImport.loadImage("/Images/replace.png") , 
 					pos.getX() + controller.getScaleDiv2(),
 					pos.getY() - controller.getScale(),

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

@@ -32,7 +32,6 @@ import classes.GroupNode;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Node;
-import classes.Vector2dInt;
 import ui.controller.Control;
 import ui.controller.UpdateController;
 import ui.model.Consumer;
@@ -48,6 +47,7 @@ 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
@@ -104,7 +104,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		
 		itemGroup.addActionListener(actionEvent -> {
 			// calculate uppernode pos (taken from the controller)
-				unPos = new Vector2dInt(0, 0);
+				unPos = new Vector2Int(0, 0);
 				animCps = new ArrayList<>();
 				for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
 					animCps.add(cps); // add to animation Cps ArrayList
@@ -121,9 +121,9 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 				animT = new javax.swing.Timer(animDelay, actionEvent1 -> {
 					if (animDuration - animDelay > 0 && animCps.size() > 1) {
 						for (AbstractCanvasObject animCpObject : animCps) {
-							Vector2dInt pos = animCpObject.getPosition();
-	                    	Vector2dInt difference = pos.subtract(unPos);
-	                    	Vector2dInt result = pos.subtract(difference.divide(animSteps));
+							Vector2Int pos = animCpObject.getPosition();
+	                    	Vector2Int difference = pos.subtract(unPos);
+	                    	Vector2Int result = pos.subtract(difference.divide(animSteps));
 	                    	pos.set(result);
 						}
 						repaint();
@@ -164,7 +164,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 						int x = tempCps.getPosition().getX();
 						int y = tempCps.getPosition().getY();
 
-						cps.setPosition(new Vector2dInt(x, y));
+						cps.setPosition(new Vector2Int(x, y));
 					}
 
 					animT = new javax.swing.Timer(
@@ -173,9 +173,9 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 								model.getSelectedCpsObjects().clear();
 								if (animDuration - animDelay >= 0) {
 									for (int i = 0; i < animCps.size(); i++) {
-										Vector2dInt pos =  animCps.get(i).getPosition();
-				                    	Vector2dInt difference = pos.subtract(savePos.get(i));
-				                    	Vector2dInt result = pos.subtract(difference.divide(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();
@@ -316,13 +316,13 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		}
 	}
 	private void paintCanvasObject(Graphics2D g, DecoratedHolonObject decoratedHolonObject){
-		Vector2dInt pos = decoratedHolonObject.getModel().getPosition();
+		Vector2Int pos = decoratedHolonObject.getModel().getPosition();
 		Color statecolor = getStateColor(decoratedHolonObject.getState());
 		g.setColor(statecolor);
 		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() - controller.getScaleDiv2(), controller.getScale(), controller.getScale());
 		drawCanvasObject(g, decoratedHolonObject.getModel().getImage(), pos);
 	}
-	private void drawCanvasObjectString(Graphics2D g, Vector2dInt posOfCanvasObject, float energy) {
+	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.getX() - controller.getScaleDiv2(), posOfCanvasObject.getY() - controller.getScaleDiv2() - 1);
@@ -337,7 +337,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		drawCanvasObjectString(g, sup.getModel().getPosition(), sup.getEnergyToSupplyNetwork());
 	}
 	
-	private void drawCanvasObject(Graphics2D g, String Image, Vector2dInt pos) {
+	private void drawCanvasObject(Graphics2D g, String Image, Vector2Int pos) {
 		g.drawImage(ImageImport.loadImage(Image, controller.getScale(), controller.getScale()) , 
 				pos.getX() - controller.getScaleDiv2(),
 				pos.getY() - controller.getScaleDiv2(),
@@ -346,8 +346,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 	
 	private void paintCable(Graphics2D g, DecoratedCable cable, boolean isSelected)
 	{
-		Vector2dInt start = cable.getModel().getA().getPosition();
-		Vector2dInt 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();
@@ -366,7 +366,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		}
 		g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
 		if(showConnectionInformation) {			
-			Vector2dInt middle = new Vector2dInt((start.getX() + end.getX()) / 2, (start.getY() + end.getY()) / 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.getX(), middle.getY());
 		}
@@ -377,8 +377,8 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 	}
 	
 	private void paintExitCable(Graphics2D g, ExitCable eCable) {
-		Vector2dInt start = eCable.getStart().getPosition();
-		Vector2dInt 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();
@@ -393,18 +393,18 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 			break;
 		}
 		g.drawLine(start.getX(), start.getY(), end.getX(), end.getY());
-		Vector2dInt middle = new Vector2dInt((start.getX() + end.getX()) / 2, (start.getY() + end.getY()) / 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.getX(), middle.getY());
 	}
 	private void paintGroupNode(Graphics2D g, DecoratedGroupNode dGroupNode) {
-		Vector2dInt pos = dGroupNode.getModel().getPosition();
+		Vector2Int pos = dGroupNode.getModel().getPosition();
 		g.setColor(Color.lightGray);
 		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 , Vector2dInt 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);
@@ -451,7 +451,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		}
 		return percentages;
 	}
-	private void paintSupplyBar(Graphics2D g, float percentage, Color color, Vector2dInt 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);
@@ -556,7 +556,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		Color transparentGrey = new Color(128, 174, 247, 40);
 		for(AbstractCanvasObject aCps:  model.getSelectedCpsObjects()) {
 			if(aCps instanceof Node) {
-				Vector2dInt pos = aCps.getPosition();
+				Vector2Int pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
 				g2d.fillOval(pos.getX() - (int) (controller.getScaleDiv2()), pos.getY() - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 				g2d.setColor(Color.LIGHT_GRAY);
@@ -564,7 +564,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 				g2d.drawOval(pos.getX() - (int) (controller.getScaleDiv2()), pos.getY() - (int) (controller.getScaleDiv2()),  controller.getScale(),  controller.getScale());
 			}
 			else {
-				Vector2dInt pos = aCps.getPosition();
+				Vector2Int pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
 				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);
@@ -576,7 +576,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		//maybeReplace:
 		if(mayBeReplaced != null){
 			g2d.setColor(Color.RED);
-			Vector2dInt pos = mayBeReplaced.getPosition();
+			Vector2Int pos = mayBeReplaced.getPosition();
 			g2d.drawImage(ImageImport.loadImage("/Images/replace.png") , 
 					pos.getX() + controller.getScaleDiv2(),
 					pos.getY() - controller.getScale(),

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

@@ -18,13 +18,13 @@ import java.util.ListIterator;
 
 import javax.swing.JPanel;
 
-import classes.Vector2dInt;
 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;
-	Vector2dInt 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);
     	}
-    	Vector2dInt oben = new Vector2dInt(border + (int)(where * widthWithBorder), 0);
-    	Vector2dInt unten = new Vector2dInt(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,7 +227,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param start the Position of one end of the line to draw. 
      * @param end the other Ends Position of the Line to draw.
      */
-    private void drawLine(Graphics2D g, Vector2dInt start, Vector2dInt end)
+    private void drawLine(Graphics2D g, Vector2Int start, Vector2Int end)
     {
     	Path2D.Double path = new Path2D.Double();
     	path.moveTo(start.getX(), start.getY());
@@ -241,7 +241,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * Initialize a Cubic BezierCurve.
      * @param start The Position to start the Curve.
      */
-    private Path2D.Double initBezier(Vector2dInt 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();
@@ -256,7 +256,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param actaul the actual Position of the Path.
      * @param target the end Position of the Curve.
      */
-    private void curveTo(Path2D.Double path, Vector2dInt actual, Vector2dInt target) {
+    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());
     }
@@ -267,7 +267,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param g to draw.
      * @param p the position of the Dot.
      */
-    private void drawDot(Graphics2D g, Vector2dInt p)
+    private void drawDot(Graphics2D g, Vector2Int p)
     {    	
     	g.fillOval(p.getX() -dotSize/2, p.getY()-dotSize/2, dotSize, dotSize);
     }
@@ -281,17 +281,17 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      */
     private void drawBoolGraph(Graphics2D g) {
     	if(actualGraphPoints.size() <= 1) return;
-    	LinkedList<Vector2dInt> cornerPoints =  new LinkedList<Vector2dInt>();
+    	LinkedList<Vector2Int> cornerPoints =  new LinkedList<Vector2Int>();
      	ListIterator<UnitGraphPoint> iter = actualGraphPoints.listIterator();
-     	Vector2dInt actual = actualGraphPoints.getFirst().displayedPosition;
+     	Vector2Int actual = actualGraphPoints.getFirst().displayedPosition;
      	Path2D.Double path = new Path2D.Double();
      	path.moveTo(actual.getX(), actual.getY());
      	while (iter.hasNext())
     	{
-    		Vector2dInt target = iter.next().displayedPosition;
+    		Vector2Int target = iter.next().displayedPosition;
     		//BooleanConnection
     		path.lineTo(target.getX(), actual.getY()); //line to corner
-    		cornerPoints.add(new Vector2dInt(target.getX(), actual.getY())); //save corner
+    		cornerPoints.add(new Vector2Int(target.getX(), actual.getY())); //save corner
     		path.lineTo(target.getX(), target.getY()); //line to next Point
     		
     		actual = target;
@@ -299,7 +299,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      	g.draw(path);
      	//Draw the Points on the Corner that dont exist in Data but should be visual
      	g.setColor(dotColor);
-     	for(Vector2dInt p: cornerPoints)
+     	for(Vector2Int p: cornerPoints)
      	{
      		drawDot(g, p);
      	}
@@ -312,8 +312,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param g2D to draw.
      */
     private void drawBoolGraphInEditMode(Graphics2D g) {
-    	LinkedList<Vector2dInt> before = new LinkedList<Vector2dInt>();
-     	LinkedList<Vector2dInt> after = new LinkedList<Vector2dInt>();
+    	LinkedList<Vector2Int> before = new LinkedList<Vector2Int>();
+     	LinkedList<Vector2Int> after = new LinkedList<Vector2Int>();
      	for(UnitGraphPoint p: actualGraphPoints)
      	{
      		if(p.displayedPosition.getX() < editPosition.getX())
@@ -326,7 +326,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      	g.setColor(Color.BLACK);
      	drawBoolGraphFromList(g, after);
      	//EditGraph
-     	LinkedList<Vector2dInt> middle = new LinkedList<Vector2dInt>();
+     	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<Vector2dInt> list) {
+	private void drawBoolGraphFromList(Graphics2D g, LinkedList<Vector2Int> list) {
 		if(list.size() <= 1) return;
-     	ListIterator<Vector2dInt> iter = list.listIterator();
-      	LinkedList<Vector2dInt> cornerPoints =  new LinkedList<Vector2dInt>();
-     	Vector2dInt 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.getX(), actual.getY());
      	while (iter.hasNext())
     	{
-    		Vector2dInt target = iter.next();
+    		Vector2Int target = iter.next();
     		//BooleanConnection
     		path.lineTo(target.getX(), actual.getY()); //line to corner
-    		cornerPoints.add(new Vector2dInt(target.getX(), actual.getY())); //save 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(Vector2dInt 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();
-    	Vector2dInt actual = iter.next().displayedPosition;
+    	Vector2Int actual = iter.next().displayedPosition;
     	Path2D.Double path = this.initBezier(actual);
     	while (iter.hasNext())
     	{
-    		Vector2dInt target = iter.next().displayedPosition;
+    		Vector2Int target = iter.next().displayedPosition;
     		this.curveTo(path, actual, target);
     		actual = target;
     	}
@@ -418,8 +418,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param g2D to draw.
      */
     private void drawDoubleGraphInEditMode(Graphics2D g) {
-     	LinkedList<Vector2dInt> before = new LinkedList<Vector2dInt>();
-     	LinkedList<Vector2dInt> after = new LinkedList<Vector2dInt>();
+     	LinkedList<Vector2Int> before = new LinkedList<Vector2Int>();
+     	LinkedList<Vector2Int> after = new LinkedList<Vector2Int>();
      	for(UnitGraphPoint p: actualGraphPoints)
      	{
      		if(p.displayedPosition.getX() < editPosition.getX())
@@ -430,7 +430,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      	drawUnitGraphFromList(g, before);
      	drawUnitGraphFromList(g, after);
      	//EditGraph
-     	LinkedList<Vector2dInt> middle = new LinkedList<Vector2dInt>();
+     	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<Vector2dInt> list) {
+	private void drawUnitGraphFromList(Graphics2D g, LinkedList<Vector2Int> list) {
 		if(list.size() <= 1) return;
-     	ListIterator<Vector2dInt> iter = list.listIterator();
-     	Vector2dInt actual = list.getFirst();
+     	ListIterator<Vector2Int> iter = list.listIterator();
+     	Vector2Int actual = list.getFirst();
      	Path2D.Double path = this.initBezier(actual);
      	while (iter.hasNext())
     	{
-    		Vector2dInt 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(Vector2dInt 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(Vector2dInt mPosition)
+    private void  detectStartEndPoint(Vector2Int mPosition)
     {
     	UnitGraphPoint first = actualGraphPoints.getFirst();
     	UnitGraphPoint last = actualGraphPoints.getLast();
@@ -541,7 +541,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param target
      * @return
      */
-	private boolean near(Vector2dInt actual, Vector2dInt target) {
+	private boolean near(Vector2Int actual, Vector2Int target) {
 		switch(actualGraphType)
 		{
 		case boolGraph: //Distance only with X 
@@ -558,9 +558,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * When the Mouse Drag a Point it updates each time the position.
 	 * @param newPosition
 	 */
-    private void updateEditPointPosition(Vector2dInt newPosition) {
+    private void updateEditPointPosition(Vector2Int newPosition) {
     	//make it in the bounds of the UnitGraph no Point out of the Border
-    	Vector2dInt 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 Vector2dInt setInBounds(Vector2dInt p) {
+	private Vector2Int setInBounds(Vector2Int p) {
 		p.clampX(border, border + widthWithBorder);
 		p.clampY(border, border + heightWithBorder);
 		return p;
@@ -585,7 +585,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * @param p the Position
 	 * @return the updated Position.
 	 */
-	private Vector2dInt snapBoolean(Vector2dInt p)
+	private Vector2Int snapBoolean(Vector2Int p)
 	{
 		if (p.getY() < border + heightWithBorder / 2) {
 			p.setY(border);
@@ -601,7 +601,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * @param p the Position
 	 * @return the updated Position.
 	 */
-	private Vector2dInt attachToBorder(Vector2dInt p)
+	private Vector2Int attachToBorder(Vector2Int p)
 	{
 		switch(editPoint)
 		{
@@ -621,13 +621,13 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * Its sorted based on the xValues.
 	 * @param pos The new UnitGraphPoints Position
 	 */
-    private void insertNewGraphPoint(Vector2dInt pos)
+    private void insertNewGraphPoint(Vector2Int pos)
     {
     	setInBounds(pos);
     	ListIterator<UnitGraphPoint> iter2 = actualGraphPoints.listIterator();
     	while (iter2.hasNext())
     	{
-    		Vector2dInt tempPosition = iter2.next().displayedPosition;
+    		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
@@ -646,7 +646,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      * @param pos the normal pos with xValues from 0..Width and yValues from 0..Height
      * @return a UnitGraphPoint
      */
-	private UnitGraphPoint generateUnitGraphPoint(Vector2dInt pos) {
+	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;
@@ -658,7 +658,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
      */
 	@Override
     public void mouseDragged(MouseEvent e) {
-    	updateEditPointPosition(new Vector2dInt(e.getPoint().x, e.getPoint().y));
+    	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) {
-		Vector2dInt mPosition = new Vector2dInt(e.getPoint().x, e.getPoint().y);
+		Vector2Int mPosition = new Vector2Int(e.getPoint().x, e.getPoint().y);
 		if (e.getButton() == MouseEvent.BUTTON3) {
 			// RightMouseButtonEvent
 			detectStartEndPoint(mPosition);

+ 16 - 16
src/classes/Vector2dFloat.java → src/utility/Vector2Float.java

@@ -1,16 +1,16 @@
-package classes;
+package utility;
 
-public class Vector2dFloat {
+public class Vector2Float {
 
 	private float x;
 	private float y;
 
-	public Vector2dFloat()
+	public Vector2Float()
 	{
 		x = y = 0;
 	}
 
-	public Vector2dFloat(float x, float y)
+	public Vector2Float(float x, float y)
 	{
 		setX(x);
 		setY(y);
@@ -39,7 +39,7 @@ public class Vector2dFloat {
 	}
 
 
-	public float dot(Vector2dFloat other)
+	public float dot(Vector2Float other)
 	{
 		float result = 0.0f;
 		result = x * other.getX() + y * other.getY();
@@ -56,7 +56,7 @@ public class Vector2dFloat {
 	 * @param other the other Position.
 	 * @return distance to the Position.
 	 */
-	public float getDistance(Vector2dFloat other)
+	public float getDistance(Vector2Float other)
 	{
 		return (float) Math.sqrt(getSquaredDistance(other));
 	}
@@ -66,45 +66,45 @@ public class Vector2dFloat {
 	 * @param other the other Position.
 	 * @return squared distance to the Position
 	 */
-	public float getSquaredDistance(Vector2dFloat other)
+	public float getSquaredDistance(Vector2Float other)
 	{
 		float xDistance = other.getX() - x;
 		float yDistance = other.getY() - y;
 		return xDistance * xDistance + yDistance * yDistance;
 	}
 
-	public Vector2dFloat add(Vector2dFloat other)
+	public Vector2Float add(Vector2Float other)
 	{
-		Vector2dFloat result = new Vector2dFloat();
+		Vector2Float result = new Vector2Float();
 		result.setX(x + other.getX());
 		result.setY(y + other.getY());
 		return result;
 	}
 
-	public Vector2dFloat subtract(Vector2dFloat other)
+	public Vector2Float subtract(Vector2Float other)
 	{
-		Vector2dFloat result = new Vector2dFloat();
+		Vector2Float result = new Vector2Float();
 		result.setX(x - other.getX());
 		result.setY(y - other.getY());
 		return result;
 	}
 
-	public Vector2dFloat multiply(float scaleFactor)
+	public Vector2Float multiply(float scaleFactor)
 	{
-		Vector2dFloat result = new Vector2dFloat();
+		Vector2Float result = new Vector2Float();
 		result.setX(x * scaleFactor);
 		result.setY(y * scaleFactor);
 		return result;
 	}
-	public Vector2dFloat divide(float divideFactor)
+	public Vector2Float divide(float divideFactor)
 	{
-		Vector2dFloat result = new Vector2dFloat();
+		Vector2Float result = new Vector2Float();
 		result.setX(x / divideFactor);
 		result.setY(y / divideFactor);
 		return result;
 	}
 
-	public Vector2dFloat normalize()
+	public Vector2Float normalize()
 	{
 		float len = getLength();
 		if (len != 0.0f)

+ 18 - 21
src/classes/Vector2dInt.java → src/utility/Vector2Int.java

@@ -1,24 +1,21 @@
-package classes;
+package utility;
 
-import java.awt.Point;
 
 /**
- * Coordinates of an Object on the canvas with a (int) x-coord and a (int).
- * y-coord
  * 
- * @author Gruppe14
+ * @author Tom Troppmann
  *
  */
-public class Vector2dInt {
+public class Vector2Int {
 	private int x;
 	private int y;
 
-	public Vector2dInt()
+	public Vector2Int()
 	{
 		x = y = 0;
 	}
 
-	public Vector2dInt(int x, int y)
+	public Vector2Int(int x, int y)
 	{
 		setX(x);
 		setY(y);
@@ -45,14 +42,14 @@ public class Vector2dInt {
 		setX(x);
 		setY(y);
 	}
-	public void set(Vector2dInt other)
+	public void set(Vector2Int other)
 	{
 		setX(other.x);
 		setY(other.y);
 	}
 
 
-	public float dot(Vector2dInt other)
+	public float dot(Vector2Int other)
 	{
 		float result = 0.0f;
 		result = x * other.getX() + y * other.getY();
@@ -69,7 +66,7 @@ public class Vector2dInt {
 	 * @param other the other Position.
 	 * @return distance to the Position.
 	 */
-	public float getDistance(Vector2dInt other)
+	public float getDistance(Vector2Int other)
 	{
 		return (float) Math.sqrt(getSquaredDistance(other));
 	}
@@ -79,38 +76,38 @@ public class Vector2dInt {
 	 * @param other the other Position.
 	 * @return squared distance to the Position
 	 */
-	public float getSquaredDistance(Vector2dInt other)
+	public float getSquaredDistance(Vector2Int other)
 	{
 		int xDistance = other.getX() - x;
 		int yDistance = other.getY() - y;
 		return xDistance * xDistance + yDistance * yDistance;
 	}
 
-	public Vector2dInt add(Vector2dInt other)
+	public Vector2Int add(Vector2Int other)
 	{
-		Vector2dInt result = new Vector2dInt();
+		Vector2Int result = new Vector2Int();
 		result.setX(x + other.getX());
 		result.setY(y + other.getY());
 		return result;
 	}
 
-	public Vector2dInt subtract(Vector2dInt other)
+	public Vector2Int subtract(Vector2Int other)
 	{
-		Vector2dInt result = new Vector2dInt();
+		Vector2Int result = new Vector2Int();
 		result.setX(x - other.getX());
 		result.setY(y - other.getY());
 		return result;
 	}
 
-	public Vector2dInt multiply(float scaleFactor)
+	public Vector2Int multiply(float scaleFactor)
 	{
-		Vector2dInt result = new Vector2dInt();
+		Vector2Int result = new Vector2Int();
 		result.setX((int)(x * scaleFactor));
 		result.setY((int)(y * scaleFactor));
 		return result;
 	}
 	
-	public Vector2dInt divide(float divideFactor)
+	public Vector2Int divide(float divideFactor)
 	{
 		return this.multiply(1.0f/divideFactor);
 	}
@@ -142,7 +139,7 @@ public class Vector2dInt {
 		return "X: " + x + " Y: " + y;
 	}
 	
-	public Vector2dInt clone() {
-		return new Vector2dInt(x, y);
+	public Vector2Int clone() {
+		return new Vector2Int(x, y);
 	}
 }

+ 3 - 2
tests/tests/PraktikumHolonsTestClasses.java

@@ -2,6 +2,7 @@ package tests;
 
 import classes.*;
 import classes.IdCounter.CounterType;
+import utility.Vector2Int;
 
 import org.junit.Test;
 
@@ -153,8 +154,8 @@ public class PraktikumHolonsTestClasses {
 	*/
 	@Test
 	public void testPosition() {
-		Vector2dInt pos1 = new Vector2dInt(100, 200);
-		Vector2dInt pos2 = new Vector2dInt();
+		Vector2Int pos1 = new Vector2Int(100, 200);
+		Vector2Int pos2 = new Vector2Int();
 
 		assertTrue("Wrong coordinates", pos1.getX() == 100 && pos1.getY() == 200);
 		assertTrue("Are the Same", pos1.getX() != pos2.getX());