Browse Source

Merge branch 'Ohne_Drag_and_Drop' of
https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons.git
into Ohne_Drag_and_Drop

Conflicts:
src/classes/CpsObject.java
src/classes/HolonSwitch.java
src/ui/controller/SimulationManager.java

Kevin Trometer 7 years ago
parent
commit
f16ed138d3

+ 1 - 1
src/classes/CpsEdge.java

@@ -119,7 +119,7 @@ public class CpsEdge {
 		if (flow > maxCapacity && maxCapacity != -1) {
 			isWorking = false;
 		} else {
-			if (!simMode && flow <= maxCapacity) {
+			if (!simMode && (flow <= maxCapacity || maxCapacity == -1)) {
 				isWorking = true;
 			}
 		}

+ 296 - 0
src/classes/CpsObject.java

@@ -0,0 +1,296 @@
+package classes;
+
+import java.awt.Color;
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import ui.model.idCounter;
+
+/**
+ * The abstract class "CpsObject" represents any possible object in the system
+ * (except Edges). The representation of any object contains following
+ * variables: see description of variables
+ * 
+ * @author Gruppe14
+ *
+ */
+public abstract class CpsObject {
+	/* Type of the Object */
+	String objName;
+	/* Name given by the user */
+	String name;
+	/* ID of the Obj. */
+	int ID;
+	/* Path of the image for the Obj. */
+	String image;
+	/* Array of neighbors */
+	ArrayList<CpsEdge> connections;
+	/* Position with a X and Y value */
+	Position position;
+	/*
+	 * Energy input and output of each object in the grid Where the Object is
+	 * Stored
+	 */
+	String sav;
+	/* BorderColor the user sets */
+	Color BorderColor = Color.WHITE;
+	/* a Tag that can be used */
+	ArrayList<Integer> tags;
+	/* tags that are only set to tags if wished */
+	ArrayList<Integer> pseudoTags;
+	/**
+	 * Constructor for a CpsObejct with an unique ID
+	 */
+	public CpsObject(String objName) {
+		setObjName(objName);
+		setName(objName);
+		setImage("/Images/Dummy_House.png");
+	}
+
+	/**
+	 * Constructor for a new CpsObject with an unique ID (This constructor
+	 * correspond to the interaction between the Categories and Canvas)-->
+	 * actually the "new" Object is a copy.
+	 * 
+	 * @param obj
+	 *            Object to be copied
+	 */
+	public CpsObject(CpsObject obj) {
+		setObjName(obj.getObjName());
+		setName(obj.getObjName());
+		setConnections(new ArrayList<CpsEdge>());
+		setPosition(new Position());
+		setID(idCounter.nextId());
+		setImage(obj.getImage());
+	}
+
+	/**
+	 * Getter for the type of the Object
+	 * 
+	 * @return String
+	 */
+	public String getObjName() {
+		return objName;
+	}
+
+	/**
+	 * Set the type of Object
+	 * 
+	 * @param objName
+	 *            String
+	 */
+	public void setObjName(String objName) {
+		this.objName = objName;
+	}
+
+	/**
+	 * Getter for the user-defined name (no unique)
+	 * 
+	 * @return String
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * Set the name
+	 * 
+	 * @param name
+	 *            String
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	/**
+	 * Getter of the unique ID
+	 * 
+	 * @return int
+	 */
+	public int getID() {
+		return ID;
+	}
+
+	/**
+	 * Set the ID to a new one
+	 * 
+	 * @param iD
+	 *            the iD to set
+	 */
+	public void setID(int ID) {
+		this.ID = ID;
+	}
+
+	/**
+	 * Get the path of the image for the selected Object
+	 * 
+	 * @return String
+	 */
+	public String getImage() {
+		return image;
+	}
+
+	/**
+	 * Set the path of the image
+	 * 
+	 * @param image
+	 *            the Image to set
+	 */
+	public void setImage(String image) {
+		this.image = image;
+	}
+
+	/**
+	 * List of all existing connections
+	 * 
+	 * @return the connections ArrayList
+	 */
+	public ArrayList<CpsEdge> getConnections() {
+		return connections;
+	}
+
+	/**
+	 * Set a new ArrayList of connections (Update)
+	 * 
+	 * @param arrayList
+	 *            the connections to set
+	 */
+	public void setConnections(ArrayList<CpsEdge> arrayList) {
+		this.connections = arrayList;
+	}
+
+	/**
+	 * List of all existing connections
+	 * 
+	 * @return the connections ArrayList
+	 */
+	public ArrayList<CpsEdge> getConnectedTo() {
+		return connections;
+	}
+
+	/**
+	 * Add a new connection to the selected Object
+	 * 
+	 * @param toConnect
+	 *            Edge
+	 */
+	public void AddConnection(CpsEdge toConnect) {
+		connections.add(toConnect);
+	}
+
+	/**
+	 * Set the position of the Object in the canvas
+	 * 
+	 * @param pos
+	 *            Coordinates
+	 */
+	public void setPosition(Position pos) {
+		this.position = pos;
+	}
+
+	/**
+	 * Set the position of the Object in the canvas
+	 * 
+	 * @param x
+	 *            X-Coord
+	 * @param y
+	 *            Y-Coord
+	 */
+	public void setPosition(int x, int y) {
+		setPosition(new Position(x, y));
+	}
+
+	/**
+	 * Get the actual position of the Object
+	 * 
+	 * @return
+	 */
+	public Position getPosition() {
+		return position;
+	}
+
+	/**
+	 * @return the stored
+	 */
+	public String getSav() {
+		return sav;
+	}
+
+	/**
+	 * @param stored
+	 *            the stored to set
+	 */
+	public void setSav(String sav) {
+		this.sav = sav;
+	}
+
+	/**
+	 * Get the color of the border
+	 * 
+	 * @return the BorderColor
+	 */
+	public Color getBorderColor() {
+		return BorderColor;
+	}
+
+	/**
+	 * Set the Border Color of this CpsObject
+	 * 
+	 * @param the
+	 *            BorderColor
+	 */
+	public void setBorderColor(Color c) {
+		this.BorderColor = c;
+	}
+
+	/**
+	 * Set the Color of the edges
+	 * 
+	 * @param Color
+	 *            the Color to set
+	 */
+	public void setConnections(Color color) {
+		this.BorderColor = color;
+	}
+
+	/**
+	 * For internal purpose (energy flow)
+	 * 
+	 * @param tag
+	 */
+	public void addTag(int tag) {
+		this.tags.add(tag);
+	}
+
+	/**
+	 * Get the actual tags
+	 * 
+	 * @return ArrayList
+	 */
+	public ArrayList<Integer> getTag() {
+		return tags;
+	}
+
+	/**
+	 * Rest the tags to Null
+	 */
+	public void resetTags() {
+		this.tags = new ArrayList<Integer>();
+	}
+
+	public void setTags(ArrayList<Integer> tags) {
+		this.tags = tags;
+	}
+	
+	public ArrayList<Integer> getPseudoTags(){
+		return pseudoTags;
+	}
+	
+	public void addPseudoTag(int pseudo){
+		pseudoTags.add(pseudo);
+	}
+	
+	public void setPseudoTags(ArrayList<Integer> tags){
+		pseudoTags = tags;
+	}
+}

+ 91 - 4
src/classes/HolonSwitch.java

@@ -3,7 +3,19 @@ package classes;
 import java.awt.Point;
 import java.util.LinkedList;
 
+<<<<<<< HEAD
 public class HolonSwitch extends AbstractCpsObject {
+=======
+/**
+ * The class HolonSwitch represents an Object in the system, that has the
+ * capacity of manipulate the electricity flow. The switch can be manage
+ * automatically through a graph or direct manually.
+ * 
+ * @author Gruppe14
+ *
+ */
+public class HolonSwitch extends CpsObject {
+>>>>>>> branch 'Ohne_Drag_and_Drop' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons.git
 	/*
 	 * manual state True, if this wire is working (capable of carrying
 	 * electricity), else false
@@ -29,6 +41,13 @@ public class HolonSwitch extends AbstractCpsObject {
 	// Points on the UnitGraph
 	LinkedList<Point> graphPoints = new LinkedList<>();
 
+	/**
+	 * Create a new HolonSwitch with the default name ("Switch"), a default
+	 * value of automatic handle and active status
+	 * 
+	 * @param ObjName
+	 *            String
+	 */
 	public HolonSwitch(String ObjName) {
 		super(ObjName);
 		setManualState(true);
@@ -37,6 +56,15 @@ public class HolonSwitch extends AbstractCpsObject {
 		setManualMode(false);
 	}
 
+	/**
+	 * Create a new HolonSwitch with user-defined name, a default value of
+	 * automatic handle and active status
+	 * 
+	 * @param ObjName
+	 *            String
+	 * @param obj
+	 *            String
+	 */
 	public HolonSwitch(String ObjName, String obj) {
 		super(ObjName);
 		super.setName(obj);
@@ -46,7 +74,16 @@ public class HolonSwitch extends AbstractCpsObject {
 		setManualMode(false);
 	}
 
+<<<<<<< HEAD
 	public HolonSwitch(AbstractCpsObject obj) {
+=======
+	/**
+	 * Create a copy of an existing HolonSwitch.
+	 * 
+	 * @param obj
+	 */
+	public HolonSwitch(CpsObject obj) {
+>>>>>>> branch 'Ohne_Drag_and_Drop' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons.git
 		super(obj);
 		super.setName(obj.getName());
 		setManualState(true);
@@ -55,6 +92,9 @@ public class HolonSwitch extends AbstractCpsObject {
 		setManualMode(false);
 	}
 
+	/**
+	 * Calculates the state of the Switch
+	 */
 	public void switchState() {
 		if (manualMode) {
 			if (this.manualActive == true) {
@@ -65,15 +105,27 @@ public class HolonSwitch extends AbstractCpsObject {
 			this.manualActive = !manualActive;
 		}
 	}
-	
-	public boolean getState(int timeStep){
-		if(manualMode){
+
+	/**
+	 * Getter for the status of the Switch at a given timestep
+	 * 
+	 * @param timeStep
+	 *            int
+	 * @return state value
+	 */
+	public boolean getState(int timeStep) {
+		if (manualMode) {
 			return this.manualActive;
 		} else {
 			return getActiveAt()[timeStep];
 		}
 	}
 
+	/**
+	 * Overall status of the switch (manual or automatic mode)
+	 * 
+	 * @return
+	 */
 	public boolean getState() {
 		if (manualMode) {
 			return this.manualActive;
@@ -83,16 +135,29 @@ public class HolonSwitch extends AbstractCpsObject {
 
 	}
 
+	/**
+	 * Change the state of the Switch to manual
+	 * 
+	 * @param state
+	 */
 	public void setManualState(boolean state) {
 		this.manualActive = state;
 		setImage();
 	}
 
+	/**
+	 * Set the state of the Switch to automatic
+	 * 
+	 * @param state
+	 */
 	public void setAutoState(boolean state) {
 		this.autoActive = state;
 		setImage();
 	}
 
+	/**
+	 * Set Image of the Switch
+	 */
 	private void setImage() {
 		if (manualMode) {
 			if (this.manualActive == false) {
@@ -110,6 +175,8 @@ public class HolonSwitch extends AbstractCpsObject {
 	}
 
 	/**
+	 * For automatic use only (throught the graph)
+	 * 
 	 * @return the Graph Points
 	 */
 	public LinkedList<Point> getGraphPoints() {
@@ -117,6 +184,8 @@ public class HolonSwitch extends AbstractCpsObject {
 	}
 
 	/**
+	 * Set the values of the switch in the graph (auto. mode only)
+	 * 
 	 * @param points,
 	 *            the Graph points
 	 */
@@ -125,17 +194,25 @@ public class HolonSwitch extends AbstractCpsObject {
 	}
 
 	/**
-	 * get the activeAt Array
+	 * All values of the graph for the selected Switch (only auto-Mode) get the
+	 * activeAt Array
 	 */
 	public boolean[] getActiveAt() {
 		return activeAt;
 	}
 
+	/**
+	 * Overall value of the Swtich (only manual-Mode)
+	 * 
+	 * @return
+	 */
 	public boolean getActiveManual() {
 		return this.manualActive;
 	}
 
 	/**
+	 * Set the value of the Switch
+	 * 
 	 * @param active,
 	 *            the default value
 	 */
@@ -145,10 +222,20 @@ public class HolonSwitch extends AbstractCpsObject {
 		}
 	}
 
+	/**
+	 * Set the overall value of the Switch (manual mode)
+	 * 
+	 * @param mode
+	 */
 	public void setManualMode(boolean mode) {
 		manualMode = mode;
 	}
 
+	/**
+	 * Get the value of the switch (manual mode)
+	 * 
+	 * @return
+	 */
 	public boolean getManualMode() {
 		return manualMode;
 	}

+ 22 - 5
src/classes/Position.java

@@ -1,16 +1,33 @@
 package classes;
 
+/**
+ * Coordinates of an Object on the canvas with a (int) x-coord and a (int)
+ * y-coord
+ * 
+ * @author Gruppe14
+ *
+ */
 public class Position {
 	public int x;
 	public int y;
-	
-	public Position(int x, int y){
+
+	/**
+	 * Constructor with an positive x and y coord on the canvas
+	 * 
+	 * @param x
+	 *            int
+	 * @param y
+	 *            int
+	 */
+	public Position(int x, int y) {
 		this.x = x;
 		this.y = y;
 	}
-	
-	//default Constructor
-	public Position(){
+
+	/**
+	 * Default constructor without defined position
+	 */
+	public Position() {
 		this.x = -1;
 		this.y = -1;
 	}

+ 14 - 8
src/classes/subNet.java

@@ -2,26 +2,32 @@ package classes;
 
 import java.util.ArrayList;
 
+/**
+ * The class "subNet" represents ....
+ * 
+ * @author Gruppe14
+ *
+ */
 public class subNet {
 	private ArrayList<HolonObject> subNetObjects;
 	private ArrayList<CpsEdge> subNetEdges;
 	private ArrayList<HolonSwitch> subNetSwitches;
-	
-	public subNet(ArrayList<HolonObject> objects, ArrayList<CpsEdge> edges, ArrayList<HolonSwitch> switches){
+
+	public subNet(ArrayList<HolonObject> objects, ArrayList<CpsEdge> edges, ArrayList<HolonSwitch> switches) {
 		subNetObjects = objects;
 		subNetEdges = edges;
 		subNetSwitches = switches;
 	}
-	
-	public ArrayList<HolonObject> getObjects(){
+
+	public ArrayList<HolonObject> getObjects() {
 		return subNetObjects;
 	}
-	
-	public ArrayList<CpsEdge> getEdges(){
+
+	public ArrayList<CpsEdge> getEdges() {
 		return subNetEdges;
 	}
-	
-	public ArrayList<HolonSwitch> getSwitches(){
+
+	public ArrayList<HolonSwitch> getSwitches() {
 		return subNetSwitches;
 	}
 }

+ 8 - 0
src/tests/praktikumHolonsTestClasses.java

@@ -0,0 +1,8 @@
+package tests;
+
+import classes.*;
+
+public class praktikumHolonsTestClasses {
+
+	
+}

+ 58 - 1
src/tests/praktikumHolonsTestLoadAndStoreController.java

@@ -86,7 +86,7 @@ public class praktikumHolonsTestLoadAndStoreController {
 	@Test
 	public void testStoreBasic() {
 
-		for (int i = 1; i <= 10; i++) {
+		for (int i = 1; i <= 26; i++) {
 			cg.addNewCategory(adapter.generate(i));
 			assertTrue("Number of Categories does not match", model.getCategories().size() == i + 3);
 			assertTrue("Category was not created", mp.searchCat(adapter.generate(i)) != null);
@@ -195,7 +195,64 @@ public class praktikumHolonsTestLoadAndStoreController {
 	
 	@Test
 	public void testLoadBasic() {
+		assertTrue("Non-Existant Category Exists", mp.searchCat("J") == null);
+		assertTrue("Non-Existant Category Exists", mp.searchCat("U") == null);
+		assertTrue("Non-Existant Category Exists", mp.searchCat("L") == null);
+		assertTrue("Non-Existant Category Exists", mp.searchCat("I") == null);
+		assertTrue("Non-Existant Category Exists", mp.searchCat("A") == null);
+		assertTrue("Non-Existant Category Exists", mp.searchCat("N") == null);
+		
 		
+		try {
+			assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 0);
+			assertTrue("Canvas File was not found", new File(path + "TestCanvasBasic.json").exists());
+			loadController.readJSON(path + "TestCanvasBasic.json");
+			assertTrue("NUmber of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 10);
+			for (CpsObject obj : model.getObjectsOnCanvas()) {
+				assertTrue("Not instance of HolonObject", obj instanceof HolonObject);
+			}
+			
+			assertTrue("NUmber of Categories not match", model.getCategories().size() == 3);
+			assertTrue("Canvas File was not found", new File(path + "TestSavBasic.json").exists());
+			loadController.readJSON(path + "TestSavBasic.json");
+			assertTrue("NUmber of Categories not match", model.getCategories().size() == 29);
+			assertTrue("Existant Category dont Exists", mp.searchCat("J") != null);
+			assertTrue("Existant Category dont Exists", mp.searchCat("U") != null);
+			assertTrue("Existant Category dont Exists", mp.searchCat("L") != null);
+			assertTrue("Existant Category dont Exists", mp.searchCat("I") != null);
+			assertTrue("Existant Category dont Exists", mp.searchCat("A") != null);
+			assertTrue("Existant Category dont Exists", mp.searchCat("N") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "A") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "B") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "C") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "D") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "E") != null);
+			assertTrue("Existant Object dont Exists", mp.searchCatObj(mp.searchCat("Z"), "F") != null);
+			
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+	
+	@Test
+	public void testLoadAdvanced() {
+		
+		try {
+			assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 0);
+			assertTrue("Save File was not found", new File(path + "TestSavAdvanced.json").exists());
+			loadController.readJSON(path + "TestSavAdvanced.json");
+			assertTrue("Objects on Canvas is not 0", model.getObjectsOnCanvas().size() == 100);
+			
+			int n = model.getObjectsOnCanvas().size();
+			assertTrue("Number of Edges does not Match", model.getEdgesOnCanvas().size() == (n * (n - 1)) / 2);
+			assertTrue("Element has no UnitGraph", !mp.searchEle((HolonObject)model.getObjectsOnCanvas().get(77), "Fridge").getGraphPoints().isEmpty());
+			assertTrue("Points in UnitGraph does not Match", mp.searchEle((HolonObject)model.getObjectsOnCanvas().get(77), "Fridge").getGraphPoints().size() == 3);
+
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
 	}
 
 	/**

+ 51 - 8
src/ui/controller/SimulationManager.java

@@ -106,6 +106,7 @@ public class SimulationManager {
 			float energy = hl.getCurrentEnergyAtTimeStep(timeStep);
 			if(energy > 0){
 				tagTable.put(hl.getID(), energy);
+				hl.addTag(hl.getID());
 				for(CpsEdge edge: hl.getConnections()){
 					if(edge.getState()){
 						if(edge.getA().getID() == hl.getID()){
@@ -126,27 +127,48 @@ public class SimulationManager {
 				}
 			}
 		}
-		setFlowSimRec(producers);
+		setFlowSimRec(producers, 0);
 	}
 	
+<<<<<<< HEAD
 	public void setFlowSimRec(ArrayList<AbstractCpsObject> nodes){
 		ArrayList<AbstractCpsObject> newNodes = new ArrayList<AbstractCpsObject>();
 		AbstractCpsObject tmp = null;
+=======
+	public void setFlowSimRec(ArrayList<CpsObject> nodes, int iter){
+		ArrayList<CpsObject> newNodes = new ArrayList<CpsObject>();
+		ArrayList<Integer> pseudoTags = new ArrayList<Integer>();
+		CpsObject tmp = null;
+>>>>>>> branch 'Ohne_Drag_and_Drop' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons.git
 		if(nodes.size() != 0){
 			for(AbstractCpsObject cps: nodes){
 				for(CpsEdge edge: cps.getConnections()){
 					for(Integer tag: cps.getTag()){
 						if(edge.getState() && !(edge.getTags().contains(tag))){
 							edge.setFlow(edge.getFlow() + tagTable.get(tag));
-							System.out.println(cps.getID() + " has tags:" + getString(cps));
+							edge.calculateState(true);
 							edge.addTag(tag);
 							if(edge.getA().getID() == cps.getID()){
 								tmp = edge.getB();
-								tmp.setTags(mergeLists(tmp.getTag(), cps.getTag()));
 							}
 							if(edge.getB().getID() == cps.getID()){
 								tmp = edge.getA();
-								tmp.setTags(mergeLists(tmp.getTag(), cps.getTag()));
+							}
+							if(tmp.getPseudoTags() != null){
+								pseudoTags.addAll(tmp.getPseudoTags());
+							}
+							pseudoTags.addAll(cps.getTag());
+							tmp.setPseudoTags(mergeLists(tmp.getTag(), pseudoTags));
+							if(!edge.getState()){
+								newNodes.remove(edge.getA());
+								newNodes.remove(edge.getB());
+								if(edge.getA().getID() == cps.getID()){
+									edge.getB().getPseudoTags().removeAll(edge.getTags());
+
+								}
+								if(edge.getB().getID() == cps.getID()){
+									edge.getA().getPseudoTags().removeAll(edge.getTags());
+								}
 							}
 							if(edge.getState() && !(newNodes.contains(tmp))){
 								newNodes.add(tmp);
@@ -156,13 +178,30 @@ public class SimulationManager {
 				edge.calculateState(true);
 				}
 			}
-			setFlowSimRec(newNodes);
+			//printNodes(newNodes);
+			setPseudoTags(newNodes);
+			setFlowSimRec(newNodes, iter + 1);
 		}
 	}
 	
+<<<<<<< HEAD
 	public String getString(AbstractCpsObject cps){
+=======
+	public void setPseudoTags(ArrayList<CpsObject> nodes){
+		for(CpsObject node: nodes){
+			node.setTags(node.getPseudoTags());
+		}
+	}
+	public void printNodes(ArrayList<CpsObject> nodes){
+		System.out.println("new Nodes:");
+		for(CpsObject node: nodes){
+			System.out.println(node.getID());
+		}
+	}
+	public String getString(ArrayList<Integer> tags){
+>>>>>>> branch 'Ohne_Drag_and_Drop' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons.git
 		String result = "";
-		for(Integer i:cps.getTag()){
+		for(Integer i: tags){
 			result = result + ", " + i;
 		}
 		return result;
@@ -171,11 +210,15 @@ public class SimulationManager {
 	public ArrayList<Integer> mergeLists(ArrayList<Integer> A, ArrayList<Integer> B){
 		ArrayList<Integer> result = new ArrayList<Integer>();
 		for(Integer i: A){
-			if(!(B.contains(i))){
+			if(!(result.contains(i))){
 				result.add(i);
 			}
 		}
-		result.addAll(B);
+		for(Integer j: B){
+			if(!(result.contains(j))){
+				result.add(j);
+			}
+		}
 		return result;
 	}
 	

+ 6 - 3
src/ui/model/idCounter.java

@@ -3,12 +3,11 @@ package ui.model;
 public class idCounter {
 	private static int counter = 1;
 
-
 	public static synchronized int nextId() {
 		return counter++;
 
 	}
-	
+
 	/**
 	 * @return the counter
 	 */
@@ -17,10 +16,14 @@ public class idCounter {
 	}
 
 	/**
-	 * @param counter the counter to set
+	 * @param counter
+	 *            the counter to set
 	 */
 	public static void setCounter(int counter) {
 		idCounter.counter = counter;
 	}
 
+	public static void resetCounter() {
+		counter = 1;
+	}
 }

+ 7 - 3
src/ui/model/idCounterElem.java

@@ -3,12 +3,11 @@ package ui.model;
 public class idCounterElem {
 	private static int counter = 1;
 
-
 	public static synchronized int nextId() {
 		return counter++;
 
 	}
-	
+
 	/**
 	 * @return the counter
 	 */
@@ -17,10 +16,15 @@ public class idCounterElem {
 	}
 
 	/**
-	 * @param counter the counter to set
+	 * @param counter
+	 *            the counter to set
 	 */
 	public static void setCounter(int counter) {
 		idCounterElem.counter = counter;
 	}
 
+	public static void resetCounter() {
+		counter = 1;
+	}
+
 }

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

@@ -69,7 +69,9 @@ import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.HolonTransformer;
 import ui.controller.Control;
-import ui.model.Model;;
+import ui.model.Model;
+import ui.model.idCounter;
+import ui.model.idCounterElem;;
 
 public class GUI<E> implements CategoryListener {
 
@@ -1351,6 +1353,8 @@ public class GUI<E> implements CategoryListener {
 				canvas.tempCps = null;
 				canvas.objectSelectionHighlighting();
 				canvas.repaint();
+				idCounter.resetCounter();
+				idCounterElem.resetCounter();
 			}
 		});
 

+ 0 - 1
src/ui/view/MyCanvas.java

@@ -656,7 +656,6 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			e = new CpsEdge(n, tempCps, edgeCapacity);
 
 			controller.AddEdgeOnCanvas(e);
-			// System.out.println("node ID: " + n.getID());
 		}
 
 		// Wenn ein Node ohne Connections da ist