Browse Source

Refactor

Adds Junit5
Deletes FlexWrapper
Fixes Colors
Calculation Element
Update Todo
Calculation HolonObject
TomTroppmann 2 years ago
parent
commit
08ceeb50db
100 changed files with 1514 additions and 2226 deletions
  1. BIN
      jars/junit-4.12.jar
  2. 0 44
      src/TypeAdapter/AbstractCpsObjectAdapter.java
  3. 0 34
      src/TypeAdapter/ColorAdapter.java
  4. 44 0
      src/adapter/AbstractCpsObjectAdapter.java
  5. 6 7
      src/adapter/PairAdapter.java
  6. 1 1
      src/adapter/PositionAdapter.java
  7. 15 15
      src/addon/InformationPanel.java
  8. 9 8
      src/addon/RandomOfferdFlexibility.java
  9. 2 2
      src/addon/RandomSwitch.java
  10. 7 7
      src/addon/Randomizer.java
  11. 1 1
      src/addon/helper/EmailNotification.java
  12. 1 1
      src/addon/helper/FlexibilitySketch.java
  13. 7 7
      src/addon/helper/HolonElementSketch.java
  14. 2 2
      src/addon/helper/RandomPriotity.java
  15. 13 14
      src/algorithm/binary/BaseLine.java
  16. 13 13
      src/algorithm/example/DemoAlgo.java
  17. 30 33
      src/algorithm/example/FlexExample.java
  18. 13 8
      src/algorithm/objective_function/Evaluation.java
  19. 5 3
      src/algorithm/objective_function/GraphMetrics.java
  20. 11 6
      src/algorithm/objective_function/ObjectiveFunctionByCarlos.java
  21. 1 1
      src/algorithm/objective_function/SwitchObjectiveFunction.java
  22. 3 2
      src/algorithm/objective_function/TopologieObjectiveFunction.java
  23. 1 1
      src/algorithm/topologie/AcoAlgorithm.java
  24. 2 1
      src/algorithm/topologie/GaAlgorithm.java
  25. 2 1
      src/algorithm/topologie/PsoAlgorithm.java
  26. 48 38
      src/api/AlgorithmFrameworkFlex.java
  27. 13 17
      src/api/TopologieAlgorithmFramework.java
  28. 0 248
      src/classes/Edge.java
  29. 0 291
      src/classes/HolonObject.java
  30. 0 51
      src/classes/Pair.java
  31. 0 41
      src/classes/comparator/EnergyMinToMaxComparator.java
  32. 0 36
      src/classes/comparator/MinEnergyComparator.java
  33. 0 36
      src/classes/comparator/TotalEnergyComparator.java
  34. 0 15
      src/classes/comparator/UnitGraphPointComperator.java
  35. 0 17
      src/classes/comparator/elementComparator/ElemCompOnEleName.java
  36. 0 25
      src/classes/comparator/elementComparator/ElemCompOnEnergy.java
  37. 0 27
      src/classes/comparator/elementComparator/ElemCompOnId.java
  38. 0 20
      src/classes/comparator/elementComparator/ElemCompOnIsActivated.java
  39. 0 17
      src/classes/comparator/elementComparator/ElementComparator.java
  40. 5 5
      src/connect/ConnectHandheld.java
  41. 7 7
      src/connect/ConnectPhysical.java
  42. 10 10
      src/connect/socket/Server.java
  43. 3 2
      src/interfaces/GraphEditable.java
  44. 0 18
      src/interfaces/ObjectListener.java
  45. 18 32
      src/model/AbstractCanvasObject.java
  46. 3 3
      src/model/Constrain.java
  47. 141 0
      src/model/Edge.java
  48. 89 13
      src/model/Flexibility.java
  49. 13 9
      src/model/GroupNode.java
  50. 109 117
      src/model/HolonElement.java
  51. 245 0
      src/model/HolonObject.java
  52. 69 66
      src/model/HolonSwitch.java
  53. 2 8
      src/model/Node.java
  54. 65 0
      src/preferences/ColorPreference.java
  55. 7 18
      src/ui/controller/CanvasController.java
  56. 16 11
      src/ui/controller/CategoryController.java
  57. 22 28
      src/ui/controller/ClipboardController.java
  58. 12 31
      src/ui/controller/Control.java
  59. 0 188
      src/ui/controller/FlexManager.java
  60. 3 3
      src/ui/controller/GlobalController.java
  61. 20 42
      src/ui/controller/LoadController.java
  62. 13 24
      src/ui/controller/MultiPurposeController.java
  63. 11 10
      src/ui/controller/NodeController.java
  64. 24 45
      src/ui/controller/ObjectController.java
  65. 21 8
      src/ui/controller/SaveController.java
  66. 8 32
      src/ui/controller/SimulationManager.java
  67. 1 1
      src/ui/model/Consumer.java
  68. 1 1
      src/ui/model/DecoratedCable.java
  69. 4 4
      src/ui/model/DecoratedGroupNode.java
  70. 1 1
      src/ui/model/DecoratedHolonObject.java
  71. 20 22
      src/ui/model/DecoratedNetwork.java
  72. 1 9
      src/ui/model/DecoratedState.java
  73. 1 1
      src/ui/model/DecoratedSwitch.java
  74. 1 1
      src/ui/model/ExitCable.java
  75. 1 1
      src/ui/model/IdCounter.java
  76. 5 6
      src/ui/model/IntermediateCableWithState.java
  77. 3 3
      src/ui/model/IntermediateCalculationCable.java
  78. 18 12
      src/ui/model/MinimumModel.java
  79. 2 2
      src/ui/model/MinimumNetwork.java
  80. 34 116
      src/ui/model/Model.java
  81. 1 1
      src/ui/model/Passiv.java
  82. 1 1
      src/ui/model/Supplier.java
  83. 5 5
      src/ui/model/VisualRepresentationalState.java
  84. 15 15
      src/ui/view/canvas/AbstractCanvas.java
  85. 28 48
      src/ui/view/canvas/Canvas.java
  86. 21 22
      src/ui/view/canvas/GroupNodeCanvas.java
  87. 8 2
      src/ui/view/component/TrippleCheckBox.java
  88. 8 7
      src/ui/view/dialog/AddElementPopUp.java
  89. 9 10
      src/ui/view/dialog/AddObjectPopUp.java
  90. 3 2
      src/ui/view/dialog/BackgroundPopUp.java
  91. 4 3
      src/ui/view/dialog/CreateNewDialog.java
  92. 7 7
      src/ui/view/dialog/CreateTemplatePopUp.java
  93. 2 2
      src/ui/view/dialog/EditEdgesPopUp.java
  94. 2 2
      src/ui/view/dialog/SearchPopUp.java
  95. 37 26
      src/ui/view/information/FilterableGroupNode.java
  96. 53 39
      src/ui/view/information/HolonInformationPanel.java
  97. 2 2
      src/ui/view/inspector/Inspector.java
  98. 16 16
      src/ui/view/inspector/InspectorTable.java
  99. 8 8
      src/ui/view/inspector/UnitGraph.java
  100. 5 7
      src/ui/view/inspector/UnitGraphPoint.java

BIN
jars/junit-4.12.jar


+ 0 - 44
src/TypeAdapter/AbstractCpsObjectAdapter.java

@@ -1,44 +0,0 @@
-package TypeAdapter;
-
-import java.lang.reflect.Type;
-
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
-
-import classes.AbstractCanvasObject;
-import classes.GroupNode;
-
-public class AbstractCpsObjectAdapter
-		implements JsonSerializer<AbstractCanvasObject>, JsonDeserializer<AbstractCanvasObject> {
-
-	@Override
-	public JsonElement serialize(AbstractCanvasObject arg0, Type arg1, JsonSerializationContext arg2) {
-		JsonObject object = new JsonObject();
-		object.add("type", new JsonPrimitive(arg0.getClass().getSimpleName()));
-		object.add("properties", arg2.serialize(arg0, arg0.getClass()));
-		if (arg0 instanceof GroupNode)
-			object.add("hash", new JsonPrimitive(arg0.hashCode()));
-		return object;
-	}
-
-	@Override
-	public AbstractCanvasObject deserialize(JsonElement arg0, Type arg1, JsonDeserializationContext arg2)
-			throws JsonParseException {
-		JsonObject object = arg0.getAsJsonObject();
-		String type = object.get("type").getAsString();
-		JsonElement element = object.get("properties");
-		try {
-			String packageName = "classes.";
-			return arg2.deserialize(element, Class.forName(packageName + type));
-		} catch (ClassNotFoundException cnfe) {
-			throw new JsonParseException("Unknown element type: " + type, cnfe);
-		}
-	}
-
-}

+ 0 - 34
src/TypeAdapter/ColorAdapter.java

@@ -1,34 +0,0 @@
-package TypeAdapter;
-
-import java.awt.Color;
-import java.lang.reflect.Type;
-
-import com.google.gson.JsonDeserializationContext;
-import com.google.gson.JsonDeserializer;
-import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParseException;
-import com.google.gson.JsonPrimitive;
-import com.google.gson.JsonSerializationContext;
-import com.google.gson.JsonSerializer;
-
-public class ColorAdapter implements JsonSerializer<Color>, JsonDeserializer<Color> {
-
-	@Override
-	public Color deserialize(JsonElement arg0, Type arg1, JsonDeserializationContext arg2) throws JsonParseException {
-		JsonObject object = arg0.getAsJsonObject();
-		return new Color(object.get("R").getAsInt(), object.get("G").getAsInt(), object.get("B").getAsInt());
-		
-	}
-
-	@Override
-	public JsonElement serialize(Color arg0, Type arg1, JsonSerializationContext arg2) {
-		JsonObject object = new JsonObject();
-		object.add("R", new JsonPrimitive(arg0.getRed()));
-		object.add("G", new JsonPrimitive(arg0.getGreen()));
-		object.add("B", new JsonPrimitive(arg0.getBlue()));
-		
-		return object;
-	}
-
-}

+ 44 - 0
src/adapter/AbstractCpsObjectAdapter.java

@@ -0,0 +1,44 @@
+package adapter;
+
+import java.lang.reflect.Type;
+
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
+
+import model.AbstractCanvasObject;
+import model.GroupNode;
+
+public class AbstractCpsObjectAdapter
+		implements JsonSerializer<AbstractCanvasObject>, JsonDeserializer<AbstractCanvasObject> {
+
+	@Override
+	public JsonElement serialize(AbstractCanvasObject object, Type type, JsonSerializationContext context) {
+		JsonObject jsonObject = new JsonObject();
+		jsonObject.add("type", new JsonPrimitive(object.getClass().getSimpleName()));
+		jsonObject.add("properties", context.serialize(object, object.getClass()));
+		if (object instanceof GroupNode)
+			jsonObject.add("hash", new JsonPrimitive(object.hashCode()));
+		return jsonObject;
+	}
+
+	@Override
+	public AbstractCanvasObject deserialize(JsonElement ele, Type type, JsonDeserializationContext context)
+			throws JsonParseException {
+		JsonObject object = ele.getAsJsonObject();
+		String typeName = object.get("type").getAsString();
+		JsonElement element = object.get("properties");
+		try {
+			String packageName = AbstractCanvasObject.class.getPackageName() + ".";
+			return context.deserialize(element, Class.forName(packageName + typeName));
+		} catch (ClassNotFoundException cnfe) {
+			throw new JsonParseException("Unknown element type: " + type, cnfe);
+		}
+	}
+
+}

+ 6 - 7
src/TypeAdapter/PairAdapter.java → src/adapter/PairAdapter.java

@@ -1,6 +1,7 @@
-package TypeAdapter;
+package adapter;
 
 import java.lang.reflect.Type;
+import java.util.AbstractMap.SimpleEntry;
 
 import com.google.gson.JsonDeserializationContext;
 import com.google.gson.JsonDeserializer;
@@ -11,21 +12,19 @@ import com.google.gson.JsonPrimitive;
 import com.google.gson.JsonSerializationContext;
 import com.google.gson.JsonSerializer;
 
-import classes.Pair;
 
 
-
-public class PairAdapter implements JsonSerializer<Pair<String, String>>, JsonDeserializer<Pair<String, String>>{
+public class PairAdapter implements JsonSerializer<SimpleEntry<String, String>>, JsonDeserializer<SimpleEntry<String, String>>{
 
 	@Override
-	public Pair<String, String> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+	public SimpleEntry<String, String> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
 			throws JsonParseException {
 		JsonObject object = json.getAsJsonObject();	
-		return new Pair<String, String>(object.get("KEY").getAsString(), object.get("VALUE").getAsString());
+		return new SimpleEntry<String, String>(object.get("KEY").getAsString(), object.get("VALUE").getAsString());
 	}
 
 	@Override
-	public JsonElement serialize(Pair<String, String> src, Type typeOfSrc, JsonSerializationContext context) {		
+	public JsonElement serialize(SimpleEntry<String, String> src, Type typeOfSrc, JsonSerializationContext context) {		
 		JsonObject object = new JsonObject();
 		object.add("KEY", new JsonPrimitive(src.getKey()));
 		object.add("VALUE", new JsonPrimitive(src.getValue()));

+ 1 - 1
src/TypeAdapter/PositionAdapter.java → src/adapter/PositionAdapter.java

@@ -1,4 +1,4 @@
-package TypeAdapter;
+package adapter;
 
 import java.lang.reflect.Type;
 

+ 15 - 15
src/addOns/InformationPanel.java → src/addon/InformationPanel.java

@@ -1,4 +1,4 @@
-package addOns;
+package addon;
 
 import java.awt.BorderLayout;
 import java.awt.Dimension;
@@ -22,11 +22,10 @@ import javax.swing.JSeparator;
 import javax.swing.JTextField;
 
 import api.AddOn;
-import classes.Flexibility;
-import classes.HolonElement;
-import classes.HolonElement.Priority;
+import model.Flexibility;
+import model.HolonElement;
+import model.HolonElement.Priority;
 import ui.controller.Control;
-import ui.controller.FlexManager.FlexState;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.DecoratedState;
 import ui.model.DecoratedSwitch.SwitchState;
@@ -248,15 +247,16 @@ public class InformationPanel implements AddOn {
 			return net.getConsumerList().stream().filter(con -> con.getState() == HolonObjectState.OVER_SUPPLIED);
 		}).mapToDouble(con -> con.getSupplyBarPercentage()).summaryStatistics();
 		
-		List<Flexibility> flexList = control.getSimManager().getActualFlexManager().getAllFlexWrapper().stream().filter(flexwrapper -> flexwrapper.getFlex().offered).map(flex -> flex.getFlex()).collect(Collectors.toList());
-		amountEssential = (int)flexList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Essential).count();
-		amountHigh = (int)flexList.stream().filter(flex -> flex.getElement().getPriority() == Priority.High).count();
-		amountMedium = (int)flexList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Medium).count();
-		amountLow = (int)flexList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Low).count();
+		//TODO(Tom2021-12-1) allOfferedFlex
+		List<Flexibility> allOfferedFlex = new ArrayList<>();
+		amountEssential = (int)allOfferedFlex.stream().filter(flex -> flex.getElement().getPriority() == Priority.Essential).count();
+		amountHigh = (int)allOfferedFlex.stream().filter(flex -> flex.getElement().getPriority() == Priority.High).count();
+		amountMedium = (int)allOfferedFlex.stream().filter(flex -> flex.getElement().getPriority() == Priority.Medium).count();
+		amountLow = (int)allOfferedFlex.stream().filter(flex -> flex.getElement().getPriority() == Priority.Low).count();
 		this.amountFlexibilities = amountEssential + amountHigh + amountMedium + amountLow;
 		
-		
-		List<Flexibility> flexActiveList = control.getSimManager().getActualFlexManager().getAllFlexWrapperWithState(FlexState.IN_USE).stream().map(flex -> flex.getFlex()).collect(Collectors.toList());
+		//TODO(Tom2021-12-1) allFlexinUse
+		List<Flexibility> flexActiveList = new ArrayList<>();
 		amountActiveEssential = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Essential).count();
 		amountActiveHigh = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.High).count();
 		amountActiveMedium = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Medium).count();
