Browse Source

Adds Inspector

- Removes Amount in HolonElement
- Fixes Todos and Warning
- Removes SplitPane
- Fix GroupNodeSelection
- Adds TrippleStateCheckBox
TomTroppmann 3 years ago
parent
commit
001edac4ea
56 changed files with 2174 additions and 3177 deletions
  1. 3 3
      .gitignore
  2. 0 1
      src/Connection/ConnectHandheld.java
  3. 12 16
      src/Connection/socket/Server.java
  4. 2 4
      src/addOns/Utility/HolonElementSketch.java
  5. 1 1
      src/algorithm/example/FlexExample.java
  6. 0 1
      src/algorithm/objectiveFunction/Evaluation.java
  7. 1 1
      src/algorithm/objectiveFunction/TopologieObjectiveFunction.java
  8. 1 22
      src/classes/AbstractCanvasObject.java
  9. 2 2
      src/classes/Flexibility.java
  10. 0 20
      src/classes/GroupNode.java
  11. 0 172
      src/classes/HolonBody.java
  12. 14 65
      src/classes/HolonElement.java
  13. 15 89
      src/classes/HolonObject.java
  14. 0 4
      src/classes/HolonSwitch.java
  15. 1 5
      src/classes/Node.java
  16. 2 2
      src/classes/comparator/elementComparator/ElemCompOnEnergy.java
  17. 0 18
      src/classes/comparator/elementComparator/ElemCompOnObj.java
  18. 0 20
      src/classes/comparator/elementComparator/ElemCompOnQuantity.java
  19. 26 18
      src/ui/controller/CanvasController.java
  20. 8 9
      src/ui/controller/CategoryController.java
  21. 10 9
      src/ui/controller/ClipboardController.java
  22. 763 807
      src/ui/controller/Control.java
  23. 0 236
      src/ui/controller/HolonCanvasController.java
  24. 24 33
      src/ui/controller/LoadController.java
  25. 6 9
      src/ui/controller/NodeController.java
  26. 188 187
      src/ui/controller/ObjectController.java
  27. 2 1
      src/ui/controller/SimulationManager.java
  28. 8 118
      src/ui/controller/UpdateController.java
  29. 1 1
      src/ui/model/MinimumNetwork.java
  30. 9 29
      src/ui/model/Model.java
  31. 76 79
      src/ui/view/AbstractCanvas.java
  32. 18 25
      src/ui/view/AddElementPopUp.java
  33. 21 36
      src/ui/view/AddObjectPopUp.java
  34. 1 6
      src/ui/view/ButtonTabComponent.java
  35. 452 470
      src/ui/view/Canvas.java
  36. 1 3
      src/ui/view/CreateNewDialog.java
  37. 8 8
      src/ui/view/CreateTemplatePopUp.java
  38. 63 237
      src/ui/view/GUI.java
  39. 27 24
      src/ui/view/GroupNodeCanvas.java
  40. 0 2
      src/ui/view/IndexTranslator.java
  41. 218 43
      src/ui/view/Inspector.java
  42. 0 4
      src/ui/view/Outliner.java
  43. 30 25
      src/ui/view/SearchPopUp.java
  44. 1 8
      src/ui/view/TimePanel.java
  45. 0 1
      src/ui/view/UnitGraph.java
  46. 94 0
      src/ui/view/util/TrippleCheckBox.java
  47. 1 1
      src/utility/events/Action.java
  48. 1 1
      src/utility/events/Event.java
  49. 16 0
      src/utility/events/LostFocusListener.java
  50. 24 0
      src/utility/events/SimpleDocumentListener.java
  51. 1 1
      tests/tests/PraktikumHolonsAdapter.java
  52. 3 3
      tests/tests/PraktikumHolonsTestCanvasController.java
  53. 6 6
      tests/tests/PraktikumHolonsTestCategoryController.java
  54. 4 8
      tests/tests/PraktikumHolonsTestClasses.java
  55. 0 274
      tests/tests/PraktikumHolonsTestLoadAndStoreController.java
  56. 9 9
      tests/tests/PraktikumHolonsTestObjectController.java

+ 3 - 3
.gitignore

@@ -139,6 +139,6 @@ nbdist/
 .idea/
 .idea/
 praktikum-holons.iml
 praktikum-holons.iml
 /gb_singlerun.txt
 /gb_singlerun.txt
-/PSO i100 p20 m3e-3 v4 (52).metalog
-/PSO i100 p20 m3e-3 v6.metalog
-/target/
+/PSO i100 p20 m3e-3 v4 (52).metalog
+/PSO i100 p20 m3e-3 v6.metalog
+/target/

+ 0 - 1
src/Connection/ConnectHandheld.java

@@ -154,7 +154,6 @@ public class ConnectHandheld implements AddOn{
 			console.println(e.getMessage());
 			console.println(e.getMessage());
 		}
 		}
 		catch (IOException e) {
 		catch (IOException e) {
-			// TODO Auto-generated catch block
 			e.printStackTrace();
 			e.printStackTrace();
 		}
 		}
 	}
 	}

+ 12 - 16
src/Connection/socket/Server.java

