Преглед изворни кода

Adds Inspector

- Removes Amount in HolonElement
- Fixes Todos and Warning
- Removes SplitPane
- Fix GroupNodeSelection
- Adds TrippleStateCheckBox

Wip Inspector
TomTroppmann пре 3 година
родитељ
комит
a29ee5945a
57 измењених фајлова са 2235 додато и 3567 уклоњено
  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 803
      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 145
      src/ui/controller/UpdateController.java
  29. 1 1
      src/ui/model/MinimumNetwork.java
  30. 9 37
      src/ui/model/Model.java
  31. 76 108
      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. 454 471
      src/ui/view/Canvas.java
  36. 1 3
      src/ui/view/CreateNewDialog.java
  37. 8 8
      src/ui/view/CreateTemplatePopUp.java
  38. 69 602
      src/ui/view/GUI.java
  39. 27 30
      src/ui/view/GroupNodeCanvas.java
  40. 0 2
      src/ui/view/IndexTranslator.java
  41. 270 0
      src/ui/view/Inspector.java
  42. 1 1
      src/ui/view/Main.java
  43. 0 4
      src/ui/view/Outliner.java
  44. 30 25
      src/ui/view/SearchPopUp.java
  45. 1 8
      src/ui/view/TimePanel.java
  46. 0 1
      src/ui/view/UnitGraph.java
  47. 94 0
      src/ui/view/util/TrippleCheckBox.java
  48. 1 1
      src/utility/events/Action.java
  49. 1 1
      src/utility/events/Event.java
  50. 16 0
      src/utility/events/LostFocusListener.java
  51. 24 0
      src/utility/events/SimpleDocumentListener.java
  52. 1 1
      tests/tests/PraktikumHolonsAdapter.java
  53. 3 3
      tests/tests/PraktikumHolonsTestCanvasController.java
  54. 6 6
      tests/tests/PraktikumHolonsTestCategoryController.java
  55. 4 8
      tests/tests/PraktikumHolonsTestClasses.java
  56. 0 274
      tests/tests/PraktikumHolonsTestLoadAndStoreController.java
  57. 9 9
      tests/tests/PraktikumHolonsTestObjectController.java

+ 3 - 3
.gitignore

@@ -139,6 +139,6 @@ nbdist/
 .idea/
 praktikum-holons.iml
 /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());
 		}
 		catch (IOException e) {
-			// TODO Auto-generated catch block
 			e.printStackTrace();
 		}
 	}

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

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

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

@@ -19,14 +19,12 @@ public class HolonElementSketch {
 	public FlexibilitySketch onFlex;
 	public FlexibilitySketch offFlex;
 	
-	public HolonElementSketch(String name, int minAmount, int maxAmount, float energy) {
+	public HolonElementSketch(String name, float energy) {
 		this.name = name;
-		this.minAmount = minAmount;
-		this.maxAmount = maxAmount;
 		this.energy = energy;
 	}
 	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);
 		if(onFlex != null && Random.nextDouble() < onFlex.flexChance)addFlex(ele, parentObject.getName(), true);
 		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());
 					//.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));
 			int shutdownCount = elementsOfPriorityToShutdown.size();
 			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).
-	 * TODO: Make me better Rolf.
 	 * @param state
 	 * @return
 	 */

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