@@ -269,7 +269,7 @@ public class InformationPanel implements AddOn {
 		amountHolons = dState.getNetworkList().size();
 		List<HolonElement> listHolonElements = control.getModel().getAllHolonElemnts();
 		this.amountHolonElements = listHolonElements.size();
-		List<HolonElement> listAcitveHolonElemnts = listHolonElements.stream().filter(ele -> ele.isActive()).collect(Collectors.toList());
+		List<HolonElement> listAcitveHolonElemnts = listHolonElements.stream().filter(ele -> ele.active).collect(Collectors.toList());
 		this.amountActiveHolonElements = listAcitveHolonElemnts.size();
 		this.amountInactiveHolonElements = amountHolonElements - amountActiveHolonElements;
 		this.amountElementLow = (int) listHolonElements.stream().filter(ele -> ele.getPriority() == Priority.Low).count();
@@ -293,9 +293,9 @@ public class InformationPanel implements AddOn {
 		int producingFlex = 0;
 		//float producingFlexEnergy = 0.0f;
 		//int maxCooldown = 0;
-		for(Flexibility flex :flexList) {
+		for(Flexibility flex :allOfferedFlex) {
 //			cost += flex.cost;
-			float energy = flex.bringtmir();
+			float energy = flex.energyReleased();
 			if(energy < 0) {
 				consumingFlex++;
 //				consumingFlexEnergy += -energy;

+ 9 - 8
src/addOns/RandomOfferdFlexibility.java → src/addon/RandomOfferdFlexibility.java

@@ -1,4 +1,4 @@
-package addOns;
+package addon;
 
 import java.awt.BorderLayout;
 import java.awt.ComponentOrientation;
@@ -26,8 +26,8 @@ import javax.swing.JPanel;
 import javax.swing.JSlider;
 import javax.swing.text.NumberFormatter;
 import api.AddOn;
-import classes.Flexibility;
-import classes.HolonElement.Priority;
+import model.Flexibility;
+import model.HolonElement.Priority;
 import ui.controller.Control;
 
 /**
@@ -324,11 +324,12 @@ public class RandomOfferdFlexibility implements AddOn {
 		}
 		control.calculateStateAndVisualForCurrentTimeStep();
 		control.updateCanvas();
-		List<Flexibility> flexList = control.getSimManager().getActualFlexManager().getAllFlexWrapper().stream().filter(flexwrapper -> flexwrapper.getFlex().offered).map(flex -> flex.getFlex()).collect(Collectors.toList());
-		low.flexList = flexList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Low && flex.fulfillsConstrains()).collect(Collectors.toList());
-		medium.flexList = flexList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Medium && flex.fulfillsConstrains()).collect(Collectors.toList());
-		high.flexList = flexList.stream().filter(flex -> flex.getElement().getPriority() == Priority.High && flex.fulfillsConstrains()).collect(Collectors.toList());
-		essential.flexList = flexList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Essential && flex.fulfillsConstrains()).collect(Collectors.toList());
+		//TODO(Tom2021-12-1) calculate All Offered Flex
+		List<Flexibility> allOfferedFlex = new ArrayList<>();
+		low.flexList = allOfferedFlex.stream().filter(flex -> flex.getElement().getPriority() == Priority.Low).collect(Collectors.toList());
+		medium.flexList = allOfferedFlex.stream().filter(flex -> flex.getElement().getPriority() == Priority.Medium).collect(Collectors.toList());
+		high.flexList = allOfferedFlex.stream().filter(flex -> flex.getElement().getPriority() == Priority.High).collect(Collectors.toList());
+		essential.flexList = allOfferedFlex.stream().filter(flex -> flex.getElement().getPriority() == Priority.Essential).collect(Collectors.toList());
 		low.update();
 		medium.update();
 		high.update();

+ 2 - 2
src/addOns/RandomSwitch.java → src/addon/RandomSwitch.java

@@ -1,4 +1,4 @@
-package addOns;
+package addon;
 
 import java.awt.BorderLayout;
 import java.awt.Dimension;
@@ -12,7 +12,7 @@ import javax.swing.JPanel;
 import javax.swing.JSlider;
 
 import api.AddOn;
-import classes.HolonSwitch;
+import model.HolonSwitch;
 import ui.controller.Control;
 
 public class RandomSwitch implements AddOn {

+ 7 - 7
src/addOns/Randomizer.java → src/addon/Randomizer.java

@@ -1,4 +1,4 @@
-package addOns;
+package addon;
 
 import java.awt.BorderLayout;
 import java.awt.Dimension;
@@ -37,13 +37,13 @@ import com.google.gson.JsonIOException;
 import com.google.gson.JsonParser;
 import com.google.gson.JsonSyntaxException;
 
-import addOns.Utility.HolonElementSketch;
-import addOns.Utility.RandomPriotity;
+import addon.helper.HolonElementSketch;
+import addon.helper.RandomPriotity;
 import api.AddOn;
-import classes.AbstractCanvasObject;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.HolonObject;
+import model.AbstractCanvasObject;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
 import ui.controller.Control;
 import utility.ImageImport;
 import utility.Random;

+ 1 - 1
src/addOns/Utility/EmailNotification.java → src/addon/helper/EmailNotification.java

@@ -1,4 +1,4 @@
-package addOns.Utility;
+package addon.helper;
 import java.awt.BorderLayout;
 import java.awt.ComponentOrientation;
 import java.awt.Dimension;

+ 1 - 1
src/addOns/Utility/FlexibilitySketch.java → src/addon/helper/FlexibilitySketch.java

@@ -1,4 +1,4 @@
-package addOns.Utility;
+package addon.helper;
 
 public class FlexibilitySketch{
 	public double flexChance;

+ 7 - 7
src/addOns/Utility/HolonElementSketch.java → src/addon/helper/HolonElementSketch.java

@@ -1,11 +1,11 @@
-package addOns.Utility;
+package addon.helper;
 
-import classes.Constrain;
-import classes.Flexibility;
-import classes.HolonElement;
-import classes.HolonElement.Priority;
+import model.Constrain;
+import model.Flexibility;
+import model.HolonElement;
+import model.HolonObject;
+import model.HolonElement.Priority;
 import utility.Random;
-import classes.HolonObject;
 
 public class HolonElementSketch {
 	//HolonElement
@@ -25,7 +25,7 @@ public class HolonElementSketch {
 	}
 	public HolonElement createHolonElement(HolonObject parentObject, boolean active) {
 		HolonElement ele = new HolonElement(parentObject, name, energy);
-		ele.setActive(active);
+		ele.active = 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);
 		ele.setPriority(Priority.valueOf(priority));

+ 2 - 2
src/addOns/Utility/RandomPriotity.java → src/addon/helper/RandomPriotity.java

@@ -1,4 +1,4 @@
-package addOns.Utility;
+package addon.helper;
 
 import java.util.Hashtable;
 
@@ -8,7 +8,7 @@ import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JSlider;
 
-import classes.HolonElement.Priority;
+import model.HolonElement.Priority;
 
 public class RandomPriotity extends JPanel{
 	/**

+ 13 - 14
src/algorithm/binary/BaseLine.java

@@ -24,11 +24,11 @@ import javax.swing.JSplitPane;
 import javax.swing.JTextArea;
 
 import api.AddOn;
-import classes.AbstractCanvasObject;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.HolonSwitch;
+import model.AbstractCanvasObject;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
+import model.HolonSwitch;
 import ui.controller.Control;
 import ui.model.Model;
 import ui.model.DecoratedGroupNode;
@@ -271,7 +271,6 @@ public class BaseLine implements AddOn {
 	 */
 	private void executeBaseLine() {
 		extractPositionAndAccess();
-		int actualIteration = control.getModel().getCurrentIteration();
 		if(closeSwitches)setAllSwitchesClosed();
 		setHolonElemntsAktiv();
 		control.calculateStateAndVisualForCurrentTimeStep();
@@ -290,17 +289,17 @@ public class BaseLine implements AddOn {
 				println("inAktiveCount:" + inAktiveCount);
 				final int inAktiveCountFinal = inAktiveCount;
 				List<HolonObject> conList = Stream.concat(net.getConsumerList().stream(), net.getConsumerSelfSuppliedList().stream()).map(con -> con.getModel()).filter(object -> objectList.contains(object)).filter(object -> (object.getNumberOfInActiveElements() == inAktiveCountFinal)).collect(Collectors.toList());
-				conList.sort((a,b) -> Float.compare(a.getMaximumConsumingElementEnergy(actualIteration), b.getMaximumConsumingElementEnergy(actualIteration)));
+				conList.sort((a,b) -> Float.compare(a.getMaximumConsumingElementEnergy(), b.getMaximumConsumingElementEnergy()));
 				consumer:
 				for(HolonObject con: conList) {
 					//println("Consumer" + con);
-					List<HolonElement> sortedElementList = con.getElements().stream().filter(ele -> ele.isActive() && ele.isConsumer()).sorted((a,b) -> -Float.compare(-a.getEnergyAtTimeStep(actualIteration), -b.getEnergyAtTimeStep(actualIteration))).collect(Collectors.toList());
+					List<HolonElement> sortedElementList = con.getElements().stream().filter(ele -> ele.active && ele.isConsumer()).sorted((a,b) -> -Float.compare(-a.getActualEnergy(), -b.getActualEnergy())).collect(Collectors.toList());
 					for(HolonElement element: sortedElementList) {
-						float elementConsumption = -element.getEnergyAtTimeStep(actualIteration);
+						float elementConsumption = -element.getActualEnergy();
 						if(elementConsumption <= difference) {
 							println("elementConsumption:" + elementConsumption);
 							difference -= elementConsumption;
-							element.setActive(false);
+							element.active = false;
 							continue consumer;
 						}
 					}
@@ -329,7 +328,7 @@ public class BaseLine implements AddOn {
 	/**
 	 * Method to get the current Position alias a ListOf Booleans for aktive settings on the Objects on the Canvas.
 	 * Also initialize the Access Hashmap to swap faster positions.
-	 * @param model
+	 * @param ModelTest
 	 * @return
 	 */
 	private List<Boolean> extractPositionAndAccess() {
@@ -338,7 +337,7 @@ public class BaseLine implements AddOn {
 		objectList = new ArrayList<HolonObject>();
 		initialState = new ArrayList<Boolean>(); 
 		access= new HashMap<Integer, AccessWrapper>();
-		rollOutNodes((useGroupNode && (dGroupNode != null))? dGroupNode.getModel().getNodes() :model.getObjectsOnCanvas(), initialState, model.getCurrentIteration());
+		rollOutNodes((useGroupNode && (dGroupNode != null))? dGroupNode.getModel().getNodes() :model.getObjectsOnCanvas(), initialState, model.getActualTimeStep());
 		return initialState;
 	}
 	/**
@@ -351,7 +350,7 @@ public class BaseLine implements AddOn {
 		for(AbstractCanvasObject aCps : nodes) {
 			if (aCps instanceof HolonObject) {
 				for (HolonElement hE : ((HolonObject) aCps).getElements()) {
-					positionToInit.add(hE.isActive());
+					positionToInit.add(hE.active);
 					access.put(positionToInit.size() - 1 , new AccessWrapper(hE));
 				}
 				objectList.add((HolonObject) aCps);
@@ -414,7 +413,7 @@ public class BaseLine implements AddOn {
 		}
 		public void setState(boolean state) {
 			if(type == HOLONELEMENT) {
-				hElement.setActive(state);
+				hElement.active = state;
 			}else{//is switch
 				hSwitch.setManualMode(true);
 				hSwitch.setManualState(state);

+ 13 - 13
src/algorithm/example/DemoAlgo.java

@@ -26,11 +26,11 @@ import javax.swing.JTextArea;
 import javax.swing.text.NumberFormatter;
 
 import api.AddOn;
-import classes.AbstractCanvasObject;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.HolonSwitch;
+import model.AbstractCanvasObject;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
+import model.HolonSwitch;
 import ui.controller.Control;
 import ui.model.DecoratedGroupNode;
 import ui.model.Model;
@@ -283,7 +283,7 @@ public class DemoAlgo implements AddOn {
 		private void executeDemoAlgo() {
 			extractPositionAndAccess();
 			counter = 0;
-			int actualIteration = control.getModel().getCurrentIteration();
+			int actualIteration = control.getModel().getActualTimeStep();
 			deactivateWindrad();
 			setAllSwitchesClosed();
 			updateVisual();
@@ -292,7 +292,7 @@ public class DemoAlgo implements AddOn {
 				//Schalte Slow das Windrad Ein
 				if(windrad == null)return;
 				for(int i = 0; i< windrad.getNumberOfElements(); i++) {
-					windrad.getElements().get(i).setActive(true);
+					windrad.getElements().get(i).active = true;
 					TimeUnit.MILLISECONDS.sleep(waitDurationWindradStep);
 					updateVisual();
 				}
@@ -312,7 +312,7 @@ public class DemoAlgo implements AddOn {
 		
 		private void deactivateWindrad() {
 			if(windrad == null)return;
-			windrad.getElements().stream().forEach(ele -> ele.setActive(false));
+			windrad.getElements().stream().forEach(ele -> ele.active = false);
 		}
 		private void setHolonElemntsAktiv(int actualIteration) {
 			for(int i = 0;i<access.size();i++) {
@@ -332,7 +332,7 @@ public class DemoAlgo implements AddOn {
 		/**
 		 * Method to get the current Position alias a ListOf Booleans for aktive settings on the Objects on the Canvas.
 		 * Also initialize the Access Hashmap to swap faster positions.
-		 * @param model
+		 * @param ModelTest
 		 * @return
 		 */
 		private List<Boolean> extractPositionAndAccess() {
@@ -341,7 +341,7 @@ public class DemoAlgo implements AddOn {
 			objectList = new ArrayList<HolonObject>();
 			initialState = new ArrayList<Boolean>(); 
 			access= new HashMap<Integer, AccessWrapper>();
-			rollOutNodes((useGroupNode && (dGroupNode != null))? dGroupNode.getModel().getNodes() :model.getObjectsOnCanvas(), initialState, model.getCurrentIteration());
+			rollOutNodes((useGroupNode && (dGroupNode != null))? dGroupNode.getModel().getNodes() :model.getObjectsOnCanvas(), initialState, model.getActualTimeStep());
 			return initialState;
 		}
 		/**
@@ -354,7 +354,7 @@ public class DemoAlgo implements AddOn {
 			for(AbstractCanvasObject aCps : nodes) {
 				if (aCps instanceof HolonObject) {
 					for (HolonElement hE : ((HolonObject) aCps).getElements()) {
-						positionToInit.add(hE.isActive());
+						positionToInit.add(hE.active);
 						access.put(positionToInit.size() - 1 , new AccessWrapper(hE));
 					}
 					objectList.add((HolonObject) aCps);
@@ -441,7 +441,7 @@ public class DemoAlgo implements AddOn {
 			}
 			public void setState(boolean state) {
 				if(type == HOLONELEMENT) {
-					hElement.setActive(state);
+					hElement.active = state;
 				}else{//is switch
 					hSwitch.setManualMode(true);
 					hSwitch.setManualState(state);
@@ -449,7 +449,7 @@ public class DemoAlgo implements AddOn {
 					
 			}
 			public boolean getState(int timeStep) {
-				return (type == HOLONELEMENT)?hElement.isActive():hSwitch.getState(timeStep);
+				return (type == HOLONELEMENT)?hElement.active:hSwitch.getState(timeStep);
 			}
 			public int getType() {
 				return type;

+ 30 - 33
src/algorithm/example/FlexExample.java

@@ -28,16 +28,14 @@ import javax.swing.JTextArea;
 import javax.swing.text.NumberFormatter;
 
 import api.AddOn;
-import classes.AbstractCanvasObject;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.HolonElement.Priority;
-import classes.HolonObject;
-import classes.HolonSwitch;
+import model.AbstractCanvasObject;
+import model.Flexibility;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
+import model.HolonSwitch;
+import model.HolonElement.Priority;
 import ui.controller.Control;
-import ui.controller.FlexManager;
-import ui.controller.FlexManager.FlexState;
-import ui.controller.FlexManager.FlexWrapper;
 import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedNetwork;
 import ui.model.DecoratedState;
@@ -332,7 +330,7 @@ public class FlexExample implements AddOn {
 		 */
 		private void executeDemoAlgo(RunResult result) {
 			extractPositionAndAccess();
-			int actualIteration = control.getModel().getCurrentIteration();
+			int actualIteration = control.getModel().getActualTimeStep();
 			println("TimeStep:" + actualIteration);
 			control.calculateStateOnlyForCurrentTimeStep();
 			List<Priority> priorityListASC = createPriorityListASC();
@@ -347,32 +345,31 @@ public class FlexExample implements AddOn {
 				if(production > consumption) continue;
 				if(difference == 0)continue;
 				Set<HolonElement> allHolonElemntsInThisNetwork = createListOfAllHolonElemnts(net);
-				FlexManager flexManager = control.getSimManager().getActualFlexManager();
-				
-				List<FlexWrapper> allOfferedFlex = flexManager.getAllFlexWrapperWithState(FlexState.OFFERED).stream().filter(flexWrapper -> allHolonElemntsInThisNetwork.contains(flexWrapper.getFlex().getElement())).collect(Collectors.toList());
-				List<FlexWrapper> allFlexThatGetMeEnergy = allOfferedFlex.stream().filter(flexWrapper -> (flexWrapper.getFlex().bringtmir() > 0)).collect(Collectors.toList());
+				//TODO(Tom2021-12-1) AllOfferedFlex
+				List<Flexibility> allOfferedFlex = new ArrayList<>();
+				List<Flexibility> allFlexThatGetMeEnergy = allOfferedFlex.stream().filter(flexWrapper -> (flexWrapper.energyReleased() > 0)).collect(Collectors.toList());
 				float amountOfAllEnergyOffered = sumEnergyAvailable(allFlexThatGetMeEnergy);
 				println("amountOfAllFlexEnergyOffered:" + amountOfAllEnergyOffered);
 				//ShuddownPriorities
 				for(Priority emergencyShutDownPriority: priorityListASC) {
 					if(amountOfAllEnergyOffered >= difference) break; 
 					println("ShutDown: " + emergencyShutDownPriority);
-					difference -= shutDownAllConsumerElementsWithPriority(flexManager, allHolonElemntsInThisNetwork, emergencyShutDownPriority, result);
+					difference -= shutDownAllConsumerElementsWithPriority(allHolonElemntsInThisNetwork, emergencyShutDownPriority, result);
 				}
 				
 				//SortFlexes
-				allFlexThatGetMeEnergy.sort((flex1, flex2) -> Float.compare(flex1.getFlex().cost / flex1.getFlex().bringtmir(), flex2.getFlex().cost / flex2.getFlex().bringtmir()));
+				allFlexThatGetMeEnergy.sort((flex1, flex2) -> Float.compare(flex1.cost / flex1.energyReleased(), flex2.cost / flex2.energyReleased()));
 				//OrderFlexes
 				float costForThisTimeStep = 0f;
 				int amountflexActivated = 0;
-				for(FlexWrapper flexWrapper : allFlexThatGetMeEnergy) {
-					if(!flexWrapper.canOrder()) continue;
-					float energy = flexWrapper.getFlex().bringtmir();
+				for(Flexibility flex : allFlexThatGetMeEnergy) {
+					if(!flex.canOrder()) continue;
+					float energy = flex.energyReleased();
 					if(energy <= difference) {
 						println("energyGained:" + energy);
 						difference -= energy;
-						costForThisTimeStep += flexWrapper.getFlex().cost;
-						flexWrapper.order();
+						costForThisTimeStep += flex.cost;
+						flex.order();
 						amountflexActivated++;
 						continue;
 					}
@@ -419,13 +416,13 @@ public class FlexExample implements AddOn {
 		
 		
 		
-		private float shutDownAllConsumerElementsWithPriority(FlexManager flexManager, Set<HolonElement> allHolonElemntsInThisNetwork,
+		private float shutDownAllConsumerElementsWithPriority(Set<HolonElement> allHolonElemntsInThisNetwork,
 				Priority emergencyShutDownPriority, RunResult result) {
 			
-			List<HolonElement> elementsOfPriorityToShutdown = allHolonElemntsInThisNetwork.stream().filter(hElement -> hElement.isConsumer() && hElement.getPriority() == emergencyShutDownPriority && !hElement.isFlexActive(flexManager) && hElement.isActive()).collect(Collectors.toList());
+			List<HolonElement> elementsOfPriorityToShutdown = allHolonElemntsInThisNetwork.stream().filter(hElement -> hElement.isConsumer() && hElement.getPriority() == emergencyShutDownPriority && !hElement.isFlexActive() && hElement.active).collect(Collectors.toList());
 					//.forEach(hElement -> hElement.setActive(false));
 			float energyGained = elementsOfPriorityToShutdown.stream().map(hElement -> -hElement.getEnergy()).reduce(0.0f, (a, b) -> a + b);
-			elementsOfPriorityToShutdown.forEach(hElement -> hElement.setActive(false));
+			elementsOfPriorityToShutdown.forEach(hElement -> hElement.active = false);
 			int shutdownCount = elementsOfPriorityToShutdown.size();
 			result.deactivatedElements += shutdownCount;
 			println("Gained " + energyGained + "Energy from Shutdown with Priority:" + emergencyShutDownPriority + " AmountOfShutDowned HolonElements: " + shutdownCount);
@@ -440,11 +437,11 @@ public class FlexExample implements AddOn {
 		}
 
 	
-		private float sumEnergyAvailable(List<FlexWrapper> flexList) {
-			HashMap<HolonElement, FlexWrapper> dublicateFilter = new HashMap<HolonElement, FlexWrapper>();
-			flexList.stream().forEach(flexWrapper -> dublicateFilter.put(flexWrapper.getFlex().getElement(), flexWrapper));
-			
-			return dublicateFilter.values().stream().map(flexWrapper -> flexWrapper.getFlex().bringtmir()).reduce(0.0f,(a, b) -> a + b);
+		private float sumEnergyAvailable(List<Flexibility> flexList) {
+			//TODO(Tom2021-12-1) is this nessesary
+			HashMap<HolonElement, Flexibility> dublicateFilter = new HashMap<HolonElement, Flexibility>();
+			flexList.stream().forEach(flex -> dublicateFilter.put(flex.getElement(), flex));
+			return dublicateFilter.values().stream().map(flex -> flex.energyReleased()).reduce(0.0f,Float::sum);
 		}
 		private List<Priority> createPriorityListASC() {
 			List<Priority> priorityASC = new ArrayList<Priority>();
@@ -457,7 +454,7 @@ public class FlexExample implements AddOn {
 		/**
 		 * Method to get the current Position alias a ListOf Booleans for aktive settings on the Objects on the Canvas.
 		 * Also initialize the Access Hashmap to swap faster positions.
-		 * @param model
+		 * @param ModelTest
 		 * @return
 		 */
 		private List<Boolean> extractPositionAndAccess() {
@@ -466,7 +463,7 @@ public class FlexExample implements AddOn {
 			objectList = new ArrayList<HolonObject>();
 			initialState = new ArrayList<Boolean>();
 			access= new HashMap<Integer, AccessWrapper>();
-			rollOutNodes((useGroupNode && (dGroupNode != null))? dGroupNode.getModel().getNodes() :model.getObjectsOnCanvas(), initialState, model.getCurrentIteration());			
+			rollOutNodes((useGroupNode && (dGroupNode != null))? dGroupNode.getModel().getNodes() :model.getObjectsOnCanvas(), initialState, model.getActualTimeStep());			
 			resetChain.add(initialState); 
 			return initialState;
 		}
@@ -480,7 +477,7 @@ public class FlexExample implements AddOn {
 			for(AbstractCanvasObject aCps : nodes) {
 				if (aCps instanceof HolonObject) {
 					for (HolonElement hE : ((HolonObject) aCps).getElements()) {
-						positionToInit.add(hE.isActive());
+						positionToInit.add(hE.active);
 						access.put(positionToInit.size() - 1 , new AccessWrapper(hE));
 					}
 					objectList.add((HolonObject) aCps);
@@ -544,7 +541,7 @@ public class FlexExample implements AddOn {
 			}
 			public void setState(boolean state) {
 				if(type == HOLONELEMENT) {
-					hElement.setActive(state);
+					hElement.active = state;
 				}else{//is switch
 					hSwitch.setManualMode(true);
 					hSwitch.setManualState(state);

+ 13 - 8
src/algorithm/objectiveFunction/Evaluation.java → src/algorithm/objective_function/Evaluation.java

@@ -1,11 +1,14 @@
-package algorithm.objectiveFunction;
+package algorithm.objective_function;
 
-import classes.HolonElement.Priority;
-import classes.HolonObject;
 import ui.model.DecoratedNetwork;
 import ui.model.DecoratedState;
-import ui.controller.FlexManager.FlexState;
-import ui.controller.FlexManager.FlexWrapper;
+import model.HolonObject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import model.Flexibility;
+import model.HolonElement.Priority;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 
 public class Evaluation {
@@ -42,10 +45,12 @@ public class Evaluation {
 		}
 		// calculate flexibility fitness old cost flex
 		/*for(FlexWrapper flexWrapper :state.getFlexManager().getAllFlexWrapperWithState(FlexState.IN_USE)) {
-			flexFitness += flexWrapper.getFlex().cost / (double)flexWrapper.getFlex().getDuration();
+			flexFitness += flexWrapper.cost / (double)flexWrapper.getDuration();
 		}*/
-		for(FlexWrapper flexWrapper :state.getFlexManager().getAllFlexWrapperWithState(FlexState.IN_USE)) {
-			flexFitness += Math.pow(sigma, (double)priorityToInt(flexWrapper.getFlex().getElement().getPriority())) - 1;
+		//TODO(Tom2021-12-1) getAllFlexInUse
+		List<Flexibility> getAllFlexInUse = new ArrayList<>();
+		for(Flexibility flexWrapper : getAllFlexInUse) {
+			flexFitness += Math.pow(sigma, (double)priorityToInt(flexWrapper.getElement().getPriority())) - 1;
 		}
 		
 		fitness = nw_fitness + object_fitness + flexFitness;

+ 5 - 3
src/algorithm/objectiveFunction/GraphMetrics.java → src/algorithm/objective_function/GraphMetrics.java

@@ -1,4 +1,4 @@
-package algorithm.objectiveFunction;
+package algorithm.objective_function;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -7,10 +7,12 @@ import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map.Entry;
+
+import model.AbstractCanvasObject;
+import model.HolonSwitch;
+
 import java.util.Set;
 
-import classes.AbstractCanvasObject;
-import classes.HolonSwitch;
 import ui.model.Consumer;
 import ui.model.DecoratedCable;
 import ui.model.DecoratedNetwork;

+ 11 - 6
src/algorithm/objectiveFunction/ObjectiveFunctionByCarlos.java → src/algorithm/objective_function/ObjectiveFunctionByCarlos.java

@@ -1,11 +1,13 @@
-package algorithm.objectiveFunction;
+package algorithm.objective_function;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import model.Flexibility;
+import model.HolonElement.Priority;
 import ui.model.DecoratedNetwork;
 import ui.model.DecoratedState;
 
-import classes.Flexibility;
-import classes.HolonElement.Priority;
-
 public class ObjectiveFunctionByCarlos {
 	//Parameters
 	
@@ -113,14 +115,17 @@ public class ObjectiveFunctionByCarlos {
 		
 		//calculate f_pro the penalty function for priority usage 
 		// for each active flexibility punish
+		
+		//TODO(Tom2021-12-1): get allFlexOfferedThisTimeStep
+		List<Flexibility> allFlexOfferedThisTimeStep = new ArrayList<>();
 		double f_pro = 0;
-		f_pro = state.getFlexManager().getAllFlexesOrderedThisTimeStep().stream().map(flex -> Math.pow(theta, priorityToDouble(flex.getElement().getPriority()) ) - 1.0).reduce(0.0, Double::sum);
+		f_pro = allFlexOfferedThisTimeStep.stream().map(flex -> Math.pow(theta, priorityToDouble(flex.getElement().getPriority()) ) - 1.0).reduce(0.0, Double::sum);
 		
 		//calculate f_perf the penalty function for the quality of a flexibility used
 		
 		// and the subfuction f_unre, f_cool, f_dur
 		double f_perf = 0;
-		for(Flexibility flex : state.getFlexManager().getAllFlexesOrderedThisTimeStep()) {
+		for(Flexibility flex : allFlexOfferedThisTimeStep) {
 			double f_unre =  unresponsivnessPenalty(flex.getSpeed());
 			double f_cool = cooldownPenalty(flex.getCooldown());
 			double f_dur = durationPenalty(flex.getDuration());

+ 1 - 1
src/algorithm/objectiveFunction/SwitchObjectiveFunction.java → src/algorithm/objective_function/SwitchObjectiveFunction.java

@@ -1,4 +1,4 @@
-package algorithm.objectiveFunction;
+package algorithm.objective_function;
 
 import ui.model.DecoratedNetwork;
 import ui.model.DecoratedState;

+ 3 - 2
src/algorithm/objectiveFunction/TopologieObjectiveFunction.java → src/algorithm/objective_function/TopologieObjectiveFunction.java

@@ -1,4 +1,4 @@
-package algorithm.objectiveFunction;
+package algorithm.objective_function;
 
 
 import ui.model.DecoratedHolonObject;
@@ -7,7 +7,8 @@ import ui.model.DecoratedState;
 import utility.FloatLog;
 
 import java.util.Locale;
-import algorithm.objectiveFunction.GraphMetrics.Graph;
+
+import algorithm.objective_function.GraphMetrics.Graph;
 
 public class TopologieObjectiveFunction {
 	//Parameters

+ 1 - 1
src/algorithm/topologie/AcoAlgorithm.java

@@ -5,7 +5,7 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 
-import algorithm.objectiveFunction.TopologieObjectiveFunction;
+import algorithm.objective_function.TopologieObjectiveFunction;
 import api.TopologieAlgorithmFramework;
 import ui.model.DecoratedState;
 import utility.Random;

+ 2 - 1
src/algorithm/topologie/GaAlgorithm.java

@@ -6,7 +6,8 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.TreeSet;
-import algorithm.objectiveFunction.TopologieObjectiveFunction;
+
+import algorithm.objective_function.TopologieObjectiveFunction;
 import api.TopologieAlgorithmFramework;
 import ui.model.DecoratedState;
 import utility.Random;

+ 2 - 1
src/algorithm/topologie/PsoAlgorithm.java

@@ -6,7 +6,8 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.TreeSet;
 import java.util.stream.Collectors;
-import algorithm.objectiveFunction.TopologieObjectiveFunction;
+
+import algorithm.objective_function.TopologieObjectiveFunction;
 import api.TopologieAlgorithmFramework;
 import ui.model.DecoratedState;
 import utility.Maths;

+ 48 - 38
src/api/AlgorithmFrameworkFlex.java

@@ -16,6 +16,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.DoubleSummaryStatistics;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Locale;
@@ -23,6 +24,7 @@ import java.util.function.BiFunction;
 import java.util.function.Consumer;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import javax.swing.BorderFactory;
 import javax.swing.Box;
@@ -41,19 +43,17 @@ import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
 import javax.swing.text.NumberFormatter;
 
-import addOns.Utility.EmailNotification;
-import algorithm.objectiveFunction.ObjectiveFunctionByCarlos;
-import algorithm.objectiveFunction.SwitchObjectiveFunction;
-import classes.AbstractCanvasObject;
-import classes.GroupNode;
-import classes.Flexibility;
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.HolonSwitch;
-import classes.HolonElement.Priority;
+import addon.helper.EmailNotification;
+import algorithm.objective_function.ObjectiveFunctionByCarlos;
+import algorithm.objective_function.SwitchObjectiveFunction;
+import model.AbstractCanvasObject;
+import model.Flexibility;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
+import model.HolonSwitch;
+import model.HolonElement.Priority;
 import ui.controller.Control;
-import ui.controller.FlexManager.FlexState;
-import ui.controller.FlexManager.FlexWrapper;
 import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedState;
 import ui.model.Model;
@@ -624,7 +624,6 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 			if(roundBest.fitness < runBest.fitness) runBest = roundBest;
 		}
 		
-		control.getSimManager().resetFlexManagerForTimeStep(control.getModel().getCurrentIteration());
 		this.extractPositionAndAccess();
 		setState(runBest.position);
 		updateVisual();
@@ -644,7 +643,9 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 	
 	private void calculateAndPrintFlexInfos(DecoratedState state) {
 		int amountOfUsedFlex = 0;
-		int amountOfFlex = state.getFlexManager().getAllFlexWrapper().size();
+		//TODO(Tom2021-12-1) calculate amounf of Flexes
+		Stream<Flexibility> allFlex = Stream.empty();
+		int amountOfFlex = (int)allFlex.count(); 
 		float cost = 0;
 		int consumingFlex = 0;
 		float consumingFlexEnergy = 0.0f;
@@ -655,10 +656,14 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 		int amountHigh = 0;
 		int amountMedium = 0;
 		int amountLow = 0;
-		for(FlexWrapper flexWrapper :state.getFlexManager().getAllFlexWrapperWithState(FlexState.IN_USE)) {
+		//TODO(Tom2021-12-1) calculate all flex in use
+		Stream<Flexibility> allFlexInUse = Stream.empty();
+		Iterator<Flexibility> iterInUseFlex =  allFlexInUse.iterator();
+		while(iterInUseFlex.hasNext()) {
+			Flexibility flex = iterInUseFlex.next();
 			amountOfUsedFlex++;
-			cost += flexWrapper.getFlex().cost;
-			float energy = flexWrapper.getFlex().bringtmir();
+			cost += flex.cost;
+			float energy = flex.energyReleased();
 			if(energy < 0) {
 				consumingFlex++;
 				consumingFlexEnergy += -energy;
@@ -666,8 +671,8 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 				producingFlex++;
 				producingFlexEnergy += energy;
 			}
-			if(flexWrapper.getFlex().getCooldown() > maxCooldown) maxCooldown = flexWrapper.getFlex().getCooldown();
-			switch(flexWrapper.getFlex().getElement().getPriority()) {
+			if(flex.getCooldown() > maxCooldown) maxCooldown = flex.getCooldown();
+			switch(flex.getElement().getPriority()) {
 			case Essential:
 				amountEssential++;
 				break;
@@ -753,7 +758,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 	 * @param position
 	 */
 	private void setState(List<Boolean> position) {
-		control.getSimManager().resetFlexManagerForTimeStep(control.getModel().getCurrentIteration());
+		control.resetSimulation();
 		int i = 0;
 		for(Boolean bool: position) {
 			access.get(i++).setState(bool);
@@ -765,7 +770,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 	/**
 	 * Method to get the current Position alias a ListOf Booleans for aktive settings on the Objects on the Canvas.
 	 * Also initialize the Access Hashmap to swap faster positions.
-	 * @param model
+	 * @param ModelTest
 	 * @return
 	 */
 	protected List<Boolean> extractPositionAndAccess() {
@@ -773,18 +778,22 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 		this.accessKillSwitch = new HashMap<HolonObject, AccessWrapper>();
 		access= new ArrayList<AccessWrapper>();
 		List<Boolean> initialState = new ArrayList<Boolean>();
-		rollOutNodes((dGroupNode != null)? dGroupNode.getModel().getNodes() :model.getObjectsOnCanvas(), initialState, model.getCurrentIteration());			
+		rollOutNodes((dGroupNode != null)? dGroupNode.getModel().getNodes() :model.getObjectsOnCanvas(), initialState, model.getActualTimeStep());			
 		resetChain.add(initialState);
-		if(algoUseFlexes) {			
-			for(FlexWrapper flex :control.getSimManager().getActualFlexManager().getAllFlexWrapperWithState(FlexState.OFFERED)){
+		if(algoUseFlexes) {		
+			//TODO(Tom2021-12-1) allOfferedFLex
+			List<Flexibility> allOfferedFLex = new ArrayList<>();
+			for(Flexibility flex :allOfferedFLex){
 				//flex.getFlex().getElement().parentObject;
-				AccessWrapper killSwitchAccess = this.algoUseKillSwitch ? this.accessKillSwitch.get(flex.getFlex().getElement().parentObject): null;;
-				access.add(new AccessWrapper(flex.getFlex(), killSwitchAccess));
+				AccessWrapper killSwitchAccess = this.algoUseKillSwitch ? this.accessKillSwitch.get(flex.getElement().parentObject): null;;
+				access.add(new AccessWrapper(flex, killSwitchAccess));
 				initialState.add(false);
 			}
-			for(FlexWrapper flex :control.getSimManager().getActualFlexManager().getAllFlexWrapperWithState(FlexState.IN_USE)){
-				AccessWrapper killSwitchAccess = this.algoUseKillSwitch ? this.accessKillSwitch.get(flex.getFlex().getElement().parentObject): null;
-				access.add(new AccessWrapper(flex.getFlex(), killSwitchAccess));
+			//TODO(Tom2021-12-1) allInUseFLex
+			List<Flexibility> allInUseFLex = new ArrayList<>();
+			for(Flexibility flex : allInUseFLex){
+				AccessWrapper killSwitchAccess = this.algoUseKillSwitch ? this.accessKillSwitch.get(flex.getElement().parentObject): null;
+				access.add(new AccessWrapper(flex, killSwitchAccess));
 				initialState.add(true);
 			}
 		}
@@ -813,7 +822,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 				}
 				if(this.algoUseElements) {
 					for (HolonElement hE : hObject.getElements()) {
-						positionToInit.add(hE.isActive());
+						positionToInit.add(hE.active);
 						access.add(new AccessWrapper(hE, killSwitchAccess));
 					}					
 				}
@@ -849,7 +858,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 			
 			val.activeElements = dGroupNode.getAmountOfAktiveElemntsFromHolonObjects();
 			val.elements = dGroupNode.getAmountOfElemntsFromHolonObjects();
-			//TODO what should be printed happen when only groupNode are selected
+			//TODO(Tom2021-12-1) what should be printed happen when only groupNode are selected
 		}
 		DecoratedState state = control.getSimManager().getActualDecorState();
 		for(DecoratedNetwork net : state.getNetworkList()) {
@@ -869,8 +878,8 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 		val.difference= Math.abs(val.production - val.consumption);
 		
 		
-		
-		List<Flexibility> flexActiveList = control.getSimManager().getActualFlexManager().getAllFlexWrapperWithState(FlexState.IN_USE).stream().map(flex -> flex.getFlex()).collect(Collectors.toList());
+		//TODO(Tom2021-12-1) flexActiveList;
+		List<Flexibility> flexActiveList = new ArrayList<>();
 		val.essentialFlex = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Essential).count();
 		val.highFlex = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.High).count();
 		val.mediumFlex = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Medium).count();
@@ -1175,7 +1184,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 			this.hObject = hObject;
 			intialStatesOfElementForKilllSwitch = new ArrayList<Boolean>();
 			for(HolonElement hE: hObject.getElements()) {
-				intialStatesOfElementForKilllSwitch.add(hE.isActive());
+				intialStatesOfElementForKilllSwitch.add(hE.active);
 			}
 		}
 		public AccessWrapper(HolonSwitch hSwitch){
@@ -1199,7 +1208,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 			switch(type) {
 				case  HolonElement:
 					if(!algoUseKillSwitch || (algoUseKillSwitch && !correspondingKillSwitch.getLastState())) {
-						hElement.setActive(state);
+						hElement.active = state;
 					}
 					break;
 				case Switch:
@@ -1208,17 +1217,18 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 					break;
 				case Flexibility:
 					if(state && (!algoUseKillSwitch || (algoUseKillSwitch && !correspondingKillSwitch.getLastState()))) {
-						control.getSimManager().getActualFlexManager().orderFlex(flex);
+						//TODO(Tom2021-12-1) order Flex
+						flex.order();
 					}
 					break;
 				case KillSwitch:
 					if(state) {
 						for (HolonElement hE : hObject.getElements()) {
-							hE.setActive(false);
+							hE.active = false;
 						}						
 					}else {
 						for(int i = 0; i < hObject.getElements().size(); i++) {
-							hObject.getElements().get(i).setActive(intialStatesOfElementForKilllSwitch.get(i));
+							hObject.getElements().get(i).active = intialStatesOfElementForKilllSwitch.get(i);
 						}
 					}
 					break;

+ 13 - 17
src/api/TopologieAlgorithmFramework.java

@@ -39,16 +39,13 @@ import javax.swing.JSeparator;
 import javax.swing.JSplitPane;
 import javax.swing.text.NumberFormatter;
 
-import algorithm.objectiveFunction.TopologieObjectiveFunction;
-import classes.AbstractCanvasObject;
-import classes.Category;
-import classes.Edge;
-import classes.GroupNode;
-import classes.HolonObject;
-import classes.HolonSwitch;
-import classes.IdCounter;
-import classes.Node;
-import classes.IdCounter.CounterType;
+import algorithm.objective_function.TopologieObjectiveFunction;
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
+import model.HolonObject;
+import model.HolonSwitch;
+import model.Node;
 import ui.controller.Control;
 import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedState;
@@ -56,6 +53,7 @@ import ui.model.Model;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.DecoratedSwitch.SwitchState;
 import ui.view.component.Console;
+import ui.view.main.Category;
 import ui.model.DecoratedNetwork;
 
 public abstract class TopologieAlgorithmFramework implements AddOn{
@@ -224,7 +222,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 	private void toggleSwitches() {
 		List<HolonSwitch> allSwitchList = control.getModel().getAllSwitches();
 		if(allSwitchList.isEmpty()) return;
-		boolean set = allSwitchList.get(0).getState(control.getModel().getCurrentIteration());
+		boolean set = allSwitchList.get(0).getState(control.getModel().getActualTimeStep());
 		allSwitchList.forEach(hSwitch -> {
 			hSwitch.setManualMode(true);
 			hSwitch.setManualState(!set);
@@ -622,7 +620,6 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 			if(roundBest.fitness < runBest.fitness) runBest = roundBest;
 		}
 		
-		control.getSimManager().resetFlexManagerForTimeStep(control.getModel().getCurrentIteration());
 		setState(runBest.position);
 		for(HolonSwitch hSwitch: switchList) {
 			hSwitch.setManualMode(true);
@@ -715,7 +712,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 	/**
 	 * Method to get the current Position alias a ListOf Booleans for aktive settings on the Objects on the Canvas.
 	 * Also initialize the Access Hashmap to swap faster positions.
-	 * @param model
+	 * @param ModelTest
 	 * @return
 	 */
 	protected List<Integer> extractPositionAndAccess() {
@@ -881,7 +878,6 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 			int middleX = (fromObject.getPosition().getX() +   toObject.getPosition().getX())/2;
 			int middleY = (fromObject.getPosition().getY() +   toObject.getPosition().getY())/2;
 			HolonSwitch newSwitch = new HolonSwitch("AddedSwitch");
-			newSwitch.setId(IdCounter.nextId(CounterType.Element));
 			newSwitch.setPosition(middleX, middleY);
 			//If fromObject is in Group
 			if(accessGroupNode.containsKey(fromObject)) {
@@ -898,18 +894,18 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 			//else if toObject is in Group
 			this.switchList.add(newSwitch);
 			//Generate Cable From Object A To Switch
-			Edge edge1 = new Edge(fromObject, newSwitch);
+			Edge edge1 = new Edge(fromObject, newSwitch, 0);
 			edge1.setUnlimitedCapacity(true);
 			control.getModel().getEdgesOnCanvas().add(edge1);
 			edgeList.add(edge1);
 			
 			//Generate Cable From Object B To Switch
-			Edge edge = new Edge(newSwitch, toObject);
+			Edge edge = new Edge(newSwitch, toObject, 0);
 			edge.setUnlimitedCapacity(true);
 			control.getModel().getEdgesOnCanvas().add(edge);
 			edgeList.add(edge);
 			}else {
-			Edge edge = new Edge(accessIntToObject.get(cable.first), accessIntToObject.get(cable.second));
+			Edge edge = new Edge(accessIntToObject.get(cable.first), accessIntToObject.get(cable.second), 0);
 			edge.setUnlimitedCapacity(true);
 			control.getModel().getEdgesOnCanvas().add(edge);
 			edgeList.add(edge);

+ 0 - 248
src/classes/Edge.java

@@ -1,248 +0,0 @@
-package classes;
-
-import com.google.gson.annotations.Expose;
-
-import java.util.ArrayList;
-
-/**
- * The class "CpsEdge" represents the connections on the GUI. Each connection
- * contains a max. capacity, a flow, a status (isWorking), tags (for internal
- * use of electricity flow), source and destination
- *
- * @author Gruppe14
- */
-public class Edge {
-
-    // Max. capacity of the Edge, if flow is greater than the status --> is
-    // Working would be false
-    @Expose
-    private float maxCapacity;
-    ArrayList<Integer> tags;
-    // for internal use --> flow of electricity (simulation state)
-    ArrayList<Integer> pseudoTags;
-    // Source
-    AbstractCanvasObject a;
-    // Destination
-    AbstractCanvasObject b;
-    
-    
-    
-    
-    
-    /**
-     * Getter for the length of the Cable.
-     * Always calculate never saved.
-     * Needs to be profiled whats better.
-     * @return
-     */
-    public float getLength() {
-    	return (float)a.getPosition().getDistance(b.getPosition());
-    }
-
-    @Expose
-    private boolean breakedManuel = false;
-    @Expose
-    private boolean unlimitedCapacity = false;
-    
-    
-    /**
-     * Constructor without max. capacity (by default as 100)
-     *
-     * @param a Source
-     * @param b Destination
-     */
-    public Edge(AbstractCanvasObject a, AbstractCanvasObject b) {
-        setA(a);
-        setB(b);
-        if(a == null) {
-        	System.out.println("A == NULL");
-        }
-        if(a == null) {
-        	System.out.println("B == NULL");
-        }
-        this.maxCapacity = 100;
-        pseudoTags = new ArrayList<>();
-    }
-
-    /**
-     * Constructor with a user-defined max. capacity
-     *
-     * @param a      Source
-     * @param b      Destination
-     * @param maxCap Maximum Capacity
-     */
-    public Edge(AbstractCanvasObject a, AbstractCanvasObject b, float maxCap) {
-        setA(a);
-        setB(b);
-        this.maxCapacity = maxCap;
-        pseudoTags = new ArrayList<>();
-    }
-
-    /**
-     * Getter for the max. capacity
-     *
-     * @return the capacity
-     */
-    public float getCapacity() {
-        return maxCapacity;
-    }
-
-    /**
-     * Setter for the max. capacity
-     *
-     * @param cap the Capacity to set
-     */
-    public void setCapacity(float cap) {
-        this.maxCapacity = cap;
-    }
-
-
-
-
-
-    /**
-     * Getter for the Source.
-     *
-     * @return the a
-     */
-    public AbstractCanvasObject getA() {
-        return a;
-    }
-
-    /**
-     * Set the Source to a new one.
-     *
-     * @param a the a to set
-     */
-    public void setA(AbstractCanvasObject a) {
-        this.a = a;
-    }
-
-    /**
-     * Getter for the destination.
-     *
-     * @return the b
-     */
-    public AbstractCanvasObject getB() {
-        return b;
-    }
-
-    /**
-     * Set the Destination to a new one.
-     *
-     * @param b the b to set
-     */
-    public void setB(AbstractCanvasObject b) {
-        this.b = b;
-    }
-
-
-
-
-
-    /**
-     * Getter for the ArrayList of tags.
-     *
-     * @return tags tags for this edge
-     */
-    public ArrayList<Integer> getTags() {
-        return tags;
-    }
-
-    /**
-     * set the tags into a new set of tags.
-     *
-     * @param tags tags for this edge
-     */
-    public void setTags(ArrayList<Integer> tags) {
-        this.tags = tags;
-    }
-
-    /**
-     * Add a new tag to the ArrayList.
-     *
-     * @param tag tag for the ArrayList
-     */
-    public void addTag(int tag) {
-        if (!tags.contains(tag)) {
-            tags.add(tag);
-        }
-    }
-
-    /**
-     * checks whether list contains all given tags
-     *
-     * @param toCheck tags that are checked
-     * @param list    list to be checked
-     * @return true if all tags in toCheck are contained in list, false otherwise
-     */
-    public boolean containsTags(ArrayList<Integer> list, ArrayList<Integer> toCheck) {
-        if (toCheck.size() == 0) {
-            return true;
-        } else {
-            for (Integer i : toCheck) {
-                if (!(list.contains(i))) {
-                    return false;
-                }
-            }
-            return true;
-        }
-    }
-
-    public void addPseudoTag(int tag) {
-        if (!pseudoTags.contains(tag)) {
-            pseudoTags.add(tag);
-        }
-    }
-
-    public void setPseudoTag(ArrayList<Integer> list) {
-        pseudoTags = list;
-    }
-
-    public ArrayList<Integer> getPseudoTags() {
-        return pseudoTags;
-    }
-
-    public void recalculateTags() {
-        for (Integer i : pseudoTags) {
-            if (!tags.contains(i)) {
-                tags.add(i);
-            }
-        }
-    }
-
-
-    
-    /**
-     * Check if a CpsEdge is Connected to the AbstractCpsObject.
-     * @param holonObject the AbstractCpsObject to check.
-     * @return true if either a or b is the AbstractCpsObject to check.
-     */
-    public boolean isConnectedTo(AbstractCanvasObject holonObject)
-    {
-    	return (holonObject.equals(a) || holonObject.equals(b));
-    }
-    @Override
-    public String toString(){
-    	String A = (a == null) ? "null" : a.getName() + "[" + a.getId()+ "]";
-    	String B = (b == null) ? "null" : b.getName() + "[" + b.getId()+ "]";
-    	return "CpsEdge: " + A + " to " + B;
-    }
-
-	public boolean isBreakedManuel() {
-		return breakedManuel;
-	}
-
-	public void setBreakedManuel(boolean breakedManuel) {
-		this.breakedManuel = breakedManuel;
-	}
-
-	public boolean isUnlimitedCapacity() {
-		return unlimitedCapacity;
-	}
-
-	public void setUnlimitedCapacity(boolean unlimitedCapacity) {
-		this.unlimitedCapacity = unlimitedCapacity;
-	}
-
-}

+ 0 - 291
src/classes/HolonObject.java

@@ -1,291 +0,0 @@
-package classes;
-
-
-import ui.controller.FlexManager;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-
-/**
- * The class HolonObject represents any Object on the system which capability of
- * injecting or consuming energy on the network, for instance a house or a power
- * plant.
- *
- * @author Gruppe14
- */
-public class HolonObject extends AbstractCanvasObject { 
-    /* Array of all consumers */
-    private List<HolonElement> elements = new ArrayList<HolonElement>();
-    
-    /**
-     * Constructor Set by default the name of the object equals to the category
-     * name, until the user changes it.
-     *
-     * @param objName name of the Object
-     */
-    public HolonObject(String objName) {
-        super(objName);
-    }
-
-    /**
-     * Contructor of a copy of an Object.
-     *
-     * @param obj object to be copied
-     */
-    public HolonObject(HolonObject obj) {
-        super(obj);
-        for(HolonElement ele : obj.getElements()) {
-        	this.addElement(new HolonElement(ele));
-        }
-    }
-
- 
-
-    /**
-     * Getter for all Elements in the HolonObject.
-     *
-     * @return the elements ArrayList
-     */
-    public List<HolonElement> getElements() {
-        return elements;
-    }
-
-
-    /**
-     * adds an Element to the Object.
-     *
-     * @param element the Element to add
-     */
-    public void addElement(HolonElement element) {
-        elements.add(element);
-        element.parentObject = this;
-    }
-    
-    /**
-     * remove an Element to the Object.
-     *
-     * @param element the Element to add
-     */
-    public void removeElement(HolonElement element) {
-        elements.remove(element);
-        element.parentObject = null;
-    }
-
-    public void removeElement(int index) {
-    	HolonElement ele = elements.remove(index);
-    	ele.parentObject = null;
-	}
-
-    
-
-
-
-    /**
-     * String of all consumers in this HolonObject.
-     *
-     * @return all the names of this HolonObject separated by "," each object
-     */
-    public String toStringElements() {
-        String objString = "Empty";
-        for (HolonElement e : elements) {
-            if (objString == "Empty") {
-                objString = e.getName();
-            } else {
-                objString = objString + ", " + e.getName();
-            }
-        }
-        return objString;
-    }
-
-
-
-
-    /**
-     * Search for the first element with the name.
-     *
-     * @param name name of the object to be searched
-     * @return the searched HolonElement
-     */
-    public HolonElement searchElement(String name) {
-        HolonElement ele = null;
-        for (HolonElement e : getElements()) {
-            if (e.getName().equals(name)) {
-                ele = e;
-                break;
-            }
-        }
-        return ele;
-    }
-
-    /**
-     * Search for the element with the id.
-     *
-     * @param id id of the element to be founded
-     * @return the element
-     */
-    public HolonElement searchElementById(int id) {
-        HolonElement ele = null;
-        for (HolonElement e : getElements()) {
-            if (e.getId() == id) {
-                ele = e;
-                break;
-            }
-        }
-        return ele;
-    }
-
-  
-    
-    
-    //New Methods:
-    /**
-     * This Method returns the smallest consuming HolonElement that is ACTIVE.
-     * If the HolonObject has no Consumer its return null. 
-     * @param timestep is the TimeStep to compare the HolonElements.
-     * @return The smallest consuming HolonElement or null.
-     */
-    public HolonElement getMinimumConsumingElement(int timestep){
-    	return getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) < 0) ).max((lhs,rhs) -> Float.compare(lhs.getEnergyAtTimeStep(timestep), rhs.getEnergyAtTimeStep(timestep))).orElse(null);
-    }
-    /**
-     * This Method returns the smallest consuming HolonElement'Energy that is ACTIVE.
-     * If the HolonObject has no Consumer its return 0. 
-     * @param timestep is the TimeStep to compare the HolonElements.
-     * @return The smallest consuming HolonElement or 0.
-     */
-    public float getMinimumConsumingElementEnergy(int timestep){
-    	return getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) < 0) ).map(element -> -element.getEnergyAtTimeStep(timestep)).min((lhs,rhs) ->Float.compare(lhs, rhs)).orElse(0.0f);
-    }
-    public float getMinimumConsumingElementEnergyWithFlex(int timestep, FlexManager flexManager){
-    	return getElements().stream().filter(element -> element.isOn(flexManager) && (element.getEnergyAtTimeStep(timestep) < 0) ).map(element -> -element.getEnergyAtTimeStep(timestep)).min((lhs,rhs) ->Float.compare(lhs, rhs)).orElse(0.0f);
-    }
-    /**
-     * This Method returns the biggest consuming HolonElement'Energy that is ACTIVE.
-     * If the HolonObject has no Consumer its return 0. 
-     * @param timestep is the TimeStep to compare the HolonElements.
-     * @return The biggest consuming HolonElement or 0.
-     */
-    public float getMaximumConsumingElementEnergy(int timestep){
-    	return getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) < 0) ).map(element -> -element.getEnergyAtTimeStep(timestep)).max((lhs,rhs) ->Float.compare(lhs, rhs)).orElse(0.0f);
-    }
-    /** 
-     * This Method returns the Energy of a HolonObject. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE.
-     * If the HolonObject have no HolonElement its return 0;
-     * Is the returned Energy negative then the HolonObject need Energy because its consuming HolonElements need more Energy then the producing HolonElements.
-     * Is the returned Energy positive its reversed.
-     * @param timestep is the TimeStep to compare the HolonElements.
-     * @return The Energy of the HolonObject.
-     */
-    public float getEnergyAtTimeStep(int timestep)
-    {
-    	return getElements().stream().filter(element -> element.isActive()).map(element -> element.getEnergyAtTimeStep(timestep)).reduce(0.0f, (a, b) -> a + b);
-    }
-    
-    public float getEnergyAtTimeStepWithFlex(int timestep, FlexManager flexManager)
-    {
-    	return getElements().stream().filter(element -> element.isOn(flexManager)).map(element -> element.getEnergyAtTimeStep(timestep)).reduce(0.0f, (a, b) -> a + b);
-    }
-    
-    
-    public float getMaximumProductionPossible(int timestep) {
-    	return elements.stream().filter(element -> element.getEnergyAtTimeStep(timestep) > 0).map(element -> element.getEnergyAtTimeStep(timestep)).reduce(0.0f, Float::sum);
-    }
-    public float getMaximumConsumptionPossible(int timestep) {
-    	return elements.stream().filter(element -> element.getEnergyAtTimeStep(timestep) < 0).map(element -> -element.getEnergyAtTimeStep(timestep)).reduce(0.0f, Float::sum);
-    }
-    
-    
-    
-    
-    
-    /** 
-     * This Method returns the Energy that all HolonElements from the HolonObject produce by itself. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE and are Producer.
-     * If the HolonObject have no HolonElement its return 0;
-     * @param timestep is the TimeStep to compare the HolonElements.
-     * @return The Energy of the producing HolonElements.
-     */
-    public float getEnergySelfProducingFromProducingElements(int timestep) {
-    	return getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) > 0)).map(element -> element.getEnergyAtTimeStep(timestep)).reduce(0.0f, (a, b) -> a + b);
-    }
-    public float getEnergySelfProducingFromProducingElementsWithFlex(int timestep, FlexManager flexManager) {
-    	return getElements().stream().filter(element -> element.isOn(flexManager) && (element.getEnergyAtTimeStep(timestep) > 0)).map(element -> element.getEnergyAtTimeStep(timestep)).reduce(0.0f, (a, b) -> a + b);
-    }
-    /** 
-     * This Method returns the Energy of all HolonElements from the HolonObject that are consuming. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE and are Consumer.
-     * If the HolonObject have no HolonElement its return 0;
-     * @param timestep is the TimeStep to compare the HolonElements.
-     * @return The Energy of the consuming HolonElements.
-     */
-    public float getEnergyNeededFromConsumingElements(int timestep) {
-    	return getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) < 0)).map(element -> -element.getEnergyAtTimeStep(timestep)).reduce(0.0f, (a, b) -> a + b);
-    }
-    public float getEnergyNeededFromConsumingElementsWithFlex(int timestep, FlexManager flexManager) {
-    	return getElements().stream().filter(element -> element.isOn(flexManager) && (element.getEnergyAtTimeStep(timestep) < 0)).map(element -> -element.getEnergyAtTimeStep(timestep)).reduce(0.0f, (a, b) -> a + b);
-    }
-    /**
-     * This Method calculate the amount of HolonElements that are consuming Energy and are ACTIVE.
-     * @param timestep is the TimeStep to compare the HolonElements.
-     * @return The amount of HolonElements that are consuming Energy.
-     */
-    public int countConsumingElements(int timestep) {
-    	return (int) getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) < 0)).count();
-    }
-    /**
-     * This Method calculate the amount of HolonElements that are producing Energy and are ACTIVE.
-     * @param timestep is the TimeStep to compare the HolonElements.
-     * @return The amount of HolonElements that are producing Energy.
-     */
-    public int countProducingElements(int timestep) {
-    	return (int) getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) > 0)).count();
-    }
-    
-
-
-
-
-
-
-
-   
-
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-
-        sb.append("[HolonObject: ");
-        sb.append("id=").append(id)
-                .append(", name=").append(name)
-                .append(", state=");
-        sb.append(", elements=[");
-        for (int i = 0; i < getElements().size(); i++) {
-            HolonElement el = getElements().get(i);
-            if (i != 0) {
-                sb.append(", ");
-            }
-            sb.append(el.getName());
-        }
-        sb.append("]]");
-
-        return sb.toString();
-    }
-    
-
-	public int getNumberOfActiveElements() {
-		return (int) elements.stream().filter(ele -> ele.isActive()).count();
-	}
-	
-	public int getNumberOfInActiveElements() {
-		return (int) elements.stream().filter(ele -> !ele.isActive()).count();
-	}
-	
-	public int getNumberOfElements() {
-		return elements.size();
-	}
-
-	public void setElements(List<HolonElement> list) {
-		this.elements = list;
-	}
-
-	
-}

+ 0 - 51
src/classes/Pair.java

@@ -1,51 +0,0 @@
-package classes;
-
-import java.io.Serializable;
-
-public class Pair<K, V> implements Serializable {
-	private static final long serialVersionUID = 111222333444555666L;
-	
-	
-	private K key;
-	private V value;
-
-	public Pair(K key, V value) {
-		this.key = key;
-		this.value = value;
-	}
-
-	public K getKey() {
-		return key;
-	}
-
-	public V getValue() {
-		return value;
-	}
-
-	@Override
-	public String toString() {
-		return key + "=" + value;
-	}
-
-	@Override
-	public int hashCode() {
-		return key.hashCode() * 13 + (value == null ? 0 : value.hashCode());
-	}
-
-	@Override
-	public boolean equals(Object o) {
-		if (this == o) {
-			return true;			
-		}
-		
-		if (o instanceof Pair) {
-			Pair<?, ?> pair = (Pair<?, ?>) o;
-			if (key != null ? !key.equals(pair.key) : pair.key != null)
-				return false;
-			if (value != null ? !value.equals(pair.value) : pair.value != null)
-				return false;
-			return true;
-		}
-		return false;
-	}
-}

+ 0 - 41
src/classes/comparator/EnergyMinToMaxComparator.java

@@ -1,41 +0,0 @@
-package classes.comparator;
-
-import java.util.Comparator;
-
-import classes.HolonObject;
-
-/**
- * Comparator of the Energy Difference between Total Energy Consumption and Min Consumption
- * of a Holon Objects.
- *
- * @author Andreas T. Meyer-Berg
- */
-public class EnergyMinToMaxComparator implements Comparator<HolonObject> {
-
-	private int timeStep = 0;
-	
-	/**
-	 * Comparator for the totalEnergy of HolonObjects
-	 * @param timeStep
-	 */
-	public EnergyMinToMaxComparator(int timeStep) {
-		this.timeStep = timeStep;
-	}
-
-	@Override
-	public int compare(HolonObject o1, HolonObject o2) {
-		float minEnergy1 = o1.getMinimumConsumingElementEnergy(timeStep);
-		float minEnergy2 = o2.getMinimumConsumingElementEnergy(timeStep);
-		float totalEnergy1 = o1.getEnergyAtTimeStep(timeStep);
-		float totalEnergy2 = o2.getEnergyAtTimeStep(timeStep);
-		float difference1 = totalEnergy1 - minEnergy1;
-		float difference2 = totalEnergy2 - minEnergy2;
-		if(difference1 < difference2)
-			return 1;
-		else if (difference1 == difference2) 
-			return 0;
-		else
-			return -1;
-	}
-
-}

+ 0 - 36
src/classes/comparator/MinEnergyComparator.java

@@ -1,36 +0,0 @@
-package classes.comparator;
-
-import java.util.Comparator;
-
-import classes.HolonObject;
-
-/**
- * Comparator for Min Consumption of Holon Objects.
- *
- * @author Andreas T. Meyer-Berg
- */
-public class MinEnergyComparator implements Comparator<HolonObject> {
-
-	private int timeStep = 0;
-	
-	/**
-	 * Comparator for the minEnergy of HolonObjects
-	 * @param timeStep
-	 */
-	public MinEnergyComparator(int timeStep) {
-		this.timeStep = timeStep;
-	}
-
-	@Override
-	public int compare(HolonObject o1, HolonObject o2) {
-		float minEnergy1 = o1.getMinimumConsumingElementEnergy(timeStep);
-		float minEnergy2 = o2.getMinimumConsumingElementEnergy(timeStep);
-		if(minEnergy1<minEnergy2)
-			return 1;
-		else if (minEnergy1 == minEnergy2) 
-			return 0;
-		else
-			return -1;
-	}
-
-}

+ 0 - 36
src/classes/comparator/TotalEnergyComparator.java

@@ -1,36 +0,0 @@
-package classes.comparator;
-
-import java.util.Comparator;
-
-import classes.HolonObject;
-
-/**
- * Comparator for the totalEnergy of HolonObjects
- *
- * @author Andreas T. Meyer-Berg
- */
-public class TotalEnergyComparator implements Comparator<HolonObject> {
-
-	private int timeStep = 0;
-	
-	/**
-	 * Comparator for the totalEnergy of HolonObjects
-	 * @param timeStep
-	 */
-	public TotalEnergyComparator(int timeStep) {
-		this.timeStep = timeStep;
-	}
-
-	@Override
-	public int compare(HolonObject o1, HolonObject o2) {
-		float totalEnergy1 = o1.getEnergyAtTimeStep(timeStep);
-		float totalEnergy2 = o2.getEnergyAtTimeStep(timeStep);
-		if(totalEnergy1<totalEnergy2)
-			return -1;
-		else if (totalEnergy1 == totalEnergy2) 
-			return 0;
-		else
-			return 1;
-	}
-
-}

+ 0 - 15
src/classes/comparator/UnitGraphPointComperator.java

@@ -1,15 +0,0 @@
-package classes.comparator;
-
-import java.util.Comparator;
-
-import ui.view.inspector.UnitGraphPoint;
-
-
-public class UnitGraphPointComperator implements Comparator<UnitGraphPoint>{
-
-	@Override
-	public int compare(UnitGraphPoint o1, UnitGraphPoint o2) {
-		return o1.displayedPosition.getX() - o2.displayedPosition.getX();
-	}
-
-}

+ 0 - 17
src/classes/comparator/elementComparator/ElemCompOnEleName.java

@@ -1,17 +0,0 @@
-package classes.comparator.elementComparator;
-
-import classes.HolonElement;
-
-public class ElemCompOnEleName extends ElementComparator {
-
-	@Override
-	public int compare(HolonElement a, HolonElement b) {
-
-		String eleNameA = a.getName();
-		String eleNameB = b.getName();
-
-		return eleNameA.compareTo(eleNameB);
-
-	}
-
-}

+ 0 - 25
src/classes/comparator/elementComparator/ElemCompOnEnergy.java

@@ -1,25 +0,0 @@
-package classes.comparator.elementComparator;
-
-import classes.HolonElement;
-
-/**
- * @author Toni
- * Bei dieser Implementierung wird nach 
- * Energieverbrauch pro HolonElement sortiert
- */
-public class ElemCompOnEnergy extends ElementComparator {
-
-	@Override
-	public int compare(HolonElement a, HolonElement b) {
-
-		float verbrauchA = a.getEnergy();
-		float verbrauchB = b.getEnergy();
-		if (verbrauchA < verbrauchB)
-			return -1;
-		if (verbrauchA > verbrauchB)
-			return 1;
-		return 0;
-
-	}
-
-}

+ 0 - 27
src/classes/comparator/elementComparator/ElemCompOnId.java

@@ -1,27 +0,0 @@
-/**
- * 
- */
-package classes.comparator.elementComparator;
-
-import classes.HolonElement;
-
-/**
- * @author Toni
- *Comparator zum sortieren nach HolonElementId
- */
-public class ElemCompOnId extends ElementComparator {
-
-	@Override
-	public int compare(HolonElement a, HolonElement b) {
-
-		float idA = a.getId();
-		float idB = b.getId();
-		if (idA < idB)
-			return -1;
-		if (idA > idB)
-			return 1;
-		return 0;
-
-	}
-
-}

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

@@ -1,20 +0,0 @@
-package classes.comparator.elementComparator;
-
-import classes.HolonElement;
-
-public class ElemCompOnIsActivated  extends ElementComparator {
-	
-	@Override
-	public int compare(HolonElement a, HolonElement b) {
-
-		boolean ifA = a.isActive();
-		boolean ifB = b.isActive();
-		if (ifA&&!ifB)
-			return -1;
-		if (!ifA && ifB)
-			return 1;
-		return 0;
-
-	}
-
-}

+ 0 - 17
src/classes/comparator/elementComparator/ElementComparator.java

@@ -1,17 +0,0 @@
-package classes.comparator.elementComparator;
-
-import java.util.Comparator;
-
-import classes.HolonElement;
-
-/**
- * @author Toni
- *Eine abstrakte Klasse um bei HolonObjekten den Comparator 
- *der die HolonElemente sortiert welchseln zu können
- */
-public abstract class ElementComparator implements Comparator<HolonElement> {
-	
-	public abstract int compare(HolonElement a, HolonElement b);
-	
-}
-	

+ 5 - 5
src/Connection/ConnectHandheld.java → src/connect/ConnectHandheld.java

@@ -1,4 +1,4 @@
-package Connection;
+package connect;
 
 import java.awt.BorderLayout;
 import java.awt.Dimension;
@@ -21,11 +21,11 @@ import javax.swing.JSplitPane;
 import javax.swing.JTextArea;
 import javax.swing.text.NumberFormatter;
 
+import model.AbstractCanvasObject;
+import model.GroupNode;
+import model.HolonObject;
 import api.AddOn;
-import classes.AbstractCanvasObject;
-import classes.GroupNode;
-import classes.HolonObject;
-import Connection.socket.Server;
+import connect.socket.Server;
 import ui.controller.Control;
 import ui.view.component.Console;
 

+ 7 - 7
src/Connection/ConnectPhysical.java → src/connect/ConnectPhysical.java

@@ -1,4 +1,4 @@
-package Connection;
+package connect;
 import java.awt.BorderLayout;
 import java.awt.Component;
 import java.awt.Dimension;
@@ -31,10 +31,10 @@ import javax.swing.JSplitPane;
 import javax.swing.text.NumberFormatter;
 
 import api.AddOn;
-import classes.AbstractCanvasObject;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.HolonObject;
+import model.AbstractCanvasObject;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
 import ui.controller.Control;
 import ui.view.component.Console;
 /**
@@ -426,7 +426,7 @@ public class ConnectPhysical implements AddOn{
 						}
 					}
 					else{
-						int value = Math.round(((float)elementsOfRoom1.stream().filter(ele -> ele.isActive()).count()/(float) elementsOfRoom1.size())*(float) 100);					
+						int value = Math.round(((float)elementsOfRoom1.stream().filter(ele -> ele.active).count()/(float) elementsOfRoom1.size())*(float) 100);					
 						if(onlyOnChange) {
 							if(oldValueRoom1 != value) {
 								sendRequest(room1Address, value);
@@ -447,7 +447,7 @@ public class ConnectPhysical implements AddOn{
 						}
 					}
 					else{
-						int value = Math.round(((float)elementsOfRoom2.stream().filter(ele -> ele.isActive()).count()/(float) elementsOfRoom2.size())*(float) 100);					
+						int value = Math.round(((float)elementsOfRoom2.stream().filter(ele -> ele.active).count()/(float) elementsOfRoom2.size())*(float) 100);					
 						if(onlyOnChange) {
 							if(oldValueRoom2 != value) {
 								sendRequest(room2Address, value);

+ 10 - 10
src/Connection/socket/Server.java → src/connect/socket/Server.java

@@ -1,11 +1,11 @@
-package Connection.socket;
+package connect.socket;
 import java.net.*;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
 
-import classes.HolonElement;
-import classes.HolonObject;
+import model.HolonElement;
+import model.HolonObject;
 import ui.controller.Control;
 
 import java.io.*;
@@ -96,7 +96,7 @@ public class Server implements Runnable{
 			if (inputByte == Command.SetAmount) {
 				if(observed == null) stopConnection();
 				console.println("Res: [" + inputByte + "] -> SetAmount");
-				int index = in.readInt();
+//				int index = in.readInt();
 				//int amount = in.readInt();
 				//modelField.getElements().get(index).amount = amount;
 				//observed.getElements().get(index).setAmount(amount);
@@ -107,21 +107,21 @@ public class Server implements Runnable{
 				int index = in.readInt();
 				boolean enabled = in.readBoolean();
 				modelField.getElements().get(index).enabled = enabled;
-				observed.getElements().get(index).setActive(enabled);
+				observed.getElements().get(index).active = enabled;
 			}else if (inputByte == Command.IncreaseAmount) {
 				if(observed == null) stopConnection();
 				console.println("Res: [" + inputByte + "] -> IncreaseAmount");
-				int index = in.readInt();
+				// int index = in.readInt();
 				//modelField.getElements().get(index).amount++;
-				HolonElement ele = observed.getElements().get(index);
+				//HolonElement ele = observed.getElements().get(index);
 				//ele.setAmount(ele.getAmount()+1);
 				
 			}else if (inputByte == Command.DecreaseAmount) {
 				if(observed == null) stopConnection();
 				console.println("Res: [" + inputByte + "] -> DecreaseAmount");
-				int index = in.readInt();
+				//int index = in.readInt();
 				//modelField.getElements().get(index).amount--;
-				HolonElement ele = observed.getElements().get(index);
+//				HolonElement ele = observed.getElements().get(index);
 				//ele.setAmount(ele.getAmount()-1);
 				
 			} else{
@@ -248,7 +248,7 @@ public class Server implements Runnable{
 			String name = ele.getName();
 			//int amount =ele.getAmount();
 			float energy =  ele.getEnergy();
-			boolean enabled = ele.isActive();
+			boolean enabled = ele.active;
 			elements.add(new HolonElementWrapper(name, energy, enabled, index));
 		}
 		

+ 3 - 2
src/interfaces/GraphEditable.java

@@ -1,8 +1,9 @@
 package interfaces;
 
-import java.awt.geom.Point2D;
 import java.util.LinkedList;
 
+import utility.Vector2Float;
+
 /**
  * Interface for all Elements that have a Graph to edit it state over time.
  * @author Tom Troppmann
@@ -27,7 +28,7 @@ public interface GraphEditable {
 	 * Getter for the graph.
 	 * @return The list of all graph points.
 	 */
-	LinkedList<Point2D.Double> getStateGraph();
+	LinkedList<Vector2Float> getStateGraph();
 	
 	/**
 	 * Sample the Graph on the object.

+ 0 - 18
src/interfaces/ObjectListener.java

@@ -1,18 +0,0 @@
-package interfaces;
-
-import java.util.ArrayList;
-
-/**
- * Intercae for ObjectListener.
- * 
- * @author Gruppe14
- */
-public interface ObjectListener {
-	/**
-	 * Constructor.
-	 * 
-	 * @param objects
-	 *            AbstractCpsObject
-	 */
-	public void onChange(ArrayList<classes.AbstractCanvasObject> objects);
-}

+ 18 - 32
src/classes/AbstractCanvasObject.java → src/model/AbstractCanvasObject.java

@@ -1,13 +1,12 @@
-package classes;
+package model;
 
 import com.google.gson.annotations.Expose;
 
-import classes.IdCounter.CounterType;
+import ui.model.IdCounter;
+import ui.model.IdCounter.CounterType;
 import utility.Vector2Int;
 
 import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
 
 /**
  * The abstract class "CpsObject" represents any possible object in the system
@@ -26,19 +25,17 @@ public abstract class AbstractCanvasObject {
 	String name;
 	/* ID of the Obj. */
 	@Expose
-	int id;
+	private int id;
 	/* Path of the image for the Obj. */
 	@Expose
 	String image;
 	/* Array of neighbors */
-	ArrayList<Edge> connections = new ArrayList<>();
+	private ArrayList<Edge> connections = new ArrayList<>();
 	/* Position with a X and Y value */
 	@Expose
 	Vector2Int position = new Vector2Int(0,0);
 	@Expose
 	String sav;
-	/* tags that can be used */
-	public Set<Integer> tags = new HashSet<Integer>();
 
 	/**
 	 * Constructor for a CpsObejct with an unique ID.
@@ -48,7 +45,7 @@ public abstract class AbstractCanvasObject {
 	 */
 	public AbstractCanvasObject(String objName) {
 		setName(objName);
-		setImage("/Images/Dummy_House.png");
+		this.id = IdCounter.nextId(CounterType.Object);
 	}
 
 	/**
@@ -61,12 +58,17 @@ public abstract class AbstractCanvasObject {
 	 */
 	public AbstractCanvasObject(AbstractCanvasObject obj) {
 		setName(obj.getName());
-		setConnections(new ArrayList<>());
-		setId(IdCounter.nextId(CounterType.Object));
 		setImage(obj.getImage());
+		this.id = IdCounter.nextId(CounterType.Object);
+
 	}
 	
-
+	public void initForReflection() {
+		connections = new ArrayList<>();
+	}
+	
+	
+	
 
 	/**
 	 * Getter for the user-defined name (no unique).
@@ -87,25 +89,6 @@ public abstract class AbstractCanvasObject {
 		this.name = name;
 	}
 
-	/**
-	 * Getter of the unique ID.
-	 * 
-	 * @return int
-	 */
-	public int getId() {
-		return id;
-	}
-
-	/**
-	 * Set the ID to a new one.
-	 * 
-	 * @param id
-	 *            the iD to set
-	 */
-	public void setId(int id) {
-		this.id = id;
-	}
-
 	/**
 	 * Get the path of the image for the selected Object.
 	 * 
@@ -125,7 +108,9 @@ public abstract class AbstractCanvasObject {
 		this.image = image;
 	}
 
-	
+	public int getId() {
+		return id;
+	}
 	
 	
 	/**
@@ -211,6 +196,7 @@ public abstract class AbstractCanvasObject {
 	 * @param sav
 	 *            the stored to set
 	 */
+	//TODO(Tom2021-12-1): Remove SAV
 	public void setSav(String sav) {
 		this.sav = sav;
 	}

+ 3 - 3
src/classes/Constrain.java → src/model/Constrain.java

@@ -1,4 +1,4 @@
-package classes;
+package model;
 
 import java.util.function.Predicate;
 
@@ -24,9 +24,9 @@ public class Constrain {
 	
 	//Example Constrains:
 	/** Flexibility should be offered when Element is active.*/
-	public static Predicate<Flexibility> onConstrain = f 	-> 	f.getElement().isActive();
+	public static Predicate<Flexibility> onConstrain = f 	-> 	f.getElement().active;
 	/** Flexibility should be offered when Element is inactive.*/
-	public static Predicate<Flexibility> offConstrain = f	-> 	!f.getElement().isActive();
+	public static Predicate<Flexibility> offConstrain = f	-> 	!f.getElement().active;
 	
 	public static Constrain createOnConstrain() {
 		return new Constrain( onConstrain, "onConstrain");

+ 141 - 0
src/model/Edge.java

@@ -0,0 +1,141 @@
+package model;
+
+import com.google.gson.annotations.Expose;
+
+/**
+ * The class "CpsEdge" represents the connections on the GUI. Each connection
+ * contains a max. capacity, a flow, a status (isWorking), tags (for internal
+ * use of electricity flow), source and destination
+ *
+ * @author Gruppe14
+ */
+public class Edge {
+
+    // Max. capacity of the Edge, if flow is greater than the status --> is
+    // Working would be false
+    @Expose
+    public float maxCapacity;
+    // Source
+    AbstractCanvasObject a;
+    // Destination
+    AbstractCanvasObject b;
+    @Expose
+    private boolean breakedManuel = false;
+    @Expose
+    private boolean unlimitedCapacity = false;
+    
+    
+    
+    
+    
+    /**
+     * Getter for the length of the Cable.
+     * Always calculate never saved.
+     * Needs to be profiled whats better.
+     * @return
+     */
+    public float getLength() {
+    	return a.getPosition().getDistance(b.getPosition());
+    }
+
+
+    /**
+     * Constructor with a user-defined max. capacity
+     *
+     * @param a      Source
+     * @param b      Destination
+     * @param maxCap Maximum Capacity
+     */
+    public Edge(AbstractCanvasObject a, AbstractCanvasObject b, float maxCap) {
+        setA(a);
+        setB(b);
+        this.maxCapacity = maxCap;
+    }
+
+    
+    /**
+     * Copy Constructor
+     *
+     * @param a      Source
+     * @param b      Destination
+     * @param maxCap Maximum Capacity
+     */
+    public Edge(Edge other) {
+        setA(other.a);
+        setB(other.b);
+        this.maxCapacity = other.maxCapacity;
+        
+    }
+
+    /**
+     * Getter for the Source.
+     *
+     * @return the a
+     */
+    public AbstractCanvasObject getA() {
+        return a;
+    }
+
+    /**
+     * Set the Source to a new one.
+     *
+     * @param a the a to set
+     */
+    public void setA(AbstractCanvasObject a) {
+        this.a = a;
+    }
+
+    /**
+     * Getter for the destination.
+     *
+     * @return the b
+     */
+    public AbstractCanvasObject getB() {
+        return b;
+    }
+
+    /**
+     * Set the Destination to a new one.
+     *
+     * @param b the b to set
+     */
+    public void setB(AbstractCanvasObject b) {
+        this.b = b;
+    }
+
+
+
+    
+    /**
+     * Check if a CpsEdge is Connected to the AbstractCpsObject.
+     * @param holonObject the AbstractCpsObject to check.
+     * @return true if either a or b is the AbstractCpsObject to check.
+     */
+    public boolean isConnectedTo(AbstractCanvasObject holonObject)
+    {
+    	return (holonObject.equals(a) || holonObject.equals(b));
+    }
+    @Override
+    public String toString(){
+    	String A = (a == null) ? "null" : a.getName() + "[" + a.getId()+ "]";
+    	String B = (b == null) ? "null" : b.getName() + "[" + b.getId()+ "]";
+    	return "CpsEdge: " + A + " to " + B;
+    }
+
+	public boolean isBreakedManuel() {
+		return breakedManuel;
+	}
+
+	public void setBreakedManuel(boolean breakedManuel) {
+		this.breakedManuel = breakedManuel;
+	}
+
+	public boolean isUnlimitedCapacity() {
+		return unlimitedCapacity;
+	}
+
+	public void setUnlimitedCapacity(boolean unlimitedCapacity) {
+		this.unlimitedCapacity = unlimitedCapacity;
+	}
+
+}

+ 89 - 13
src/classes/Flexibility.java → src/model/Flexibility.java

@@ -1,15 +1,21 @@
-package classes;
+package model;
 
 import java.util.ArrayList;
 import java.util.List;
 import java.util.function.Predicate;
 
 import com.google.gson.annotations.Expose;
+
 /**
  * Representative of a flexibility for a HolonElement.
  *
  */
 public class Flexibility {
+	/*
+	 *  MODEL
+	 */
+	/** The owner of the Flexibility.*/
+	private HolonElement element;
 	/** The Name of a Flexibility.*/
 	@Expose
 	public String name;
@@ -29,7 +35,6 @@ public class Flexibility {
 	@Expose
 	private int cooldown;
 	/** The Element this flexibility is assigned.*/
-	private HolonElement element;
 
 
 
@@ -50,15 +55,10 @@ public class Flexibility {
 		setCooldown(cooldown);
 		this.offered=offered;
 		this.element = element;
-		constrainList = new ArrayList<Constrain>();		
+		constrainList = new ArrayList<Constrain>();	
 	}
 	
 	
-	/** Checks if all assigned constrains are fulfilled. When no constrains assigned returns true.*/
-	public boolean fulfillsConstrains() {
-		//System.out.println("Fix me when other is fixed");
-		return constrainList.stream().map(constrain -> constrain.getConstrainFunction()).reduce(Predicate::and).orElse(f -> true).test(this);
-	}
 	
 	public HolonElement getElement() {
 		return element;
@@ -88,15 +88,14 @@ public class Flexibility {
 		return ((float)duration) *  element.getEnergy();
 	}
 	
-	public float bringtmir(){
-		//System.out.println("Name:" +  element.getEleName() + "   BringtMir:" + (-element.getEnergyPerElement() * element.getAmount()));
+	public float energyReleased(){
 		return (constrainList.stream().map(constrain -> constrain.getName()).anyMatch(name -> name.equals("onConstrain"))?-1.0f:1.0f) * element.getEnergy();
 	}
 	public boolean isPositive() {
-		return bringtmir() >= 0;
+		return energyReleased() >= 0;
 	}
 	public boolean isNegative() {
-		return bringtmir() < 0;
+		return energyReleased() < 0;
 	}
 	
 	
@@ -109,14 +108,91 @@ public class Flexibility {
 	}
 	@Override
 	public String toString() {
-		return "Flexibility: " + name + " from [HolonElement: " + element.getName() + " ID:" + element.getId()+"]";
+		return "Flexibility: " + name + " from [HolonElement: " + element.getName() + " ID:" + element.getId() +"]";
 	}
 
 	
+	public static enum FlexState{
+		IN_USE, ON_COOLDOWN, OFFERED, NOT_OFFERED, UNAVAILABLE
+	}		
 	
 
+	/*
+	 *  STATE
+	 */
+	private FlexState state = FlexState.OFFERED;
+	private int timestep;
+	private int activationTime = -1;
+	private int durationEndTime = -1;
+	private int coolDownEndTime = -1;
+
+	//TODO(Tom2021-12-1) public -> package 
+	public void calculateState(int timestep) {
+		this.timestep = timestep;
+		state = revalidateState();
+	}
+	//TODO(Tom2021-12-1) public -> package 
+	public boolean order() {
+		if(canOrder()) {
+			state = FlexState.IN_USE;
+			durationEndTime = timestep + this.getDuration();
+			coolDownEndTime = durationEndTime + this.getCooldown();
+			activationTime = timestep;
+			return true;
+		}
+		return false;
+	}
+	//TODO(Tom2021-12-1) public -> package 
+	public boolean cancel() {
+		if(activationTime == timestep) {
+			state=FlexState.OFFERED;
+			durationEndTime = -1;
+			coolDownEndTime = -1;
+			return true;
+		}
+		return false;
+	}	
+	public boolean canActivate() {
+		return remainingTimeTillActivation() == 0;
+	}
 	
+	public boolean canOrder() {
+		boolean flexIsOffered = state.equals(FlexState.OFFERED);
+		return  flexIsOffered && !element.isFlexActive() ;
+	}
+	public FlexState getState() {
+		return state;
+	}
 	
+	public int remainingTimeTillActivation() {
+		return Math.max(0, coolDownEndTime - timestep);
+	}
+	public int remainingDuration() {
+		return Math.max(0, durationEndTime - timestep);
+	}
 	
+	/** Checks if all assigned constrains are fulfilled. When no constrains assigned returns true.*/
+	private boolean fulfillsConstrains() {
+		return constrainList.stream().map(constrain -> constrain.getConstrainFunction()).reduce(Predicate::and).orElse(f -> true).test(this);
+	}
+	
+	private FlexState revalidateState() {
+		if(canActivate()) {
+			if (!this.fulfillsConstrains() || element.isFlexActive()) {
+				return FlexState.UNAVAILABLE;
+			}else if (this.offered){
+				return FlexState.OFFERED;
+			}
+			return FlexState.NOT_OFFERED;
+		}
+		else if(remainingDuration()== 0) {
+			return FlexState.ON_COOLDOWN;
+		}
+		else {
+			return FlexState.IN_USE;
+		}
+	}
+	
+
 	
 }

+ 13 - 9
src/classes/GroupNode.java → src/model/GroupNode.java

@@ -1,16 +1,14 @@
-package classes;
+package model;
 
 import com.google.gson.annotations.Expose;
 
-import classes.IdCounter.CounterType;
-
 import java.util.ArrayList;
 import java.util.HashMap;
 
 public class GroupNode extends AbstractCanvasObject {
 
-	private ArrayList<AbstractCanvasObject> nodes;
-	private HashMap<Integer, Integer> nodesIdx;
+	private ArrayList<AbstractCanvasObject> nodes = new ArrayList<>();
+	private HashMap<Integer, Integer> nodesIdx = new HashMap<>();
 	
 	@Expose
 	private String imgPath = "";
@@ -23,14 +21,20 @@ public class GroupNode extends AbstractCanvasObject {
 
 	public GroupNode(String nodeName) {
 		super(nodeName);
-		this.setConnections(new ArrayList<>());
 		this.setImage("/Images/upper_node.png");
 		this.setSav("CVS");
-		this.setId(IdCounter.nextId(CounterType.Object));
-		this.setNodes(new ArrayList<>());
-		this.setNodesIdx(new HashMap<>());
 	}
 
+	@Override
+	public void initForReflection() {
+		super.initForReflection();
+		nodes = new ArrayList<>();
+        nodesIdx = new HashMap<>();
+	}
+	
+	
+	
+	
 	/**
 	 * @return the nodes
 	 */

+ 109 - 117
src/classes/HolonElement.java → src/model/HolonElement.java

@@ -1,20 +1,18 @@
-package classes;
+package model;
 
 import com.google.gson.annotations.Expose;
 import com.google.gson.annotations.SerializedName;
 
-import classes.IdCounter.CounterType;
 import interfaces.TimelineDependent;
-import ui.controller.FlexManager;
+import model.Flexibility.FlexState;
 import ui.controller.IndexTranslator;
-
-import java.awt.*;
-import java.awt.geom.Point2D;
-import java.awt.geom.Point2D.Double;
+import ui.model.IdCounter;
+import ui.model.IdCounter.CounterType;
+import utility.Vector2Float;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.ListIterator;
-
+import java.util.AbstractMap.SimpleEntry;
 /**
  * The class "HolonElement" represents any possible element that can be added to
  * a CpsObject (such as TV (consumer) or any energyPerElement source/producer).
@@ -23,40 +21,45 @@ import java.util.ListIterator;
  */
 public class HolonElement implements TimelineDependent{
 
+	/*
+	 * MODEL
+	 */
+	/** Owner of the Element */
+	public HolonObject parentObject;
     /** Points of new TestGraph 
      * Represent the Graph 
      * the X component from a Point is period from 0..1
      * the Y component from a Point is the percentage from 0..1
      * */
-    private LinkedList<Point2D.Double> graphPoints;
+    private LinkedList<Vector2Float> graphPoints;
     /** Name of the gadget, e.g. TV */
     @Expose
-    private String eleName;
+    @SerializedName(value = "name", alternate = "eleName")
+    private String name;
     /** Amount of same elements */
     @Expose
     @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;
+    public boolean active;
     /** Gives us whether this element is flexible and can flexibly use any part of the energy in flexibleEnergyAvailable */
     
-    public HolonObject parentObject;
     
     
     
+    public enum Priority {
+    	Low, Medium, High, Essential
+    }
     
     @Expose
-    private Priority priority = Priority.Low;
+    public Priority priority = Priority.Low;
 
-	public enum Priority {
-    	Low, Medium, High, Essential
-    }
 
     
     /** Place where the Object is Stored */
     @Expose
-    private Pair<String, String> saving;
+    private SimpleEntry<String, String> saving;
     /** ID */
     @Expose
     private int id;
@@ -97,14 +100,13 @@ public class HolonElement implements TimelineDependent{
     public HolonElement(HolonObject parentObject, String eleName, float energy, int id){
     	this.parentObject = parentObject;
     	setUseLocalPeriod(false);
-    	setEleName(eleName);
-        setEnergyPerElement(energy);
-        setActive(true);
+    	setName(eleName);
+        setEnergy(energy);
+        this.active = true;
         setGraphPoints(new LinkedList<>());
         initGraphPoints();
         sampleGraph();
-        setId(id);
-        this.priority = Priority.Low;
+        this.id = id;
     }
 
     /**
@@ -117,22 +119,26 @@ public class HolonElement implements TimelineDependent{
     	this.priority = element.getPriority();
     	setLocalPeriod(element.getLocalPeriod());
     	setUseLocalPeriod(element.isUsingLocalPeriod());
-        setEleName(element.getName());
+        setName(element.getName());
         setLocalPeriod(element.getLocalPeriod());
-        setEnergyPerElement(element.getEnergy());
-        setActive(element.isActive());
+        setEnergy(element.getEnergy());
+        this.active = element.active;
         setGraphPoints(new LinkedList<>());
-        for (Point2D.Double p : element.getGraphPoints()) {
-            this.graphPoints.add(new Point2D.Double(p.getX(), p.getY()));
+        for (Vector2Float p : element.getGraphPoints()) {
+            this.graphPoints.add(new Vector2Float(p));
         }
         sampleGraph();
         setSaving(null);
-        setId(IdCounter.nextId(CounterType.Element));
-
+        this.id = IdCounter.nextId(CounterType.Element);
     }
 
 
 
+    
+    public int getId() {
+    	return id;
+    }
+    
 
     /**
      * Get the user-defined Name.
@@ -140,7 +146,7 @@ public class HolonElement implements TimelineDependent{
      * @return the name String
      */
     public String getName() {
-        return eleName;
+        return name;
     }
 
     /**
@@ -148,8 +154,8 @@ public class HolonElement implements TimelineDependent{
      *
      * @param name the name to set
      */
-    public void setEleName(String name) {
-        this.eleName = name;
+    public void setName(String name) {
+        this.name = name;
     }
 
 
@@ -161,15 +167,15 @@ public class HolonElement implements TimelineDependent{
     public float getEnergy() {
         return energy;
     }
-    public Priority getPriority() {
-    	return priority;
-    }
-    
-    
-    public void setPriority(Priority priority) {
-    	this.priority = priority;
-    }    
     
+    /**
+     * Set the energyPerElement value of the selected Element.
+     *
+     * @param energyPerElement the energyPerElement to set
+     */
+    public void setEnergy(float energyPerElement) {
+    	this.energy = energyPerElement;
+    }
     
     
     /**
@@ -189,80 +195,34 @@ public class HolonElement implements TimelineDependent{
     {
     	return (energy < 0);
     }
-
-    /**
-     * Set the energyPerElement value of the selected Element.
-     *
-     * @param energyPerElement the energyPerElement to set
-     */
-    public void setEnergyPerElement(float energyPerElement) {
-        this.energy = energyPerElement;
-    }
-
-    /**
-     * Get the Status of the Element (see description of variables).
-     *
-     * @return the active
-     */
-    public boolean isActive() {
-        return active;
-    }
-
-    public boolean isOn(FlexManager flexManager) {
-    	//return (flexManager.isAFlexInUseOfHolonElement(this))?!active:active; 
-    	//Bool logic XOR
-    	return flexManager.isAFlexInUseOfHolonElement(this) ^ active;
-    }
-    public boolean isFlexActive(FlexManager flexManager) {
-    	return flexManager.isAFlexInUseOfHolonElement(this);
-    }
     
-    /**
-     * Set the Status of the Element (see description of variables).
-     *
-     * @param active the active to set
-     */
-    public void setActive(boolean active) {
-        this.active = active;
-    }
-
-    /**
-     * Get the energyPerElement currently(at given time step) available
-     */
-    public float getEnergyAtTimeStep(int timestep) {
-    	return energy * this.curveSample[IndexTranslator.getEffectiveIndex(this, timestep)];
+    
+    
+    public Priority getPriority() {
+    	return priority;
     }
+    
+    
+    public void setPriority(Priority priority) {
+    	this.priority = priority;
+    }    
+    
 
 
-    /**
-     * Get the Id of the selected HolonElement.
-     *
-     * @return id the id
-     */
-    public int getId() {
-        return id;
-    }
+  
 
-    /**
-     * Set the ID of the HolonElement (one time only).
-     *
-     * @param id the id
-     */
-    public void setId(int id) {
-        this.id = id;
-    }
 
     /**
      * @return the saving
      */
-    public Pair<String, String> getSaving() {
+    public SimpleEntry<String, String> getSaving() {
         return saving;
     }
 
     /**
      * @param saving the saving to set
      */
-    public void setSaving(Pair<String, String> saving) {
+    public void setSaving(SimpleEntry<String, String> saving) {
         this.saving = saving;
     }
 
@@ -271,7 +231,7 @@ public class HolonElement implements TimelineDependent{
         StringBuilder sb = new StringBuilder();
         sb.append("[HolonElement: ");
         sb.append("id=").append(id)
-                .append(", eleName=").append(eleName)
+                .append(", eleName=").append(name)
                 .append(", parentName=").append(parentObject.getName())
                 .append(", active=").append(active)
                 .append(", energyPerElement used=").append(energy);
@@ -286,14 +246,14 @@ public class HolonElement implements TimelineDependent{
 	private void initGraphPoints()
 	{
 		graphPoints.clear();
-		graphPoints.add(new Point2D.Double(0,1.0));
-		graphPoints.add(new Point2D.Double(1,1.0));
+		graphPoints.add(new Vector2Float(0f,1.0f));
+		graphPoints.add(new Vector2Float(1f,1.0f));
 	}
 	/**
 	 * Getter for the graphPoint List.
 	 * @return {@link HolonElement#graphPoints}
 	 */
-	public LinkedList<Point2D.Double> getGraphPoints() {
+	public LinkedList<Vector2Float> getGraphPoints() {
 		return graphPoints;
 	}
 
@@ -301,8 +261,8 @@ public class HolonElement implements TimelineDependent{
 	 * Setter for the graphPoint List.
 	 * @param testGraphPoints is new  {@link HolonElement#graphPoints}
 	 */
-	public void setGraphPoints(LinkedList<Point2D.Double> testGraphPoints) {
-		this.graphPoints = testGraphPoints;
+	public void setGraphPoints(LinkedList<Vector2Float> graphPoints) {
+		this.graphPoints = graphPoints;
 	}
 
 	
@@ -316,7 +276,7 @@ public class HolonElement implements TimelineDependent{
 
 
 	@Override
-	public LinkedList<Double> getStateGraph() {
+	public LinkedList<Vector2Float> getStateGraph() {
 		return getGraphPoints();
 	}
 
@@ -339,9 +299,9 @@ public class HolonElement implements TimelineDependent{
 	 */
 	private float[] sampleGraph(int sampleLength)
 	{		
-		ListIterator<Point2D.Double> iter = this.graphPoints.listIterator();
-		Point.Double before = iter.next();
-		Point.Double after = iter.next();
+		ListIterator<Vector2Float> iter = this.graphPoints.listIterator();
+		Vector2Float before = iter.next();
+		Vector2Float after = iter.next();
 		float [] sampleCurve = new float[sampleLength];	
 		for(int i = 0; i<sampleLength ; i++)
 		{
@@ -370,14 +330,14 @@ public class HolonElement implements TimelineDependent{
 	 * @param end is the end Point of the Curve.
 	 * @return the percentage from the Curve at the X Value based on t.
 	 */
-	private double getYBetweenTwoPoints(double t, Point.Double start, Point.Double end) {
+	private double getYBetweenTwoPoints(double t, Vector2Float start, Vector2Float end) {
 		
-		double mitte = (start.x + end.x)* 0.5;
-		Point.Double bezier = getBezierPoint(t, start, new Point.Double(mitte, start.y), new Point.Double(mitte, end.y), end);
+		float mitte = (start.x + end.x)* 0.5f;
+		Vector2Float bezier = getBezierPoint(t, start, new Vector2Float(mitte, start.y), new Vector2Float(mitte, end.y), end);
 		return bezier.y;
 	}
 	/**
-	 * Helper method for {@link HolonElement#getYBetweenTwoPoints(double, Point.Double, Point.Double)}.
+	 * Helper method for {@link HolonElement#getYBetweenTwoPoints(double, Vector2Float, Vector2Float)}.
 	 * <p>
 	 * A Method for a normal Cubic Bezier Curve. A Cubic Bezier curve has four control points.
 	 * @param t is in Range [0,1] how much it traverse along the curve.
@@ -387,22 +347,22 @@ public class HolonElement implements TimelineDependent{
 	 * @param p3 EndPoint
 	 * @return the BezierPosition at t.
 	 */
-	private Point.Double getBezierPoint(double t, Point.Double p0, Point.Double p1,Point.Double p2,Point.Double p3) {
+	private Vector2Float getBezierPoint(double t, Vector2Float p0, Vector2Float p1,Vector2Float p2,Vector2Float p3) {
 		/*
 		 * Calculate Bezi�r:
 		 * B(t) = (1-t)^3 * P0 + 3*(1-t)^2 * t * P1 + 3*(1-t)*t^2 * P2 + t^3 * P3 , 0 < t < 1
 		 * 
 		 * Source: //http://www.theappguruz.com/blog/bezier-curve-in-games
 		 */
-		Point.Double bezier = new Point.Double();
+		Vector2Float bezier = new Vector2Float();
 		double OneSubT =  1-t;
 		double OneSubT2 = Math.pow(OneSubT, 2);
 		double OneSubT3 = Math.pow(OneSubT, 3);
 		double t2 = Math.pow(t , 2);
 		double t3 = Math.pow(t , 3);
 		
-		bezier.x = OneSubT3 * p0.x + 3 * OneSubT2 * t * p1.x + 3 * OneSubT * t2 * p2.x + t3 * p3.x;
-		bezier.y = OneSubT3 * p0.y + 3 * OneSubT2 * t * p1.y + 3 * OneSubT * t2 * p2.y + t3 * p3.y;
+		bezier.x = (float)(OneSubT3 * p0.x + 3 * OneSubT2 * t * p1.x + 3 * OneSubT * t2 * p2.x + t3 * p3.x);
+		bezier.y = (float)(OneSubT3 * p0.y + 3 * OneSubT2 * t * p1.y + 3 * OneSubT * t2 * p2.y + t3 * p3.y);
 		return bezier;
 		
 	}
@@ -427,4 +387,36 @@ public class HolonElement implements TimelineDependent{
 		this.isUsingLocalPeriod=state;
 	}
 	
+	/*
+	 * STATE 
+	 */
+	
+	private float actualEnergy = 0;
+	//TODO(Tom2021-12-1): public -> package
+	public void calculateState(int timestep) {
+		flexList.forEach(flex -> flex.calculateState(timestep));
+		float energyWhenActive = energy * this.curveSample[IndexTranslator.getEffectiveIndex(this, timestep)];
+		actualEnergy = isOn() ? energyWhenActive : 0;
+	}
+	  /**
+     * Get the energyPerElement currently(at given time step) available
+     */
+    public float calculateExpectedEnergyAtTimeStep(int timestep) {
+    	float energyWhenActive = energy * this.curveSample[IndexTranslator.getEffectiveIndex(this, timestep)];
+    	return active ? energyWhenActive : 0;
+    }
+	
+    public float getActualEnergy() {
+    	return actualEnergy;
+    }
+
+    public boolean isOn() {
+    	//return isFlexActive()?!active:active; 
+    	//Bool logic XOR
+    	return isFlexActive() ^ active;
+    }
+    public boolean isFlexActive() {
+    	return flexList.stream().anyMatch(flex -> flex.getState() == FlexState.IN_USE || flex.getState() == FlexState.ON_COOLDOWN);
+    }
+    
 }

+ 245 - 0
src/model/HolonObject.java

@@ -0,0 +1,245 @@
+package model;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+
+/**
+ * The class HolonObject represents any Object on the system which capability of
+ * injecting or consuming energy on the network, for instance a house or a power
+ * plant.
+ *
+ * @author Gruppe14
+ */
+public class HolonObject extends AbstractCanvasObject { 
+    /* Array of all consumers */
+    private List<HolonElement> elements = new ArrayList<HolonElement>();
+    
+    /**
+     * Constructor Set by default the name of the object equals to the category
+     * name, until the user changes it.
+     *
+     * @param objName name of the Object
+     */
+    public HolonObject(String objName) {
+        super(objName);
+    }
+
+    /**
+     * Contructor of a copy of an Object.
+     *
+     * @param obj object to be copied
+     */
+    public HolonObject(HolonObject obj) {
+        super(obj);
+        for(HolonElement ele : obj.elements) {
+        	this.addElement(new HolonElement(ele));
+        }
+    }
+
+    @Override
+    public void initForReflection() {
+    	super.initForReflection();
+    	elements = new ArrayList<HolonElement>();
+    }
+    
+    
+ 
+
+    /**
+     * Getter for all Elements in the HolonObject.
+     *
+     * @return the elements ArrayList
+     */
+    public List<HolonElement> getElements() {
+        return elements;
+    }
+    
+	public void setElements(List<HolonElement> list) {
+		this.elements = list;
+	}
+    
+    
+    
+
+    /**
+     * adds an Element to the Object.
+     *
+     * @param element the Element to add
+     */
+    public void addElement(HolonElement element) {
+        elements.add(element);
+        element.parentObject = this;
+    }
+    
+    /**
+     * remove an Element to the Object.
+     *
+     * @param element the Element to add
+     */
+    public void removeElement(HolonElement element) {
+        elements.remove(element);
+        element.parentObject = null;
+    }
+
+    public void removeElement(int index) {
+    	HolonElement ele = elements.remove(index);
+    	ele.parentObject = null;
+	}
+
+  
+    /*
+     * STATE
+     */
+    
+    
+    private float actualEnergy;
+    
+    
+    /** 
+     * This Method returns the Energy of a HolonObject. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE.
+     * If the HolonObject have no HolonElement its return 0;
+     * Is the returned Energy negative then the HolonObject need Energy because its consuming HolonElements need more Energy then the producing HolonElements.
+     * Is the returned Energy positive its reversed.
+     * @param timestep is the TimeStep to compare the HolonElements.
+     * @return The Energy of the HolonObject.
+     */
+    public void calculateState(int timestep)
+    {
+    	elements.forEach(ele -> ele.calculateState(timestep));
+    	actualEnergy = elements.stream().map(element -> element.getActualEnergy()).reduce(0.0f, Float::sum);
+    }
+    
+    
+    public float getActualEnergy()
+    {
+    	return actualEnergy;
+    }
+
+    
+    
+    
+    //New Methods:
+    /**
+     * This Method returns the smallest consuming HolonElement that is ACTIVE.
+     * If the HolonObject has no Consumer its return null. 
+     * @param timestep is the TimeStep to compare the HolonElements.
+     * @return The smallest consuming HolonElement or null.
+     */
+    public HolonElement getMinimumConsumingElement(){
+    	return elements.stream().filter(element -> element.getActualEnergy() < 0).max((lhs,rhs) -> Float.compare(lhs.getActualEnergy(), rhs.getActualEnergy())).orElse(null);
+    }
+    /**
+     * This Method returns the smallest consuming HolonElement'Energy that is ACTIVE.
+     * If the HolonObject has no Consumer its return 0. 
+     * @param timestep is the TimeStep to compare the HolonElements.
+     * @return The smallest consuming HolonElement or 0.
+     */
+    public float getMinimumConsumingElementEnergy(){
+    	return elements.stream().filter(element -> element.getActualEnergy() < 0 ).map(element -> -element.getActualEnergy()).min((lhs,rhs) ->Float.compare(lhs, rhs)).orElse(0.0f);
+    }
+    /**
+     * This Method returns the biggest consuming HolonElement'Energy that is ACTIVE.
+     * If the HolonObject has no Consumer its return 0. 
+     * @param timestep is the TimeStep to compare the HolonElements.
+     * @return The biggest consuming HolonElement or 0.
+     */
+    public float getMaximumConsumingElementEnergy(){
+    	return elements.stream().filter(element -> element.getActualEnergy() < 0 ).map(element -> -element.getActualEnergy()).max((lhs,rhs) ->Float.compare(lhs, rhs)).orElse(0.0f);
+    }
+
+    
+    public float getMaximumProductionPossible() {
+    	return elements.stream().filter(element -> element.getEnergy() > 0).map(element -> element.getEnergy()).reduce(0.0f, Float::sum);
+    }
+    public float getMaximumConsumptionPossible() {
+    	return elements.stream().filter(element -> element.getEnergy() < 0).map(element -> -element.getEnergy()).reduce(0.0f, Float::sum);
+    }
+    
+    
+    
+    
+    
+    /** 
+     * This Method returns the Energy that all HolonElements from the HolonObject produce by itself. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE and are Producer.
+     * If the HolonObject have no HolonElement its return 0;
+     * @param timestep is the TimeStep to compare the HolonElements.
+     * @return The Energy of the producing HolonElements.
+     */
+    public float getEnergySelfProducingFromProducingElements() {
+    	return elements.stream().filter(element -> element.getActualEnergy() > 0).map(element -> element.getActualEnergy()).reduce(0.0f, Float::sum);
+    }
+    /** 
+     * This Method returns the Energy of all HolonElements from the HolonObject that are consuming. Its sums all Energies from the HolonElements of the HolonObject that are ACTIVE and are Consumer.
+     * If the HolonObject have no HolonElement its return 0;
+     * @param timestep is the TimeStep to compare the HolonElements.
+     * @return The Energy of the consuming HolonElements.
+     */
+    public float getEnergyNeededFromConsumingElements() {
+    	return elements.stream().filter(element -> element.getActualEnergy() < 0).map(element -> -element.getActualEnergy()).reduce(0.0f, Float::sum);
+    }
+    /**
+     * This Method calculate the amount of HolonElements that are consuming Energy and are ACTIVE.
+     * @param timestep is the TimeStep to compare the HolonElements.
+     * @return The amount of HolonElements that are consuming Energy.
+     */
+    public int countConsumingElements() {
+    	return (int) elements.stream().filter(element ->  element.getActualEnergy() < 0).count();
+    }
+    /**
+     * This Method calculate the amount of HolonElements that are producing Energy and are ACTIVE.
+     * @param timestep is the TimeStep to compare the HolonElements.
+     * @return The amount of HolonElements that are producing Energy.
+     */
+    public int countProducingElements() {
+    	return (int) elements.stream().filter(element ->  element.getActualEnergy() > 0).count();
+    }
+    
+
+
+
+
+
+
+
+   
+
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+
+        sb.append("[HolonObject: ");
+        sb.append("id=").append(getId())
+                .append(", name=").append(name)
+                .append(", state=");
+        sb.append(", elements=[");
+        for (int i = 0; i < elements.size(); i++) {
+            HolonElement el = elements.get(i);
+            if (i != 0) {
+                sb.append(", ");
+            }
+            sb.append(el.getName());
+        }
+        sb.append("]]");
+
+        return sb.toString();
+    }
+    
+
+	public int getNumberOfActiveElements() {
+		return (int) elements.stream().filter(ele -> ele.active).count();
+	}
+	
+	public int getNumberOfInActiveElements() {
+		return (int) elements.stream().filter(ele -> !ele.active).count();
+	}
+	
+	public int getNumberOfElements() {
+		return elements.size();
+	}
+
+
+
+	
+}

+ 69 - 66
src/classes/HolonSwitch.java → src/model/HolonSwitch.java

@@ -1,8 +1,5 @@
-package classes;
+package model;
 
-import java.awt.Point;
-import java.awt.geom.Point2D;
-import java.awt.geom.Point2D.Double;
 import java.util.LinkedList;
 import java.util.ListIterator;
 
@@ -10,6 +7,7 @@ import com.google.gson.annotations.Expose;
 import interfaces.LocalMode;
 import interfaces.TimelineDependent;
 import ui.controller.IndexTranslator;
+import utility.Vector2Float;
 
 /**
  * The class HolonSwitch represents a Switch, which can be turned on and off.
@@ -26,15 +24,15 @@ public class HolonSwitch extends AbstractCanvasObject implements TimelineDepende
 	 *
 	 */
 	/*
-	 * manual state True, if this wire is working (capable of carrying
-	 * electricity), else false
+	 * manual state True, if this wire is working (capable of carrying electricity),
+	 * else false
 	 */
 	@Expose
 	boolean manualActive;
 
 	/*
-	 * active state True, if this wire is working (capable of carrying
-	 * electricity), else false
+	 * active state True, if this wire is working (capable of carrying electricity),
+	 * else false
 	 */
 	@Expose
 	private boolean autoActive;
@@ -44,10 +42,10 @@ public class HolonSwitch extends AbstractCanvasObject implements TimelineDepende
 	 */
 	@Expose
 	boolean manualMode;
-	
+
 	@Expose
 	int localPeriod;
-	
+
 	@Expose
 	boolean localPeriodActive;
 
@@ -57,23 +55,22 @@ public class HolonSwitch extends AbstractCanvasObject implements TimelineDepende
 	 */
 	boolean[] activeAt;
 	// Points on the UnitGraph
-	LinkedList<Point2D.Double> graphPoints = new LinkedList<>();
+	LinkedList<Vector2Float> graphPoints = new LinkedList<>();
 
 	/**
-	 * Create a new HolonSwitch with the default name ("Switch"), a default
-	 * value of automatic handle and active status.
+	 * Create a new HolonSwitch with the default name ("Switch"), a default value of
+	 * automatic handle and active status.
 	 * 
-	 * @param objName
-	 *            String
+	 * @param objName String
 	 */
 	public HolonSwitch(String objName) {
 		super(objName);
 		setUseLocalPeriod(false);
-		activeAt=new boolean[LocalMode.STANDARD_GRAPH_ACCURACY];
+		activeAt = new boolean[LocalMode.STANDARD_GRAPH_ACCURACY];
 		setManualState(true);
 		setAutoState(true);
 		setManualMode(false);
-		setGraphPoints(new LinkedList<Point2D.Double>());
+		setGraphPoints(new LinkedList<Vector2Float>());
 		initGraphPoints();
 		sampleGraph();
 	}
@@ -81,26 +78,32 @@ public class HolonSwitch extends AbstractCanvasObject implements TimelineDepende
 	/**
 	 * Create a copy of an existing HolonSwitch.
 	 * 
-	 * @param obj
-	 *            the Object to copy
+	 * @param obj the Object to copy
 	 */
 	public HolonSwitch(AbstractCanvasObject obj) {
 		super(obj);
-		HolonSwitch copyObj = (HolonSwitch)obj;
+		HolonSwitch copyObj = (HolonSwitch) obj;
 		setLocalPeriod(copyObj.getLocalPeriod());
 		setUseLocalPeriod(copyObj.isUsingLocalPeriod());
-		activeAt=new boolean[LocalMode.STANDARD_GRAPH_ACCURACY];
+		activeAt = new boolean[LocalMode.STANDARD_GRAPH_ACCURACY];
 		super.setName(obj.getName());
 		setManualState(copyObj.getManualState());
 		setAutoState(true);
-		setGraphPoints(new LinkedList<Point2D.Double>());
-		for (Point2D.Double p : copyObj.getGraphPoints()) {
-			this.graphPoints.add(new Point2D.Double(p.getX(),p.getY()));
+		setGraphPoints(new LinkedList<Vector2Float>());
+		for (Vector2Float p : copyObj.getGraphPoints()) {
+			this.graphPoints.add(new Vector2Float(p.getX(), p.getY()));
 		}
 		sampleGraph();
 		setManualMode(copyObj.getManualMode());
 	}
 
+	@Override
+	public void initForReflection() {
+		super.initForReflection();
+		this.graphPoints = new LinkedList<>();
+		this.reset();
+	}
+
 	/**
 	 * Calculates the state of the Switch.
 	 */
@@ -117,13 +120,14 @@ public class HolonSwitch extends AbstractCanvasObject implements TimelineDepende
 
 	}
 
-	public static String getSwitchClosedImage(){
+	public static String getSwitchClosedImage() {
 		return "/Images/switch-on.png";
 	}
-	
-	public static String getSwitchOpenImage(){
+
+	public static String getSwitchOpenImage() {
 		return "/Images/switch-off.png";
 	}
+
 	/**
 	 * Getter for the status of the Switch at a given timestep.
 	 * 
@@ -138,7 +142,6 @@ public class HolonSwitch extends AbstractCanvasObject implements TimelineDepende
 		}
 	}
 
-
 	/**
 	 * Change the state of the Switch to manual.
 	 * 
@@ -183,7 +186,7 @@ public class HolonSwitch extends AbstractCanvasObject implements TimelineDepende
 	 * 
 	 * @return the Graph Points
 	 */
-	public LinkedList<Point2D.Double> getGraphPoints() {
+	public LinkedList<Vector2Float> getGraphPoints() {
 		return graphPoints;
 	}
 
@@ -192,18 +195,19 @@ public class HolonSwitch extends AbstractCanvasObject implements TimelineDepende
 	 * 
 	 * @param linkedList the Graph points
 	 */
-	public void setGraphPoints(LinkedList<Double> linkedList) {
+	public void setGraphPoints(LinkedList<Vector2Float> linkedList) {
 		this.graphPoints = linkedList;
 	}
+
 	/**
 	 * Initialize the Graph as a closed Switch.
 	 */
-	private void initGraphPoints()
-	{
+	private void initGraphPoints() {
 		graphPoints.clear();
-		graphPoints.add(new Point2D.Double(0.0, 1.0));
-		graphPoints.add(new Point2D.Double(1.0, 1.0));
+		graphPoints.add(new Vector2Float(0, 1));
+		graphPoints.add(new Vector2Float(1, 1));
 	}
+
 	/**
 	 * Returns the ManualState.
 	 * 
@@ -221,12 +225,11 @@ public class HolonSwitch extends AbstractCanvasObject implements TimelineDepende
 	public boolean getAutoActive() {
 		return autoActive;
 	}
-	
+
 	/**
 	 * Set the overall value of the Switch (manual mode).
 	 * 
-	 * @param mode
-	 *            the mode (boolean)
+	 * @param mode the mode (boolean)
 	 */
 	public void setManualMode(boolean mode) {
 		manualMode = mode;
@@ -241,76 +244,76 @@ public class HolonSwitch extends AbstractCanvasObject implements TimelineDepende
 		return manualMode;
 	}
 
-	//interfaces.GraphEditable
+	// interfaces.GraphEditable
 	@Override
 	public GraphType getGraphType() {
 		return GraphType.boolGraph;
 	}
 
 	@Override
-	public LinkedList<Double> getStateGraph() {
+	public LinkedList<Vector2Float> getStateGraph() {
 		return graphPoints;
 	}
-	
 
 	@Override
 	public void reset() {
 		initGraphPoints();
 		sampleGraph();
 	}
+
 	@Override
 	public void sampleGraph() {
 		activeAt = sampleGraph(100);
 	}
+
 	/**
-	 * Generate out of the Graph Points a array of boolean that represent the Curve("on or off"-Graph) at each sample position. The Values are in the Range [0,1].
-	 * @param sampleLength amount of samplePositions. The positions are equidistant on the Range[0,1].
+	 * Generate out of the Graph Points a array of boolean that represent the
+	 * Curve("on or off"-Graph) at each sample position. The Values are in the Range
+	 * [0,1].
+	 * 
+	 * @param sampleLength amount of samplePositions. The positions are equidistant
+	 *                     on the Range[0,1].
 	 * @return the boolean array of samplepoints.
 	 */
-	private boolean[] sampleGraph(int sampleLength)
-	{
-		ListIterator<Point2D.Double> iter = this.graphPoints.listIterator();
-		Point.Double before = iter.next();
-		Point.Double after = iter.next();
-		boolean [] activeTriggerPos = new boolean[sampleLength];	
-		for(int i = 0; i<sampleLength ; i++)
-		{
-			double graphX = (double)i / (double) (sampleLength - 1); //from 0.0 to 1.0
-			if(graphX > after.x)
-			{
+	private boolean[] sampleGraph(int sampleLength) {
+		ListIterator<Vector2Float> iter = this.graphPoints.listIterator();
+		Vector2Float before = iter.next();
+		Vector2Float after = iter.next();
+		boolean[] activeTriggerPos = new boolean[sampleLength];
+		for (int i = 0; i < sampleLength; i++) {
+			double graphX = (double) i / (double) (sampleLength - 1); // from 0.0 to 1.0
+			if (graphX > after.x) {
 				before = after;
 				after = iter.next();
-			}		
+			}
 			activeTriggerPos[i] = (before.getY() >= 0.5);
 		}
 		return activeTriggerPos;
 	}
-	
-	//interfaces.LocalMode
+
+	// interfaces.LocalMode
 	@Override
 	public void setLocalPeriod(int period) {
-		localPeriod=period;
+		localPeriod = period;
 	}
-	
+
 	@Override
 	public int getLocalPeriod() {
 		return localPeriod;
 	}
-	
+
 	@Override
 	public boolean isUsingLocalPeriod() {
 		return localPeriodActive;
 	}
-	
+
 	@Override
 	public void setUseLocalPeriod(boolean state) {
-		this.localPeriodActive=state;
+		this.localPeriodActive = state;
 	}
-	
-	
-		
+
 	public String toString() {
-		return name + "[ID:" + id + "]";
-		
+		return name + "[ID:" + getId() + "]";
+
 	}
 }

+ 2 - 8
src/classes/Node.java → src/model/Node.java

@@ -1,8 +1,4 @@
-package classes;
-
-import java.util.ArrayList;
-
-import classes.IdCounter.CounterType;
+package model;
 
 /**
  * The class "CpsNode" represents empty Objects in the system. They are just
@@ -21,10 +17,8 @@ public class Node extends AbstractCanvasObject {
 	 */
 	public Node(String objName) {
 		super(objName);
-		this.setConnections(new ArrayList<Edge>());
 		this.setImage("/Images/node.png");
 		this.setSav("CVS");
-		this.setId(IdCounter.nextId(CounterType.Object));
 	}
 	
 	public Node(Node node){
@@ -32,7 +26,7 @@ public class Node extends AbstractCanvasObject {
 	}
 	
 	public String toString(){
-		return "Node ID:" + super.id;
+		return "Node ID:" + getId();
 	}
 
 }

+ 65 - 0
src/preferences/ColorPreference.java

@@ -2,6 +2,9 @@ package preferences;
 
 import java.awt.Color;
 
+import model.Flexibility.FlexState;
+import ui.model.DecoratedHolonObject.HolonObjectState;
+
 /**
  * A Class to save all colors in Holeg.
  * @author Tom
@@ -28,7 +31,33 @@ public class ColorPreference {
 		public static final Color PartiallySupplied = Color.yellow;
 		public static final Color NotSupplied = new Color(230, 120, 100);
 		public static final Color NoEnergy = Color.white;
+	
+		public static Color getStateColor(HolonObjectState state) {
+			switch (state) {
+			case NOT_SUPPLIED:
+				return NotSupplied;
+			case OVER_SUPPLIED:
+				return OverSupplied;
+			case PARTIALLY_SUPPLIED:
+				return PartiallySupplied;
+			case PRODUCER:
+				return Producer;
+			case SUPPLIED:
+				return Supplied;
+			case NO_ENERGY:
+			default:
+				return NoEnergy;
+			}
+		}
+	}
+	
+	public static class Edge{
+		public static final Color Working = new Color(13, 175, 28);
+		public static final Color Burned = Color.red;
 	}
+	
+	
+	
 	public static class Energy{
 		public static final Color Production = new Color(61, 133, 243);
 		public static final Color Consumption = new Color(255, 67, 60);
@@ -39,11 +68,47 @@ public class ColorPreference {
 		public static final Color Offered = new Color(75, 170, 72);
 		public static final Color NotOffered = new Color(237, 106, 90);
 		public static final Color Unavailable = new Color(193, 193, 193);
+		
+		public static Color getStateColor(FlexState state) {
+			switch(state) {
+			case IN_USE:
+				return InUse;
+			case NOT_OFFERED:
+				return NotOffered;
+			case OFFERED:
+				return Offered;
+			case ON_COOLDOWN:
+				return OnCooldown;
+			case UNAVAILABLE:
+			default:
+				return Unavailable;
+			}
+		}
 	}
 	
 	public static class Panel {
 		public static final Color Transparent = new Color(0,0,0,0);
+		public static final Color ObjectSelection = new Color(128, 174, 247, 40);
+		public static final Color ObjectSelectionBorder = Color.lightGray;
+		public static final Color MouseSelection = Color.blue;
 		public static final Color Background = new Color(250, 250, 250);
 		public static final Color Title = new Color(54, 73, 78);
 	}
+	
+	public static class Dialog{
+		public static final Color BackgroundColor = new Color(255, 50, 50);
+	}
+	
+	public static class Category {
+		public final static Color Focus = new Color(0, 0, 255);	
+	}
+	public static class Inspector{
+		public final static Color Selected = new Color(126, 186, 255);
+		public final static Color Border = new Color(171, 173, 179);
+	}
+	
+	public static class GUI {
+		//TODO(Tom2021-12-1) for what is this collor used
+		public static final Color PALE_RED = new Color(255, 192, 192);
+	}
 }

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

@@ -7,13 +7,12 @@ import java.util.List;
 import java.util.ListIterator;
 import java.util.stream.Collectors;
 
-import classes.AbstractCanvasObject;
-import classes.Edge;
-import classes.GroupNode;
-import classes.HolonObject;
-import classes.HolonSwitch;
-import classes.Node;
-import interfaces.ObjectListener;
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
+import model.HolonObject;
+import model.HolonSwitch;
+import model.Node;
 import ui.model.Model;
 import ui.view.main.GUI;
 import utility.Vector2Int;
@@ -107,15 +106,6 @@ public class CanvasController {
 		addObject(object, true);
 	}
 
-	/**
-	 * adds the ObjectListener.
-	 * 
-	 * @param objLis
-	 *            ObjectListener
-	 */
-	public void addObjectListener(ObjectListener objLis) {
-		model.getObjectListeners().add(objLis);
-	}
 
 
 	/**
@@ -248,8 +238,7 @@ public class CanvasController {
 						}
 					}
 					if (newEdge) {
-						Edge tempE = new Edge(a, b,
-								e.getCapacity());
+						Edge tempE = new Edge(e);
 						addEdgeOnCanvas(tempE);
 					}
 				}

+ 16 - 11
src/ui/controller/CategoryController.java

@@ -1,15 +1,18 @@
 package ui.controller;
 
+import java.util.AbstractMap.SimpleEntry;
+
+import model.AbstractCanvasObject;
+import model.HolonElement;
+import model.HolonObject;
+import model.HolonSwitch;
+
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
 
-import classes.Category;
-import classes.AbstractCanvasObject;
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.HolonSwitch;
-import classes.Pair;
 import ui.model.Model;
+import ui.view.main.Category;
 import utility.events.Event;
 
 /**
@@ -129,7 +132,8 @@ public class CategoryController {
 		int i = 0;
 		boolean updateElementSaves = false;
 		String name = "";
-		while (mpC.searchCatObj(category, object.getName()) != null) {
+		//TODO(Tom2021-12-1) remove/redo this search
+		while (mpC.searchCatObj(category, object.getName()).isPresent()) {
 			updateElementSaves = true;
 			if (object.getName().contains("_"))
 				object.setName(object.getName().substring(0, object.getName().indexOf('_')));
@@ -139,7 +143,7 @@ public class CategoryController {
 		}
 		if(updateElementSaves && object instanceof HolonObject &&((HolonObject)object).getElements()!=null){
 			for(HolonElement e: ((HolonObject)object).getElements()){
-				e.setSaving(new Pair<String,String>(e.getSaving().getKey(), name));
+				e.setSaving(new SimpleEntry<String,String>(e.getSaving().getKey(), name));
 			}
 		}
 		category.getObjIdx().put(object.getName(), category.getObjects().size());
@@ -205,12 +209,13 @@ public class CategoryController {
 	 * 
 	 * @param category
 	 *            the Category
-	 * @param obj
+	 * @param objectName
 	 *            the Object
 	 */
-	public void deleteObject(String category, String obj) {
+	public void deleteObject(String category, String objectName) {
 		Category cat = mpC.searchCat(category);
-		removeObject(cat, mpC.searchCatObj(cat, obj));
+		Optional<AbstractCanvasObject> object = mpC.searchCatObj(cat, objectName);
+		object.ifPresent(obj -> removeObject(cat, obj));
 	}
 
 }

+ 22 - 28
src/ui/controller/ClipboardController.java

@@ -1,19 +1,18 @@
 package ui.controller;
 
-import classes.*;
-import classes.IdCounter.CounterType;
-
 import com.google.gson.*;
+
+import model.*;
 import ui.controller.SaveController.EDGETYPE;
 import ui.controller.SaveController.GRAPHTYPE;
 import ui.controller.SaveController.NUMTYPE;
 import ui.controller.SaveController.TYPE;
 import ui.model.Model;
+import utility.Vector2Float;
 import utility.Vector2Int;
 
 import java.awt.*;
 import java.awt.datatransfer.*;
-import java.awt.geom.Point2D;
 import java.io.IOException;
 import java.util.*;
 import java.util.List;
@@ -25,7 +24,6 @@ public class ClipboardController {
     private SaveController store;
     private LoadController load;
     private CanvasController cvsC;
-    private ObjectController objC;
     private NodeController uppC;
     private JsonParser parser;
     private Clipboard clipboard;
@@ -41,7 +39,6 @@ public class ClipboardController {
         this.store = store;
         this.load = load;
         this.cvsC = cvs;
-        this.objC = obj;
         this.uppC = uppC;
         this.clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
         this.simManager = simManager;
@@ -139,7 +136,7 @@ public class ClipboardController {
         // for selecting Cps
         getObjectsInDepth();
         forwardEdges(edges, json, objDispatch, upperNode);
-        this.simManager.calculateStateForTimeStep(model.getCurrentIteration(), true);
+        this.simManager.calculateStateForTimeStep(model.getActualTimeStep(), true);
     }
 
     /**
@@ -157,7 +154,7 @@ public class ClipboardController {
                 cvsC.bfsNodeCleaner((GroupNode) abs);
         }
         model.getSelectedObjects().clear();
-        this.simManager.calculateStateForTimeStep(model.getCurrentIteration(), true);
+        this.simManager.calculateStateForTimeStep(model.getActualTimeStep(), true);
 
     }
 
@@ -202,7 +199,7 @@ public class ClipboardController {
     private void loadCanvasObject(JsonElement jsonElement, HashMap<Integer, AbstractCanvasObject> objDispatch,
                                   GroupNode upperNode) {
         AbstractCanvasObject temp = model.getGson().fromJson(jsonElement.getAsJsonObject(), AbstractCanvasObject.class);
-        load.initObjects(temp);
+        temp.initForReflection();
         objIDMapper(temp);
         updatePosition(temp, upperNode);
 
@@ -238,18 +235,17 @@ public class ClipboardController {
                                     HashMap<Integer, HolonElement> eleDispatch) {
         JsonObject object = jsonElement.getAsJsonObject();
 
-        HolonElement temp = model.getGson().fromJson(object.get("properties"), HolonElement.class);
-        load.initElements(temp);
-        eleIDMapper(temp);
+        HolonElement ele = model.getGson().fromJson(object.get("properties"), HolonElement.class);
+        load.initElements(ele);
+        eleIDMapper(ele);
         // id which Object it was stored before
         int stored = objIDMap.get(object.get("ID").getAsInt());
         // lookup that object
-        HolonObject temp2 = (HolonObject) objDispatch.get(stored);
+        HolonObject obj = (HolonObject) objDispatch.get(stored);
         // add it
-        objC.addElement(temp2, temp);
+        obj.addElement(ele);
         // store element also inside a table
-        eleDispatch.put(temp.getId(), temp);
-
+        eleDispatch.put(ele.getId(), ele);
     }
 
     private void loadUnitGraph(GRAPHTYPE type, JsonElement jsonElement, HashMap<Integer, AbstractCanvasObject> objDispatch,
@@ -259,14 +255,14 @@ public class ClipboardController {
         String p;
         int mid;
         int sav = 0;
-     	LinkedList<Point2D.Double> graphpointTEST = new LinkedList<>();
+     	LinkedList<Vector2Float> graphpointTEST = new LinkedList<>();
         for (String k : keys) {
             if (!k.equals("ID")) {
                 p = object.get(k).getAsString();
                 mid = p.indexOf(':');
-                double x1 = Double.parseDouble(p.substring(0, mid));
-                double y1 = Double.parseDouble(p.substring(mid + 1, p.length()));
-                graphpointTEST.add(new Point2D.Double(x1, y1));
+                float x1 = Float.parseFloat(p.substring(0, mid));
+                float y1 = Float.parseFloat(p.substring(mid + 1, p.length()));
+                graphpointTEST.add(new Vector2Float(x1, y1));
             } else
                 // else its an ID
                 sav = object.get(k).getAsInt();
@@ -409,7 +405,6 @@ public class ClipboardController {
      */
     private void objIDMapper(AbstractCanvasObject temp) {
         int id = temp.getId();
-        temp.setId(IdCounter.nextId(CounterType.Object));
         // oldID -> currentID
         objIDMap.put(id, temp.getId());
     }
@@ -419,7 +414,6 @@ public class ClipboardController {
      */
     private void eleIDMapper(HolonElement temp) {
         int id = temp.getId();
-        temp.setId(IdCounter.nextId(CounterType.Element));
         // oldID -> currentID
         eleIDMap.put(id, temp.getId());
 
@@ -430,16 +424,16 @@ public class ClipboardController {
         int y = temp.getPosition().getY() - point.y;
 
         if (y < 0)
-            y = 0 + model.getScaleDiv2() + 1;
+            y = 0 + Model.getScaleDiv2() + 1;
         if (upperNode != null) {
-            if (x < model.getScaleDiv2() + 1)
-                x = model.getScaleDiv2() + 1;
+            if (x < Model.getScaleDiv2() + 1)
+                x = Model.getScaleDiv2() + 1;
         } else if (x < 0)
-            x = 0 + model.getScaleDiv2() + 1;
+            x = 0 + Model.getScaleDiv2() + 1;
         if (x > model.getCanvasX())
-            x = model.getCanvasX() - model.getScaleDiv2() - 1;
+            x = model.getCanvasX() - Model.getScaleDiv2() - 1;
         if (y > model.getCanvasX())
-            y = model.getCanvasY() - model.getScaleDiv2() - 1;
+            y = model.getCanvasY() - Model.getScaleDiv2() - 1;
 
         temp.setPosition(new Vector2Int(x, y));
 

+ 12 - 31
src/ui/controller/Control.java

@@ -17,16 +17,16 @@ import org.apache.commons.compress.archivers.ArchiveException;
 
 import com.google.gson.JsonParseException;
 
-import classes.AbstractCanvasObject;
-import classes.Category;
-import classes.Edge;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.Node;
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
+import model.Node;
 import ui.model.Model;
 import ui.model.Model.FairnessModel;
 import ui.view.dialog.CreateTemplatePopUp;
+import ui.view.main.Category;
 import ui.view.main.GUI;
 import utility.events.Event;
 
@@ -151,17 +151,8 @@ public class Control {
 	public AbstractCanvasObject searchTracked(int id) {
 		return multiPurposeController.searchByID(id);
 	}
+	
 
-	/**
-	 * Search for Object in a Category.
-	 *
-	 * @param category name of the Category
-	 * @param object   Name of the Object
-	 * @return The Object
-	 */
-	public AbstractCanvasObject searchCategoryObject(String category, String object) {
-		return multiPurposeController.searchCatObj(multiPurposeController.searchCat(category), object);
-	}
 
 	/**
 	 * search for category.
@@ -327,7 +318,7 @@ public class Control {
 	 */
 	public void addObjectCanvas(AbstractCanvasObject object) {
 		canvasController.addNewObject(object);
-		calculateStateAndVisualForTimeStep(model.getCurrentIteration());
+		calculateStateAndVisualForTimeStep(model.getActualTimeStep());
 		if (!(object instanceof Node)) {
 			tryAutoSave();
 		}
@@ -424,16 +415,6 @@ public class Control {
 		objectController.addNewElementIntoCategoryObject(catName, objName, eleName, energy);
 	}
 
-	/**
-	 * deletes a Element from a given Canvas Object.
-	 *
-	 * @param id        the ID
-	 * @param elementid the Element ID
-	 */
-	public void deleteElementCanvas(int id, int elementid) {
-		objectController.deleteElementInCanvas(id, elementid);
-		tryAutoSave();
-	}
 
 	/**
 	 * Returns SCALE.
@@ -519,11 +500,11 @@ public class Control {
 	 * Timestep.
 	 */
 	public void calculateStateAndVisualForCurrentTimeStep() {
-		calculateStateAndVisualForTimeStep(model.getCurrentIteration());
+		calculateStateAndVisualForTimeStep(model.getActualTimeStep());
 	}
 
 	public void calculateStateOnlyForCurrentTimeStep() {
-		simulationManager.calculateStateForTimeStep(model.getCurrentIteration(), false);
+		simulationManager.calculateStateForTimeStep(model.getActualTimeStep(), false);
 	}
 
 	/**
@@ -543,7 +524,7 @@ public class Control {
 	 * the default "is working" state
 	 */
 	public void resetSimulation() {
-		simulationManager.resetFlexManager();
+		System.out.println("RESET SIMULATION");
 	}
 
 	/**

+ 0 - 188
src/ui/controller/FlexManager.java

@@ -1,188 +0,0 @@
-package ui.controller;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import classes.AbstractCanvasObject;
-import classes.GroupNode;
-import classes.Flexibility;
-import classes.HolonElement;
-import classes.HolonObject;
-import ui.model.Model;
-
-/**
- * Class to Manage to flexibilities.
- * To order, view Flexibilities.
- * @author tom
- *
- */
-public class FlexManager {
-	private int timeStep;
-	private  List<Flexibility> allFlexModels;
-	private List<Flexibility> allFlexesOrderedThisTimeStep = new ArrayList<Flexibility>();
-	private HashMap<HolonElement, List<FlexWrapper>> accessOtherFlex = new HashMap<HolonElement, List<FlexWrapper>>();
-	private HashMap<Flexibility, FlexWrapper> accessFlexMap = new HashMap<Flexibility, FlexWrapper>();
-	public FlexManager(Model model, int timeStep, FlexManager timestepBefore){
-		//Thread.dumpStack();
-		this.timeStep = timeStep;
-		allFlexModels = getAllFlexFromModel(model);
-		//fill accessFlexMap
-		allFlexModels.stream().map(flex -> new FlexWrapper(flex, timeStep, (timestepBefore != null)?timestepBefore.getFlexWrapper(flex):null)).forEach(flexWrapper -> {
-			accessFlexMap.put(flexWrapper.getFlex(), flexWrapper);
-			HolonElement ele = flexWrapper.getFlex().getElement();
-			if(accessOtherFlex.containsKey(ele)) {
-				accessOtherFlex.get(ele).add(flexWrapper);
-			}else {
-				ArrayList<FlexWrapper> toAdd = new ArrayList<FlexWrapper>();
-				toAdd.add(flexWrapper);
-				accessOtherFlex.put(ele, new ArrayList<FlexWrapper>(toAdd));
-			}
-			});
-		//because when added not all flexes can see others
-		accessFlexMap.values().stream().forEach(flexWrapper -> flexWrapper.revalidateState());
-	}
-	
-	
-	
-	private FlexWrapper getFlexWrapper(Flexibility flex) {
-		return accessFlexMap.getOrDefault(flex, null);
-	}
-
-	public List<FlexWrapper> getAllFlexWrapper() {
-		return accessFlexMap.values().stream().collect(Collectors.toList());
-	}
-	
-	public List<FlexWrapper> getAllFlexWrapperWithState(FlexState state) {
-		return accessFlexMap.values().stream().filter(flexWrapper -> (flexWrapper.getState() == state)).collect(Collectors.toList());
-	}
-
-
-
-	private List<Flexibility> getAllFlexFromModel(Model model) {
-		return createListOfHolonObjects(model.getObjectsOnCanvas()).stream().flatMap(hObject -> hObject.getElements().stream()).flatMap(hElement -> hElement.flexList.stream()).collect(Collectors.toList());
-	}
-
-	private List<HolonObject> createListOfHolonObjects(List<AbstractCanvasObject> objectsOnCanvas) {
-		List<HolonObject> list = new ArrayList<HolonObject>();
-		for(AbstractCanvasObject aCps :  objectsOnCanvas) {
-			if(aCps instanceof HolonObject) list.add((HolonObject) aCps);
-			else if(aCps instanceof GroupNode)list.addAll(createListOfHolonObjects(((GroupNode)aCps).getNodes()));
-		}
-		return list;
-	}
-
-
-	public int getTimeStep() {
-		return timeStep;
-	}
-	
-	public List<Flexibility> getAllFlexesOrderedThisTimeStep() {
-		return allFlexesOrderedThisTimeStep;
-	}
-
-	public void orderFlexFromList(List<Flexibility> flexList) {
-		flexList.stream().forEach(flex -> {
-			FlexWrapper flexToOrder = accessFlexMap.get(flex);
-			if(flexToOrder!=null)flexToOrder.order();
-		});
-	}
-	public void orderFlex(Flexibility flex) {
-		FlexWrapper flexToOrder =  accessFlexMap.get(flex);
-		if(flexToOrder!=null)flexToOrder.order();
-	}
-	public boolean isAFlexInUseOfHolonElement(HolonElement ele) {
-		return ele.flexList.stream().filter(flex -> this.accessFlexMap.containsKey(flex)).anyMatch(flex -> (this.accessFlexMap.get(flex).getState() == FlexState.IN_USE));
-	}
-	/**
-	 * Or Return null
-	 * @param flex
-	 * @return
-	 */
-	public FlexWrapper getFlexWrapperFromFlexibility(Flexibility flex) {
-		return accessFlexMap.get(flex);
-	}
-	
-	public static enum FlexState{
-			IN_USE, ON_COOLDOWN, OFFERED, NOT_OFFERED, UNAVAILABLE
-		}
-	//Classes
-	public class FlexWrapper{
-		private Flexibility flex;
-		private FlexState state;
-		int timeStep;
-		int durationEndTime = -1;
-		int coolDownEndTime = -1;
-		public FlexWrapper(Flexibility flex, int timeStep, FlexWrapper old) {
-			this.flex = flex;
-			this.timeStep = timeStep;
-			if(old == null) {
-				state = flex.fulfillsConstrains()?(flex.offered?FlexState.OFFERED:FlexState.NOT_OFFERED):FlexState.UNAVAILABLE;
-			}else {
-				durationEndTime = old.durationEndTime;
-				coolDownEndTime = old.coolDownEndTime;
-				revalidateState();
-			}
-				
-			
-		}
-		
-		public void revalidateState() {
-			if(remainingTimeTillActivation() == 0) state = (flex.fulfillsConstrains() && !otherFlexInUseOrOnCooldown())?(flex.offered?FlexState.OFFERED:FlexState.NOT_OFFERED):FlexState.UNAVAILABLE;
-			else if(remainingDuration()== 0) state = FlexState.ON_COOLDOWN;
-			else state = FlexState.IN_USE;
-		}
-		
-		
-		
-		public Flexibility getFlex() {
-			return flex;
-		}
-		public FlexState getState() {
-			return state;
-		}
-		public boolean canOrder() {
-			return (state == FlexState.OFFERED) &&  //Right state
-					!otherFlexInUseOrOnCooldown(); //No other flex of this ele in use
-		}
-		private boolean otherFlexInUseOrOnCooldown() {
-			if(accessOtherFlex.get(this.getFlex().getElement()) == null) return false;
-			return accessOtherFlex.get(this.getFlex().getElement()).stream().anyMatch(flexWrapper -> flexWrapper != this && (flexWrapper.getState() == FlexState.IN_USE || flexWrapper.getState() == FlexState.ON_COOLDOWN));
-		}
-		public boolean order() {
-			if(canOrder()) {
-				state=FlexState.IN_USE;
-				allFlexesOrderedThisTimeStep.add(flex);
-				durationEndTime = timeStep + flex.getDuration();
-				coolDownEndTime = durationEndTime + flex.getCooldown();
-				//accessFlexMap.values().stream().filter(flexWrapper -> (flexWrapper.getFlex().getElement() == flex.getElement() && flexWrapper != this)).forEach(otherFlex -> otherFlex.revalidateState());
-				accessOtherFlex.get(this.getFlex().getElement()).stream().filter(flexWrapper -> (flexWrapper != this)).forEach(otherFlex -> otherFlex.revalidateState());
-				return true;
-			}
-			return false;
-		}
-		public boolean cancel() {
-			if(allFlexesOrderedThisTimeStep.contains(flex)) {
-				state=FlexState.OFFERED;
-				durationEndTime = -1;
-				coolDownEndTime = -1;
-				allFlexesOrderedThisTimeStep.remove(flex);
-				accessOtherFlex.get(this.getFlex().getElement()).stream().filter(flexWrapper -> (flexWrapper != this)).forEach(otherFlex -> otherFlex.revalidateState());
-
-				return true;
-			}
-			return false;
-		}
-		public int remainingTimeTillActivation() {
-			return Math.max(0, coolDownEndTime - timeStep);
-		}
-		public int remainingDuration() {
-			return Math.max(0, durationEndTime - timeStep);
-		}
-		
-	}
-	public void reset() {
-		getAllFlexWrapper().forEach(flexWrapper -> flexWrapper.cancel());
-	}
-}

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

@@ -37,7 +37,7 @@ public class GlobalController {
 	 * @return SCALE Divided by 2
 	 */
 	public int getScaleDiv2() {
-		return model.getScaleDiv2();
+		return Model.getScaleDiv2();
 	}
 
 	/**
@@ -47,7 +47,7 @@ public class GlobalController {
 	 *            Scale
 	 */
 	public void setScale(int s) {
-		model.setScale(s);
+		Model.setScale(s);
 	}
 
 	/**
@@ -57,7 +57,7 @@ public class GlobalController {
 	 *            the current Iteration
 	 */
 	public void setCurIteration(int curit) {
-		model.setCurIteration(curit);
+		model.setCurrentIteration(curit);
 	}
 
 	/**

+ 20 - 42
src/ui/controller/LoadController.java

@@ -1,24 +1,24 @@
 package ui.controller;
 
-import classes.*;
-import classes.HolonElement.Priority;
-import classes.IdCounter.CounterType;
-
 import com.google.gson.JsonElement;
 import com.google.gson.JsonObject;
 import com.google.gson.JsonParser;
 import com.google.gson.reflect.TypeToken;
 
+import model.*;
+import model.HolonElement.Priority;
+
 import org.apache.commons.compress.archivers.ArchiveEntry;
 import org.apache.commons.compress.archivers.ArchiveException;
 import org.apache.commons.compress.archivers.ArchiveInputStream;
 import org.apache.commons.compress.archivers.ArchiveStreamFactory;
 import org.apache.commons.compress.utils.IOUtils;
-
-import ui.controller.LoadController.MODE;
+import ui.model.IdCounter;
 import ui.model.Model;
+import utility.Vector2Float;
+import ui.model.IdCounter.CounterType;
+import ui.view.main.Category;
 
-import java.awt.geom.Point2D;
 import java.io.*;
 import java.nio.file.Files;
 import java.nio.file.StandardCopyOption;
@@ -242,7 +242,7 @@ public class LoadController {
     	}
         
         temp.setImage(checkOS(temp.getImage()));
-        initObjects(temp);
+        temp.initForReflection();
         if (mpC.searchCatObj(mpC.searchCat(temp.getSav()), temp.getName()) != null)
             cgC.deleteObject(temp.getSav(), temp.getName());
         cgC.addObject(mpC.searchCat(temp.getSav()), temp);
@@ -268,7 +268,7 @@ public class LoadController {
         //Fix old amount
         JsonElement amount = object.get("properties").getAsJsonObject().get("amount");
         if(amount != null) {
-        	ele.setEnergyPerElement(amount.getAsInt() * ele.getEnergy());
+        	ele.setEnergy(amount.getAsInt() * ele.getEnergy());
         }
         objC.addElementIntoCategoryObject(ele.getSaving().getKey(), ele.getSaving().getValue(), ele);
     }
@@ -285,7 +285,7 @@ public class LoadController {
     		System.err.println(jsonObject.get("type").getAsString());
     		return;
     	}
-        initObjects(temp);
+        temp.initForReflection();
         temp.setImage(checkOS(temp.getImage()));
         if (temp instanceof GroupNode) {
             model.getHashcodeMap().put(jsonObject.get("hash").getAsInt(), (GroupNode) temp);
@@ -341,14 +341,14 @@ public class LoadController {
         //Fix old amount
         JsonElement amount = object.get("properties").getAsJsonObject().get("amount");
         if(amount != null) {
-        	ele.setEnergyPerElement(amount.getAsInt() * ele.getEnergy());
+        	ele.setEnergy(amount.getAsInt() * ele.getEnergy());
         }
         // id which Object it was stored before
         int stored = object.get("ID").getAsInt();
         // lookup that object
         HolonObject hObject = (HolonObject) objDispatch.get(stored);
         // add it
-        objC.addElement(hObject, ele);
+        hObject.addElement(ele);
         ele.parentObject = hObject;
         // store element also inside a table
         eleDispatch.put(ele.getId(), ele);
@@ -377,14 +377,14 @@ public class LoadController {
         String p;
         int mid;
         int sav = 0;
-     	LinkedList<Point2D.Double> graphpointTEST = new LinkedList<>();
+     	LinkedList<Vector2Float> graphpointTEST = new LinkedList<>();
         for (String k : keys) {
             if (!k.equals("ID")) {
                 p = object.get(k).getAsString();
                 mid = p.indexOf(':');
-                double x1 = Double.parseDouble(p.substring(0, mid));
-                double y1 = Double.parseDouble(p.substring(mid + 1, p.length()));
-                graphpointTEST.add(new Point2D.Double(x1, y1));
+                float x1 = Float.parseFloat(p.substring(0, mid));
+                float y1 = Float.parseFloat(p.substring(mid + 1, p.length()));
+                graphpointTEST.add(new Vector2Float(x1, y1));
             } else
                 // else its an ID
                 sav = object.get(k).getAsInt();
@@ -462,31 +462,9 @@ public class LoadController {
 //        }
         return ret;
     }
-
-    /**
-     * Init new Arrays which haven't been serialized along the object
-     */
-    void initObjects(AbstractCanvasObject obj) {
-
-        obj.setConnections(new ArrayList<>());
-
-        if (obj instanceof HolonObject) {
-            ((HolonObject) obj).setElements(new ArrayList<>());
-        }
-
-        if (obj instanceof HolonSwitch) {
-           
-            ((HolonSwitch) obj).setGraphPoints(new LinkedList<>()); 
-            ((HolonSwitch) obj).reset();
-            ((HolonSwitch) obj).sampleGraph();
-        }
-
-        if (obj instanceof GroupNode) {
-            ((GroupNode) obj).setNodes(new ArrayList<>());
-            ((GroupNode) obj).setNodesIdx(new HashMap<>());
-        }
-    }
-
+    
+    
+    
     /**
      * Init Elements (set available energy, set new graph points)
      *
@@ -503,12 +481,12 @@ public class LoadController {
     }
 
     /**
+     * TODO(Tom2021-12-1) DELETE
      * Init Edges (set tags and reset source and target)
      *
      * @param edge the edge to be initialized
      */
     void initCpsEdge(Edge edge) {
-        edge.setTags(new ArrayList<>());
         edge.setA(null);
         edge.setB(null);
     }

+ 13 - 24
src/ui/controller/MultiPurposeController.java

@@ -2,14 +2,13 @@ package ui.controller;
 
 import java.util.HashMap;
 import java.util.Map.Entry;
+import java.util.Optional;
 
-import classes.Category;
-import classes.Edge;
-import classes.GroupNode;
-import classes.AbstractCanvasObject;
-import classes.HolonElement;
-import classes.HolonObject;
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
 import ui.model.Model;
+import ui.view.main.Category;
 
 /**
  * Controller for Multiple Purposes.
@@ -57,14 +56,16 @@ public class MultiPurposeController {
 	 *            Name of the Object
 	 * @return The Object
 	 */
-	public AbstractCanvasObject searchCatObj(Category category, String object) {
+	public Optional<AbstractCanvasObject> searchCatObj(Category category, String objectName) {
 
 		Integer idx;
-
-		if ((idx = category.getObjIdx().get(object)) == null || category.getObjIdx().size() < 1)
-			return null;
-		else
-			return category.getObjects().get(idx);
+		if (category.getObjIdx().isEmpty()) {
+			return Optional.empty();			
+		}
+		else if ((idx = category.getObjIdx().get(objectName)) == null) {
+			return Optional.empty();
+		}
+		return Optional.ofNullable(category.getObjects().get(idx));
 	}
 
 	/**
@@ -100,18 +101,6 @@ public class MultiPurposeController {
 			return upperNode.getNodes().get(idx);
 	}
 
-	/**
-	 * Search the Element by ID.
-	 * 
-	 * @param object
-	 *            the Holon Object
-	 * @param idEle
-	 *            the Element ID
-	 * @return The Holon Element
-	 */
-	public HolonElement searchEleById(HolonObject object, int idEle) {
-		return object.searchElementById(idEle);
-	}
 
 	/**
 	 * Search Edge between 2 Objects.

+ 11 - 10
src/ui/controller/NodeController.java

@@ -1,9 +1,5 @@
 package ui.controller;
 
-import classes.AbstractCanvasObject;
-import classes.Edge;
-import classes.Node;
-import classes.GroupNode;
 import ui.model.Model;
 import utility.Vector2Int;
 
@@ -12,6 +8,11 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.LinkedList;
 
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
+import model.Node;
+
 
 class NodeController {
 
@@ -269,16 +270,16 @@ class NodeController {
 		int y = temp.getPosition().getY() - point.y;
 
 		if (y < 0)
-			y = 0 + model.getScaleDiv2() + 1;
+			y = 0 + Model.getScaleDiv2() + 1;
 		if (upperNode != null) {
-			if (x < model.getScaleDiv2() + 1)
-				x = model.getScaleDiv2() + 1;
+			if (x < Model.getScaleDiv2() + 1)
+				x = Model.getScaleDiv2() + 1;
 		} else if (x < 0)
-			x = 0 + model.getScaleDiv2() + 1;
+			x = 0 + Model.getScaleDiv2() + 1;
 		if (x > model.getCanvasX())
-			x = model.getCanvasX() - model.getScaleDiv2() - 1;
+			x = model.getCanvasX() - Model.getScaleDiv2() - 1;
 		if (y > model.getCanvasX())
-			y = model.getCanvasY() - model.getScaleDiv2() - 1;
+			y = model.getCanvasY() - Model.getScaleDiv2() - 1;
 
 		temp.setPosition(new Vector2Int(x, y));
 

+ 24 - 45
src/ui/controller/ObjectController.java

@@ -1,13 +1,16 @@
 package ui.controller;
 
+import java.util.AbstractMap.SimpleEntry;
+
+import model.AbstractCanvasObject;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
+
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Optional;
 
-import classes.AbstractCanvasObject;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.Pair;
 import ui.model.Model;
 
 /**
@@ -52,16 +55,6 @@ public class ObjectController {
 		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.
 	 *
@@ -70,7 +63,7 @@ public class ObjectController {
 	 */
 	public void addElementIntoCanvasObject(HolonObject object, HolonElement element) {
 		element.setSaving(null);
-		addElement(object, element);
+		object.addElement(element);
 	}
 
 	/**
@@ -98,24 +91,27 @@ public class ObjectController {
 	 * @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);
+	public void addElementIntoCategoryObject(String category, String objectName, HolonElement element) {
+		element.setSaving(new SimpleEntry<>(category, objectName));
+		Optional<AbstractCanvasObject> object = mpC.searchCatObj(mpC.searchCat(category), objectName);
+		object.ifPresent(obj -> ((HolonObject) obj).addElement(element));
+		if(object.isEmpty()) {
+			System.out.println(String.format("Category %s ObjectName %s element %s", category, objectName, element.getName()));
+			//throw new UnsupportedOperationException();
+		}
 	}
 
 	/**
 	 * 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 category   the Category
+	 * @param objectName 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);
+	public void addNewElementIntoCategoryObject(String category, String objectName, String element, float energy) {
+		HolonElement ele = new HolonElement(null, element, energy);
+		addElementIntoCategoryObject(category, objectName, ele);
 	}
 
 	/**
@@ -146,7 +142,6 @@ public class ObjectController {
 		model.getSelectedObjects().add(obj);
 	}
 
-
 	/**
 	 * add an Object to selectedObject.
 	 *
@@ -156,22 +151,6 @@ public class ObjectController {
 		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);
-	}
-
-
 	/**
 	 * Get the number of HolonObjects in the given List
 	 *

+ 21 - 8
src/ui/controller/SaveController.java

@@ -1,21 +1,34 @@
 package ui.controller;
 
-import classes.*;
-import classes.IdCounter.CounterType;
-
 import com.google.gson.JsonObject;
 import com.google.gson.JsonPrimitive;
 import com.google.gson.reflect.TypeToken;
 
+import model.*;
+
 import org.apache.commons.compress.archivers.ArchiveException;
 import org.apache.commons.compress.archivers.ArchiveOutputStream;
 import org.apache.commons.compress.archivers.ArchiveStreamFactory;
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 import org.apache.commons.compress.utils.IOUtils;
+
+import ui.model.IdCounter;
 import ui.model.Model;
-import java.awt.geom.Point2D;
-import java.io.*;
-import java.util.*;
+import utility.Vector2Float;
+import ui.model.IdCounter.CounterType;
+import ui.view.main.Category;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.LinkedList;
 import java.util.List;
 
 /**
@@ -273,7 +286,7 @@ public class SaveController {
     /**
      * Put the UnitGraphs of Switches or Elements into Json
      */
-    void unitgraphToJson(GRAPHTYPE type, JsonObject file, int id, LinkedList<Point2D.Double> graph) {
+    void unitgraphToJson(GRAPHTYPE type, JsonObject file, int id, LinkedList<Vector2Float> graph) {
 
         JsonObject temp = new JsonObject();
         String key = null;
@@ -303,7 +316,7 @@ public class SaveController {
     /**
      * Put the UnitGraphs of Switches or Elements into Json
      */
-    void unitgraphTESTToJson(JsonObject file, int id, LinkedList<Point2D.Double> graph) {
+    void unitgraphTESTToJson(JsonObject file, int id, LinkedList<Vector2Float> graph) {
 
         JsonObject temp = new JsonObject();
         String key = null;

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

@@ -1,6 +1,5 @@
 package ui.controller;
 
-import classes.*;
 import ui.model.IntermediateCableWithState;
 import ui.model.DecoratedCable;
 import ui.model.DecoratedCable.CableState;
@@ -19,6 +18,8 @@ import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.ListIterator;
 
+import model.*;
+
 
 /**
  * Controller for Simulation.
@@ -31,8 +32,6 @@ public class SimulationManager {
 	private HashMap<Integer, DecoratedState> saves = new HashMap<Integer, DecoratedState>();
 	private HashMap<Integer, VisualRepresentationalState> savesVisual = new HashMap<Integer, VisualRepresentationalState>();
 	
-	private HashMap<Integer, FlexManager> savesFlexManger = new HashMap<Integer, FlexManager>();
-	
 	private int timeStep;
 
 	/**
@@ -59,21 +58,6 @@ public class SimulationManager {
 	 * Determine if the Visuals should also be calculated
 	 */
 	public void calculateStateForTimeStep(int timestep, boolean updateVisual) {
-		boolean doesFlexManagerExist = savesFlexManger.containsKey(timestep);
-		boolean createNew = updateVisual || !doesFlexManagerExist;
-		FlexManager newFlexManager;
-		if(createNew) {
-			newFlexManager = new FlexManager(model, timestep, savesFlexManger.get(timestep-1));
-			if(doesFlexManagerExist) newFlexManager.orderFlexFromList(savesFlexManger.get(timestep).getAllFlexesOrderedThisTimeStep());
-			savesFlexManger.put(timestep, newFlexManager);
-		}else {
-			newFlexManager = savesFlexManger.get(timestep);
-		}
-		
-
-		
-		
-		
 		HashMap<Edge, CableState> map = new HashMap<Edge, CableState>();
 		if(timestep > 0 && saves.containsKey(timestep-1)) //if the state before exist
 		{
@@ -90,7 +74,7 @@ public class SimulationManager {
 		
 		
 		ArrayList<MinimumNetwork> list =  new ArrayList<MinimumNetwork>();
-		MinimumModel minimumModel = new MinimumModel(model.getObjectsOnCanvas(), model.getEdgesOnCanvas());
+		MinimumModel minimumModel = new MinimumModel(model.getObjectsOnCanvas(), model.getEdgesOnCanvas(), model.getActualTimeStep());
 		//set all BreakedManuel Cable Burned:
 		for(IntermediateCableWithState cable : minimumModel.getEdgeList()) {
 			if(cable.getModel().isBreakedManuel()) cable.setState(CableState.Burned);
@@ -109,9 +93,10 @@ public class SimulationManager {
 			doAnotherLoop = false;
 			list = calculateNetworks(minimumModel, timestep, leftOver);
 			for(MinimumNetwork net : list) {
-				float energyOnCables = net.getHolonObjectList().stream().filter(object -> object.getEnergyAtTimeStepWithFlex(timestep, newFlexManager) > 0.0f).map(object -> object.getEnergyAtTimeStepWithFlex(timestep, newFlexManager)).reduce(0.0f, ((a,b) -> a + b));
+				
+				float energyOnCables = net.getHolonObjectList().stream().filter(object -> object.getActualEnergy() > 0.0f).map(object -> object.getActualEnergy()).reduce(0.0f, ((a,b) -> a + b));
 				//find the cable with the energy supplied from his two connected objects are the biggest, from all cables that the network give more energy than the cablecapacity. 
-				IntermediateCableWithState cable = net.getEdgeList().stream().filter(aCable -> energyOnCables > aCable.getModel().getCapacity() && !aCable.getModel().isUnlimitedCapacity()).max((lhs,rhs) -> Float.compare(lhs.getEnergyFromConnetedAtTimestep(timestep, newFlexManager), rhs.getEnergyFromConnetedAtTimestep(timestep, newFlexManager))).orElse(null);
+				IntermediateCableWithState cable = net.getEdgeList().stream().filter(aCable -> energyOnCables > aCable.getModel().maxCapacity && !aCable.getModel().isUnlimitedCapacity()).max((lhs,rhs) -> Float.compare(lhs.getEnergyFromConneted(), rhs.getEnergyFromConneted())).orElse(null);
 				if(cable != null) {
 					cable.setState(CableState.Burned);
 					doAnotherLoop = true;
@@ -121,7 +106,7 @@ public class SimulationManager {
 		ArrayList<DecoratedNetwork> decorNetworks = new ArrayList<DecoratedNetwork>();
 		FairnessModel actualFairnessModel = model.getFairnessModel();
 		for (MinimumNetwork net : list) {
-			decorNetworks.add(new DecoratedNetwork(net, timestep, actualFairnessModel, newFlexManager));
+			decorNetworks.add(new DecoratedNetwork(net, timestep, actualFairnessModel));
 		}
 
 		
@@ -133,7 +118,7 @@ public class SimulationManager {
 			leftOverDecoratedCables.add(new DecoratedCable(cable.getModel(), cable.getState(), 0.0f));
 		}
 		ArrayList<DecoratedSwitch> listOfDecoratedSwitches = decorateSwitches(minimumModel, timestep);
-		DecoratedState stateFromThisTimestep = new DecoratedState(decorNetworks, leftOverDecoratedCables, listOfDecoratedSwitches, newFlexManager, timestep);
+		DecoratedState stateFromThisTimestep = new DecoratedState(decorNetworks, leftOverDecoratedCables, listOfDecoratedSwitches, timestep);
 		saves.put(timestep, stateFromThisTimestep);
 		if(updateVisual)savesVisual.put(timestep, new VisualRepresentationalState(stateFromThisTimestep, minimumModel));
 
@@ -246,15 +231,6 @@ public class SimulationManager {
 	public VisualRepresentationalState getActualVisualRepresentationalState(){
 		return savesVisual.getOrDefault(timeStep, null);
 	}
-	public FlexManager getActualFlexManager() {
-		return savesFlexManger.getOrDefault(timeStep, null);
-	}
-	public void resetFlexManager(){
-		savesFlexManger.clear();
-	}
-	public void resetFlexManagerForTimeStep(int timestep) {
-		savesFlexManger.get(timestep).reset();
-	}
 	
 	public DecoratedState getDecorState(int timestep) {
 		return saves.get(timestep);

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

@@ -2,7 +2,7 @@ package ui.model;
 
 import java.util.ArrayList;
 
-import classes.HolonObject;
+import model.HolonObject;
 
 public class Consumer extends DecoratedHolonObject {
 

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

@@ -1,6 +1,6 @@
 package ui.model;
 
-import classes.Edge;
+import model.Edge;
 
 public class DecoratedCable {
 	public enum CableState{

+ 4 - 4
src/ui/model/DecoratedGroupNode.java

@@ -3,11 +3,11 @@ package ui.model;
 import java.util.ArrayList;
 import java.util.stream.Stream;
 
-import classes.Node;
 import jdk.jfr.Unsigned;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.Flexibility;
+import model.Flexibility;
+import model.GroupNode;
+import model.HolonElement;
+import model.Node;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 
 /**

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

@@ -1,6 +1,6 @@
 package ui.model;
 
-import classes.HolonObject;
+import model.HolonObject;
 
 public abstract class DecoratedHolonObject {
 	public enum HolonObjectState {

+ 20 - 22
src/ui/model/DecoratedNetwork.java

@@ -3,9 +3,9 @@ package ui.model;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
-import classes.HolonElement;
-import classes.HolonObject;
-import ui.controller.FlexManager;
+
+import model.HolonElement;
+import model.HolonObject;
 import ui.model.DecoratedCable.CableState;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.Model.FairnessModel;
@@ -16,17 +16,15 @@ public class DecoratedNetwork {
 	private ArrayList<Consumer> consumerSelfSuppliedList = new ArrayList<Consumer>();
 	private ArrayList<Passiv> passivNoEnergyList = new ArrayList<Passiv>();
 	private ArrayList<DecoratedCable> decoratedCableList = new ArrayList<DecoratedCable>();
-	private int timestep;
 
-	public DecoratedNetwork(MinimumNetwork minimumNetwork, int Iteration, FairnessModel actualFairnessModel, FlexManager flexManager){	
-		this.timestep = Iteration;
+	public DecoratedNetwork(MinimumNetwork minimumNetwork, int Iteration, FairnessModel actualFairnessModel){	
 		switch(actualFairnessModel) {
 		case AllEqual:
-			calculateAllEqualNetwork(minimumNetwork, Iteration, flexManager);
+			calculateAllEqualNetwork(minimumNetwork, Iteration);
 			break;
 		case MininumDemandFirst:
 		default:
-			calculateMinimumDemandFirstNetwork(minimumNetwork, Iteration, flexManager);
+			calculateMinimumDemandFirstNetwork(minimumNetwork, Iteration);
 			break;		
 		}
 	}
@@ -57,8 +55,8 @@ public class DecoratedNetwork {
 	
 	
 	//Calculations:
-	private void calculateMinimumDemandFirstNetwork(MinimumNetwork minimumNetwork, int Iteration, FlexManager flexManager) {
-		categorize(minimumNetwork, Iteration, flexManager);
+	private void calculateMinimumDemandFirstNetwork(MinimumNetwork minimumNetwork, int Iteration) {
+		categorize(minimumNetwork, Iteration);
 		//Sort SupplierList according to the EnergyToSupplyNetwork maximum first.
 		//Sort ConsumerList according to the MinimumConsumingElementEnergy minimum first.
 		supplierList.sort((Supplier lhs,Supplier rhs) -> -Float.compare(lhs.getEnergyToSupplyNetwork(), rhs.getEnergyToSupplyNetwork()));
@@ -184,8 +182,8 @@ public class DecoratedNetwork {
 
 
 
-	private void calculateAllEqualNetwork(MinimumNetwork minimumNetwork, int Iteration, FlexManager flexManager) {
-		categorize(minimumNetwork, Iteration, flexManager);
+	private void calculateAllEqualNetwork(MinimumNetwork minimumNetwork, int Iteration) {
+		categorize(minimumNetwork, Iteration);
 		float energyToSupplyInTheNetwork = supplierList.stream().map(supplier -> supplier.getEnergyToSupplyNetwork() - supplier.getEnergySupplied()).reduce( 0.0f, (a, b) -> a + b);
 		float energyForEachConsumer = (consumerList.size() != 0) ? energyToSupplyInTheNetwork / consumerList.size() : 0.0f;
 		decorateCable(minimumNetwork, energyToSupplyInTheNetwork);
@@ -226,20 +224,20 @@ public class DecoratedNetwork {
 			setConsumerState(con);
 		}
 	}
-	private void categorize(MinimumNetwork minimumNetwork, int Iteration, FlexManager flexManager) {
+	private void categorize(MinimumNetwork minimumNetwork, int Iteration) {
 		//Categorize
 		for(HolonObject hObject: minimumNetwork.getHolonObjectList()) {
-			float energyNeeded = hObject.getEnergyNeededFromConsumingElementsWithFlex(Iteration, flexManager);
-			float energySelfProducing = hObject.getEnergySelfProducingFromProducingElementsWithFlex(Iteration, flexManager);
+			float energyNeeded = hObject.getEnergyNeededFromConsumingElements();
+			float energySelfProducing = hObject.getEnergySelfProducingFromProducingElements();
 			if(energyNeeded < energySelfProducing) {
 				Supplier sup = new Supplier(hObject, energySelfProducing - energyNeeded, energyNeeded);
 				supplierList.add(sup);
 			} else if (energyNeeded > energySelfProducing) {
 				Consumer con = new Consumer(hObject);
 				con.setEnergyNeededFromNetwork(energyNeeded - energySelfProducing);
-				con.setMinimumConsumingElementEnergy(hObject.getMinimumConsumingElementEnergyWithFlex(Iteration, flexManager));
-				con.setEnergyFromConsumingElemnets(hObject.getEnergyNeededFromConsumingElementsWithFlex(Iteration, flexManager));
-				con.setEnergySelfSupplied(hObject.getEnergySelfProducingFromProducingElementsWithFlex(Iteration, flexManager));
+				con.setMinimumConsumingElementEnergy(hObject.getMinimumConsumingElementEnergy());
+				con.setEnergyFromConsumingElemnets(hObject.getEnergyNeededFromConsumingElements());
+				con.setEnergySelfSupplied(hObject.getEnergySelfProducingFromProducingElements());
 				consumerList.add(con);
 			}else if(energyNeeded == energySelfProducing) {
 				
@@ -249,9 +247,9 @@ public class DecoratedNetwork {
 				} else {
 					Consumer con = new Consumer(hObject);
 					con.setEnergyNeededFromNetwork(0.0f);
-					con.setMinimumConsumingElementEnergy(hObject.getMinimumConsumingElementEnergyWithFlex(Iteration, flexManager));
-					con.setEnergyFromConsumingElemnets(hObject.getEnergyNeededFromConsumingElementsWithFlex(Iteration, flexManager));
-					con.setEnergySelfSupplied(hObject.getEnergySelfProducingFromProducingElementsWithFlex(Iteration, flexManager));
+					con.setMinimumConsumingElementEnergy(hObject.getMinimumConsumingElementEnergy());
+					con.setEnergyFromConsumingElemnets(hObject.getEnergyNeededFromConsumingElements());
+					con.setEnergySelfSupplied(hObject.getEnergySelfProducingFromProducingElements());
 					consumerSelfSuppliedList.add(con);
 				}
 				
@@ -391,7 +389,7 @@ public class DecoratedNetwork {
 		eleList.addAll(consumerSelfSuppliedList.stream().flatMap(con-> con.getModel().getElements().stream()).collect(Collectors.toList()));
 		eleList.addAll(supplierList.stream().flatMap(con-> con.getModel().getElements().stream()).collect(Collectors.toList()));
 		eleList.addAll(passivNoEnergyList.stream().flatMap(con-> con.getModel().getElements().stream()).collect(Collectors.toList()));
-		return  eleList.stream().filter(ele -> (ele.flexList.stream().anyMatch(flex -> flex.offered && flex.fulfillsConstrains())) ).map(ele -> -ele.getEnergyAtTimeStep(timestep) ).collect(Collectors.toList()) ;
+		return  eleList.stream().filter(ele -> (ele.flexList.stream().anyMatch(flex -> flex.offered)) ).map(ele -> -ele.getActualEnergy() ).collect(Collectors.toList()) ;
 	}
 	
 	public List<Float> getListOfEnergyInProductionThatIsOfferedByFlexibilitiesInThisNetwork(){

+ 1 - 9
src/ui/model/DecoratedState.java

@@ -2,21 +2,16 @@ package ui.model;
 
 import java.util.ArrayList;
 
-import ui.controller.FlexManager;
-
-
 public class DecoratedState {
 	int timestepOfState;
 	ArrayList<DecoratedNetwork> networkList;
 	ArrayList<DecoratedCable> leftOverEdges;
 	ArrayList<DecoratedSwitch> decoratedSwitches;
-	FlexManager flexManager;
-	public DecoratedState(ArrayList<DecoratedNetwork> networkList, ArrayList<DecoratedCable> leftOverEdges, ArrayList<DecoratedSwitch> decoratedSwitches, FlexManager flexManager , int timestepOfState){
+	public DecoratedState(ArrayList<DecoratedNetwork> networkList, ArrayList<DecoratedCable> leftOverEdges, ArrayList<DecoratedSwitch> decoratedSwitches, int timestepOfState){
 		this.networkList = networkList;
 		this.leftOverEdges = leftOverEdges;
 		this.decoratedSwitches = decoratedSwitches;
 		this.timestepOfState = timestepOfState;
-		this.flexManager = flexManager;
 	}
 	public ArrayList<DecoratedNetwork> getNetworkList() {
 		return networkList;
@@ -27,9 +22,6 @@ public class DecoratedState {
 	public ArrayList<DecoratedSwitch> getDecoratedSwitches() {
 		return decoratedSwitches;
 	}
-	public FlexManager getFlexManager() {
-		return flexManager;
-	}
 	public int getTimestepOfState() {
 		return timestepOfState;
 	}

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

@@ -1,6 +1,6 @@
 package ui.model;
 
-import classes.HolonSwitch;
+import model.HolonSwitch;
 
 public class DecoratedSwitch {
 	public enum SwitchState{

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

@@ -1,6 +1,6 @@
 package ui.model;
 
-import classes.AbstractCanvasObject;
+import model.AbstractCanvasObject;
 /**
  * For the Visual State.
  * @author Tom

+ 1 - 1
src/classes/IdCounter.java → src/ui/model/IdCounter.java

@@ -1,4 +1,4 @@
-package classes;
+package ui.model;
 
 import com.google.gson.annotations.Expose;
 

+ 5 - 6
src/ui/model/IntermediateCableWithState.java

@@ -1,8 +1,7 @@
 package ui.model;
 
-import classes.Edge;
-import classes.HolonObject;
-import ui.controller.FlexManager;
+import model.Edge;
+import model.HolonObject;
 import ui.model.DecoratedCable.CableState;
 
 /**
@@ -28,10 +27,10 @@ public class IntermediateCableWithState {
 		return model;
 	}
 	//ugly
-	public float getEnergyFromConnetedAtTimestep(int iteration, FlexManager flexManager) {
+	public float getEnergyFromConneted() {
 		float energy = 0.0f;
-		if(model.getA() instanceof HolonObject && ((HolonObject) model.getA()).getEnergyAtTimeStepWithFlex(iteration, flexManager) > 0) energy += ((HolonObject) model.getA()).getEnergyAtTimeStepWithFlex(iteration, flexManager);
-		if(model.getB() instanceof HolonObject && ((HolonObject) model.getB()).getEnergyAtTimeStepWithFlex(iteration, flexManager) > 0) energy += ((HolonObject) model.getB()).getEnergyAtTimeStepWithFlex(iteration, flexManager);
+		if(model.getA() instanceof HolonObject && ((HolonObject) model.getA()).getActualEnergy() > 0) energy += ((HolonObject) model.getA()).getActualEnergy();
+		if(model.getB() instanceof HolonObject && ((HolonObject) model.getB()).getActualEnergy() > 0) energy += ((HolonObject) model.getB()).getActualEnergy();
 		return energy;
 	}
 	

+ 3 - 3
src/ui/model/IntermediateCalculationCable.java

@@ -1,8 +1,8 @@
 package ui.model;
 
-import classes.AbstractCanvasObject;
-import classes.Edge;
-import classes.GroupNode;
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
 
 /**
  * A VisualRepresentation to represent a connection from a UpperNode to a AbstactCpsObject, but actually the UpperNode is not connected.

+ 18 - 12
src/ui/model/MinimumModel.java

@@ -3,12 +3,12 @@ package ui.model;
 import java.util.ArrayList;
 import java.util.HashMap;
 
-import classes.AbstractCanvasObject;
-import classes.Edge;
-import classes.Node;
-import classes.GroupNode;
-import classes.HolonObject;
-import classes.HolonSwitch;
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
+import model.HolonObject;
+import model.HolonSwitch;
+import model.Node;
 import ui.model.DecoratedCable.CableState;
 
 /**
@@ -39,15 +39,17 @@ public class MinimumModel {
 		return inGroupEdges;
 	}
 
-	public MinimumModel(ArrayList<AbstractCanvasObject> abstractObjectList, ArrayList<Edge> edgeList) {// Constructor because of old Model
+	public MinimumModel(ArrayList<AbstractCanvasObject> abstractObjectList, ArrayList<Edge> edgeList, int timestep) {// Constructor because of old Model
 		for (AbstractCanvasObject aCps : abstractObjectList) {
 			if (aCps instanceof HolonObject) {
-				holonObjectList.add((HolonObject) aCps);
+				HolonObject hObject = (HolonObject) aCps;
+				hObject.calculateState(timestep);
+				holonObjectList.add(hObject);
 			}
 			else if (aCps instanceof Node) nodeList.add((Node) aCps);
 			else if (aCps instanceof HolonSwitch) switchList.add((HolonSwitch) aCps);
 			else if(aCps instanceof GroupNode) {
-				addUpperObjects((GroupNode)aCps);
+				addGroupNodeObjects((GroupNode)aCps, timestep);
 				uppderNodeList.add((GroupNode)aCps);
 			}
 		}
@@ -68,13 +70,17 @@ public class MinimumModel {
 		}
 	}
 
-	private void addUpperObjects(GroupNode aUpperNode) {
+	private void addGroupNodeObjects(GroupNode aUpperNode, int timestep) {
 		for(AbstractCanvasObject aCps : aUpperNode.getNodes()) {
-			if (aCps instanceof HolonObject) holonObjectList.add((HolonObject) aCps);
+			if (aCps instanceof HolonObject) {
+				HolonObject hObject = (HolonObject) aCps;
+				hObject.calculateState(timestep);
+				holonObjectList.add(hObject);
+			}
 			else if (aCps instanceof Node) nodeList.add((Node) aCps);
 			else if (aCps instanceof HolonSwitch) switchList.add((HolonSwitch) aCps);
 			else if(aCps instanceof GroupNode) {
-				addUpperObjects((GroupNode)aCps);
+				addGroupNodeObjects((GroupNode)aCps, timestep);
 				uppderNodeList.add((GroupNode)aCps);
 			}
 			inGroupObjects.put(aCps, aUpperNode);

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

@@ -2,8 +2,8 @@ package ui.model;
 
 import java.util.ArrayList;
 
-import classes.AbstractCanvasObject;
-import classes.HolonObject;
+import model.AbstractCanvasObject;
+import model.HolonObject;
 
 public class MinimumNetwork {
 	private ArrayList<HolonObject> holonObjectList = new ArrayList<HolonObject>();

+ 34 - 116
src/ui/model/Model.java

@@ -1,10 +1,10 @@
 package ui.model;
 
-import java.awt.Color;
+import java.util.AbstractMap.SimpleEntry;
 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;
@@ -12,20 +12,17 @@ import java.util.stream.Collectors;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 
-import TypeAdapter.AbstractCpsObjectAdapter;
-import TypeAdapter.ColorAdapter;
-import TypeAdapter.PairAdapter;
-import TypeAdapter.PositionAdapter;
-import classes.AbstractCanvasObject;
-import classes.Category;
-import classes.Edge;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.HolonSwitch;
-import classes.Node;
-import classes.Pair;
-import interfaces.ObjectListener;
+import adapter.AbstractCpsObjectAdapter;
+import adapter.PairAdapter;
+import adapter.PositionAdapter;
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
+import model.HolonSwitch;
+import model.Node;
+import ui.view.main.Category;
 import utility.Vector2Int;
 
 /**
@@ -39,9 +36,8 @@ public class Model {
 	
     private static final int GRAPH_ITERATIONS = 100;
     // Global Variables
-    private static int sCALE = 50; // Picture Scale
-    private static int sCALEdIV2 = sCALE / 2;
-    public String[] colNames = {"Field", "Information"};
+    private static int scale = 50; // Picture Scale
+    private static int halfScale = scale / 2;
     // Canvas Attributes
     private String imgPath = "";
     private int backgroundMode = 0;
@@ -50,17 +46,14 @@ public class Model {
     private int canvasX = 3000;
     private int canvasY = 3000;
     private int curIteration = 0;
-    private HolonElement selectedHolonElement;
     private Edge selectedEdge;
     private Set<AbstractCanvasObject> selectedObjects = new HashSet<>();
     private Set<AbstractCanvasObject> clipboardObjects = new HashSet<>();
-    private HashMap<Integer, ArrayList<HolonElement>> eleToDelete;
     // Capacity for Edge
     private float maxCapacity;
    
     // Iteration Speed
     private int timerSpeed = 1000;
-    private int selectedID = 0;
     // number of the current autosave
     private int autoSaveNr = -1;
     // number of max simultaneous autosaves
@@ -114,7 +107,6 @@ public class Model {
     private ArrayList<Node> nodesOnCanvas= new ArrayList<Node>();
     private ArrayList<HolonSwitch> switchsOnCanvas= new ArrayList<HolonSwitch>();
     
-    private List<ObjectListener> objectListeners;
     private HashMap<Integer, GroupNode> hashcodeMap = new HashMap<>();
 
 
@@ -129,10 +121,8 @@ public class Model {
         setCategories(new ArrayList<>());
         setObjectsOnCanvas(new ArrayList<>());
         setEdgesOnCanvas(new ArrayList<>());
-        setObjectListeners(new LinkedList<>());
         setCgIdx(new HashMap<>());
         setCvsObjIdx(new HashMap<>());
-        setEleToDelete(new HashMap<>());
         initGson();
     }
 
@@ -154,23 +144,6 @@ public class Model {
         this.categories = categories;
     }
 
-    /**
-     * Transform the Arraylist of categories into a string of all objectName
-     * with a separation (',') between each name.
-     *
-     * @return String of all names separeted by ','
-     */
-    public String toStringCat() {
-        String text = "";
-        for (int i = 0; i < categories.size(); i++) {
-            if (text.equals("")) {
-                text = categories.get(i).getName();
-            } else {
-                text = text + ", " + categories.get(i).getName();
-            }
-        }
-        return text;
-    }
 
     /**
      * Returns all Objects on the Canvas.
@@ -226,23 +199,6 @@ public class Model {
         this.edgesOnCanvas.remove(edge);
     }
 
-    /**
-     * Returns the ObjectListener.
-     *
-     * @return the objectListeners
-     */
-    public List<ObjectListener> getObjectListeners() {
-        return objectListeners;
-    }
-
-    /**
-     * Sets the ObjectListener.
-     *
-     * @param linkedList the objectListeners to set
-     */
-    public void setObjectListeners(LinkedList<ObjectListener> linkedList) {
-        this.objectListeners = linkedList;
-    }
 
 
     /**
@@ -263,53 +219,34 @@ public class Model {
         this.selectedObjects = arr;
     }
 
-    /**
-     * Returns the Selected Holon Element.
-     *
-     * @return selected Holon Element
-     */
-    public HolonElement getSelectedHolonElement() {
-        return selectedHolonElement;
-    }
 
-    /**
-     * Sets the Selecte HolonElement.
-     *
-     * @param selectedHolonElement that is Selected
-     */
-    public void setSelectedHolonElement(HolonElement selectedHolonElement) {
-        this.selectedHolonElement = selectedHolonElement;
-    }
 
     /**
      * Returns the sCale (Scale for the Images).
      *
-     * @return sCALE
+     * @return scale
      */
     public int getScale() {
-        return sCALE;
+        return scale;
     }
 
+
     /**
-     * Sets the Image Scale.
+     * Returns scaledIV2 (The Scale divided by 2).
      *
-     * @param scale for the image
+     * @return scaledIV2
      */
-    public void setScale(int scale) {
-        sCALE = scale;
-        if ((sCALE & 1) == 0)
-            sCALEdIV2 = sCALE / 2;
-        else
-            sCALEdIV2 = (sCALE + 1) / 2;
+    public static int getScaleDiv2() {
+        return halfScale;
     }
-
     /**
-     * Returns sCALEdIV2 (The Scale divided by 2).
+     * Sets the Image Scale.
      *
-     * @return sCALEdIV2
+     * @param value for the image
      */
-    public int getScaleDiv2() {
-        return sCALEdIV2;
+    public static void setScale(int value) {
+    	scale = value;
+    	halfScale = (value + 1) / 2;
     }
 
     /**
@@ -323,11 +260,11 @@ public class Model {
 
 
     /**
-     * Returns cURiTERATION.
+     * Returns the current iteration.
      *
-     * @return cURiTERATION
+     * @return current iteration
      */
-    public int getCurrentIteration() {
+    public int getActualTimeStep() {
         return curIteration;
     }
 
@@ -336,8 +273,8 @@ public class Model {
      *
      * @param curIT the current Iteration
      */
-    public void setCurIteration(int curIT) {
-        this.curIteration = curIT;
+    public void setCurrentIteration(int value) {
+        this.curIteration = value;
     }
 
     /**
@@ -517,14 +454,6 @@ public class Model {
         this.canvasY = canvasY;
     }
 
-    public HashMap<Integer, ArrayList<HolonElement>> getEleToDelete() {
-        return this.eleToDelete;
-    }
-    //TODO eleToDelete is this necessary
-    public void setEleToDelete(HashMap<Integer, ArrayList<HolonElement>> theHash) {
-        this.eleToDelete = theHash;
-    }
-
 
     public List<HolonElement> getAllHolonElemnts() {
     	return getAllHolonObjectsOnCanvas().stream().flatMap(hO -> hO.getElements().stream()).collect(Collectors.toList());
@@ -723,8 +652,7 @@ public class Model {
         builder.setPrettyPrinting();
         builder.registerTypeAdapter(AbstractCanvasObject.class, new AbstractCpsObjectAdapter());
         builder.registerTypeAdapter(Vector2Int.class, new PositionAdapter());
-        builder.registerTypeAdapter(Color.class, new ColorAdapter());
-        builder.registerTypeAdapter(Pair.class, new PairAdapter());
+        builder.registerTypeAdapter(SimpleEntry.class, new PairAdapter());
         // use the builder and make a instance of the Gson
         this.setGson(builder.create());
 
@@ -786,15 +714,5 @@ public class Model {
 	public void setHolonObjectsOnCanvas(ArrayList<HolonObject> holonObjectsOnCanvas) {
 		this.holonObjectsOnCanvas = holonObjectsOnCanvas;
 	}
-	
-	public void defineLists() {
-		switchsOnCanvas.clear();
-		nodesOnCanvas.clear();
-		holonObjectsOnCanvas.clear();
-		for(AbstractCanvasObject aCps : this.objectsOnCanvas) {
-			if(aCps instanceof HolonObject)holonObjectsOnCanvas.add((HolonObject) aCps);
-			else if(aCps instanceof Node)nodesOnCanvas.add((Node) aCps);
-			else if(aCps instanceof HolonSwitch)switchsOnCanvas.add((HolonSwitch) aCps);
-		}
-	}
+
 }

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

@@ -1,6 +1,6 @@
 package ui.model;
 
-import classes.HolonObject;
+import model.HolonObject;
 
 public class Passiv extends DecoratedHolonObject {
 	public Passiv(HolonObject objectToLookAt) {

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

@@ -2,7 +2,7 @@ package ui.model;
 
 import java.util.ArrayList;
 
-import classes.HolonObject;
+import model.HolonObject;
 
 public class Supplier extends DecoratedHolonObject {
 

+ 5 - 5
src/ui/model/VisualRepresentationalState.java

@@ -7,12 +7,12 @@ import java.util.List;
 import java.util.ListIterator;
 import java.util.stream.Collectors;
 
-import classes.AbstractCanvasObject;
-import classes.Edge;
-import classes.Node;
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
+import model.HolonObject;
+import model.Node;
 import ui.model.ExitCable.ExitCableState;
-import classes.GroupNode;
-import classes.HolonObject;
 
 public class VisualRepresentationalState {
 	private ArrayList<Supplier> supplierList = new ArrayList<Supplier>();

+ 15 - 15
src/ui/view/canvas/AbstractCanvas.java

@@ -18,12 +18,12 @@ import javax.swing.JPanel;
 import javax.swing.JPopupMenu;
 import javax.swing.Timer;
 
-import classes.AbstractCanvasObject;
-import classes.Edge;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.Node;
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
+import model.Node;
 import ui.controller.Control;
 import ui.model.Model;
 import utility.Vector2Int;
@@ -139,7 +139,7 @@ public abstract class AbstractCanvas extends JPanel {
 			// width
 
 			// fixed x and y Position to the screen
-			int fixXPos = toolTipPos.getX() - (textWidth >> 1) + model.getScaleDiv2();
+			int fixXPos = toolTipPos.getX() - (textWidth >> 1) + Model.getScaleDiv2();
 			int fixYPos = toolTipPos.getY();
 
 			if (fixXPos < 0) {
@@ -219,18 +219,18 @@ public abstract class AbstractCanvas extends JPanel {
 		int lx, ly, hx, hy;
 
 		if (p.getA().getPosition().getX() > p.getB().getPosition().getX()) {
-			hx = p.getA().getPosition().getX() + model.getScaleDiv2() + 7;
-			lx = p.getB().getPosition().getX() + model.getScaleDiv2() - 7;
+			hx = p.getA().getPosition().getX() + Model.getScaleDiv2() + 7;
+			lx = p.getB().getPosition().getX() + Model.getScaleDiv2() - 7;
 		} else {
-			lx = p.getA().getPosition().getX() + model.getScaleDiv2() - 7;
-			hx = p.getB().getPosition().getX() + model.getScaleDiv2() + 7;
+			lx = p.getA().getPosition().getX() + Model.getScaleDiv2() - 7;
+			hx = p.getB().getPosition().getX() + Model.getScaleDiv2() + 7;
 		}
 		if (p.getA().getPosition().getY() > p.getB().getPosition().getY()) {
-			hy = p.getA().getPosition().getY() + model.getScaleDiv2() + 7;
-			ly = p.getB().getPosition().getY() + model.getScaleDiv2() - 7;
+			hy = p.getA().getPosition().getY() + Model.getScaleDiv2() + 7;
+			ly = p.getB().getPosition().getY() + Model.getScaleDiv2() - 7;
 		} else {
-			ly = p.getA().getPosition().getY() + model.getScaleDiv2() - 7;
-			hy = p.getB().getPosition().getY() + model.getScaleDiv2() + 7;
+			ly = p.getA().getPosition().getY() + Model.getScaleDiv2() - 7;
+			hy = p.getB().getPosition().getY() + Model.getScaleDiv2() + 7;
 		}
 
 		return new int[] { lx, ly, hx, hy };

+ 28 - 48
src/ui/view/canvas/Canvas.java

@@ -26,12 +26,13 @@ import javax.swing.SwingUtilities;
 
 import com.google.gson.JsonParseException;
 
-import classes.AbstractCanvasObject;
-import classes.Edge;
-import classes.GroupNode;
-import classes.HolonObject;
-import classes.HolonSwitch;
-import classes.Node;
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
+import model.HolonObject;
+import model.HolonSwitch;
+import model.Node;
+import preferences.ColorPreference;
 import ui.controller.Control;
 import ui.model.Consumer;
 import ui.model.DecoratedCable;
@@ -58,11 +59,13 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 
 	private static final long serialVersionUID = 1L;
 	public boolean disabled = false;
-	private boolean showSupplyBar = false;
 
 	GroupNode groupNode = null;
 
-	Color[] colors = new Color[6];
+	private static Color[] colors = { ColorPreference.HolonObject.Producer, ColorPreference.HolonObject.NotSupplied,
+			ColorPreference.HolonObject.PartiallySupplied, ColorPreference.HolonObject.Supplied,
+			ColorPreference.HolonObject.OverSupplied, ColorPreference.HolonObject.NoEnergy };
+
 
 	/**
 	 * Constructor.
@@ -75,12 +78,6 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 		toolTip = false;
 		this.controller = control;
 		this.model = mod;
-		colors[0] = getStateColor(HolonObjectState.PRODUCER);
-		colors[1] = getStateColor(HolonObjectState.NOT_SUPPLIED);
-		colors[2] = getStateColor(HolonObjectState.PARTIALLY_SUPPLIED);
-		colors[3] = getStateColor(HolonObjectState.SUPPLIED);
-		colors[4] = getStateColor(HolonObjectState.OVER_SUPPLIED);
-		colors[5] = getStateColor(HolonObjectState.NO_ENERGY);
 
 		scalediv20 = model.getScale() / 20;
 
@@ -239,7 +236,7 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 
 		itemAlign.addActionListener(actionEvent -> {
 			for (AbstractCanvasObject cps : model.getSelectedObjects())
-				align(cps, model.getScaleDiv2());
+				align(cps, Model.getScaleDiv2());
 			repaint();
 		});
 		itemPaste.addActionListener(actionEvent -> {
@@ -270,28 +267,11 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 	 * @param g Graphics
 	 */
 
-	protected Color getStateColor(HolonObjectState state) {
-		switch (state) {
-		case NOT_SUPPLIED:
-			return new Color(230, 120, 100);
-		case NO_ENERGY:
-			return Color.white;
-		case OVER_SUPPLIED:
-			return new Color(166, 78, 229);
-		case PARTIALLY_SUPPLIED:
-			return Color.yellow;
-		case PRODUCER:
-			return Color.lightGray;
-		case SUPPLIED:
-			return new Color(13, 175, 28);
-		default:
-			return Color.BLACK;
-		}
-	}
+
 
 	protected void paintCanvasObject(Graphics2D g, DecoratedHolonObject decoratedHolonObject) {
 		Vector2Int pos = decoratedHolonObject.getModel().getPosition();
-		Color statecolor = getStateColor(decoratedHolonObject.getState());
+		Color statecolor = ColorPreference.HolonObject.getStateColor(decoratedHolonObject.getState());
 		g.setColor(statecolor);
 		g.fillRect(pos.getX() - controller.getScaleDiv2(), pos.getY() - controller.getScaleDiv2(),
 				controller.getScale(), controller.getScale());
@@ -309,8 +289,8 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 	protected void paintConsumer(Graphics2D g, Consumer con) {
 		paintCanvasObject(g, con);
 		drawCanvasObjectString(g, con.getModel().getPosition(), -con.getEnergyNeededFromNetwork());
-		if (showSupplyBar) {
-			paintSupplyBar(g, con.getSupplyBarPercentage(), getStateColor(con.getState()),
+		if (model.getShowSupplyBars()) {
+			paintSupplyBar(g, con.getSupplyBarPercentage(), ColorPreference.HolonObject.getStateColor(con.getState()),
 					con.getModel().getPosition());
 		}
 	}
@@ -330,15 +310,15 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 		Vector2Int start = cable.getModel().getA().getPosition();
 		Vector2Int end = cable.getModel().getB().getPosition();
 		float currentEnergy = cable.getFlowEnergy();
-		float capacity = cable.getModel().getCapacity();
+		float capacity = cable.getModel().maxCapacity;
 		boolean unlimited = cable.getModel().isUnlimitedCapacity();
 		switch (cable.getState()) {
 		case Burned:
-			g.setColor(Color.RED);
+			g.setColor(ColorPreference.Edge.Burned);
 			g.setStroke(new BasicStroke(2));
 			break;
 		case Working:
-			g.setColor(new Color(13, 175, 28));
+			g.setColor(ColorPreference.Edge.Working);
 			g.setStroke(new BasicStroke(unlimited ? 2f : (currentEnergy / capacity * 2f) + 1));
 			break;
 		}
@@ -362,7 +342,7 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 		Vector2Int start = eCable.getStart().getPosition();
 		Vector2Int end = eCable.getFinish().getPosition();
 		float currentEnergy = eCable.getCable().getFlowEnergy();
-		float capacity = eCable.getCable().getModel().getCapacity();
+		float capacity = eCable.getCable().getModel().maxCapacity;
 		boolean unlimited = eCable.getCable().getModel().isUnlimitedCapacity();
 		switch (eCable.getCable().getState()) {
 		case Burned:
@@ -462,7 +442,7 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 
 	// old code
 	void drawMarker(Graphics2D g) {
-		Color transparentGrey = new Color(128, 174, 247, 40);
+		Color transparentGrey = ColorPreference.Panel.ObjectSelection;
 		if (sx > x && sy > y) {
 			g.drawRect(x, y, sx - x, sy - y);
 			g.setColor(transparentGrey);
@@ -486,7 +466,7 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 		super.paintComponent(g);
 		Graphics2D g2d = (Graphics2D) g;
 		g2d.setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
-		// -->Old code
+		// -->Old code TODO(Tom2021-12-1): remove
 		if (drawEdge) {
 			g2d.setColor(Color.BLACK);
 			g2d.setStroke(new BasicStroke(1));
@@ -547,7 +527,7 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 		// Objects:
 		g2d.setColor(Color.BLUE);
 		g2d.setStroke(new BasicStroke(1));
-		Color transparentGrey = new Color(128, 174, 247, 40);
+		Color transparentGrey = ColorPreference.Panel.ObjectSelection;
 		for (AbstractCanvasObject aCps : model.getSelectedObjects()) {
 			if (aCps instanceof Node) {
 				Vector2Int pos = aCps.getPosition();
@@ -716,7 +696,7 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 			if (doubleclick && tempCps != null && tempCps instanceof GroupNode) {
 				controller.getGui().openNewUpperNodeTab((GroupNode) tempCps);
 			}
-			controller.calculateStateAndVisualForTimeStep(model.getCurrentIteration());
+			controller.calculateStateAndVisualForTimeStep(model.getActualTimeStep());
 
 			repaint();
 		}
@@ -810,8 +790,8 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 						y1 = y;
 						y2 = sy;
 					}
-					if (x1 <= cps.getPosition().getX() + model.getScaleDiv2()
-							&& y1 <= cps.getPosition().getY() + model.getScaleDiv2() && x2 >= cps.getPosition().getX()
+					if (x1 <= cps.getPosition().getX() + Model.getScaleDiv2()
+							&& y1 <= cps.getPosition().getY() + Model.getScaleDiv2() && x2 >= cps.getPosition().getX()
 							&& y2 >= cps.getPosition().getY()) {
 						tempSelected.add(cps);
 
@@ -985,7 +965,7 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 			int hy = positions[3];
 
 			// distance from a point to a line and between both Objects
-			if (l.ptLineDistSq(x - model.getScaleDiv2(), y - model.getScaleDiv2()) < 20 && x > lx && x < hx && y > ly
+			if (l.ptLineDistSq(x - Model.getScaleDiv2(), y - Model.getScaleDiv2()) < 20 && x > lx && x < hx && y > ly
 					&& y < hy) {
 				return p;
 			}
@@ -1025,7 +1005,7 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 		 * Align all Objects
 		 */
 		for (AbstractCanvasObject cps : model.getObjectsOnCanvas())
-			align(cps, 3 * model.getScaleDiv2());
+			align(cps, 3 * Model.getScaleDiv2());
 
 		/**
 		 * AutoSave new Positons

+ 21 - 22
src/ui/view/canvas/GroupNodeCanvas.java

@@ -10,12 +10,13 @@ import java.awt.event.MouseEvent;
 import java.io.IOException;
 import java.util.HashSet;
 
-import classes.AbstractCanvasObject;
-import classes.Edge;
-import classes.GroupNode;
-import classes.HolonObject;
-import classes.HolonSwitch;
-import classes.Node;
+import model.AbstractCanvasObject;
+import model.Edge;
+import model.GroupNode;
+import model.HolonObject;
+import model.HolonSwitch;
+import model.Node;
+import preferences.ColorPreference;
 import ui.controller.Control;
 import ui.model.Consumer;
 import ui.model.DecoratedCable;
@@ -30,7 +31,7 @@ import utility.ImageImport;
 import utility.Vector2Int;
 
 
-//TODO delete GroupNodeCanvas completely and only have canvas Class
+//TODO(Tom2021-12-1) delete GroupNodeCanvas completely and only have canvas Class
 public class GroupNodeCanvas extends Canvas {
 	private String parentPath;
 	private Component parentComponent;
@@ -118,16 +119,15 @@ public class GroupNodeCanvas extends Canvas {
 		}
 		// Test Selection
 		// Objects:
-		g2d.setColor(Color.BLUE);
 		g2d.setStroke(new BasicStroke(1));
-		Color transparentGrey = new Color(128, 174, 247, 40);
+		Color transparentGrey = ColorPreference.Panel.ObjectSelection;
 		for (AbstractCanvasObject aCps : model.getSelectedObjects()) {
 			if (aCps instanceof Node) {
 				Vector2Int pos = aCps.getPosition();
 				g2d.setColor(transparentGrey);
 				g2d.fillOval(pos.getX() - (int) (controller.getScaleDiv2()),
 						pos.getY() - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
-				g2d.setColor(Color.LIGHT_GRAY);
+				g2d.setColor(ColorPreference.Panel.ObjectSelectionBorder);
 				g2d.setStroke(new BasicStroke(2));
 				g2d.drawOval(pos.getX() - (int) (controller.getScaleDiv2()),
 						pos.getY() - (int) (controller.getScaleDiv2()), controller.getScale(), controller.getScale());
@@ -137,7 +137,7 @@ public class GroupNodeCanvas extends Canvas {
 				g2d.fillRect(pos.getX() - (int) (controller.getScaleDiv2() * 1.5f),
 						pos.getY() - (int) (controller.getScaleDiv2() * 1.5f), (int) (controller.getScale() * 1.5f),
 						(int) (controller.getScale() * 1.5f));
-				g2d.setColor(Color.LIGHT_GRAY);
+				g2d.setColor(ColorPreference.Panel.ObjectSelectionBorder);
 				g2d.setStroke(new BasicStroke(2));
 				g2d.drawRect(pos.getX() - (int) (controller.getScaleDiv2() * 1.5f),
 						pos.getY() - (int) (controller.getScaleDiv2() * 1.5f), (int) (controller.getScale() * 1.5f),
@@ -147,7 +147,6 @@ public class GroupNodeCanvas extends Canvas {
 		}
 		// maybeReplace:
 		if (mayBeReplaced != null) {
-			g2d.setColor(Color.RED);
 			Vector2Int pos = mayBeReplaced.getPosition();
 			g.drawImage(ImageImport.loadImage("/Images/replace.png"), pos.getX() + controller.getScaleDiv2(),
 					pos.getY() - controller.getScale(), controller.getScaleDiv2(), controller.getScaleDiv2(), null);
@@ -167,8 +166,8 @@ public class GroupNodeCanvas extends Canvas {
 
 			if (e.getX() > 0) {
 				for (AbstractCanvasObject cps : groupNode.getNodes()) {
-					cx = cps.getPosition().getX() - model.getScaleDiv2();
-					cy = cps.getPosition().getY() - model.getScaleDiv2();
+					cx = cps.getPosition().getX() - Model.getScaleDiv2();
+					cy = cps.getPosition().getY() - Model.getScaleDiv2();
 					if (x - controller.getScale() <= cx && y - controller.getScale() <= cy && x >= cx && y >= cy) {
 						tempCps = cps;
 
@@ -206,10 +205,10 @@ public class GroupNodeCanvas extends Canvas {
 					} else {
 						cps = ed.getA();
 					}
-					if (x - controller.getScale() <= (model.getScaleDiv2())
+					if (x - controller.getScale() <= (Model.getScaleDiv2())
 							&& y - controller.getScale() <= (scalediv20 + 5
 									+ (model.getScale() + scalediv20 + 10) * count)
-							&& x >= model.getScaleDiv2()
+							&& x >= Model.getScaleDiv2()
 							&& y >= (scalediv20 + 5 + (model.getScale() + scalediv20 + 10) * count)) {
 						tempCps = cps;
 						// If drawing an Edge (CTRL down)
@@ -304,7 +303,7 @@ public class GroupNodeCanvas extends Canvas {
 			if (doubleclick && tempCps != null && tempCps instanceof GroupNode) {
 				controller.getGui().openNewUpperNodeTab((GroupNode)tempCps);
 			}
-			controller.calculateStateAndVisualForTimeStep(model.getCurrentIteration());
+			controller.calculateStateAndVisualForTimeStep(model.getActualTimeStep());
 			repaint();
 		}
 	}
@@ -351,8 +350,8 @@ public class GroupNodeCanvas extends Canvas {
 						// TipText Position and name
 						toolTip = true;
 						toolTipText = tempCps.getName() + ", " + tempCps.getId();
-						toolTipPos.setX(tempCps.getPosition().getX() - model.getScaleDiv2());
-						toolTipPos.setY(tempCps.getPosition().getY() - model.getScaleDiv2());
+						toolTipPos.setX(tempCps.getPosition().getX() - Model.getScaleDiv2());
+						toolTipPos.setY(tempCps.getPosition().getY() - Model.getScaleDiv2());
 
 						// All Selected Objects
 						for (AbstractCanvasObject cps : model.getSelectedObjects()) {
@@ -401,8 +400,8 @@ public class GroupNodeCanvas extends Canvas {
 						y1 = y;
 						y2 = sy;
 					}
-					if (x1 <= cps.getPosition().getX() + model.getScaleDiv2()
-							&& y1 <= cps.getPosition().getY() + model.getScaleDiv2() && x2 >= cps.getPosition().getX()
+					if (x1 <= cps.getPosition().getX() + Model.getScaleDiv2()
+							&& y1 <= cps.getPosition().getY() + Model.getScaleDiv2() && x2 >= cps.getPosition().getX()
 							&& y2 >= cps.getPosition().getY()) {
 						tempSelected.add(cps);
 
@@ -429,7 +428,7 @@ public class GroupNodeCanvas extends Canvas {
 					}
 
 					if (x1 <= 0
-							&& y1 <= (int) (5 + (model.getScale() + scalediv20 + 10) * count) + model.getScaleDiv2()
+							&& y1 <= (int) (5 + (model.getScale() + scalediv20 + 10) * count) + Model.getScaleDiv2()
 							&& x2 >=  0
 							&& y2 >= (int) (5 + (model.getScale() + scalediv20 + 10) * count)) {
 						tempSelected.add(cps);

+ 8 - 2
src/ui/view/component/TrippleCheckBox.java

@@ -19,6 +19,12 @@ public class TrippleCheckBox extends JCheckBox implements Icon, ActionListener {
 	State state;
 	final static Icon icon = UIManager.getIcon("CheckBox.icon");
 
+	private static final Color borderColor = new Color(81, 81, 81);
+	private static final Color enabledBackgroundColor = new Color(51, 51, 51);
+	private static final Color disabledBackgroundColor = new Color(122, 138, 153);
+	
+	
+	
 	public TrippleCheckBox() {
 		this("", State.unselected);
 	}
@@ -60,12 +66,12 @@ public class TrippleCheckBox extends JCheckBox implements Icon, ActionListener {
 		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.setColor(c.isEnabled() ? enabledBackgroundColor : disabledBackgroundColor);
 		g.fillRect(x + 4, y + 4, w - 8, h - 8);
 
 		if (!c.isEnabled())
 			return;
-		g.setColor(new Color(81, 81, 81));
+		g.setColor(borderColor);
 		g.drawRect(x + 4, y + 4, w - 9, h - 9);
 	}
 

+ 8 - 7
src/ui/view/dialog/AddElementPopUp.java

@@ -16,8 +16,9 @@ import javax.swing.JPanel;
 import javax.swing.JTextField;
 import javax.swing.border.EmptyBorder;
 
-import classes.HolonElement;
-import classes.HolonObject;
+import model.HolonElement;
+import model.HolonObject;
+import preferences.ColorPreference;
 import utility.ImageImport;
 
 /**
@@ -150,7 +151,7 @@ public class AddElementPopUp extends JDialog {
 		hl = holonElement;
 		elementName.setText(hl.getName());
 		providedEnergy.setText(""+hl.getEnergy());
-		checkBoxActive.setSelected(hl.isActive());
+		checkBoxActive.setSelected(hl.active);
 		
 	}
 	
@@ -171,9 +172,9 @@ public class AddElementPopUp extends JDialog {
 				if(hl == null){
 					hl = new HolonElement(this.tempCps, elementName.getText(), energy);
 				} else {
-					hl.setEleName(elementName.getText());
-					hl.setEnergyPerElement(energy);
-					hl.setActive(checkBoxActive.isSelected());
+					hl.setName(elementName.getText());
+					hl.setEnergy(energy);
+					hl.active = checkBoxActive.isSelected();
 				}
 				dispose();
 			} catch (NumberFormatException e) {
@@ -189,7 +190,7 @@ public class AddElementPopUp extends JDialog {
 				errorString.setBounds(250, 8, 100, 20);
 				contentPanel.add(errorString);
 			}
-			elementName.setBackground(new Color(255, 50, 50));
+			elementName.setBackground(ColorPreference.Dialog.BackgroundColor);
 		}
 	}
 }

+ 9 - 10
src/ui/view/dialog/AddObjectPopUp.java

@@ -13,6 +13,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.AbstractMap.SimpleEntry;
 import java.util.ArrayList;
 
 import javax.swing.DefaultListModel;
@@ -30,10 +31,10 @@ import javax.swing.SwingConstants;
 import javax.swing.border.EmptyBorder;
 import javax.swing.filechooser.FileNameExtensionFilter;
 
-import classes.AbstractCanvasObject;
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.Pair;
+import model.AbstractCanvasObject;
+import model.HolonElement;
+import model.HolonObject;
+import preferences.ColorPreference;
 import ui.controller.Control;
 import utility.ImageImport;
 
@@ -165,7 +166,7 @@ public class AddObjectPopUp extends JDialog {
 				addElement.setActualHolonObject((HolonObject) toEdit);
 				addElement.setVisible(true);
 				HolonElement hl = addElement.getElement();
-				hl.setSaving(new Pair<>(givenCategory, objectName.getText()));
+				hl.setSaving(new SimpleEntry<>(givenCategory, objectName.getText()));
 				// if (hl != null) {
 				// hl.setSav(givenCategory);
 				// }
@@ -230,7 +231,7 @@ public class AddObjectPopUp extends JDialog {
 									if (editState) {
 										controller.delObjectCategory(givenCategory, toEdit.getName());
 										hElements.forEach(ele -> ele
-												.setSaving(new Pair<>(ele.getSaving().getKey(), objectName.getText())));
+												.setSaving(new SimpleEntry<>(ele.getSaving().getKey(), objectName.getText())));
 										controller.addObject(controller.searchCategory(givenCategory),
 												objectName.getText(), hElements, imagePath);
 
@@ -248,12 +249,10 @@ public class AddObjectPopUp extends JDialog {
 
 								dispose();
 							} else {
-								sourcePath.setBackground(new Color(255, 50, 50));
+								sourcePath.setBackground(ColorPreference.Dialog.BackgroundColor);
 							}
 						} else {
-							objectName.setBackground(new Color(255, 50, 50));
-							if (!sourcePath.getText().equals(filePath))
-								sourcePath.setBackground(new Color(255, 50, 50));
+							objectName.setBackground(ColorPreference.Dialog.BackgroundColor);
 
 						}
 					}

+ 3 - 2
src/ui/view/dialog/BackgroundPopUp.java

@@ -1,6 +1,5 @@
 package ui.view.dialog;
 
-import classes.GroupNode;
 import ui.controller.Control;
 import ui.model.Model;
 import ui.view.canvas.Canvas;
@@ -9,6 +8,8 @@ import utility.ImageImport;
 import javax.swing.*;
 import javax.swing.filechooser.FileNameExtensionFilter;
 
+import model.GroupNode;
+
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.FlowLayout;
@@ -103,7 +104,7 @@ public class BackgroundPopUp extends JDialog {
 		bgroup.add(rdbtnImagePixel);
 		bgroup.add(rdbtnStretched);
 		panelRadio.add(rdbtnCustom);
-		rdbtnCustom.setBackground(new Color(255, 255, 255));
+		rdbtnCustom.setBackground(Color.white);
 		bgroup.add(rdbtnCustom);
 		panel.setBackground(Color.WHITE);
 

+ 4 - 3
src/ui/view/dialog/CreateNewDialog.java

@@ -14,7 +14,8 @@ import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
-import classes.HolonObject;
+
+import model.HolonObject;
 import ui.controller.Control;
 
 
@@ -105,7 +106,7 @@ public class CreateNewDialog extends JDialog{
 		contentPanel.add(content, BorderLayout.CENTER);
 		contentPanel.add(makeBottemPanel(), BorderLayout.PAGE_END);
 		addSaveButtonLogik(); 
-		//TODO delete and make own iterface
+		//TODO(Tom2021-12-1) delete and make own iterface
 	    if(aOption == Option.Object) saveButton.setVisible(false);
 		add(contentPanel);	
 		setMinimumSize(new Dimension(400,50));
@@ -150,7 +151,7 @@ public class CreateNewDialog extends JDialog{
 	}
 
 	private void makeOldObjectPopUp(String categoryName) {
-		//TODO: del and make own on
+		//TODO(Tom2021-12-1): del and make own on
 		
 		HolonObject hO = new HolonObject("");
 		

+ 7 - 7
src/ui/view/dialog/CreateTemplatePopUp.java

@@ -4,6 +4,7 @@ import java.awt.BorderLayout;
 import java.awt.Choice;
 import java.io.File;
 import java.io.IOException;
+import java.util.AbstractMap.SimpleEntry;
 
 import javax.swing.DefaultListModel;
 import javax.swing.ImageIcon;
@@ -19,12 +20,11 @@ import javax.swing.JTextField;
 import javax.swing.border.EmptyBorder;
 import javax.swing.filechooser.FileNameExtensionFilter;
 
-import classes.Category;
-import classes.HolonElement;
-import classes.HolonObject;
-import classes.Pair;
+import model.HolonElement;
+import model.HolonObject;
 import ui.controller.Control;
 import ui.model.Model;
+import ui.view.main.Category;
 import utility.ImageImport;
 
 /**
@@ -299,7 +299,7 @@ public class CreateTemplatePopUp extends JDialog {
 			template.setName(textField_name.getText());
 			template.setImage(textField_imagePath.getText());
 			template.getElements().forEach(
-					ele -> ele.setSaving(new Pair<String, String>(choice
+					ele -> ele.setSaving(new SimpleEntry<String, String>(choice
 							.getSelectedItem(), template.getName())));
 			controller.addObject(controller.searchCategory(choice
 					.getItem(choice.getSelectedIndex())), template.getName(),
@@ -324,7 +324,7 @@ public class CreateTemplatePopUp extends JDialog {
 			listModel.addElement(he.getName()
 					+ ": " + he.getEnergy() + "U");
 			template.addElement(he);
-			he.setSaving(new Pair<>(category, textField_name.getText()));
+			he.setSaving(new SimpleEntry<>(category, textField_name.getText()));
 		}
 	}
 
@@ -358,7 +358,7 @@ public class CreateTemplatePopUp extends JDialog {
 					+ ": " + he.getEnergy() + "U");
 			template.removeElement(index);
 			template.addElement(he);
-			he.setSaving(new Pair<>(category, textField_name.getText()));
+			he.setSaving(new SimpleEntry<>(category, textField_name.getText()));
 		}
 	}
 

+ 2 - 2
src/ui/view/dialog/EditEdgesPopUp.java

@@ -16,7 +16,7 @@ import javax.swing.JRadioButton;
 import javax.swing.JTextField;
 import javax.swing.border.EmptyBorder;
 
-import classes.Edge;
+import model.Edge;
 import ui.controller.Control;
 import ui.view.canvas.Canvas;
 
@@ -170,7 +170,7 @@ public class EditEdgesPopUp extends JDialog {
 		 * }
 		 */
 		for (Edge edge : controller.getModel().getEdgesOnCanvas()) {
-			edge.setCapacity(cap);
+			edge.maxCapacity = cap;
         }
 		controller.resetSimulation();
 		controller.calculateStateAndVisualForCurrentTimeStep();

+ 2 - 2
src/ui/view/dialog/SearchPopUp.java

@@ -15,7 +15,7 @@ import javax.swing.JRadioButton;
 import javax.swing.JTextField;
 import javax.swing.border.EmptyBorder;
 
-import classes.AbstractCanvasObject;
+import model.AbstractCanvasObject;
 import ui.controller.Control;
 import ui.view.canvas.Canvas;
 
@@ -157,7 +157,7 @@ public class SearchPopUp extends JDialog {
 		JButton btnReplace = new JButton("Replace");
 		btnReplace.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent e) {
-				//TODO fix or remove SearchPopUp
+				//TODO(Tom2021-12-1) fix or remove SearchPopUp
 				System.out.println("REPLACE");
 				canvas.repaint();
 			}

+ 37 - 26
src/ui/view/information/FilterableGroupNode.java

@@ -5,11 +5,11 @@ import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
-import classes.Flexibility;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.Node;
 import jdk.jfr.Unsigned;
+import model.Flexibility;
+import model.GroupNode;
+import model.HolonElement;
+import model.Node;
 import ui.model.Consumer;
 import ui.model.DecoratedCable;
 import ui.model.DecoratedGroupNode;
@@ -44,10 +44,9 @@ public class FilterableGroupNode {
 	private ArrayList<ExitCable> exitCableList;
 	private ArrayList<DecoratedSwitch> switchList;
 	private ArrayList<FilterableGroupNode> groupNodeList;
-	private int iteration;
+
 	public FilterableGroupNode(GroupNode model, int iteration) {
 		this.model = model;
-		this.iteration = iteration;
 		this.supplierList = new ArrayList<Supplier>();
 		this.passivList = new ArrayList<Passiv>();
 		this.consumerList = new ArrayList<Consumer>();
@@ -60,7 +59,6 @@ public class FilterableGroupNode {
 
 	public FilterableGroupNode(DecoratedGroupNode dGroupNode, int iteration) {
 		model = dGroupNode.getModel();
-		this.iteration = iteration;
 		supplierList = dGroupNode.getSupplierList();
 		passivList = dGroupNode.getPassivList();
 		consumerList = dGroupNode.getConsumerList();
@@ -153,7 +151,6 @@ public class FilterableGroupNode {
 						.reduce(0, Integer::sum);
 	}
 
-
 	public PriorityCounts getPriorityCounts(Predicate<DecoratedHolonObject> stateFilter) {
 		PriorityCounts priority = new PriorityCounts();
 		objectStream().filter(stateFilter)
@@ -194,32 +191,46 @@ public class FilterableGroupNode {
 		}
 	}
 
-	public int getAmountOfElementsFromHolonObjects(Predicate<DecoratedHolonObject> stateFilter, Predicate<HolonElement> priorityFilter) {
-		return objectStream().filter(stateFilter).map(object -> (int)object.getModel().getElements().stream().filter(priorityFilter).count()).reduce(0,
-				Integer::sum)
-				+ groupNodeList.stream().map(groupNode -> groupNode.getAmountOfElementsFromHolonObjects(stateFilter, priorityFilter))
-				.reduce(0, Integer::sum);
-	}
-	public int getAmountOfAktiveElementsFromHolonObjects(Predicate<DecoratedHolonObject> stateFilter, Predicate<HolonElement> priorityFilter) {
-		return objectStream().filter(stateFilter).map(object -> (int)object.getModel().getElements().stream().filter(priorityFilter).count()).reduce(0, Integer::sum)
+	public int getAmountOfElementsFromHolonObjects(Predicate<DecoratedHolonObject> stateFilter,
+			Predicate<HolonElement> priorityFilter) {
+		return objectStream().filter(stateFilter)
+				.map(object -> (int) object.getModel().getElements().stream().filter(priorityFilter).count())
+				.reduce(0, Integer::sum)
 				+ groupNodeList.stream()
-						.map(groupNode -> groupNode.getAmountOfAktiveElementsFromHolonObjects(stateFilter, priorityFilter))
+						.map(groupNode -> groupNode.getAmountOfElementsFromHolonObjects(stateFilter, priorityFilter))
+						.reduce(0, Integer::sum);
+	}
+
+	public int getAmountOfAktiveElementsFromHolonObjects(Predicate<DecoratedHolonObject> stateFilter,
+			Predicate<HolonElement> priorityFilter) {
+		return objectStream().filter(stateFilter)
+				.map(object -> (int) object.getModel().getElements().stream().filter(priorityFilter).count())
+				.reduce(0, Integer::sum)
+				+ groupNodeList.stream().map(
+						groupNode -> groupNode.getAmountOfAktiveElementsFromHolonObjects(stateFilter, priorityFilter))
 						.reduce(0, Integer::sum);
 	}
 
 	public float getConsumption(Predicate<DecoratedHolonObject> stateFilter, Predicate<HolonElement> priorityFilter) {
-		return ((Stream<DecoratedHolonObject>) Stream.concat(this.consumerList.stream(), supplierList.stream())).filter(stateFilter).map(con -> con.getModel().getElements().stream().filter(priorityFilter.and(ele -> ele.getEnergyAtTimeStep(iteration) < 0)).map(ele -> -ele.getEnergyAtTimeStep(iteration)).reduce(0.0f, Float::sum)).reduce(0.f,
-				Float::sum)
-				+ groupNodeList.stream().map(groupNode -> groupNode.getConsumption(stateFilter, priorityFilter)).reduce(0.f,
-						Float::sum);
+		return ((Stream<DecoratedHolonObject>) Stream.concat(this.consumerList.stream(), supplierList.stream()))
+				.filter(stateFilter)
+				.map(con -> con.getModel().getElements().stream()
+						.filter(priorityFilter.and(ele -> ele.getActualEnergy() < 0))
+						.map(ele -> -ele.getActualEnergy()).reduce(0.0f, Float::sum))
+				.reduce(0.f, Float::sum)
+				+ groupNodeList.stream().map(groupNode -> groupNode.getConsumption(stateFilter, priorityFilter))
+						.reduce(0.f, Float::sum);
 	}
 
 	public float getProduction(Predicate<DecoratedHolonObject> stateFilter, Predicate<HolonElement> priorityFilter) {
-		return ((Stream<DecoratedHolonObject>) Stream.concat(this.consumerList.stream(), supplierList.stream())).filter(stateFilter).map(con -> con.getModel().getElements().stream().filter(priorityFilter.and(ele -> ele.getEnergyAtTimeStep(iteration) > 0)).map(ele -> ele.getEnergyAtTimeStep(iteration)).reduce(0.0f, Float::sum)).reduce(0.f,
-				Float::sum)
-				+ groupNodeList.stream().map(groupNode -> groupNode.getProduction(stateFilter, priorityFilter)).reduce(0.f,
-						Float::sum);
+		return ((Stream<DecoratedHolonObject>) Stream.concat(this.consumerList.stream(), supplierList.stream()))
+				.filter(stateFilter)
+				.map(con -> con.getModel().getElements().stream()
+						.filter(priorityFilter.and(ele -> ele.getActualEnergy() > 0))
+						.map(ele -> ele.getActualEnergy()).reduce(0.0f, Float::sum))
+				.reduce(0.f, Float::sum)
+				+ groupNodeList.stream().map(groupNode -> groupNode.getProduction(stateFilter, priorityFilter))
+						.reduce(0.f, Float::sum);
 	}
 
-
 }

+ 53 - 39
src/ui/view/information/HolonInformationPanel.java

@@ -27,14 +27,13 @@ import org.knowm.xchart.XChartPanel;
 import org.knowm.xchart.style.PieStyler;
 import org.knowm.xchart.style.PieStyler.LabelType;
 
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.HolonElement.Priority;
-import classes.HolonObject;
+import model.Flexibility;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
+import model.HolonElement.Priority;
 import preferences.ColorPreference;
 import ui.controller.Control;
-import ui.controller.FlexManager;
-import ui.controller.FlexManager.FlexWrapper;
 import ui.model.Consumer;
 import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedHolonObject;
@@ -44,11 +43,28 @@ import ui.model.Supplier;
 import utility.FormatFloat;
 
 public class HolonInformationPanel extends JPanel {
-	private Predicate<DecoratedHolonObject> stateFilter = (object) -> true;//= (object) -> object.getState() == HolonObjectState.PRODUCER;
+	private Predicate<DecoratedHolonObject> stateFilter = (object) -> true;// = (object) -> object.getState() ==
+																			// HolonObjectState.PRODUCER;
 	private Predicate<HolonElement> priorityFilter = (ele) -> ele.getPriority() == Priority.Low;
 	private final int defaultWidth = 50;
 	private final int defaultHeight = 200;
 
+	private static final Color[] supplyStateColors = new Color[] { ColorPreference.HolonObject.Producer,
+			ColorPreference.HolonObject.OverSupplied, ColorPreference.HolonObject.Supplied,
+			ColorPreference.HolonObject.PartiallySupplied, ColorPreference.HolonObject.NotSupplied,
+			ColorPreference.HolonObject.NoEnergy };
+	private static final Color[] productionColors = new Color[] { ColorPreference.Energy.Production,
+			ColorPreference.Energy.Consumption };
+	private static final Color[] activeColors = new Color[] { ColorPreference.Element.Active,
+			ColorPreference.Element.Inactive };
+	private static final Color[] flexibilityColors = new Color[] { ColorPreference.Flexibility.Offered,
+			ColorPreference.Flexibility.InUse, ColorPreference.Flexibility.OnCooldown,
+			ColorPreference.Flexibility.NotOffered, ColorPreference.Flexibility.Unavailable,
+			ColorPreference.Element.Priority.NoData };
+	private static final Color[] priorityColors = new Color[] { ColorPreference.Element.Priority.Essential,
+			ColorPreference.Element.Priority.High, ColorPreference.Element.Priority.Medium,
+			ColorPreference.Element.Priority.Low, ColorPreference.Element.Priority.NoData };
+	
 	private PieChart supplyChart = createSupplyStateChart();
 	private PieChart priorityChart = createPriorityChart();
 	private PieChart flexibilityChart = createFlexibilityChart();
@@ -75,11 +91,13 @@ public class HolonInformationPanel extends JPanel {
 
 		// UPDATE SUPPLY STATE
 		int producerAmount = decoratedGroupNode.getAmountOfSupplier(stateFilter);
-		int overSuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(stateFilter, HolonObjectState.OVER_SUPPLIED);
+		int overSuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(stateFilter,
+				HolonObjectState.OVER_SUPPLIED);
 		int suppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(stateFilter, HolonObjectState.SUPPLIED);
-		int partiallySuppliedAmount = decoratedGroupNode
-				.getAmountOfConsumerWithState(stateFilter, HolonObjectState.PARTIALLY_SUPPLIED);
-		int notSuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(stateFilter, HolonObjectState.NOT_SUPPLIED);
+		int partiallySuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(stateFilter,
+				HolonObjectState.PARTIALLY_SUPPLIED);
+		int notSuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(stateFilter,
+				HolonObjectState.NOT_SUPPLIED);
 		int noEnergyAmount = decoratedGroupNode.getAmountOfPassiv(stateFilter);
 
 		supplyChart.updatePieSeries("Producer", producerAmount);
@@ -91,7 +109,8 @@ public class HolonInformationPanel extends JPanel {
 		panelHolonObject.updateToolTips();
 
 		// UPDATE PRIORITYS
-		ui.view.information.FilterableGroupNode.PriorityCounts priorityCounts = decoratedGroupNode.getPriorityCounts(stateFilter);
+		ui.view.information.FilterableGroupNode.PriorityCounts priorityCounts = decoratedGroupNode
+				.getPriorityCounts(stateFilter);
 
 		priorityChart.updatePieSeries("Essential", priorityCounts.essential);
 		priorityChart.updatePieSeries("High", priorityCounts.high);
@@ -104,7 +123,7 @@ public class HolonInformationPanel extends JPanel {
 
 		// UPDATE PRODUCTION
 		float production = decoratedGroupNode.getProduction(stateFilter, priorityFilter);
-		float consumption = decoratedGroupNode.getConsumption(stateFilter,priorityFilter);
+		float consumption = decoratedGroupNode.getConsumption(stateFilter, priorityFilter);
 		System.out.println("production" + production);
 		System.out.println("consumption" + consumption);
 		float difference = Math.abs(production - consumption);
@@ -119,12 +138,11 @@ public class HolonInformationPanel extends JPanel {
 		int onCooldown = 0;
 		int notOffered = 0;
 		int unavailable = 0;
-		FlexManager manager = control.getSimManager().getActualFlexManager();
-		Stream<FlexWrapper> flexWrapperStream = decoratedGroupNode.getFlexibilitiesStream(stateFilter, priorityFilter)
-				.map(flex -> manager.getFlexWrapperFromFlexibility(flex));
-		List<FlexWrapper> wrapperList = flexWrapperStream.collect(Collectors.toList());
-		for (FlexWrapper wrapper : wrapperList) {
-			switch (wrapper.getState()) {
+
+		Stream<Flexibility> flexWrapperStream = decoratedGroupNode.getFlexibilitiesStream(stateFilter, priorityFilter);
+		List<Flexibility> flexList = flexWrapperStream.collect(Collectors.toList());
+		for (Flexibility flex : flexList) {
+			switch (flex.getState()) {
 			case IN_USE:
 				inUse++;
 				break;
@@ -156,7 +174,8 @@ public class HolonInformationPanel extends JPanel {
 
 		// UPDATE ActiveInActive
 		int activeAmount = decoratedGroupNode.getAmountOfAktiveElementsFromHolonObjects(stateFilter, priorityFilter);
-		int inactiveAmounts = decoratedGroupNode.getAmountOfElementsFromHolonObjects(stateFilter, priorityFilter) - activeAmount;
+		int inactiveAmounts = decoratedGroupNode.getAmountOfElementsFromHolonObjects(stateFilter, priorityFilter)
+				- activeAmount;
 		activeChart.updatePieSeries("Active", activeAmount);
 		activeChart.updatePieSeries("Inactive", inactiveAmounts);
 		panelActive.updateToolTips();
@@ -166,14 +185,16 @@ public class HolonInformationPanel extends JPanel {
 	}
 
 	private FilterableGroupNode multiSelectionToFilterableGroupNode() {
-		FilterableGroupNode temp = new FilterableGroupNode(new GroupNode("Temp"), control.getModel().getCurrentIteration());
+		FilterableGroupNode temp = new FilterableGroupNode(new GroupNode("Temp"),
+				control.getModel().getActualTimeStep());
 
 		// GroupNodes
 		HashMap<GroupNode, DecoratedGroupNode> accessMapGroupNode = control.getSimManager()
 				.getActualVisualRepresentationalState().getCreatedGroupNodes();
 		List<FilterableGroupNode> groupNodeList = control.getModel().getSelectedObjects().stream()
 				.filter(object -> object instanceof GroupNode).map(object -> accessMapGroupNode.get(object))
-				.map(node -> new FilterableGroupNode(node, control.getModel().getCurrentIteration())).collect(Collectors.toList());
+				.map(node -> new FilterableGroupNode(node, control.getModel().getActualTimeStep()))
+				.collect(Collectors.toList());
 
 		temp.getGroupNodeList().addAll(groupNodeList);
 
@@ -288,11 +309,8 @@ public class HolonInformationPanel extends JPanel {
 	public PieChart createSupplyStateChart() {
 		PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight).title("Holon Objects").build();
 		setDefaultPieChartSettings(chart);
-		Color[] sliceColors = new Color[] { ColorPreference.HolonObject.Producer,
-				ColorPreference.HolonObject.OverSupplied, ColorPreference.HolonObject.Supplied,
-				ColorPreference.HolonObject.PartiallySupplied, ColorPreference.HolonObject.NotSupplied,
-				ColorPreference.HolonObject.NoEnergy };
-		chart.getStyler().setSeriesColors(sliceColors);
+
+		chart.getStyler().setSeriesColors(supplyStateColors);
 
 		// Series
 		chart.addSeries("Producer", 0);
@@ -308,10 +326,8 @@ public class HolonInformationPanel extends JPanel {
 		PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight).title("Priotities").build();
 		setDefaultPieChartSettings(chart);
 		// Customize Chart
-		Color[] sliceColors = new Color[] { ColorPreference.Element.Priority.Essential,
-				ColorPreference.Element.Priority.High, ColorPreference.Element.Priority.Medium,
-				ColorPreference.Element.Priority.Low, ColorPreference.Element.Priority.NoData };
-		chart.getStyler().setSeriesColors(sliceColors);
+
+		chart.getStyler().setSeriesColors(priorityColors);
 		// Series
 		chart.addSeries("Essential", 0);
 		chart.addSeries("High", 0);
@@ -325,10 +341,8 @@ public class HolonInformationPanel extends JPanel {
 		PieChart chart = new PieChartBuilder().width(defaultWidth).height(defaultHeight).title("Flexibilities").build();
 		setDefaultPieChartSettings(chart);
 		// Customize Chart
-		Color[] sliceColors = new Color[] { ColorPreference.Flexibility.Offered, ColorPreference.Flexibility.InUse,
-				ColorPreference.Flexibility.OnCooldown, ColorPreference.Flexibility.NotOffered,
-				ColorPreference.Flexibility.Unavailable, ColorPreference.Element.Priority.NoData };
-		chart.getStyler().setSeriesColors(sliceColors);
+
+		chart.getStyler().setSeriesColors(flexibilityColors);
 		// Series
 		chart.addSeries("Offered", 0);
 		chart.addSeries("In use", 0);
@@ -346,8 +360,8 @@ public class HolonInformationPanel extends JPanel {
 
 		// Customize Chart
 		// Customize Chart
-		Color[] barColors = new Color[] { ColorPreference.Energy.Production, ColorPreference.Energy.Consumption };
-		chart.getStyler().setSeriesColors(barColors);
+
+		chart.getStyler().setSeriesColors(productionColors);
 		// Series
 		chart.addSeries("Production", 0);
 		chart.addSeries("Consumption", 0);
@@ -359,8 +373,8 @@ public class HolonInformationPanel extends JPanel {
 		setDefaultPieChartSettings(chart);
 		// Customize Chart
 		// Customize Chart
-		Color[] barColors = new Color[] { ColorPreference.Element.Active, ColorPreference.Element.Inactive };
-		chart.getStyler().setSeriesColors(barColors);
+
+		chart.getStyler().setSeriesColors(activeColors);
 		// Series
 		chart.addSeries("Active", 0);
 		chart.addSeries("Inactive", 0);

+ 2 - 2
src/ui/view/inspector/Inspector.java

@@ -20,9 +20,9 @@ import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
 import javax.swing.JToolBar;
 
-import classes.HolonElement;
-import classes.HolonSwitch;
 import interfaces.TimelineDependent;
+import model.HolonElement;
+import model.HolonSwitch;
 import ui.controller.Control;
 import utility.FormatFloat;
 import utility.ImageImport;

+ 16 - 16
src/ui/view/inspector/InspectorTable.java

@@ -36,12 +36,13 @@ import javax.swing.KeyStroke;
 import javax.swing.SwingConstants;
 import javax.swing.text.NumberFormatter;
 
-import classes.AbstractCanvasObject;
-import classes.GroupNode;
-import classes.HolonElement;
-import classes.HolonElement.Priority;
-import classes.HolonObject;
+import model.AbstractCanvasObject;
+import model.GroupNode;
+import model.HolonElement;
+import model.HolonObject;
+import model.HolonElement.Priority;
 import net.miginfocom.swing.MigLayout;
+import preferences.ColorPreference;
 import ui.controller.Control;
 import ui.view.component.TrippleCheckBox;
 import ui.view.component.TrippleCheckBox.State;
@@ -81,8 +82,7 @@ public class InspectorTable extends JPanel {
 	private Comparator<ElementRow> actual_comp = (ElementRow a, ElementRow b) -> Float.compare(a.element.getEnergy(), b.element.getEnergy());
 	
 	// Colors
-	private final static Color selectedColor = new Color(126, 186, 255);
-	private final static Color borderColor = new Color(171, 173, 179);
+
 	// Events
 	public Action<Set<HolonElement>> OnElementSelectionChanged = new Action<>();
 	private Thread populateRowsThread;
@@ -175,7 +175,7 @@ public class InspectorTable extends JPanel {
 		Comparator<ElementRow> deviceComp = (ElementRow a, ElementRow b) -> a.element.getName().compareTo(b.element.getName());
 		Comparator<ElementRow> energyComp = (ElementRow a, ElementRow b) -> Float.compare(a.element.getEnergy(), b.element.getEnergy());
 		Comparator<ElementRow> priorityComp = (ElementRow a, ElementRow b) -> a.element.getPriority().compareTo(b.element.getPriority());
-		Comparator<ElementRow> activeComp = (ElementRow a, ElementRow b) -> Boolean.compare(a.element.isActive(), b.element.isActive());
+		Comparator<ElementRow> activeComp = (ElementRow a, ElementRow b) -> Boolean.compare(a.element.active, b.element.active);
 ;
 		
 		headerButtonList.add(new SortButton<ElementRow>("Object", objectComp));
@@ -208,7 +208,7 @@ public class InspectorTable extends JPanel {
 			}
 				break;
 			case unselected:
-				// TODO maybe select only current page
+				// TODO(Tom2021-12-1) maybe select only current page
 				if (rowPool.getBorrowedCount() != 0) {
 					rowPool.getBorrowedStream().forEach(row -> row.setSelected(true));
 					duplicateButton.setEnabled(true);
@@ -402,7 +402,7 @@ public class InspectorTable extends JPanel {
 			selectionBox.setSelected(value);
 			// Color row
 			for (Container cell : cellsInRow) {
-				cell.setBackground(selectionBox.isSelected() ? selectedColor : Color.white);
+				cell.setBackground(selectionBox.isSelected() ? ColorPreference.Inspector.Selected : Color.white);
 			}
 		}
 
@@ -418,14 +418,14 @@ public class InspectorTable extends JPanel {
 			elementNameTextField.setText(this.element.getName());
 			energyTextField.setValue(this.element.getEnergy());
 			comboBox.setSelectedItem(this.element.getPriority());
-			activeCheckBox.setSelected(this.element.isActive());
+			activeCheckBox.setSelected(this.element.active);
 		}
 
 		private void createEditFields() {
 			// Selected
 			JPanel selectedColumnPanel = new JPanel(new BorderLayout());
 			selectedColumnPanel.setBackground(Color.white);
-			selectedColumnPanel.setBorder(BorderFactory.createLineBorder(borderColor));
+			selectedColumnPanel.setBorder(BorderFactory.createLineBorder(ColorPreference.Inspector.Border));
 			selectionBox = new JCheckBox();
 			selectionBox.addActionListener(clicked -> {
 				setSelected(selectionBox.isSelected());
@@ -456,7 +456,7 @@ public class InspectorTable extends JPanel {
 			// Name
 			elementNameTextField = new JTextField();
 			elementNameTextField.getDocument().addDocumentListener((SimpleDocumentListener) e -> {
-				this.element.setEleName(elementNameTextField.getText());
+				this.element.setName(elementNameTextField.getText());
 			});
 			elementNameTextField.setBackground(Color.white);
 			cellsInRow[3] = elementNameTextField;
@@ -470,7 +470,7 @@ public class InspectorTable extends JPanel {
 				try {
 					float energy = Float.parseFloat(energyTextField.getText());
 					if (this.element.getEnergy() != energy) {
-						this.element.setEnergyPerElement(energy);
+						this.element.setEnergy(energy);
 						control.calculateStateAndVisualForCurrentTimeStep();
 					}
 				} catch (NumberFormatException e) {
@@ -490,7 +490,7 @@ public class InspectorTable extends JPanel {
 			cellsInRow[5] = comboBox;
 
 			JPanel checkBoxWrapperPanel = new JPanel(new BorderLayout());
-			checkBoxWrapperPanel.setBorder(BorderFactory.createLineBorder(borderColor));
+			checkBoxWrapperPanel.setBorder(BorderFactory.createLineBorder(ColorPreference.Inspector.Border));
 			checkBoxWrapperPanel.setBackground(Color.white);
 			checkBoxWrapperPanel.setMinimumSize(new Dimension(columnHeight, columnHeight));
 			checkBoxWrapperPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, columnHeight));
@@ -499,7 +499,7 @@ public class InspectorTable extends JPanel {
 			activeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0));
 			activeCheckBox.setOpaque(false);
 			activeCheckBox.addActionListener(actionEvent -> {
-				this.element.setActive(activeCheckBox.isSelected());
+				this.element.active = activeCheckBox.isSelected();
 				control.calculateStateAndVisualForCurrentTimeStep();
 			});
 			checkBoxWrapperPanel.add(activeCheckBox, BorderLayout.CENTER);

+ 8 - 8
src/ui/view/inspector/UnitGraph.java

@@ -12,7 +12,6 @@ import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
 import java.awt.geom.Path2D;
-import java.awt.geom.Point2D;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
@@ -22,12 +21,13 @@ import java.util.Set;
 
 import javax.swing.JPanel;
 
-import classes.HolonElement;
 import interfaces.GraphEditable.GraphType;
+import model.HolonElement;
 import interfaces.TimelineDependent;
 import ui.controller.Control;
 import ui.model.Model;
 import utility.Maths;
+import utility.Vector2Float;
 import utility.Vector2Int;
 
 /**
@@ -93,7 +93,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	/**
 	 * Constructor.
 	 *
-	 * @param model   the Model
+	 * @param ModelTest   the Model
 	 * @param control the Controller
 	 */
 	public UnitGraph(Control control) {
@@ -142,7 +142,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		// sample energy
 		for (HolonElement element : elements) {
 			for (int i = 0; i < model.getMaxIterations(); i++) {
-				sample[i] += element.getEnergyAtTimeStep(i);
+				sample[i] += element.calculateExpectedEnergyAtTimeStep(i);
 			}
 		}
 		
@@ -304,7 +304,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * @param g2D to draw.
 	 */
 	private void drawCurrentIterartionLine(Graphics2D g) {
-		int cur = model.getCurrentIteration();
+		int cur = model.getActualTimeStep();
 		int max = model.getMaxIterations();
 		if (isLocalPeriedDifferentInSeries()) {
 			for (Series series : seriesList) {
@@ -631,9 +631,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 * 
 	 * @param stateCurve the list of GraphPoint
 	 */
-	private void overrideUnitGraph(Series series, LinkedList<Point2D.Double> stateCurve) {
+	private void overrideUnitGraph(Series series, LinkedList<Vector2Float> stateCurve) {
 		series.points.clear();
-		for (Point2D.Double p : stateCurve) {
+		for (Vector2Float p : stateCurve) {
 			UnitGraphPoint point = new UnitGraphPoint(p);
 			point.calcDisplayedPosition(border, widthWithBorder, heightWithBorder);
 			series.points.add(point);
@@ -654,7 +654,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 	 */
 	private void saveGraph() {
 		for (Series series : seriesList) {
-			LinkedList<Point2D.Double> actual = series.element.getStateGraph();
+			LinkedList<Vector2Float> actual = series.element.getStateGraph();
 			actual.clear();
 			for (UnitGraphPoint p : series.points) {
 				actual.add(p.getPoint());

+ 5 - 7
src/ui/view/inspector/UnitGraphPoint.java

@@ -1,8 +1,6 @@
 package ui.view.inspector;
 
-import java.awt.Point;
-import java.awt.geom.Point2D;
-
+import utility.Vector2Float;
 import utility.Vector2Int;
 
 /**
@@ -26,7 +24,7 @@ public class UnitGraphPoint {
 		this.changed = changed;
 	}
 	/** Constructor with a Point2D.Double*/
-	public UnitGraphPoint(Point2D.Double pos, boolean changed){
+	public UnitGraphPoint(Vector2Float pos, boolean changed){
 		this.x = pos.getX();
 		this.y = pos.getY();
 		this.changed = changed;
@@ -34,7 +32,7 @@ public class UnitGraphPoint {
 	/** Constructor with a Point2D.Double
 	 * when changed not specified is false;
 	 * */
-	public UnitGraphPoint(Point2D.Double pos){
+	public UnitGraphPoint(Vector2Float pos){
 		this.x = pos.getX();
 		this.y = pos.getY();
 		this.changed = false;
@@ -46,9 +44,9 @@ public class UnitGraphPoint {
 		displayedPosition =  new Vector2Int((int) (x * widthWithBorder) + border, (int) ((1-y) * heightWithBorder) + border);
     }
 	
-	public Point.Double getPoint()
+	public Vector2Float getPoint()
 	{
-		 return new Point2D.Double(x, y);
+		 return new Vector2Float((float)x, (float)y);
 	}
 	@Override
 	public String toString() {

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