@@ -97,9 +97,9 @@ public class Server implements Runnable{
 				if(observed == null) stopConnection();
 				if(observed == null) stopConnection();
 				console.println("Res: [" + inputByte + "] -> SetAmount");
 				console.println("Res: [" + inputByte + "] -> SetAmount");
 				int index = in.readInt();
 				int index = in.readInt();
-				int amount = in.readInt();
-				modelField.getElements().get(index).amount = amount;
-				observed.getElements().get(index).setAmount(amount);
+				//int amount = in.readInt();
+				//modelField.getElements().get(index).amount = amount;
+				//observed.getElements().get(index).setAmount(amount);
 				
 				
 			}else if (inputByte == Command.SetEnable) {
 			}else if (inputByte == Command.SetEnable) {
 				if(observed == null) stopConnection();
 				if(observed == null) stopConnection();
@@ -112,17 +112,17 @@ public class Server implements Runnable{
 				if(observed == null) stopConnection();
 				if(observed == null) stopConnection();
 				console.println("Res: [" + inputByte + "] -> IncreaseAmount");
 				console.println("Res: [" + inputByte + "] -> IncreaseAmount");
 				int index = in.readInt();
 				int index = in.readInt();
-				modelField.getElements().get(index).amount++;
+				//modelField.getElements().get(index).amount++;
 				HolonElement ele = observed.getElements().get(index);
 				HolonElement ele = observed.getElements().get(index);
-				ele.setAmount(ele.getAmount()+1);
+				//ele.setAmount(ele.getAmount()+1);
 				
 				
 			}else if (inputByte == Command.DecreaseAmount) {
 			}else if (inputByte == Command.DecreaseAmount) {
 				if(observed == null) stopConnection();
 				if(observed == null) stopConnection();
 				console.println("Res: [" + inputByte + "] -> DecreaseAmount");
 				console.println("Res: [" + inputByte + "] -> DecreaseAmount");
 				int index = in.readInt();
 				int index = in.readInt();
-				modelField.getElements().get(index).amount--;
+				//modelField.getElements().get(index).amount--;
 				HolonElement ele = observed.getElements().get(index);
 				HolonElement ele = observed.getElements().get(index);
-				ele.setAmount(ele.getAmount()-1);
+				//ele.setAmount(ele.getAmount()-1);
 				
 				
 			} else{
 			} else{
 				console.println("Res: [" + inputByte + "] -> unknown");
 				console.println("Res: [" + inputByte + "] -> unknown");
@@ -172,7 +172,6 @@ public class Server implements Runnable{
 		}
 		}
 
 
 		private boolean checkForUpdates() {
 		private boolean checkForUpdates() {
-			//TODO Delete And CheckforUpdatesReal
 			newModelField = createModel();
 			newModelField = createModel();
 			if(compareModels(modelField,newModelField)) {
 			if(compareModels(modelField,newModelField)) {
 				return false;
 				return false;
@@ -195,7 +194,7 @@ public class Server implements Runnable{
 				out.writeInt(modelField.size());
 				out.writeInt(modelField.size());
 				for(HolonElementWrapper wrapper : modelField.getElements()) {
 				for(HolonElementWrapper wrapper : modelField.getElements()) {
 					out.writeUTF(wrapper.name);
 					out.writeUTF(wrapper.name);
-					out.writeInt(wrapper.amount);
+					//out.writeInt(wrapper.amount);
 					out.writeFloat(wrapper.energy);
 					out.writeFloat(wrapper.energy);
 					out.writeBoolean(wrapper.enabled);
 					out.writeBoolean(wrapper.enabled);
 				}
 				}
@@ -248,10 +247,10 @@ public class Server implements Runnable{
 		
 		
 		public void add(HolonElement ele, int index ) {
 		public void add(HolonElement ele, int index ) {
 			String name = ele.getEleName();
 			String name = ele.getEleName();
-			int amount =ele.getAmount();
-			float energy =  ele.getEnergyPerElement();
+			//int amount =ele.getAmount();
+			float energy =  ele.getEnergy();
 			boolean enabled = ele.isActive();
 			boolean enabled = ele.isActive();
-			elements.add(new HolonElementWrapper(name, amount, energy, enabled, index));
+			elements.add(new HolonElementWrapper(name, energy, enabled, index));
 		}
 		}
 		
 		
 		public int size() {
 		public int size() {
@@ -274,15 +273,13 @@ public class Server implements Runnable{
 	public class HolonElementWrapper{
 	public class HolonElementWrapper{
 		public int index;
 		public int index;
 		public String name;
 		public String name;
-		public int amount;
 		public float energy;
 		public float energy;
 		public boolean enabled;
 		public boolean enabled;
 		public HolonElementWrapper(){
 		public HolonElementWrapper(){
 			
 			
 		}
 		}
-		public HolonElementWrapper(String name, int amount, float energy, boolean enabled, int index){
+		public HolonElementWrapper(String name, float energy, boolean enabled, int index){
 			this.name = name;
 			this.name = name;
-			this.amount = amount;
 			this.energy = energy;
 			this.energy = energy;
 			this.enabled = enabled;
 			this.enabled = enabled;
 		}
 		}
@@ -299,7 +296,6 @@ public class Server implements Runnable{
 			
 			
 			
 			
 			return this.name.compareTo(element.name) == 0 &&
 			return this.name.compareTo(element.name) == 0 &&
-				   this.amount == element.amount &&
 				   this.energy == element.energy &&
 				   this.energy == element.energy &&
 				   this.enabled == element.enabled;
 				   this.enabled == element.enabled;
 		}
 		}

+ 2 - 4
src/addOns/Utility/HolonElementSketch.java

@@ -19,14 +19,12 @@ public class HolonElementSketch {
 	public FlexibilitySketch onFlex;
 	public FlexibilitySketch onFlex;
 	public FlexibilitySketch offFlex;
 	public FlexibilitySketch offFlex;
 	
 	
-	public HolonElementSketch(String name, int minAmount, int maxAmount, float energy) {
+	public HolonElementSketch(String name, float energy) {
 		this.name = name;
 		this.name = name;
-		this.minAmount = minAmount;
-		this.maxAmount = maxAmount;
 		this.energy = energy;
 		this.energy = energy;
 	}
 	}
 	public HolonElement createHolonElement(HolonObject parentObject, boolean active) {
 	public HolonElement createHolonElement(HolonObject parentObject, boolean active) {
-		HolonElement ele = new HolonElement(parentObject, name, Random.nextIntegerInRange(minAmount, maxAmount + 1), energy);
+		HolonElement ele = new HolonElement(parentObject, name, energy);
 		ele.setActive(active);
 		ele.setActive(active);
 		if(onFlex != null && Random.nextDouble() < onFlex.flexChance)addFlex(ele, parentObject.getName(), true);
 		if(onFlex != null && Random.nextDouble() < onFlex.flexChance)addFlex(ele, parentObject.getName(), true);
 		if(offFlex != null && Random.nextDouble() < offFlex.flexChance)addFlex(ele, parentObject.getName(), false);
 		if(offFlex != null && Random.nextDouble() < offFlex.flexChance)addFlex(ele, parentObject.getName(), false);

+ 1 - 1
src/algorithm/example/FlexExample.java

@@ -424,7 +424,7 @@ public class FlexExample implements AddOn {
 			
 			
 			List<HolonElement> elementsOfPriorityToShutdown = allHolonElemntsInThisNetwork.stream().filter(hElement -> hElement.isConsumer() && hElement.getPriority() == emergencyShutDownPriority && !hElement.isFlexActive(flexManager) && hElement.isActive()).collect(Collectors.toList());
 			List<HolonElement> elementsOfPriorityToShutdown = allHolonElemntsInThisNetwork.stream().filter(hElement -> hElement.isConsumer() && hElement.getPriority() == emergencyShutDownPriority && !hElement.isFlexActive(flexManager) && hElement.isActive()).collect(Collectors.toList());
 					//.forEach(hElement -> hElement.setActive(false));
 					//.forEach(hElement -> hElement.setActive(false));
-			float energyGained = elementsOfPriorityToShutdown.stream().map(hElement -> -hElement.getEnergyPerElement() * hElement.getAmount()).reduce(0.0f, (a, b) -> a + b);
+			float energyGained = elementsOfPriorityToShutdown.stream().map(hElement -> -hElement.getEnergy()).reduce(0.0f, (a, b) -> a + b);
 			elementsOfPriorityToShutdown.forEach(hElement -> hElement.setActive(false));
 			elementsOfPriorityToShutdown.forEach(hElement -> hElement.setActive(false));
 			int shutdownCount = elementsOfPriorityToShutdown.size();
 			int shutdownCount = elementsOfPriorityToShutdown.size();
 			result.deactivatedElements += shutdownCount;
 			result.deactivatedElements += shutdownCount;

+ 0 - 1
src/algorithm/objectiveFunction/Evaluation.java

@@ -12,7 +12,6 @@ public class Evaluation {
 	
 	
 	/**
 	/**
 	 * Calculate the Fitness(Penelty) Value for a state (alias the calculated Position).
 	 * Calculate the Fitness(Penelty) Value for a state (alias the calculated Position).
-	 * TODO: Make me better Rolf.
 	 * @param state
 	 * @param state
 	 * @return
 	 * @return
 	 */
 	 */

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

@@ -96,7 +96,7 @@ public class TopologieObjectiveFunction {
 	 * 
 	 * 
 	 * 
 	 * 
 	 * @param state
 	 * @param state
-	 * @param moreInformation TODO
+	 * @param moreInformation if more prints should be made
 	 * @return f_g value between 0 and 100
 	 * @return f_g value between 0 and 100
 	 */
 	 */
 	static public float getFitnessValueForState(DecoratedState state, int amountOfAddedSwitch, double addedCableMeters, boolean moreInformation) {
 	static public float getFitnessValueForState(DecoratedState state, int amountOfAddedSwitch, double addedCableMeters, boolean moreInformation) {

+ 1 - 22
src/classes/AbstractCanvasObject.java

@@ -51,7 +51,6 @@ public abstract class AbstractCanvasObject {
 	 *            of the Object
 	 *            of the Object
 	 */
 	 */
 	public AbstractCanvasObject(String objName) {
 	public AbstractCanvasObject(String objName) {
-		setObjName(objName);
 		setName(objName);
 		setName(objName);
 		setImage("/Images/Dummy_House.png");
 		setImage("/Images/Dummy_House.png");
 	}
 	}
@@ -65,33 +64,13 @@ public abstract class AbstractCanvasObject {
 	 *            Object to be copied
 	 *            Object to be copied
 	 */
 	 */
 	public AbstractCanvasObject(AbstractCanvasObject obj) {
 	public AbstractCanvasObject(AbstractCanvasObject obj) {
-		setObjName(obj.getObjName());
-		setName(obj.getObjName());
+		setName(obj.getName());
 		setConnections(new ArrayList<>());
 		setConnections(new ArrayList<>());
 		setId(IdCounter.nextId(CounterType.Object));
 		setId(IdCounter.nextId(CounterType.Object));
 		setImage(obj.getImage());
 		setImage(obj.getImage());
 	}
 	}
 	
 	
-	public abstract AbstractCanvasObject makeCopy();
 
 
-	/**
-	 * 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).
 	 * Getter for the user-defined name (no unique).

+ 2 - 2
src/classes/Flexibility.java

@@ -85,12 +85,12 @@ public class Flexibility {
 
 
 	/** returns the total energy Amount accumulated over the TimeSteps.*/
 	/** returns the total energy Amount accumulated over the TimeSteps.*/
 	public float magnitude() {
 	public float magnitude() {
-		return ((float)duration) *  element.getEnergyPerElement() * element.getAmount();
+		return ((float)duration) *  element.getEnergy();
 	}
 	}
 	
 	
 	public float bringtmir(){
 	public float bringtmir(){
 		//System.out.println("Name:" +  element.getEleName() + "   BringtMir:" + (-element.getEnergyPerElement() * element.getAmount()));
 		//System.out.println("Name:" +  element.getEleName() + "   BringtMir:" + (-element.getEnergyPerElement() * element.getAmount()));
-		return (constrainList.stream().map(constrain -> constrain.getName()).anyMatch(name -> name.equals("onConstrain"))?-1.0f:1.0f) * element.getEnergyPerElement() * element.getAmount();
+		return (constrainList.stream().map(constrain -> constrain.getName()).anyMatch(name -> name.equals("onConstrain"))?-1.0f:1.0f) * element.getEnergy();
 	}
 	}
 	public boolean isPositive() {
 	public boolean isPositive() {
 		return bringtmir() >= 0;
 		return bringtmir() >= 0;

+ 0 - 20
src/classes/GroupNode.java

@@ -12,8 +12,6 @@ public class GroupNode extends AbstractCanvasObject {
 	private ArrayList<AbstractCanvasObject> nodes;
 	private ArrayList<AbstractCanvasObject> nodes;
 	private HashMap<Integer, Integer> nodesIdx;
 	private HashMap<Integer, Integer> nodesIdx;
 	
 	
-	@Expose
-	private int leftBorder; //TODO Delete leftBorder, jet is just set to 0
 	@Expose
 	@Expose
 	private String imgPath = "";
 	private String imgPath = "";
 	@Expose
 	@Expose
@@ -180,24 +178,6 @@ public class GroupNode extends AbstractCanvasObject {
 		return backgroundHeight;
 		return backgroundHeight;
 	}
 	}
 
 
-	/**
-	 * @return the leftBorder
-	 */
-	public int getLeftBorder() {
-		return leftBorder;
-	}
-
-	/**
-	 * @param leftBorder the leftBorder to set
-	 */
-	public void setLeftBorder(int leftBorder) {
-		this.leftBorder = leftBorder;
-	}
-
-	@Override
-	public AbstractCanvasObject makeCopy() {
-		return this;
-	}
 
 
 
 
 }
 }

+ 0 - 172
src/classes/HolonBody.java

@@ -1,172 +0,0 @@
-package classes;
-
-import java.awt.Color;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.Graphics2D;
-
-import utility.Vector2Float;
-
-public class HolonBody implements Comparable<HolonBody> {
-
-	public Vector2Float velocity;
-	public Vector2Float position;
-	private float mass;
-	private float radius;
-	private Color color;
-	private int id;
-
-	public void setId(int id) {
-		this.id = id;
-	}
-
-	public int getId() {
-		return id;
-	}
-
-	public Color getColor() {
-		return color;
-	}
-
-	public HolonBody(float x, float y, float radius, float mass, Color color) {
-		this.velocity = new Vector2Float(0, 0);
-		this.position = new Vector2Float(x, y);
-		this.setMass(mass);
-		this.setRadius(radius);
-		this.color = color;
-	}
-
-	public void draw(Graphics2D g2, String info) {
-
-		g2.setColor(color);
-		g2.fillOval((int) (position.getX() - getRadius()), (int) (position.getY() - getRadius()),
-				(int) (2 * getRadius()), (int) (2 * getRadius()));
-		g2.setFont(new Font("TimesRoman", Font.PLAIN, (int) radius/((info.length()/5)+1)));
-		g2.setColor(Color.WHITE);
-		g2.drawString(info, position.getX() - g2.getFontMetrics().stringWidth(info) / 2,
-				position.getY() + g2.getFontMetrics().getHeight() / 3);
-	}
-
-	public void setRadius(float radius) {
-		if (radius > 1)
-			this.radius = radius;
-		else
-			this.radius = 1;
-	}
-
-	public float getRadius() {
-		return radius;
-	}
-
-	public boolean colliding(HolonBody body) {
-		float xd = position.getX() - body.position.getX();
-		float yd = position.getY() - body.position.getY();
-
-		float sumRadius = getRadius() + body.getRadius();
-		float sqrRadius = sumRadius * sumRadius;
-
-		float distSqr = (xd * xd) + (yd * yd);
-
-		if (distSqr <= sqrRadius) {
-			return true;
-		}
-
-		return false;
-
-	}
-
-	public void resolveCollision(HolonBody body) {
-
-		// get the mtd
-		Vector2Float delta = (position.subtract(body.position));
-		float r = getRadius() + body.getRadius();
-		float dist2 = delta.dot(delta);
-
-		if (dist2 > r * r)
-			return; // they aren't colliding
-
-		float d = delta.getLength();
-
-		Vector2Float mtd;
-		if (d != 0.0f) {
-			// minimum translation distance to push bodies apart after
-			// intersecting
-			mtd = delta.multiply(((getRadius() + body.getRadius()) - d) / d);
-
-		} else {
-			// Special case. Bodies are exactly on top of eachother. Don't want
-			// to divide by zero.
-			d = body.getRadius() + getRadius() - 1.0f;
-			delta = new Vector2Float(body.getRadius() + getRadius(), 0.0f);
-
-			mtd = delta.multiply(((getRadius() + body.getRadius()) - d) / d);
-		}
-
-		// resolve intersection
-		float im1 = 1 / getMass(); // inverse mass quantities
-		float im2 = 1 / body.getMass();
-
-		// push-pull them apart
-		position = position.add(mtd.multiply(im1 / (im1 + im2)));
-		body.position = body.position.subtract(mtd.multiply(im2 / (im1 + im2)));
-
-		// impact speed
-		Vector2Float v = (this.velocity.subtract(body.velocity));
-		float vn = v.dot(mtd.normalize());
-
-		// sphere intersecting but moving away from each other already
-		if (vn > 0.0f)
-			return;
-
-		// collision impulse
-		float restitution = 0.85f;
-		float i = (-(1.0f + restitution) * vn) / (im1 + im2);
-		Vector2Float impulse = mtd.multiply(i);
-
-		// change in momentum
-		this.velocity = this.velocity.add(impulse.multiply(im1));
-		body.velocity = body.velocity.subtract(impulse.multiply(im2));
-
-	}
-
-	public void setMass(float mass) {
-		this.mass = mass;
-	}
-
-	private float getMass() {
-		return mass;
-	}
-
-	public int compareTo(HolonBody body) {
-		if (this.position.getX() - this.getRadius() > body.position.getX() - body.getRadius()) {
-			return 1;
-		} else if (this.position.getX() - this.getRadius() < body.position.getX() - body.getRadius()) {
-			return -1;
-		} else {
-			return 0;
-		}
-	}
-
-	public int compareSizeTo(HolonBody body) {
-		if (this.getRadius() > body.getRadius()) {
-			return 1;
-		} else if (this.getRadius() < body.getRadius()) {
-			return -1;
-		} else {
-			return 0;
-		}
-	}
-
-	public int compareDistTo(HolonBody body, Dimension center) {
-		float thisDist = (float) Math.sqrt(Math.pow(center.getWidth()-this.position.getX(),2)+Math.pow(center.getHeight()-this.position.getY(), 2));
-		float bodyDist = (float) Math.sqrt(Math.pow(center.getWidth()-body.position.getX(),2)+Math.pow(center.getHeight()-body.position.getY(), 2));
-		if (thisDist > bodyDist) {
-			return 1;
-		} else if (thisDist < bodyDist) {
-			return -1;
-		} else {
-			return 0;
-		}
-	}
-
-}

+ 14 - 65
src/classes/HolonElement.java

@@ -1,6 +1,7 @@
 package classes;
 package classes;
 
 
 import com.google.gson.annotations.Expose;
 import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
 
 
 import classes.IdCounter.CounterType;
 import classes.IdCounter.CounterType;
 import interfaces.GraphEditable;
 import interfaces.GraphEditable;
@@ -29,18 +30,13 @@ public class HolonElement implements LocalMode, GraphEditable{
      * the Y component from a Point is the percentage from 0..1
      * the Y component from a Point is the percentage from 0..1
      * */
      * */
     private LinkedList<Point2D.Double> graphPoints;
     private LinkedList<Point2D.Double> graphPoints;
-    /** Name of the object, e.g. House, 1 */
-    @Expose
-    private String objName;
     /** Name of the gadget, e.g. TV */
     /** Name of the gadget, e.g. TV */
     @Expose
     @Expose
     private String eleName;
     private String eleName;
     /** Amount of same elements */
     /** Amount of same elements */
     @Expose
     @Expose
-    private int amount;
-    /** Currently used energy per element (- indicates consumation of energy, + indicates production of energy)*/
-    @Expose
-    private float energyPerElement;
+    @SerializedName(value = "energy", alternate = "energyPerElement")
+    private float energy;
     /** Whether the gadget is active or not (currently uses/produces the energy in energyPerElement) */
     /** Whether the gadget is active or not (currently uses/produces the energy in energyPerElement) */
     @Expose
     @Expose
     private boolean active;
     private boolean active;
@@ -90,20 +86,19 @@ public class HolonElement implements LocalMode, GraphEditable{
      * @param energy  float
      * @param energy  float
      * @param model Model
      * @param model Model
      */
      */
-    public HolonElement(HolonObject parentObject, String eleName, int amount, float energy) {
+    public HolonElement(HolonObject parentObject, String eleName, float energy) {
     	
     	
-    	this(parentObject, eleName, amount, energy, IdCounter.nextId(CounterType.Element));
+    	this(parentObject, eleName, energy, IdCounter.nextId(CounterType.Element));
     }
     }
     
     
 
 
     /**
     /**
      * same as standard constructor, but with already given id (so the counter is not increased twice)
      * same as standard constructor, but with already given id (so the counter is not increased twice)
      */
      */
-    public HolonElement(HolonObject parentObject, String eleName, int amount, float energy, int id){
+    public HolonElement(HolonObject parentObject, String eleName, float energy, int id){
     	this.parentObject = parentObject;
     	this.parentObject = parentObject;
     	setUseLocalPeriod(false);
     	setUseLocalPeriod(false);
     	setEleName(eleName);
     	setEleName(eleName);
-        setAmount(amount);
         setEnergyPerElement(energy);
         setEnergyPerElement(energy);
         setActive(true);
         setActive(true);
         setGraphPoints(new LinkedList<>());
         setGraphPoints(new LinkedList<>());
@@ -125,8 +120,7 @@ public class HolonElement implements LocalMode, GraphEditable{
     	setUseLocalPeriod(element.isUsingLocalPeriod());
     	setUseLocalPeriod(element.isUsingLocalPeriod());
         setEleName(element.getEleName());
         setEleName(element.getEleName());
         setLocalPeriod(element.getLocalPeriod());
         setLocalPeriod(element.getLocalPeriod());
-        setAmount(element.getAmount());
-        setEnergyPerElement(element.getEnergyPerElement());
+        setEnergyPerElement(element.getEnergy());
         setActive(element.isActive());
         setActive(element.isActive());
         setGraphPoints(new LinkedList<>());
         setGraphPoints(new LinkedList<>());
         for (Point2D.Double p : element.getGraphPoints()) {
         for (Point2D.Double p : element.getGraphPoints()) {
@@ -138,13 +132,6 @@ public class HolonElement implements LocalMode, GraphEditable{
 
 
     }
     }
 
 
-	public String getObjName() {
-		return objName;
-	}
-
-	public void setObjName(String objName) {
-		this.objName = objName;
-	}
 
 
 
 
 
 
@@ -166,31 +153,14 @@ public class HolonElement implements LocalMode, GraphEditable{
         this.eleName = name;
         this.eleName = name;
     }
     }
 
 
-    /**
-     * Get the actual amount of Elements in the selected Object.
-     *
-     * @return the amount int
-     */
-    public int getAmount() {
-        return amount;
-    }
-
-    /**
-     * Set the amount of the Element in the selected Object.
-     *
-     * @param amount the amount to set
-     */
-    public void setAmount(int amount) {
-        this.amount = amount;
-    }
 
 
     /**
     /**
      * Get the energyPerElement value of the selected Element.
      * Get the energyPerElement value of the selected Element.
      *
      *
      * @return the energyPerElement
      * @return the energyPerElement
      */
      */
-    public float getEnergyPerElement() {
-        return energyPerElement;
+    public float getEnergy() {
+        return energy;
     }
     }
     public Priority getPriority() {
     public Priority getPriority() {
     	return priority;
     	return priority;
@@ -209,7 +179,7 @@ public class HolonElement implements LocalMode, GraphEditable{
      */
      */
     public boolean isProducer()
     public boolean isProducer()
     {
     {
-    	return (energyPerElement > 0);
+    	return (energy > 0);
     }
     }
     
     
     /**
     /**
@@ -218,7 +188,7 @@ public class HolonElement implements LocalMode, GraphEditable{
      */
      */
     public boolean isConsumer()
     public boolean isConsumer()
     {
     {
-    	return (energyPerElement < 0);
+    	return (energy < 0);
     }
     }
 
 
     /**
     /**
@@ -227,7 +197,7 @@ public class HolonElement implements LocalMode, GraphEditable{
      * @param energyPerElement the energyPerElement to set
      * @param energyPerElement the energyPerElement to set
      */
      */
     public void setEnergyPerElement(float energyPerElement) {
     public void setEnergyPerElement(float energyPerElement) {
-        this.energyPerElement = energyPerElement;
+        this.energy = energyPerElement;
     }
     }
 
 
     /**
     /**
@@ -257,31 +227,11 @@ public class HolonElement implements LocalMode, GraphEditable{
         this.active = active;
         this.active = active;
     }
     }
 
 
-    /**
-     * Multiply the amount of gadgets, given by the user, and the
-     * consumption/production. If the switch isWorking is turned off for on
-     * gadget, the energyPerElement of this gadget have to be subtracted.
-     *
-     * @return totalEnergy (actual)
-     */
-    public float getMaximumEnergy() {
-        return amount * energyPerElement;
-    }
-
-    /**
-     * Get the energyPerElement value at a selected time x.
-     *
-     * @param timestep int
-     * @return energyPerElement value
-     */
-    public float getOverallEnergyAtTimeStep(int timestep) {
-       return ((float) amount) * energyPerElement * curveSample[IndexTranslator.getEffectiveIndex(this, timestep)];
-    }
     /**
     /**
      * Get the energyPerElement currently(at given time step) available
      * Get the energyPerElement currently(at given time step) available
      */
      */
     public float getEnergyAtTimeStep(int timestep) {
     public float getEnergyAtTimeStep(int timestep) {
-    	return amount * energyPerElement * this.curveSample[IndexTranslator.getEffectiveIndex(this, timestep)];
+    	return energy * this.curveSample[IndexTranslator.getEffectiveIndex(this, timestep)];
     }
     }
 
 
 
 
@@ -324,9 +274,8 @@ public class HolonElement implements LocalMode, GraphEditable{
         sb.append("id=").append(id)
         sb.append("id=").append(id)
                 .append(", eleName=").append(eleName)
                 .append(", eleName=").append(eleName)
                 .append(", parentName=").append(parentObject.getName())
                 .append(", parentName=").append(parentObject.getName())
-                .append(", amount=").append(amount)
                 .append(", active=").append(active)
                 .append(", active=").append(active)
-                .append(", energyPerElement used=").append(energyPerElement);
+                .append(", energyPerElement used=").append(energy);
         sb.append("]");
         sb.append("]");
 
 
         return sb.toString();
         return sb.toString();

+ 15 - 89
src/classes/HolonObject.java

@@ -18,12 +18,6 @@ import java.util.List;
 public class HolonObject extends AbstractCanvasObject { 
 public class HolonObject extends AbstractCanvasObject { 
     /* Array of all consumers */
     /* Array of all consumers */
     private List<HolonElement> elements = new ArrayList<HolonElement>();
     private List<HolonElement> elements = new ArrayList<HolonElement>();
-    /* Array for tracking Production */
-    private float[] trackingProd;
-    /* Array for tracking Consumption */
-    private float[] trackingCons;
-    /* Total Flexibility */
-    private float totalFlex;
     
     
     /**
     /**
      * Constructor Set by default the name of the object equals to the category
      * Constructor Set by default the name of the object equals to the category
@@ -33,8 +27,6 @@ public class HolonObject extends AbstractCanvasObject {
      */
      */
     public HolonObject(String objName) {
     public HolonObject(String objName) {
         super(objName);
         super(objName);
-        setTrackingProd(new float[100]);
-        setTrackingCons(new float[100]);
     }
     }
 
 
     /**
     /**
@@ -47,8 +39,6 @@ public class HolonObject extends AbstractCanvasObject {
         for(HolonElement ele : obj.getElements()) {
         for(HolonElement ele : obj.getElements()) {
         	this.addElement(new HolonElement(ele));
         	this.addElement(new HolonElement(ele));
         }
         }
-        setTrackingProd(new float[100]);
-        setTrackingCons(new float[100]);
     }
     }
 
 
  
  
@@ -72,16 +62,21 @@ public class HolonObject extends AbstractCanvasObject {
         elements.add(element);
         elements.add(element);
         element.parentObject = this;
         element.parentObject = this;
     }
     }
-
+    
     /**
     /**
-     * deletes Element at a given index.
+     * remove an Element to the Object.
      *
      *
-     * @param idx index
+     * @param element the Element to add
      */
      */
-    public void deleteElement(int idx) {
-    	elements.remove(idx);
+    public void removeElement(HolonElement element) {
+        elements.remove(element);
+        element.parentObject = null;
     }
     }
-    
+
+    public void removeElement(int index) {
+    	HolonElement ele = elements.remove(index);
+    	ele.parentObject = null;
+	}
 
 
     
     
 
 
@@ -249,78 +244,11 @@ public class HolonObject extends AbstractCanvasObject {
 
 
 
 
 
 
-    /**
-     * Get the Array Production
-     */
-    public float[] getTrackingProd() {
-        return this.trackingProd;
-    }
 
 
-    /**
-     * Set the Array Production
-     */
-    public void setTrackingProd(float[] arr) {
-        this.trackingProd = arr;
-    }
 
 
-    /**
-     * Get the Array Consumption
-     */
-    public float[] getTrackingCons() {
-        return this.trackingCons;
-    }
 
 
-    /**
-     * Set the Array Consumption
-     */
-    public void setTrackingCons(float[] arr) {
-        this.trackingCons = arr;
-    }
-
-    /**
-     * Get the Array Consumption
-     */
-    public float getTotalFlex() {
-        return totalFlex;
-    }
-
-    /**
-     * Set the Array Consumption
-     */
-    public void setTotalFlex(float totalFlex) {
-        this.totalFlex = totalFlex;
-    }
-
-
-
-
-    /**
-     * If the user track any HolonObject the tracking information will be
-     * updated. (If the HolonObject enters into the untracked state, the array
-     * will be reseted)
-     */
-
-    public void updateTrackingInfo() {
-        float[] tempProd = new float[100];
-        float[] tempCons = new float[100];
-        for (int i = 0; i < 100; i++) {
-            float valueProd = 0;
-            float valueCons = 0;
-            for (HolonElement e : getElements()) {
-                if (e.isActive() && e.isProducer()) {
-                    valueProd += e.getOverallEnergyAtTimeStep(i);
-                }
-                if (e.isActive() && e.isConsumer()) {
-                    valueCons += e.getOverallEnergyAtTimeStep(i);
-                }
-            }
-            tempProd[i] = valueProd;
-            tempCons[i] = valueCons;
-        }
-        this.trackingProd = tempProd;
-        this.trackingCons = tempCons;
-    }
 
 
+   
 
 
     public String toString() {
     public String toString() {
         StringBuilder sb = new StringBuilder();
         StringBuilder sb = new StringBuilder();
@@ -342,10 +270,6 @@ public class HolonObject extends AbstractCanvasObject {
         return sb.toString();
         return sb.toString();
     }
     }
     
     
-    @Override
-	public HolonObject makeCopy(){
-		return new HolonObject(this);
-	}
 
 
 	public int getNumberOfActiveElements() {
 	public int getNumberOfActiveElements() {
 		return (int) elements.stream().filter(ele -> ele.isActive()).count();
 		return (int) elements.stream().filter(ele -> ele.isActive()).count();
@@ -356,10 +280,12 @@ public class HolonObject extends AbstractCanvasObject {
 	}
 	}
 	
 	
 	public int getNumberOfElements() {
 	public int getNumberOfElements() {
-		return (int) elements.stream().count();
+		return elements.size();
 	}
 	}
 
 
 	public void setElements(List<HolonElement> list) {
 	public void setElements(List<HolonElement> list) {
 		this.elements = list;
 		this.elements = list;
 	}
 	}
+
+	
 }
 }

+ 0 - 4
src/classes/HolonSwitch.java

@@ -308,10 +308,6 @@ public class HolonSwitch extends AbstractCanvasObject implements LocalMode, Grap
 		this.localPeriodActive=state;
 		this.localPeriodActive=state;
 	}
 	}
 	
 	
-	@Override
-	public HolonSwitch makeCopy(){
-		return new HolonSwitch(this);
-	}
 	
 	
 		
 		
 	public String toString() {
 	public String toString() {

+ 1 - 5
src/classes/Node.java

@@ -34,9 +34,5 @@ public class Node extends AbstractCanvasObject {
 	public String toString(){
 	public String toString(){
 		return "Node ID:" + super.id;
 		return "Node ID:" + super.id;
 	}
 	}
-	
-	@Override
-	public AbstractCanvasObject makeCopy() {
-		return new Node(this);
-	}
+
 }
 }

+ 2 - 2
src/classes/comparator/elementComparator/ElemCompOnEnergy.java

@@ -12,8 +12,8 @@ public class ElemCompOnEnergy extends ElementComparator {
 	@Override
 	@Override
 	public int compare(HolonElement a, HolonElement b) {
 	public int compare(HolonElement a, HolonElement b) {
 
 
-		float verbrauchA = a.getEnergyPerElement();
-		float verbrauchB = b.getEnergyPerElement();
+		float verbrauchA = a.getEnergy();
+		float verbrauchB = b.getEnergy();
 		if (verbrauchA < verbrauchB)
 		if (verbrauchA < verbrauchB)
 			return -1;
 			return -1;
 		if (verbrauchA > verbrauchB)
 		if (verbrauchA > verbrauchB)

+ 0 - 18
src/classes/comparator/elementComparator/ElemCompOnObj.java

@@ -1,18 +0,0 @@
-package classes.comparator.elementComparator;
-
-import classes.HolonElement;
-
-public class ElemCompOnObj extends ElementComparator {
-
-	@Override
-	public int compare(HolonElement a, HolonElement b) {
-
-		String objNameA = a.getObjName();
-		String objNameB = b.getObjName();
-		if(objNameA == null)return -1;
-		if (objNameB == null)return 1;
-		return objNameA.compareTo(objNameB);
-
-	}
-
-}

+ 0 - 20
src/classes/comparator/elementComparator/ElemCompOnQuantity.java

@@ -1,20 +0,0 @@
-package classes.comparator.elementComparator;
-
-import classes.HolonElement;
-
-public class ElemCompOnQuantity extends ElementComparator {
-
-	@Override
-	public int compare(HolonElement a, HolonElement b) {
-
-		float amountA = a.getAmount();
-		float amountB = b.getAmount();
-		if (amountA < amountB)
-			return -1;
-		if (amountA > amountB)
-			return 1;
-		return 0;
-
-	}
-
-}

+ 26 - 18
src/ui/controller/CanvasController.java

@@ -2,15 +2,17 @@ package ui.controller;
 
 
 import java.awt.Point;
 import java.awt.Point;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.ListIterator;
+import java.util.stream.Collectors;
 
 
+import classes.AbstractCanvasObject;
 import classes.Edge;
 import classes.Edge;
-import classes.Node;
 import classes.GroupNode;
 import classes.GroupNode;
-import classes.AbstractCanvasObject;
 import classes.HolonObject;
 import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.HolonSwitch;
+import classes.Node;
 import interfaces.ObjectListener;
 import interfaces.ObjectListener;
 import ui.model.Model;
 import ui.model.Model;
 import ui.view.GUI;
 import ui.view.GUI;
@@ -128,6 +130,15 @@ public class CanvasController {
 		model.getCvsObjIdx().remove(obj.getId());
 		model.getCvsObjIdx().remove(obj.getId());
 		model.getObjectsOnCanvas().remove(obj);
 		model.getObjectsOnCanvas().remove(obj);
 	}
 	}
+	
+	public void deleteObjectsOnCanvas(Collection<AbstractCanvasObject> objects) {
+		for(AbstractCanvasObject obj: objects) {
+			removeAllConnectionsFromObject(obj);
+			mpC.decIdx(obj.getId(), model.getCvsObjIdx());
+			model.getCvsObjIdx().remove(obj.getId());
+			model.getObjectsOnCanvas().remove(obj);
+		}
+	}
 
 
 	/**
 	/**
      * Replaces {@code toBeReplaced} by {@code by} on the canvas
      * Replaces {@code toBeReplaced} by {@code by} on the canvas
@@ -185,7 +196,7 @@ public class CanvasController {
 	 *            the mouse Position
 	 *            the mouse Position
 	 */
 	 */
 	public void pasteObjects(Point p) {
 	public void pasteObjects(Point p) {
-		model.getSelectedCpsObjects().clear();
+		model.getSelectedObjects().clear();
 		AbstractCanvasObject tCps = null;
 		AbstractCanvasObject tCps = null;
 		int x = Integer.MAX_VALUE, y = Integer.MAX_VALUE;
 		int x = Integer.MAX_VALUE, y = Integer.MAX_VALUE;
 
 
@@ -199,7 +210,6 @@ public class CanvasController {
 			}
 			}
 		}
 		}
 
 
-		ArrayList<AbstractCanvasObject> tempList = new ArrayList<>();
 		// Objects
 		// Objects
 		for (AbstractCanvasObject cps : model.getClipboradObjects()) {
 		for (AbstractCanvasObject cps : model.getClipboradObjects()) {
 			if (cps instanceof HolonObject) {
 			if (cps instanceof HolonObject) {
@@ -211,21 +221,21 @@ public class CanvasController {
 			}
 			}
 			tCps.setPosition(new Vector2Int(p.x + (cps.getPosition().getX() - x), p.y + (cps.getPosition().getY() - y)));
 			tCps.setPosition(new Vector2Int(p.x + (cps.getPosition().getX() - x), p.y + (cps.getPosition().getY() - y)));
 			tCps.setSav(cps.getSav());
 			tCps.setSav(cps.getSav());
-			tempList.add(tCps);
 			addObject(tCps, false);
 			addObject(tCps, false);
 		}
 		}
 
 
 		// Edges
 		// Edges
-		boolean newEdge = true;
+
 		for (AbstractCanvasObject cps : model.getClipboradObjects()) {
 		for (AbstractCanvasObject cps : model.getClipboradObjects()) {
 			for (Edge e : cps.getConnectedTo()) {
 			for (Edge e : cps.getConnectedTo()) {
 				// A and B of e in the copied Elements?
 				// A and B of e in the copied Elements?
-				if (model.getClipboradObjects().indexOf(e.getA()) != -1
-						&& model.getClipboradObjects().indexOf(e.getB()) != -1) {
-					AbstractCanvasObject a = tempList.get(model.getClipboradObjects().indexOf(e.getA()));
-					AbstractCanvasObject b = tempList.get(model.getClipboradObjects().indexOf(e.getB()));
+				if (model.getClipboradObjects().contains(e.getA())
+						&& model.getClipboradObjects().contains(e.getB())) {
+					AbstractCanvasObject a = e.getA();
+					AbstractCanvasObject b = e.getB();
+					boolean newEdge = true;
 					// was this Edge created or not?
 					// was this Edge created or not?
-					for (Edge et : tempList.get(model.getClipboradObjects().indexOf(cps)).getConnectedTo()) {
+					for (Edge et : cps.getConnectedTo()) {
 						for (Edge etA : et.getA().getConnectedTo()) {
 						for (Edge etA : et.getA().getConnectedTo()) {
 							if (etA.getA() == a && etA.getB() == b) {
 							if (etA.getA() == a && etA.getB() == b) {
 								newEdge = false;
 								newEdge = false;
@@ -238,12 +248,10 @@ public class CanvasController {
 						}
 						}
 					}
 					}
 					if (newEdge) {
 					if (newEdge) {
-						Edge tempE = new Edge(tempList.get(model.getClipboradObjects().indexOf(e.getA())), // A
-								tempList.get(model.getClipboradObjects().indexOf(e.getB())), /* B */
+						Edge tempE = new Edge(a, b,
 								e.getCapacity());
 								e.getCapacity());
 						addEdgeOnCanvas(tempE);
 						addEdgeOnCanvas(tempE);
 					}
 					}
-					newEdge = true;
 				}
 				}
 			}
 			}
 		}
 		}
@@ -253,15 +261,13 @@ public class CanvasController {
 	/**
 	/**
 	 * Cut all Selected Objects.
 	 * Cut all Selected Objects.
 	 */
 	 */
-	@SuppressWarnings("unchecked")
 	public void cutObjects() {
 	public void cutObjects() {
-		model.setClipboradObjects((ArrayList<AbstractCanvasObject>) model.getSelectedCpsObjects().clone());
-
+		model.setClipboradObjects(model.getSelectedObjects().stream().collect(Collectors.toSet()));
 		for (AbstractCanvasObject cps : model.getClipboradObjects()) {
 		for (AbstractCanvasObject cps : model.getClipboradObjects()) {
 			deleteObjectOnCanvas(cps);
 			deleteObjectOnCanvas(cps);
 		}
 		}
 
 
-		model.getSelectedCpsObjects().clear();
+		model.getSelectedObjects().clear();
 	}
 	}
 
 
 	
 	
@@ -337,5 +343,7 @@ public class CanvasController {
 		model.setCanvasImageWidth(width);
 		model.setCanvasImageWidth(width);
 		model.setCanvasImageHeight(height);
 		model.setCanvasImageHeight(height);
 	}
 	}
+
+	
 	
 	
 }
 }

+ 8 - 9
src/ui/controller/CategoryController.java

@@ -10,7 +10,7 @@ import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.HolonSwitch;
 import classes.Pair;
 import classes.Pair;
 import ui.model.Model;
 import ui.model.Model;
-import utility.Event;
+import utility.events.Event;
 
 
 /**
 /**
  * Controller for the Categories.
  * Controller for the Categories.
@@ -129,12 +129,11 @@ public class CategoryController {
 		int i = 0;
 		int i = 0;
 		boolean updateElementSaves = false;
 		boolean updateElementSaves = false;
 		String name = "";
 		String name = "";
-		while (mpC.searchCatObj(category, object.getObjName()) != null) {
+		while (mpC.searchCatObj(category, object.getName()) != null) {
 			updateElementSaves = true;
 			updateElementSaves = true;
-			if (object.getObjName().contains("_"))
-				object.setObjName(object.getObjName().substring(0, object.getObjName().indexOf('_')));
-			name = object.getObjName() + "_" + i;
-			object.setObjName(name);
+			if (object.getName().contains("_"))
+				object.setName(object.getName().substring(0, object.getName().indexOf('_')));
+			name = object.getName() + "_" + i;
 			object.setName(name);
 			object.setName(name);
 			i++;
 			i++;
 		}
 		}
@@ -143,7 +142,7 @@ public class CategoryController {
 				e.setSaving(new Pair<String,String>(e.getSaving().getKey(), name));
 				e.setSaving(new Pair<String,String>(e.getSaving().getKey(), name));
 			}
 			}
 		}
 		}
-		category.getObjIdx().put(object.getObjName(), category.getObjects().size());
+		category.getObjIdx().put(object.getName(), category.getObjects().size());
 		category.getObjects().add(object);
 		category.getObjects().add(object);
 	}
 	}
 
 
@@ -195,8 +194,8 @@ public class CategoryController {
 	 */
 	 */
 	public void removeObject(Category category, AbstractCanvasObject cps) {
 	public void removeObject(Category category, AbstractCanvasObject cps) {
 
 
-		mpC.decIdx(cps.getObjName(), category.getObjIdx());
-		category.getObjIdx().remove(cps.getObjName());
+		mpC.decIdx(cps.getName(), category.getObjIdx());
+		category.getObjIdx().remove(cps.getName());
 		category.getObjects().remove(cps);
 		category.getObjects().remove(cps);
 		OnCategoryChanged.broadcast();
 		OnCategoryChanged.broadcast();
 	}
 	}

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

@@ -60,10 +60,10 @@ public class ClipboardController {
         store.initNumeration();
         store.initNumeration();
 
 
         file.add("SAV", new JsonPrimitive((upperNode == null ? "CVS" : "" + upperNode.getId())));
         file.add("SAV", new JsonPrimitive((upperNode == null ? "CVS" : "" + upperNode.getId())));
-        Vector2Int pos = uppC.calculatePos(model.getSelectedCpsObjects());
+        Vector2Int pos = uppC.calculatePos(model.getSelectedObjects());
         file.add("CENTER", model.getGson().toJsonTree(pos, Vector2Int.class));
         file.add("CENTER", model.getGson().toJsonTree(pos, Vector2Int.class));
 
 
-        for (AbstractCanvasObject abs : model.getSelectedCpsObjects()) {
+        for (AbstractCanvasObject abs : model.getSelectedObjects()) {
             queue.add(abs);
             queue.add(abs);
         }
         }
         while (!queue.isEmpty()) {
         while (!queue.isEmpty()) {
@@ -126,7 +126,7 @@ public class ClipboardController {
 
 
         HashMap<Integer, AbstractCanvasObject> objDispatch = new HashMap<>();
         HashMap<Integer, AbstractCanvasObject> objDispatch = new HashMap<>();
         HashMap<Integer, HolonElement> eleDispatch = new HashMap<>();
         HashMap<Integer, HolonElement> eleDispatch = new HashMap<>();
-        model.getSelectedCpsObjects().clear();
+        model.getSelectedObjects().clear();
 
 
         objIDMap = new HashMap<>();
         objIDMap = new HashMap<>();
         eleIDMap = new HashMap<>();
         eleIDMap = new HashMap<>();
@@ -147,7 +147,7 @@ public class ClipboardController {
      */
      */
     void cut(GroupNode upperNode) {
     void cut(GroupNode upperNode) {
         copy(upperNode);
         copy(upperNode);
-        for (AbstractCanvasObject abs : model.getSelectedCpsObjects()) {
+        for (AbstractCanvasObject abs : model.getSelectedObjects()) {
             if (upperNode == null)
             if (upperNode == null)
                 cvsC.deleteObjectOnCanvas(abs);
                 cvsC.deleteObjectOnCanvas(abs);
             else
             else
@@ -156,6 +156,7 @@ public class ClipboardController {
             if (abs instanceof GroupNode)
             if (abs instanceof GroupNode)
                 cvsC.bfsNodeCleaner((GroupNode) abs);
                 cvsC.bfsNodeCleaner((GroupNode) abs);
         }
         }
+        model.getSelectedObjects().clear();
         this.simManager.calculateStateForTimeStep(model.getCurIteration(), true);
         this.simManager.calculateStateForTimeStep(model.getCurIteration(), true);
 
 
     }
     }
@@ -212,7 +213,7 @@ public class ClipboardController {
             else
             else
                 uppC.addObjectInUpperNode(temp, upperNode, false);
                 uppC.addObjectInUpperNode(temp, upperNode, false);
             // mark the Pasted Objects
             // mark the Pasted Objects
-            model.getSelectedCpsObjects().add(temp);
+            model.getSelectedObjects().add(temp);
         } else {
         } else {
             // else look up the table and put it into the right Uppernode
             // else look up the table and put it into the right Uppernode
             GroupNode temp2 = (GroupNode) objDispatch.get(objIDMap.get(Integer.parseInt(temp.getSav())));
             GroupNode temp2 = (GroupNode) objDispatch.get(objIDMap.get(Integer.parseInt(temp.getSav())));
@@ -381,8 +382,8 @@ public class ClipboardController {
      * Adds all Objects in Depth into Clipboardobjects preemptive when objects are selected
      * Adds all Objects in Depth into Clipboardobjects preemptive when objects are selected
      */
      */
     void getObjectsInDepth() {
     void getObjectsInDepth() {
-        model.setClipboradObjects(new ArrayList<>());
-        for (AbstractCanvasObject obj : model.getSelectedCpsObjects()) {
+        model.getClipboradObjects().clear();
+        for (AbstractCanvasObject obj : model.getSelectedObjects()) {
             clipboadDepth(obj);
             clipboadDepth(obj);
         }
         }
     }
     }
@@ -431,8 +432,8 @@ public class ClipboardController {
         if (y < 0)
         if (y < 0)
             y = 0 + model.getScaleDiv2() + 1;
             y = 0 + model.getScaleDiv2() + 1;
         if (upperNode != null) {
         if (upperNode != null) {
-            if (x < upperNode.getLeftBorder() + model.getScaleDiv2() + 1)
-                x = upperNode.getLeftBorder() + model.getScaleDiv2() + 1;
+            if (x < model.getScaleDiv2() + 1)
+                x = model.getScaleDiv2() + 1;
         } else if (x < 0)
         } else if (x < 0)
             x = 0 + model.getScaleDiv2() + 1;
             x = 0 + model.getScaleDiv2() + 1;
         if (x > model.getCanvasX())
         if (x > model.getCanvasX())

File diff suppressed because it is too large
+ 763 - 807
src/ui/controller/Control.java


+ 0 - 236
src/ui/controller/HolonCanvasController.java

@@ -1,236 +0,0 @@
-package ui.controller;
-
-import classes.*;
-import ui.model.Model;
-import utility.Vector2Float;
-
-import java.awt.*;
-import java.util.ArrayList;
-
-public class HolonCanvasController {
-
-	// Ball objects
-	private ArrayList<HolonBody> bodies = new ArrayList<>();
-	private int subCount;
-	private Dimension center;
-	private Model model;
-	private ArrayList<HolonBody> sortedSize = new ArrayList<>();
-	private ArrayList<HolonBody> sortedDist = new ArrayList<>();
-	private int toDrag;
-	private boolean beingDragged;
-
-	/**
-	 * Constructor.
-	 * 
-	 * @param model
-	 *            the Model
-	 * @param mp
-	 *            the MultipurposeController
-	 */
-	public HolonCanvasController(Model model) {
-		this.model = model;
-	}
-
-	// sort the HolonBodys after size
-	public void rearrangeAfterSize() {
-		int j = 0;
-		sortedSize.addAll(bodies);
-		insertionSizeSort(sortedSize);
-		sortedDist.addAll(bodies);
-
-		ArrayList<Vector2Float> pos = insertionDistSort(sortedDist);
-		for (int i = 0; i < subCount; i++) {
-			int ID = sortedSize.get(subCount - 1 - i).getId();
-			for (j = 0; j < subCount; j++) {
-				if (ID == bodies.get(j).getId()) {
-					bodies.get(j).position = pos.get(i);
-					break;
-				}
-			}
-		}
-	}
-
-	public int getActiveElements(ArrayList<AbstractCanvasObject> objects) {
-		int val = 0;
-		for (AbstractCanvasObject obj : objects) {
-			if (obj instanceof HolonObject) {
-				for (HolonElement ele : ((HolonObject) obj).getElements()) {
-                    if (ele.isActive()) {
-                        val += 1;
-					}
-				}
-			} else if (obj instanceof GroupNode) {
-				val += getTotalProduction(((GroupNode) obj).getNodes());
-			}
-		}
-		return val;
-	}
-
-	public int getTotalProducers(ArrayList<AbstractCanvasObject> objects) {
-		float val = 0;
-		int prod = 0;
-		int tStep = model.getCurIteration();
-		for (AbstractCanvasObject obj : objects) {
-			if (obj instanceof HolonObject) {
-				for (HolonElement ele : ((HolonObject) obj).getElements()) {
-                    if (ele.getEnergyAtTimeStep(tStep) > 0 && ele.isActive()) {
-                        val += ele.getEnergyAtTimeStep(tStep) * ele.getAmount();
-                    }
-                }
-				if (val > 0)
-					prod += 1;
-			} else if (obj instanceof GroupNode) {
-				val += getTotalProduction(((GroupNode) obj).getNodes());
-			}
-		}
-		return prod;
-	}
-
-	public int getTotalElements(ArrayList<AbstractCanvasObject> objects) {
-		int val = 0;
-		for (AbstractCanvasObject obj : objects) {
-			if (obj instanceof HolonObject) {
-				val += ((HolonObject) obj).getElements().size();
-			} else if (obj instanceof GroupNode) {
-				val += getTotalConsumption(((GroupNode) obj).getNodes());
-			}
-		}
-		return val;
-	}
-
-	public float getTotalConsumption(ArrayList<AbstractCanvasObject> objects) {
-		float val = 0;
-		int tStep = model.getCurIteration();
-		for (AbstractCanvasObject obj : objects) {
-			if (obj instanceof HolonObject) {
-				for (HolonElement ele : ((HolonObject) obj).getElements()) {
-                    if (ele.getEnergyAtTimeStep(tStep) < 0 && ele.isActive()) {
-                        val += ele.getEnergyAtTimeStep(tStep) * ele.getAmount();
-                    }
-                }
-			} else if (obj instanceof GroupNode) {
-				val += getTotalConsumption(((GroupNode) obj).getNodes());
-			}
-		}
-		return val;
-	}
-
-	public float getTotalProduction(ArrayList<AbstractCanvasObject> objects) {
-		float val = 0;
-		int tStep = model.getCurIteration();
-		for (AbstractCanvasObject obj : objects) {
-			if (obj instanceof HolonObject) {
-				for (HolonElement ele : ((HolonObject) obj).getElements()) {
-                    if (ele.getEnergyAtTimeStep(tStep) > 0 && ele.isActive()) {
-                        val += ele.getEnergyAtTimeStep(tStep) * ele.getAmount();
-                    }
-                }
-			} else if (obj instanceof GroupNode) {
-				val += getTotalProduction(((GroupNode) obj).getNodes());
-			}
-		}
-		return val;
-	}
-
-	public void updateBodies(float elapsedSeconds) {
-		// step the position of movable objects based off their velocity/gravity
-		// and elapsedTime
-		for (int i = 0; i < subCount; i++) {
-			if (toDrag != bodies.get(i).getId() || !beingDragged) {
-				bodies.get(i).position.setX(
-						(float) (bodies.get(i).position.getX() + (bodies.get(i).velocity.getX() * (elapsedSeconds))
-								- ((bodies.get(i).position.getX() - center.getWidth()) / (50 + subCount))));
-				bodies.get(i).position.setY(
-						(float) (bodies.get(i).position.getY() + (bodies.get(i).velocity.getY() * (elapsedSeconds))
-								- ((bodies.get(i).position.getY() - center.getHeight()) / (50 + subCount))));
-				float epsilon = 0.000009f;
-				if (Math.abs(bodies.get(i).velocity.getX()) < epsilon)
-					bodies.get(i).velocity.setX(0);
-				if (Math.abs(bodies.get(i).velocity.getY()) < epsilon)
-					bodies.get(i).velocity.setY(0);
-			}
-		}
-		checkCollisions();
-	}
-
-	// Insertion sort for Sweep and Prune
-	public void insertionSort(ArrayList<HolonBody> a) {
-		for (int p = 1; p < subCount; p++) {
-			Comparable<HolonBody> tmp = a.get(p);
-			int j = p;
-
-			for (; j > 0 && tmp.compareTo(a.get(j - 1)) < 0; j--)
-				a.set(j, a.get(j - 1));
-
-			a.set(j, (HolonBody) tmp);
-		}
-	}
-
-	// Insertion sort for subnet size
-	private void insertionSizeSort(ArrayList<HolonBody> a) {
-		for (int p = 1; p < subCount; p++) {
-			HolonBody tmp = a.get(p);
-			int j = p;
-
-			for (; j > 0 && tmp.compareSizeTo(a.get(j - 1)) < 0; j--)
-				a.set(j, a.get(j - 1));
-
-			a.set(j, (HolonBody) tmp);
-		}
-	}
-
-	// Insertion sort for HolonBody distance
-	private ArrayList<Vector2Float> insertionDistSort(ArrayList<HolonBody> a) {
-		ArrayList<Vector2Float> pos = new ArrayList<>();
-		for (int p = 1; p < subCount; p++) {
-			HolonBody tmp = a.get(p);
-			int j = p;
-
-			for (; j > 0 && tmp.compareDistTo(a.get(j - 1), center) < 0; j--)
-				a.set(j, a.get(j - 1));
-
-			a.set(j, (HolonBody) tmp);
-		}
-		for (int i = 0; i < subCount; i++)
-			pos.add(a.get(i).position);
-		return pos;
-	}
-
-	public void checkCollisions() {
-		insertionSort(bodies);
-
-		for (int i = 0; i < subCount; i++) {
-			// Ball to Ball collision
-			float radiusI = bodies.get(i).getRadius();
-			float xPlusradius = (bodies.get(i).position.getX() + radiusI);
-			float yPlusradius = (bodies.get(i).position.getY() + radiusI);
-			float yMinusRadius = (bodies.get(i).position.getY()- radiusI);
-			for (int j = i + 1; j < subCount; j++) {
-				float radiusJ = bodies.get(j).getRadius();
-				if (xPlusradius < (bodies.get(j).position.getX()- radiusJ))
-					break;
-
-				if (yPlusradius < (bodies.get(j).position.getY()- radiusJ)
-					|| (bodies.get(j).position.getY() + radiusJ) < yMinusRadius)
-					continue;
-
-				bodies.get(i).resolveCollision(bodies.get(j));
-
-			}
-		}
-
-	}
-
-	public ArrayList<HolonBody> getBodies() {
-		return bodies;
-	}
-
-	public void setDrag(boolean beingDragged) {
-		this.beingDragged = beingDragged;
-	}
-
-	public void setBodyToDrag(int i) {
-		this.toDrag = i;
-	}
-
-}

+ 24 - 33
src/ui/controller/LoadController.java

@@ -1,6 +1,7 @@
 package ui.controller;
 package ui.controller;
 
 
 import classes.*;
 import classes.*;
+import classes.HolonElement.Priority;
 import classes.IdCounter.CounterType;
 import classes.IdCounter.CounterType;
 
 
 import com.google.gson.JsonElement;
 import com.google.gson.JsonElement;
@@ -166,22 +167,18 @@ public class LoadController {
         for (String key : keys) {
         for (String key : keys) {
             if (key.contains("CATEGORY"))
             if (key.contains("CATEGORY"))
                 loadCategory(json.get(key));
                 loadCategory(json.get(key));
-            if (key.contains("CGOBJECT"))
+            else if (key.contains("CGOBJECT"))
                 loadCategoryObject(json.get(key).getAsJsonObject());
                 loadCategoryObject(json.get(key).getAsJsonObject());
-            if (key.contains("CGELEMENT"))
-                loadCategoryElements(json.get(key), eleDispatch);//TODO
-            if (key.contains("CVSOBJECT"))
+            else if (key.contains("CGELEMENT"))
+                loadCategoryElements(json.get(key), eleDispatch);
+            else if (key.contains("CVSOBJECT"))
                 loadCanvasObject(json.get(key).getAsJsonObject(), objDispatch);
                 loadCanvasObject(json.get(key).getAsJsonObject(), objDispatch);
-            if (key.contains("CVSELEMENT"))
+            else if (key.contains("CVSELEMENT"))
                 loadCanvasElements(json.get(key), objDispatch, eleDispatch);
                 loadCanvasElements(json.get(key), objDispatch, eleDispatch);
-            if (key.contains("SWUNITGRAPH"))
+            else if (key.contains("SWUNITGRAPH"))
                 loadUnitGraph(GRAPHTYPE.SWITCH, json.get(key), objDispatch, null);
                 loadUnitGraph(GRAPHTYPE.SWITCH, json.get(key), objDispatch, null);
-            if (key.contains("ELEUNITGRAPH"))
+            else if (key.contains("ELEUNITGRAPH") && key.contains("ELETESTUNITGRAPH"))
                 loadUnitGraph(GRAPHTYPE.ELEMENT, json.get(key), null, eleDispatch);
                 loadUnitGraph(GRAPHTYPE.ELEMENT, json.get(key), null, eleDispatch);
-            if (key.contains("ELETESTUNITGRAPH"))
-                loadUnitGraph(GRAPHTYPE.TESTELEMENT, json.get(key), null, eleDispatch);
-            if (key.contains("TRACKED"))
-                loadTracked(json.get(key), objDispatch);
         }
         }
 
 
     }
     }
@@ -245,8 +242,8 @@ public class LoadController {
         
         
         temp.setImage(checkOS(temp.getImage()));
         temp.setImage(checkOS(temp.getImage()));
         initObjects(temp);
         initObjects(temp);
-        if (mpC.searchCatObj(mpC.searchCat(temp.getSav()), temp.getObjName()) != null)
-            cgC.deleteObject(temp.getSav(), temp.getObjName());
+        if (mpC.searchCatObj(mpC.searchCat(temp.getSav()), temp.getName()) != null)
+            cgC.deleteObject(temp.getSav(), temp.getName());
         cgC.addObject(mpC.searchCat(temp.getSav()), temp);
         cgC.addObject(mpC.searchCat(temp.getSav()), temp);
 
 
     }
     }
@@ -267,6 +264,11 @@ public class LoadController {
         	flex.constrainList.forEach(con -> con.fixJson());
         	flex.constrainList.forEach(con -> con.fixJson());
         	
         	
         });
         });
+        //Fix old amount
+        JsonElement amount = object.get("properties").getAsJsonObject().get("amount");
+        if(amount != null) {
+        	ele.setEnergyPerElement(amount.getAsInt() * ele.getEnergy());
+        }
         objC.addElementIntoCategoryObject(ele.getSaving().getKey(), ele.getSaving().getValue(), ele);
         objC.addElementIntoCategoryObject(ele.getSaving().getKey(), ele.getSaving().getValue(), ele);
     }
     }
 
 
@@ -286,7 +288,6 @@ public class LoadController {
         temp.setImage(checkOS(temp.getImage()));
         temp.setImage(checkOS(temp.getImage()));
         if (temp instanceof GroupNode) {
         if (temp instanceof GroupNode) {
             model.getHashcodeMap().put(jsonObject.get("hash").getAsInt(), (GroupNode) temp);
             model.getHashcodeMap().put(jsonObject.get("hash").getAsInt(), (GroupNode) temp);
-            ((GroupNode) temp).setLeftBorder(jsonObject.get("properties").getAsJsonObject().get("leftBorder").getAsInt());
         }
         }
         // if its stored before on the canvas just put it there
         // if its stored before on the canvas just put it there
         if (temp.getSav().equals("CVS")) {
         if (temp.getSav().equals("CVS")) {
@@ -336,7 +337,11 @@ public class LoadController {
         	
         	
         });
         });
         
         
-        
+        //Fix old amount
+        JsonElement amount = object.get("properties").getAsJsonObject().get("amount");
+        if(amount != null) {
+        	ele.setEnergyPerElement(amount.getAsInt() * ele.getEnergy());
+        }
         // id which Object it was stored before
         // id which Object it was stored before
         int stored = object.get("ID").getAsInt();
         int stored = object.get("ID").getAsInt();
         // lookup that object
         // lookup that object
@@ -386,7 +391,6 @@ public class LoadController {
         }  
         }  
         
         
        
        
-
         switch (type) {
         switch (type) {
             case SWITCH:
             case SWITCH:
                 HolonSwitch sw = (HolonSwitch) objDispatch.get(sav);
                 HolonSwitch sw = (HolonSwitch) objDispatch.get(sav);
@@ -394,9 +398,6 @@ public class LoadController {
                 sw.sampleGraph();
                 sw.sampleGraph();
                 break;
                 break;
             case ELEMENT:
             case ELEMENT:
-            	System.out.println("Write me new");
-            	break;
-            case TESTELEMENT:
                 HolonElement ele1 = eleDispatch.get(sav);
                 HolonElement ele1 = eleDispatch.get(sav);
                 ele1.setGraphPoints(graphpointTEST);
                 ele1.setGraphPoints(graphpointTEST);
                 ele1.sampleGraph();
                 ele1.sampleGraph();
@@ -406,19 +407,6 @@ public class LoadController {
         }
         }
     }
     }
 
 
-    private void loadTracked(JsonElement jsonElement, HashMap<Integer, AbstractCanvasObject> objDispatch) {
-        JsonObject object = jsonElement.getAsJsonObject();
-        List<String> keys = getKeys(object);
-
-        for (String k : keys) {
-            int id = object.get(k).getAsInt();
-            if (objDispatch.get(id) instanceof HolonObject) {
-                ((HolonObject) objDispatch.get(id)).updateTrackingInfo();
-            }
-        }
-
-    }
-
     private File readArchive(File src) throws IOException, ArchiveException {
     private File readArchive(File src) throws IOException, ArchiveException {
         File tmp = Files.createTempDirectory("tmpHolon").toFile();
         File tmp = Files.createTempDirectory("tmpHolon").toFile();
         tmp.deleteOnExit();
         tmp.deleteOnExit();
@@ -507,6 +495,9 @@ public class LoadController {
         ele.flexList = new ArrayList<Flexibility>();
         ele.flexList = new ArrayList<Flexibility>();
         ele.setGraphPoints(new LinkedList<>());
         ele.setGraphPoints(new LinkedList<>());
         ele.reset();
         ele.reset();
+        if(ele.getPriority() == null) {
+        	ele.setPriority(Priority.Low);
+        }
     }
     }
 
 
     /**
     /**
@@ -542,7 +533,7 @@ public class LoadController {
     }
     }
 
 
     public enum GRAPHTYPE {
     public enum GRAPHTYPE {
-        SWITCH, ELEMENT, TESTELEMENT
+        SWITCH, ELEMENT
     }
     }
 
 
 }
 }

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

@@ -9,6 +9,7 @@ import utility.Vector2Int;
 
 
 import java.awt.*;
 import java.awt.*;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.LinkedList;
 import java.util.LinkedList;
 
 
 
 
@@ -128,11 +129,8 @@ class NodeController {
 	/**
 	/**
 	 * Calculate new Position of the Upper Node
 	 * Calculate new Position of the Upper Node
 	 */
 	 */
-    Vector2Int calculatePos(ArrayList<AbstractCanvasObject> toGroup) {
-
+    Vector2Int calculatePos(Collection<AbstractCanvasObject> toGroup) {
 		Vector2Int pos = new Vector2Int(0, 0);
 		Vector2Int pos = new Vector2Int(0, 0);
-
-		// sum(x0 .. xn) / numOfPos, y analog
 		for (AbstractCanvasObject abs : toGroup) {
 		for (AbstractCanvasObject abs : toGroup) {
 			pos = pos.add(abs.getPosition());
 			pos = pos.add(abs.getPosition());
 		}
 		}
@@ -248,9 +246,8 @@ class NodeController {
 			}
 			}
 			
 			
 			/** if edge from an object to itself -> remove it */
 			/** if edge from an object to itself -> remove it */
-			if(e.getA() == e.getB())
-				;//TODO Delte me if not nessesary
-			else/** else add edge to 'by' */
+			/** else add edge to 'by' */
+			if(e.getA() != e.getB())
 				by.addConnection(e);
 				by.addConnection(e);
 		}
 		}
 		/** delete 'toBeReplaced' new empty connections, to prevent Nullpointer*/
 		/** delete 'toBeReplaced' new empty connections, to prevent Nullpointer*/
@@ -274,8 +271,8 @@ class NodeController {
 		if (y < 0)
 		if (y < 0)
 			y = 0 + model.getScaleDiv2() + 1;
 			y = 0 + model.getScaleDiv2() + 1;
 		if (upperNode != null) {
 		if (upperNode != null) {
-			if (x < upperNode.getLeftBorder() + model.getScaleDiv2() + 1)
-				x = upperNode.getLeftBorder() + model.getScaleDiv2() + 1;
+			if (x < model.getScaleDiv2() + 1)
+				x = model.getScaleDiv2() + 1;
 		} else if (x < 0)
 		} else if (x < 0)
 			x = 0 + model.getScaleDiv2() + 1;
 			x = 0 + model.getScaleDiv2() + 1;
 		if (x > model.getCanvasX())
 		if (x > model.getCanvasX())

+ 188 - 187
src/ui/controller/ObjectController.java

@@ -1,9 +1,14 @@
 package ui.controller;
 package ui.controller;
 
 
-import classes.*;
-import ui.model.Model;
-
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Collection;
+
+import classes.AbstractCanvasObject;
+import classes.GroupNode;
+import classes.HolonElement;
+import classes.HolonObject;
+import classes.Pair;
+import ui.model.Model;
 
 
 /**
 /**
  * Controller for Objects.
  * Controller for Objects.
@@ -12,188 +17,184 @@ import java.util.ArrayList;
  */
  */
 public class ObjectController {
 public class ObjectController {
 
 
-    private Model model;
-    private MultiPurposeController mpC;
-
-    /**
-     * Constructor.
-     *
-     * @param model Model
-     * @param mp    MultiPurposeController
-     */
-    public ObjectController(Model model, MultiPurposeController mp) {
-        this.model = model;
-        this.mpC = mp;
-        initHolonElements();
-    }
-
-    /**
-     * init default Power supply of the Power Plant.
-     */
-    public void initHolonElements() {
-        addNewElementIntoCategoryObject("Energy", "Power Plant", "Power", 1, 10000);
-        addNewElementIntoCategoryObject("Building", "House", "TV", 2, -250);
-        addNewElementIntoCategoryObject("Building", "House", "Fridge", 1, -500);
-        addNewElementIntoCategoryObject("Building", "House", "Radio", 1, -100);
-        addNewElementIntoCategoryObject("Building", "House", "PC", 3, -250);
-        addNewElementIntoCategoryObject("Building", "House", "Light", 5, -50);
-        addNewElementIntoCategoryObject("Building", "House", "Solar Panels", 1, 300);
-    }
-
-    /**
-     * Adds Element into a Object.
-     *
-     * @param object  the Object
-     * @param element the Element
-     */
-    public void addElement(HolonObject object, HolonElement element) {
-        object.addElement(element);
-    }
-
-    /**
-     * Adds Element into a Object on the Canvas.
-     *
-     * @param object  the Object
-     * @param element the Element
-     */
-    public void addElementIntoCanvasObject(HolonObject object, HolonElement element) {
-        element.setSaving(null);
-        addElement(object, element);
-    }
-
-    /**
-     * Add a new Element into a Object on the Canvas.
-     *
-     * @param objectId  the Object ID
-     * @param element   the Name of the Element
-     * @param amount    the Amount
-     * @param energy    the Energy
-     * @param elementId the Element ID
-     */
-    public void addNewElementIntoCanvasObject(int objectId, String element, int amount, float energy, int elementId) {
-    	HolonObject hObject;
-    	if (mpC.searchByID(objectId) == null) {
-        	hObject = (HolonObject) model.getSelectedCpsObjects().get(0);
-        } else {
-        	hObject = ((HolonObject) mpC.searchByID(objectId));
-        }
-        HolonElement ele = new HolonElement(hObject, element, amount, energy, elementId);
-        addElementIntoCanvasObject(hObject, ele);
-    }
-
-    /**
-     * Add Element into a Object in Category.
-     *
-     * @param category the Category
-     * @param object   the Object
-     * @param element  the Element
-     */
-    public void addElementIntoCategoryObject(String category, String object, HolonElement element) {
-        element.setSaving(new Pair<>(category, object));
-        addElement((HolonObject) mpC.searchCatObj(mpC.searchCat(category), object), element);
-    }
-
-    /**
-     * Add a new Element into a Object in Category.
-     *
-     * @param category the Category
-     * @param object   the Object
-     * @param element  the Element Name
-     * @param energy   the Energy
-     * @param amount   the amount
-     */
-    public void addNewElementIntoCategoryObject(String category, String object, String element, int amount,
-                                                float energy) {
-
-        HolonElement ele = new HolonElement((HolonObject) mpC.searchCatObj(mpC.searchCat(category), object),element, amount, energy);
-        addElementIntoCategoryObject(category, object, ele);
-    }
-
-    /**
-     * deletes a Element from a given Object.
-     *
-     * @param obj the Oject
-     * @param ele the Element
-     */
-    public void deleteElement(HolonObject obj, HolonElement ele) {
-        obj.getElements().remove(ele);
-    }
-
-    /**
-     * deletes a selectedObject.
-     *
-     * @param obj Cpsobject
-     */
-    public void deleteSelectedObject(AbstractCanvasObject obj) {
-        model.getSelectedCpsObjects().remove(obj);
-    }
-
-    /**
-     * add an Object to selectedObject.
-     *
-     * @param obj AbstractCpsobject
-     */
-    public void addSelectedObject(AbstractCanvasObject obj) {
-        model.getSelectedCpsObjects().add(obj);
-    }
-
-    /**
-     * deletes a Element from a given Canvas Object.
-     *
-     * @param id    the ID
-     * @param eleid the Element ID
-     */
-    public void deleteElementInCanvas(int id, int eleid) {
-        HolonObject object = (HolonObject) mpC.searchByID(id);
-        if (object == null) {
-            object = (HolonObject) model.getSelectedCpsObjects().get(0);
-        }
-        HolonElement element = mpC.searchEleById(object, eleid);
-        deleteElement(object, element);
-    }
-
-    /**
-     * Returns the ID of the selected Object 0 = no Object is selected.
-     *
-     * @param id the ID of the selected Object
-     */
-    public void setSelectedObjectID(int id) {
-        model.setSelectedObjectID(id);
-    }
-
-    /**
-     * Get the number of HolonObjects in the given List
-     *
-     * @param list
-     */
-    public int getNumberHolonObjects(ArrayList<AbstractCanvasObject> list) {
-        int val = 0;
-
-        for (AbstractCanvasObject obj : list) {
-            if (obj instanceof HolonObject) {
-                val++;
-            } else if (obj instanceof GroupNode) {
-                val += getNumberHolonObjects(((GroupNode) obj).getNodes());
-            }
-        }
-        return val;
-    }
-/**
- * Helper added by Rolf TODO: macht hier vll keinen Sinn...
- */
-    public ArrayList<HolonObject> getAllHolonObjects(ArrayList<AbstractCanvasObject> list){
-    	ArrayList<HolonObject> allObj = new ArrayList<HolonObject>();
-    	
-    	for (AbstractCanvasObject obj : list) {
-            if (obj instanceof HolonObject) {
-                allObj.add((HolonObject)obj);
-            } else if (obj instanceof GroupNode) {
-                 allObj.addAll(getAllHolonObjects(((GroupNode) obj).getNodes()));
-            }
-        }
-    	
-    	
-    	return allObj;
-    }
-   
+	private Model model;
+	private MultiPurposeController mpC;
+
+	/**
+	 * Constructor.
+	 *
+	 * @param model Model
+	 * @param mp    MultiPurposeController
+	 */
+	public ObjectController(Model model, MultiPurposeController mp) {
+		this.model = model;
+		this.mpC = mp;
+		initHolonElements();
+	}
+
+	/**
+	 * init default Power supply of the Power Plant.
+	 */
+	public void initHolonElements() {
+		addNewElementIntoCategoryObject("Energy", "Power Plant", "Power", 10000);
+		addNewElementIntoCategoryObject("Building", "House", "TV", -250);
+		addNewElementIntoCategoryObject("Building", "House", "TV", -250);
+		addNewElementIntoCategoryObject("Building", "House", "Fridge", -500);
+		addNewElementIntoCategoryObject("Building", "House", "Radio", -100);
+		addNewElementIntoCategoryObject("Building", "House", "PC", -250);
+		addNewElementIntoCategoryObject("Building", "House", "PC", -250);
+		addNewElementIntoCategoryObject("Building", "House", "PC", -250);
+		addNewElementIntoCategoryObject("Building", "House", "Light", -50);
+		addNewElementIntoCategoryObject("Building", "House", "Light", -50);
+		addNewElementIntoCategoryObject("Building", "House", "Light", -50);
+		addNewElementIntoCategoryObject("Building", "House", "Light", -50);
+		addNewElementIntoCategoryObject("Building", "House", "Light", -50);
+		addNewElementIntoCategoryObject("Building", "House", "Solar Panels", 300);
+	}
+
+	/**
+	 * Adds Element into a Object.
+	 *
+	 * @param object  the Object
+	 * @param element the Element
+	 */
+	public void addElement(HolonObject object, HolonElement element) {
+		object.addElement(element);
+	}
+
+	/**
+	 * Adds Element into a Object on the Canvas.
+	 *
+	 * @param object  the Object
+	 * @param element the Element
+	 */
+	public void addElementIntoCanvasObject(HolonObject object, HolonElement element) {
+		element.setSaving(null);
+		addElement(object, element);
+	}
+
+	/**
+	 * Add a new Element into a Object on the Canvas.
+	 *
+	 * @param objectId  the Object ID
+	 * @param element   the Name of the Element
+	 * @param amount    the Amount
+	 * @param energy    the Energy
+	 * @param elementId the Element ID
+	 */
+	public void addNewElementIntoCanvasObject(int objectId, String element, float energy, int elementId) {
+		HolonObject hObject = (HolonObject) mpC.searchByID(objectId);
+		if (hObject == null) {
+			hObject = (HolonObject) model.getSelectedObjects().stream().findFirst().get();
+		}
+		HolonElement ele = new HolonElement(hObject, element, energy, elementId);
+		addElementIntoCanvasObject(hObject, ele);
+	}
+
+	/**
+	 * Add Element into a Object in Category.
+	 *
+	 * @param category the Category
+	 * @param object   the Object
+	 * @param element  the Element
+	 */
+	public void addElementIntoCategoryObject(String category, String object, HolonElement element) {
+		element.setSaving(new Pair<>(category, object));
+		addElement((HolonObject) mpC.searchCatObj(mpC.searchCat(category), object), element);
+	}
+
+	/**
+	 * Add a new Element into a Object in Category.
+	 *
+	 * @param category the Category
+	 * @param object   the Object
+	 * @param element  the Element Name
+	 * @param energy   the Energy
+	 */
+	public void addNewElementIntoCategoryObject(String category, String object, String element, float energy) {
+
+		HolonElement ele = new HolonElement((HolonObject) mpC.searchCatObj(mpC.searchCat(category), object), element,
+				energy);
+		addElementIntoCategoryObject(category, object, ele);
+	}
+
+	/**
+	 * deletes a Element from a given Object.
+	 *
+	 * @param obj the Oject
+	 * @param ele the Element
+	 */
+	public void deleteElement(HolonObject obj, HolonElement ele) {
+		obj.getElements().remove(ele);
+	}
+
+	/**
+	 * deletes a selectedObject.
+	 *
+	 * @param obj Cpsobject
+	 */
+	public void removeObjectFromSelection(AbstractCanvasObject obj) {
+		model.getSelectedObjects().remove(obj);
+	}
+
+	/**
+	 * add an Object to selectedObject.
+	 *
+	 * @param obj AbstractCpsobject
+	 */
+	public void addSelectedObject(AbstractCanvasObject obj) {
+		model.getSelectedObjects().add(obj);
+	}
+
+	/**
+	 * add an Object to selectedObject.
+	 *
+	 * @param obj AbstractCpsobject
+	 */
+	public void addSelectedObjects(Collection<AbstractCanvasObject> objects) {
+		model.getSelectedObjects().addAll(objects);
+	}
+
+	/**
+	 * deletes a Element from a given Canvas Object.
+	 *
+	 * @param id    the ID
+	 * @param eleid the Element ID
+	 */
+	public void deleteElementInCanvas(int id, int eleid) {
+		HolonObject hObject = (HolonObject) mpC.searchByID(id);
+		if (hObject == null) {
+			hObject = (HolonObject) model.getSelectedObjects().stream().findFirst().get();
+		}
+		HolonElement element = mpC.searchEleById(hObject, eleid);
+		deleteElement(hObject, element);
+	}
+
+	/**
+	 * Returns the ID of the selected Object 0 = no Object is selected.
+	 *
+	 * @param id the ID of the selected Object
+	 */
+	public void setSelectedObjectID(int id) {
+		model.setSelectedObjectID(id);
+	}
+
+	/**
+	 * Get the number of HolonObjects in the given List
+	 *
+	 * @param list
+	 */
+	public int getNumberHolonObjects(ArrayList<AbstractCanvasObject> list) {
+		int val = 0;
+
+		for (AbstractCanvasObject obj : list) {
+			if (obj instanceof HolonObject) {
+				val++;
+			} else if (obj instanceof GroupNode) {
+				val += getNumberHolonObjects(((GroupNode) obj).getNodes());
+			}
+		}
+		return val;
+	}
+
 }
 }

+ 2 - 1
src/ui/controller/SimulationManager.java

@@ -55,7 +55,8 @@ public class SimulationManager {
 	 *
 	 *
 	 * @param timestep
 	 * @param timestep
 	 *            current Iteration
 	 *            current Iteration
-	 * @param updateVisual TODO
+	 * @param updateVisual 
+	 * Determine if the Visuals should also be calculated
 	 */
 	 */
 	public void calculateStateForTimeStep(int timestep, boolean updateVisual) {
 	public void calculateStateForTimeStep(int timestep, boolean updateVisual) {
 		boolean doesFlexManagerExist = savesFlexManger.containsKey(timestep);
 		boolean doesFlexManagerExist = savesFlexManger.containsKey(timestep);

+ 8 - 118
src/ui/controller/UpdateController.java

@@ -1,12 +1,6 @@
 package ui.controller;
 package ui.controller;
 
 
 import classes.*;
 import classes.*;
-import classes.comparator.elementComparator.ElemCompOnEleName;
-import classes.comparator.elementComparator.ElemCompOnEnergy;
-import classes.comparator.elementComparator.ElemCompOnId;
-import classes.comparator.elementComparator.ElemCompOnIsActivated;
-import classes.comparator.elementComparator.ElemCompOnObj;
-import classes.comparator.elementComparator.ElemCompOnQuantity;
 import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.Model;
 import ui.model.Model;
@@ -16,7 +10,6 @@ import ui.view.GroupNodeCanvas;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
-import java.util.LinkedList;
 
 
 /**
 /**
  * This class is for all update methods and more ;)
  * This class is for all update methods and more ;)
@@ -27,133 +20,32 @@ import java.util.LinkedList;
 public class UpdateController {
 public class UpdateController {
 
 
 	Model model;
 	Model model;
-	Control controller;
-	private int sortBy;
+	Control controller;;
 
 
 	public UpdateController(Model model, Control control) {
 	public UpdateController(Model model, Control control) {
 		this.model = model;
 		this.model = model;
 		this.controller = control;
 		this.controller = control;
-		sortBy= 1;
 	}
 	}
 
 
 	/**
 	/**
 	 * Update the information concerning properties of the selected CpsObject.
 	 * Update the information concerning properties of the selected CpsObject.
 	 */
 	 */
 	public void refreshTableProperties(DefaulTable table) {
 	public void refreshTableProperties(DefaulTable table) {
-		if (model.getSelectedCpsObjects().size() == 1) {
-			AbstractCanvasObject tempCps = model.getSelectedCpsObjects().get(0);
+		if (model.getSelectedObjects().size() == 1) {
+			AbstractCanvasObject tempCps = model.getSelectedObjects().stream().findFirst().get();
 			if (tempCps != null && tempCps.getClass() == HolonObject.class) {
 			if (tempCps != null && tempCps.getClass() == HolonObject.class) {
 				if (table.getRowCount() != 0) {
 				if (table.getRowCount() != 0) {
 					table.removeRow(2);
 					table.removeRow(2);
 					Object[] tempEnergy = { "Total Energy", ((HolonObject) tempCps).getEnergyNeededFromConsumingElements(model.getCurIteration()) };
 					Object[] tempEnergy = { "Total Energy", ((HolonObject) tempCps).getEnergyNeededFromConsumingElements(model.getCurIteration()) };
 					table.insertRow(2, tempEnergy);
 					table.insertRow(2, tempEnergy);
-					table.removeRow(3);
-					Object[] tempFlex = { "Flexibility", ((HolonObject) tempCps).getTotalFlex() };
-					table.insertRow(3, tempFlex);
 				}
 				}
 			}
 			}
 		}
 		}
 	}
 	}
 
 
 	    
 	    
-	/**
-	 * Add the Information of the given ArrayList in the HolonElement Model as
-	 * Name,Energy and Amount.
-	 * 
-	 * @param objects
-	 *            ArrayList to be displayed
-	 */
-	public void fillElementTable(ArrayList<AbstractCanvasObject> objects, PropertyTable table) {
-		LinkedList<HolonElement> elemList = new LinkedList<HolonElement>();
-		
-		if (objects.size() > 1) {
-			for (AbstractCanvasObject o : objects) {
-				if (o instanceof HolonObject) {
-					for (HolonElement he : ((HolonObject) o).getElements()) {
-						he.setObjName(o.getName() + ", " + o.getId());
-						elemList.add(he);
-						elemList=sortElemList(elemList);
-					}
-				}
-			}
-			for (HolonElement e1 : elemList) {
-				Object[] temp2 = { e1.getObjName(), e1.getId(), e1.getEleName(), e1.getEnergyPerElement(),
-						controller.getSimManager().getActualFlexManager().isAFlexInUseOfHolonElement(e1), e1.getAmount(), e1.isActive()};
-				table.addRow(temp2);
-			}
 
 
-		} else if (objects.size() == 1) {
-			AbstractCanvasObject o = objects.get(0);
-			if (o instanceof HolonObject) {
-				for (HolonElement he : ((HolonObject) o).getElements()) {
-					elemList.add(he);
-					elemList=sortElemList(elemList);
-				}
-				
-				for (HolonElement e1 : elemList) {
-					Object[] temp2 = { e1.getId(), e1.getEleName(), e1.getEnergyPerElement(),
-							controller.getSimManager().getActualFlexManager().isAFlexInUseOfHolonElement(e1), e1.getAmount(), e1.isActive()};
-					table.addRow(temp2);
-				}
-			}
-		}
-	}
-	
-	/**
-	 * @param elemList - HolonElement-List (unsorted)
-	 * @return sorted HolonElement-List! 
-	 */
-	public LinkedList<HolonElement> sortElemList(LinkedList<HolonElement> elemList) {
-		switch(sortBy) {
-		case 0://"Object": 
-			elemList.sort(new ElemCompOnObj());
-			break;
-		case 1://ID
-			elemList.sort(new ElemCompOnId());
-			break;
-		case 2://"Device": 
-			elemList.sort(new ElemCompOnEleName());
-			break;
-		case 3://"Energy": 
-			elemList.sort(new ElemCompOnEnergy());
-			break;
-		case 4://"Flexible Energy Available": 
-			elemList.sort(null);
-			break;
-		case 5://"Quantity": 
-			elemList.sort(new ElemCompOnQuantity());
-			break;
-		case 6://"Activated": 
-			elemList.sort(new ElemCompOnIsActivated());
-			break;
-		case 7://"Flexible": 
-			elemList.sort(null);
-			break;
-		default: 
-			elemList.sort(new ElemCompOnId());
-			break;
-		}
-		return elemList;
-	};
 
 
-	/**
-	 * Update the HolonElement Table, that means erase all rows and add the new
-	 * rows with new data.
-	 */
-	public void refreshTableHolonElement(PropertyTable multiTable, PropertyTable singleTable) {
-		// Update of the Information about the HolonElements - only for
-		// HolonObjects
-		if(multiTable == null || singleTable == null ) return;
-		if (model.getSelectedCpsObjects().size() > 1) {
-			deleteRows(multiTable);
-			fillElementTable(model.getSelectedCpsObjects(), multiTable);
-			multiTable.fireTableDataChanged();
-		} else if (model.getSelectedCpsObjects().size() == 1) {
-			deleteRows(singleTable);
-			fillElementTable(model.getSelectedCpsObjects(), singleTable);
-			singleTable.fireTableDataChanged();
-		}
-	}
 
 
 	/**
 	/**
 	 * Erase all information of the HolonElement Model.
 	 * Erase all information of the HolonElement Model.
@@ -218,7 +110,7 @@ public class UpdateController {
 			if (obj == null) {
 			if (obj == null) {
 				String tempStringObj = tables.get(1).getValueAt(yTemp, 0).toString();
 				String tempStringObj = tables.get(1).getValueAt(yTemp, 0).toString();
 				int idTempObj = Integer.parseInt(tempStringObj.split(", ")[1]);
 				int idTempObj = Integer.parseInt(tempStringObj.split(", ")[1]);
-				if (model.getSelectedCpsObjects() != null) {
+				if (model.getSelectedObjects() != null) {
 					obtTemp = (HolonObject) getHolonObjSelected(idTempObj);
 					obtTemp = (HolonObject) getHolonObjSelected(idTempObj);
 				}
 				}
 				id = Integer.parseInt(tables.get(1).getValueAt(yTemp, 1).toString());
 				id = Integer.parseInt(tables.get(1).getValueAt(yTemp, 1).toString());
@@ -262,8 +154,8 @@ public class UpdateController {
 	 */
 	 */
 	public AbstractCanvasObject getActualCps() {
 	public AbstractCanvasObject getActualCps() {
         AbstractCanvasObject tempCps;
         AbstractCanvasObject tempCps;
-        if (model.getSelectedCpsObjects().size() == 1) {
-			tempCps = model.getSelectedCpsObjects().get(0);
+        if (model.getSelectedObjects().size() == 1) {
+			tempCps = model.getSelectedObjects().stream().findFirst().get();
 		} else {
 		} else {
 			int tempID = model.getSelectedObjectID();
 			int tempID = model.getSelectedObjectID();
 			tempCps = controller.searchByID(tempID);
 			tempCps = controller.searchByID(tempID);
@@ -293,11 +185,9 @@ public class UpdateController {
 			// For HolonObjects the Total Energy (production or
 			// For HolonObjects the Total Energy (production or
 			// consumption) is calculated
 			// consumption) is calculated
 			if (obj instanceof HolonObject) {
 			if (obj instanceof HolonObject) {
-				refreshTableHolonElement(model.getMultiTable(), model.getSingleTable());
+				
 				Object[] tempEnergy = { "Total Energy", ((HolonObject) obj).getEnergyNeededFromConsumingElements(model.getCurIteration()) };
 				Object[] tempEnergy = { "Total Energy", ((HolonObject) obj).getEnergyNeededFromConsumingElements(model.getCurIteration()) };
-				Object[] tempFlex = { "Flexibility", ((HolonObject) obj).getTotalFlex() };
 				model.getPropertyTable().addRow(tempEnergy);
 				model.getPropertyTable().addRow(tempEnergy);
-				model.getPropertyTable().addRow(tempFlex);
 				model.getPropertyTable().setCellEditable(0, 1, false);
 				model.getPropertyTable().setCellEditable(0, 1, false);
 				model.getPropertyTable().setCellEditable(2, 1, false);
 				model.getPropertyTable().setCellEditable(2, 1, false);
 				model.getPropertyTable().setCellEditable(3, 1, false);
 				model.getPropertyTable().setCellEditable(3, 1, false);
@@ -448,7 +338,7 @@ public class UpdateController {
 
 
 	public AbstractCanvasObject getHolonObjSelected(int id) {
 	public AbstractCanvasObject getHolonObjSelected(int id) {
 		AbstractCanvasObject obj = null;
 		AbstractCanvasObject obj = null;
-		for (AbstractCanvasObject o : model.getSelectedCpsObjects()) {
+		for (AbstractCanvasObject o : model.getSelectedObjects()) {
 			if (o.getId() == id) {
 			if (o.getId() == id) {
 				obj = o;
 				obj = o;
 				break;
 				break;

+ 1 - 1
src/ui/model/MinimumNetwork.java

@@ -24,7 +24,7 @@ public class MinimumNetwork {
 	{
 	{
 		String objecte = "[";
 		String objecte = "[";
 		for(HolonObject object :holonObjectList) {
 		for(HolonObject object :holonObjectList) {
-			objecte += " " + object.getObjName();
+			objecte += " " + object.getName();
 		}
 		}
 		objecte += "]";
 		objecte += "]";
 		String edges = "[";
 		String edges = "[";

+ 9 - 29
src/ui/model/Model.java

@@ -3,8 +3,10 @@ package ui.model;
 import java.awt.Color;
 import java.awt.Color;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 import javax.swing.JTable;
 import javax.swing.JTable;
@@ -54,16 +56,13 @@ public class Model {
     private int canvasY = 3000;
     private int canvasY = 3000;
     private int curIteration = 0;
     private int curIteration = 0;
     // ID of the Selected Object
     // ID of the Selected Object
-    private AbstractCanvasObject selectedCpsObject = null;
     private HolonElement selectedHolonElement;
     private HolonElement selectedHolonElement;
     private Edge selectedEdge;
     private Edge selectedEdge;
-    private ArrayList<AbstractCanvasObject> selectedObjects = new ArrayList<>();
-    private ArrayList<AbstractCanvasObject> clipboardObjects = new ArrayList<>();
+    private Set<AbstractCanvasObject> selectedObjects = new HashSet<>();
+    private Set<AbstractCanvasObject> clipboardObjects = new HashSet<>();
     private HashMap<Integer, ArrayList<HolonElement>> eleToDelete;
     private HashMap<Integer, ArrayList<HolonElement>> eleToDelete;
     // Capacity for Edge
     // Capacity for Edge
     private float maxCapacity;
     private float maxCapacity;
-    // Table for HolonElements --> all cells are editable
-    private JTable tableHolonElement;
     /** Table for the properties of HolonObjects, Edges etc */
     /** Table for the properties of HolonObjects, Edges etc */
     private JTable propertyTable;
     private JTable propertyTable;
     
     
@@ -77,7 +76,7 @@ public class Model {
     private int numberOfSaves = 35;
     private int numberOfSaves = 35;
     /** whether the supplyBars should be shown or not */
     /** whether the supplyBars should be shown or not */
     private boolean showSupplyBars = true;
     private boolean showSupplyBars = true;
-    //TODO:
+    /** the amount of iterations */
     private int iterations=100;
     private int iterations=100;
     
     
     /**
     /**
@@ -145,7 +144,6 @@ public class Model {
         setObjectListeners(new LinkedList<>());
         setObjectListeners(new LinkedList<>());
         setCgIdx(new HashMap<>());
         setCgIdx(new HashMap<>());
         setCvsObjIdx(new HashMap<>());
         setCvsObjIdx(new HashMap<>());
-        setClipboradObjects(new ArrayList<>());
         setEleToDelete(new HashMap<>());
         setEleToDelete(new HashMap<>());
         setSingleTable(new PropertyTable());
         setSingleTable(new PropertyTable());
         setMultiTable(new PropertyTable());
         setMultiTable(new PropertyTable());
@@ -280,30 +278,12 @@ public class Model {
         this.selectedID = id;
         this.selectedID = id;
     }
     }
 
 
-    /**
-     * Returns the Selected Cps Object.
-     *
-     * @return selected Cps Object
-     */
-    public AbstractCanvasObject getSelectedCpsObject() {
-        return selectedCpsObject;
-    }
-
-    /**
-     * Set the Selected Objecs.
-     *
-     * @param selectedCpsObject Objects that are selected
-     */
-    public void setSelectedCpsObject(AbstractCanvasObject selectedCpsObject) {
-        this.selectedCpsObject = selectedCpsObject;
-    }
-
     /**
     /**
      * Returns all selected Objects on the Canvas.
      * Returns all selected Objects on the Canvas.
      *
      *
      * @return The selected Objects
      * @return The selected Objects
      */
      */
-    public ArrayList<AbstractCanvasObject> getSelectedCpsObjects() {
+    public Set<AbstractCanvasObject> getSelectedObjects() {
         return selectedObjects;
         return selectedObjects;
     }
     }
 
 
@@ -312,7 +292,7 @@ public class Model {
      *
      *
      * @return The selected Objects
      * @return The selected Objects
      */
      */
-    public void setSelectedCpsObjects(ArrayList<AbstractCanvasObject> arr) {
+    public void setSelectedCpsObjects(Set<AbstractCanvasObject> arr) {
         this.selectedObjects = arr;
         this.selectedObjects = arr;
     }
     }
 
 
@@ -495,7 +475,7 @@ public class Model {
      *
      *
      * @return Objects in the Clipboard
      * @return Objects in the Clipboard
      */
      */
-    public ArrayList<AbstractCanvasObject> getClipboradObjects() {
+    public Set<AbstractCanvasObject> getClipboradObjects() {
         return clipboardObjects;
         return clipboardObjects;
     }
     }
 
 
@@ -504,7 +484,7 @@ public class Model {
      *
      *
      * @param c Array of Objects
      * @param c Array of Objects
      */
      */
-    public void setClipboradObjects(ArrayList<AbstractCanvasObject> c) {
+    public void setClipboradObjects(Set<AbstractCanvasObject> c) {
         this.clipboardObjects = c;
         this.clipboardObjects = c;
     }
     }
 
 

+ 76 - 79
src/ui/view/AbstractCanvas.java

@@ -8,14 +8,14 @@ import java.awt.Image;
 import java.awt.Point;
 import java.awt.Point;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseEvent;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.List;
+import java.util.Set;
 import java.util.TimerTask;
 import java.util.TimerTask;
 
 
-import javax.swing.CellEditor;
 import javax.swing.JMenuItem;
 import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.JPopupMenu;
-import javax.swing.JTable;
 import javax.swing.Timer;
 import javax.swing.Timer;
 
 
 import classes.AbstractCanvasObject;
 import classes.AbstractCanvasObject;
@@ -43,7 +43,7 @@ public abstract class AbstractCanvas extends JPanel {
 	 * Version
 	 * Version
 	 */
 	 */
 	private static final long serialVersionUID = 1L;
 	private static final long serialVersionUID = 1L;
-	
+
 	final JMenuItem itemCut = new JMenuItem("Cut");
 	final JMenuItem itemCut = new JMenuItem("Cut");
 	final JMenuItem itemCopy = new JMenuItem("Copy");
 	final JMenuItem itemCopy = new JMenuItem("Copy");
 	final JMenuItem itemPaste = new JMenuItem("Paste");
 	final JMenuItem itemPaste = new JMenuItem("Paste");
@@ -52,7 +52,7 @@ public abstract class AbstractCanvas extends JPanel {
 	final JMenuItem itemUngroup = new JMenuItem("Ungroup");
 	final JMenuItem itemUngroup = new JMenuItem("Ungroup");
 	final JMenuItem itemAlign = new JMenuItem("Align selected");
 	final JMenuItem itemAlign = new JMenuItem("Align selected");
 	final JMenuItem itemCreateTemplate = new JMenuItem("Create Template");
 	final JMenuItem itemCreateTemplate = new JMenuItem("Create Template");
-	
+
 	final int ANIMTIME = 500; // animation Time
 	final int ANIMTIME = 500; // animation Time
 	private final int animFPS = 60;
 	private final int animFPS = 60;
 	final int animDelay = 1000 / animFPS; // animation Delay
 	final int animDelay = 1000 / animFPS; // animation Delay
@@ -63,13 +63,13 @@ public abstract class AbstractCanvas extends JPanel {
 	// Selection
 	// Selection
 	AbstractCanvasObject tempCps = null;
 	AbstractCanvasObject tempCps = null;
 	UpdateController updCon;
 	UpdateController updCon;
-	
-	//Replacement
+
+	// Replacement
 	/**
 	/**
 	 * the CpsObject that might be replaced by drag&drop
 	 * the CpsObject that might be replaced by drag&drop
 	 */
 	 */
 	protected AbstractCanvasObject mayBeReplaced = null;
 	protected AbstractCanvasObject mayBeReplaced = null;
-	
+
 	// PopUpMenu
 	// PopUpMenu
 	JPopupMenu popmenu = new JPopupMenu();
 	JPopupMenu popmenu = new JPopupMenu();
 	// Tooltip
 	// Tooltip
@@ -77,7 +77,7 @@ public abstract class AbstractCanvas extends JPanel {
 	Vector2Int toolTipPos = new Vector2Int(); // Tooltip Position
 	Vector2Int toolTipPos = new Vector2Int(); // Tooltip Position
 	String toolTipText = "";
 	String toolTipText = "";
 	List<HolonElement> dataSelected = new ArrayList<>();
 	List<HolonElement> dataSelected = new ArrayList<>();
-	ArrayList<AbstractCanvasObject> tempSelected = new ArrayList<>();
+	protected Set<AbstractCanvasObject> tempSelected = new HashSet<>();
 	boolean showConnectionInformation;
 	boolean showConnectionInformation;
 	boolean dragging = false; // for dragging
 	boolean dragging = false; // for dragging
 	boolean dragged = false; // if an object/objects was/were dragged
 	boolean dragged = false; // if an object/objects was/were dragged
@@ -104,16 +104,14 @@ public abstract class AbstractCanvas extends JPanel {
 
 
 	// ------------------------------------------ METHODS
 	// ------------------------------------------ METHODS
 	// ------------------------------------------
 	// ------------------------------------------
-	
 
 
-	
-	
-
-	class ACpsHandle{
+	class ACpsHandle {
 		public AbstractCanvasObject object;
 		public AbstractCanvasObject object;
-		ACpsHandle(AbstractCanvasObject object){
+
+		ACpsHandle(AbstractCanvasObject object) {
 			this.object = object;
 			this.object = object;
 		}
 		}
+
 		public String toString() {
 		public String toString() {
 			return object.toString();
 			return object.toString();
 		}
 		}
@@ -130,6 +128,7 @@ public abstract class AbstractCanvas extends JPanel {
 			g2.drawRect(sx, y, x - sx, sy - y);
 			g2.drawRect(sx, y, x - sx, sy - y);
 		}
 		}
 	}
 	}
+
 	/**
 	/**
 	 * @deprecated
 	 * @deprecated
 	 * @param g
 	 * @param g
@@ -160,8 +159,6 @@ public abstract class AbstractCanvas extends JPanel {
 		}
 		}
 	}
 	}
 
 
-
-
 	void setRightClickMenu(MouseEvent e) {
 	void setRightClickMenu(MouseEvent e) {
 		if (e.getButton() == MouseEvent.BUTTON3) {
 		if (e.getButton() == MouseEvent.BUTTON3) {
 			itemPaste.setEnabled(true);
 			itemPaste.setEnabled(true);
@@ -180,7 +177,7 @@ public abstract class AbstractCanvas extends JPanel {
 					itemUngroup.setEnabled(true);
 					itemUngroup.setEnabled(true);
 				else
 				else
 					itemUngroup.setEnabled(false);
 					itemUngroup.setEnabled(false);
-				if (model.getSelectedCpsObjects().size() == 0) {
+				if (model.getSelectedObjects().size() == 0) {
 					controller.addSelectedObject(tempCps);
 					controller.addSelectedObject(tempCps);
 				}
 				}
 				if (tempCps instanceof HolonObject) {
 				if (tempCps instanceof HolonObject) {
@@ -211,17 +208,15 @@ public abstract class AbstractCanvas extends JPanel {
 	void markObjects() {
 	void markObjects() {
 		if (doMark) {
 		if (doMark) {
 			doMark = false;
 			doMark = false;
-			for (AbstractCanvasObject cps : tempSelected) {
-				if (!model.getSelectedCpsObjects().contains(cps)) {
-					controller.addSelectedObject(cps);
-				}
+			if (!tempSelected.isEmpty()) {
+				controller.toggleSelectedObjects(tempSelected);
+				controller.getObjectsInDepth();
+				tempSelected.clear();
 			}
 			}
-			controller.getObjectsInDepth();
-			tempSelected.clear();
+			
 		}
 		}
 	}
 	}
 
 
-
 	int[] determineMousePositionOnEdge(Edge p) {
 	int[] determineMousePositionOnEdge(Edge p) {
 		int lx, ly, hx, hy;
 		int lx, ly, hx, hy;
 
 
@@ -280,97 +275,97 @@ public abstract class AbstractCanvas extends JPanel {
 
 
 	void triggerUpdateController() {
 	void triggerUpdateController() {
 		updCon.paintProperties(tempCps);
 		updCon.paintProperties(tempCps);
-		updCon.refreshTableHolonElement(model.getMultiTable(), model.getSingleTable());
 		updCon.refreshTableProperties(model.getPropertyTable());
 		updCon.refreshTableProperties(model.getPropertyTable());
 	}
 	}
-	
-	
+
 	/**
 	/**
-	 * Checks if {@code draggedCps} or a new cpsObject at Position (x,y) could replace exactly one object
-	 * in {@code objects}.
-	 * Saves the object that would be replaced in {@link AbstractCanvas}.{@code MayBeReplaced}
-	 * @param objects list of objects that could be replaced
+	 * Checks if {@code draggedCps} or a new cpsObject at Position (x,y) could
+	 * replace exactly one object in {@code objects}. Saves the object that would be
+	 * replaced in {@link AbstractCanvas}.{@code MayBeReplaced}
+	 * 
+	 * @param objects    list of objects that could be replaced
 	 * @param draggedCps Object that might replace
 	 * @param draggedCps Object that might replace
-	 * @param x Position of the objects that might replace
-	 * @param y Position of the objects that might replace
-	 * @return true if exactly one Object could be replaced 
+	 * @param x          Position of the objects that might replace
+	 * @param y          Position of the objects that might replace
+	 * @return true if exactly one Object could be replaced
 	 */
 	 */
-	protected boolean checkForReplacement(ArrayList<AbstractCanvasObject> objects, AbstractCanvasObject draggedCps, int x, int y){
-		
+	protected boolean checkForReplacement(ArrayList<AbstractCanvasObject> objects, AbstractCanvasObject draggedCps,
+			int x, int y) {
+
 		/** distance treshold for replacement */
 		/** distance treshold for replacement */
-		int treshhold = controller.getScale()/2;
-						
+		int treshhold = controller.getScale() / 2;
+
 		/** number of Objects that might be replaced (should be 1) */
 		/** number of Objects that might be replaced (should be 1) */
 		int replaceCounter = 0;
 		int replaceCounter = 0;
-		
+
 		/** last object that could be replaced */
 		/** last object that could be replaced */
 		AbstractCanvasObject toBeReplaced = null;
 		AbstractCanvasObject toBeReplaced = null;
-		
+
 		/** Position of object that might be replaced */
 		/** Position of object that might be replaced */
 		Vector2Int p;
 		Vector2Int p;
-		
+
 		/** for each cps on Canvas */
 		/** for each cps on Canvas */
-		if(draggedCps == null || !(draggedCps instanceof Node) && !(draggedCps instanceof Node)){
-			for (AbstractCanvasObject cps : objects){
+		if (draggedCps == null || !(draggedCps instanceof Node) && !(draggedCps instanceof Node)) {
+			for (AbstractCanvasObject cps : objects) {
 				/** same object -> ignore */
 				/** same object -> ignore */
-				if(cps == draggedCps)continue;
-						
+				if (cps == draggedCps)
+					continue;
+
 				/** set Position of object that might be replaced */
 				/** set Position of object that might be replaced */
 				p = cps.getPosition();
 				p = cps.getPosition();
-				
+
 				/** if near enough */
 				/** if near enough */
-				if(Math.abs(x-p.getX())<treshhold && Math.abs(y-p.getY())<treshhold){
+				if (Math.abs(x - p.getX()) < treshhold && Math.abs(y - p.getY()) < treshhold) {
 					replaceCounter++;
 					replaceCounter++;
 					toBeReplaced = cps;
 					toBeReplaced = cps;
-					
+
 					/**
 					/**
-					 * if too many Objects could be replaced:
-					 * stop searching, because it would not be clear which one should
-					 * be replaced
+					 * if too many Objects could be replaced: stop searching, because it would not
+					 * be clear which one should be replaced
 					 */
 					 */
-					if(replaceCounter>1)break;
+					if (replaceCounter > 1)
+						break;
 				}
 				}
 			}
 			}
 		}
 		}
 		/**
 		/**
 		 * return true if exactly one obect would be replaced
 		 * return true if exactly one obect would be replaced
 		 */
 		 */
-		if( replaceCounter == 1 && toBeReplaced != null){
+		if (replaceCounter == 1 && toBeReplaced != null) {
 			mayBeReplaced = toBeReplaced;
 			mayBeReplaced = toBeReplaced;
 			return true;
 			return true;
-		}else{
+		} else {
 			mayBeReplaced = null;
 			mayBeReplaced = null;
 			return false;
 			return false;
 		}
 		}
 	}
 	}
-	
+
 	/**
 	/**
-	 * Checks if an inserted new Object could replace exactly one object on the canvas.
-	 * Saves the object that would be replaced in {@link AbstractCanvas}.{@code MayBeReplaced}
+	 * Checks if an inserted new Object could replace exactly one object on the
+	 * canvas. Saves the object that would be replaced in
+	 * {@link AbstractCanvas}.{@code MayBeReplaced}
+	 * 
 	 * @param x Position of the objects that might replace
 	 * @param x Position of the objects that might replace
 	 * @param y Position of the objects that might replace
 	 * @param y Position of the objects that might replace
-	 * @return true if exactly one Object could be replaced 
+	 * @return true if exactly one Object could be replaced
 	 */
 	 */
 	public abstract boolean checkForReplacement(int x, int y);
 	public abstract boolean checkForReplacement(int x, int y);
-	
-		
+
 	/**
 	/**
 	 * highlights the object that mayBeReplaced
 	 * highlights the object that mayBeReplaced
+	 * 
 	 * @param g2
 	 * @param g2
 	 */
 	 */
 	protected void highlightMayBeReplaced(Graphics2D g2) {
 	protected void highlightMayBeReplaced(Graphics2D g2) {
-		if(mayBeReplaced != null){
+		if (mayBeReplaced != null) {
 			g2.setColor(Color.RED);
 			g2.setColor(Color.RED);
-			g2.fillRect(
-					(int) (mayBeReplaced.getPosition().getX()
-							- controller.getScaleDiv2() - (scalediv20 + 3)),
-					(int) (mayBeReplaced.getPosition().getY()
-							- controller.getScaleDiv2() - (scalediv20 + 3)),
+			g2.fillRect((int) (mayBeReplaced.getPosition().getX() - controller.getScaleDiv2() - (scalediv20 + 3)),
+					(int) (mayBeReplaced.getPosition().getY() - controller.getScaleDiv2() - (scalediv20 + 3)),
 					(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
 					(int) (controller.getScale() + ((scalediv20 + 3) * 2)),
 					(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
 					(int) (controller.getScale() + ((scalediv20 + 3) * 2)));
 		}
 		}
 	}
 	}
-	
+
 	/**
 	/**
 	 * Align alle Objects on the Canvas to a Grid with objects every 10 pixels
 	 * Align alle Objects on the Canvas to a Grid with objects every 10 pixels
 	 */
 	 */
@@ -378,33 +373,35 @@ public abstract class AbstractCanvas extends JPanel {
 
 
 	/**
 	/**
 	 * Aligns the Object the a grid
 	 * Aligns the Object the a grid
-	 * @param cps Object that should be aligned
-	 * @param distance distance between the AlignmentGrid Lines. (objects every 'distance' pixels
+	 * 
+	 * @param cps      Object that should be aligned
+	 * @param distance distance between the AlignmentGrid Lines. (objects every
+	 *                 'distance' pixels
 	 */
 	 */
 	protected void align(AbstractCanvasObject cps, int distance) {
 	protected void align(AbstractCanvasObject cps, int distance) {
 		/** Position of the AbstractCpsObject which should be aligned */
 		/** Position of the AbstractCpsObject which should be aligned */
 		Vector2Int p = cps.getPosition();
 		Vector2Int p = cps.getPosition();
-		
-		//calculate how many pixels the cps should be decreased to align
+
+		// calculate how many pixels the cps should be decreased to align
 		/** x offset relative to a grid with lines every distance pixels */
 		/** x offset relative to a grid with lines every distance pixels */
 		int x_off = cps.getPosition().getX() % distance;
 		int x_off = cps.getPosition().getX() % distance;
-		
+
 		/** y offset relative to a grid with lines every distance pixels */
 		/** y offset relative to a grid with lines every distance pixels */
 		int y_off = cps.getPosition().getY() % distance;
 		int y_off = cps.getPosition().getY() % distance;
-		
-		//align to the other Line, if it is nearer
-		if(x_off > distance/2)
+
+		// align to the other Line, if it is nearer
+		if (x_off > distance / 2)
 			x_off -= distance;
 			x_off -= distance;
-		if(y_off > distance/2)
+		if (y_off > distance / 2)
 			y_off -= distance;
 			y_off -= distance;
-		
+
 		/** set new Position */
 		/** set new Position */
-		cps.setPosition(p.getX()-x_off, p.getY()-y_off);
+		cps.setPosition(p.getX() - x_off, p.getY() - y_off);
 	}
 	}
-	
 
 
 	/**
 	/**
 	 * Closes a tab of the UpperNode with ID upperNodeID
 	 * Closes a tab of the UpperNode with ID upperNodeID
+	 * 
 	 * @param upperNodeId
 	 * @param upperNodeId
 	 */
 	 */
 	public abstract void closeUpperNodeTab(int upperNodeId);
 	public abstract void closeUpperNodeTab(int upperNodeId);

+ 18 - 25
src/ui/view/AddElementPopUp.java

@@ -1,16 +1,24 @@
 package ui.view;
 package ui.view;
 
 
-import classes.AbstractCanvasObject;
-import classes.HolonElement;
-import classes.HolonObject;
-import utility.ImageImport;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.FlowLayout;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
 
 
-import javax.swing.*;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
 import javax.swing.border.EmptyBorder;
 import javax.swing.border.EmptyBorder;
 
 
-import java.awt.*;
-import java.awt.event.KeyEvent;
-import java.awt.event.KeyListener;
+import classes.HolonElement;
+import classes.HolonObject;
+import utility.ImageImport;
 
 
 /**
 /**
  * popup for adding an Holon Element to a holon Object.
  * popup for adding an Holon Element to a holon Object.
@@ -39,8 +47,6 @@ public class AddElementPopUp extends JDialog {
 	private JTextField providedEnergy;
 	private JTextField providedEnergy;
 	/** Element is active if checked */
 	/** Element is active if checked */
 	JCheckBox checkBoxActive;
 	JCheckBox checkBoxActive;
-	/** Textfield to enter the amount of this Element */
-	private JTextField amount;
 
 
 	/**
 	/**
 	 * Create the AddElementPopup Dialog
 	 * Create the AddElementPopup Dialog
@@ -98,17 +104,7 @@ public class AddElementPopUp extends JDialog {
 		checkBoxActive.setSelected(true);
 		checkBoxActive.setSelected(true);
 		checkBoxActive.setBounds(250, 50, 115, 20);
 		checkBoxActive.setBounds(250, 50, 115, 20);
 		contentPanel.add(checkBoxActive);
 		contentPanel.add(checkBoxActive);
-		
-		/* Add Amount Textfield and Checkbox */
-		JLabel lblAmount = new JLabel("Amount:");
-		lblAmount.setBounds(10, 130, 100, 14);
-		contentPanel.add(lblAmount);
 
 
-		amount = new JTextField();
-		amount.setBounds(130, 130, 110, 20);
-		contentPanel.add(amount);
-		amount.setColumns(10);
-		amount.setText("1");
 
 
 		/* Add Buttons and Actions */
 		/* Add Buttons and Actions */
 		JPanel buttonPane = new JPanel();
 		JPanel buttonPane = new JPanel();
@@ -153,8 +149,7 @@ public class AddElementPopUp extends JDialog {
 	public void setElement(HolonElement holonElement) {
 	public void setElement(HolonElement holonElement) {
 		hl = holonElement;
 		hl = holonElement;
 		elementName.setText(hl.getEleName());
 		elementName.setText(hl.getEleName());
-		amount.setText(""+hl.getAmount());
-		providedEnergy.setText(""+hl.getEnergyPerElement());
+		providedEnergy.setText(""+hl.getEnergy());
 		checkBoxActive.setSelected(hl.isActive());
 		checkBoxActive.setSelected(hl.isActive());
 		
 		
 	}
 	}
@@ -173,12 +168,10 @@ public class AddElementPopUp extends JDialog {
 		if (elementName.getText().length() != 0 && !repeated) {
 		if (elementName.getText().length() != 0 && !repeated) {
 			try {
 			try {
 				float energy = Float.parseFloat(providedEnergy.getText());
 				float energy = Float.parseFloat(providedEnergy.getText());
-				int elementAmount = Integer.parseInt(amount.getText());
 				if(hl == null){
 				if(hl == null){
-					hl = new HolonElement(this.tempCps, elementName.getText(), elementAmount, energy);
+					hl = new HolonElement(this.tempCps, elementName.getText(), energy);
 				} else {
 				} else {
 					hl.setEleName(elementName.getText());
 					hl.setEleName(elementName.getText());
-					hl.setAmount(elementAmount);
 					hl.setEnergyPerElement(energy);
 					hl.setEnergyPerElement(energy);
 					hl.setActive(checkBoxActive.isSelected());
 					hl.setActive(checkBoxActive.isSelected());
 				}
 				}

+ 21 - 36
src/ui/view/AddObjectPopUp.java

@@ -3,7 +3,6 @@ package ui.view;
 import java.awt.BorderLayout;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Color;
 import java.awt.FlowLayout;
 import java.awt.FlowLayout;
-import java.awt.Image;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 import java.awt.event.KeyListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseAdapter;
@@ -53,7 +52,7 @@ public class AddObjectPopUp extends JDialog {
 	private DefaultListModel<String> listModel;
 	private DefaultListModel<String> listModel;
 	private JList<String> list;
 	private JList<String> list;
 	private String imagePath;
 	private String imagePath;
-	//	private HolonObject theObject;
+	// private HolonObject theObject;
 	private Control controller;
 	private Control controller;
 	private File selectedFile = null;
 	private File selectedFile = null;
 	private String filePath = " ";
 	private String filePath = " ";
@@ -63,25 +62,21 @@ public class AddObjectPopUp extends JDialog {
 	private boolean editState;
 	private boolean editState;
 	private boolean imageChanged = false;
 	private boolean imageChanged = false;
 
 
-
 	/**
 	/**
 	 * Create the dialog.
 	 * Create the dialog.
 	 * 
 	 * 
-	 * @param edit
-	 *            true if edit
-	 * @param obj
-	 *            the object
-	 * @param cat
-	 *            the categorie
+	 * @param edit true if edit
+	 * @param obj  the object
+	 * @param cat  the categorie
 	 */
 	 */
-    AddObjectPopUp(boolean edit, AbstractCanvasObject obj, String cat, JFrame parentFrame) {
+	AddObjectPopUp(boolean edit, AbstractCanvasObject obj, String cat, JFrame parentFrame) {
 
 
-        toEdit = obj;
+		toEdit = obj;
 		editState = edit;
 		editState = edit;
-		this.setIconImage(ImageImport.loadImage("/Images/Holeg.png",30,30));
+		this.setIconImage(ImageImport.loadImage("/Images/Holeg.png", 30, 30));
 		setBounds(100, 100, 450, 342);
 		setBounds(100, 100, 450, 342);
-        setLocationRelativeTo(parentFrame);
-        getContentPane().setLayout(new BorderLayout());
+		setLocationRelativeTo(parentFrame);
+		getContentPane().setLayout(new BorderLayout());
 		JPanel contentPanel = new JPanel();
 		JPanel contentPanel = new JPanel();
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
@@ -155,19 +150,19 @@ public class AddObjectPopUp extends JDialog {
 				lblImagePreview.setIcon(new ImageIcon(ImageImport.loadImage(obj.getImage(), 50, 50)));
 				lblImagePreview.setIcon(new ImageIcon(ImageImport.loadImage(obj.getImage(), 50, 50)));
 			}
 			}
 			sourcePath.setBounds(148, 77, 271, 20);
 			sourcePath.setBounds(148, 77, 271, 20);
-			if(edit) {
+			if (edit) {
 				this.filePath = obj.getImage();
 				this.filePath = obj.getImage();
 				sourcePath.setText(filePath);
 				sourcePath.setText(filePath);
 			}
 			}
 			contentPanel.add(sourcePath);
 			contentPanel.add(sourcePath);
-			
+
 			sourcePath.setColumns(10);
 			sourcePath.setColumns(10);
 		}
 		}
 		{
 		{
 			JButton btnAddDefaultElement = new JButton("Add Element");
 			JButton btnAddDefaultElement = new JButton("Add Element");
 			btnAddDefaultElement.addActionListener(actionEvent -> {
 			btnAddDefaultElement.addActionListener(actionEvent -> {
-                addElement = new AddElementPopUp(parentFrame);
-                addElement.setActualHolonObject((HolonObject)toEdit);
+				addElement = new AddElementPopUp(parentFrame);
+				addElement.setActualHolonObject((HolonObject) toEdit);
 				addElement.setVisible(true);
 				addElement.setVisible(true);
 				HolonElement hl = addElement.getElement();
 				HolonElement hl = addElement.getElement();
 				hl.setSaving(new Pair<>(givenCategory, objectName.getText()));
 				hl.setSaving(new Pair<>(givenCategory, objectName.getText()));
@@ -190,9 +185,9 @@ public class AddObjectPopUp extends JDialog {
 				listModel = new DefaultListModel<String>();
 				listModel = new DefaultListModel<String>();
 
 
 				/*
 				/*
-				 * HolonElement hel = new HolonElement("Test", 100, 5); String
-				 * name = hel.getEleName(); for (int i = 0; i < 11; i++) {
-				 * hel.setEleName(name + i); addElement(hel); }
+				 * HolonElement hel = new HolonElement("Test", 100, 5); String name =
+				 * hel.getEleName(); for (int i = 0; i < 11; i++) { hel.setEleName(name + i);
+				 * addElement(hel); }
 				 */
 				 */
 				list = new JList<String>(listModel);
 				list = new JList<String>(listModel);
 				scrollPane.setViewportView(list);
 				scrollPane.setViewportView(list);
@@ -231,10 +226,6 @@ public class AddObjectPopUp extends JDialog {
 								if (imageChanged)
 								if (imageChanged)
 									copieFile();
 									copieFile();
 								imageChanged = false;
 								imageChanged = false;
-								// theObject = new
-								// HolonObject(objectName.getText());
-								// theObject.setElements(hElements);
-								// theObject.setImage(imagePath);// TODO Auto-generated catch block
 								try {
 								try {
 									if (editState) {
 									if (editState) {
 										controller.delObjectCategory(givenCategory, toEdit.getName());
 										controller.delObjectCategory(givenCategory, toEdit.getName());
@@ -280,16 +271,14 @@ public class AddObjectPopUp extends JDialog {
 		}
 		}
 	}
 	}
 
 
-
 	/**
 	/**
 	 * adds a Holon Element.
 	 * adds a Holon Element.
 	 *
 	 *
-	 * @param hl
-	 *            the HolonElement
+	 * @param hl the HolonElement
 	 */
 	 */
 	private void addElement(HolonElement hl) {
 	private void addElement(HolonElement hl) {
 		hElements.add(hl);
 		hElements.add(hl);
-		listModel.addElement(hl.getAmount() + "x: " + hl.getEleName() + " " + hl.getEnergyPerElement() + "U");
+		listModel.addElement("x: " + hl.getEleName() + " " + hl.getEnergy() + "U");
 	}
 	}
 
 
 	/**
 	/**
@@ -304,9 +293,7 @@ public class AddObjectPopUp extends JDialog {
 			selectedFile = fileChooser.getSelectedFile();
 			selectedFile = fileChooser.getSelectedFile();
 			filePath = selectedFile.getAbsolutePath();
 			filePath = selectedFile.getAbsolutePath();
 			sourcePath.setText(filePath);
 			sourcePath.setText(filePath);
-			ImageIcon icon = new ImageIcon(//TODO: ugly
-					
-					new ImageIcon(filePath).getImage().getScaledInstance(50, 50, Image.SCALE_SMOOTH));
+			ImageIcon icon = new ImageIcon(ImageImport.loadImage(filePath, 50, 50));
 			lblImagePreview.setIcon(icon);
 			lblImagePreview.setIcon(icon);
 			imageChanged = true;
 			imageChanged = true;
 		} else {
 		} else {
@@ -367,8 +354,7 @@ public class AddObjectPopUp extends JDialog {
 	/**
 	/**
 	 * Sets the Controller.
 	 * Sets the Controller.
 	 * 
 	 * 
-	 * @param controller
-	 *            the controller
+	 * @param controller the controller
 	 */
 	 */
 	public void setController(Control controller) {
 	public void setController(Control controller) {
 		this.controller = controller;
 		this.controller = controller;
@@ -377,8 +363,7 @@ public class AddObjectPopUp extends JDialog {
 	/**
 	/**
 	 * Set the Category.
 	 * Set the Category.
 	 * 
 	 * 
-	 * @param cat
-	 *            the Category
+	 * @param cat the Category
 	 */
 	 */
 	public void setCategory(String cat) {
 	public void setCategory(String cat) {
 		givenCategory = cat;
 		givenCategory = cat;

+ 1 - 6
src/ui/view/ButtonTabComponent.java

@@ -42,16 +42,14 @@ import java.awt.event.*;
  */
  */
 public class ButtonTabComponent extends JPanel {
 public class ButtonTabComponent extends JPanel {
 	private final JTabbedPane pane;
 	private final JTabbedPane pane;
-	private final JTabbedPane pane2;
 
 
-	public ButtonTabComponent(final JTabbedPane pane, final JTabbedPane pane2) {
+	public ButtonTabComponent(final JTabbedPane pane) {
 		// unset default FlowLayout' gaps
 		// unset default FlowLayout' gaps
 		super(new FlowLayout(FlowLayout.LEFT, 0, 0));
 		super(new FlowLayout(FlowLayout.LEFT, 0, 0));
 		if (pane == null) {
 		if (pane == null) {
 			throw new NullPointerException("TabbedPane is null");
 			throw new NullPointerException("TabbedPane is null");
 		}
 		}
 		this.pane = pane;
 		this.pane = pane;
-		this.pane2 = pane2;
 		setOpaque(false);
 		setOpaque(false);
 
 
 		// make JLabel read titles from JTabbedPane
 		// make JLabel read titles from JTabbedPane
@@ -149,9 +147,6 @@ public class ButtonTabComponent extends JPanel {
 		int i = pane.indexOfTabComponent(ButtonTabComponent.this);
 		int i = pane.indexOfTabComponent(ButtonTabComponent.this);
 		if (i != -1) {
 		if (i != -1) {
 			pane.remove(i);
 			pane.remove(i);
-			if (pane2.getTabCount() > 0) {
-				pane2.remove(i);
-			}
 		}
 		}
 	}
 	}
 }
 }

File diff suppressed because it is too large
+ 452 - 470
src/ui/view/Canvas.java


+ 1 - 3
src/ui/view/CreateNewDialog.java

@@ -39,7 +39,6 @@ public class CreateNewDialog extends JDialog{
 	JComboBox<String> optionList = new JComboBox<String>(optionStrings);
 	JComboBox<String> optionList = new JComboBox<String>(optionStrings);
 	JTextField inputName = new JTextField();
 	JTextField inputName = new JTextField();
 	JButton saveButton = new JButton("Save");
 	JButton saveButton = new JButton("Save");
-	//TODO
 	JTextField inputNameSwitch = new JTextField();
 	JTextField inputNameSwitch = new JTextField();
 	JComboBox<String> selectedCategorySwitch = new JComboBox<String>();
 	JComboBox<String> selectedCategorySwitch = new JComboBox<String>();
 	
 	
@@ -64,7 +63,6 @@ public class CreateNewDialog extends JDialog{
 			actualOption = Option.getEnumAtIndex(optionList.getSelectedIndex());
 			actualOption = Option.getEnumAtIndex(optionList.getSelectedIndex());
 		    cl.show(cards, actualOption.name());
 		    cl.show(cards, actualOption.name());
 		    saveButton.setEnabled(actualOption != Option.None);  
 		    saveButton.setEnabled(actualOption != Option.None);  
-		    //TODO delete and make own iterface
 		    saveButton.setVisible(actualOption != Option.Object);	
 		    saveButton.setVisible(actualOption != Option.Object);	
 		});
 		});
 		
 		
@@ -239,7 +237,7 @@ public class CreateNewDialog extends JDialog{
 				dispose();
 				dispose();
 			}
 			}
 			else if (actualOption == Option.Switch)
 			else if (actualOption == Option.Switch)
-			{//TODO
+			{
 				try {
 				try {
 					actualController.addSwitch(actualController.searchCategory(selectedCategorySwitch.getSelectedItem().toString()), inputNameSwitch.getText());
 					actualController.addSwitch(actualController.searchCategory(selectedCategorySwitch.getSelectedItem().toString()), inputNameSwitch.getText());
 				} catch (IOException e) {
 				} catch (IOException e) {

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

@@ -210,8 +210,8 @@ public class CreateTemplatePopUp extends JDialog {
 		 * Add Elements to List
 		 * Add Elements to List
 		 */
 		 */
 		for (HolonElement he : template.getElements())
 		for (HolonElement he : template.getElements())
-			listModel.addElement(he.getAmount() + " * " + he.getEleName()
-					+ ": " + he.getMaximumEnergy() + "U");
+			listModel.addElement(he.getEleName()
+					+ ": " + he.getEnergy() + "U");
 
 
 		/**
 		/**
 		 * Add ScrollPane to List
 		 * Add ScrollPane to List
@@ -321,8 +321,8 @@ public class CreateTemplatePopUp extends JDialog {
 		popUp.setVisible(true);
 		popUp.setVisible(true);
 		HolonElement he = popUp.getElement();
 		HolonElement he = popUp.getElement();
 		if (he != null) {
 		if (he != null) {
-			listModel.addElement(he.getAmount() + " * " + he.getEleName()
-					+ ": " + he.getMaximumEnergy() + "U");
+			listModel.addElement(he.getEleName()
+					+ ": " + he.getEnergy() + "U");
 			template.addElement(he);
 			template.addElement(he);
 			he.setSaving(new Pair<>(category, textField_name.getText()));
 			he.setSaving(new Pair<>(category, textField_name.getText()));
 		}
 		}
@@ -335,7 +335,7 @@ public class CreateTemplatePopUp extends JDialog {
 		int index = list.getSelectedIndex();
 		int index = list.getSelectedIndex();
 		if (index == -1)
 		if (index == -1)
 			return;
 			return;
-		template.deleteElement(index);
+		template.removeElement(index);
 		listModel.remove(index);
 		listModel.remove(index);
 	}
 	}
 
 
@@ -354,9 +354,9 @@ public class CreateTemplatePopUp extends JDialog {
 		HolonElement he = popUp.getElement();
 		HolonElement he = popUp.getElement();
 		if (he != null) {
 		if (he != null) {
 			listModel.remove(index);
 			listModel.remove(index);
-			listModel.addElement(he.getAmount() + " * " + he.getEleName()
-					+ ": " + he.getMaximumEnergy() + "U");
-			template.deleteElement(index);
+			listModel.addElement(he.getEleName()
+					+ ": " + he.getEnergy() + "U");
+			template.removeElement(index);
 			template.addElement(he);
 			template.addElement(he);
 			he.setSaving(new Pair<>(category, textField_name.getText()));
 			he.setSaving(new Pair<>(category, textField_name.getText()));
 		}
 		}

+ 63 - 237
src/ui/view/GUI.java

@@ -26,7 +26,6 @@ import java.awt.event.MouseMotionAdapter;
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
 import java.net.URI;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.ListIterator;
@@ -157,8 +156,6 @@ public class GUI {
 	// the original tabbed Pane (containing tabs for view, statistics, holon,
 	// the original tabbed Pane (containing tabs for view, statistics, holon,
 	// flexibility)
 	// flexibility)
 	private final JTabbedPane tabbedPaneOriginal = new JTabbedPane(JTabbedPane.TOP);
 	private final JTabbedPane tabbedPaneOriginal = new JTabbedPane(JTabbedPane.TOP);
-	// the same tabbed Pane that appears once the view is split
-	private final JTabbedPane tabbedPaneSplit = new JTabbedPane(JTabbedPane.TOP);
 	private final JPopupMenu popmenuEdit = new JPopupMenu();
 	private final JPopupMenu popmenuEdit = new JPopupMenu();
 	private final JMenuItem editItem = new JMenuItem("Edit Object");
 	private final JMenuItem editItem = new JMenuItem("Edit Object");
 	private final JLabel maxGraph = new JLabel("100%");
 	private final JLabel maxGraph = new JLabel("100%");
@@ -275,7 +272,7 @@ public class GUI {
 	GUI(Control control) {
 	GUI(Control control) {
 		this.controller = control;
 		this.controller = control;
 		this.model = control.getModel();
 		this.model = control.getModel();
-		inspector  = new Inspector(control);
+		inspector = new Inspector(control);
 		control.setGui(this);
 		control.setGui(this);
 		control.calculateStateAndVisualForCurrentTimeStep();
 		control.calculateStateAndVisualForCurrentTimeStep();
 		this.unitGraph = new UnitGraph(model, control);
 		this.unitGraph = new UnitGraph(model, control);
@@ -389,7 +386,7 @@ public class GUI {
 			public void actionPerformed(ActionEvent e) {
 			public void actionPerformed(ActionEvent e) {
 				chooseTabTemp();
 				chooseTabTemp();
 
 
-				model.getSelectedCpsObjects().clear();
+				model.getSelectedObjects().clear();
 
 
 				// Uppernode Canvas?
 				// Uppernode Canvas?
 				JScrollPane scrollPane = getScrollPaneFromTabbedPane();
 				JScrollPane scrollPane = getScrollPaneFromTabbedPane();
@@ -397,19 +394,14 @@ public class GUI {
 
 
 				if (canvasOrUpperNodeCanvas instanceof GroupNodeCanvas) {
 				if (canvasOrUpperNodeCanvas instanceof GroupNodeCanvas) {
 					GroupNodeCanvas uNC = (GroupNodeCanvas) canvasOrUpperNodeCanvas;
 					GroupNodeCanvas uNC = (GroupNodeCanvas) canvasOrUpperNodeCanvas;
-					for (AbstractCanvasObject cps : uNC.getGroupNode().getNodes()) {
-						controller.addSelectedObject(cps);
-					}
+					controller.addSelectedObjects(uNC.getGroupNode().getNodes());
 					uNC.repaint();
 					uNC.repaint();
 					// or Canvas?
 					// or Canvas?
 				} else if (canvasOrUpperNodeCanvas instanceof Canvas) {
 				} else if (canvasOrUpperNodeCanvas instanceof Canvas) {
-					for (AbstractCanvasObject cps : model.getObjectsOnCanvas()) {
-						controller.addSelectedObject(cps);
-					}
+					controller.addSelectedObjects(model.getObjectsOnCanvas());
 					canvas.repaint();
 					canvas.repaint();
 				}
 				}
 				controller.getObjectsInDepth();
 				controller.getObjectsInDepth();
-
 			}
 			}
 		};
 		};
 		actionMap.put(cntrlADown, controlA);
 		actionMap.put(cntrlADown, controlA);
@@ -434,7 +426,7 @@ public class GUI {
 
 
 				if (canvasOrUpperNodeCanvas instanceof GroupNodeCanvas) {
 				if (canvasOrUpperNodeCanvas instanceof GroupNodeCanvas) {
 					GroupNodeCanvas uNC = (GroupNodeCanvas) canvasOrUpperNodeCanvas;
 					GroupNodeCanvas uNC = (GroupNodeCanvas) canvasOrUpperNodeCanvas;
-					for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
+					for (AbstractCanvasObject cps : model.getSelectedObjects()) {
 						if (uNC.getGroupNode().getNodes().contains(cps)) {
 						if (uNC.getGroupNode().getNodes().contains(cps)) {
 							controller.delObjUpperNode(cps, uNC.getGroupNode());
 							controller.delObjUpperNode(cps, uNC.getGroupNode());
 							unc.setToolTip(false);
 							unc.setToolTip(false);
@@ -444,26 +436,24 @@ public class GUI {
 						}
 						}
 					}
 					}
 					uNC.repaint();
 					uNC.repaint();
+					controller.clearSelection();
 
 
 					// or Canvas?
 					// or Canvas?
 				} else if (canvasOrUpperNodeCanvas instanceof Canvas) {
 				} else if (canvasOrUpperNodeCanvas instanceof Canvas) {
-					boolean save = false;
 					// Edge Deleting
 					// Edge Deleting
 					Edge edgeHighlight = model.getSelectedEdge();
 					Edge edgeHighlight = model.getSelectedEdge();
 					if (edgeHighlight != null) {
 					if (edgeHighlight != null) {
 						controller.removeEdgesOnCanvas(edgeHighlight);
 						controller.removeEdgesOnCanvas(edgeHighlight);
 						((Canvas) canvasOrUpperNodeCanvas).edgeHighlight = null;
 						((Canvas) canvasOrUpperNodeCanvas).edgeHighlight = null;
 					}
 					}
-					for (int j = 0; j < model.getSelectedCpsObjects().size(); j++) {
-						AbstractCanvasObject cps = model.getSelectedCpsObjects().get(j);
-						if (j < model.getSelectedCpsObjects().size() - 1)
-							save = true;
-						controller.delCanvasObject(cps, save);
-						canvas.setToolTip(false);
-
+					canvas.setToolTip(false);
+					for (AbstractCanvasObject cps : model.getSelectedObjects()) {
+						controller.delCanvasObject(cps, false);
 						// remove UpperNodeTab if UpperNode deleted
 						// remove UpperNodeTab if UpperNode deleted
 						removeUpperNodeTab(cps);
 						removeUpperNodeTab(cps);
 					}
 					}
+					controller.clearSelection();
+					controller.tryAutoSave();
 					canvas.repaint();
 					canvas.repaint();
 				}
 				}
 
 
@@ -473,7 +463,7 @@ public class GUI {
 					controller.calculateStateAndVisualForCurrentTimeStep();
 					controller.calculateStateAndVisualForCurrentTimeStep();
 				}
 				}
 
 
-				model.getSelectedCpsObjects().clear();
+				model.getSelectedObjects().clear();
 				hideScrollGraph();
 				hideScrollGraph();
 			}
 			}
 		});
 		});
@@ -502,7 +492,7 @@ public class GUI {
 				chooseTabTemp();
 				chooseTabTemp();
 				System.out.println("heiCopy - control C");
 				System.out.println("heiCopy - control C");
 				JScrollPane scrollPane = getScrollPaneFromTabbedPane();
 				JScrollPane scrollPane = getScrollPaneFromTabbedPane();
-				if (!model.getSelectedCpsObjects().isEmpty()) {
+				if (!model.getSelectedObjects().isEmpty()) {
 					if (scrollPane.getViewport().getComponent(0) instanceof GroupNodeCanvas)
 					if (scrollPane.getViewport().getComponent(0) instanceof GroupNodeCanvas)
 						controller.copy(((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getGroupNode());
 						controller.copy(((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getGroupNode());
 					else
 					else
@@ -527,9 +517,6 @@ public class GUI {
 					if (tabbedPaneOriginal.getMousePosition() != null) {
 					if (tabbedPaneOriginal.getMousePosition() != null) {
 						tabTemp = tabbedPaneOriginal;
 						tabTemp = tabbedPaneOriginal;
 					} else {
 					} else {
-						if (!initSplit) {
-							tabTemp = tabbedPaneSplit;
-						}
 					}
 					}
 
 
 					if (tabTemp == null)
 					if (tabTemp == null)
@@ -565,9 +552,8 @@ public class GUI {
 			@Override
 			@Override
 			public void actionPerformed(ActionEvent e) {
 			public void actionPerformed(ActionEvent e) {
 				chooseTabTemp();
 				chooseTabTemp();
-
 				JScrollPane scrollPane = getScrollPaneFromTabbedPane();
 				JScrollPane scrollPane = getScrollPaneFromTabbedPane();
-				if (!model.getSelectedCpsObjects().isEmpty()) {
+				if (!model.getSelectedObjects().isEmpty()) {
 					if (scrollPane.getViewport().getComponent(0) instanceof GroupNodeCanvas) {
 					if (scrollPane.getViewport().getComponent(0) instanceof GroupNodeCanvas) {
 						controller.cut(((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getGroupNode());
 						controller.cut(((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getGroupNode());
 						controller.calculateStateAndVisualForCurrentTimeStep();
 						controller.calculateStateAndVisualForCurrentTimeStep();
@@ -701,6 +687,9 @@ public class GUI {
 			popUp.setVisible(true);
 			popUp.setVisible(true);
 		});
 		});
 
 
+		tabbedPaneInnerOriginal.addChangeListener(change -> {
+			controller.clearSelection();
+		});
 		mnNewMenuView.add(mntmCanvasSize);
 		mnNewMenuView.add(mntmCanvasSize);
 
 
 		/*
 		/*
@@ -754,44 +743,6 @@ public class GUI {
 		mnHelp.add(mntmCodeDoc);
 		mnHelp.add(mntmCodeDoc);
 		mnHelp.add(mntmAboutUs);
 		mnHelp.add(mntmAboutUs);
 
 
-		tabbedPaneOriginal.addChangeListener(changeEvent -> {
-			if (tabbedPaneOriginal.getSelectedComponent() == null) {
-				Component tempC = tabbedPaneSplit.getSelectedComponent();
-				tabbedPaneSplit.setComponentAt(tabbedPaneOriginal.getSelectedIndex(), null);
-				tabbedPaneOriginal.setComponentAt(tabbedPaneOriginal.getSelectedIndex(), tempC);
-				tempC = tabbedPaneOriginal.getComponentAt(
-						(tabbedPaneOriginal.getSelectedIndex() + 1) % (tabbedPaneOriginal.getTabCount()));
-				tabbedPaneOriginal.setComponentAt(
-						(tabbedPaneOriginal.getSelectedIndex() + 1) % (tabbedPaneOriginal.getTabCount()), null);
-				tabbedPaneSplit.setComponentAt(
-						(tabbedPaneOriginal.getSelectedIndex() + 1) % (tabbedPaneOriginal.getTabCount()), tempC);
-				tabbedPaneSplit.setSelectedIndex(
-						(tabbedPaneOriginal.getSelectedIndex() + 1) % (tabbedPaneOriginal.getTabCount()));
-				contentPane.updateUI();
-			}
-		});
-
-		tabbedPaneSplit.addChangeListener(changeEvent -> {
-			if (tabbedPaneSplit.getSelectedComponent() == null && !initSplit) {
-				Component tempC = tabbedPaneOriginal.getComponentAt(tabbedPaneSplit.getSelectedIndex());
-				tabbedPaneOriginal.setComponentAt(tabbedPaneSplit.getSelectedIndex(), null);
-				tabbedPaneSplit.setComponentAt(tabbedPaneSplit.getSelectedIndex(), tempC);
-
-				for (int i = 0; i < tabbedPaneOriginal.getTabCount(); i++) {
-					if (tabbedPaneSplit.getComponentAt(i) != null && tabbedPaneSplit.getComponentAt(i) != tempC) {
-						tempC = tabbedPaneSplit.getComponentAt(i);
-						tabbedPaneSplit.setComponentAt(i, null);
-						tabbedPaneOriginal.setComponentAt(i, tempC);
-						break;
-					}
-				}
-				if (tabbedPaneOriginal.getSelectedIndex() == tabbedPaneSplit.getSelectedIndex()) {
-					tabbedPaneOriginal.setSelectedIndex(
-							(tabbedPaneSplit.getSelectedIndex() + 1) % tabbedPaneOriginal.getTabCount());
-				}
-				contentPane.updateUI();
-			}
-		});
 		canvas.setBackground(Color.WHITE);
 		canvas.setBackground(Color.WHITE);
 		canvas.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
 		canvas.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
 		/********************
 		/********************
@@ -854,7 +805,7 @@ public class GUI {
 		 * Add HolonElement to given HolonObject
 		 * Add HolonElement to given HolonObject
 		 */
 		 */
 		btnAddHolEL.addActionListener(actionEvent -> {
 		btnAddHolEL.addActionListener(actionEvent -> {
-			if (model.getSelectedCpsObjects().size() == 1) {
+			if (model.getSelectedObjects().size() == 1) {
 				AbstractCanvasObject tempCpsObject = updCon.getActualCps();
 				AbstractCanvasObject tempCpsObject = updCon.getActualCps();
 				if (tempCpsObject != null && tempCpsObject.getClass() == HolonObject.class
 				if (tempCpsObject != null && tempCpsObject.getClass() == HolonObject.class
 						&& tempCpsObject.getId() != 0) {
 						&& tempCpsObject.getId() != 0) {
@@ -863,8 +814,8 @@ public class GUI {
 					addElementPopUp.setVisible(true);
 					addElementPopUp.setVisible(true);
 					HolonElement ele = addElementPopUp.getElement();
 					HolonElement ele = addElementPopUp.getElement();
 					if (ele != null) {
 					if (ele != null) {
-						controller.addElementCanvasObject(tempCpsObject.getId(), ele.getEleName(), ele.getAmount(),
-								ele.getEnergyPerElement(), ele.getId());
+						controller.addElementCanvasObject(tempCpsObject.getId(), ele.getEleName(), ele.getEnergy(),
+								ele.getId());
 					}
 					}
 					controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
 					controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
 					triggerUpdateController(null);
 					triggerUpdateController(null);
@@ -884,7 +835,7 @@ public class GUI {
 		 */
 		 */
 		btnDelHolEL.addActionListener(actionEvent -> {
 		btnDelHolEL.addActionListener(actionEvent -> {
 			// For Single Selection of CpsObject
 			// For Single Selection of CpsObject
-			if (model.getSelectedCpsObjects().size() == 1) {
+			if (model.getSelectedObjects().size() == 1) {
 				if (updCon.getActualCps().getClass() == HolonObject.class) {
 				if (updCon.getActualCps().getClass() == HolonObject.class) {
 					HolonObject obj = (HolonObject) updCon.getActualCps();
 					HolonObject obj = (HolonObject) updCon.getActualCps();
 					if (selectedElements.isEmpty()) {
 					if (selectedElements.isEmpty()) {
@@ -894,7 +845,7 @@ public class GUI {
 					}
 					}
 					for (HolonElement e : selectedElements) {
 					for (HolonElement e : selectedElements) {
 						controller.deleteElementCanvas(obj.getId(), e.getId());
 						controller.deleteElementCanvas(obj.getId(), e.getId());
-						controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
+						controller.calculateStateAndVisualForCurrentTimeStep();
 						triggerUpdateController(null);
 						triggerUpdateController(null);
 						contentPane.updateUI();
 						contentPane.updateUI();
 						// Names displayed in graph are not updated
 						// Names displayed in graph are not updated
@@ -903,7 +854,7 @@ public class GUI {
 					selectedElements.clear();
 					selectedElements.clear();
 				}
 				}
 				// For MultiSelection of CpsObject
 				// For MultiSelection of CpsObject
-			} else if (model.getSelectedCpsObjects().size() > 1) {
+			} else if (model.getSelectedObjects().size() > 1) {
 				for (Integer i : model.getEleToDelete().keySet()) {
 				for (Integer i : model.getEleToDelete().keySet()) {
 					for (HolonElement e : model.getEleToDelete().get(i)) {
 					for (HolonElement e : model.getEleToDelete().get(i)) {
 						controller.deleteElementCanvas(i, e.getId());
 						controller.deleteElementCanvas(i, e.getId());
@@ -974,7 +925,7 @@ public class GUI {
 				if (leaf) {
 				if (leaf) {
 					for (Category cat : model.getCategories()) {
 					for (Category cat : model.getCategories()) {
 						for (AbstractCanvasObject cps : cat.getObjects()) {
 						for (AbstractCanvasObject cps : cat.getObjects()) {
-							if (value.toString().compareTo(cps.getObjName()) == 0) {
+							if (value.toString().compareTo(cps.getName()) == 0) {
 								imgR = ImageImport.loadImage(cps.getImage(), 50, 50);
 								imgR = ImageImport.loadImage(cps.getImage(), 50, 50);
 								if (imgR != null) {
 								if (imgR != null) {
 									label.setIcon(new ImageIcon(imgR));
 									label.setIcon(new ImageIcon(imgR));
@@ -1091,35 +1042,31 @@ public class GUI {
 							int x = (int) unc.getMousePosition().getX() + 16;
 							int x = (int) unc.getMousePosition().getX() + 16;
 							int y = (int) unc.getMousePosition().getY() + 16;
 							int y = (int) unc.getMousePosition().getY() + 16;
 
 
-							if (x > unc.getGroupNode().getLeftBorder()) {
-
-								AbstractCanvasObject h = null;
-								if (tempCps instanceof HolonObject) {
-									h = new HolonObject((HolonObject) tempCps);
-								}
-								if (tempCps instanceof HolonSwitch) {
-									h = new HolonSwitch(tempCps);
-								}
-								h.setPosition(x, y);
+							AbstractCanvasObject h = null;
+							if (tempCps instanceof HolonObject) {
+								h = new HolonObject((HolonObject) tempCps);
+							}
+							if (tempCps instanceof HolonSwitch) {
+								h = new HolonSwitch(tempCps);
+							}
+							h.setPosition(x, y);
 
 
-								/**
-								 * close UpperNodeTabs of replaced UpperNode
-								 */
-								if (unc.mayBeReplaced != null && unc.mayBeReplaced instanceof GroupNode) {
-									unc.closeUpperNodeTab(unc.mayBeReplaced.getId());
-								}
-								controller.addObjUpperNode(h, unc.getGroupNode());
-
-								/**
-								 * object would be replaced
-								 */
-								unc.mayBeReplaced = null;
-								unc.invalidate();
-								controller.calculateStateAndVisualForCurrentTimeStep();
-								unc.repaint();
-								unc.setXY((int) canvas.getMousePosition().getX(),
-										(int) canvas.getMousePosition().getY());
+							/**
+							 * close UpperNodeTabs of replaced UpperNode
+							 */
+							if (unc.mayBeReplaced != null && unc.mayBeReplaced instanceof GroupNode) {
+								unc.closeUpperNodeTab(unc.mayBeReplaced.getId());
 							}
 							}
+							controller.addObjUpperNode(h, unc.getGroupNode());
+
+							/**
+							 * object would be replaced
+							 */
+							unc.mayBeReplaced = null;
+							unc.invalidate();
+							controller.calculateStateAndVisualForCurrentTimeStep();
+							unc.repaint();
+							unc.setXY((int) canvas.getMousePosition().getX(), (int) canvas.getMousePosition().getY());
 						} else {
 						} else {
 							int x = (int) canvas.getMousePosition().getX() + 16;
 							int x = (int) canvas.getMousePosition().getX() + 16;
 							int y = (int) canvas.getMousePosition().getY() + 16;
 							int y = (int) canvas.getMousePosition().getY() + 16;
@@ -1189,7 +1136,7 @@ public class GUI {
 					if (SwingUtilities.isRightMouseButton(e)) {
 					if (SwingUtilities.isRightMouseButton(e)) {
 						for (Category cat : model.getCategories()) {
 						for (Category cat : model.getCategories()) {
 							for (AbstractCanvasObject cps : cat.getObjects()) {
 							for (AbstractCanvasObject cps : cat.getObjects()) {
-								if (actualObjectClicked.compareTo(cps.getObjName()) == 0
+								if (actualObjectClicked.compareTo(cps.getName()) == 0
 										&& !(cps instanceof HolonSwitch)) {
 										&& !(cps instanceof HolonSwitch)) {
 									editItem.setEnabled(true);
 									editItem.setEnabled(true);
 									popmenuEdit.show(e.getComponent(), e.getX(), e.getY());
 									popmenuEdit.show(e.getComponent(), e.getX(), e.getY());
@@ -1201,7 +1148,7 @@ public class GUI {
 					} else {
 					} else {
 						for (Category cat : model.getCategories()) {
 						for (Category cat : model.getCategories()) {
 							for (AbstractCanvasObject cps : cat.getObjects()) {
 							for (AbstractCanvasObject cps : cat.getObjects()) {
-								if (actualObjectClicked.compareTo(cps.getObjName()) == 0) {
+								if (actualObjectClicked.compareTo(cps.getName()) == 0) {
 									File checkPath = new File(cps.getImage());
 									File checkPath = new File(cps.getImage());
 									if (checkPath.exists()) {
 									if (checkPath.exists()) {
 										img = new ImageIcon(cps.getImage()).getImage().getScaledInstance(32, 32,
 										img = new ImageIcon(cps.getImage()).getImage().getScaledInstance(32, 32,
@@ -1323,61 +1270,6 @@ public class GUI {
 				aboutUsPopUp.setVisible(true);
 				aboutUsPopUp.setVisible(true);
 			}
 			}
 		});
 		});
-
-		/**
-		 * Update of every interaction between the user and the canvas (only on the
-		 * canvas). Basically the update of all the information concerning the clicked
-		 * HolonObject. For multi-selection, the propertyTable would be disabled
-		 */
-		canvas.addMouseListener(new MouseAdapter() {
-			@Override
-			public void mousePressed(MouseEvent e) {
-
-			}
-
-			@Override
-			public void mouseReleased(MouseEvent e) {
-				holonEleNamesDisplayed = "None";
-				// If any empty space is clicked
-				if (temp == null || temp.getId() != model.getSelectedObjectID()) {
-					hideScrollGraph();
-					elementGraph.setText("None");
-				}
-				temp = updCon.getActualCps();
-				// Erase old data in the PropertyTable
-				if (model.getPropertyTable().getRowCount() > 0) {
-					for (int i = model.getPropertyTable().getRowCount() - 1; i > -1; i--) {
-						model.getPropertyTable().removeRow(i);
-					}
-				}
-				if (e.isControlDown() && temp != null) {
-					if (model.getSelectedCpsObjects().contains(temp)) {
-						controller.deleteSelectedObject(temp);
-					} else {
-						controller.addSelectedObject(temp);
-					}
-				}
-				if (temp instanceof HolonSwitch) {
-					showScrollGraph();
-					updateUnitGraph((GraphEditable) temp);
-				}
-				// Write new data in the PropertyTable
-				triggerUpdateController(temp);
-
-				// New Tab with NodeOfNode
-				if (doubleClick() && MouseEvent.BUTTON3 != e.getButton() && temp instanceof GroupNode) {
-					openNewUpperNodeTab();
-					try {
-						controller.autoSave();
-					} catch (IOException e1) {
-						e1.printStackTrace();
-					}
-				}
-
-			}
-
-		});
-
 		// Del Button
 		// Del Button
 		btnDel.addActionListener(actionEvent -> {
 		btnDel.addActionListener(actionEvent -> {
 			Object nodeInfo = categoryTree.getLastSelectedPathComponent();
 			Object nodeInfo = categoryTree.getLastSelectedPathComponent();
@@ -1429,9 +1321,10 @@ public class GUI {
 			while (tabbedPaneInnerOriginal.getTabCount() > 1) {
 			while (tabbedPaneInnerOriginal.getTabCount() > 1) {
 				tabbedPaneInnerOriginal.remove(1);
 				tabbedPaneInnerOriginal.remove(1);
 			}
 			}
-			model.getSelectedCpsObjects().clear();
-			model.getEdgesOnCanvas().removeAll(model.getEdgesOnCanvas());
-			model.getObjectsOnCanvas().removeAll(model.getObjectsOnCanvas());
+			controller.clearSelection();
+			model.getEdgesOnCanvas().clear();
+			model.getObjectsOnCanvas().clear();
+			controller.OnSelectionChanged.broadcast();
 			controller.setSelectedObjectID(0);
 			controller.setSelectedObjectID(0);
 			controller.setSelecteEdge(null);
 			controller.setSelecteEdge(null);
 			controller.setCurIteration(0);
 			controller.setCurIteration(0);
@@ -1463,7 +1356,7 @@ public class GUI {
 						while (tabbedPaneInnerOriginal.getTabCount() > 1) {
 						while (tabbedPaneInnerOriginal.getTabCount() > 1) {
 							tabbedPaneInnerOriginal.remove(1);
 							tabbedPaneInnerOriginal.remove(1);
 						}
 						}
-						model.getSelectedCpsObjects().clear();
+						model.getSelectedObjects().clear();
 						controller.loadFile(file.getAbsolutePath());
 						controller.loadFile(file.getAbsolutePath());
 						canvas.repaint();
 						canvas.repaint();
 						categoryTree.repaint();
 						categoryTree.repaint();
@@ -1770,7 +1663,7 @@ public class GUI {
 					node1 = new DefaultMutableTreeNode(c.getName());
 					node1 = new DefaultMutableTreeNode(c.getName());
 
 
 					for (AbstractCanvasObject obj : c.getObjects()) {
 					for (AbstractCanvasObject obj : c.getObjects()) {
-						node1.add(new DefaultMutableTreeNode(obj.getObjName()));
+						node1.add(new DefaultMutableTreeNode(obj.getName()));
 					}
 					}
 					add(node1);
 					add(node1);
 				}
 				}
@@ -1820,16 +1713,16 @@ public class GUI {
 	/*
 	/*
 	 * Open a new Tab with an UpperNodeCanvas
 	 * Open a new Tab with an UpperNodeCanvas
 	 */
 	 */
-	private void openNewUpperNodeTab() {
+	public void openNewUpperNodeTab(GroupNode node) {
 		chooseTabTemp();
 		chooseTabTemp();
 
 
 		JScrollPane scrollPane = getScrollPaneFromTabbedPane();
 		JScrollPane scrollPane = getScrollPaneFromTabbedPane();
 		if (scrollPane.getViewport().getComponent(0) instanceof Canvas) {
 		if (scrollPane.getViewport().getComponent(0) instanceof Canvas) {
-			unc = new GroupNodeCanvas(model, controller, unitGraph, (GroupNode) temp, "",
+			unc = new GroupNodeCanvas(model, controller, unitGraph, node, "",
 					scrollPane.getViewport().getComponent(0));
 					scrollPane.getViewport().getComponent(0));
 
 
 		} else {
 		} else {
-			unc = new GroupNodeCanvas(model, controller, unitGraph, (GroupNode) temp,
+			unc = new GroupNodeCanvas(model, controller, unitGraph, node,
 					((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getParentPath() + " -> ",
 					((GroupNodeCanvas) scrollPane.getViewport().getComponent(0)).getParentPath() + " -> ",
 					scrollPane.getViewport().getComponent(0));
 					scrollPane.getViewport().getComponent(0));
 		}
 		}
@@ -1840,7 +1733,7 @@ public class GUI {
 		for (int i = 1; i < tabbedPaneInnerOriginal.getTabCount(); i++) {
 		for (int i = 1; i < tabbedPaneInnerOriginal.getTabCount(); i++) {
 			JScrollPane paneOriginal = (JScrollPane) tabbedPaneInnerOriginal.getComponentAt(i);
 			JScrollPane paneOriginal = (JScrollPane) tabbedPaneInnerOriginal.getComponentAt(i);
 			if (paneOriginal != null && ((GroupNodeCanvas) paneOriginal.getViewport().getComponent(0)).getGroupNode()
 			if (paneOriginal != null && ((GroupNodeCanvas) paneOriginal.getViewport().getComponent(0)).getGroupNode()
-					.getId() == temp.getId()) {
+					.getId() == node.getId()) {
 				dupl = true;
 				dupl = true;
 				// set selected component to view
 				// set selected component to view
 				tabbedPaneOriginal.setSelectedComponent(tabbedPaneInnerOriginal);
 				tabbedPaneOriginal.setSelectedComponent(tabbedPaneInnerOriginal);
@@ -1848,80 +1741,27 @@ public class GUI {
 				tabbedPaneInnerOriginal.setSelectedComponent(tabbedPaneInnerOriginal.getComponentAt(i));
 				tabbedPaneInnerOriginal.setSelectedComponent(tabbedPaneInnerOriginal.getComponentAt(i));
 			}
 			}
 
 
-			if (tabbedPaneSplit.getTabCount() > 0) {
-				JTabbedPane tabbedPaneInnerSplit = (JTabbedPane) tabbedPaneSplit.getComponentAt(0);
-				if (tabbedPaneInnerSplit != null) {
-					JScrollPane paneSplit = (JScrollPane) tabbedPaneInnerSplit.getComponentAt(i);
-					if (!initSplit && paneSplit != null && ((GroupNodeCanvas) paneSplit.getViewport().getComponent(0))
-							.getGroupNode().getId() == temp.getId()) {
-						dupl = true;
-						// set selected component to view
-						tabbedPaneSplit.setSelectedComponent(tabbedPaneInnerSplit);
-						// set selected tab in view to found upper-node-canvas
-						tabbedPaneInnerSplit.setSelectedComponent(tabbedPaneInnerSplit.getComponentAt(i));
-					}
-				}
-			}
-
 			// if we found a duplicate, break
 			// if we found a duplicate, break
 			if (dupl) {
 			if (dupl) {
 				break;
 				break;
 			}
 			}
 		}
 		}
 		if (!dupl) {
 		if (!dupl) {
-			unc.setBorder(null);
-			unc.setBackground(Color.WHITE);
-			unc.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
-
-			unc.addMouseListener(new MouseAdapter() {
-				@Override
-				public void mousePressed(MouseEvent e) {
-					hideScrollGraph();
-					holonEleNamesDisplayed = "None";
-					elementGraph.setText(holonEleNamesDisplayed);
-
-					chooseTabTemp();
-
-					JScrollPane scrollPane1 = getScrollPaneFromTabbedPane();
-					temp = ((GroupNodeCanvas) scrollPane1.getViewport().getComponent(0)).tempCps;
-					if (doubleClick() && MouseEvent.BUTTON3 != e.getButton() && temp instanceof GroupNode) {
-						openNewUpperNodeTab();
-					}
-					if (temp instanceof HolonSwitch) {
-						updateUnitGraph((GraphEditable) temp);
-					}
-				}
-
-			});
-
 			JScrollPane sp = new JScrollPane(unc);
 			JScrollPane sp = new JScrollPane(unc);
 			sp.setBorder(null);
 			sp.setBorder(null);
 
 
 			// Selected tabbed Pane = tabbedPaneOriginal or tabbedPaneSplit
 			// Selected tabbed Pane = tabbedPaneOriginal or tabbedPaneSplit
 			if (tabTemp == tabbedPaneOriginal) {
 			if (tabTemp == tabbedPaneOriginal) {
-				this.tabbedPaneInnerOriginal.add(temp.getName(), sp);
+				this.tabbedPaneInnerOriginal.add(node.getName(), sp);
 				this.tabbedPaneInnerOriginal.setSelectedComponent(sp);
 				this.tabbedPaneInnerOriginal.setSelectedComponent(sp);
 				this.tabbedPaneInnerOriginal.setTabComponentAt(this.tabbedPaneInnerOriginal.getTabCount() - 1,
 				this.tabbedPaneInnerOriginal.setTabComponentAt(this.tabbedPaneInnerOriginal.getTabCount() - 1,
-						new ButtonTabComponent(this.tabbedPaneInnerOriginal, tabbedPaneSplit));
+						new ButtonTabComponent(this.tabbedPaneInnerOriginal));
 
 
-			} else {
-				JTabbedPane tabbedPaneInnerSplit = (JTabbedPane) tabbedPaneSplit.getComponentAt(0);
-				tabbedPaneInnerSplit.add(temp.getName(), sp);
-				Component tempC = tabbedPaneInnerSplit.getSelectedComponent();
-				tabbedPaneInnerSplit.setComponentAt(tabbedPaneInnerSplit.getSelectedIndex(), null);
-				tabbedPaneOriginal.setComponentAt(tabbedPaneInnerSplit.getSelectedIndex(), tempC);
-				tabbedPaneInnerSplit.setSelectedComponent(sp);
-
-				tabbedPaneInnerOriginal.add(temp.getName(), null);
-				tabbedPaneInnerOriginal.setTabComponentAt(tabbedPaneInnerOriginal.getTabCount() - 1,
-						new ButtonTabComponent(tabbedPaneInnerOriginal, tabbedPaneInnerSplit));
 			}
 			}
-
-			temp = null;
 		}
 		}
 	}
 	}
 
 
-	// TODO remove me
+	// TODO refactor tabbedPane and access to groupNodeViews
 	private void updateUpperNodes() {
 	private void updateUpperNodes() {
 		for (Component c : tabbedPaneInnerOriginal.getComponents()) {
 		for (Component c : tabbedPaneInnerOriginal.getComponents()) {
 			if (!(c instanceof JScrollPane)) {
 			if (!(c instanceof JScrollPane)) {
@@ -1942,29 +1782,16 @@ public class GUI {
 	 */
 	 */
 	private void removeUpperNodeTab(AbstractCanvasObject cps) {
 	private void removeUpperNodeTab(AbstractCanvasObject cps) {
 		if (cps instanceof GroupNode) {
 		if (cps instanceof GroupNode) {
-			boolean splitView = false;
 			for (int i = 1; i < tabbedPaneInnerOriginal.getTabCount(); i++) {
 			for (int i = 1; i < tabbedPaneInnerOriginal.getTabCount(); i++) {
 				JScrollPane scrollPaneOriginal = (JScrollPane) tabbedPaneInnerOriginal.getComponentAt(i);
 				JScrollPane scrollPaneOriginal = (JScrollPane) tabbedPaneInnerOriginal.getComponentAt(i);
 
 
 				if (scrollPaneOriginal == null) {
 				if (scrollPaneOriginal == null) {
-					splitView = true;
 				} else if (((GroupNodeCanvas) scrollPaneOriginal.getViewport().getComponent(0)).getGroupNode()
 				} else if (((GroupNodeCanvas) scrollPaneOriginal.getViewport().getComponent(0)).getGroupNode()
 						.getId() == cps.getId()) {
 						.getId() == cps.getId()) {
 					((ButtonTabComponent) tabbedPaneInnerOriginal.getTabComponentAt(i)).removeTabs();
 					((ButtonTabComponent) tabbedPaneInnerOriginal.getTabComponentAt(i)).removeTabs();
 					break;
 					break;
 				}
 				}
 			}
 			}
-			// If SplitView is on and the view on
-			// tabbedPaneSplit is the deleted upperNode
-			if (splitView && tabbedPaneSplit.getComponentCount() > 0) {
-				JTabbedPane tabbedPaneInnerSplit = (JTabbedPane) tabbedPaneSplit.getComponentAt(0);
-
-				if (((GroupNodeCanvas) ((JScrollPane) tabbedPaneInnerSplit.getSelectedComponent()).getViewport()
-						.getComponent(0)).getGroupNode().getId() == cps.getId()) {
-					((ButtonTabComponent) tabbedPaneInnerOriginal
-							.getTabComponentAt(tabbedPaneInnerSplit.getSelectedIndex())).removeTabs();
-				}
-			}
 		}
 		}
 	}
 	}
 
 
@@ -1972,7 +1799,7 @@ public class GUI {
 	 * chooses whether to set the tabTemp to tabbedPaneOriginal or tabbedPaneSplit
 	 * chooses whether to set the tabTemp to tabbedPaneOriginal or tabbedPaneSplit
 	 */
 	 */
 	private void chooseTabTemp() {
 	private void chooseTabTemp() {
-		// TODO Remove me when not needed
+		// TODO Remove tabTabbed
 		tabTemp = tabbedPaneOriginal;
 		tabTemp = tabbedPaneOriginal;
 	}
 	}
 
 
@@ -2011,7 +1838,6 @@ public class GUI {
 		if (temp != null) {
 		if (temp != null) {
 			updCon.paintProperties(temp);
 			updCon.paintProperties(temp);
 		}
 		}
-		updCon.refreshTableHolonElement(model.getMultiTable(), model.getSingleTable());
 		updCon.refreshTableProperties(model.getPropertyTable());
 		updCon.refreshTableProperties(model.getPropertyTable());
 	}
 	}
 
 

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

@@ -72,7 +72,7 @@ public class GroupNodeCanvas extends Canvas {
 		// <--
 		// <--
 		// SelectedCable
 		// SelectedCable
 		HashSet<Edge> selectedEdges = new HashSet<Edge>();
 		HashSet<Edge> selectedEdges = new HashSet<Edge>();
-		for (AbstractCanvasObject aCps : model.getSelectedCpsObjects()) {
+		for (AbstractCanvasObject aCps : model.getSelectedObjects()) {
 			for (Edge edge : aCps.getConnections()) {
 			for (Edge edge : aCps.getConnections()) {
 				selectedEdges.add(edge);
 				selectedEdges.add(edge);
 			}
 			}
@@ -120,7 +120,7 @@ public class GroupNodeCanvas extends Canvas {
 		g2d.setColor(Color.BLUE);
 		g2d.setColor(Color.BLUE);
 		g2d.setStroke(new BasicStroke(1));
 		g2d.setStroke(new BasicStroke(1));
 		Color transparentGrey = new Color(128, 174, 247, 40);
 		Color transparentGrey = new Color(128, 174, 247, 40);
-		for (AbstractCanvasObject aCps : model.getSelectedCpsObjects()) {
+		for (AbstractCanvasObject aCps : model.getSelectedObjects()) {
 			if (aCps instanceof Node) {
 			if (aCps instanceof Node) {
 				Vector2Int pos = aCps.getPosition();
 				Vector2Int pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
 				g2d.setColor(transparentGrey);
@@ -172,7 +172,7 @@ public class GroupNodeCanvas extends Canvas {
 				}
 				}
 			}
 			}
 
 
-			if (e.getX() > groupNode.getLeftBorder()) {
+			if (e.getX() > 0) {
 				for (AbstractCanvasObject cps : groupNode.getNodes()) {
 				for (AbstractCanvasObject cps : groupNode.getNodes()) {
 					cx = cps.getPosition().getX() - model.getScaleDiv2();
 					cx = cps.getPosition().getX() - model.getScaleDiv2();
 					cy = cps.getPosition().getY() - model.getScaleDiv2();
 					cy = cps.getPosition().getY() - model.getScaleDiv2();
@@ -181,8 +181,9 @@ public class GroupNodeCanvas extends Canvas {
 
 
 						dragging = true;
 						dragging = true;
 						if (e.isControlDown() && tempCps != null) {
 						if (e.isControlDown() && tempCps != null) {
-							if (model.getSelectedCpsObjects().contains(tempCps)) {
-								controller.deleteSelectedObject(tempCps);
+							System.out.println("Add Remove Selection GROUPNODECANVAS");
+							if (model.getSelectedObjects().contains(tempCps)) {
+								controller.removeObjectFromSelection(tempCps);
 							} else {
 							} else {
 								controller.addSelectedObject(tempCps);
 								controller.addSelectedObject(tempCps);
 								if (tempCps instanceof GroupNode)
 								if (tempCps instanceof GroupNode)
@@ -212,10 +213,10 @@ public class GroupNodeCanvas extends Canvas {
 					} else {
 					} else {
 						cps = ed.getA();
 						cps = ed.getA();
 					}
 					}
-					if (x - controller.getScale() <= ((groupNode.getLeftBorder() >> 1) - model.getScaleDiv2())
+					if (x - controller.getScale() <= (model.getScaleDiv2())
 							&& y - controller.getScale() <= (scalediv20 + 5
 							&& y - controller.getScale() <= (scalediv20 + 5
 									+ (model.getScale() + scalediv20 + 10) * count)
 									+ (model.getScale() + scalediv20 + 10) * count)
-							&& x >= (groupNode.getLeftBorder() >> 1) - model.getScaleDiv2()
+							&& x >= model.getScaleDiv2()
 							&& y >= (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count)) {
 							&& y >= (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count)) {
 						tempCps = cps;
 						tempCps = cps;
 						// If drawing an Edge (CTRL down)
 						// If drawing an Edge (CTRL down)
@@ -237,7 +238,7 @@ public class GroupNodeCanvas extends Canvas {
 					controller.setSelecteEdge(edgeHighlight);
 					controller.setSelecteEdge(edgeHighlight);
 					controller.setSelectedObjectID(0);
 					controller.setSelectedObjectID(0);
 					if (!e.isControlDown() && e.getButton() != MouseEvent.BUTTON3) {
 					if (!e.isControlDown() && e.getButton() != MouseEvent.BUTTON3) {
-						model.getSelectedCpsObjects().clear();
+						controller.clearSelection();
 					}
 					}
 					updCon.deleteRows(model.getMultiTable());
 					updCon.deleteRows(model.getMultiTable());
 					updCon.deleteRows(model.getSingleTable());
 					updCon.deleteRows(model.getSingleTable());
@@ -278,7 +279,7 @@ public class GroupNodeCanvas extends Canvas {
 				/**
 				/**
 				 * check if tempCps could replace an Object on the UpperNodeanvas
 				 * check if tempCps could replace an Object on the UpperNodeanvas
 				 */
 				 */
-				if (model.getSelectedCpsObjects().size() == 1 && checkForReplacement(groupNode.getNodes(), tempCps,
+				if (model.getSelectedObjects().size() == 1 && checkForReplacement(groupNode.getNodes(), tempCps,
 						tempCps.getPosition().getX(), tempCps.getPosition().getY())) {
 						tempCps.getPosition().getX(), tempCps.getPosition().getY())) {
 					/**
 					/**
 					 * if UpperNode would be replaced, close its tabs
 					 * if UpperNode would be replaced, close its tabs
@@ -294,7 +295,7 @@ public class GroupNodeCanvas extends Canvas {
 			}
 			}
 
 
 			if (!e.isControlDown() && !dragged && tempCps != null && MouseEvent.BUTTON3 != e.getButton()) {
 			if (!e.isControlDown() && !dragged && tempCps != null && MouseEvent.BUTTON3 != e.getButton()) {
-				model.getSelectedCpsObjects().clear();
+				controller.clearSelection();
 				controller.addSelectedObject(tempCps);
 				controller.addSelectedObject(tempCps);
 				if (tempCps instanceof GroupNode)
 				if (tempCps instanceof GroupNode)
 					controller.getObjectsInDepth();
 					controller.getObjectsInDepth();
@@ -306,11 +307,13 @@ public class GroupNodeCanvas extends Canvas {
 			setRightClickMenu(e);
 			setRightClickMenu(e);
 
 
 			markObjects();
 			markObjects();
-
-			if (doubleClick() && tempCps != null && tempCps instanceof HolonSwitch) {
+			boolean doubleclick = doubleClick();  
+			if (doubleclick && tempCps != null && tempCps instanceof HolonSwitch) {
 				((HolonSwitch) tempCps).switchState();
 				((HolonSwitch) tempCps).switchState();
 			}
 			}
-
+			if (doubleclick && tempCps != null && tempCps instanceof GroupNode) {
+				controller.getGui().openNewUpperNodeTab((GroupNode)tempCps);
+			}
 			controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
 			controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
 			triggerUpdateController();
 			triggerUpdateController();
 			repaint();
 			repaint();
@@ -323,8 +326,8 @@ public class GroupNodeCanvas extends Canvas {
 			// If Edge is drawn
 			// If Edge is drawn
 			x = e.getX();
 			x = e.getX();
 			y = e.getY();
 			y = e.getY();
-			if (!model.getSelectedCpsObjects().contains(tempCps) && !doMark) {
-				model.getSelectedCpsObjects().clear();
+			if (!model.getSelectedObjects().contains(tempCps) && !doMark) {
+				controller.clearSelection();
 				if (tempCps != null) {
 				if (tempCps != null) {
 					controller.addSelectedObject(tempCps);
 					controller.addSelectedObject(tempCps);
 				}
 				}
@@ -341,8 +344,8 @@ public class GroupNodeCanvas extends Canvas {
 						y = e.getY();
 						y = e.getY();
 
 
 						// Make sure its in bounds
 						// Make sure its in bounds
-						if (e.getX() < controller.getScaleDiv2() + groupNode.getLeftBorder() + 5)
-							x = controller.getScaleDiv2() + groupNode.getLeftBorder() + 5;
+						if (e.getX() < controller.getScaleDiv2() +  + 5)
+							x = controller.getScaleDiv2() +  + 5;
 						else if (e.getX() > this.getWidth() - controller.getScaleDiv2())
 						else if (e.getX() > this.getWidth() - controller.getScaleDiv2())
 							x = this.getWidth() - controller.getScaleDiv2();
 							x = this.getWidth() - controller.getScaleDiv2();
 						if (e.getY() < controller.getScaleDiv2())
 						if (e.getY() < controller.getScaleDiv2())
@@ -363,14 +366,14 @@ public class GroupNodeCanvas extends Canvas {
 						toolTipPos.setY(tempCps.getPosition().getY() - model.getScaleDiv2());
 						toolTipPos.setY(tempCps.getPosition().getY() - model.getScaleDiv2());
 
 
 						// All Selected Objects
 						// All Selected Objects
-						for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
+						for (AbstractCanvasObject cps : model.getSelectedObjects()) {
 							if (cps != tempCps) {
 							if (cps != tempCps) {
 								x = (int) (cps.getPosition().getX() + xDist);
 								x = (int) (cps.getPosition().getX() + xDist);
 								y = (int) (cps.getPosition().getY() + yDist);
 								y = (int) (cps.getPosition().getY() + yDist);
 
 
 								// Make sure its in bounds
 								// Make sure its in bounds
-								if (x < groupNode.getLeftBorder() + 5 + controller.getScaleDiv2())
-									x = controller.getScaleDiv2() + groupNode.getLeftBorder() + 5;
+								if (x <  + 5 + controller.getScaleDiv2())
+									x = controller.getScaleDiv2() +  + 5;
 								else if (x > this.getWidth() - controller.getScaleDiv2())
 								else if (x > this.getWidth() - controller.getScaleDiv2())
 									x = this.getWidth() - controller.getScaleDiv2();
 									x = this.getWidth() - controller.getScaleDiv2();
 								if (y <= controller.getScaleDiv2())
 								if (y <= controller.getScaleDiv2())
@@ -385,7 +388,7 @@ public class GroupNodeCanvas extends Canvas {
 					/**
 					/**
 					 * check if something would be replaced
 					 * check if something would be replaced
 					 */
 					 */
-					if (model.getSelectedCpsObjects().size() == 1)
+					if (model.getSelectedObjects().size() == 1)
 						checkForReplacement(groupNode.getNodes(), tempCps, x, y);
 						checkForReplacement(groupNode.getNodes(), tempCps, x, y);
 
 
 					repaint();
 					repaint();
@@ -436,9 +439,9 @@ public class GroupNodeCanvas extends Canvas {
 						y2 = sy;
 						y2 = sy;
 					}
 					}
 
 
-					if (x1 <= groupNode.getLeftBorder() >> 1
+					if (x1 <= 0
 							&& y1 <= (int) (5 + (model.getScale() + scalediv20 + 10) * count) + model.getScaleDiv2()
 							&& y1 <= (int) (5 + (model.getScale() + scalediv20 + 10) * count) + model.getScaleDiv2()
-							&& x2 >= groupNode.getLeftBorder() >> 1
+							&& x2 >=  0
 							&& y2 >= (int) (5 + (model.getScale() + scalediv20 + 10) * count)) {
 							&& y2 >= (int) (5 + (model.getScale() + scalediv20 + 10) * count)) {
 						tempSelected.add(cps);
 						tempSelected.add(cps);
 
 
@@ -475,7 +478,7 @@ public class GroupNodeCanvas extends Canvas {
 					cps = ed.getA();
 					cps = ed.getA();
 				}
 				}
 
 
-				cx = groupNode.getLeftBorder() >> 1;
+				cx = 0 ;
 				cy = (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count);
 				cy = (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count);
 				if (x - 50 <= cx && y - 50 <= cy && x >= cx && y >= cy) {
 				if (x - 50 <= cx && y - 50 <= cy && x >= cx && y >= cy) {
 
 

+ 0 - 2
src/ui/view/IndexTranslator.java

@@ -6,8 +6,6 @@ import ui.model.Model;
 
 
 public class IndexTranslator {
 public class IndexTranslator {
 	public static int STANDARD_GRAPH_ACCURACY = 100;
 	public static int STANDARD_GRAPH_ACCURACY = 100;
-	// TODO assign model
-	// this refrence should be updated with the model
 	public static Model model;
 	public static Model model;
 	   /**
 	   /**
      * Determines the index of the internal value array
      * Determines the index of the internal value array

+ 218 - 43
src/ui/view/Inspector.java

@@ -1,95 +1,270 @@
 package ui.view;
 package ui.view;
 
 
+import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Dimension;
 import java.awt.GridLayout;
 import java.awt.GridLayout;
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
+import javax.swing.BorderFactory;
 import javax.swing.BoxLayout;
 import javax.swing.BoxLayout;
+import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JFormattedTextField;
 import javax.swing.JLabel;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JPanel;
+import javax.swing.JTextField;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
 
 
 import classes.AbstractCanvasObject;
 import classes.AbstractCanvasObject;
 import classes.HolonElement;
 import classes.HolonElement;
+import classes.HolonElement.Priority;
 import classes.HolonObject;
 import classes.HolonObject;
 import ui.controller.Control;
 import ui.controller.Control;
-import ui.model.Model;
+import ui.view.util.TrippleCheckBox;
+import utility.ImageImport;
+import utility.events.SimpleDocumentListener;
+
 
 
 public class Inspector extends JPanel {
 public class Inspector extends JPanel {
 	private List<HolonElement> elements = new ArrayList<>();
 	private List<HolonElement> elements = new ArrayList<>();
-	private Model model;
-	
+	private Control control;
+	private final int columnHeight = 19;
+	private final Inspector self;
+	private final ImageIcon deleteElementIcon = new ImageIcon(ImageImport.loadImage("Images/minus.png", 13, 13));
+	private final ImageIcon addElementIcon = new ImageIcon(ImageImport.loadImage("Images/plus.png", 13, 13));
+	private final Color selectedColor = new Color(126, 186, 255);
 	
 	
-	Inspector(Control control){
+	Inspector(Control control) {
 		control.OnSelectionChanged.addListener(() -> update_ui());
 		control.OnSelectionChanged.addListener(() -> update_ui());
-		model = control.getModel();
+		this.control = control;
+		UIManager.put("Spinner.editorAlignment", JTextField.LEFT);
 		initUI();
 		initUI();
+		this.add(header());
+		self = this;
 	}
 	}
+
 	public void update_ui() {
 	public void update_ui() {
-		System.out.println("OnSelectionChanged");
-		elements = extractElements(model.getSelectedCpsObjects());
-		//TODO Pooling
+		System.out.println("update_ui");
+		elements = extractElements(control.getModel().getSelectedObjects());
+		// TODO Pooling
 		this.removeAll();
 		this.removeAll();
 		this.add(header());
 		this.add(header());
-		for(HolonElement ele : elements) {
-			this.add(new ElementEdit(ele));
+		for (HolonElement element : elements) {
+			this.add(new ElementEdit(element));
+		}
+		if(!elements.isEmpty()) {
+			this.add(generateAddElementButton(elements.stream().findFirst().get()));
 		}
 		}
+
+		
+		revalidate();
+		repaint();
 	}
 	}
-	
-	
-	
+
 	private void initUI() {
 	private void initUI() {
 		this.setBackground(Color.white);
 		this.setBackground(Color.white);
 		this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
 		this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
-		this.add(header());
+		
 	}
 	}
-	
-	//	private final String[] columnNamesMulti = { "Object", "Nr.", "Device", "Energy", "Flexibility active", "Quantity", "Activated" };
+
 	private JPanel header() {
 	private JPanel header() {
-		JPanel header = new JPanel(new GridLayout(1,6));
-		header.add(new JLabel("Object"));
-		header.add(new JLabel("Nr."));
-		header.add(new JLabel("Device"));
-		header.add(new JLabel("Energy"));
-		//this.add(new JLabel("Flexibility"));
-		header.add(new JLabel("Quantity"));
-		header.add(new JLabel("Activated"));
-		header.setMaximumSize(new Dimension(Integer.MAX_VALUE, 30));
+		JPanel header = new JPanel(new GridLayout(1,7));
+		header.setMinimumSize(new Dimension(Integer.MIN_VALUE, columnHeight));
+		header.setMaximumSize(new Dimension(Integer.MAX_VALUE, columnHeight));
+		JPanel selectionPanel = new JPanel();
+		selectionPanel.setLayout(new BoxLayout(selectionPanel, BoxLayout.LINE_AXIS));
+		//Delete Button
+		JButton deleteButton = new JButton();
+		deleteButton.setIcon(deleteElementIcon);
+		deleteButton.setBorder(generateButtonHeaderBorder());
+		deleteButton.setContentAreaFilled(false);
+		deleteButton.setFocusPainted(false);
+		deleteButton.setToolTipText(
+				"<html><b>Remove this element</b><br>Removes this HolonElement from the HolonObject.</html>");
+		deleteButton.addActionListener(clicked ->{
+			System.out.println("hello");
+		});
+		
+		JButton addButton = new JButton();
+		addButton.setIcon(addElementIcon);
+		addButton.setBorder(generateButtonHeaderBorder());
+		addButton.setContentAreaFilled(false);
+		addButton.setFocusPainted(false);
+		TrippleCheckBox selectAllCheckBox = new TrippleCheckBox();
+		selectAllCheckBox.setBorder(generateButtonHeaderBorder());
+		selectionPanel.add(selectAllCheckBox);
+		selectionPanel.add(deleteButton, BorderLayout.LINE_END);
+		selectionPanel.add(addButton);
+		header.add(selectionPanel);
+		//Populate
+		String[] headerCoulumnTitles = {"Object", "Nr.", "Device", "Energy", "Priority", "Activ"};
+		for(String coulumnTitle : headerCoulumnTitles) {
+			header.add(generateHeaderColumnTitle(coulumnTitle));
+		}
 		return header;
 		return header;
 	}
 	}
+
+	private JLabel generateHeaderColumnTitle(String string) {
+		JLabel columnTitleLabel = new JLabel(string);
+		columnTitleLabel.setToolTipText(string);
+		columnTitleLabel.setBorder(generateHeaderBorder());
+		return columnTitleLabel;
+	}
 	
 	
-	private List<HolonElement> extractElements(List<AbstractCanvasObject> toInspect) {
-		//Extract elements from a list of AbstractCanvasObjects
+	private JPanel generateAddElementButton(HolonElement element) {
+		JPanel panel = new JPanel(new BorderLayout());
+		panel.setBorder(generateTableBorder());
+		panel.setBackground(Color.white);
+		panel.setMinimumSize(new Dimension(Integer.MIN_VALUE, columnHeight));
+		panel.setMaximumSize(new Dimension(Integer.MAX_VALUE, columnHeight));
+		JButton button = new JButton();
+		button.setIcon(addElementIcon);
+		button.setBorder(null);
+		button.setBackground(Color.white);
+		button.addActionListener(clicked -> {
+			element.parentObject.addElement(new HolonElement(element));
+			update_ui();
+			
+		});
+		panel.add(button, BorderLayout.CENTER);
+		return panel;
+	}
+	
+
+	private List<HolonElement> extractElements(Collection<AbstractCanvasObject> toInspect) {
+		// Extract elements from a list of AbstractCanvasObjects
 		return toInspect.stream().filter(obj -> obj instanceof HolonObject).flatMap(obj -> {
 		return toInspect.stream().filter(obj -> obj instanceof HolonObject).flatMap(obj -> {
 			HolonObject ho = (HolonObject) obj;
 			HolonObject ho = (HolonObject) obj;
 			return ho.getElements().stream();
 			return ho.getElements().stream();
 		}).collect(Collectors.toList());
 		}).collect(Collectors.toList());
 	}
 	}
-	
-	
-	private class ElementEdit extends JPanel{
+
+	private Border generateTableBorder() {
+		return BorderFactory.createMatteBorder(1, 1, 0, 0, Color.LIGHT_GRAY);
+	}
+
+	private Border generateHeaderBorder() {
+		return BorderFactory.createEmptyBorder(1, 2, 0, 0);
+	}
+	private Border generateButtonHeaderBorder() {
+		return BorderFactory.createEmptyBorder(2, 2, 0, 0);
+	}
+
+	private class ElementEdit extends JPanel {
 		HolonElement element;
 		HolonElement element;
-		ElementEdit(HolonElement element){
+
+		ElementEdit(HolonElement element) {
 			this.element = element;
 			this.element = element;
 			this.initUI();
 			this.initUI();
-			this.add(new JLabel(this.element.parentObject.getName()));
-			this.add(new JLabel(Integer.toString(this.element.getId())));
-			this.add(new JLabel(this.element.getEleName()));
-			this.add(new JLabel(Float.toString(this.element.getEnergyPerElement())));
-			this.add(new JLabel(Integer.toString(this.element.getAmount())));
-			this.add(new JLabel(Boolean.toString(this.element.isActive())));
+			this.createEditFields();
 		}
 		}
+		
 		private void initUI() {
 		private void initUI() {
-			//this.setBackground(Color.gray);
-			this.setLayout(new GridLayout(1,6));
-			this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 30));
+			this.setBackground(Color.white);
+			this.setLayout(new GridLayout(1, 7));
+			this.setMinimumSize(new Dimension(Integer.MIN_VALUE, columnHeight));
+			this.setMaximumSize(new Dimension(Integer.MAX_VALUE, columnHeight));
 		}
 		}
-		
-	}
-}
+		private void createEditFields(){
+			//Selected
+			JPanel selectedColumnPanel = new JPanel(new BorderLayout());
+			selectedColumnPanel.setBorder(generateTableBorder());
+			selectedColumnPanel.setOpaque(false);
+			this.add(selectedColumnPanel);
+			JCheckBox selected = new JCheckBox();
+			selected.setBorder(generateTableBorder());
+			selected.setOpaque(false);
+			selected.addActionListener(clicked -> {
+				this.setBackground(selected.isSelected() ? selectedColor : Color.white);
+			});
+			selectedColumnPanel.add(selected, BorderLayout.CENTER);
+			
+			//ObjectName and ID
+			JPanel objectNamePanel = new JPanel(new BorderLayout());
+			JTextField objectNameTextField = new JTextField(this.element.parentObject.getName());
+			objectNameTextField.setBorder(generateTableBorder());
+			objectNameTextField.getDocument().addDocumentListener((SimpleDocumentListener) e -> {
+				this.element.parentObject.setName(objectNameTextField.getText());
+				
+			});
+			objectNameTextField.setOpaque(false);
+			objectNameTextField.setBorder(BorderFactory.createEmptyBorder());
+			objectNameTextField.addActionListener(ae -> update_ui());
+			
+			JLabel idLabel = new JLabel("[" + this.element.parentObject.getId() + "]");
+			objectNamePanel.add(objectNameTextField, BorderLayout.CENTER);
+			objectNamePanel.setBorder(generateTableBorder());
+			objectNamePanel.add(idLabel, BorderLayout.LINE_END);
+			objectNamePanel.setOpaque(false);
+			idLabel.setForeground(Color.gray);
+			idLabel.setToolTipText("HolonObject's ID");
+			this.add(objectNamePanel);
 
 
+			//Id
+			JLabel idTextField = new JLabel(Integer.toString(this.element.getId()));
+			idTextField.setBorder(generateTableBorder());
+			this.add(idTextField);
+			
+			//Name
+			JTextField elementNameTextField = new JTextField(this.element.getEleName());
+			elementNameTextField.setBorder(generateTableBorder());
+			elementNameTextField.getDocument().addDocumentListener((SimpleDocumentListener) e -> {
+				this.element.setEleName(elementNameTextField.getText());
+			});
+			elementNameTextField.setOpaque(false);
+			this.add(elementNameTextField);
+			// Energy
+			JFormattedTextField energyTextField = new JFormattedTextField();
+			energyTextField.setValue(this.element.getEnergy());
+			energyTextField.setOpaque(false);
+			energyTextField.addPropertyChangeListener(actionEvent -> {
+				float energy = (float)energyTextField.getValue();
+				if(this.element.getEnergy() != energy) {
+					this.element.setEnergyPerElement(energy);
+					control.calculateStateAndVisualForCurrentTimeStep();
+				}
+			});
+			energyTextField.setBorder(generateTableBorder());
+			this.add(energyTextField);
+			
+			//Priority
+			JComboBox<Priority> comboBox = new JComboBox<Priority>(Priority.values());
+			comboBox.setSelectedItem(this.element.getPriority());
+			comboBox.setOpaque(false);
+			comboBox.setBorder(generateTableBorder());
+			comboBox.setEditable(false);
+			comboBox.addActionListener(ae -> {
+				this.element.setPriority((Priority)comboBox.getSelectedItem());
+			});
+			this.add(comboBox);
 
 
+			//Active Delete Column
+			
+			JPanel checkBoxWrapperPanel = new JPanel(new BorderLayout());
+			checkBoxWrapperPanel.setBorder(generateTableBorder());
+			checkBoxWrapperPanel.setOpaque(false);
+			this.add(checkBoxWrapperPanel);
 
 
+			// Active
+			JCheckBox checkbox = new JCheckBox();
+			checkbox.setSelected(this.element.isActive());
+			checkbox.setOpaque(false);
+			checkbox.addActionListener(actionEvent -> {
+				this.element.setActive(checkbox.isSelected());
+				control.calculateStateAndVisualForCurrentTimeStep();
+			});
+			checkBoxWrapperPanel.add(checkbox, BorderLayout.LINE_START);
+			
+			
+			
+		}
 
 
+	}
+}

+ 0 - 4
src/ui/view/Outliner.java

@@ -165,25 +165,21 @@ public class Outliner extends JFrame {
 
 
 		@Override
 		@Override
 		public void treeNodesChanged(TreeModelEvent tmE) {
 		public void treeNodesChanged(TreeModelEvent tmE) {
-			// TODO Auto-generated method stub
 			System.out.println("treeNodesChanged");
 			System.out.println("treeNodesChanged");
 		}
 		}
 
 
 		@Override
 		@Override
 		public void treeNodesInserted(TreeModelEvent tmE) {
 		public void treeNodesInserted(TreeModelEvent tmE) {
-			// TODO Auto-generated method stub
 			System.out.println("treeNodesInserted");
 			System.out.println("treeNodesInserted");
 		}
 		}
 
 
 		@Override
 		@Override
 		public void treeNodesRemoved(TreeModelEvent tmE) {
 		public void treeNodesRemoved(TreeModelEvent tmE) {
-			// TODO Auto-generated method stub
 			System.out.println("treeNodesRemoved");
 			System.out.println("treeNodesRemoved");
 		}
 		}
 
 
 		@Override
 		@Override
 		public void treeStructureChanged(TreeModelEvent tmE) {
 		public void treeStructureChanged(TreeModelEvent tmE) {
-			// TODO Auto-generated method stub
 			System.out.println("treeStructureChanged");
 			System.out.println("treeStructureChanged");
 		}
 		}
 	
 	

+ 30 - 25
src/ui/view/SearchPopUp.java

@@ -1,14 +1,22 @@
 package ui.view;
 package ui.view;
 
 
-import classes.AbstractCanvasObject;
-import ui.controller.Control;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import java.awt.*;
+import java.awt.BorderLayout;
+import java.awt.Font;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.ActionListener;
-import java.util.ArrayList;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JRadioButton;
+import javax.swing.JTextField;
+import javax.swing.border.EmptyBorder;
+
+import classes.AbstractCanvasObject;
+import ui.controller.Control;
 
 
 /**
 /**
  * This Class represents a popup to seatch for Objects on the Canvas.
  * This Class represents a popup to seatch for Objects on the Canvas.
@@ -114,24 +122,24 @@ public class SearchPopUp extends JDialog {
 					for (AbstractCanvasObject cps : controller.getModel().getObjectsOnCanvas()) {
 					for (AbstractCanvasObject cps : controller.getModel().getObjectsOnCanvas()) {
 
 
 						if (cps.getName().equals(findTextField.getText())
 						if (cps.getName().equals(findTextField.getText())
-								&& !controller.getModel().getSelectedCpsObjects().contains(cps)) {
-							controller.getModel().getSelectedCpsObjects().add(cps);
+								&& !controller.getModel().getSelectedObjects().contains(cps)) {
+							controller.getModel().getSelectedObjects().add(cps);
 						}
 						}
 
 
 					}
 					}
 
 
 				}
 				}
 				if (rdbtnSingle.isSelected()) {
 				if (rdbtnSingle.isSelected()) {
-					controller.getModel().getSelectedCpsObjects().clear();
+					controller.getModel().getSelectedObjects().clear();
 
 
 					if (!controller.getModel().getObjectsOnCanvas().isEmpty() && !findTextField.getText().isEmpty()) {
 					if (!controller.getModel().getObjectsOnCanvas().isEmpty() && !findTextField.getText().isEmpty()) {
 
 
 						if (rdbtnForward.isSelected()) {
 						if (rdbtnForward.isSelected()) {
 							if ((idx = getNext(++idx)) != -1)
 							if ((idx = getNext(++idx)) != -1)
-								controller.getModel().getSelectedCpsObjects().add(getObj(idx));
+								controller.getModel().getSelectedObjects().add(getObj(idx));
 						} else if (rdbtnBackward.isSelected()) {
 						} else if (rdbtnBackward.isSelected()) {
 							if ((idx = getPrev(--idx)) != -1)
 							if ((idx = getPrev(--idx)) != -1)
-								controller.getModel().getSelectedCpsObjects().add(getObj(idx));
+								controller.getModel().getSelectedObjects().add(getObj(idx));
 						}
 						}
 					}
 					}
 
 
@@ -148,10 +156,8 @@ public class SearchPopUp extends JDialog {
 		JButton btnReplace = new JButton("Replace");
 		JButton btnReplace = new JButton("Replace");
 		btnReplace.addActionListener(new ActionListener() {
 		btnReplace.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 			public void actionPerformed(ActionEvent e) {
-
-				if (controller.getModel().getSelectedCpsObjects().size() == 1 && controller.getModel()
-						.getSelectedCpsObjects().get(0).getName().equals(findTextField.getText()))
-					controller.getModel().getSelectedCpsObjects().get(0).setName(replaceTextField.getText());
+				//TODO fix or remove SearchPopUp
+				System.out.println("REPLACE");
 				canvas.repaint();
 				canvas.repaint();
 			}
 			}
 		});
 		});
@@ -164,16 +170,15 @@ public class SearchPopUp extends JDialog {
 		btnReplaceAll.addActionListener(new ActionListener() {
 		btnReplaceAll.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 			public void actionPerformed(ActionEvent e) {
 				canvas.tempCps = null;
 				canvas.tempCps = null;
-				canvas.tempSelected = new ArrayList<>();
-				controller.getModel().getSelectedCpsObjects().clear();
+				controller.getModel().getSelectedObjects().clear();
 
 
 				for (AbstractCanvasObject cps : controller.getModel().getObjectsOnCanvas()) {
 				for (AbstractCanvasObject cps : controller.getModel().getObjectsOnCanvas()) {
 					if (cps.getName().equals(findTextField.getText())
 					if (cps.getName().equals(findTextField.getText())
-							&& !controller.getModel().getSelectedCpsObjects().contains(cps))
+							&& !controller.getModel().getSelectedObjects().contains(cps))
 						selectObj(cps);
 						selectObj(cps);
 				}
 				}
 
 
-				for (AbstractCanvasObject cps : controller.getModel().getSelectedCpsObjects()) {
+				for (AbstractCanvasObject cps : controller.getModel().getSelectedObjects()) {
 					renameObj(cps, replaceTextField.getText());
 					renameObj(cps, replaceTextField.getText());
 				}
 				}
 
 
@@ -212,7 +217,7 @@ public class SearchPopUp extends JDialog {
 	 *            The Object
 	 *            The Object
 	 */
 	 */
 	public void selectObj(AbstractCanvasObject obj) {
 	public void selectObj(AbstractCanvasObject obj) {
-		controller.getModel().getSelectedCpsObjects().add(obj);
+		controller.getModel().getSelectedObjects().add(obj);
 	}
 	}
 
 
 	/**
 	/**
@@ -248,12 +253,12 @@ public class SearchPopUp extends JDialog {
 	public int getNext(int idx) {
 	public int getNext(int idx) {
 		for (int i = idx; i < controller.getModel().getObjectsOnCanvas().size(); i++) {
 		for (int i = idx; i < controller.getModel().getObjectsOnCanvas().size(); i++) {
 			if (getObj(i).getName().equals(findTextField.getText())
 			if (getObj(i).getName().equals(findTextField.getText())
-					&& !controller.getModel().getSelectedCpsObjects().contains(getObj(i)))
+					&& !controller.getModel().getSelectedObjects().contains(getObj(i)))
 				return i;
 				return i;
 		}
 		}
 		for (int i = 0; i < idx; i++) {
 		for (int i = 0; i < idx; i++) {
 			if (getObj(i).getName().equals(findTextField.getText())
 			if (getObj(i).getName().equals(findTextField.getText())
-					&& !controller.getModel().getSelectedCpsObjects().contains(getObj(i)))
+					&& !controller.getModel().getSelectedObjects().contains(getObj(i)))
 				return i;
 				return i;
 		}
 		}
 		return -1;
 		return -1;
@@ -269,12 +274,12 @@ public class SearchPopUp extends JDialog {
 	public int getPrev(int idx) {
 	public int getPrev(int idx) {
 		for (int i = idx; i >= 0; i--) {
 		for (int i = idx; i >= 0; i--) {
 			if (getObj(i).getName().equals(findTextField.getText())
 			if (getObj(i).getName().equals(findTextField.getText())
-					&& !controller.getModel().getSelectedCpsObjects().contains(getObj(i)))
+					&& !controller.getModel().getSelectedObjects().contains(getObj(i)))
 				return i;
 				return i;
 		}
 		}
 		for (int i = controller.getModel().getObjectsOnCanvas().size() - 1; i > idx; i--) {
 		for (int i = controller.getModel().getObjectsOnCanvas().size() - 1; i > idx; i--) {
 			if (getObj(i).getName().equals(findTextField.getText())
 			if (getObj(i).getName().equals(findTextField.getText())
-					&& !controller.getModel().getSelectedCpsObjects().contains(getObj(i)))
+					&& !controller.getModel().getSelectedObjects().contains(getObj(i)))
 				return i;
 				return i;
 		}
 		}
 		return -1;
 		return -1;

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

@@ -116,20 +116,13 @@ public class TimePanel extends JPanel implements ActionListener{
 		super();
 		super();
 		this.controller = cont;
 		this.controller = cont;
 		// One Iteration
 		// One Iteration
-		timer = new Timer(0, new ActionListener() {//TODO: Merge all these damned listeners.
+		timer = new Timer(0, new ActionListener() {
 			@Override
 			@Override
 			public void actionPerformed(ActionEvent ae) {
 			public void actionPerformed(ActionEvent ae) {
 				timeSlider.setValue(timeSlider.getValue() + 1);
 				timeSlider.setValue(timeSlider.getValue() + 1);
 				controller.setCurIteration(timeSlider.getValue());
 				controller.setCurIteration(timeSlider.getValue());
 				timer.setDelay(cont.getModel().getTimerSpeed());
 				timer.setDelay(cont.getModel().getTimerSpeed());
 				if (timeSlider.getValue() >= cont.getModel().getIterations() - 1) {
 				if (timeSlider.getValue() >= cont.getModel().getIterations() - 1) {
-					/*/calc and print performance
-					performanceTime = System.nanoTime()-performanceTime;
-					
-					System.out.println(performanceTime/1000000000 + " Sekunden "
-							+ (performanceTime%1000000000)/1000000 + " Millisekunden "
-							+ (performanceTime%1000000)/1000 + " Mikrosekunden ");
-					//*/
 					running = false;
 					running = false;
 					playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/play.png", 30, 30)));
 					playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/play.png", 30, 30)));
 					timer.stop();
 					timer.stop();

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

@@ -52,7 +52,6 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	Color editDotColor = new Color(255, 119, 0);
 	Color editDotColor = new Color(255, 119, 0);
 	
 	
 	//Intern Variables
 	//Intern Variables
-	//TODO: JavaDoc
 	private LinkedList<UnitGraphPoint> actualGraphPoints = new LinkedList<UnitGraphPoint>();
 	private LinkedList<UnitGraphPoint> actualGraphPoints = new LinkedList<UnitGraphPoint>();
 	private Graphtype actualGraphType;
 	private Graphtype actualGraphType;
 	private GraphEditable actualElement;
 	private GraphEditable actualElement;

+ 94 - 0
src/ui/view/util/TrippleCheckBox.java

@@ -0,0 +1,94 @@
+package ui.view.util;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Graphics;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.Icon;
+import javax.swing.JCheckBox;
+import javax.swing.UIManager;
+
+public class TrippleCheckBox extends JCheckBox implements Icon, ActionListener {
+
+	public enum Mode {
+		unselected, mid_state_selection, selected
+	};
+
+	Mode mode;
+	final static Icon icon = UIManager.getIcon("CheckBox.icon");
+
+	public TrippleCheckBox() {
+		this("", Mode.unselected);
+	}
+
+	public TrippleCheckBox(String text) {
+		this(text, Mode.unselected);
+	}
+
+	public TrippleCheckBox(String text, Mode selection) {
+		super(text, selection != Mode.unselected);
+		setSelectionState(selection);
+		addActionListener(this);
+		setIcon(this);
+	}
+
+	@Override
+	public boolean isSelected() {
+		return (getSelectionState() != Mode.unselected);
+	}
+
+	public Mode getSelectionState() {
+		return mode;
+	}
+
+	public void setSelectionState(Mode selection) {
+		setSelected(selection != Mode.unselected);
+		mode = selection;
+	}
+
+
+	@Override
+	public void paintIcon(Component c, Graphics g, int x, int y) {
+		icon.paintIcon(c, g, x, y);
+		if (getSelectionState() != Mode.mid_state_selection)
+			return;
+
+		int w = getIconWidth();
+		int h = getIconHeight();
+		g.setColor(Color.white);
+		g.fillRect(x + 1, y + 1, w - 2, h - 2);
+		g.setColor(c.isEnabled() ? new Color(51, 51, 51) : new Color(122, 138, 153));
+		g.fillRect(x + 4, y + 4, w - 8, h - 8);
+
+		if (!c.isEnabled())
+			return;
+		g.setColor(new Color(81, 81, 81));
+		g.drawRect(x + 4, y + 4, w - 9, h - 9);
+	}
+
+	@Override
+	public int getIconWidth() {
+		return icon.getIconWidth();
+	}
+
+	@Override
+	public int getIconHeight() {
+		return icon.getIconHeight();
+	}
+
+	public void actionPerformed(ActionEvent e) {
+		switch (getSelectionState()) {
+		case unselected:
+			setSelectionState(Mode.selected);
+			break;
+		case mid_state_selection:
+			setSelectionState(Mode.unselected);
+			break;
+		case selected:
+			setSelectionState(Mode.unselected);
+			break;
+		}
+	}
+}

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

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

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

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

+ 16 - 0
src/utility/events/LostFocusListener.java

@@ -0,0 +1,16 @@
+package utility.events;
+
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+
+@FunctionalInterface
+public interface LostFocusListener extends FocusListener {
+	void update(FocusEvent e);
+	
+	default void focusGained(FocusEvent e) {
+	}
+
+	default void focusLost(FocusEvent e) {
+		update(e);
+	}
+}

+ 24 - 0
src/utility/events/SimpleDocumentListener.java

@@ -0,0 +1,24 @@
+package utility.events;
+
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+
+@FunctionalInterface
+public interface SimpleDocumentListener extends DocumentListener {
+    void update(DocumentEvent e);
+
+    @Override
+    default void insertUpdate(DocumentEvent e) {
+        update(e);
+    }
+    @Override
+    default void removeUpdate(DocumentEvent e) {
+        update(e);
+    }
+    @Override
+    default void changedUpdate(DocumentEvent e) {
+        update(e);
+    }
+}
+
+

+ 1 - 1
tests/tests/PraktikumHolonsAdapter.java

@@ -44,7 +44,7 @@ public class PraktikumHolonsAdapter {
 	 */
 	 */
 	public void generateElements(ArrayList<HolonElement> arr) {
 	public void generateElements(ArrayList<HolonElement> arr) {
 		for (int i = 1; i < 18279; i++) {
 		for (int i = 1; i < 18279; i++) {
-			arr.add(new HolonElement(null, generate(i), 1, 10, IdCounter.nextId(CounterType.Element)));
+			arr.add(new HolonElement(null, generate(i), 1, IdCounter.nextId(CounterType.Element)));
 		}
 		}
 	}
 	}
 	
 	

+ 3 - 3
tests/tests/PraktikumHolonsTestCanvasController.java

@@ -198,9 +198,9 @@ public class PraktikumHolonsTestCanvasController {
 
 
 		
 		
 		assertTrue("Clipboard not empty", model.getClipboradObjects().isEmpty());
 		assertTrue("Clipboard not empty", model.getClipboradObjects().isEmpty());
-		model.getSelectedCpsObjects().add(a);
-		model.getSelectedCpsObjects().add(b);
-		model.getSelectedCpsObjects().add(c);
+		model.getSelectedObjects().add(a);
+		model.getSelectedObjects().add(b);
+		model.getSelectedObjects().add(c);
 		//controller.copyObjects();
 		//controller.copyObjects();
 		//assertTrue("Clipboard empty", !model.getClipboradObjects().isEmpty());
 		//assertTrue("Clipboard empty", !model.getClipboradObjects().isEmpty());
 	
 	

+ 6 - 6
tests/tests/PraktikumHolonsTestCategoryController.java

@@ -43,7 +43,7 @@ public class PraktikumHolonsTestCategoryController {
 		assertTrue("Number of Categories is not 3", model.getCategories().size() == 3);
 		assertTrue("Number of Categories is not 3", model.getCategories().size() == 3);
 		assertTrue("Second Category is not Building", model.getCategories().get(1).getName().equals("Building"));
 		assertTrue("Second Category is not Building", model.getCategories().get(1).getName().equals("Building"));
 		assertTrue("Category Building is Empty", !model.getCategories().get(1).getObjects().isEmpty());
 		assertTrue("Category Building is Empty", !model.getCategories().get(1).getObjects().isEmpty());
-		assertEquals("Object is not a Power Plant", mp.searchCat("Energy").getObjects().get(0).getObjName(),
+		assertEquals("Object is not a Power Plant", mp.searchCat("Energy").getObjects().get(0).getName(),
 				"Power Plant");
 				"Power Plant");
 		assertFalse("A Switch should not be a Holon Object",
 		assertFalse("A Switch should not be a Holon Object",
 				mp.searchCatObj(mp.searchCat("Component"), "Switch") instanceof HolonObject);
 				mp.searchCatObj(mp.searchCat("Component"), "Switch") instanceof HolonObject);
@@ -126,18 +126,18 @@ public class PraktikumHolonsTestCategoryController {
 		assertTrue("Number of Objects in Energy is not 4", mp.searchCat("Energy").getObjects().size() == 4);
 		assertTrue("Number of Objects in Energy is not 4", mp.searchCat("Energy").getObjects().size() == 4);
 		assertTrue("Number of Object-Indices in Energy is not 4", mp.searchCat("Energy").getObjIdx().size() == 4);
 		assertTrue("Number of Object-Indices in Energy is not 4", mp.searchCat("Energy").getObjIdx().size() == 4);
 		assertTrue("Object was not renamed to \"Power Plant_0\" ",
 		assertTrue("Object was not renamed to \"Power Plant_0\" ",
-				mp.searchCat("Energy").getObjects().get(1).getObjName().equals("Power Plant_0"));
+				mp.searchCat("Energy").getObjects().get(1).getName().equals("Power Plant"));
 		assertTrue("Object was not renamed to \"Power Plant_1\" ",
 		assertTrue("Object was not renamed to \"Power Plant_1\" ",
-				mp.searchCat("Energy").getObjects().get(2).getObjName().equals("Power Plant_1"));
+				mp.searchCat("Energy").getObjects().get(2).getName().equals("Power Plant"));
 		assertTrue("3th Object was not \"Power Plant_1\"",
 		assertTrue("3th Object was not \"Power Plant_1\"",
-				mp.searchCat("Energy").getObjects().get(2).getName().equals("Power Plant_1"));
+				mp.searchCat("Energy").getObjects().get(2).getName().equals("Power Plant"));
 		controller.deleteObject("Energy", "Power Plant_1");
 		controller.deleteObject("Energy", "Power Plant_1");
 		assertTrue("3th Object was not deleted",
 		assertTrue("3th Object was not deleted",
 				mp.searchCat("Energy").getObjects().get(2).getName().equals("Solar Plant"));
 				mp.searchCat("Energy").getObjects().get(2).getName().equals("Solar Plant"));
 		assertTrue("Number of Objects in Energy is not 3", mp.searchCat("Energy").getObjects().size() == 3);
 		assertTrue("Number of Objects in Energy is not 3", mp.searchCat("Energy").getObjects().size() == 3);
 		controller.addNewHolonObject(mp.searchCat("Energy"), "Solar Plant", null, "");
 		controller.addNewHolonObject(mp.searchCat("Energy"), "Solar Plant", null, "");
 		assertTrue("Object was not renamed to \"Solar Plant_0\" ",
 		assertTrue("Object was not renamed to \"Solar Plant_0\" ",
-				mp.searchCat("Energy").getObjects().get(3).getObjName().equals("Solar Plant_0"));
+				mp.searchCat("Energy").getObjects().get(3).getName().equals("Solar Plant_0"));
 		assertTrue("Number of Objects in Energy is not 4", mp.searchCat("Energy").getObjects().size() == 4);
 		assertTrue("Number of Objects in Energy is not 4", mp.searchCat("Energy").getObjects().size() == 4);
 	}
 	}
 
 
@@ -155,7 +155,7 @@ public class PraktikumHolonsTestCategoryController {
 			assertTrue("Objects were not added", mp.searchCat("Energy").getObjects().size() == i * 2 + 1);
 			assertTrue("Objects were not added", mp.searchCat("Energy").getObjects().size() == i * 2 + 1);
 
 
 			assertTrue("Object was not renamed to \"" + adapter.generate(i) + "_0\"", mp.searchCat("Energy")
 			assertTrue("Object was not renamed to \"" + adapter.generate(i) + "_0\"", mp.searchCat("Energy")
-					.getObjects().get(i * 2).getObjName().equals(adapter.generate(i) + "_0"));
+					.getObjects().get(i * 2).getName().equals(adapter.generate(i) + "_0"));
 		}
 		}
 		//deleting the duplicates
 		//deleting the duplicates
 		controller.deleteObject("Energy", "E_0");
 		controller.deleteObject("Energy", "E_0");

+ 4 - 8
tests/tests/PraktikumHolonsTestClasses.java

@@ -54,7 +54,7 @@ public class PraktikumHolonsTestClasses {
 		HolonObject test1 = new HolonObject("Test1");
 		HolonObject test1 = new HolonObject("Test1");
 		HolonObject test2 = new HolonObject("Test2");
 		HolonObject test2 = new HolonObject("Test2");
 		HolonObject test3 = new HolonObject(test1);
 		HolonObject test3 = new HolonObject(test1);
-		HolonElement ele = new HolonElement(test1, "Element", 1, 10, IdCounter.nextId(CounterType.Element));
+		HolonElement ele = new HolonElement(test1, "Element", 10, IdCounter.nextId(CounterType.Element));
 		ArrayList<HolonElement> arr = new ArrayList<>();
 		ArrayList<HolonElement> arr = new ArrayList<>();
 		assertTrue("Should be Empty", test1.getElements().isEmpty());
 		assertTrue("Should be Empty", test1.getElements().isEmpty());
 		test1.setElements(arr);
 		test1.setElements(arr);
@@ -69,7 +69,7 @@ public class PraktikumHolonsTestClasses {
 		assertTrue("Current Energy not corrent", test2.getEnergyAtTimeStep(20) == 20);
 		assertTrue("Current Energy not corrent", test2.getEnergyAtTimeStep(20) == 20);
 		String str = test2.toStringElements();
 		String str = test2.toStringElements();
 		assertTrue("String not corrent", str.equals("Element, Element"));
 		assertTrue("String not corrent", str.equals("Element, Element"));
-		test2.deleteElement(0);
+		test2.removeElement(0);
 		test2.addElement(ele);
 		test2.addElement(ele);
 		
 		
 		assertTrue("Element not Found", test3.searchElement("Element") != null);
 		assertTrue("Element not Found", test3.searchElement("Element") != null);
@@ -134,17 +134,13 @@ public class PraktikumHolonsTestClasses {
 	 */
 	 */
 	@Test
 	@Test
 	public void testHolonElement() {
 	public void testHolonElement() {
-		HolonElement ele1 = new HolonElement(null, "TV", 2, -20f, IdCounter.nextId(CounterType.Element));
-		HolonElement ele2 = new HolonElement(null, "Fridge", 1, -50f, IdCounter.nextId(CounterType.Element));
+		HolonElement ele1 = new HolonElement(null, "TV", -20f, IdCounter.nextId(CounterType.Element));
+		HolonElement ele2 = new HolonElement(null, "Fridge", -50f, IdCounter.nextId(CounterType.Element));
         assertTrue("Array not empty",  ele1.getEnergyAtTimeStep(0) == -40);
         assertTrue("Array not empty",  ele1.getEnergyAtTimeStep(0) == -40);
         assertTrue("Array not empty", ele1.getEnergyAtTimeStep(2) == -40);
         assertTrue("Array not empty", ele1.getEnergyAtTimeStep(2) == -40);
         assertTrue("Name not correct", ele1.getEleName().equals("TV"));
         assertTrue("Name not correct", ele1.getEleName().equals("TV"));
         ele1.setEleName(ele2.getEleName());
         ele1.setEleName(ele2.getEleName());
 		assertTrue("Name not correct", ele1.getEleName().equals("Fridge"));
 		assertTrue("Name not correct", ele1.getEleName().equals("Fridge"));
-		assertTrue("Amount not correct", ele2.getAmount() == 1);
-		ele2.setAmount(5);
-		assertTrue("Amount not correct", ele2.getAmount() == 5);
-        assertTrue("Total Energy not Correct", ele2.getMaximumEnergy() == ele2.getAmount() * ele2.getEnergyPerElement());
 	}
 	}
 	/**
 	/**
 	 * Test for Position.
 	 * Test for Position.

+ 0 - 274
tests/tests/PraktikumHolonsTestLoadAndStoreController.java

@@ -28,278 +28,4 @@ public class PraktikumHolonsTestLoadAndStoreController {
 	protected LoadController loadController;
 	protected LoadController loadController;
 	protected IdCounter id;
 	protected IdCounter id;
 	protected String path = System.getProperty("user.home") + "/HolonGUI/Test/";
 	protected String path = System.getProperty("user.home") + "/HolonGUI/Test/";
-
-//	/**
-//	 * Setup for the Tests.
-//	 */
-//	@Before
-//	public void setUp() {
-//		adapter = new PraktikumHolonsAdapter();
-//		model = new Model();
-//		mp = new MultiPurposeController(model);
-//		cg = new CategoryController(model, mp);
-//		cvs = new CanvasController(model, mp);
-//		obj = new ObjectController(model, mp);
-//		storeController = new StoreController(model);
-//		loadController = new LoadController(model, cg, cvs, obj, global, mp);
-//		// cg.initCategories();
-//		// obj.initHolonElements();
-//		File file = new File(path);
-//		file.mkdirs();
-//	}
-//
-//	/**
-//	 * minimal tests for saving.
-//	 */
-//	@Test
-//	public void testStoreMinimal() {
-//		try {
-//			File sav = new File(path + "TestSavMinimal.json");
-//			storeController.writeSaveFile(sav.getAbsolutePath());
-//			assertTrue("Save File was not created", new File(path + "TestSavMinimal.json").exists());
-//
-//			File cat = new File(path + "TestCategoryMinimal.json");
-//			//storeController.writeCategoryFile(cat.getAbsolutePath());
-//			assertTrue("Category File was not created", new File(path + "TestCategoryMinimal.json").exists());
-//
-//			File canvas = new File(path + "TestCanvasMinimal.json");
-//			storeController.writeCanvasFile(canvas.getAbsolutePath());
-//			assertTrue("Canvas File was not created", new File(path + "TestCanvasMinimal.json").exists());
-//
-//			assertTrue("Non Existant File exist", !new File(path + "TestDummyMinimal.json").exists());
-//
-//		} catch (IOException e) {
-//			// TODO Auto-generated catch block
-//			e.printStackTrace();
-//		}
-//	}
-//
-//	/**
-//	 * basic tests for saving.
-//	 */
-//	@Test
-//	public void testStoreBasic() {
-//
-//		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);
-//			for (int j = 1; j <= 10; j++) {
-//				cg.addNewHolonObject(mp.searchCat(adapter.generate(i)), adapter.generate(j),
-//						new ArrayList<HolonElement>(), "");
-//				assertTrue("Number of Objects does not match",
-//						mp.searchCat(adapter.generate(i)).getObjects().size() == j);
-//				assertTrue("Object was not created", mp.searchCat(adapter.generate(i)).getObjects().get(j - 1) != null);
-//			}
-//		}
-//
-//		// here some Objects were dropped on the canvas
-//		for (int i = 1; i <= 10; i++) {
-//			cvs.addNewObject(new HolonObject(mp.searchCatObj(mp.searchCat("Building"), "House")));
-//			assertTrue("Size of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == i);
-//			assertTrue("Object was not added", model.getObjectsOnCanvas().get(i - 1) != null
-//					&& model.getObjectsOnCanvas().get(i - 1).getObjName().equals("House"));
-//		}
-//
-//		HolonSwitch sw = new HolonSwitch(mp.searchCatObj(mp.searchCat("Component"), "Switch"));
-//		sw.setPosition(77, 88);
-//		cvs.addNewObject(sw);
-//
-//		try {
-//			File sav = new File(path + "TestSavBasic.json");
-//			storeController.writeSaveFile(sav.getAbsolutePath());
-//			assertTrue("Save File was not created", new File(path + "TestSavBasic.json").exists());
-//
-//			File canvas = new File(path + "TestCanvasBasic.json");
-//			storeController.writeCanvasFile(canvas.getAbsolutePath());
-//			assertTrue("Canvas File was not created", new File(path + "TestCanvasBasic.json").exists());
-//
-//			assertTrue("Non Existant File exist", !new File(path + "TestDummyMinimal.json").exists());
-//
-//		} catch (IOException e) {
-//			// TODO Auto-generated catch block
-//			e.printStackTrace();
-//		}
-//	}
-//
-//	/**
-//	 * advanced tests for saving.
-//	 */
-//	@Test
-//	public void testStoreAdvanced() {
-//
-//		setGraphPoints((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"));
-//
-//		int n = 0;
-//		for (int i = 0; i < 10; i++) {
-//			for (int j = 0; j < 10; j++) {
-//				HolonObject h = new HolonObject(mp.searchCatObj(mp.searchCat("Building"), "House"));
-//				h.setPosition(j * 50, i * 50);
-//				cvs.addNewObject(h);
-//				setGraphPoints(h);
-//				for (AbstractCpsObject cps : model.getObjectsOnCanvas()) {
-//					if (!cps.equals(h))
-//						cvs.addEdgeOnCanvas(new CpsEdge(h, cps));
-//				}
-//
-//				// vollständiger Graph
-//				n = model.getObjectsOnCanvas().size();
-//				assertTrue("Number of Edges does not Match", model.getEdgesOnCanvas().size() == (n * (n - 1)) / 2);
-//			}
-//		}
-//
-//		try {
-//			File sav = new File(path + "TestSavAdvanced.json");
-//			storeController.writeSaveFile(sav.getAbsolutePath());
-//			assertTrue("Save File was not created", new File(path + "TestSavAdvanced.json").exists());
-//
-//		} catch (IOException e) {
-//			// TODO Auto-generated catch block
-//			e.printStackTrace();
-//		}
-//
-//	}
-//
-//	/**
-//	 * minimal tests for loading a save file.
-//	 */
-//	@Test
-//	public void testLoadMinimal() {
-//		try {
-//			// Category Tests
-//			Category building = mp.searchCat("Building");
-//			assertTrue("Number of Categories does not match", model.getCategories().size() == 3);
-//			assertTrue("TestFile was not found", new File(path + "TestCategoryMinimal.json").exists());
-//			loadController.readJson(path + "TestCategoryMinimal.json");
-//			assertTrue("Number of Categories does not match", model.getCategories().size() == 3);
-//			// Tests if its same instance and if Name is the same
-//			assertTrue("Same instance of Category:Building", building != mp.searchCat("Building")
-//					&& building.getName().equals(mp.searchCat("Building").getName()));
-//
-//			// Canvas Tests.. basically nothing happens because nothing is on
-//			// the Canvas
-//			assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
-//			assertTrue("TestFile was not found", new File(path + "TestCanvasMinimal.json").exists());
-//			loadController.readJson(path + "TestCanvasMinimal.json");
-//			assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
-//
-//			// Save File tests basically both Test from Above Combined
-//			building = mp.searchCat("Building");
-//			assertTrue("Number of Objects in Energy does not Match", mp.searchCat("Energy").getObjects().size() == 1);
-//			assertTrue("TestFile was not found", new File(path + "TestSavMinimal.json").exists());
-//			loadController.readJson(path + "TestSavMinimal.json");
-//			assertTrue("Number of Objects in Energy does not Match", mp.searchCat("Energy").getObjects().size() == 1);
-//			assertTrue("Number of Objects on Canvas does not match", model.getObjectsOnCanvas().size() == 0);
-//			assertTrue("Same instance of Category:Building", building != mp.searchCat("Building")
-//					&& building.getName().equals(mp.searchCat("Building").getName()));
-//
-//		} catch (IOException e) {
-//			// TODO Auto-generated catch block
-//			e.printStackTrace();
-//		}
-//	}
-//
-//	/**
-//	 * basic tests for loading a save file.
-//	 */
-//	@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() == 11);
-//			for (AbstractCpsObject obj : model.getObjectsOnCanvas()) {
-//				assertTrue("Not instance of HolonObject", obj instanceof HolonObject || obj instanceof HolonSwitch);
-//
-//			}
-//
-//			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();
-//		}
-//	}
-//
-//	/**
-//	 * advanced tests for loading a save file.
-//	 */
-//	@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 100", 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();
-//		}
-//	}
-//
-//	/**
-//	 * Test for FileNotFound.
-//	 * 
-//	 * @throws IOException
-//	 *             FileNotFoundException
-//	 */
-//	@Test(expected = FileNotFoundException.class)
-//	public void testLoadException() throws IOException {
-//		assertTrue("Save File was not found", !new File(path + "TestSavDummy.json").exists());
-//		loadController.readJson(path + "TestSavDummy.json");
-//	}
-//
-//	/**
-//	 * sets the graph points in all elements of an Object.
-//	 * 
-//	 * @param obj
-//	 *            the Object
-//	 */
-//	public void setGraphPoints(HolonObject obj) {
-//		LinkedList<Point> list = new LinkedList<>();
-//		list.add(new Point(0, 0));
-//		list.add(new Point(125, 50));
-//		list.add(new Point(249, 0));
-//		UnitGraph u = new UnitGraph(model, null);
-//		u.repaintWithNewElement(obj.getElements());
-//		u.fillArrayofValue();
-//		for (HolonElement ele : obj.getElements()) {
-//			ele.setGraphPoints(list);
-//		}
-//
-//	}
 }
 }

+ 9 - 9
tests/tests/PraktikumHolonsTestObjectController.java

@@ -66,9 +66,9 @@ public class PraktikumHolonsTestObjectController {
 	 */
 	 */
 	@Test
 	@Test
 	public void testAddingAndDeletingInCategory() {
 	public void testAddingAndDeletingInCategory() {
-		controller.addNewElementIntoCategoryObject("Building", "House", "A", 1, -10);
+		controller.addNewElementIntoCategoryObject("Building", "House", "A", -10);
 		for (int i = 2; i < 27; i++) {
 		for (int i = 2; i < 27; i++) {
-			controller.addNewElementIntoCategoryObject("Building", "House", adapter.generate(i), i, -10);
+			controller.addNewElementIntoCategoryObject("Building", "House", adapter.generate(i), -10);
 			// n(n+1) / 2
 			// n(n+1) / 2
 					assertTrue("Number of Elements does not Match",
 					assertTrue("Number of Elements does not Match",
 					((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House")).getElements().size() == 6 + i);
 					((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House")).getElements().size() == 6 + i);
@@ -86,16 +86,16 @@ public class PraktikumHolonsTestObjectController {
 		}
 		}
 
 
 		for (AbstractCanvasObject cps : model.getObjectsOnCanvas()) {
 		for (AbstractCanvasObject cps : model.getObjectsOnCanvas()) {
-			int size = model.getSelectedCpsObjects().size();
+			int size = model.getSelectedObjects().size();
 			controller.addSelectedObject(cps);
 			controller.addSelectedObject(cps);
-			assertTrue("Size does not Match", model.getSelectedCpsObjects().size() == size + 1);
+			assertTrue("Size does not Match", model.getSelectedObjects().size() == size + 1);
 		}
 		}
 		for (AbstractCanvasObject cps : model.getObjectsOnCanvas()) {
 		for (AbstractCanvasObject cps : model.getObjectsOnCanvas()) {
-			System.out.println(model.getSelectedCpsObjects().size());
-			int size = model.getSelectedCpsObjects().size();
-			controller.deleteSelectedObject(cps);
-			assertTrue("Size does not Match", model.getSelectedCpsObjects().size() == size - 1);
-			assertTrue("Object was not unselected", !model.getSelectedCpsObjects().contains(cps));
+			System.out.println(model.getSelectedObjects().size());
+			int size = model.getSelectedObjects().size();
+			controller.removeObjectFromSelection(cps);
+			assertTrue("Size does not Match", model.getSelectedObjects().size() == size - 1);
+			assertTrue("Object was not unselected", !model.getSelectedObjects().contains(cps));
 
 
 		}
 		}
 	}
 	}

Some files were not shown because too many files changed in this diff