@@ -96,7 +96,7 @@ public class TopologieObjectiveFunction {
 	 * 
 	 * 
 	 * @param state
-	 * @param moreInformation TODO
+	 * @param moreInformation if more prints should be made
 	 * @return f_g value between 0 and 100
 	 */
 	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
 	 */
 	public AbstractCanvasObject(String objName) {
-		setObjName(objName);
 		setName(objName);
 		setImage("/Images/Dummy_House.png");
 	}
@@ -65,33 +64,13 @@ public abstract class AbstractCanvasObject {
 	 *            Object to be copied
 	 */
 	public AbstractCanvasObject(AbstractCanvasObject obj) {
-		setObjName(obj.getObjName());
-		setName(obj.getObjName());
+		setName(obj.getName());
 		setConnections(new ArrayList<>());
 		setId(IdCounter.nextId(CounterType.Object));
 		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).

+ 2 - 2
src/classes/Flexibility.java

@@ -85,12 +85,12 @@ public class Flexibility {
 
 	/** returns the total energy Amount accumulated over the TimeSteps.*/
 	public float magnitude() {
-		return ((float)duration) *  element.getEnergyPerElement() * element.getAmount();
+		return ((float)duration) *  element.getEnergy();
 	}
 	
 	public float bringtmir(){
 		//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() {
 		return bringtmir() >= 0;

+ 0 - 20
src/classes/GroupNode.java

@@ -12,8 +12,6 @@ public class GroupNode extends AbstractCanvasObject {
 	private ArrayList<AbstractCanvasObject> nodes;
 	private HashMap<Integer, Integer> nodesIdx;
 	
-	@Expose
-	private int leftBorder; //TODO Delete leftBorder, jet is just set to 0
 	@Expose
 	private String imgPath = "";
 	@Expose
@@ -180,24 +178,6 @@ public class GroupNode extends AbstractCanvasObject {
 		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;
 
 import com.google.gson.annotations.Expose;
+import com.google.gson.annotations.SerializedName;
 
 import classes.IdCounter.CounterType;
 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
      * */
     private LinkedList<Point2D.Double> graphPoints;
-    /** Name of the object, e.g. House, 1 */
-    @Expose
-    private String objName;
     /** Name of the gadget, e.g. TV */
     @Expose
     private String eleName;
     /** Amount of same elements */
     @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) */
     @Expose
     private boolean active;
@@ -90,20 +86,19 @@ public class HolonElement implements LocalMode, GraphEditable{
      * @param energy  float
      * @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)
      */
-    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;
     	setUseLocalPeriod(false);
     	setEleName(eleName);
-        setAmount(amount);
         setEnergyPerElement(energy);
         setActive(true);
         setGraphPoints(new LinkedList<>());
@@ -125,8 +120,7 @@ public class HolonElement implements LocalMode, GraphEditable{
     	setUseLocalPeriod(element.isUsingLocalPeriod());
         setEleName(element.getEleName());
         setLocalPeriod(element.getLocalPeriod());
-        setAmount(element.getAmount());
-        setEnergyPerElement(element.getEnergyPerElement());
+        setEnergyPerElement(element.getEnergy());
         setActive(element.isActive());
         setGraphPoints(new LinkedList<>());
         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;
     }
 
-    /**
-     * 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.
      *
      * @return the energyPerElement
      */
-    public float getEnergyPerElement() {
-        return energyPerElement;
+    public float getEnergy() {
+        return energy;
     }
     public Priority getPriority() {
     	return priority;
@@ -209,7 +179,7 @@ public class HolonElement implements LocalMode, GraphEditable{
      */
     public boolean isProducer()
     {
-    	return (energyPerElement > 0);
+    	return (energy > 0);
     }
     
     /**
@@ -218,7 +188,7 @@ public class HolonElement implements LocalMode, GraphEditable{
      */
     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
      */
     public void setEnergyPerElement(float energyPerElement) {
-        this.energyPerElement = energyPerElement;
+        this.energy = energyPerElement;
     }
 
     /**
@@ -257,31 +227,11 @@ public class HolonElement implements LocalMode, GraphEditable{
         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
      */
     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)
                 .append(", eleName=").append(eleName)
                 .append(", parentName=").append(parentObject.getName())
-                .append(", amount=").append(amount)
                 .append(", active=").append(active)
-                .append(", energyPerElement used=").append(energyPerElement);
+                .append(", energyPerElement used=").append(energy);
         sb.append("]");
 
         return sb.toString();

+ 15 - 89
src/classes/HolonObject.java

@@ -18,12 +18,6 @@ import java.util.List;
 public class HolonObject extends AbstractCanvasObject { 
     /* Array of all consumers */
     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
@@ -33,8 +27,6 @@ public class HolonObject extends AbstractCanvasObject {
      */
     public HolonObject(String 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()) {
         	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);
         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() {
         StringBuilder sb = new StringBuilder();
@@ -342,10 +270,6 @@ public class HolonObject extends AbstractCanvasObject {
         return sb.toString();
     }
     
-    @Override
-	public HolonObject makeCopy(){
-		return new HolonObject(this);
-	}
 
 	public int getNumberOfActiveElements() {
 		return (int) elements.stream().filter(ele -> ele.isActive()).count();
@@ -356,10 +280,12 @@ public class HolonObject extends AbstractCanvasObject {
 	}
 	
 	public int getNumberOfElements() {
-		return (int) elements.stream().count();
+		return elements.size();
 	}
 
 	public void setElements(List<HolonElement> 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;
 	}
 	
-	@Override
-	public HolonSwitch makeCopy(){
-		return new HolonSwitch(this);
-	}
 	
 		
 	public String toString() {

+ 1 - 5
src/classes/Node.java

@@ -34,9 +34,5 @@ public class Node extends AbstractCanvasObject {
 	public String toString(){
 		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
 	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)
 			return -1;
 		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.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.stream.Collectors;
 
+import classes.AbstractCanvasObject;
 import classes.Edge;
-import classes.Node;
 import classes.GroupNode;
-import classes.AbstractCanvasObject;
 import classes.HolonObject;
 import classes.HolonSwitch;
+import classes.Node;
 import interfaces.ObjectListener;
 import ui.model.Model;
 import ui.view.GUI;
@@ -128,6 +130,15 @@ public class CanvasController {
 		model.getCvsObjIdx().remove(obj.getId());
 		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
@@ -185,7 +196,7 @@ public class CanvasController {
 	 *            the mouse Position
 	 */
 	public void pasteObjects(Point p) {
-		model.getSelectedCpsObjects().clear();
+		model.getSelectedObjects().clear();
 		AbstractCanvasObject tCps = null;
 		int x = Integer.MAX_VALUE, y = Integer.MAX_VALUE;
 
@@ -199,7 +210,6 @@ public class CanvasController {
 			}
 		}
 
-		ArrayList<AbstractCanvasObject> tempList = new ArrayList<>();
 		// Objects
 		for (AbstractCanvasObject cps : model.getClipboradObjects()) {
 			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.setSav(cps.getSav());
-			tempList.add(tCps);
 			addObject(tCps, false);
 		}
 
 		// Edges
-		boolean newEdge = true;
+
 		for (AbstractCanvasObject cps : model.getClipboradObjects()) {
 			for (Edge e : cps.getConnectedTo()) {
 				// A and B of e in the copied Elements?
-				if (model.getClipboradObjects().indexOf(e.getA()) != -1
-						&& model.getClipboradObjects().indexOf(e.getB()) != -1) {
-					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?
-					for (Edge et : tempList.get(model.getClipboradObjects().indexOf(cps)).getConnectedTo()) {
+					for (Edge et : cps.getConnectedTo()) {
 						for (Edge etA : et.getA().getConnectedTo()) {
 							if (etA.getA() == a && etA.getB() == b) {
 								newEdge = false;
@@ -238,12 +248,10 @@ public class CanvasController {
 						}
 					}
 					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());
 						addEdgeOnCanvas(tempE);
 					}
-					newEdge = true;
 				}
 			}
 		}
@@ -253,15 +261,13 @@ public class CanvasController {
 	/**
 	 * Cut all Selected Objects.
 	 */
-	@SuppressWarnings("unchecked")
 	public void cutObjects() {
-		model.setClipboradObjects((ArrayList<AbstractCanvasObject>) model.getSelectedCpsObjects().clone());
-
+		model.setClipboradObjects(model.getSelectedObjects().stream().collect(Collectors.toSet()));
 		for (AbstractCanvasObject cps : model.getClipboradObjects()) {
 			deleteObjectOnCanvas(cps);
 		}
 
-		model.getSelectedCpsObjects().clear();
+		model.getSelectedObjects().clear();
 	}
 
 	
@@ -337,5 +343,7 @@ public class CanvasController {
 		model.setCanvasImageWidth(width);
 		model.setCanvasImageHeight(height);
 	}
+
+	
 	
 }

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

@@ -10,7 +10,7 @@ import classes.HolonObject;
 import classes.HolonSwitch;
 import classes.Pair;
 import ui.model.Model;
-import utility.Event;
+import utility.events.Event;
 
 /**
  * Controller for the Categories.
@@ -129,12 +129,11 @@ public class CategoryController {
 		int i = 0;
 		boolean updateElementSaves = false;
 		String name = "";
-		while (mpC.searchCatObj(category, object.getObjName()) != null) {
+		while (mpC.searchCatObj(category, object.getName()) != null) {
 			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);
 			i++;
 		}
@@ -143,7 +142,7 @@ public class CategoryController {
 				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);
 	}
 
@@ -195,8 +194,8 @@ public class CategoryController {
 	 */
 	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);
 		OnCategoryChanged.broadcast();
 	}

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

@@ -60,10 +60,10 @@ public class ClipboardController {
         store.initNumeration();
 
         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));
 
-        for (AbstractCanvasObject abs : model.getSelectedCpsObjects()) {
+        for (AbstractCanvasObject abs : model.getSelectedObjects()) {
             queue.add(abs);
         }
         while (!queue.isEmpty()) {
@@ -126,7 +126,7 @@ public class ClipboardController {
 
         HashMap<Integer, AbstractCanvasObject> objDispatch = new HashMap<>();
         HashMap<Integer, HolonElement> eleDispatch = new HashMap<>();
-        model.getSelectedCpsObjects().clear();
+        model.getSelectedObjects().clear();
 
         objIDMap = new HashMap<>();
         eleIDMap = new HashMap<>();
@@ -147,7 +147,7 @@ public class ClipboardController {
      */
     void cut(GroupNode upperNode) {
         copy(upperNode);
-        for (AbstractCanvasObject abs : model.getSelectedCpsObjects()) {
+        for (AbstractCanvasObject abs : model.getSelectedObjects()) {
             if (upperNode == null)
                 cvsC.deleteObjectOnCanvas(abs);
             else
@@ -156,6 +156,7 @@ public class ClipboardController {
             if (abs instanceof GroupNode)
                 cvsC.bfsNodeCleaner((GroupNode) abs);
         }
+        model.getSelectedObjects().clear();
         this.simManager.calculateStateForTimeStep(model.getCurIteration(), true);
 
     }
@@ -212,7 +213,7 @@ public class ClipboardController {
             else
                 uppC.addObjectInUpperNode(temp, upperNode, false);
             // mark the Pasted Objects
-            model.getSelectedCpsObjects().add(temp);
+            model.getSelectedObjects().add(temp);
         } else {
             // else look up the table and put it into the right Uppernode
             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
      */
     void getObjectsInDepth() {
-        model.setClipboradObjects(new ArrayList<>());
-        for (AbstractCanvasObject obj : model.getSelectedCpsObjects()) {
+        model.getClipboradObjects().clear();
+        for (AbstractCanvasObject obj : model.getSelectedObjects()) {
             clipboadDepth(obj);
         }
     }
@@ -431,8 +432,8 @@ public class ClipboardController {
         if (y < 0)
             y = 0 + model.getScaleDiv2() + 1;
         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)
             x = 0 + model.getScaleDiv2() + 1;
         if (x > model.getCanvasX())

Разлика између датотеке није приказан због своје велике величине
+ 763 - 803
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;
 
 import classes.*;
+import classes.HolonElement.Priority;
 import classes.IdCounter.CounterType;
 
 import com.google.gson.JsonElement;
@@ -166,22 +167,18 @@ public class LoadController {
         for (String key : keys) {
             if (key.contains("CATEGORY"))
                 loadCategory(json.get(key));
-            if (key.contains("CGOBJECT"))
+            else if (key.contains("CGOBJECT"))
                 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);
-            if (key.contains("CVSELEMENT"))
+            else if (key.contains("CVSELEMENT"))
                 loadCanvasElements(json.get(key), objDispatch, eleDispatch);
-            if (key.contains("SWUNITGRAPH"))
+            else if (key.contains("SWUNITGRAPH"))
                 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);
-            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()));
         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);
 
     }
@@ -267,6 +264,11 @@ public class LoadController {
         	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);
     }
 
@@ -286,7 +288,6 @@ public class LoadController {
         temp.setImage(checkOS(temp.getImage()));
         if (temp instanceof GroupNode) {
             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 (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
         int stored = object.get("ID").getAsInt();
         // lookup that object
@@ -386,7 +391,6 @@ public class LoadController {
         }  
         
        
-
         switch (type) {
             case SWITCH:
                 HolonSwitch sw = (HolonSwitch) objDispatch.get(sav);
@@ -394,9 +398,6 @@ public class LoadController {
                 sw.sampleGraph();
                 break;
             case ELEMENT:
-            	System.out.println("Write me new");
-            	break;
-            case TESTELEMENT:
                 HolonElement ele1 = eleDispatch.get(sav);
                 ele1.setGraphPoints(graphpointTEST);
                 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 {
         File tmp = Files.createTempDirectory("tmpHolon").toFile();
         tmp.deleteOnExit();
@@ -507,6 +495,9 @@ public class LoadController {
         ele.flexList = new ArrayList<Flexibility>();
         ele.setGraphPoints(new LinkedList<>());
         ele.reset();
+        if(ele.getPriority() == null) {
+        	ele.setPriority(Priority.Low);
+        }
     }
 
     /**
@@ -542,7 +533,7 @@ public class LoadController {
     }
 
     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.util.ArrayList;
+import java.util.Collection;
 import java.util.LinkedList;
 
 
@@ -128,11 +129,8 @@ class NodeController {
 	/**
 	 * Calculate new Position of the Upper Node
 	 */
-    Vector2Int calculatePos(ArrayList<AbstractCanvasObject> toGroup) {
-
+    Vector2Int calculatePos(Collection<AbstractCanvasObject> toGroup) {
 		Vector2Int pos = new Vector2Int(0, 0);
-
-		// sum(x0 .. xn) / numOfPos, y analog
 		for (AbstractCanvasObject abs : toGroup) {
 			pos = pos.add(abs.getPosition());
 		}
@@ -248,9 +246,8 @@ class NodeController {
 			}
 			
 			/** 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);
 		}
 		/** delete 'toBeReplaced' new empty connections, to prevent Nullpointer*/
@@ -274,8 +271,8 @@ class NodeController {
 		if (y < 0)
 			y = 0 + model.getScaleDiv2() + 1;
 		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)
 			x = 0 + model.getScaleDiv2() + 1;
 		if (x > model.getCanvasX())

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

@@ -1,9 +1,14 @@
 package ui.controller;
 
-import classes.*;
-import ui.model.Model;
-
 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.
@@ -12,188 +17,184 @@ import java.util.ArrayList;
  */
 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
 	 *            current Iteration
-	 * @param updateVisual TODO
+	 * @param updateVisual 
+	 * Determine if the Visuals should also be calculated
 	 */
 	public void calculateStateForTimeStep(int timestep, boolean updateVisual) {
 		boolean doesFlexManagerExist = savesFlexManger.containsKey(timestep);

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

@@ -1,12 +1,6 @@
 package ui.controller;
 
 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.DecoratedHolonObject.HolonObjectState;
 import ui.model.Model;
@@ -16,7 +10,6 @@ import ui.view.GroupNodeCanvas;
 
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.LinkedList;
 
 /**
  * This class is for all update methods and more ;)
@@ -27,133 +20,32 @@ import java.util.LinkedList;
 public class UpdateController {
 
 	Model model;
-	Control controller;
-	private int sortBy;
+	Control controller;;
 
 	public UpdateController(Model model, Control control) {
 		this.model = model;
 		this.controller = control;
-		sortBy= 1;
 	}
 
 	/**
 	 * Update the information concerning properties of the selected CpsObject.
 	 */
 	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 (table.getRowCount() != 0) {
 					table.removeRow(2);
 					Object[] tempEnergy = { "Total Energy", ((HolonObject) tempCps).getEnergyNeededFromConsumingElements(model.getCurIteration()) };
 					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.
@@ -218,7 +110,7 @@ public class UpdateController {
 			if (obj == null) {
 				String tempStringObj = tables.get(1).getValueAt(yTemp, 0).toString();
 				int idTempObj = Integer.parseInt(tempStringObj.split(", ")[1]);
-				if (model.getSelectedCpsObjects() != null) {
+				if (model.getSelectedObjects() != null) {
 					obtTemp = (HolonObject) getHolonObjSelected(idTempObj);
 				}
 				id = Integer.parseInt(tables.get(1).getValueAt(yTemp, 1).toString());
@@ -262,8 +154,8 @@ public class UpdateController {
 	 */
 	public AbstractCanvasObject getActualCps() {
         AbstractCanvasObject tempCps;
-        if (model.getSelectedCpsObjects().size() == 1) {
-			tempCps = model.getSelectedCpsObjects().get(0);
+        if (model.getSelectedObjects().size() == 1) {
+			tempCps = model.getSelectedObjects().stream().findFirst().get();
 		} else {
 			int tempID = model.getSelectedObjectID();
 			tempCps = controller.searchByID(tempID);
@@ -293,11 +185,9 @@ public class UpdateController {
 			// For HolonObjects the Total Energy (production or
 			// consumption) is calculated
 			if (obj instanceof HolonObject) {
-				refreshTableHolonElement(model.getMultiTable(), model.getSingleTable());
+				
 				Object[] tempEnergy = { "Total Energy", ((HolonObject) obj).getEnergyNeededFromConsumingElements(model.getCurIteration()) };
-				Object[] tempFlex = { "Flexibility", ((HolonObject) obj).getTotalFlex() };
 				model.getPropertyTable().addRow(tempEnergy);
-				model.getPropertyTable().addRow(tempFlex);
 				model.getPropertyTable().setCellEditable(0, 1, false);
 				model.getPropertyTable().setCellEditable(2, 1, false);
 				model.getPropertyTable().setCellEditable(3, 1, false);
@@ -444,16 +334,11 @@ public class UpdateController {
 			deleteRows(model.getMultiTable());
 		}
 		// Update of the HolonElementTable (Single- or Multi-Selection)
-		if (model.getSelectedCpsObjects().size() > 1) {
-			model.getTableHolonElement().setModel(model.getMultiTable());
-		} else if (model.getSelectedCpsObjects().size() == 1) {
-			model.getTableHolonElement().setModel(model.getSingleTable());
-		}
 	}
 
 	public AbstractCanvasObject getHolonObjSelected(int id) {
 		AbstractCanvasObject obj = null;
-		for (AbstractCanvasObject o : model.getSelectedCpsObjects()) {
+		for (AbstractCanvasObject o : model.getSelectedObjects()) {
 			if (o.getId() == id) {
 				obj = o;
 				break;
@@ -462,26 +347,4 @@ public class UpdateController {
 		return obj;
 	}
 
-
-	/**
-	 * 
-	 * @return id of column that should be sorted
-	 */
-	public int getSortBy() {
-		return sortBy;
-	}
-
-	/**
-	 * sets the column id that should be sorted
-	 * @param column
-	 */
-	public void setSortBy(int column) {
-		/**
-		 * if there is no "Object" column, assume coloumn 0 is
-		 */
-		if(model.getTableHolonElement().getColumnCount()==7)
-			this.sortBy = column+1;
-		else
-			this.sortBy = column;
-	}
 }

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

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

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

@@ -3,8 +3,10 @@ package ui.model;
 import java.awt.Color;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 import javax.swing.JTable;
@@ -54,16 +56,13 @@ public class Model {
     private int canvasY = 3000;
     private int curIteration = 0;
     // ID of the Selected Object
-    private AbstractCanvasObject selectedCpsObject = null;
     private HolonElement selectedHolonElement;
     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;
     // Capacity for Edge
     private float maxCapacity;
-    // Table for HolonElements --> all cells are editable
-    private JTable tableHolonElement;
     /** Table for the properties of HolonObjects, Edges etc */
     private JTable propertyTable;
     
@@ -77,7 +76,7 @@ public class Model {
     private int numberOfSaves = 35;
     /** whether the supplyBars should be shown or not */
     private boolean showSupplyBars = true;
-    //TODO:
+    /** the amount of iterations */
     private int iterations=100;
     
     /**
@@ -145,13 +144,11 @@ public class Model {
         setObjectListeners(new LinkedList<>());
         setCgIdx(new HashMap<>());
         setCvsObjIdx(new HashMap<>());
-        setClipboradObjects(new ArrayList<>());
         setEleToDelete(new HashMap<>());
         setSingleTable(new PropertyTable());
         setMultiTable(new PropertyTable());
         setPropertyTable(new DefaulTable(1000, colNames.length));
         getPropertyTable().setColumnIdentifiers(colNames);
-        setTableHolonElement(new JTable());
         initGson();
     }
 
@@ -281,30 +278,12 @@ public class Model {
         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.
      *
      * @return The selected Objects
      */
-    public ArrayList<AbstractCanvasObject> getSelectedCpsObjects() {
+    public Set<AbstractCanvasObject> getSelectedObjects() {
         return selectedObjects;
     }
 
@@ -313,7 +292,7 @@ public class Model {
      *
      * @return The selected Objects
      */
-    public void setSelectedCpsObjects(ArrayList<AbstractCanvasObject> arr) {
+    public void setSelectedCpsObjects(Set<AbstractCanvasObject> arr) {
         this.selectedObjects = arr;
     }
 
@@ -496,7 +475,7 @@ public class Model {
      *
      * @return Objects in the Clipboard
      */
-    public ArrayList<AbstractCanvasObject> getClipboradObjects() {
+    public Set<AbstractCanvasObject> getClipboradObjects() {
         return clipboardObjects;
     }
 
@@ -505,7 +484,7 @@ public class Model {
      *
      * @param c Array of Objects
      */
-    public void setClipboradObjects(ArrayList<AbstractCanvasObject> c) {
+    public void setClipboradObjects(Set<AbstractCanvasObject> c) {
         this.clipboardObjects = c;
     }
 
@@ -611,13 +590,6 @@ public class Model {
         this.tableModelProperties = pt;
     }
 
-    public JTable getTableHolonElement() {
-        return tableHolonElement;
-    }
-
-    public void setTableHolonElement(JTable tableHolonElement) {
-        this.tableHolonElement = tableHolonElement;
-    }
     
 	/**
 	 * @return the tableProperties

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

@@ -8,14 +8,14 @@ import java.awt.Image;
 import java.awt.Point;
 import java.awt.event.MouseEvent;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Set;
 import java.util.TimerTask;
 
-import javax.swing.CellEditor;
 import javax.swing.JMenuItem;
 import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
-import javax.swing.JTable;
 import javax.swing.Timer;
 
 import classes.AbstractCanvasObject;
@@ -43,7 +43,7 @@ public abstract class AbstractCanvas extends JPanel {
 	 * Version
 	 */
 	private static final long serialVersionUID = 1L;
-	
+
 	final JMenuItem itemCut = new JMenuItem("Cut");
 	final JMenuItem itemCopy = new JMenuItem("Copy");
 	final JMenuItem itemPaste = new JMenuItem("Paste");
@@ -52,7 +52,7 @@ public abstract class AbstractCanvas extends JPanel {
 	final JMenuItem itemUngroup = new JMenuItem("Ungroup");
 	final JMenuItem itemAlign = new JMenuItem("Align selected");
 	final JMenuItem itemCreateTemplate = new JMenuItem("Create Template");
-	
+
 	final int ANIMTIME = 500; // animation Time
 	private final int animFPS = 60;
 	final int animDelay = 1000 / animFPS; // animation Delay
@@ -63,13 +63,13 @@ public abstract class AbstractCanvas extends JPanel {
 	// Selection
 	AbstractCanvasObject tempCps = null;
 	UpdateController updCon;
-	
-	//Replacement
+
+	// Replacement
 	/**
 	 * the CpsObject that might be replaced by drag&drop
 	 */
 	protected AbstractCanvasObject mayBeReplaced = null;
-	
+
 	// PopUpMenu
 	JPopupMenu popmenu = new JPopupMenu();
 	// Tooltip
@@ -77,7 +77,7 @@ public abstract class AbstractCanvas extends JPanel {
 	Vector2Int toolTipPos = new Vector2Int(); // Tooltip Position
 	String toolTipText = "";
 	List<HolonElement> dataSelected = new ArrayList<>();
-	ArrayList<AbstractCanvasObject> tempSelected = new ArrayList<>();
+	protected Set<AbstractCanvasObject> tempSelected = new HashSet<>();
 	boolean showConnectionInformation;
 	boolean dragging = false; // for dragging
 	boolean dragged = false; // if an object/objects was/were dragged
@@ -104,16 +104,14 @@ public abstract class AbstractCanvas extends JPanel {
 
 	// ------------------------------------------ METHODS
 	// ------------------------------------------
-	
-
-	
-	
 
-	class ACpsHandle{
+	class ACpsHandle {
 		public AbstractCanvasObject object;
-		ACpsHandle(AbstractCanvasObject object){
+
+		ACpsHandle(AbstractCanvasObject object) {
 			this.object = object;
 		}
+
 		public String toString() {
 			return object.toString();
 		}
@@ -130,6 +128,7 @@ public abstract class AbstractCanvas extends JPanel {
 			g2.drawRect(sx, y, x - sx, sy - y);
 		}
 	}
+
 	/**
 	 * @deprecated
 	 * @param g
@@ -160,8 +159,6 @@ public abstract class AbstractCanvas extends JPanel {
 		}
 	}
 
-
-
 	void setRightClickMenu(MouseEvent e) {
 		if (e.getButton() == MouseEvent.BUTTON3) {
 			itemPaste.setEnabled(true);
@@ -180,7 +177,7 @@ public abstract class AbstractCanvas extends JPanel {
 					itemUngroup.setEnabled(true);
 				else
 					itemUngroup.setEnabled(false);
-				if (model.getSelectedCpsObjects().size() == 0) {
+				if (model.getSelectedObjects().size() == 0) {
 					controller.addSelectedObject(tempCps);
 				}
 				if (tempCps instanceof HolonObject) {
@@ -211,17 +208,15 @@ public abstract class AbstractCanvas extends JPanel {
 	void markObjects() {
 		if (doMark) {
 			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 lx, ly, hx, hy;
 
@@ -280,97 +275,97 @@ public abstract class AbstractCanvas extends JPanel {
 
 	void triggerUpdateController() {
 		updCon.paintProperties(tempCps);
-		updCon.refreshTableHolonElement(model.getMultiTable(), model.getSingleTable());
 		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 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 */
-		int treshhold = controller.getScale()/2;
-						
+		int treshhold = controller.getScale() / 2;
+
 		/** number of Objects that might be replaced (should be 1) */
 		int replaceCounter = 0;
-		
+
 		/** last object that could be replaced */
 		AbstractCanvasObject toBeReplaced = null;
-		
+
 		/** Position of object that might be replaced */
 		Vector2Int p;
-		
+
 		/** 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 */
-				if(cps == draggedCps)continue;
-						
+				if (cps == draggedCps)
+					continue;
+
 				/** set Position of object that might be replaced */
 				p = cps.getPosition();
-				
+
 				/** 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++;
 					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
 		 */
-		if( replaceCounter == 1 && toBeReplaced != null){
+		if (replaceCounter == 1 && toBeReplaced != null) {
 			mayBeReplaced = toBeReplaced;
 			return true;
-		}else{
+		} else {
 			mayBeReplaced = null;
 			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 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);
-	
-		
+
 	/**
 	 * highlights the object that mayBeReplaced
+	 * 
 	 * @param g2
 	 */
 	protected void highlightMayBeReplaced(Graphics2D g2) {
-		if(mayBeReplaced != null){
+		if (mayBeReplaced != null) {
 			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)));
 		}
 	}
-	
+
 	/**
 	 * Align alle Objects on the Canvas to a Grid with objects every 10 pixels
 	 */
@@ -378,62 +373,35 @@ public abstract class AbstractCanvas extends JPanel {
 
 	/**
 	 * 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) {
 		/** Position of the AbstractCpsObject which should be aligned */
 		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 */
 		int x_off = cps.getPosition().getX() % distance;
-		
+
 		/** y offset relative to a grid with lines every distance pixels */
 		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;
-		if(y_off > distance/2)
+		if (y_off > distance / 2)
 			y_off -= distance;
-		
+
 		/** set new Position */
-		cps.setPosition(p.getX()-x_off, p.getY()-y_off);
-	}
-	
-	/**
-	 * Stops Editing in HolonElementTable and PropertyTable
-	 */
-	protected void stopEditing() {
-		/**
-		 * Stop Editing, if mouse exits the Table
-		 */
-		JTable holElem = model.getTableHolonElement();
-		CellEditor cellEditor = holElem.getCellEditor();
-		if (cellEditor != null) {
-		    if (cellEditor.getCellEditorValue() != null) {
-		    	/** TODO: Maybe try to save current Data */
-		        cellEditor.stopCellEditing();
-		    } else {
-		        cellEditor.cancelCellEditing();
-		    }
-		}
-		
-		JTable propertys = model.getTableProperties();
-		cellEditor = propertys.getCellEditor();
-		if (cellEditor != null) {
-		    if (cellEditor.getCellEditorValue() != null) {
-		    	/** TODO: Maybe try to save current Data */
-		        cellEditor.stopCellEditing();
-		    } else {
-		        cellEditor.cancelCellEditing();
-		    }
-		}
+		cps.setPosition(p.getX() - x_off, p.getY() - y_off);
 	}
 
 	/**
 	 * Closes a tab of the UpperNode with ID upperNodeID
+	 * 
 	 * @param upperNodeId
 	 */
 	public abstract void closeUpperNodeTab(int upperNodeId);

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

@@ -1,16 +1,24 @@
 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 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.
@@ -39,8 +47,6 @@ public class AddElementPopUp extends JDialog {
 	private JTextField providedEnergy;
 	/** Element is active if checked */
 	JCheckBox checkBoxActive;
-	/** Textfield to enter the amount of this Element */
-	private JTextField amount;
 
 	/**
 	 * Create the AddElementPopup Dialog
@@ -98,17 +104,7 @@ public class AddElementPopUp extends JDialog {
 		checkBoxActive.setSelected(true);
 		checkBoxActive.setBounds(250, 50, 115, 20);
 		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 */
 		JPanel buttonPane = new JPanel();
@@ -153,8 +149,7 @@ public class AddElementPopUp extends JDialog {
 	public void setElement(HolonElement holonElement) {
 		hl = holonElement;
 		elementName.setText(hl.getEleName());
-		amount.setText(""+hl.getAmount());
-		providedEnergy.setText(""+hl.getEnergyPerElement());
+		providedEnergy.setText(""+hl.getEnergy());
 		checkBoxActive.setSelected(hl.isActive());
 		
 	}
@@ -173,12 +168,10 @@ public class AddElementPopUp extends JDialog {
 		if (elementName.getText().length() != 0 && !repeated) {
 			try {
 				float energy = Float.parseFloat(providedEnergy.getText());
-				int elementAmount = Integer.parseInt(amount.getText());
 				if(hl == null){
-					hl = new HolonElement(this.tempCps, elementName.getText(), elementAmount, energy);
+					hl = new HolonElement(this.tempCps, elementName.getText(), energy);
 				} else {
 					hl.setEleName(elementName.getText());
-					hl.setAmount(elementAmount);
 					hl.setEnergyPerElement(energy);
 					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.Color;
 import java.awt.FlowLayout;
-import java.awt.Image;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 import java.awt.event.MouseAdapter;
@@ -53,7 +52,7 @@ public class AddObjectPopUp extends JDialog {
 	private DefaultListModel<String> listModel;
 	private JList<String> list;
 	private String imagePath;
-	//	private HolonObject theObject;
+	// private HolonObject theObject;
 	private Control controller;
 	private File selectedFile = null;
 	private String filePath = " ";
@@ -63,25 +62,21 @@ public class AddObjectPopUp extends JDialog {
 	private boolean editState;
 	private boolean imageChanged = false;
 
-
 	/**
 	 * 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;
-		this.setIconImage(ImageImport.loadImage("/Images/Holeg.png",30,30));
+		this.setIconImage(ImageImport.loadImage("/Images/Holeg.png", 30, 30));
 		setBounds(100, 100, 450, 342);
-        setLocationRelativeTo(parentFrame);
-        getContentPane().setLayout(new BorderLayout());
+		setLocationRelativeTo(parentFrame);
+		getContentPane().setLayout(new BorderLayout());
 		JPanel contentPanel = new JPanel();
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
@@ -155,19 +150,19 @@ public class AddObjectPopUp extends JDialog {
 				lblImagePreview.setIcon(new ImageIcon(ImageImport.loadImage(obj.getImage(), 50, 50)));
 			}
 			sourcePath.setBounds(148, 77, 271, 20);
-			if(edit) {
+			if (edit) {
 				this.filePath = obj.getImage();
 				sourcePath.setText(filePath);
 			}
 			contentPanel.add(sourcePath);
-			
+
 			sourcePath.setColumns(10);
 		}
 		{
 			JButton btnAddDefaultElement = new JButton("Add Element");
 			btnAddDefaultElement.addActionListener(actionEvent -> {
-                addElement = new AddElementPopUp(parentFrame);
-                addElement.setActualHolonObject((HolonObject)toEdit);
+				addElement = new AddElementPopUp(parentFrame);
+				addElement.setActualHolonObject((HolonObject) toEdit);
 				addElement.setVisible(true);
 				HolonElement hl = addElement.getElement();
 				hl.setSaving(new Pair<>(givenCategory, objectName.getText()));
@@ -190,9 +185,9 @@ public class AddObjectPopUp extends JDialog {
 				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);
 				scrollPane.setViewportView(list);
@@ -231,10 +226,6 @@ public class AddObjectPopUp extends JDialog {
 								if (imageChanged)
 									copieFile();
 								imageChanged = false;
-								// theObject = new
-								// HolonObject(objectName.getText());
-								// theObject.setElements(hElements);
-								// theObject.setImage(imagePath);// TODO Auto-generated catch block
 								try {
 									if (editState) {
 										controller.delObjectCategory(givenCategory, toEdit.getName());
@@ -280,16 +271,14 @@ public class AddObjectPopUp extends JDialog {
 		}
 	}
 
-
 	/**
 	 * adds a Holon Element.
 	 *
-	 * @param hl
-	 *            the HolonElement
+	 * @param hl the HolonElement
 	 */
 	private void addElement(HolonElement 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();
 			filePath = selectedFile.getAbsolutePath();
 			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);
 			imageChanged = true;
 		} else {
@@ -367,8 +354,7 @@ public class AddObjectPopUp extends JDialog {
 	/**
 	 * Sets the Controller.
 	 * 
-	 * @param controller
-	 *            the controller
+	 * @param controller the controller
 	 */
 	public void setController(Control controller) {
 		this.controller = controller;
@@ -377,8 +363,7 @@ public class AddObjectPopUp extends JDialog {
 	/**
 	 * Set the Category.
 	 * 
-	 * @param cat
-	 *            the Category
+	 * @param cat the Category
 	 */
 	public void setCategory(String cat) {
 		givenCategory = cat;

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

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

Разлика између датотеке није приказан због своје велике величине
+ 454 - 471
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);
 	JTextField inputName = new JTextField();
 	JButton saveButton = new JButton("Save");
-	//TODO
 	JTextField inputNameSwitch = new JTextField();
 	JComboBox<String> selectedCategorySwitch = new JComboBox<String>();
 	
@@ -64,7 +63,6 @@ public class CreateNewDialog extends JDialog{
 			actualOption = Option.getEnumAtIndex(optionList.getSelectedIndex());
 		    cl.show(cards, actualOption.name());
 		    saveButton.setEnabled(actualOption != Option.None);  
-		    //TODO delete and make own iterface
 		    saveButton.setVisible(actualOption != Option.Object);	
 		});
 		
@@ -239,7 +237,7 @@ public class CreateNewDialog extends JDialog{
 				dispose();
 			}
 			else if (actualOption == Option.Switch)
-			{//TODO
+			{
 				try {
 					actualController.addSwitch(actualController.searchCategory(selectedCategorySwitch.getSelectedItem().toString()), inputNameSwitch.getText());
 				} catch (IOException e) {

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

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

Разлика између датотеке није приказан због своје велике величине
+ 69 - 602
src/ui/view/GUI.java


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

@@ -72,7 +72,7 @@ public class GroupNodeCanvas extends Canvas {
 		// <--
 		// SelectedCable
 		HashSet<Edge> selectedEdges = new HashSet<Edge>();
-		for (AbstractCanvasObject aCps : model.getSelectedCpsObjects()) {
+		for (AbstractCanvasObject aCps : model.getSelectedObjects()) {
 			for (Edge edge : aCps.getConnections()) {
 				selectedEdges.add(edge);
 			}
@@ -120,7 +120,7 @@ public class GroupNodeCanvas extends Canvas {
 		g2d.setColor(Color.BLUE);
 		g2d.setStroke(new BasicStroke(1));
 		Color transparentGrey = new Color(128, 174, 247, 40);
-		for (AbstractCanvasObject aCps : model.getSelectedCpsObjects()) {
+		for (AbstractCanvasObject aCps : model.getSelectedObjects()) {
 			if (aCps instanceof Node) {
 				Vector2Int pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
@@ -158,7 +158,6 @@ public class GroupNodeCanvas extends Canvas {
 	public void mousePressed(MouseEvent e) {
 		this.grabFocus();
 		if (!disabled) {
-			stopEditing();
 			tempCps = null;
 			dataSelected = null;
 			edgeHighlight = null;
@@ -173,7 +172,7 @@ public class GroupNodeCanvas extends Canvas {
 				}
 			}
 
-			if (e.getX() > groupNode.getLeftBorder()) {
+			if (e.getX() > 0) {
 				for (AbstractCanvasObject cps : groupNode.getNodes()) {
 					cx = cps.getPosition().getX() - model.getScaleDiv2();
 					cy = cps.getPosition().getY() - model.getScaleDiv2();
@@ -182,8 +181,9 @@ public class GroupNodeCanvas extends Canvas {
 
 						dragging = true;
 						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 {
 								controller.addSelectedObject(tempCps);
 								if (tempCps instanceof GroupNode)
@@ -213,10 +213,10 @@ public class GroupNodeCanvas extends Canvas {
 					} else {
 						cps = ed.getA();
 					}
-					if (x - controller.getScale() <= ((groupNode.getLeftBorder() >> 1) - model.getScaleDiv2())
+					if (x - controller.getScale() <= (model.getScaleDiv2())
 							&& y - controller.getScale() <= (scalediv20 + 5
 									+ (model.getScale() + scalediv20 + 10) * count)
-							&& x >= (groupNode.getLeftBorder() >> 1) - model.getScaleDiv2()
+							&& x >= model.getScaleDiv2()
 							&& y >= (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count)) {
 						tempCps = cps;
 						// If drawing an Edge (CTRL down)
@@ -238,7 +238,7 @@ public class GroupNodeCanvas extends Canvas {
 					controller.setSelecteEdge(edgeHighlight);
 					controller.setSelectedObjectID(0);
 					if (!e.isControlDown() && e.getButton() != MouseEvent.BUTTON3) {
-						model.getSelectedCpsObjects().clear();
+						controller.clearSelection();
 					}
 					updCon.deleteRows(model.getMultiTable());
 					updCon.deleteRows(model.getSingleTable());
@@ -260,11 +260,6 @@ public class GroupNodeCanvas extends Canvas {
 			x = e.getX();
 			y = e.getY();
 			dragging = false;
-			if (model.getSelectedCpsObjects().size() > 1) {
-				model.getTableHolonElement().setModel(model.getMultiTable());
-			} else if (model.getSelectedCpsObjects().size() == 1) {
-				model.getTableHolonElement().setModel(model.getSingleTable());
-			}
 
 			if (drawEdge) {
 				drawEdge = false;
@@ -284,7 +279,7 @@ public class GroupNodeCanvas extends Canvas {
 				/**
 				 * 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())) {
 					/**
 					 * if UpperNode would be replaced, close its tabs
@@ -300,7 +295,7 @@ public class GroupNodeCanvas extends Canvas {
 			}
 
 			if (!e.isControlDown() && !dragged && tempCps != null && MouseEvent.BUTTON3 != e.getButton()) {
-				model.getSelectedCpsObjects().clear();
+				controller.clearSelection();
 				controller.addSelectedObject(tempCps);
 				if (tempCps instanceof GroupNode)
 					controller.getObjectsInDepth();
@@ -312,11 +307,13 @@ public class GroupNodeCanvas extends Canvas {
 			setRightClickMenu(e);
 
 			markObjects();
-
-			if (doubleClick() && tempCps != null && tempCps instanceof HolonSwitch) {
+			boolean doubleclick = doubleClick();  
+			if (doubleclick && tempCps != null && tempCps instanceof HolonSwitch) {
 				((HolonSwitch) tempCps).switchState();
 			}
-
+			if (doubleclick && tempCps != null && tempCps instanceof GroupNode) {
+				controller.getGui().openNewUpperNodeTab((GroupNode)tempCps);
+			}
 			controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
 			triggerUpdateController();
 			repaint();
@@ -329,8 +326,8 @@ public class GroupNodeCanvas extends Canvas {
 			// If Edge is drawn
 			x = e.getX();
 			y = e.getY();
-			if (!model.getSelectedCpsObjects().contains(tempCps) && !doMark) {
-				model.getSelectedCpsObjects().clear();
+			if (!model.getSelectedObjects().contains(tempCps) && !doMark) {
+				controller.clearSelection();
 				if (tempCps != null) {
 					controller.addSelectedObject(tempCps);
 				}
@@ -347,8 +344,8 @@ public class GroupNodeCanvas extends Canvas {
 						y = e.getY();
 
 						// 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())
 							x = this.getWidth() - controller.getScaleDiv2();
 						if (e.getY() < controller.getScaleDiv2())
@@ -369,14 +366,14 @@ public class GroupNodeCanvas extends Canvas {
 						toolTipPos.setY(tempCps.getPosition().getY() - model.getScaleDiv2());
 
 						// All Selected Objects
-						for (AbstractCanvasObject cps : model.getSelectedCpsObjects()) {
+						for (AbstractCanvasObject cps : model.getSelectedObjects()) {
 							if (cps != tempCps) {
 								x = (int) (cps.getPosition().getX() + xDist);
 								y = (int) (cps.getPosition().getY() + yDist);
 
 								// 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())
 									x = this.getWidth() - controller.getScaleDiv2();
 								if (y <= controller.getScaleDiv2())
@@ -391,7 +388,7 @@ public class GroupNodeCanvas extends Canvas {
 					/**
 					 * check if something would be replaced
 					 */
-					if (model.getSelectedCpsObjects().size() == 1)
+					if (model.getSelectedObjects().size() == 1)
 						checkForReplacement(groupNode.getNodes(), tempCps, x, y);
 
 					repaint();
@@ -442,9 +439,9 @@ public class GroupNodeCanvas extends Canvas {
 						y2 = sy;
 					}
 
-					if (x1 <= groupNode.getLeftBorder() >> 1
+					if (x1 <= 0
 							&& y1 <= (int) (5 + (model.getScale() + scalediv20 + 10) * count) + model.getScaleDiv2()
-							&& x2 >= groupNode.getLeftBorder() >> 1
+							&& x2 >=  0
 							&& y2 >= (int) (5 + (model.getScale() + scalediv20 + 10) * count)) {
 						tempSelected.add(cps);
 
@@ -481,7 +478,7 @@ public class GroupNodeCanvas extends Canvas {
 					cps = ed.getA();
 				}
 
-				cx = groupNode.getLeftBorder() >> 1;
+				cx = 0 ;
 				cy = (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count);
 				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 static int STANDARD_GRAPH_ACCURACY = 100;
-	// TODO assign model
-	// this refrence should be updated with the model
 	public static Model model;
 	   /**
      * Determines the index of the internal value array

+ 270 - 0
src/ui/view/Inspector.java

@@ -0,0 +1,270 @@
+package ui.view;
+
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.swing.BorderFactory;
+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.JPanel;
+import javax.swing.JTextField;
+import javax.swing.UIManager;
+import javax.swing.border.Border;
+
+import classes.AbstractCanvasObject;
+import classes.HolonElement;
+import classes.HolonElement.Priority;
+import classes.HolonObject;
+import ui.controller.Control;
+import ui.view.util.TrippleCheckBox;
+import utility.ImageImport;
+import utility.events.SimpleDocumentListener;
+
+
+public class Inspector extends JPanel {
+	private List<HolonElement> elements = new ArrayList<>();
+	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) {
+		control.OnSelectionChanged.addListener(() -> update_ui());
+		this.control = control;
+		UIManager.put("Spinner.editorAlignment", JTextField.LEFT);
+		initUI();
+		this.add(header());
+		self = this;
+	}
+
+	public void update_ui() {
+		System.out.println("update_ui");
+		elements = extractElements(control.getModel().getSelectedObjects());
+		// TODO Pooling
+		this.removeAll();
+		this.add(header());
+		for (HolonElement element : elements) {
+			this.add(new ElementEdit(element));
+		}
+		if(!elements.isEmpty()) {
+			this.add(generateAddElementButton(elements.stream().findFirst().get()));
+		}
+
+		
+		revalidate();
+		repaint();
+	}
+
+	private void initUI() {
+		this.setBackground(Color.white);
+		this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
+		
+	}
+
+	private JPanel header() {
+		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;
+	}
+
+	private JLabel generateHeaderColumnTitle(String string) {
+		JLabel columnTitleLabel = new JLabel(string);
+		columnTitleLabel.setToolTipText(string);
+		columnTitleLabel.setBorder(generateHeaderBorder());
+		return columnTitleLabel;
+	}
+	
+	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 -> {
+			HolonObject ho = (HolonObject) obj;
+			return ho.getElements().stream();
+		}).collect(Collectors.toList());
+	}
+
+	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;
+
+		ElementEdit(HolonElement element) {
+			this.element = element;
+			this.initUI();
+			this.createEditFields();
+		}
+		
+		private void initUI() {
+			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);
+			
+			
+			
+		}
+
+	}
+}

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

@@ -32,7 +32,7 @@ public class Main {
                 Control control = new Control(model);
                 GUI view = new GUI(control);
                 IndexTranslator.model = model;
-                view.getFrmCyberPhysical().setVisible(true);
+                view.setVisible(true);
 
             } catch (Exception e) {
                 e.printStackTrace();

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

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

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

@@ -1,14 +1,22 @@
 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.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.
@@ -114,24 +122,24 @@ public class SearchPopUp extends JDialog {
 					for (AbstractCanvasObject cps : controller.getModel().getObjectsOnCanvas()) {
 
 						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()) {
-					controller.getModel().getSelectedCpsObjects().clear();
+					controller.getModel().getSelectedObjects().clear();
 
 					if (!controller.getModel().getObjectsOnCanvas().isEmpty() && !findTextField.getText().isEmpty()) {
 
 						if (rdbtnForward.isSelected()) {
 							if ((idx = getNext(++idx)) != -1)
-								controller.getModel().getSelectedCpsObjects().add(getObj(idx));
+								controller.getModel().getSelectedObjects().add(getObj(idx));
 						} else if (rdbtnBackward.isSelected()) {
 							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");
 		btnReplace.addActionListener(new ActionListener() {
 			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();
 			}
 		});
@@ -164,16 +170,15 @@ public class SearchPopUp extends JDialog {
 		btnReplaceAll.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
 				canvas.tempCps = null;
-				canvas.tempSelected = new ArrayList<>();
-				controller.getModel().getSelectedCpsObjects().clear();
+				controller.getModel().getSelectedObjects().clear();
 
 				for (AbstractCanvasObject cps : controller.getModel().getObjectsOnCanvas()) {
 					if (cps.getName().equals(findTextField.getText())
-							&& !controller.getModel().getSelectedCpsObjects().contains(cps))
+							&& !controller.getModel().getSelectedObjects().contains(cps))
 						selectObj(cps);
 				}
 
-				for (AbstractCanvasObject cps : controller.getModel().getSelectedCpsObjects()) {
+				for (AbstractCanvasObject cps : controller.getModel().getSelectedObjects()) {
 					renameObj(cps, replaceTextField.getText());
 				}
 
@@ -212,7 +217,7 @@ public class SearchPopUp extends JDialog {
 	 *            The Object
 	 */
 	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) {
 		for (int i = idx; i < controller.getModel().getObjectsOnCanvas().size(); i++) {
 			if (getObj(i).getName().equals(findTextField.getText())
-					&& !controller.getModel().getSelectedCpsObjects().contains(getObj(i)))
+					&& !controller.getModel().getSelectedObjects().contains(getObj(i)))
 				return i;
 		}
 		for (int i = 0; i < idx; i++) {
 			if (getObj(i).getName().equals(findTextField.getText())
-					&& !controller.getModel().getSelectedCpsObjects().contains(getObj(i)))
+					&& !controller.getModel().getSelectedObjects().contains(getObj(i)))
 				return i;
 		}
 		return -1;
@@ -269,12 +274,12 @@ public class SearchPopUp extends JDialog {
 	public int getPrev(int idx) {
 		for (int i = idx; i >= 0; i--) {
 			if (getObj(i).getName().equals(findTextField.getText())
-					&& !controller.getModel().getSelectedCpsObjects().contains(getObj(i)))
+					&& !controller.getModel().getSelectedObjects().contains(getObj(i)))
 				return i;
 		}
 		for (int i = controller.getModel().getObjectsOnCanvas().size() - 1; i > idx; i--) {
 			if (getObj(i).getName().equals(findTextField.getText())
-					&& !controller.getModel().getSelectedCpsObjects().contains(getObj(i)))
+					&& !controller.getModel().getSelectedObjects().contains(getObj(i)))
 				return i;
 		}
 		return -1;

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

@@ -116,20 +116,13 @@ public class TimePanel extends JPanel implements ActionListener{
 		super();
 		this.controller = cont;
 		// One Iteration
-		timer = new Timer(0, new ActionListener() {//TODO: Merge all these damned listeners.
+		timer = new Timer(0, new ActionListener() {
 			@Override
 			public void actionPerformed(ActionEvent ae) {
 				timeSlider.setValue(timeSlider.getValue() + 1);
 				controller.setCurIteration(timeSlider.getValue());
 				timer.setDelay(cont.getModel().getTimerSpeed());
 				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;
 					playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/play.png", 30, 30)));
 					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);
 	
 	//Intern Variables
-	//TODO: JavaDoc
 	private LinkedList<UnitGraphPoint> actualGraphPoints = new LinkedList<UnitGraphPoint>();
 	private Graphtype actualGraphType;
 	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.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.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) {
 		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());
-		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();
 		//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("Second Category is not Building", model.getCategories().get(1).getName().equals("Building"));
 		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");
 		assertFalse("A Switch should not be a Holon Object",
 				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 Object-Indices in Energy is not 4", mp.searchCat("Energy").getObjIdx().size() == 4);
 		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\" ",
-				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\"",
-				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");
 		assertTrue("3th Object was not deleted",
 				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);
 		controller.addNewHolonObject(mp.searchCat("Energy"), "Solar Plant", null, "");
 		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);
 	}
 
@@ -155,7 +155,7 @@ public class PraktikumHolonsTestCategoryController {
 			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")
-					.getObjects().get(i * 2).getObjName().equals(adapter.generate(i) + "_0"));
+					.getObjects().get(i * 2).getName().equals(adapter.generate(i) + "_0"));
 		}
 		//deleting the duplicates
 		controller.deleteObject("Energy", "E_0");

+ 4 - 8
tests/tests/PraktikumHolonsTestClasses.java

@@ -54,7 +54,7 @@ public class PraktikumHolonsTestClasses {
 		HolonObject test1 = new HolonObject("Test1");
 		HolonObject test2 = new HolonObject("Test2");
 		HolonObject test3 = new HolonObject(test1);
-		HolonElement ele = new HolonElement(test1, "Element", 1, 10, IdCounter.nextId(CounterType.Element));
+		HolonElement ele = new HolonElement(test1, "Element", 10, IdCounter.nextId(CounterType.Element));
 		ArrayList<HolonElement> arr = new ArrayList<>();
 		assertTrue("Should be Empty", test1.getElements().isEmpty());
 		test1.setElements(arr);
@@ -69,7 +69,7 @@ public class PraktikumHolonsTestClasses {
 		assertTrue("Current Energy not corrent", test2.getEnergyAtTimeStep(20) == 20);
 		String str = test2.toStringElements();
 		assertTrue("String not corrent", str.equals("Element, Element"));
-		test2.deleteElement(0);
+		test2.removeElement(0);
 		test2.addElement(ele);
 		
 		assertTrue("Element not Found", test3.searchElement("Element") != null);
@@ -134,17 +134,13 @@ public class PraktikumHolonsTestClasses {
 	 */
 	@Test
 	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(2) == -40);
         assertTrue("Name not correct", ele1.getEleName().equals("TV"));
         ele1.setEleName(ele2.getEleName());
 		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.

+ 0 - 274
tests/tests/PraktikumHolonsTestLoadAndStoreController.java

@@ -28,278 +28,4 @@ public class PraktikumHolonsTestLoadAndStoreController {
 	protected LoadController loadController;
 	protected IdCounter id;
 	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
 	public void testAddingAndDeletingInCategory() {
-		controller.addNewElementIntoCategoryObject("Building", "House", "A", 1, -10);
+		controller.addNewElementIntoCategoryObject("Building", "House", "A", -10);
 		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
 					assertTrue("Number of Elements does not Match",
 					((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House")).getElements().size() == 6 + i);
@@ -86,16 +86,16 @@ public class PraktikumHolonsTestObjectController {
 		}
 
 		for (AbstractCanvasObject cps : model.getObjectsOnCanvas()) {
-			int size = model.getSelectedCpsObjects().size();
+			int size = model.getSelectedObjects().size();
 			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()) {
-			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));
 
 		}
 	}

Неке датотеке нису приказане због велике количине промена