Browse Source

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

Jessey Widhalm 7 years ago
parent
commit
9cd896b6be

+ 6 - 6
src/API/CpsAPI.java

@@ -4,7 +4,7 @@ import java.awt.Color;
 import java.util.ArrayList;
 
 import classes.CpsEdge;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.subNet;
@@ -33,7 +33,7 @@ public class CpsAPI {
 	 * 
 	 * @return all Objects on Canvas in no specific order
 	 */
-	public ArrayList<CpsObject> getAllObjOnCanvas(){
+	public ArrayList<AbstractCpsObject> getAllObjOnCanvas(){
 
 		return controller.getModel().getObjectsOnCanvas();
 	}
@@ -95,7 +95,7 @@ public class CpsAPI {
 	 * @param toChange
 	 * @param color
 	 */
-	public void setBorderColorForObj(CpsObject toChange, Color color){
+	public void setBorderColorForObj(AbstractCpsObject toChange, Color color){
 		toChange.setBorderColor(color);
 	}
 	
@@ -104,8 +104,8 @@ public class CpsAPI {
 	 * @param objects
 	 * @param color
 	 */
-	public void setBorderColorForMultObj(ArrayList<CpsObject> objects, Color color){
-		for(CpsObject cps: objects){
+	public void setBorderColorForMultObj(ArrayList<AbstractCpsObject> objects, Color color){
+		for(AbstractCpsObject cps: objects){
 			setBorderColorForObj(cps, color);
 		}
 	}
@@ -114,7 +114,7 @@ public class CpsAPI {
 	 * resets the bordercolor of given object to default (white)
 	 * @param toReset
 	 */
-	public void resetBorderColor(CpsObject toReset){
+	public void resetBorderColor(AbstractCpsObject toReset){
 		toReset.setBorderColor(Color.WHITE);
 	}
 	

+ 1 - 1
src/Interfaces/ObjectListener.java

@@ -3,5 +3,5 @@ package Interfaces;
 import java.util.ArrayList;
 
 public interface ObjectListener {
-	public void onChange(ArrayList<classes.CpsObject> objects);
+	public void onChange(ArrayList<classes.AbstractCpsObject> objects);
 }

+ 83 - 53
src/classes/CpsObject.java → src/classes/AbstractCpsObject.java

@@ -2,8 +2,6 @@ package classes;
 
 import java.awt.Color;
 import java.util.ArrayList;
-import java.util.HashMap;
-
 import ui.model.idCounter;
 
 /**
@@ -14,13 +12,13 @@ import ui.model.idCounter;
  * @author Gruppe14
  *
  */
-public abstract class CpsObject {
-	/* Type of the Object */
+public abstract class AbstractCpsObject {
+	/* Type of the Object. */
 	String objName;
-	/* Name given by the user */
+	/* Name given by the user. */
 	String name;
 	/* ID of the Obj. */
-	int ID;
+	int id;
 	/* Path of the image for the Obj. */
 	String image;
 	/* Array of neighbors */
@@ -32,16 +30,20 @@ public abstract class CpsObject {
 	 * Stored
 	 */
 	String sav;
-	/* BorderColor the user sets */
-	Color BorderColor = Color.WHITE;
+	/* 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 */
+	/* a Tag that can be used */
 	ArrayList<Integer> pseudoTags;
+	
 	/**
-	 * Constructor for a CpsObejct with an unique ID
+	 * Constructor for a CpsObejct with an unique ID.
+	 * 
+	 * @param objName
+	 *            of the Object
 	 */
-	public CpsObject(String objName) {
+	public AbstractCpsObject(String objName) {
 		setObjName(objName);
 		setName(objName);
 		setImage("/Images/Dummy_House.png");
@@ -55,7 +57,7 @@ public abstract class CpsObject {
 	 * @param obj
 	 *            Object to be copied
 	 */
-	public CpsObject(CpsObject obj) {
+	public AbstractCpsObject(AbstractCpsObject obj) {
 		setObjName(obj.getObjName());
 		setName(obj.getObjName());
 		setConnections(new ArrayList<CpsEdge>());
@@ -65,7 +67,7 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Getter for the type of the Object
+	 * Getter for the type of the Object.
 	 * 
 	 * @return String
 	 */
@@ -74,7 +76,7 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Set the type of Object
+	 * Set the type of Object.
 	 * 
 	 * @param objName
 	 *            String
@@ -84,7 +86,7 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Getter for the user-defined name (no unique)
+	 * Getter for the user-defined name (no unique).
 	 * 
 	 * @return String
 	 */
@@ -93,7 +95,7 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Set the name
+	 * Set the name.
 	 * 
 	 * @param name
 	 *            String
@@ -103,26 +105,26 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Getter of the unique ID
+	 * Getter of the unique ID.
 	 * 
 	 * @return int
 	 */
 	public int getID() {
-		return ID;
+		return id;
 	}
 
 	/**
-	 * Set the ID to a new one
+	 * Set the ID to a new one.
 	 * 
-	 * @param iD
+	 * @param id
 	 *            the iD to set
 	 */
-	public void setID(int ID) {
-		this.ID = ID;
+	public void setID(int id) {
+		this.id = id;
 	}
 
 	/**
-	 * Get the path of the image for the selected Object
+	 * Get the path of the image for the selected Object.
 	 * 
 	 * @return String
 	 */
@@ -131,7 +133,7 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Set the path of the image
+	 * Set the path of the image.
 	 * 
 	 * @param image
 	 *            the Image to set
@@ -141,7 +143,7 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * List of all existing connections
+	 * List of all existing connections.
 	 * 
 	 * @return the connections ArrayList
 	 */
@@ -150,7 +152,7 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Set a new ArrayList of connections (Update)
+	 * Set a new ArrayList of connections (Update).
 	 * 
 	 * @param arrayList
 	 *            the connections to set
@@ -160,7 +162,7 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * List of all existing connections
+	 * List of all existing connections.
 	 * 
 	 * @return the connections ArrayList
 	 */
@@ -169,17 +171,17 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Add a new connection to the selected Object
+	 * Add a new connection to the selected Object.
 	 * 
 	 * @param toConnect
 	 *            Edge
 	 */
-	public void AddConnection(CpsEdge toConnect) {
+	public void addConnection(CpsEdge toConnect) {
 		connections.add(toConnect);
 	}
 
 	/**
-	 * Set the position of the Object in the canvas
+	 * Set the position of the Object in the canvas.
 	 * 
 	 * @param pos
 	 *            Coordinates
@@ -189,7 +191,7 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Set the position of the Object in the canvas
+	 * Set the position of the Object in the canvas.
 	 * 
 	 * @param x
 	 *            X-Coord
@@ -201,15 +203,17 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Get the actual position of the Object
+	 * Get the actual position of the Object.
 	 * 
-	 * @return
+	 * @return Position Position of this Object
 	 */
 	public Position getPosition() {
 		return position;
 	}
 
 	/**
+	 * For save purpose.
+	 * 
 	 * @return the stored
 	 */
 	public String getSav() {
@@ -217,7 +221,9 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * @param stored
+	 * For save purpose.
+	 * 
+	 * @param sav
 	 *            the stored to set
 	 */
 	public void setSav(String sav) {
@@ -225,45 +231,46 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Get the color of the border
+	 * Get the color of the border.
 	 * 
 	 * @return the BorderColor
 	 */
 	public Color getBorderColor() {
-		return BorderColor;
+		return borderColor;
 	}
 
 	/**
-	 * Set the Border Color of this CpsObject
+	 * Set the Border Color of this CpsObject.
 	 * 
-	 * @param the
-	 *            BorderColor
+	 * @param c
+	 *          the BorderColor
 	 */
 	public void setBorderColor(Color c) {
-		this.BorderColor = c;
+		this.borderColor = c;
 	}
 
 	/**
-	 * Set the Color of the edges
+	 * Set the Color of the edges.
 	 * 
-	 * @param Color
+	 * @param color
 	 *            the Color to set
 	 */
 	public void setConnections(Color color) {
-		this.BorderColor = color;
+		this.borderColor = color;
 	}
 
 	/**
-	 * For internal purpose (energy flow)
+	 * For internal purpose (energy flow).
 	 * 
 	 * @param tag
+	 *            for internal purpose
 	 */
 	public void addTag(int tag) {
 		this.tags.add(tag);
 	}
 
 	/**
-	 * Get the actual tags
+	 * Get the actual tags.
 	 * 
 	 * @return ArrayList
 	 */
@@ -272,25 +279,48 @@ public abstract class CpsObject {
 	}
 
 	/**
-	 * Rest the tags to Null
+	 * Rest the tags to Null.
 	 */
 	public void resetTags() {
 		this.tags = new ArrayList<Integer>();
 	}
 
+	/**
+	 * For internal purpose (energy flow).
+	 * 
+	 * @param tags
+	 *            for internal purpose
+	 */
 	public void setTags(ArrayList<Integer> tags) {
 		this.tags = tags;
 	}
-	
-	public ArrayList<Integer> getPseudoTags(){
-		return pseudoTags;
+
+	/**
+	 * For internal purpose (energy flow).
+	 * 
+	 * @param tags
+	 *            for internal purpose
+	 */
+	public void setPseudoTags(ArrayList<Integer> tags) {
+		this.pseudoTags= tags;
 	}
 	
-	public void addPseudoTag(int pseudo){
-		pseudoTags.add(pseudo);
+	/**
+	 * Get the pseudo tags.
+	 * 
+	 * @return ArrayList
+	 */
+	public ArrayList<Integer> getPseudoTags() {
+		return this.pseudoTags;
 	}
 	
-	public void setPseudoTags(ArrayList<Integer> tags){
-		pseudoTags = tags;
+	/**
+	 * add a pseudo tag.
+	 * 
+	 * @return ArrayList
+	 */
+	public ArrayList<Integer> addPseudoTag() {
+		return this.pseudoTags;
 	}
+	
 }

+ 15 - 10
src/classes/Category.java

@@ -14,40 +14,45 @@ import java.util.HashMap;
 
 public class Category {
 	// objects: is a ArrayList of all Objects that belongs to the Category
-	private ArrayList<CpsObject> objects;
+	private ArrayList<AbstractCpsObject> objects;
 	// name: is a String chosen by the User
 	private String name;
 	// ObjIdx: Index of each Category that corresponds to the order in the tree
 	private HashMap<String, Integer> objIdx;
 
+	/**
+	 * Category Constructor.
+	 * 
+	 * @param name name of the Category
+	 */
 	public Category(String name) {
-		setObjects(new ArrayList<CpsObject>());
+		setObjects(new ArrayList<AbstractCpsObject>());
 		setName(name);
 		setObjIdx(new HashMap<String, Integer>());
 
 	}
 
 	/**
-	 * Getter for all CpsObjects
+	 * Getter for all CpsObjects.
 	 * 
 	 * @return the objects
 	 */
-	public ArrayList<CpsObject> getObjects() {
+	public ArrayList<AbstractCpsObject> getObjects() {
 		return objects;
 	}
 
 	/**
-	 * Set a new ArrayList of CpsObjects
+	 * Set a new ArrayList of CpsObjects.
 	 * 
 	 * @param objects
 	 *            the objects to set
 	 */
-	public void setObjects(ArrayList<CpsObject> objects) {
+	public void setObjects(ArrayList<AbstractCpsObject> objects) {
 		this.objects = objects;
 	}
 
 	/**
-	 * Getter the name of the Category
+	 * Getter the name of the Category.
 	 * 
 	 * @return the name
 	 */
@@ -56,7 +61,7 @@ public class Category {
 	}
 
 	/**
-	 * Set the name of the Category to a new one
+	 * Set the name of the Category to a new one.
 	 * 
 	 * @param name
 	 *            the name to set
@@ -66,7 +71,7 @@ public class Category {
 	}
 
 	/**
-	 * Getter of the Objects in the Tree with their respective order
+	 * Getter of the Objects in the Tree with their respective order.
 	 * 
 	 * @return the objIdx
 	 */
@@ -75,7 +80,7 @@ public class Category {
 	}
 
 	/**
-	 * Set a new sequence of Objects in the tree
+	 * Set a new sequence of Objects in the tree.
 	 * 
 	 * @param objIdx
 	 *            the objIdx to set

+ 46 - 41
src/classes/CpsEdge.java

@@ -27,23 +27,23 @@ public class CpsEdge {
 	// for internal use --> flow of electricity (simulation state)
 	ArrayList<Integer> tags;
 	// Source
-	CpsObject A;
+	AbstractCpsObject a;
 	// Destination
-	CpsObject B;
+	AbstractCpsObject b;
 
 	/**
 	 * Constructor without max. capacity (by default as 100)
 	 * 
-	 * @param A
+	 * @param a
 	 *            Source
-	 * @param B
+	 * @param b
 	 *            Destination
 	 */
-	public CpsEdge(CpsObject A, CpsObject B) {
-		setA(A);
-		setB(B);
-		this.A.AddConnection(this);
-		this.B.AddConnection(this);
+	public CpsEdge(AbstractCpsObject a, AbstractCpsObject b) {
+		setA(a);
+		setB(b);
+		this.a.addConnection(this);
+		this.b.addConnection(this);
 		this.maxCapacity = 100;
 		flow = 0;
 		isWorking = true;
@@ -52,16 +52,18 @@ public class CpsEdge {
 	/**
 	 * Constructor with a user-defined max. capacity
 	 * 
-	 * @param A
+	 * @param a
 	 *            Source
-	 * @param B
+	 * @param b
 	 *            Destination
-	 */
-	public CpsEdge(CpsObject A, CpsObject B, float maxCap) {
-		setA(A);
-		setB(B);
-		this.A.AddConnection(this);
-		this.B.AddConnection(this);
+	 * @param maxCap
+	 *            Maximum Capacity
+	 */
+	public CpsEdge(AbstractCpsObject a, AbstractCpsObject b, float maxCap) {
+		setA(a);
+		setB(b);
+		this.a.addConnection(this);
+		this.b.addConnection(this);
 		this.maxCapacity = maxCap;
 		flow = 0;
 		isWorking = true;
@@ -87,7 +89,7 @@ public class CpsEdge {
 	}
 
 	/**
-	 * Getter fot the current flow
+	 * Getter fot the current flow.
 	 * 
 	 * @return the flow
 	 */
@@ -96,7 +98,7 @@ public class CpsEdge {
 	}
 
 	/**
-	 * Set the flow into a new one
+	 * Set the flow into a new one.
 	 * 
 	 * @param flow
 	 *            the flow to set
@@ -105,14 +107,15 @@ public class CpsEdge {
 		this.flow = flow;
 		/**
 		 * if (flow <= maxCapacity || flow == -1) { isWorking = true; } else {
-		 * isWorking = false; state = false; }
+		 * isWorking = false; state = false;
 		 **/
 	}
 
 	/**
-	 * Calculates the state of the edge (see description of isWorking)
+	 * Calculates the state of the edge (see description of isWorking).
 	 * 
 	 * @param simMode
+	 *            Simulation Mode
 	 */
 
 	public void calculateState(boolean simMode) {
@@ -126,83 +129,85 @@ public class CpsEdge {
 	}
 
 	/**
-	 * Getter for the Source
+	 * Getter for the Source.
 	 * 
 	 * @return the a
 	 */
-	public CpsObject getA() {
-		return A;
+	public AbstractCpsObject getA() {
+		return a;
 	}
 
 	/**
-	 * Set the Source to a new one
+	 * Set the Source to a new one.
 	 * 
 	 * @param a
 	 *            the a to set
 	 */
-	public void setA(CpsObject a) {
-		A = a;
+	public void setA(AbstractCpsObject a) {
+		this.a = a;
 	}
 
 	/**
-	 * Getter for the destination
+	 * Getter for the destination.
 	 * 
 	 * @return the b
 	 */
-	public CpsObject getB() {
-		return B;
+	public AbstractCpsObject getB() {
+		return b;
 	}
 
 	/**
-	 * Set the Destination to a new one
+	 * Set the Destination to a new one.
 	 * 
 	 * @param b
 	 *            the b to set
 	 */
-	public void setB(CpsObject b) {
-		B = b;
+	public void setB(AbstractCpsObject b) {
+		this.b = b;
 	}
 
 	/**
-	 * Set the state manually to a new one
+	 * Set the state manually to a new one.
 	 * 
 	 * @param state
+	 *            the state
 	 */
 	public void setState(boolean state) {
 		isWorking = state;
 	}
 
 	/**
-	 * Getter for the status
+	 * Getter for the status.
 	 * 
-	 * @return
+	 * @return the state
 	 */
 	public boolean getState() {
 		return isWorking;
 	}
 
 	/**
-	 * set the tags into a new set of tags
+	 * set the tags into a new set of tags.
 	 * 
 	 * @param tags
+	 *            tags for this edge
 	 */
 	public void setTags(ArrayList<Integer> tags) {
 		this.tags = tags;
 	}
 
 	/**
-	 * Getter for the ArrayList of tags
+	 * Getter for the ArrayList of tags.
 	 * 
-	 * @return
+	 * @return tags tags for this edge
 	 */
 	public ArrayList<Integer> getTags() {
 		return tags;
 	}
 
 	/**
-	 * Add a new tag to the ArrayList
+	 * Add a new tag to the ArrayList.
 	 * 
-	 * @param tag
+	 * @param tag tag for the ArrayList
 	 */
 	public void addTag(int tag) {
 		tags.add(tag);

+ 3 - 3
src/classes/CpsNode.java

@@ -11,10 +11,10 @@ import ui.model.idCounter;
  * @author Gruppe14
  *
  */
-public class CpsNode extends CpsObject {
-
+public class CpsNode extends AbstractCpsObject {
+	
 	/**
-	 * Create a new node in the system with an user-defined name
+	 * Create a new node in the system with an user-defined name.
 	 * 
 	 * @param objName
 	 *            String

+ 2 - 2
src/classes/HolonObject.java

@@ -15,7 +15,7 @@ import ui.model.idCounter;
  * @author Gruppe14
  *
  */
-public class HolonObject extends CpsObject {
+public class HolonObject extends AbstractCpsObject {
 	/*
 	 * Color of the actual state (red = no supplied, yellow = partially supplied
 	 * and green = supplied)
@@ -66,7 +66,7 @@ public class HolonObject extends CpsObject {
 	 * @param obj
 	 *            object to be copied
 	 */
-	public HolonObject(CpsObject obj) {
+	public HolonObject(AbstractCpsObject obj) {
 		super(obj);
 		setEleIdx(MultiPurposeController.copyHashMap(((HolonObject) obj).getEleIdx()));
 		setElements(copyElements(((HolonObject) obj).getElements()));

+ 11 - 10
src/classes/HolonSwitch.java

@@ -3,15 +3,16 @@ package classes;
 import java.awt.Point;
 import java.util.LinkedList;
 
-/**
- * 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 {
+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
+	 *
+	 */
 	/*
 	 * manual state True, if this wire is working (capable of carrying
 	 * electricity), else false
@@ -75,7 +76,7 @@ public class HolonSwitch extends CpsObject {
 	 * 
 	 * @param obj
 	 */
-	public HolonSwitch(CpsObject obj) {
+	public HolonSwitch(AbstractCpsObject obj) {
 		super(obj);
 		super.setName(obj.getName());
 		setManualState(true);

+ 2 - 2
src/classes/HolonTransformer.java

@@ -1,6 +1,6 @@
 package classes;
 
-public class HolonTransformer extends CpsObject {
+public class HolonTransformer extends AbstractCpsObject {
 
 	/* Ratio of the transformer */
 	float transformRatio;
@@ -25,7 +25,7 @@ public class HolonTransformer extends CpsObject {
 		super.setName(obj);
 	}
 
-	public HolonTransformer(CpsObject obj) {
+	public HolonTransformer(AbstractCpsObject obj) {
 		super(obj);
 		this.setTransformRatio(((HolonTransformer) obj).getTransformRatio());
 		this.setTransformFixed(((HolonTransformer) obj).getTransformFixed());

+ 2 - 2
src/tests/praktikumHolonsTestCanvasController.java

@@ -6,7 +6,7 @@ import org.junit.Before;
 import org.junit.Test;
 
 import classes.CpsEdge;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import ui.controller.CanvasController;
@@ -109,7 +109,7 @@ public class praktikumHolonsTestCanvasController {
 			HolonObject temp = new HolonObject(adapter.generate(i));
 			controller.addNewObject(new HolonObject(temp));
 			//connect current vertice with all other vertices
-			for (CpsObject cps : model.getObjectsOnCanvas()) {
+			for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 				if (!cps.equals(mp.searchByID(i)))
 					controller.addEdgeOnCanvas(new CpsEdge(mp.searchByID(i), cps));
 			}

+ 3 - 3
src/tests/praktikumHolonsTestLoadAndStoreController.java

@@ -13,7 +13,7 @@ import com.sun.security.auth.UnixNumericGroupPrincipal;
 
 import classes.Category;
 import classes.CpsEdge;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 
@@ -135,7 +135,7 @@ public class praktikumHolonsTestLoadAndStoreController {
 				h.setPosition(j * 50, i * 50);
 				cvs.addNewObject(h);
 				setGraphPoints(h);
-				for (CpsObject cps : model.getObjectsOnCanvas()) {
+				for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 					if (!cps.equals(h))
 						cvs.addEdgeOnCanvas(new CpsEdge(h, cps));
 				}
@@ -208,7 +208,7 @@ public class praktikumHolonsTestLoadAndStoreController {
 			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()) {
+			for (AbstractCpsObject obj : model.getObjectsOnCanvas()) {
 				assertTrue("Not instance of HolonObject", obj instanceof HolonObject);
 			}
 			

+ 4 - 4
src/tests/praktikumHolonsTestObjectController.java

@@ -7,7 +7,7 @@ import static org.junit.Assert.assertTrue;
 import org.junit.Before;
 import org.junit.Test;
 
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonObject;
 import ui.controller.CanvasController;
 import ui.controller.CategoryController;
@@ -94,7 +94,7 @@ public class praktikumHolonsTestObjectController {
 		for (int i = 0; i < 100; i++) {
 			cvs.addNewObject(new HolonObject(mp.searchCatObj(mp.searchCat("Building"), "House")));
 		}
-		for (CpsObject cps : model.getObjectsOnCanvas()) {
+		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 			for (int i = 0; i < 27; i++) {
 				controller.addNewElementIntoCanvasObject(cps.getID(), adapter.generate(i), 1, -100);
 				assertTrue("Element:" + adapter.generate(i) + " was not Created", mp
@@ -116,12 +116,12 @@ public class praktikumHolonsTestObjectController {
 					.searchEle((HolonObject) mp.searchByID(cps.getID()), "B") != null);	
 		}
 		
-		for (CpsObject cps : model.getObjectsOnCanvas()) {
+		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 			int size = model.getSelectedCpsObjects().size();
 			controller.addSelectedObject(cps);
 			assertTrue("Size does not Match", model.getSelectedCpsObjects().size() == size +1);
 		}
-		for (CpsObject cps : model.getObjectsOnCanvas()) {
+		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 			System.out.println(model.getSelectedCpsObjects().size());
 			int size = model.getSelectedCpsObjects().size();
 			controller.deleteSelectedObject(cps);

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

@@ -7,7 +7,7 @@ import Interfaces.CategoryListener;
 import Interfaces.ObjectListener;
 import classes.CpsEdge;
 import classes.CpsNode;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Position;
@@ -29,7 +29,7 @@ public class CanvasController {
 	 * @param object
 	 *            CpsObject to be added.
 	 */
-	public void addObject(CpsObject object) {
+	public void addObject(AbstractCpsObject object) {
 		MODEL.getCvsObjIdx().put(object.getID(), MODEL.getObjectsOnCanvas().size());
 		MODEL.getObjectsOnCanvas().add(object);
 		notifyObjListeners();
@@ -39,7 +39,7 @@ public class CanvasController {
 	 * 
 	 * @param object
 	 */
-	public void addNewObject(CpsObject object) {
+	public void addNewObject(AbstractCpsObject object) {
 		object.setSav("CVS");
 		object.setConnections(new ArrayList<CpsEdge>());
 		addObject(object);
@@ -61,11 +61,11 @@ public class CanvasController {
 	/**
 	 * Deletes an CpsObject on the Canvas and its connections
 	 * 
-	 * @param CpsObject
+	 * @param AbstractCpsObject
 	 */
-	public void deleteObjectOnCanvas(CpsObject obj) {
+	public void deleteObjectOnCanvas(AbstractCpsObject obj) {
 		CpsEdge e = null;
-		for (CpsObject cps : MODEL.getObjectsOnCanvas()) {
+		for (AbstractCpsObject cps : MODEL.getObjectsOnCanvas()) {
 			for (CpsEdge p : cps.getConnections()) {
 				if (p.getA() == obj || p.getB() == obj) {
 					e = p;
@@ -105,7 +105,7 @@ public class CanvasController {
 	 */
 	@SuppressWarnings("unchecked")
 	public void copyObjects() {
-		MODEL.setClipboradObjects((ArrayList<CpsObject>) MODEL.getSelectedCpsObjects().clone());
+		MODEL.setClipboradObjects((ArrayList<AbstractCpsObject>) MODEL.getSelectedCpsObjects().clone());
 	}
 
 	/**
@@ -117,11 +117,11 @@ public class CanvasController {
 	public void pasteObjects(Point p) {
 		System.out.println("paste");
 		MODEL.getSelectedCpsObjects().clear();
-		CpsObject tCps = null;
+		AbstractCpsObject tCps = null;
 		int x = Integer.MAX_VALUE, y = Integer.MAX_VALUE;
 
 		// Location whre to copy the Elements
-		for (CpsObject cps : MODEL.getClipboradObjects()) {
+		for (AbstractCpsObject cps : MODEL.getClipboradObjects()) {
 			if (cps.getPosition().x < x) {
 				x = cps.getPosition().x;
 			}
@@ -130,10 +130,10 @@ public class CanvasController {
 			}
 		}
 
-		ArrayList<CpsObject> tempList = new ArrayList<>();
+		ArrayList<AbstractCpsObject> tempList = new ArrayList<>();
 
 		// Objects
-		for (CpsObject cps : MODEL.getClipboradObjects()) {
+		for (AbstractCpsObject cps : MODEL.getClipboradObjects()) {
 			if (cps instanceof HolonObject) {
 				tCps = new HolonObject((HolonObject) cps);
 			} else if (cps instanceof HolonSwitch) {
@@ -149,14 +149,14 @@ public class CanvasController {
 
 		// Edges
 		boolean newEdge = true;
-		for (CpsObject cps : MODEL.getClipboradObjects()) {
+		for (AbstractCpsObject cps : MODEL.getClipboradObjects()) {
 			System.out.println("Object edges: " + cps.getConnectedTo().size());
 			for (CpsEdge e : cps.getConnectedTo()) {
 				// A and B of e in the copied Elements?
 				if (MODEL.getClipboradObjects().indexOf(e.getA()) != -1
 						&& MODEL.getClipboradObjects().indexOf(e.getB()) != -1) {
-					CpsObject A = tempList.get(MODEL.getClipboradObjects().indexOf(e.getA()));
-					CpsObject B = tempList.get(MODEL.getClipboradObjects().indexOf(e.getB()));
+					AbstractCpsObject A = tempList.get(MODEL.getClipboradObjects().indexOf(e.getA()));
+					AbstractCpsObject B = tempList.get(MODEL.getClipboradObjects().indexOf(e.getB()));
 					//was this Edge created or not?
 					for (CpsEdge et : tempList.get(MODEL.getClipboradObjects().indexOf(cps)).getConnectedTo()) {
 						for (CpsEdge etA : et.getA().getConnectedTo()) {
@@ -191,9 +191,9 @@ public class CanvasController {
 	 */
 	@SuppressWarnings("unchecked")
 	public void cutObjects() {
-		MODEL.setClipboradObjects((ArrayList<CpsObject>) MODEL.getSelectedCpsObjects().clone());
+		MODEL.setClipboradObjects((ArrayList<AbstractCpsObject>) MODEL.getSelectedCpsObjects().clone());
 		
-		for (CpsObject cps : MODEL.getClipboradObjects()) {
+		for (AbstractCpsObject cps : MODEL.getClipboradObjects()) {
 			deleteObjectOnCanvas(cps);
 		}
 

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

@@ -4,7 +4,7 @@ import java.util.ArrayList;
 
 import Interfaces.CategoryListener;
 import classes.Category;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
@@ -101,7 +101,7 @@ public class CategoryController {
 	 * @param object
 	 *            Object
 	 */
-	public void addObject(Category category, CpsObject object) {
+	public void addObject(Category category, AbstractCpsObject object) {
 		int i = 0;
 		while (mpC.searchCatObj(category, object.getObjName()) != null) {
 			if (object.getObjName().contains("_"))
@@ -163,7 +163,7 @@ public class CategoryController {
 		addObject(cat, holonSwitch);
 	}
 
-	public void removeObject(Category category, CpsObject cps) {
+	public void removeObject(Category category, AbstractCpsObject cps) {
 
 		mpC.decIdx(cps.getObjName(), category.getObjIdx());
 		category.getObjIdx().remove(cps.getObjName());

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

@@ -11,7 +11,7 @@ import Interfaces.CategoryListener;
 import classes.Category;
 import classes.CpsEdge;
 import classes.CpsNode;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.Position;
@@ -79,11 +79,11 @@ public class Control {
 
 	/* Operations for searching */
 
-	public CpsObject searchByID(int ID) {
+	public AbstractCpsObject searchByID(int ID) {
 		return multiPurposeController.searchByID(ID);
 	}
 
-	public CpsObject searchCategoryObject(String category, String object) {
+	public AbstractCpsObject searchCategoryObject(String category, String object) {
 		return multiPurposeController.searchCatObj(multiPurposeController.searchCat(category), object);
 	}
 
@@ -120,11 +120,11 @@ public class Control {
 		categoryController.deleteObject(cat, obj);
 	}
 
-	public void deleteSelectedObject(CpsObject obj) {
+	public void deleteSelectedObject(AbstractCpsObject obj) {
 		objectController.deleteSelectedObject(obj);
 	}
 
-	public void addSelectedObject(CpsObject obj) {
+	public void addSelectedObject(AbstractCpsObject obj) {
 		objectController.addSelectedObject(obj);
 	}
 
@@ -154,7 +154,7 @@ public class Control {
 		MODEL.setSelectedEdge(edge);
 	}
 
-	public void addObjectCanvas(CpsObject object) {
+	public void addObjectCanvas(AbstractCpsObject object) {
 		canvasController.addNewObject(object);
 		if (!(object instanceof CpsNode)) {
 			try {
@@ -170,7 +170,7 @@ public class Control {
 		objectController.setSelectedObjectID(id);
 	}
 
-	public void delCanvasObject(CpsObject obj) {
+	public void delCanvasObject(AbstractCpsObject obj) {
 		canvasController.deleteObjectOnCanvas(obj);
 		try {
 			autoSave();
@@ -197,7 +197,7 @@ public class Control {
 		objectController.deleteElement(obj, ele);
 	}
 
-	public void setClipboardObjects(ArrayList<CpsObject> list) {
+	public void setClipboardObjects(ArrayList<AbstractCpsObject> list) {
 		MODEL.setClipboradObjects(list);
 	}
 

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

@@ -16,7 +16,7 @@ import org.json.simple.parser.ParseException;
 import classes.Category;
 import classes.CpsEdge;
 import classes.CpsNode;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
@@ -75,7 +75,7 @@ public class LoadController {
 		}
 		if (mode.equals(MODE.ALL) || mode.equals(MODE.CANVAS)) {
 			MODEL.setCvsObjIdx(new HashMap<Integer, Integer>());
-			MODEL.setObjectsOnCanvas(new ArrayList<CpsObject>());
+			MODEL.setObjectsOnCanvas(new ArrayList<AbstractCpsObject>());
 			MODEL.setEdgesOnCanvas(new ArrayList<CpsEdge>());
 		}
 
@@ -172,7 +172,7 @@ public class LoadController {
 	 */
 	public void readCanvasObject(JSONArray arr) {
 		Iterator<Object> i = arr.iterator();
-		CpsObject cps = null;
+		AbstractCpsObject cps = null;
 
 		String type = next(i);
 

+ 5 - 5
src/ui/controller/MultiPurposeController.java

@@ -5,7 +5,7 @@ import java.util.Map.Entry;
 
 import classes.Category;
 import classes.CpsEdge;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import ui.model.Model;
@@ -42,7 +42,7 @@ public class MultiPurposeController {
 	 * @param list
 	 * @return
 	 */
-	public CpsObject searchCatObj(Category category, String object) {
+	public AbstractCpsObject searchCatObj(Category category, String object) {
 
 		Integer idx;
 
@@ -59,7 +59,7 @@ public class MultiPurposeController {
 	 * @param list
 	 * @return
 	 */
-	public CpsObject searchByID(int ID) {
+	public AbstractCpsObject searchByID(int ID) {
 
 		Integer idx;
 
@@ -92,8 +92,8 @@ public class MultiPurposeController {
 
 	public CpsEdge searchEdge(int a, int b) {
 
-		CpsObject A = searchByID(a);
-		CpsObject B = searchByID(b);
+		AbstractCpsObject A = searchByID(a);
+		AbstractCpsObject B = searchByID(b);
 
 		for (CpsEdge edge : MODEL.getEdgesOnCanvas()) {
 			// if (edge.getA().getObjName().equals(A.getObjName()) &&

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

@@ -3,7 +3,7 @@ package ui.controller;
 import java.util.ArrayList;
 
 import classes.Category;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import ui.model.Model;
@@ -113,7 +113,7 @@ public class ObjectController {
 	 * 
 	 * @param Cpsobject
 	 */
-	public void deleteSelectedObject(CpsObject obj) {
+	public void deleteSelectedObject(AbstractCpsObject obj) {
 		MODEL.getSelectedCpsObjects().remove(obj);
 	}
 
@@ -122,7 +122,7 @@ public class ObjectController {
 	 * 
 	 * @param Cpsobject
 	 */
-	public void addSelectedObject(CpsObject obj) {
+	public void addSelectedObject(AbstractCpsObject obj) {
 		MODEL.getSelectedCpsObjects().add(obj);
 	}
 
@@ -172,7 +172,7 @@ public class ObjectController {
 	 * @param ArrayList
 	 *            of CpsObjects
 	 */
-	public void setClipboardObjects(ArrayList<CpsObject> list) {
+	public void setClipboardObjects(ArrayList<AbstractCpsObject> list) {
 		MODEL.setClipboradObjects(list);
 	}
 }

+ 159 - 150
src/ui/controller/SimulationManager.java

@@ -5,7 +5,7 @@ import java.util.HashMap;
 
 import classes.CpsEdge;
 import classes.CpsNode;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
@@ -15,61 +15,62 @@ import ui.view.MyCanvas;
 
 public class SimulationManager {
 	private Model model;
-	private ArrayList<CpsObject> objectsToHandle;
+	private ArrayList<AbstractCpsObject> objectsToHandle;
 	private ArrayList<CpsEdge> allConnections;
 	private ArrayList<subNet> subNets;
 	private MyCanvas canvas;
 	private int timeStep;
 	private boolean simMode;
 	private HashMap<Integer, Float> tagTable = new HashMap<Integer, Float>();
-	
-	public SimulationManager(Model m){
+
+	public SimulationManager(Model m) {
 		canvas = null;
 		model = m;
 		subNets = new ArrayList<subNet>();
 		simMode = model.getIsSimulation();
 	}
-	
-	
+
 	/**
 	 * calculates the flow of the edges and the supply for objects
+	 * 
 	 * @param x
 	 */
-	public void calculateStateForTimeStep(int x){
+	public void calculateStateForTimeStep(int x) {
 		simMode = model.getIsSimulation();
 		timeStep = x;
 		searchForSubNets();
-		for(subNet singleSubNet: subNets){
+		for (subNet singleSubNet : subNets) {
 			ResetConnections(singleSubNet.getObjects().get(0), new ArrayList<Integer>(), new ArrayList<CpsEdge>());
 		}
-		for(subNet singleSubNet: subNets){
+		for (subNet singleSubNet : subNets) {
 			float production = calculateEnergy("prod", singleSubNet, timeStep);
 			float consumption = calculateEnergy("cons", singleSubNet, timeStep);
-			float minConsumption = calculateMinimumEnergy( singleSubNet, timeStep);
+			float minConsumption = calculateMinimumEnergy(singleSubNet, timeStep);
 			setFlow(singleSubNet, simMode);
-			for(HolonObject hl: singleSubNet.getObjects()){
-				if(!(hl.getState() == 0) && !(hl.getState() == 3)){
-					for(int i = 0; i < hl.getConnections().size(); i++){
+			for (HolonObject hl : singleSubNet.getObjects()) {
+				if (!(hl.getState() == 0) && !(hl.getState() == 3)) {
+					for (int i = 0; i < hl.getConnections().size(); i++) {
 						CpsEdge edge = hl.getConnectedTo().get(i);
-						if(edge.getState() && edge.getFlow() > 0 || edge.getCapacity() == -1){
-							// 0 = no energy, 1 = not supplied, 2 = supplied, 3 = producer, 4 = partially supplied
-							if((production + consumption) >= 0){
+						if (edge.getState() && edge.getFlow() > 0 || edge.getCapacity() == -1) {
+							// 0 = no energy, 1 = not supplied, 2 = supplied, 3
+							// = producer, 4 = partially supplied
+							if ((production + consumption) >= 0) {
 								hl.setState(2);
 							}
-							if((production + consumption) < 0 ){
-								if((production + minConsumption) >= 0){
+							if ((production + consumption) < 0) {
+								if ((production + minConsumption) >= 0) {
 									hl.setState(4);
-								}else if(hl.checkIfPartiallySupplied(timeStep)){
+								} else if (hl.checkIfPartiallySupplied(timeStep)) {
 									hl.setState(4);
-								}else {
+								} else {
 									hl.setState(1);
 								}
 							}
 							break;
 						}
-							hl.setState(1);
+						hl.setState(1);
 					}
-					if(hl.checkIfPartiallySupplied(timeStep) && !(hl.getState() == 2)){
+					if (hl.checkIfPartiallySupplied(timeStep) && !(hl.getState() == 2)) {
 						hl.setState(4);
 					}
 				}
@@ -77,50 +78,50 @@ public class SimulationManager {
 		}
 		canvas.repaint();
 	}
-	
-	public void setFlow(subNet sN, boolean simulation){
-		if(simulation){
+
+	public void setFlow(subNet sN, boolean simulation) {
+		if (simulation) {
 			setFlowSimulation(sN);
 		} else {
 			setFlowModelation(sN);
 		}
 	}
-	
-	public void setFlowModelation(subNet sN){
-		for(HolonObject hl: sN.getObjects()){
+
+	public void setFlowModelation(subNet sN) {
+		for (HolonObject hl : sN.getObjects()) {
 			float energy = hl.getCurrentEnergyAtTimeStep(timeStep);
-			if(energy > 0){
-				for(CpsEdge e : sN.getEdges()){
+			if (energy > 0) {
+				for (CpsEdge e : sN.getEdges()) {
 					e.setFlow(e.getFlow() + energy);
 					e.calculateState(simMode);
 				}
 			}
 		}
 	}
-	
-	public void setFlowSimulation(subNet sN){
-		ArrayList<CpsObject> producers = new ArrayList<CpsObject>();
-		CpsObject tmp = null;
+
+	public void setFlowSimulation(subNet sN) {
+		ArrayList<AbstractCpsObject> producers = new ArrayList<AbstractCpsObject>();
+		AbstractCpsObject tmp = null;
 		tagTable = new HashMap<Integer, Float>();
-		for(HolonObject hl: sN.getObjects()){
+		for (HolonObject hl : sN.getObjects()) {
 			float energy = hl.getCurrentEnergyAtTimeStep(timeStep);
-			if(energy > 0){
+			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()){
+				for (CpsEdge edge : hl.getConnections()) {
+					if (edge.getState()) {
+						if (edge.getA().getID() == hl.getID()) {
 							edge.getB().addTag(hl.getID());
 							tmp = edge.getB();
 						}
-						if(edge.getB().getID() == hl.getID()){
+						if (edge.getB().getID() == hl.getID()) {
 							edge.getA().addTag(hl.getID());
 							tmp = edge.getA();
 						}
 						edge.setFlow(edge.getFlow() + energy);
 						edge.calculateState(true);
 						edge.addTag(hl.getID());
-						if(edge.getState() && !producers.contains(tmp)){
+						if (edge.getState() && !producers.contains(tmp)) {
 							producers.add(tmp);
 						}
 					}
@@ -129,147 +130,151 @@ public class SimulationManager {
 		}
 		setFlowSimRec(producers, 0);
 	}
-	
-	public void setFlowSimRec(ArrayList<CpsObject> nodes, int iter){
-		ArrayList<CpsObject> newNodes = new ArrayList<CpsObject>();
+
+	public void setFlowSimRec(ArrayList<AbstractCpsObject> nodes, int iter) {
+		ArrayList<AbstractCpsObject> newNodes = new ArrayList<AbstractCpsObject>();
 		ArrayList<Integer> pseudoTags = new ArrayList<Integer>();
-		CpsObject tmp = null;
-		if(nodes.size() != 0){
-			for(CpsObject cps: nodes){
-				for(CpsEdge edge: cps.getConnections()){
-					for(Integer tag: cps.getTag()){
-						if(edge.getState() && !(edge.getTags().contains(tag))){
+		AbstractCpsObject tmp = null;
+		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));
 							edge.calculateState(true);
 							edge.addTag(tag);
-							if(edge.getA().getID() == cps.getID()){
+							if (edge.getA().getID() == cps.getID()) {
 								tmp = edge.getB();
 							}
-							if(edge.getB().getID() == cps.getID()){
+							if (edge.getB().getID() == cps.getID()) {
 								tmp = edge.getA();
 							}
-							if(tmp.getPseudoTags() != null){
+							if (tmp.getPseudoTags() != null) {
 								pseudoTags.addAll(tmp.getPseudoTags());
 							}
 							pseudoTags.addAll(cps.getTag());
 							tmp.setPseudoTags(mergeLists(tmp.getTag(), pseudoTags));
-							if(!edge.getState()){
+							if (!edge.getState()) {
 								newNodes.remove(edge.getA());
 								newNodes.remove(edge.getB());
-								if(edge.getA().getID() == cps.getID()){
+								if (edge.getA().getID() == cps.getID()) {
 									edge.getB().getPseudoTags().removeAll(edge.getTags());
 
 								}
-								if(edge.getB().getID() == cps.getID()){
+								if (edge.getB().getID() == cps.getID()) {
 									edge.getA().getPseudoTags().removeAll(edge.getTags());
 								}
 							}
-							if(edge.getState() && !(newNodes.contains(tmp))){
+							if (edge.getState() && !(newNodes.contains(tmp))) {
 								newNodes.add(tmp);
-							}	
+							}
 						}
 					}
-				edge.calculateState(true);
+					edge.calculateState(true);
 				}
 			}
-			//printNodes(newNodes);
+			// printNodes(newNodes);
 			setPseudoTags(newNodes);
 			setFlowSimRec(newNodes, iter + 1);
 		}
 	}
-	
-	public void setPseudoTags(ArrayList<CpsObject> nodes){
-		for(CpsObject node: nodes){
+
+	public void setPseudoTags(ArrayList<AbstractCpsObject> nodes) {
+		for (AbstractCpsObject node : nodes) {
 			node.setTags(node.getPseudoTags());
 		}
 	}
-	public void printNodes(ArrayList<CpsObject> nodes){
+
+	public void printNodes(ArrayList<AbstractCpsObject> nodes) {
 		System.out.println("new Nodes:");
-		for(CpsObject node: nodes){
+		for (AbstractCpsObject node : nodes) {
 			System.out.println(node.getID());
 		}
 	}
-	public String getString(ArrayList<Integer> tags){
+
+	public String getString(ArrayList<Integer> tags) {
 		String result = "";
-		for(Integer i: tags){
+		for (Integer i : tags) {
 			result = result + ", " + i;
 		}
 		return result;
 	}
-	
-	public ArrayList<Integer> mergeLists(ArrayList<Integer> A, ArrayList<Integer> B){
+
+	public ArrayList<Integer> mergeLists(ArrayList<Integer> A, ArrayList<Integer> B) {
 		ArrayList<Integer> result = new ArrayList<Integer>();
-		for(Integer i: A){
-			if(!(result.contains(i))){
+		for (Integer i : A) {
+			if (!(result.contains(i))) {
 				result.add(i);
 			}
 		}
-		for(Integer j: B){
-			if(!(result.contains(j))){
+		for (Integer j : B) {
+			if (!(result.contains(j))) {
 				result.add(j);
 			}
 		}
 		return result;
 	}
-	
-	public void ResetConnections(CpsObject cps, ArrayList<Integer> visitedObj, ArrayList<CpsEdge> visitedEdges){
+
+	public void ResetConnections(AbstractCpsObject cps, ArrayList<Integer> visitedObj,
+			ArrayList<CpsEdge> visitedEdges) {
 		visitedObj.add(cps.getID());
 		cps.resetTags();
-		for(CpsEdge e: cps.getConnections()){
-			if(!(visitedEdges.contains(e))){
+		for (CpsEdge e : cps.getConnections()) {
+			if (!(visitedEdges.contains(e))) {
 				e.setFlow(0);
 				e.calculateState(simMode);
 				e.setTags(new ArrayList<Integer>());
 				visitedEdges.add(e);
-				if(!(visitedObj.contains(e.getA().getID()))){
+				if (!(visitedObj.contains(e.getA().getID()))) {
 					ResetConnections(e.getA(), visitedObj, visitedEdges);
 					e.getA().resetTags();
 				}
-				if(!(visitedObj.contains(e.getB().getID()))){
+				if (!(visitedObj.contains(e.getB().getID()))) {
 					ResetConnections(e.getB(), visitedObj, visitedEdges);
 					e.getB().resetTags();
 				}
 			}
 		}
 	}
-	
+
 	/**
 	 * calculates the energy of either all producers or consumers
+	 * 
 	 * @param type
 	 * @param sN
 	 * @return
 	 */
-	public float calculateEnergy(String type, subNet sN, int x){
+	public float calculateEnergy(String type, subNet sN, int x) {
 		float energy = 0;
-		for(HolonObject hl: sN.getObjects()){
-			if(type.equals("prod")){
-				if(hl.getCurrentEnergyAtTimeStep(x) > 0){
+		for (HolonObject hl : sN.getObjects()) {
+			if (type.equals("prod")) {
+				if (hl.getCurrentEnergyAtTimeStep(x) > 0) {
 					energy = energy + hl.getCurrentEnergyAtTimeStep(x);
 					hl.setState(3);
 				}
 			}
-			if(type.equals("cons")){
-				if(hl.getCurrentEnergyAtTimeStep(x) < 0){
+			if (type.equals("cons")) {
+				if (hl.getCurrentEnergyAtTimeStep(x) < 0) {
 					energy = energy + hl.getCurrentEnergyAtTimeStep(x);
 					hl.setState(1);
 				}
 			}
-			if(hl.getCurrentEnergyAtTimeStep(x) == 0){
+			if (hl.getCurrentEnergyAtTimeStep(x) == 0) {
 				hl.setState(0);
 			}
 		}
 		return energy;
 	}
-	
-	public float calculateMinimumEnergy(subNet sN, int x){
+
+	public float calculateMinimumEnergy(subNet sN, int x) {
 		float min = 0;
 		float minElement = 0;
-		for(HolonObject hl: sN.getObjects()){
-			if(hl.getElements().size() > 0 && hl.getElements().get(0).getTotalEnergyAtTimeStep(x) < 0 ){
+		for (HolonObject hl : sN.getObjects()) {
+			if (hl.getElements().size() > 0 && hl.getElements().get(0).getTotalEnergyAtTimeStep(x) < 0) {
 				minElement = hl.getElements().get(0).getTotalEnergyAtTimeStep(x);
 			}
-			for(HolonElement he: hl.getElements()){
-				if(minElement < he.getTotalEnergyAtTimeStep(x) && he.getTotalEnergyAtTimeStep(x) < 0){
+			for (HolonElement he : hl.getElements()) {
+				if (minElement < he.getTotalEnergyAtTimeStep(x) && he.getTotalEnergyAtTimeStep(x) < 0) {
 					minElement = he.getTotalEnergyAtTimeStep(x);
 				}
 			}
@@ -277,152 +282,156 @@ public class SimulationManager {
 		}
 		return min;
 	}
-	
+
 	/**
 	 * generates all subNets from all objectsToHandle
 	 */
-	public void searchForSubNets(){
+	public void searchForSubNets() {
 		subNets = new ArrayList<subNet>();
 		boolean end = false;
 		int i = 0;
-		CpsObject cps;
-		if(objectsToHandle.size() > 0){
-			while(!end){
+		AbstractCpsObject cps;
+		if (objectsToHandle.size() > 0) {
+			while (!end) {
 				cps = objectsToHandle.get(i);
-				subNet singleSubNet = new subNet(new ArrayList<HolonObject>(), new ArrayList<CpsEdge>(), new ArrayList<HolonSwitch>());
+				subNet singleSubNet = new subNet(new ArrayList<HolonObject>(), new ArrayList<CpsEdge>(),
+						new ArrayList<HolonSwitch>());
 				singleSubNet = buildSubNet(cps, new ArrayList<Integer>(), singleSubNet);
-				if(singleSubNet.getObjects().size() != 0){
+				if (singleSubNet.getObjects().size() != 0) {
 					subNets.add(singleSubNet);
 				}
-				if(0 == objectsToHandle.size()){
+				if (0 == objectsToHandle.size()) {
 					end = true;
 				}
 			}
 		}
 	}
-	
+
 	/**
-	 * recursivly generates a subnet of all objects, that one specific object is connected to
+	 * recursivly generates a subnet of all objects, that one specific object is
+	 * connected to
+	 * 
 	 * @param cps
 	 * @param visited
 	 * @param sN
 	 * @return
 	 */
-	public subNet buildSubNet(CpsObject cps, ArrayList<Integer> visited, subNet sN){
+	public subNet buildSubNet(AbstractCpsObject cps, ArrayList<Integer> visited, subNet sN) {
 		visited.add(cps.getID());
-		if(cps instanceof HolonObject){
+		if (cps instanceof HolonObject) {
 			sN.getObjects().add((HolonObject) cps);
 		}
-		if(cps instanceof HolonSwitch){
+		if (cps instanceof HolonSwitch) {
 			sN.getSwitches().add((HolonSwitch) cps);
 		}
 		removeFromToHandle(cps.getID());
-		CpsObject A;
-		CpsObject B;
-		for(CpsEdge edge: cps.getConnections()){
+		AbstractCpsObject A;
+		AbstractCpsObject B;
+		for (CpsEdge edge : cps.getConnections()) {
 			A = edge.getA();
 			B = edge.getB();
-			if(!(cps instanceof HolonSwitch)){
-				if(!(sN.getEdges().contains(edge))){
+			if (!(cps instanceof HolonSwitch)) {
+				if (!(sN.getEdges().contains(edge))) {
 					sN.getEdges().add(edge);
 				}
 			}
-			if(!visited.contains(A.getID()) && legitState(A, cps)){
-					sN = buildSubNet(A, visited, sN);
+			if (!visited.contains(A.getID()) && legitState(A, cps)) {
+				sN = buildSubNet(A, visited, sN);
 			}
-			if(!visited.contains(B.getID()) && legitState(B, cps)){
-					sN = buildSubNet(B, visited, sN);
+			if (!visited.contains(B.getID()) && legitState(B, cps)) {
+				sN = buildSubNet(B, visited, sN);
 			}
 		}
 		return sN;
 	}
-	
-	public boolean legitState(CpsObject neighbor, CpsObject current){
-		if(current instanceof HolonSwitch){
-			if(((HolonSwitch) current).getState(timeStep)){
-				if(neighbor instanceof HolonSwitch){
-					if(((HolonSwitch) neighbor).getState(timeStep)){
+
+	public boolean legitState(AbstractCpsObject neighbor, AbstractCpsObject current) {
+		if (current instanceof HolonSwitch) {
+			if (((HolonSwitch) current).getState(timeStep)) {
+				if (neighbor instanceof HolonSwitch) {
+					if (((HolonSwitch) neighbor).getState(timeStep)) {
 						return true;
-					}else{
+					} else {
 						return false;
-						}
+					}
 				}
-			}else{
+			} else {
 				return false;
 			}
 		}
 		return true;
 	}
-	
+
 	/**
 	 * removes an Object that already has been handled with
+	 * 
 	 * @param id
 	 */
-	public void removeFromToHandle(int id){
-		for(int i = 0; i < objectsToHandle.size(); i++){
-			if(objectsToHandle.get(i).getID() == id){
+	public void removeFromToHandle(int id) {
+		for (int i = 0; i < objectsToHandle.size(); i++) {
+			if (objectsToHandle.get(i).getID() == id) {
 				objectsToHandle.remove(i);
 			}
 		}
 	}
-	
+
 	/**
 	 * ensures that objectsToHandle only contains HolonObjects
 	 */
-	public void cleanObjectsToHandle(){
-		for(int i = 0; i < objectsToHandle.size(); i++){
-			if(!(objectsToHandle.get(i) instanceof HolonObject)){
+	public void cleanObjectsToHandle() {
+		for (int i = 0; i < objectsToHandle.size(); i++) {
+			if (!(objectsToHandle.get(i) instanceof HolonObject)) {
 				objectsToHandle.remove(i);
 			}
 		}
 	}
-	
+
 	/**
 	 * copies the data of an array of Objects
+	 * 
 	 * @param toCopy
 	 */
-	public void copyObjects(ArrayList<CpsObject> toCopy){
-		objectsToHandle = new ArrayList<CpsObject>();
-		for(CpsObject cps: toCopy){
+	public void copyObjects(ArrayList<AbstractCpsObject> toCopy) {
+		objectsToHandle = new ArrayList<AbstractCpsObject>();
+		for (AbstractCpsObject cps : toCopy) {
 			objectsToHandle.add(cps);
 		}
 	}
-	
+
 	/**
 	 * Prints the Components auf all subnets
 	 */
-	public void printNet(){
-		for(int i = 0; i < subNets.size(); i++){
+	public void printNet() {
+		for (int i = 0; i < subNets.size(); i++) {
 			System.out.println("SUBNET NR:" + i);
 			System.out.println("  Objects:");
-			for(int j = 0; j < subNets.get(i).getObjects().size(); j++){
+			for (int j = 0; j < subNets.get(i).getObjects().size(); j++) {
 				HolonObject hl = subNets.get(i).getObjects().get(j);
 				System.out.println("    " + hl.getName() + " " + hl.getID());
 			}
 			System.out.println("  Edges:");
-			for(int j = 0; j < subNets.get(i).getEdges().size(); j++){
+			for (int j = 0; j < subNets.get(i).getEdges().size(); j++) {
 				CpsEdge edge = subNets.get(i).getEdges().get(j);
 				System.out.println("     " + edge.getA().getName() + " connected To " + edge.getB().getName());
 			}
 			System.out.println("  Switches:");
-			for(int j = 0; j < subNets.get(i).getSwitches().size(); j++){
+			for (int j = 0; j < subNets.get(i).getSwitches().size(); j++) {
 				HolonSwitch sw = subNets.get(i).getSwitches().get(j);
 				System.out.println("    " + sw.getName() + " " + sw.getID() + " State:" + sw.getActiveAt()[timeStep]);
 			}
 		}
 	}
-	
-	public void setCanvas(MyCanvas can){
+
+	public void setCanvas(MyCanvas can) {
 		canvas = can;
 	}
-	
-	public void reset(){
+
+	public void reset() {
 		copyObjects(model.getObjectsOnCanvas());
 	}
-	
-	public ArrayList<subNet> getSubNets(){
+
+	public ArrayList<subNet> getSubNets() {
 		return subNets;
 	}
-	
-	
+
 }

+ 8 - 8
src/ui/controller/StoreController.java

@@ -10,7 +10,7 @@ import org.json.simple.JSONObject;
 
 import classes.Category;
 import classes.CpsEdge;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
@@ -118,7 +118,7 @@ public class StoreController {
 		int i = 1;
 
 		for (Category cats : MODEL.getCategories())
-			for (CpsObject cps : cats.getObjects()) {
+			for (AbstractCpsObject cps : cats.getObjects()) {
 				arr.add(getObjectType(cps));
 				arr.add(cps.getSav());
 				arr.add(cps.getObjName());
@@ -132,7 +132,7 @@ public class StoreController {
 
 		JSONArray arr = new JSONArray();
 		int i = 1;
-		for (CpsObject cps : MODEL.getObjectsOnCanvas()) {
+		for (AbstractCpsObject cps : MODEL.getObjectsOnCanvas()) {
 			arr.add(getObjectType(cps));
 			arr.add(cps.getObjName());
 			arr.add(cps.getName());
@@ -156,7 +156,7 @@ public class StoreController {
 		int i = 1;
 
 		for (Category cats : MODEL.getCategories())
-			for (CpsObject cps : cats.getObjects())
+			for (AbstractCpsObject cps : cats.getObjects())
 				if (cps instanceof HolonObject)
 					for (HolonElement ele : ((HolonObject) cps).getElements()) {
 						arr.add(ele.getSav());
@@ -175,7 +175,7 @@ public class StoreController {
 		
 		JSONArray arr = new JSONArray();
 		int i = 1;
-		for (CpsObject cps : MODEL.getObjectsOnCanvas()) {
+		for (AbstractCpsObject cps : MODEL.getObjectsOnCanvas()) {
 			if (cps instanceof HolonObject)
 				for (HolonElement ele : ((HolonObject) cps).getElements()) {
 					arr.add(ele.getSav());
@@ -222,7 +222,7 @@ public class StoreController {
 		int i = 1;
 
 		for (Category cats : MODEL.getCategories())
-			for (CpsObject cps : cats.getObjects())
+			for (AbstractCpsObject cps : cats.getObjects())
 				if (cps instanceof HolonObject)
 					for (HolonElement ele : ((HolonObject) cps).getElements())
 						if (!ele.getGraphPoints().isEmpty()) {
@@ -241,7 +241,7 @@ public class StoreController {
 							arr = new JSONArray();
 						}
 		i = 1;
-		for (CpsObject cps : MODEL.getObjectsOnCanvas()) {
+		for (AbstractCpsObject cps : MODEL.getObjectsOnCanvas()) {
 			if (cps instanceof HolonObject)
 				for (HolonElement ele : ((HolonObject) cps).getElements())
 					if (!ele.getGraphPoints().isEmpty()) {
@@ -268,7 +268,7 @@ public class StoreController {
 	 * @param cps
 	 * @return
 	 */
-	public String getObjectType(CpsObject cps) {
+	public String getObjectType(AbstractCpsObject cps) {
 		if (cps instanceof HolonObject)
 			return "HolonObject";
 		if (cps instanceof HolonTransformer)

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

@@ -10,7 +10,7 @@ import java.util.List;
 
 import classes.Category;
 import classes.CpsEdge;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import ui.controller.*;
 import ui.view.Console;
@@ -23,11 +23,11 @@ public class Model {
 	private static final int ITERATIONS = 100;
 	private int CUR_ITERATION = 0;
 	// ID of the Selected Object
-	private CpsObject selectedCpsObject = null;
+	private AbstractCpsObject selectedCpsObject = null;
 	private HolonElement selectedHolonElement;
 	private CpsEdge selectedEdge;
-	private ArrayList<CpsObject> selectedObjects = new ArrayList<CpsObject>();
-	private ArrayList<CpsObject> clipboardObjects = new ArrayList<CpsObject>();
+	private ArrayList<AbstractCpsObject> selectedObjects = new ArrayList<AbstractCpsObject>();
+	private ArrayList<AbstractCpsObject> clipboardObjects = new ArrayList<AbstractCpsObject>();
 	private Console console;
 
 	// Iteration Speed
@@ -54,7 +54,7 @@ public class Model {
 	 * Array of all CpsObjects in our canvas. It is set by default as an empty
 	 * list.
 	 */
-	private ArrayList<CpsObject> objectsOnCanvas;
+	private ArrayList<AbstractCpsObject> objectsOnCanvas;
 
 	private HashMap<String, Integer> cgIdx;
 	private HashMap<Integer, Integer> cvsObjIdx;
@@ -78,13 +78,13 @@ public class Model {
 	 */
 	public Model() {
 		setCategories(new ArrayList<Category>());
-		setObjectsOnCanvas(new ArrayList<CpsObject>());
+		setObjectsOnCanvas(new ArrayList<AbstractCpsObject>());
 		setEdgesOnCanvas(new ArrayList<CpsEdge>());
 		setCategoryListeners(new LinkedList<CategoryListener>());
 		setObjectListeners(new LinkedList<ObjectListener>());
 		setCgIdx(new HashMap<String, Integer>());
 		setCvsObjIdx(new HashMap<Integer, Integer>());
-		setClipboradObjects(new ArrayList<CpsObject>());
+		setClipboradObjects(new ArrayList<AbstractCpsObject>());
 	}
 
 	/**
@@ -123,7 +123,7 @@ public class Model {
 	/**
 	 * @return the objectsOnCanvas
 	 */
-	public ArrayList<CpsObject> getObjectsOnCanvas() {
+	public ArrayList<AbstractCpsObject> getObjectsOnCanvas() {
 		return objectsOnCanvas;
 	}
 
@@ -131,7 +131,7 @@ public class Model {
 	 * @param objectsOnCanvas
 	 *            the objectsOnCanvas to set
 	 */
-	public void setObjectsOnCanvas(ArrayList<CpsObject> objectsOnCanvas) {
+	public void setObjectsOnCanvas(ArrayList<AbstractCpsObject> objectsOnCanvas) {
 		this.objectsOnCanvas = objectsOnCanvas;
 	}
 
@@ -215,15 +215,15 @@ public class Model {
 		return selectedID;
 	}
 
-	public CpsObject getSelectedCpsObject() {
+	public AbstractCpsObject getSelectedCpsObject() {
 		return selectedCpsObject;
 	}
 
-	public void setSelectedCpsObject(CpsObject selectedCpsObject) {
+	public void setSelectedCpsObject(AbstractCpsObject selectedCpsObject) {
 		this.selectedCpsObject = selectedCpsObject;
 	}
 
-	public ArrayList<CpsObject> getSelectedCpsObjects() {
+	public ArrayList<AbstractCpsObject> getSelectedCpsObjects() {
 		return selectedObjects;
 	}
 
@@ -362,7 +362,7 @@ public class Model {
 	 * @param Objects
 	 *            Array of Objects
 	 */
-	public void setClipboradObjects(ArrayList<CpsObject> c) {
+	public void setClipboradObjects(ArrayList<AbstractCpsObject> c) {
 		this.clipboardObjects = c;
 	}
 
@@ -370,7 +370,7 @@ public class Model {
 	 * 
 	 * @return Objects in the Clipboard
 	 */
-	public ArrayList<CpsObject> getClipboradObjects() {
+	public ArrayList<AbstractCpsObject> getClipboradObjects() {
 		return clipboardObjects;
 	}
 

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

@@ -18,7 +18,7 @@ import javax.swing.JComboBox;
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.ImageIcon;
 
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import ui.model.Model;
@@ -35,7 +35,7 @@ public class AddElementPopUp extends JDialog {
 	private JTextField providedEnergy;
 	private JTextField amount;
 	private HolonElement hl;
-	private CpsObject tempCps;
+	private AbstractCpsObject tempCps;
 
 	/**
 	 * Launch the application.
@@ -172,7 +172,7 @@ public class AddElementPopUp extends JDialog {
 
 	}
 
-	public void setActualCps(CpsObject cps) {
+	public void setActualCps(AbstractCpsObject cps) {
 		this.tempCps = cps;
 	}
 

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

@@ -35,7 +35,7 @@ import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 import javax.swing.filechooser.FileNameExtensionFilter;
 
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import ui.controller.Control;
@@ -56,7 +56,7 @@ public class AddObjectPopUp extends JDialog {
 	private String filePath = " ";
 	private String givenCategory;
 	private JLabel lblImagePreview;
-	private CpsObject toEdit;
+	private AbstractCpsObject toEdit;
 	private boolean editState;
 	private boolean imageChanged = false;
 
@@ -76,7 +76,7 @@ public class AddObjectPopUp extends JDialog {
 	/**
 	 * Create the dialog.
 	 */
-	public AddObjectPopUp(boolean edit, CpsObject obj, String cat) {
+	public AddObjectPopUp(boolean edit, AbstractCpsObject obj, String cat) {
 		toEdit = obj;
 		editState = edit;
 		this.setIconImage(new ImageIcon(this.getClass().getResource("/Images/Dummy_House.png")).getImage()

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

@@ -63,7 +63,7 @@ import javax.swing.tree.TreeCellRenderer;
 import Interfaces.CategoryListener;
 import classes.Category;
 import classes.CpsEdge;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
@@ -195,7 +195,7 @@ public class GUI<E> implements CategoryListener {
 	private boolean dragging = false;
 	private String actualObjectClicked;
 	private Image img = null;
-	private CpsObject tempCps = null;
+	private AbstractCpsObject tempCps = null;
 	private int yValueElements = 0;
 
 	private Console console = new Console();
@@ -215,7 +215,7 @@ public class GUI<E> implements CategoryListener {
 	// Coord for the Edit-Modus in the PropertieTable
 	private int yProThis;
 	private int xProThis;
-	private CpsObject temp = null;
+	private AbstractCpsObject temp = null;
 	private final JButton btnTest = new JButton("test");
 	private final JMenuItem mntmUndo = new JMenuItem("Undo");
 	private final JMenuItem mntmRedo = new JMenuItem("Redo");
@@ -283,7 +283,7 @@ public class GUI<E> implements CategoryListener {
 					controller.loadFile(controller.getUndoSave());
 					canvas.repaint();
 					ArrayList<HolonElement> tempList = new ArrayList<>();
-					for (CpsObject cps : model.getObjectsOnCanvas()) {
+					for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 						if (cps instanceof HolonObject) {
 							for (HolonElement h : ((HolonObject) cps).getElements()) {
 								tempList.add(h);
@@ -320,7 +320,7 @@ public class GUI<E> implements CategoryListener {
 					controller.loadFile(controller.getRedoSave());
 					canvas.repaint();
 					ArrayList<HolonElement> tempList = new ArrayList<>();
-					for (CpsObject cps : model.getObjectsOnCanvas()) {
+					for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 						if (cps instanceof HolonObject) {
 							for (HolonElement h : ((HolonObject) cps).getElements()) {
 								tempList.add(h);
@@ -353,7 +353,7 @@ public class GUI<E> implements CategoryListener {
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				model.getSelectedCpsObjects().clear();
-				for (CpsObject cps : model.getObjectsOnCanvas()) {
+				for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 					controller.addSelectedObject(cps);
 				}
 				canvas.repaint();
@@ -370,7 +370,7 @@ public class GUI<E> implements CategoryListener {
 
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				for (CpsObject cps : model.getSelectedCpsObjects()) {
+				for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
 					controller.delCanvasObject(cps);
 				}
 				model.getSelectedCpsObjects().clear();
@@ -636,7 +636,7 @@ public class GUI<E> implements CategoryListener {
 		btnAddHolEL.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent arg0) {
 				if (model.getSelectedCpsObjects().size() == 1) {
-					CpsObject tempCpsObject = getActualCps();
+					AbstractCpsObject tempCpsObject = getActualCps();
 					if (tempCpsObject != null && tempCpsObject.getClass() == HolonObject.class
 							&& tempCpsObject.getID() != 0) {
 						addElementPopUp = new AddElementPopUp();
@@ -936,7 +936,7 @@ public class GUI<E> implements CategoryListener {
 				Image imgR = null;
 				if (leaf) {
 					for (Category cat : model.getCategories()) {
-						for (CpsObject cps : cat.getObjects()) {
+						for (AbstractCpsObject cps : cat.getObjects()) {
 							if (value.toString().compareTo(cps.getObjName()) == 0) {
 								File checkPath = new File(cps.getImage());
 								if (checkPath.exists()) {
@@ -979,7 +979,7 @@ public class GUI<E> implements CategoryListener {
 					if (dragging) {
 						int x = (int) canvas.getMousePosition().getX();
 						int y = (int) canvas.getMousePosition().getY();
-						CpsObject h = null;
+						AbstractCpsObject h = null;
 						if (tempCps.getClass() == HolonObject.class) {
 							h = new HolonObject(tempCps);
 						}
@@ -1029,7 +1029,7 @@ public class GUI<E> implements CategoryListener {
 					}
 					if (SwingUtilities.isRightMouseButton(e)) {
 						for (Category cat : model.getCategories()) {
-							for (CpsObject cps : cat.getObjects()) {
+							for (AbstractCpsObject cps : cat.getObjects()) {
 								if (actualObjectClicked.compareTo(cps.getObjName()) == 0
 										&& !(cps instanceof HolonSwitch)) {
 									editItem.setEnabled(true);
@@ -1041,7 +1041,7 @@ public class GUI<E> implements CategoryListener {
 						}
 					} else {
 						for (Category cat : model.getCategories()) {
-							for (CpsObject cps : cat.getObjects()) {
+							for (AbstractCpsObject cps : cat.getObjects()) {
 								if (actualObjectClicked.compareTo(cps.getObjName()) == 0) {
 									File checkPath = new File(cps.getImage());
 									if (checkPath.exists()) {
@@ -1106,7 +1106,7 @@ public class GUI<E> implements CategoryListener {
 									"Please select a Category first before adding " + selectedOption + ".");
 						}
 						if (selectedNode.getLevel() == 1) {
-							CpsObject tmp = new HolonObject("");
+							AbstractCpsObject tmp = new HolonObject("");
 							addObjectPopUP = new AddObjectPopUp(false, tmp, null);
 							addObjectPopUP.setVisible(true);
 							addObjectPopUP.setController(controller);
@@ -1364,7 +1364,7 @@ public class GUI<E> implements CategoryListener {
 						controller.loadFile(file.getAbsolutePath());
 						canvas.repaint();
 						ArrayList<HolonElement> tempList = new ArrayList<>();
-						for (CpsObject cps : model.getObjectsOnCanvas()) {
+						for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 							if (cps instanceof HolonObject) {
 								for (HolonElement h : ((HolonObject) cps).getElements()) {
 									tempList.add(h);
@@ -1429,7 +1429,7 @@ public class GUI<E> implements CategoryListener {
 					controller.loadFile(controller.getUndoSave());
 					canvas.repaint();
 					ArrayList<HolonElement> tempList = new ArrayList<>();
-					for (CpsObject cps : model.getObjectsOnCanvas()) {
+					for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 						if (cps instanceof HolonObject) {
 							for (HolonElement h : ((HolonObject) cps).getElements()) {
 								tempList.add(h);
@@ -1465,7 +1465,7 @@ public class GUI<E> implements CategoryListener {
 					controller.loadFile(controller.getRedoSave());
 					canvas.repaint();
 					ArrayList<HolonElement> tempList = new ArrayList<>();
-					for (CpsObject cps : model.getObjectsOnCanvas()) {
+					for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 						if (cps instanceof HolonObject) {
 							for (HolonElement h : ((HolonObject) cps).getElements()) {
 								tempList.add(h);
@@ -1581,7 +1581,7 @@ public class GUI<E> implements CategoryListener {
 					node_1 = new DefaultMutableTreeNode(c.getName());
 
 					// kann eventuell umgeändert werden
-					for (CpsObject obj : c.getObjects()) {
+					for (AbstractCpsObject obj : c.getObjects()) {
 						node_1.add(new DefaultMutableTreeNode(obj.getObjName()));
 					}
 					add(node_1);
@@ -1613,9 +1613,9 @@ public class GUI<E> implements CategoryListener {
 	 * 
 	 * @return selected CpsObject
 	 */
-	private CpsObject getActualCps() {
+	private AbstractCpsObject getActualCps() {
 		int tempID = model.getSelectedObjectID();
-		CpsObject tempCps = controller.searchByID(tempID);
+		AbstractCpsObject tempCps = controller.searchByID(tempID);
 		return tempCps;
 	}
 
@@ -1738,9 +1738,9 @@ public class GUI<E> implements CategoryListener {
 	 * @param elements
 	 *            ArrayList to be displayed
 	 */
-	private void fillElementTable(ArrayList<CpsObject> objects) {
+	private void fillElementTable(ArrayList<AbstractCpsObject> objects) {
 		if (objects.size() > 1) {
-			for (CpsObject o : objects) {
+			for (AbstractCpsObject o : objects) {
 				if (o instanceof HolonObject) {
 					for (HolonElement he : ((HolonObject) o).getElements()) {
 						Object[] temp = { o.getName() + ", " + o.getID(), he.getId(), he.getEleName(), he.getEnergy(),
@@ -1750,7 +1750,7 @@ public class GUI<E> implements CategoryListener {
 				}
 			}
 		} else if (objects.size() == 1) {
-			CpsObject o = objects.get(0);
+			AbstractCpsObject o = objects.get(0);
 			if (o instanceof HolonObject) {
 				for (HolonElement he : ((HolonObject) o).getElements()) {
 					Object[] temp = { he.getId(), he.getEleName(), he.getEnergy(), he.getAmount(), he.getActive() };
@@ -1765,7 +1765,7 @@ public class GUI<E> implements CategoryListener {
 	 */
 	private void refreshTableProperties() {
 		if (model.getSelectedCpsObjects().size() == 1) {
-			CpsObject tempCps = getActualCps();
+			AbstractCpsObject tempCps = getActualCps();
 			if (tempCps != null && tempCps.getClass() == HolonObject.class) {
 				tableModelProperties.removeRow(2);
 				Object[] tempEnergy = { "Total Energy", ((HolonObject) tempCps).getCurrentEnergy() };

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

@@ -27,7 +27,7 @@ import javax.swing.JToolTip;
 
 import classes.CpsEdge;
 import classes.CpsNode;
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import classes.HolonSwitch;
@@ -51,7 +51,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	private float scalediv20;
 
 	ArrayList<HolonElement> dataSelected = new ArrayList<HolonElement>();
-	ArrayList<CpsObject> TempSelected = new ArrayList<CpsObject>();
+	ArrayList<AbstractCpsObject> TempSelected = new ArrayList<AbstractCpsObject>();
 
 	private boolean[] showedInformation = new boolean[3];
 	private boolean dragging = false; // for dragging
@@ -59,7 +59,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 	private boolean drawEdge = false; // for drawing edges
 	private boolean click = false; // for double click
 	private boolean doMark = false; // for double click
-	public CpsObject tempCps = null;
+	public AbstractCpsObject tempCps = null;
 	private Rectangle selectRect = new Rectangle();
 	private CpsEdge edgeHighlight = null;
 
@@ -102,7 +102,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				// Remove the selected Object objects
-				for (CpsObject cps : model.getSelectedCpsObjects()) {
+				for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
 					controller.delCanvasObject(cps);
 				}
 				model.getSelectedCpsObjects().clear();
@@ -254,7 +254,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		}
 
 		// Objects
-		for (CpsObject cps : model.getObjectsOnCanvas()) {
+		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 			// Border Highlighting
 			g2.setColor(cps.getBorderColor());
 			if (g2.getColor() != Color.WHITE) {
@@ -348,7 +348,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		edgeHighlight = null;
 		controller.setSelecteEdge(null);
 		// Object Selection
-		for (CpsObject cps : model.getObjectsOnCanvas()) {
+		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 			cx = cps.getPosition().x;
 			cy = cps.getPosition().y;
 			if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
@@ -424,7 +424,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 
 		if (doMark) {
 			doMark = false;
-			for (CpsObject cps : TempSelected) {
+			for (AbstractCpsObject cps : TempSelected) {
 				if (!model.getSelectedCpsObjects().contains(cps)) {
 					controller.addSelectedObject(cps);
 				}
@@ -482,7 +482,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 				objectTT.setLocation(x, y + controller.getScale());
 
 				// All Selected Objects
-				for (CpsObject cps : model.getSelectedCpsObjects()) {
+				for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
 					if (cps != tempCps) {
 						x = (int) (cps.getPosition().x + xDist);
 						y = (int) (cps.getPosition().y + yDist);
@@ -509,7 +509,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		// Mark Objects
 		if (doMark) {
 			TempSelected.clear();
-			for (CpsObject cps : model.getObjectsOnCanvas()) {
+			for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 				int x1 = sx, x2 = x, y1 = sy, y2 = y;
 
 				if (sx >= x) {
@@ -539,7 +539,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		y = e.getY();
 		// Everytghing for the tooltip :)
 		boolean on = false;
-		for (CpsObject cps : model.getObjectsOnCanvas()) {
+		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 
 			cx = cps.getPosition().x;
 			cy = cps.getPosition().y;
@@ -582,9 +582,9 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 		boolean onEdge = true;
 		boolean deleteNode = false;
 		CpsEdge e = null;
-		CpsObject tempCPS = null;
+		AbstractCpsObject tempCPS = null;
 
-		for (CpsObject cps : model.getObjectsOnCanvas()) {
+		for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
 			cx = cps.getPosition().x;
 			cy = cps.getPosition().y;
 			if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy
@@ -629,7 +629,7 @@ public class MyCanvas extends JPanel implements MouseListener, MouseMotionListen
 				n.setPosition(x - model.getScaleDiv2(), y - model.getScaleDiv2());
 				controller.addObjectCanvas(n);
 
-				CpsObject r, k;
+				AbstractCpsObject r, k;
 				r = p.getA();
 				k = p.getB();
 

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

@@ -16,7 +16,7 @@ import javax.swing.event.ChangeListener;
 
 import com.sun.crypto.provider.JceKeyStore;
 
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.HolonTransformer;

+ 7 - 7
src/ui/view/searchPopUp.java

@@ -6,7 +6,7 @@ import javax.swing.JDialog;
 import javax.swing.JPanel;
 import javax.swing.border.EmptyBorder;
 
-import classes.CpsObject;
+import classes.AbstractCpsObject;
 
 import javax.swing.JLabel;
 
@@ -109,7 +109,7 @@ public class searchPopUp extends JDialog {
 		btnFind.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 				if (rdbtnAll.isSelected()) {
-					for (CpsObject cps : controller.getModel().getObjectsOnCanvas()) {
+					for (AbstractCpsObject cps : controller.getModel().getObjectsOnCanvas()) {
 
 						if (cps.getName().equals(findTextField.getText())
 								&& !controller.getModel().getSelectedCpsObjects().contains(cps)) {
@@ -165,13 +165,13 @@ public class searchPopUp extends JDialog {
 				canvas.TempSelected = new ArrayList<>();
 				controller.getModel().getSelectedCpsObjects().clear();
 
-				for (CpsObject cps : controller.getModel().getObjectsOnCanvas()) {
+				for (AbstractCpsObject cps : controller.getModel().getObjectsOnCanvas()) {
 					if (cps.getName().equals(findTextField.getText())
 							&& !controller.getModel().getSelectedCpsObjects().contains(cps))
 						selectObj(cps);
 				}
 
-				for (CpsObject cps : controller.getModel().getSelectedCpsObjects()) {
+				for (AbstractCpsObject cps : controller.getModel().getSelectedCpsObjects()) {
 					renameObj(cps, replaceTextField.getText());
 				}
 
@@ -207,7 +207,7 @@ public class searchPopUp extends JDialog {
 	 * 
 	 * @param obj
 	 */
-	public void selectObj(CpsObject obj) {
+	public void selectObj(AbstractCpsObject obj) {
 		controller.getModel().getSelectedCpsObjects().add(obj);
 	}
 
@@ -216,7 +216,7 @@ public class searchPopUp extends JDialog {
 	 * @param obj
 	 * @param name
 	 */
-	public void renameObj(CpsObject obj, String name) {
+	public void renameObj(AbstractCpsObject obj, String name) {
 		obj.setName(name);
 	}
 
@@ -225,7 +225,7 @@ public class searchPopUp extends JDialog {
 	 * @param idx
 	 * @return
 	 */
-	public CpsObject getObj(int idx) {
+	public AbstractCpsObject getObj(int idx) {
 		return controller.getModel().getObjectsOnCanvas().get(idx);
 	}