Browse Source

Removed DecoratedCables

TomTroppmann 2 năm trước cách đây
mục cha
commit
842f2cf6e1

+ 2 - 2
src/addon/InformationPanel.java

@@ -225,7 +225,7 @@ public class InformationPanel implements AddOn {
 	
 	
 	void calculateValues(){
-		DecoratedState dState = control.getSimManager().getActualDecorState();
+		DecoratedState dState = control.getSimManager().getActualDecorState().get();
 		amountConsumer = dState.getNetworkList().stream().map(net -> net.getAmountOfConsumer()).reduce(0, Integer::sum);
 		this.amountSwitch = dState.getDecoratedSwitches().size();
 		amountActiveSwitch = (int)dState.getDecoratedSwitches().stream().filter(dswitch -> (dswitch.getState() == SwitchState.Closed)).count();
@@ -262,7 +262,7 @@ public class InformationPanel implements AddOn {
 		amountActiveMedium = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Medium).count();
 		amountActiveLow = (int)flexActiveList.stream().filter(flex -> flex.getElement().getPriority() == Priority.Low).count();
 		this.amountActiveFlexibilities = amountActiveEssential + amountActiveHigh + amountActiveMedium + amountActiveLow;
-		VisualRepresentationalState visualState =control.getSimManager().getActualVisualRepresentationalState();
+		VisualRepresentationalState visualState =control.getSimManager().getActualVisualRepresentationalState().get();
 		amountGroupNodes = visualState.getAmountfOfGroupNodes();
 		
 		

+ 11 - 9
src/algorithm/binary/BaseLine.java

@@ -22,7 +22,6 @@ import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
 import javax.swing.JTextArea;
-
 import api.AddOn;
 import model.AbstractCanvasObject;
 import model.GroupNode;
@@ -222,13 +221,16 @@ public class BaseLine implements AddOn {
 		textArea.append(message  + "\n");
 	}
 	private void selectGroupNode() {
-		Object[] possibilities = control.getSimManager().getActualVisualRepresentationalState().getCreatedGroupNodes().values().stream().map(aCps -> new Handle<DecoratedGroupNode>(aCps)).toArray();
-		@SuppressWarnings("unchecked")
-		Handle<DecoratedGroupNode> selected = (Handle<DecoratedGroupNode>) JOptionPane.showInputDialog(content, "Select GroupNode:", "GroupNode?",  JOptionPane.OK_OPTION,new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) , possibilities, "");
-		if(selected != null) {
-			println("Selected: " + selected);
-			dGroupNode = selected.object;
-		}
+		control.getSimManager().getActualVisualRepresentationalState().ifPresent(state -> {
+			Object[] possibilities = state.getCreatedGroupNodes().values().stream().map(aCps -> new Handle<DecoratedGroupNode>(aCps)).toArray();
+			@SuppressWarnings("unchecked")
+			Handle<DecoratedGroupNode> selected = (Handle<DecoratedGroupNode>) JOptionPane.showInputDialog(content, "Select GroupNode:", "GroupNode?",  JOptionPane.OK_OPTION,new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) , possibilities, "");
+			if(selected != null) {
+				println("Selected: " + selected);
+				dGroupNode = selected.object;
+			}
+		});
+		
 	}
 	
 	private void startTimer(){
@@ -274,7 +276,7 @@ public class BaseLine implements AddOn {
 		if(closeSwitches)setAllSwitchesClosed();
 		setHolonElemntsAktiv();
 		control.calculateStateAndVisualForCurrentTimeStep();
-		DecoratedState actualstate = control.getSimManager().getActualDecorState();	
+		DecoratedState actualstate = control.getSimManager().getActualDecorState().get();	
 		for(DecoratedNetwork net : actualstate.getNetworkList()) {
 			float production = net.getSupplierList().stream().map(supplier -> supplier.getEnergyToSupplyNetwork()).reduce(0.0f, (a, b) -> a + b);
 			float consumption = net.getConsumerList().stream().map(con -> con.getEnergyNeededFromNetwork()).reduce(0.0f, (a, b) -> a + b);

+ 10 - 8
src/algorithm/example/DemoAlgo.java

@@ -258,15 +258,17 @@ public class DemoAlgo implements AddOn {
 			textArea.append(message  + "\n");
 		}
 		private void selectGroupNode() {
-			Object[] possibilities = control.getSimManager().getActualVisualRepresentationalState().getCreatedGroupNodes().values().stream().map(aCps -> new Handle<DecoratedGroupNode>(aCps)).toArray();
-			@SuppressWarnings("unchecked")
-			Handle<DecoratedGroupNode> selected = (Handle<DecoratedGroupNode>) JOptionPane.showInputDialog(content, "Select GroupNode:", "GroupNode?",  JOptionPane.OK_OPTION,new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) , possibilities, "");
-			if(selected != null) {
-				println("Selected: " + selected);
-				dGroupNode = selected.object;
-			}
+			control.getSimManager().getActualVisualRepresentationalState().ifPresent(state -> {
+				Object[] possibilities = state.getCreatedGroupNodes().values().stream().map(aCps -> new Handle<DecoratedGroupNode>(aCps)).toArray();
+				@SuppressWarnings("unchecked")
+				Handle<DecoratedGroupNode> selected = (Handle<DecoratedGroupNode>) JOptionPane.showInputDialog(content, "Select GroupNode:", "GroupNode?",  JOptionPane.OK_OPTION,new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) , possibilities, "");
+				if(selected != null) {
+					println("Selected: " + selected);
+					dGroupNode = selected.object;
+				}
+			});
+			
 		}
-		
 		private void startTimer(){
 			startTime = System.currentTimeMillis();
 		}

+ 12 - 10
src/algorithm/example/FlexExample.java

@@ -26,7 +26,6 @@ import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
 import javax.swing.JTextArea;
 import javax.swing.text.NumberFormatter;
-
 import api.AddOn;
 import model.AbstractCanvasObject;
 import model.Flexibility;
@@ -285,13 +284,16 @@ public class FlexExample implements AddOn {
 			textArea.append(message  + "\n");
 		}
 		private void selectGroupNode() {
-			Object[] possibilities = control.getSimManager().getActualVisualRepresentationalState().getCreatedGroupNodes().values().stream().map(aCps -> new Handle<DecoratedGroupNode>(aCps)).toArray();
-			@SuppressWarnings("unchecked")
-			Handle<DecoratedGroupNode> selected = (Handle<DecoratedGroupNode>) JOptionPane.showInputDialog(content, "Select GroupNode:", "GroupNode?",  JOptionPane.OK_OPTION,new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) , possibilities, "");
-			if(selected != null) {
-				println("Selected: " + selected);
-				dGroupNode = selected.object;
-			}
+			control.getSimManager().getActualVisualRepresentationalState().ifPresent(state -> {
+				Object[] possibilities = state.getCreatedGroupNodes().values().stream().map(aCps -> new Handle<DecoratedGroupNode>(aCps)).toArray();
+				@SuppressWarnings("unchecked")
+				Handle<DecoratedGroupNode> selected = (Handle<DecoratedGroupNode>) JOptionPane.showInputDialog(content, "Select GroupNode:", "GroupNode?",  JOptionPane.OK_OPTION,new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) , possibilities, "");
+				if(selected != null) {
+					println("Selected: " + selected);
+					dGroupNode = selected.object;
+				}
+			});
+			
 		}
 		private void startTimer(){
 			startTime = System.currentTimeMillis();
@@ -335,7 +337,7 @@ public class FlexExample implements AddOn {
 			println("TimeStep:" + actualIteration);
 			control.calculateStateOnlyForCurrentTimeStep();
 			List<Priority> priorityListASC = createPriorityListASC();
-			DecoratedState actualstate = control.getSimManager().getActualDecorState();	
+			DecoratedState actualstate = control.getSimManager().getActualDecorState().get();	
 			for(DecoratedNetwork net : actualstate.getNetworkList()) {
 				float production = net.getSupplierList().stream().map(supplier -> supplier.getEnergyToSupplyNetwork()).reduce(0.0f, (a, b) -> a + b);
 				float consumption = net.getConsumerList().stream().map(con -> con.getEnergyNeededFromNetwork()).reduce(0.0f, (a, b) -> a + b);
@@ -386,7 +388,7 @@ public class FlexExample implements AddOn {
 			control.calculateStateOnlyForCurrentTimeStep();
 			RunResult.TimeStepStateResult timeStepState = result.addTimeStepStateResult();
 			
-			for(DecoratedNetwork network: control.getSimManager().getActualDecorState().getNetworkList()) {
+			for(DecoratedNetwork network: control.getSimManager().getActualDecorState().get().getNetworkList()) {
 				timeStepState.amountOfConsumer += network.getAmountOfConsumer();
 				timeStepState.amountOfConsumerOverSupplied += network.getAmountOfConsumerWithState(HolonObjectState.OVER_SUPPLIED);
 				timeStepState.amountOfConsumerPartiallySupplied += network.getAmountOfConsumerWithState(HolonObjectState.PARTIALLY_SUPPLIED);

+ 4 - 5
src/algorithm/objective_function/GraphMetrics.java

@@ -14,7 +14,6 @@ import model.HolonSwitch;
 import java.util.Set;
 
 import ui.model.Consumer;
-import ui.model.DecoratedCable;
 import ui.model.DecoratedNetwork;
 import ui.model.Passiv;
 import ui.model.Supplier;
@@ -92,10 +91,10 @@ public class GraphMetrics {
 		
 		//Generate EdgeList 
 		List<Edge> edgeList = new ArrayList<Edge>();
-		for(DecoratedCable cable : net.getDecoratedCableList()){
+		for(model.Edge cable : net.getDecoratedCableList()){
 			
-			AbstractCanvasObject objectA = cable.getModel().getA();
-			AbstractCanvasObject objectB = cable.getModel().getB();
+			AbstractCanvasObject objectA = cable.getA();
+			AbstractCanvasObject objectB = cable.getB();
 			if(objectA == null) {
 				System.out.println("Edge: " + cable + "objectA == null");
 				continue;
@@ -127,7 +126,7 @@ public class GraphMetrics {
 				idB = count;
 				objectToId.put(objectB, count++);
 			}
-			double length = cable.getModel().getLength();
+			double length = cable.getLength();
 			edgeList.add(new Edge(idA, idB, length));
 		}
 		//Generate EdgeArray

+ 13 - 11
src/api/AlgorithmFrameworkFlex.java

@@ -495,19 +495,21 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 	
 	
 	private void selectGroupNode() {
-		Object[] possibilities = control.getSimManager().getActualVisualRepresentationalState().getCreatedGroupNodes().values().stream().map(aCps -> new Handle<DecoratedGroupNode>(aCps)).toArray();
-		@SuppressWarnings("unchecked")
-		Handle<DecoratedGroupNode> selected = (Handle<DecoratedGroupNode>) JOptionPane.showInputDialog(content, "Select group-node:", "Select a designated area",  JOptionPane.OK_OPTION,new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) , possibilities, "");
-		if(selected != null) {
-			console.println("Selected: " + selected);
-			dGroupNode = selected.object;
-		}
+		control.getSimManager().getActualVisualRepresentationalState().ifPresent(state -> {
+			Object[] possibilities = state.getCreatedGroupNodes().values().stream().map(aCps -> new Handle<DecoratedGroupNode>(aCps)).toArray();
+			@SuppressWarnings("unchecked")
+			Handle<DecoratedGroupNode> selected = (Handle<DecoratedGroupNode>) JOptionPane.showInputDialog(content, "Select GroupNode:", "GroupNode?",  JOptionPane.OK_OPTION,new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB)) , possibilities, "");
+			if(selected != null) {
+				console.println("Selected: " + selected);
+				dGroupNode = selected.object;
+			}
+		});
 	}
 	
 	protected double evaluatePosition(List<Boolean> positionToEvaluate) {
 		runProgressbar.step();
 		setState(positionToEvaluate); // execution time critical
-		DecoratedState actualstate = control.getSimManager().getActualDecorState();
+		DecoratedState actualstate = control.getSimManager().getActualDecorState().get();
 		double result = evaluateState(actualstate);
 		return result;
 	}
@@ -630,7 +632,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 		updateVisual();
 		console.println("Start: " + FormatFloat.doubleFixedPlaces(2,startFitness));
 		console.println("AlgoResult: " + FormatFloat.doubleFixedPlaces(2,runBest.fitness));
-		if(this.algoUseFlexes)calculateAndPrintFlexInfos(control.getSimManager().getActualDecorState());
+		if(this.algoUseFlexes)calculateAndPrintFlexInfos(control.getSimManager().getActualDecorState().get());
 		runPrinter.openStream();
 		if(rounds > 1) {
 			RunValues avgRun = avg.getAverage();
@@ -843,7 +845,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 		if(dGroupNode != null)
 		{
 			//GetActualDecoratedGroupNode
-			dGroupNode = control.getSimManager().getActualVisualRepresentationalState().getCreatedGroupNodes().get(dGroupNode.getModel());
+			dGroupNode = control.getSimManager().getActualVisualRepresentationalState().get().getCreatedGroupNodes().get(dGroupNode.getModel());
 			val.producer = dGroupNode.getAmountOfSupplier();
 			val.consumer = dGroupNode.getAmountOfConsumer();
 			val.passiv = dGroupNode.getAmountOfPassiv();
@@ -858,7 +860,7 @@ public abstract class AlgorithmFrameworkFlex implements AddOn{
 			val.elements = dGroupNode.getAmountOfElemntsFromHolonObjects();
 			//TODO(Tom2021-12-1) what should be printed happen when only groupNode are selected
 		}
-		DecoratedState state = control.getSimManager().getActualDecorState();
+		DecoratedState state = control.getSimManager().getActualDecorState().get();
 		for(DecoratedNetwork net : state.getNetworkList()) {
 			val.consumer += net.getAmountOfConsumer();
 			val.producer += net.getAmountOfSupplier();

+ 4 - 4
src/api/TopologieAlgorithmFramework.java

@@ -497,7 +497,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 
 	private double evaluateNetwork() {
 		runProgressbar.step();
-		DecoratedState actualstate = control.getSimManager().getActualDecorState();
+		DecoratedState actualstate = control.getSimManager().getActualDecorState().get();
 		return evaluateState(actualstate, calculateAmountOfAddedSwitches(), addedCableMeter(), false);
 	}
 	private double evaluateNetworkAndPrint() {
@@ -507,7 +507,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 			hSwitch.setManualState(false);
 		}
 		control.calculateStateOnlyForCurrentTimeStep();
-		DecoratedState actualstate = control.getSimManager().getActualDecorState();
+		DecoratedState actualstate = control.getSimManager().getActualDecorState().get();
 		return evaluateState(actualstate, calculateAmountOfAddedSwitches(), addedCableMeter(), true);
 	}
 	
@@ -933,7 +933,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 		if(dGroupNode != null)
 		{
 			//GetActualDecoratedGroupNode
-			dGroupNode = control.getSimManager().getActualVisualRepresentationalState().getCreatedGroupNodes().get(dGroupNode.getModel());
+			dGroupNode = control.getSimManager().getActualVisualRepresentationalState().get().getCreatedGroupNodes().get(dGroupNode.getModel());
 			int amountOfSupplier = dGroupNode.getAmountOfSupplier();
 			int amountOfConsumer = dGroupNode.getAmountOfConsumer();
 			int amountOfPassiv = dGroupNode.getAmountOfPassiv();
@@ -956,7 +956,7 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 				+	" Active: " + activeElements  + "/" + elements + "("+ (float)activeElements/(float)elements * 100 + "%)"
 				+ "]";
 		}
-		DecoratedState state = control.getSimManager().getActualDecorState();
+		DecoratedState state = control.getSimManager().getActualDecorState().get();
 		int amountOfSupplier = 0, amountOfConsumer = 0, amountOfPassiv = 0, unSuppliedConsumer = 0, partiallySuppliedConsumer = 0, suppliedConsumer = 0, overSuppliedConsumer = 0;
 		int activeElements = 0, amountOfelements = 0;
 		int totalConsumption = 0, totalProduction = 0;

+ 49 - 2
src/model/Edge.java

@@ -54,7 +54,7 @@ public class Edge {
 
     
     /**
-     * Copy Constructor
+     * Clone Constructor
      *
      * @param a      Source
      * @param b      Destination
@@ -64,7 +64,6 @@ public class Edge {
         setA(other.a);
         setB(other.b);
         this.maxCapacity = other.maxCapacity;
-        
     }
 
     /**
@@ -138,4 +137,52 @@ public class Edge {
 		this.unlimitedCapacity = unlimitedCapacity;
 	}
 
+	/*
+	 * STATE 
+	 */
+	public enum EdgeState{
+		Working, Burned
+	}
+	private EdgeState state = initState();
+	private float flowEnergy = 0;
+	
+	public EdgeState getState() {
+		return state;
+	}
+	//TODO(Tom 2021-12-3): public -> package
+	public void reset() {
+		state = initState();
+	}
+	private EdgeState initState() {
+		if (breakedManuel) {
+			return EdgeState.Burned;
+		}else {
+			return EdgeState.Working;
+		}
+	}
+	
+	public float getActualFlow() {
+		return flowEnergy;
+	}
+	
+	
+	public float getEnergyFromConneted() {
+		float energy = 0.0f;
+		if(getA() instanceof HolonObject && ((HolonObject) getA()).getActualEnergy() > 0) {
+			energy += ((HolonObject) getA()).getActualEnergy();
+		}
+		if(getB() instanceof HolonObject && ((HolonObject) getB()).getActualEnergy() > 0) {
+			energy += ((HolonObject) getB()).getActualEnergy();
+		}
+		return energy;
+	}
+
+	//TODO(Tom 2021-12-3): public -> package
+	public void setActualFlow(float energyToSupplyInTheNetwork) {
+		flowEnergy = energyToSupplyInTheNetwork;
+	}
+	//TODO(Tom 2021-12-3): public -> package
+	public void setState(EdgeState state) {
+		this.state = state;
+	}
 }

+ 4 - 2
src/ui/controller/CanvasController.java

@@ -5,6 +5,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
 import java.util.ListIterator;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 import model.AbstractCanvasObject;
@@ -13,6 +14,7 @@ import model.GroupNode;
 import model.HolonObject;
 import model.HolonSwitch;
 import model.Node;
+import ui.model.DecoratedState;
 import ui.model.Model;
 import ui.view.main.GUI;
 import utility.Vector2Int;
@@ -289,9 +291,9 @@ public class CanvasController {
 	}
 	
 	public void updateOutliner(SimulationManager manager ) {
-		gui.updateOutliners(manager.getActualDecorState());
+		Optional<DecoratedState> decorState = manager.getActualDecorState();
+		decorState.ifPresent(state -> gui.updateOutliners(state));
 	}
-	
 	public void updateFlexWindow() {
 		gui.updateFlexWindows();
 	}

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

@@ -525,7 +525,7 @@ public class Control {
 	 * the default "is working" state
 	 */
 	public void resetSimulation() {
-		model.resetFlexibilities();
+		model.reset();
 	}
 
 	/**

+ 29 - 65
src/ui/controller/SimulationManager.java

@@ -1,8 +1,5 @@
 package ui.controller;
 
-import ui.model.IntermediateCableWithState;
-import ui.model.DecoratedCable;
-import ui.model.DecoratedCable.CableState;
 import ui.model.DecoratedSwitch.SwitchState;
 import ui.model.DecoratedNetwork;
 import ui.model.DecoratedState;
@@ -17,8 +14,10 @@ import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.ListIterator;
+import java.util.Optional;
 
 import model.*;
+import model.Edge.EdgeState;
 
 
 /**
@@ -27,12 +26,10 @@ import model.*;
  * @author Gruppe14
  */
 public class SimulationManager {
-	int global = 0;
 	private Model model;
-	private HashMap<Integer, DecoratedState> saves = new HashMap<Integer, DecoratedState>();
 	private HashMap<Integer, VisualRepresentationalState> savesVisual = new HashMap<Integer, VisualRepresentationalState>();
-	
 	private int timeStep;
+	public Optional<DecoratedState> actualDecorState = Optional.empty();
 
 	/**
 	 * Constructor.
@@ -58,36 +55,11 @@ public class SimulationManager {
 	 * Determine if the Visuals should also be calculated
 	 */
 	public void calculateStateForTimeStep(int timestep, boolean updateVisual) {
-		HashMap<Edge, CableState> map = new HashMap<Edge, CableState>();
-		if(timestep > 0 && saves.containsKey(timestep-1)) //if the state before exist
-		{
-			//make cable hastmap
-			DecoratedState theStateBefore = saves.get(timestep-1);
-			//edges without HolonObjects or burned
-			for(DecoratedCable edge : theStateBefore.getLeftOverEdges())
-			{
-				map.put(edge.getModel(), edge.getState());
-			}
-		}
 		timeStep = timestep;
-		
-		
-		
 		ArrayList<MinimumNetwork> list =  new ArrayList<MinimumNetwork>();
 		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);
-		}
-		
-		//set all the state before:
-		for(IntermediateCableWithState cable : minimumModel.getEdgeList()) {
-			if(map.containsKey(cable.getModel())) cable.setState(map.get(cable.getModel()));
-		}
-		ArrayList<IntermediateCableWithState> leftOver = new ArrayList<IntermediateCableWithState>();
-		
-		
-		
+		ArrayList<Edge> leftOver = new ArrayList<Edge>();
+
 		boolean doAnotherLoop = true;
 		while(doAnotherLoop) {
 			doAnotherLoop = false;
@@ -95,9 +67,9 @@ public class SimulationManager {
 			for(MinimumNetwork net : list) {
 				float energyOnCables = net.getHolonObjectList().stream().map(object -> object.getActualEnergy()).filter(energy -> energy > 0.0f).reduce(0.0f, (Float::sum));
 				//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().maxCapacity && !aCable.getModel().isUnlimitedCapacity()).max((lhs,rhs) -> Float.compare(lhs.getEnergyFromConneted(), rhs.getEnergyFromConneted())).orElse(null);
+				Edge cable = net.getEdgeList().stream().filter(aCable -> energyOnCables > aCable.maxCapacity && !aCable.isUnlimitedCapacity()).max((lhs,rhs) -> Float.compare(lhs.getEnergyFromConneted(), rhs.getEnergyFromConneted())).orElse(null);
 				if(cable != null) {
-					cable.setState(CableState.Burned);
+					cable.setState(EdgeState.Burned);
 					doAnotherLoop = true;
 				}
 			}
@@ -111,17 +83,13 @@ public class SimulationManager {
 		
 		
 		
-		ArrayList<DecoratedCable> leftOverDecoratedCables = new ArrayList<DecoratedCable>();
-		
-		for(IntermediateCableWithState cable: leftOver) {
-			leftOverDecoratedCables.add(new DecoratedCable(cable.getModel(), cable.getState(), 0.0f));
+		for(Edge cable: leftOver) {
+			cable.setActualFlow(0.0f);
 		}
 		ArrayList<DecoratedSwitch> listOfDecoratedSwitches = decorateSwitches(minimumModel, timestep);
-		DecoratedState stateFromThisTimestep = new DecoratedState(decorNetworks, leftOverDecoratedCables, listOfDecoratedSwitches, timestep);
-		saves.put(timestep, stateFromThisTimestep);
+		DecoratedState stateFromThisTimestep = new DecoratedState(decorNetworks, leftOver, listOfDecoratedSwitches, timestep);
 		if(updateVisual)savesVisual.put(timestep, new VisualRepresentationalState(stateFromThisTimestep, minimumModel));
-
-		
+		actualDecorState = Optional.of(stateFromThisTimestep);	
 	}
 	/** 
 	 * Decorate a switch
@@ -143,15 +111,15 @@ public class SimulationManager {
 	 * @param leftOver
 	 * @return
 	 */
-	ArrayList<MinimumNetwork> calculateNetworks(MinimumModel minModel, int Iteration, ArrayList<IntermediateCableWithState> leftOver){
+	ArrayList<MinimumNetwork> calculateNetworks(MinimumModel minModel, int Iteration, ArrayList<Edge> leftOver){
 		//Copy minModel ObjectList
 		ArrayList<HolonObject> holonObjectList = new ArrayList<HolonObject>();
 		for(HolonObject holonObject: minModel.getHolonObjectList()) {
 			holonObjectList.add(holonObject);
 		}
 		//Copy minModelEdgeList
-		ArrayList<IntermediateCableWithState> edgeList = new ArrayList<IntermediateCableWithState>();
-		for(IntermediateCableWithState cable: minModel.getEdgeList()) {
+		ArrayList<Edge> edgeList = new ArrayList<Edge>();
+		for(Edge cable: minModel.getEdgeList()) {
 			edgeList.add(cable);
 		}
 		
@@ -162,7 +130,7 @@ public class SimulationManager {
 			//delete out of list
 			holonObjectList.remove(0);
 			//create a new Network
-			MinimumNetwork actualNetwork = new MinimumNetwork(new ArrayList<HolonObject>(), new ArrayList<IntermediateCableWithState>());
+			MinimumNetwork actualNetwork = new MinimumNetwork(new ArrayList<HolonObject>(), new ArrayList<Edge>());
 			actualNetwork.getHolonObjectList().add(lookAtObject);
 			//create List of neighbors
 			LinkedList<AbstractCanvasObject> neighbors = new LinkedList<AbstractCanvasObject>();
@@ -186,7 +154,7 @@ public class SimulationManager {
 		}	
 		if(leftOver!= null) {
 			leftOver.clear();
-			for(IntermediateCableWithState cable: edgeList) {
+			for(Edge cable: edgeList) {
 				leftOver.add(cable);
 			}
 		}
@@ -199,23 +167,23 @@ public class SimulationManager {
 	 * @param actualNetwork
 	 * @param neighbors
 	 */
-	void populateListOfNeighbors(ArrayList<IntermediateCableWithState> edgeList, AbstractCanvasObject lookAtObject,
+	void populateListOfNeighbors(ArrayList<Edge> edgeList, AbstractCanvasObject lookAtObject,
 			MinimumNetwork actualNetwork, LinkedList<AbstractCanvasObject> neighbors) {
-		ListIterator<IntermediateCableWithState> iter = edgeList.listIterator();
+		ListIterator<Edge> iter = edgeList.listIterator();
 		while(iter.hasNext())
 		{
-			IntermediateCableWithState lookAtEdge = iter.next();
-			if(lookAtEdge.getState() == CableState.Working && lookAtEdge.getModel().isConnectedTo(lookAtObject)) {
+			Edge lookAtEdge = iter.next();
+			if(lookAtEdge.getState() == EdgeState.Working && lookAtEdge.isConnectedTo(lookAtObject)) {
 				iter.remove();
 				actualNetwork.getEdgeList().add(lookAtEdge);
 				
 				//Add neighbar
 				AbstractCanvasObject edgeNeighbor;
-				if(lookAtEdge.getModel().getA().equals(lookAtObject)) {
-					edgeNeighbor = lookAtEdge.getModel().getB();
+				if(lookAtEdge.getA().equals(lookAtObject)) {
+					edgeNeighbor = lookAtEdge.getB();
 					
 				}else {
-					edgeNeighbor = lookAtEdge.getModel().getA();
+					edgeNeighbor = lookAtEdge.getA();
 				}
 				if(!neighbors.contains(edgeNeighbor)) {
 					neighbors.add(edgeNeighbor);
@@ -224,18 +192,14 @@ public class SimulationManager {
 		}
 	}
 	
-	public DecoratedState getActualDecorState() {
-		return getDecorState(timeStep);
+	public Optional<DecoratedState> getActualDecorState() {
+		return actualDecorState;
 	}
-	public VisualRepresentationalState getActualVisualRepresentationalState(){
-		return savesVisual.getOrDefault(timeStep, null);
-	}
-	
-	public DecoratedState getDecorState(int timestep) {
-		return saves.get(timestep);
+	public Optional<VisualRepresentationalState> getActualVisualRepresentationalState(){
+		return Optional.ofNullable(savesVisual.get(timeStep));
 	}
-	public VisualRepresentationalState getVisualRepresentationalState(int timestep) {
-		return savesVisual.getOrDefault(timestep, null);
+	public Optional<VisualRepresentationalState> getVisualRepresentationalState(int timestep) {
+		return Optional.ofNullable(savesVisual.get(timestep));
 	}
 
 

+ 0 - 26
src/ui/model/DecoratedCable.java

@@ -1,26 +0,0 @@
-package ui.model;
-
-import model.Edge;
-
-public class DecoratedCable {
-	public enum CableState{
-		Working, Burned
-	}
-	private Edge model;
-	private CableState state;
-	private float flowEnergy;
-	public DecoratedCable(Edge edge, CableState state, float flowEnergy){
-		this.model = edge;
-		this.state = state;
-		this.flowEnergy = flowEnergy;
-	}
-	public Edge getModel() {
-		return model;
-	}
-	public CableState getState() {
-		return state;
-	}
-	public float getFlowEnergy() {
-		return flowEnergy;
-	}
-}

+ 10 - 17
src/ui/model/DecoratedGroupNode.java

@@ -4,6 +4,7 @@ import java.util.ArrayList;
 import java.util.stream.Stream;
 
 import jdk.jfr.Unsigned;
+import model.Edge;
 import model.Flexibility;
 import model.GroupNode;
 import model.HolonElement;
@@ -18,33 +19,25 @@ import ui.model.DecoratedHolonObject.HolonObjectState;
  */
 public class DecoratedGroupNode {
 	private GroupNode model;
-	private ArrayList<Supplier> supplierList;
-	private ArrayList<Passiv> passivList;
-	private ArrayList<Consumer> consumerList;
-	private ArrayList<Node> nodeList;
+	private ArrayList<Supplier> supplierList= new ArrayList<>(); 
+	private ArrayList<Passiv> passivList= new ArrayList<>(); 
+	private ArrayList<Consumer> consumerList= new ArrayList<>(); 
+	private ArrayList<Node> nodeList= new ArrayList<>(); 
 	/**
 	 * Cables that only exist on that group node. From a object in that group node
 	 * to a object in that group Node. Not exit the group node (a layer down).
 	 */
-	private ArrayList<DecoratedCable> internCableList;
+	private ArrayList<Edge> internCableList= new ArrayList<>(); 
 	/**
 	 * Cables that exit this group node (a Layer Up). From a object in this group
 	 * node to a object in a upper layer.
 	 */
-	private ArrayList<ExitCable> exitCableList;
-	private ArrayList<DecoratedSwitch> switchList;
-	private ArrayList<DecoratedGroupNode> groupNodeList;
+	private ArrayList<ExitCable> exitCableList= new ArrayList<>(); 
+	private ArrayList<DecoratedSwitch> switchList= new ArrayList<>(); 
+	private ArrayList<DecoratedGroupNode> groupNodeList= new ArrayList<>(); 
 
 	public DecoratedGroupNode(GroupNode model) {
 		this.model = model;
-		this.supplierList = new ArrayList<Supplier>();
-		this.passivList = new ArrayList<Passiv>();
-		this.consumerList = new ArrayList<Consumer>();
-		this.nodeList = new ArrayList<Node>();
-		this.internCableList = new ArrayList<DecoratedCable>();
-		this.exitCableList = new ArrayList<ExitCable>();
-		this.switchList = new ArrayList<DecoratedSwitch>();
-		this.groupNodeList = new ArrayList<DecoratedGroupNode>();
 	}
 
 	public GroupNode getModel() {
@@ -67,7 +60,7 @@ public class DecoratedGroupNode {
 		return nodeList;
 	}
 
-	public ArrayList<DecoratedCable> getInternCableList() {
+	public ArrayList<Edge> getInternCableList() {
 		return internCableList;
 	}
 

+ 8 - 8
src/ui/model/DecoratedNetwork.java

@@ -4,7 +4,7 @@ import java.util.ArrayList;
 import java.util.stream.Stream;
 import model.HolonElement;
 import model.HolonObject;
-import ui.model.DecoratedCable.CableState;
+import model.Edge;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.Model.FairnessModel;
 
@@ -13,7 +13,7 @@ public class DecoratedNetwork {
 	private ArrayList<Consumer> consumerList = new ArrayList<Consumer>();
 	private ArrayList<Consumer> consumerSelfSuppliedList = new ArrayList<Consumer>();
 	private ArrayList<Passiv> passivNoEnergyList = new ArrayList<Passiv>();
-	private ArrayList<DecoratedCable> decoratedCableList = new ArrayList<DecoratedCable>();
+	private ArrayList<Edge> edgeList = new ArrayList<Edge>();
 
 	public DecoratedNetwork(MinimumNetwork minimumNetwork, int Iteration, FairnessModel actualFairnessModel) {
 		switch (actualFairnessModel) {
@@ -44,8 +44,8 @@ public class DecoratedNetwork {
 		return passivNoEnergyList;
 	}
 
-	public ArrayList<DecoratedCable> getDecoratedCableList() {
-		return decoratedCableList;
+	public ArrayList<Edge> getDecoratedCableList() {
+		return edgeList;
 	}
 
 	// Calculations:
@@ -179,9 +179,9 @@ public class DecoratedNetwork {
 	private void decorateCable(MinimumNetwork minimumNetwork, float energyToSupplyInTheNetwork) {
 		// DecoratedCables
 		// Minimum demand first:
-		for (IntermediateCableWithState edge : minimumNetwork.getEdgeList()) {
-			decoratedCableList.add(new DecoratedCable(edge.getModel(), edge.getState(),
-					(edge.getState() == CableState.Working) ? energyToSupplyInTheNetwork : 0.0f));
+		this.edgeList = minimumNetwork.getEdgeList();
+		for (Edge edge : edgeList) {
+			edge.setActualFlow(energyToSupplyInTheNetwork);
 		}
 	}
 
@@ -189,7 +189,7 @@ public class DecoratedNetwork {
 		categorize(minimumNetwork, Iteration);
 		float energyToSupplyInTheNetwork = supplierList.stream()
 				.map(supplier -> supplier.getEnergyToSupplyNetwork() - supplier.getEnergySupplied())
-				.reduce(0.0f, (a, b) -> a + b);
+				.reduce(0.0f, Float::sum);
 		float energyForEachConsumer = (consumerList.size() != 0) ? energyToSupplyInTheNetwork / consumerList.size()
 				: 0.0f;
 		decorateCable(minimumNetwork, energyToSupplyInTheNetwork);

+ 4 - 3
src/ui/model/DecoratedState.java

@@ -3,14 +3,15 @@ package ui.model;
 import java.util.ArrayList;
 import java.util.stream.Stream;
 
+import model.Edge;
 import model.Flexibility;
 
 public class DecoratedState {
 	int timestepOfState;
 	ArrayList<DecoratedNetwork> networkList;
-	ArrayList<DecoratedCable> leftOverEdges;
+	ArrayList<Edge> leftOverEdges;
 	ArrayList<DecoratedSwitch> decoratedSwitches;
-	public DecoratedState(ArrayList<DecoratedNetwork> networkList, ArrayList<DecoratedCable> leftOverEdges, ArrayList<DecoratedSwitch> decoratedSwitches, int timestepOfState){
+	public DecoratedState(ArrayList<DecoratedNetwork> networkList, ArrayList<Edge> leftOverEdges, ArrayList<DecoratedSwitch> decoratedSwitches, int timestepOfState){
 		this.networkList = networkList;
 		this.leftOverEdges = leftOverEdges;
 		this.decoratedSwitches = decoratedSwitches;
@@ -19,7 +20,7 @@ public class DecoratedState {
 	public ArrayList<DecoratedNetwork> getNetworkList() {
 		return networkList;
 	}
-	public ArrayList<DecoratedCable> getLeftOverEdges() {
+	public ArrayList<Edge> getLeftOverEdges() {
 		return leftOverEdges;
 	}
 	public ArrayList<DecoratedSwitch> getDecoratedSwitches() {

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

@@ -1,6 +1,7 @@
 package ui.model;
 
 import model.AbstractCanvasObject;
+import model.Edge;
 /**
  * For the Visual State.
  * @author Tom
@@ -15,13 +16,13 @@ public class ExitCable {
 	//GroupNode or AbstractCpsObject
 	private AbstractCanvasObject start;
 	private AbstractCanvasObject finish;
-	private DecoratedCable cable;
+	private Edge edge;
 	
-	public ExitCable(ExitCableState state, AbstractCanvasObject start, AbstractCanvasObject finish, DecoratedCable cable) {
+	public ExitCable(ExitCableState state, AbstractCanvasObject start, AbstractCanvasObject finish, Edge edge) {
 		this.state = state;
 		this.start = start;
 		this.finish = finish;
-		this.cable = cable;
+		this.edge = edge;
 	}
 
 	public ExitCableState getState() {
@@ -33,8 +34,8 @@ public class ExitCable {
 	public AbstractCanvasObject getFinish() {
 		return finish;
 	}
-	public DecoratedCable getCable() {
-		return cable;
+	public Edge getEdge() {
+		return edge;
 	}
 
 }

+ 0 - 37
src/ui/model/IntermediateCableWithState.java

@@ -1,37 +0,0 @@
-package ui.model;
-
-import model.Edge;
-import model.HolonObject;
-import ui.model.DecoratedCable.CableState;
-
-/**
- * Intermediate to calculate/simulate the burning of Cables.
- * When all burning is done the Cable will be represented as a DecoratedCable.
- * @see DecoratedCable
- */
-public class IntermediateCableWithState {
-	private CableState state;
-	private Edge model;
-	public IntermediateCableWithState(Edge model,CableState state)
-	{
-		this.model = model;
-		this.state = state;
-	}
-	public CableState getState() {
-		return state;
-	}
-	public void setState(CableState state) {
-		this.state = state;
-	}
-	public Edge getModel() {
-		return model;
-	}
-	//ugly
-	public float getEnergyFromConneted() {
-		float energy = 0.0f;
-		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;
-	}
-	
-}

+ 6 - 10
src/ui/model/IntermediateCalculationCable.java

@@ -14,9 +14,9 @@ public class IntermediateCalculationCable {
 	private AbstractCanvasObject insideObject;
 	private GroupNode getInsideUpperNode;
 	private GroupNode getOutsideUpperNode;
-	private DecoratedCable cable;
-	public IntermediateCalculationCable(DecoratedCable cable, GroupNode getInsideUpperNode,GroupNode getOutsideUpperNode, AbstractCanvasObject insideObject, AbstractCanvasObject outsideObject){
-		this.cable = cable;
+	private Edge edge;
+	public IntermediateCalculationCable(Edge edge, GroupNode getInsideUpperNode,GroupNode getOutsideUpperNode, AbstractCanvasObject insideObject, AbstractCanvasObject outsideObject){
+		this.edge = edge;
 		this.getInsideUpperNode = getInsideUpperNode;
 		this.getOutsideUpperNode = getOutsideUpperNode;
 		this.insideObject = insideObject;
@@ -31,18 +31,14 @@ public class IntermediateCalculationCable {
 	public GroupNode getInsideUpperNode() {
 		return getInsideUpperNode;
 	}
-	public DecoratedCable getCable() {
-		return cable;
-	}
-	public Edge getModel() {
-		return cable.getModel();
+	public Edge getEdge() {
+		return edge;
 	}
 	public GroupNode getOutsideUpperNode() {
 		return getOutsideUpperNode;
 	}
 	public String toString() {
-		return getModel().toString();
-		
+		return edge.toString();
 	}
 
 }

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

@@ -9,7 +9,6 @@ import model.GroupNode;
 import model.HolonObject;
 import model.HolonSwitch;
 import model.Node;
-import ui.model.DecoratedCable.CableState;
 
 /**
  * For DecoratedState And VisualRepresentationalState
@@ -21,14 +20,14 @@ public class MinimumModel {
 	
 	
 	
-	private ArrayList<HolonObject> holonObjectList = new ArrayList<HolonObject>();
-	private ArrayList<IntermediateCableWithState> cableList = new ArrayList<IntermediateCableWithState>();
-	private ArrayList<Node> nodeList = new ArrayList<Node>();
-	private ArrayList<HolonSwitch> switchList = new ArrayList<HolonSwitch>();
+	private ArrayList<HolonObject> holonObjectList = new ArrayList<>();
+	private ArrayList<Edge> edgeList = new ArrayList<>();
+	private ArrayList<Node> nodeList = new ArrayList<>();
+	private ArrayList<HolonSwitch> switchList = new ArrayList<>();
 	//-->Only for Visual:
-	private ArrayList<GroupNode> uppderNodeList = new ArrayList<GroupNode>();
+	private ArrayList<GroupNode> uppderNodeList = new ArrayList<>();
 	private HashMap<AbstractCanvasObject, GroupNode> inGroupObjects = new HashMap<>();
-	HashMap<Edge, ArrayList<GroupNode>> inGroupEdges = new HashMap<Edge, ArrayList<GroupNode>>();
+	HashMap<Edge, ArrayList<GroupNode>> inGroupEdges = new HashMap<>();
 	//<--
 	
 	
@@ -53,7 +52,7 @@ public class MinimumModel {
 			}
 		}
 		for (Edge edge : edgeList) {
-			this.cableList.add(new IntermediateCableWithState(edge, CableState.Working));
+			this.edgeList.add(edge);
 			AbstractCanvasObject objectA = edge.getA();
 			AbstractCanvasObject objectB = edge.getB();
 			if(inGroupObjects.containsKey(objectA) || inGroupObjects.containsKey(objectB)){
@@ -93,11 +92,11 @@ public class MinimumModel {
 	public void setHolonObjectList(ArrayList<HolonObject> holonObjectList) {
 		this.holonObjectList = holonObjectList;
 	}
-	public ArrayList<IntermediateCableWithState> getEdgeList() {
-		return cableList;
+	public ArrayList<Edge> getEdgeList() {
+		return edgeList;
 	}
-	public void setEdgeList(ArrayList<IntermediateCableWithState> cableList) {
-		this.cableList = cableList;
+	public void setEdgeList(ArrayList<Edge> cableList) {
+		this.edgeList = cableList;
 	}
 	public ArrayList<Node> getNodeList() {
 		return nodeList;

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

@@ -3,21 +3,22 @@ package ui.model;
 import java.util.ArrayList;
 
 import model.AbstractCanvasObject;
+import model.Edge;
 import model.HolonObject;
 
 public class MinimumNetwork {
 	private ArrayList<HolonObject> holonObjectList = new ArrayList<HolonObject>();
-	private ArrayList<IntermediateCableWithState> edgeList = new ArrayList<IntermediateCableWithState>();
+	private ArrayList<Edge> edgeList = new ArrayList<Edge>();
 	//ToCalculate average path
 	private ArrayList<AbstractCanvasObject> nodeAndSwitches = new ArrayList<AbstractCanvasObject>();
-	public MinimumNetwork(ArrayList<HolonObject> holonObjectList, ArrayList<IntermediateCableWithState> edgeList){
+	public MinimumNetwork(ArrayList<HolonObject> holonObjectList, ArrayList<Edge> edgeList){
 		this.holonObjectList = holonObjectList;
 		this.edgeList = edgeList;
 	}
 	public ArrayList<HolonObject> getHolonObjectList() {
 		return holonObjectList;
 	}
-	public ArrayList<IntermediateCableWithState> getEdgeList() {
+	public ArrayList<Edge> getEdgeList() {
 		return edgeList;
 	}
 	public String toString()
@@ -28,8 +29,8 @@ public class MinimumNetwork {
 		}
 		objecte += "]";
 		String edges = "[";
-		for(IntermediateCableWithState edge :edgeList) {
-			edges += " " + edge.getModel();
+		for(Edge edge :edgeList) {
+			edges += " " + edge;
 		}
 		edges += "]";
 		return objecte + edges;

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

@@ -464,9 +464,17 @@ public class Model {
     	return getAllHolonObjectsOnCanvas().stream().flatMap(hO -> hO.getElements().stream().flatMap(ele -> ele.flexList.stream())).collect(Collectors.toList());
     }
     
-    public void resetFlexibilities() {
+    public void reset() {
+    	resetFlexibilities();
+    	resetEdges();
+    }
+    
+    private void resetFlexibilities() {
     	getAllFlexibilities().forEach(flex -> flex.reset());
     }
+    private void resetEdges() {
+    	this.getEdgesOnCanvas().forEach(edge -> edge.reset());
+    }
     
     
     public ArrayList<HolonObject> getAllHolonObjectsOnCanvas(){

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

@@ -15,14 +15,14 @@ import model.Node;
 import ui.model.ExitCable.ExitCableState;
 
 public class VisualRepresentationalState {
-	private ArrayList<Supplier> supplierList = new ArrayList<Supplier>();
-	private ArrayList<Passiv> passivList= new ArrayList<Passiv>();
-	private ArrayList<Consumer> consumerList= new ArrayList<Consumer>();
-	private ArrayList<Node> nodeList= new ArrayList<Node>();
-	private ArrayList<DecoratedCable> cableList= new ArrayList<DecoratedCable>();
-	private ArrayList<DecoratedSwitch> switchList= new ArrayList<DecoratedSwitch>();
-	private ArrayList<DecoratedGroupNode> groupNodeList= new ArrayList<DecoratedGroupNode>();
-	private ArrayList<ExitCable> exitCableList= new ArrayList<ExitCable>();
+	private ArrayList<Supplier> supplierList = new ArrayList<>();
+	private ArrayList<Passiv> passivList= new ArrayList<>();
+	private ArrayList<Consumer> consumerList= new ArrayList<>();
+	private ArrayList<Node> nodeList= new ArrayList<>();
+	private ArrayList<Edge> cableList= new ArrayList<>();
+	private ArrayList<DecoratedSwitch> switchList= new ArrayList<>();
+	private ArrayList<DecoratedGroupNode> groupNodeList= new ArrayList<>();
+	private ArrayList<ExitCable> exitCableList= new ArrayList<>();
 	
 	//ForFastAccessIndividualGroupNodes:
 	private HashMap<GroupNode, DecoratedGroupNode> createdGroupNodes;
@@ -47,7 +47,7 @@ public class VisualRepresentationalState {
 	public ArrayList<Node> getNodeList() {
 		return nodeList;
 	}
-	public ArrayList<DecoratedCable> getCableList() {
+	public ArrayList<Edge> getCableList() {
 		return cableList;
 	}
 	public ArrayList<DecoratedSwitch> getSwitchList() {
@@ -102,11 +102,11 @@ public class VisualRepresentationalState {
 				}
 				this.createdHolonObjects.put(pas.getModel(), pas);
 			}
-			for(DecoratedCable cable : net.getDecoratedCableList()) {
+			for(Edge cable : net.getDecoratedCableList()) {
 				addCable(cable, inGroupEdges, inGroupObjects,createdGroupNodes, exitCables);
 			}
 		}
-		for(DecoratedCable cable : stateFromThisTimestep.getLeftOverEdges()) {
+		for(Edge cable : stateFromThisTimestep.getLeftOverEdges()) {
 			addCable(cable, inGroupEdges, inGroupObjects, createdGroupNodes, exitCables);
 		}
 		for(Node node : minimumModel.getNodeList()) {
@@ -135,12 +135,12 @@ public class VisualRepresentationalState {
 			addTreeNode(root, dGroupNode, 1, fastaccess);
 		}
 		for(IntermediateCalculationCable cable : exitCables) {
-			createExitEdgesV2(root,cable.getCable() , cable.getInsideObject(),cable.getInsideUpperNode(),cable.getOusideObject(),cable.getOutsideUpperNode(), fastaccess);			
+			createExitEdgesV2(root,cable , cable.getInsideObject(),cable.getInsideUpperNode(),cable.getOusideObject(),cable.getOutsideUpperNode(), fastaccess);			
 		}
 	}
 
 
-	private void createExitEdgesV2(TreeNode<TreeGroupNodeData> root, DecoratedCable cable,  AbstractCanvasObject insideObject,
+	private void createExitEdgesV2(TreeNode<TreeGroupNodeData> root, IntermediateCalculationCable cable,  AbstractCanvasObject insideObject,
 			GroupNode insideUpperNode, AbstractCanvasObject ousideObject, GroupNode outsideUpperNode, HashMap<GroupNode, TreeNode<TreeGroupNodeData>> fastaccess) {
 		
 		
@@ -206,33 +206,33 @@ public class VisualRepresentationalState {
 			if(info.previous == Info.Nothing) {
 				if(info.next == Info.Child) {
 					state = ExitCableState.DOWN;
-					mylist.add(new ExitCable(state, insideObject, info.nextGroupNode, cable));
+					mylist.add(new ExitCable(state, insideObject, info.nextGroupNode, cable.getEdge()));
 				}else if(info.next == Info.Parent) {
 					state = ExitCableState.UP;
-					mylist.add(new ExitCable(state, insideObject, ousideObject, cable));
+					mylist.add(new ExitCable(state, insideObject, ousideObject, cable.getEdge()));
 				}else {
 					System.out.println("Error in VisualState");
 				}
 			}else if(info.previous == Info.Child) {
 				if(info.next == Info.Child) {
 					state = ExitCableState.DOWNDOWN;
-					mylist.add(new ExitCable(state, info.previousGroupNode, info.nextGroupNode, cable));
+					mylist.add(new ExitCable(state, info.previousGroupNode, info.nextGroupNode, cable.getEdge()));
 				}else if(info.next == Info.Parent) {
 					state = ExitCableState.DOWNUP;
-					mylist.add(new ExitCable(state, info.previousGroupNode, ousideObject, cable));
+					mylist.add(new ExitCable(state, info.previousGroupNode, ousideObject, cable.getEdge()));
 				}else {
 					state = ExitCableState.DOWN;
-					mylist.add(new ExitCable(state, info.previousGroupNode, ousideObject, cable));
+					mylist.add(new ExitCable(state, info.previousGroupNode, ousideObject, cable.getEdge()));
 				}
 			}else {//(info.previous == Info.Parent)
 				if(info.next == Info.Child) {
 					state = ExitCableState.DOWNUP;
-					mylist.add(new ExitCable(state, info.nextGroupNode, insideObject, cable));
+					mylist.add(new ExitCable(state, info.nextGroupNode, insideObject, cable.getEdge()));
 				}else if(info.next == Info.Parent) {
 					System.out.println("Error in VisualState");
 				}else {
 					state = ExitCableState.UP;
-					mylist.add(new ExitCable(state, ousideObject, insideObject, cable));
+					mylist.add(new ExitCable(state, ousideObject, insideObject, cable.getEdge()));
 				}
 			}
 		}
@@ -263,26 +263,26 @@ public class VisualRepresentationalState {
 	}
 
 
-	private void addCable(DecoratedCable cable, HashMap<Edge, ArrayList<GroupNode>> inGroupEdges, HashMap<AbstractCanvasObject, GroupNode> inGroupObjects,
+	private void addCable(Edge cable, HashMap<Edge, ArrayList<GroupNode>> inGroupEdges, HashMap<AbstractCanvasObject, GroupNode> inGroupObjects,
 			HashMap<GroupNode, DecoratedGroupNode> createdGroupNodes, ArrayList<IntermediateCalculationCable> exitCables) {
 		boolean isInGroup = false;
-		if(inGroupObjects.containsKey(cable.getModel().getA())) {
+		if(inGroupObjects.containsKey(cable.getA())) {
 			isInGroup = true;
 		}
-		if(inGroupObjects.containsKey(cable.getModel().getB())) {
+		if(inGroupObjects.containsKey(cable.getB())) {
 			isInGroup = true;
 		}
 		if(isInGroup) {
 			
-			boolean isIntern = inGroupObjects.get(cable.getModel().getA()) == inGroupObjects.get(cable.getModel().getB()); //Case null == null is not possible trough before Filtering MinimumModel#addUpperObjects(CpsUpperNode)
+			boolean isIntern = inGroupObjects.get(cable.getA()) == inGroupObjects.get(cable.getB()); //Case null == null is not possible trough before Filtering MinimumModel#addUpperObjects(CpsUpperNode)
 			if(isIntern) {
-				DecoratedGroupNode groupNodeFromBoth = createdGroupNodes.get(inGroupObjects.get(cable.getModel().getA()));
+				DecoratedGroupNode groupNodeFromBoth = createdGroupNodes.get(inGroupObjects.get(cable.getA()));
 				groupNodeFromBoth.getInternCableList().add(cable);				
 			}else {
-				if(inGroupObjects.containsKey(cable.getModel().getA())) {
-					exitCables.add(new IntermediateCalculationCable(cable, inGroupObjects.get(cable.getModel().getA()),inGroupObjects.get(cable.getModel().getB()), cable.getModel().getA(), cable.getModel().getB()));
-				} else if(inGroupObjects.containsKey(cable.getModel().getB())) {
-					exitCables.add(new IntermediateCalculationCable(cable, inGroupObjects.get(cable.getModel().getB()),inGroupObjects.get(cable.getModel().getA()), cable.getModel().getB(), cable.getModel().getA()));
+				if(inGroupObjects.containsKey(cable.getA())) {
+					exitCables.add(new IntermediateCalculationCable(cable, inGroupObjects.get(cable.getA()),inGroupObjects.get(cable.getB()), cable.getA(), cable.getB()));
+				} else if(inGroupObjects.containsKey(cable.getB())) {
+					exitCables.add(new IntermediateCalculationCable(cable, inGroupObjects.get(cable.getB()),inGroupObjects.get(cable.getA()), cable.getB(), cable.getA()));
 				}
 				
 			}

+ 20 - 16
src/ui/view/canvas/Canvas.java

@@ -15,6 +15,7 @@ import java.awt.image.BufferedImage;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashSet;
+import java.util.Optional;
 
 import javax.swing.ImageIcon;
 import javax.swing.JFrame;
@@ -35,7 +36,6 @@ import model.Node;
 import preferences.ColorPreference;
 import ui.controller.Control;
 import ui.model.Consumer;
-import ui.model.DecoratedCable;
 import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedHolonObject;
 import ui.model.DecoratedHolonObject.HolonObjectState;
@@ -306,12 +306,12 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 				controller.getScale(), null);
 	}
 
-	protected void paintCable(Graphics2D g, DecoratedCable cable, boolean isSelected) {
-		Vector2Int start = cable.getModel().getA().getPosition();
-		Vector2Int end = cable.getModel().getB().getPosition();
-		float currentEnergy = cable.getFlowEnergy();
-		float capacity = cable.getModel().maxCapacity;
-		boolean unlimited = cable.getModel().isUnlimitedCapacity();
+	protected void paintCable(Graphics2D g, Edge cable, boolean isSelected) {
+		Vector2Int start = cable.getA().getPosition();
+		Vector2Int end = cable.getB().getPosition();
+		float currentEnergy = cable.getActualFlow();
+		float capacity = cable.maxCapacity;
+		boolean unlimited = cable.isUnlimitedCapacity();
 		switch (cable.getState()) {
 		case Burned:
 			g.setColor(ColorPreference.Edge.Burned);
@@ -341,15 +341,18 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 	protected void paintExitCable(Graphics2D g, ExitCable eCable) {
 		Vector2Int start = eCable.getStart().getPosition();
 		Vector2Int end = eCable.getFinish().getPosition();
-		float currentEnergy = eCable.getCable().getFlowEnergy();
-		float capacity = eCable.getCable().getModel().maxCapacity;
-		boolean unlimited = eCable.getCable().getModel().isUnlimitedCapacity();
-		switch (eCable.getCable().getState()) {
+		float currentEnergy;
+		float capacity = eCable.getEdge().maxCapacity;
+		boolean unlimited = eCable.getEdge().isUnlimitedCapacity();
+		switch (eCable.getEdge().getState()) {
 		case Burned:
+			currentEnergy = 0.0f;
 			g.setColor(Color.RED);
 			g.setStroke(new BasicStroke(2));
 			break;
 		case Working:
+		default:
+			currentEnergy = eCable.getEdge().getActualFlow();
 			g.setColor(new Color(13, 175, 28));
 			g.setStroke(new BasicStroke(unlimited ? 2f : (currentEnergy / capacity * 2f) + 1));
 			break;
@@ -486,17 +489,18 @@ public class Canvas extends AbstractCanvas implements MouseListener, MouseMotion
 		g.setFont(new Font("TimesNewRoman", Font.PLAIN, Math.max((int) (controller.getScale() / 3.5f), 10)));
 		g2d.setColor(Color.BLACK);
 
-		VisualRepresentationalState visualState = controller.getSimManager().getActualVisualRepresentationalState();
+		Optional<VisualRepresentationalState> optVisualState = controller.getSimManager().getActualVisualRepresentationalState();
 		// VisualState Representation:
-		if (visualState == null) {
-			System.out.println("AHHH");
+		if (optVisualState.isEmpty()) {
 			return;
 		}
+		VisualRepresentationalState visualState = optVisualState.get();
+		
 		for (ExitCable cable : visualState.getExitCableList()) {
 			paintExitCable(g2d, cable);
 		}
-		for (DecoratedCable cable : visualState.getCableList()) {
-			paintCable(g2d, cable, selectedEdges.contains(cable.getModel()));
+		for (Edge cable : visualState.getCableList()) {
+			paintCable(g2d, cable, selectedEdges.contains(cable));
 		}
 		for (DecoratedGroupNode dGroupNode : visualState.getGroupNodeList()) {
 			paintGroupNode(g2d, dGroupNode);

+ 18 - 17
src/ui/view/canvas/GroupNodeCanvas.java

@@ -9,6 +9,7 @@ import java.awt.RenderingHints;
 import java.awt.event.MouseEvent;
 import java.io.IOException;
 import java.util.HashSet;
+import java.util.Optional;
 
 import model.AbstractCanvasObject;
 import model.Edge;
@@ -19,18 +20,17 @@ import model.Node;
 import preferences.ColorPreference;
 import ui.controller.Control;
 import ui.model.Consumer;
-import ui.model.DecoratedCable;
 import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedSwitch;
 import ui.model.ExitCable;
 import ui.model.Model;
 import ui.model.Passiv;
 import ui.model.Supplier;
+import ui.model.VisualRepresentationalState;
 import ui.view.inspector.UnitGraph;
 import utility.ImageImport;
 import utility.Vector2Int;
 
-
 //TODO(Tom2021-12-1) delete GroupNodeCanvas completely and only have canvas Class
 public class GroupNodeCanvas extends Canvas {
 	private String parentPath;
@@ -82,14 +82,17 @@ public class GroupNodeCanvas extends Canvas {
 		if (model.getSelectedEdge() != null)
 			selectedEdges.add(model.getSelectedEdge());
 
-		DecoratedGroupNode actualGroupNode = controller.getSimManager().getActualVisualRepresentationalState()
-				.getCreatedGroupNodes().get(groupNode);
+		Optional<VisualRepresentationalState> visState = controller.getSimManager().getActualVisualRepresentationalState();
+		if(visState.isEmpty()) {
+			return;
+		}
+		DecoratedGroupNode actualGroupNode = visState.get().getCreatedGroupNodes().get(groupNode);
 		// VisualState Representation:
 		for (ExitCable cable : actualGroupNode.getExitCableList()) {
 			paintExitCable(g2d, cable);
 		}
-		for (DecoratedCable cable : actualGroupNode.getInternCableList()) {
-			paintCable(g2d, cable, selectedEdges.contains(cable.getModel()));
+		for (Edge cable : actualGroupNode.getInternCableList()) {
+			paintCable(g2d, cable, selectedEdges.contains(cable));
 		}
 
 		for (DecoratedGroupNode dGroupNode : actualGroupNode.getGroupNodeList()) {
@@ -296,12 +299,12 @@ public class GroupNodeCanvas extends Canvas {
 			setRightClickMenu(e);
 
 			markObjects();
-			boolean doubleclick = doubleClick();  
+			boolean doubleclick = doubleClick();
 			if (doubleclick && tempCps != null && tempCps instanceof HolonSwitch) {
 				((HolonSwitch) tempCps).switchState();
 			}
 			if (doubleclick && tempCps != null && tempCps instanceof GroupNode) {
-				controller.getGui().openNewUpperNodeTab((GroupNode)tempCps);
+				controller.getGui().openNewUpperNodeTab((GroupNode) tempCps);
 			}
 			controller.calculateStateAndVisualForTimeStep(model.getActualTimeStep());
 			repaint();
@@ -332,8 +335,8 @@ public class GroupNodeCanvas extends Canvas {
 						y = e.getY();
 
 						// Make sure its in bounds
-						if (e.getX() < controller.getScaleDiv2() +  + 5)
-							x = controller.getScaleDiv2() +  + 5;
+						if (e.getX() < controller.getScaleDiv2() + +5)
+							x = controller.getScaleDiv2() + +5;
 						else if (e.getX() > this.getWidth() - controller.getScaleDiv2())
 							x = this.getWidth() - controller.getScaleDiv2();
 						if (e.getY() < controller.getScaleDiv2())
@@ -360,8 +363,8 @@ public class GroupNodeCanvas extends Canvas {
 								y = (int) (cps.getPosition().getY() + yDist);
 
 								// Make sure its in bounds
-								if (x <  + 5 + controller.getScaleDiv2())
-									x = controller.getScaleDiv2() +  + 5;
+								if (x < +5 + controller.getScaleDiv2())
+									x = controller.getScaleDiv2() + +5;
 								else if (x > this.getWidth() - controller.getScaleDiv2())
 									x = this.getWidth() - controller.getScaleDiv2();
 								if (y <= controller.getScaleDiv2())
@@ -427,10 +430,8 @@ public class GroupNodeCanvas extends Canvas {
 						y2 = sy;
 					}
 
-					if (x1 <= 0
-							&& y1 <= (int) (5 + (model.getScale() + scalediv20 + 10) * count) + Model.getScaleDiv2()
-							&& x2 >=  0
-							&& y2 >= (int) (5 + (model.getScale() + scalediv20 + 10) * count)) {
+					if (x1 <= 0 && y1 <= (int) (5 + (model.getScale() + scalediv20 + 10) * count) + Model.getScaleDiv2()
+							&& x2 >= 0 && y2 >= (int) (5 + (model.getScale() + scalediv20 + 10) * count)) {
 						tempSelected.add(cps);
 
 					}
@@ -466,7 +467,7 @@ public class GroupNodeCanvas extends Canvas {
 					cps = ed.getA();
 				}
 
-				cx = 0 ;
+				cx = 0;
 				cy = (int) (scalediv20 + 5 + (50 + scalediv20 + 10) * count);
 				if (x - 50 <= cx && y - 50 <= cy && x >= cx && y >= cy) {
 

+ 10 - 18
src/ui/view/information/FilterableGroupNode.java

@@ -6,12 +6,12 @@ import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 import jdk.jfr.Unsigned;
+import model.Edge;
 import model.Flexibility;
 import model.GroupNode;
 import model.HolonElement;
 import model.Node;
 import ui.model.Consumer;
-import ui.model.DecoratedCable;
 import ui.model.DecoratedGroupNode;
 import ui.model.DecoratedHolonObject;
 import ui.model.DecoratedHolonObject.HolonObjectState;
@@ -28,33 +28,25 @@ import ui.model.Supplier;
  */
 public class FilterableGroupNode {
 	private GroupNode model;
-	private ArrayList<Supplier> supplierList;
-	private ArrayList<Passiv> passivList;
-	private ArrayList<Consumer> consumerList;
-	private ArrayList<Node> nodeList;
+	private ArrayList<Supplier> supplierList = new ArrayList<>();
+	private ArrayList<Passiv> passivList = new ArrayList<>();
+	private ArrayList<Consumer> consumerList = new ArrayList<>();
+	private ArrayList<Node> nodeList = new ArrayList<>();
 	/**
 	 * Cables that only exist on that group node. From a object in that group node
 	 * to a object in that group Node. Not exit the group node (a layer down).
 	 */
-	private ArrayList<DecoratedCable> internCableList;
+	private ArrayList<Edge> internCableList = new ArrayList<>();
 	/**
 	 * Cables that exit this group node (a Layer Up). From a object in this group
 	 * node to a object in a upper layer.
 	 */
-	private ArrayList<ExitCable> exitCableList;
-	private ArrayList<DecoratedSwitch> switchList;
-	private ArrayList<FilterableGroupNode> groupNodeList;
+	private ArrayList<ExitCable> exitCableList = new ArrayList<>();
+	private ArrayList<DecoratedSwitch> switchList = new ArrayList<>();
+	private ArrayList<FilterableGroupNode> groupNodeList = new ArrayList<>();
 
 	public FilterableGroupNode(GroupNode model, int iteration) {
 		this.model = model;
-		this.supplierList = new ArrayList<Supplier>();
-		this.passivList = new ArrayList<Passiv>();
-		this.consumerList = new ArrayList<Consumer>();
-		this.nodeList = new ArrayList<Node>();
-		this.internCableList = new ArrayList<DecoratedCable>();
-		this.exitCableList = new ArrayList<ExitCable>();
-		this.switchList = new ArrayList<DecoratedSwitch>();
-		this.groupNodeList = new ArrayList<FilterableGroupNode>();
 	}
 
 	public FilterableGroupNode(DecoratedGroupNode dGroupNode, int iteration) {
@@ -90,7 +82,7 @@ public class FilterableGroupNode {
 		return nodeList;
 	}
 
-	public ArrayList<DecoratedCable> getInternCableList() {
+	public ArrayList<Edge> getInternCableList() {
 		return internCableList;
 	}
 

+ 17 - 8
src/ui/view/information/HolonInformationPanel.java

@@ -9,6 +9,7 @@ import java.awt.GridLayout;
 import java.awt.Insets;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Optional;
 import java.util.function.Predicate;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -39,6 +40,7 @@ import ui.model.DecoratedHolonObject;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.Passiv;
 import ui.model.Supplier;
+import ui.model.VisualRepresentationalState;
 import utility.FormatFloat;
 
 public class HolonInformationPanel extends JPanel {
@@ -86,8 +88,12 @@ public class HolonInformationPanel extends JPanel {
 		if (control.getModel().getSelectedObjects().isEmpty()) {
 			return;
 		}
-		FilterableGroupNode decoratedGroupNode = multiSelectionToFilterableGroupNode();
-
+		Optional<FilterableGroupNode> filteredGroupNode = multiSelectionToFilterableGroupNode();
+		if(filteredGroupNode.isEmpty()) {
+			return;
+		}
+		
+		FilterableGroupNode decoratedGroupNode = filteredGroupNode.get();
 		// UPDATE SUPPLY STATE
 		int producerAmount = decoratedGroupNode.getAmountOfSupplier(stateFilter);
 		int overSuppliedAmount = decoratedGroupNode.getAmountOfConsumerWithState(stateFilter,
@@ -183,13 +189,17 @@ public class HolonInformationPanel extends JPanel {
 		this.repaint();
 	}
 
-	private FilterableGroupNode multiSelectionToFilterableGroupNode() {
+	private Optional<FilterableGroupNode> multiSelectionToFilterableGroupNode() {
 		FilterableGroupNode temp = new FilterableGroupNode(new GroupNode("Temp"),
 				control.getModel().getActualTimeStep());
 
+		Optional<VisualRepresentationalState> visState = control.getSimManager().getActualVisualRepresentationalState();
+		if(visState.isEmpty()) {
+			return Optional.empty();
+		}
+		
 		// GroupNodes
-		HashMap<GroupNode, DecoratedGroupNode> accessMapGroupNode = control.getSimManager()
-				.getActualVisualRepresentationalState().getCreatedGroupNodes();
+		HashMap<GroupNode, DecoratedGroupNode> accessMapGroupNode = visState.get().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().getActualTimeStep()))
@@ -198,8 +208,7 @@ public class HolonInformationPanel extends JPanel {
 		temp.getGroupNodeList().addAll(groupNodeList);
 
 		// HolonObjects
-		HashMap<HolonObject, DecoratedHolonObject> accessMapHolonObject = control.getSimManager()
-				.getActualVisualRepresentationalState().createdHolonObjects;
+		HashMap<HolonObject, DecoratedHolonObject> accessMapHolonObject = visState.get().createdHolonObjects;
 		List<DecoratedHolonObject> holonObjectList = control.getModel().getSelectedObjects().stream()
 				.filter(object -> object instanceof HolonObject).map(object -> accessMapHolonObject.get(object))
 				.collect(Collectors.toList());
@@ -217,7 +226,7 @@ public class HolonInformationPanel extends JPanel {
 				break;
 			}
 		}
-		return temp;
+		return Optional.of(temp);
 	}
 
 	public HolonInformationPanel(Control control) {

+ 44 - 51
src/ui/view/main/TimePanel.java

@@ -100,7 +100,7 @@ public class TimePanel extends JPanel implements ActionListener {
 		}
 	};
 	// private Model model;
-	private Control controller;
+	private Control control;
 	private int dragResetIteration = 0;
 	private JLabel simSpeedLabel = new JLabel("Speed:");
 	private JSlider speedSlider = new JSlider();
@@ -115,22 +115,9 @@ public class TimePanel extends JPanel implements ActionListener {
 	 */
 	public TimePanel(Control cont) {
 		super();
-		this.controller = cont;
+		this.control = cont;
 		// One Iteration
-		timer = new Timer(0, new ActionListener() {
-			@Override
-			public void actionPerformed(ActionEvent ae) {
-				timeSlider.setValue(timeSlider.getValue() + 1);
-				controller.setCurIteration(timeSlider.getValue());
-				timer.setDelay(cont.getModel().getTimerSpeed());
-				if (timeSlider.getValue() >= cont.getModel().getMaxIterations() - 1) {
-					running = false;
-					playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/play.png", 30, 30)));
-					timer.stop();
-				}
-			}
-		});
-
+		timer = new Timer(0, clicked -> timerAction());
 		// Time Slider. Panels and Buttons
 		this.setLayout(new BorderLayout(0, 0));
 		this.setBorder(null);
@@ -142,7 +129,7 @@ public class TimePanel extends JPanel implements ActionListener {
 		timeSlider.setToolTipText("Time Slider");
 		timeSlider.setMaximum(cont.getModel().getMaxIterations() - 1);
 		timeSlider.setValue(0);
-		timeSlider.addChangeListener(changeEvent -> controller.setCurIteration(timeSlider.getValue()));
+		timeSlider.addChangeListener(changeEvent -> control.setCurIteration(timeSlider.getValue()));
 
 		timeSlider.addMouseListener(new MouseAdapter() {
 			@Override
@@ -156,7 +143,7 @@ public class TimePanel extends JPanel implements ActionListener {
 			public void mouseDragged(MouseEvent e) {
 				if (dragResetIteration != cont.getModel().getActualTimeStep()) {
 					if (running) {
-						playBtn.doClick();
+						play();
 					}
 				}
 			}
@@ -173,29 +160,7 @@ public class TimePanel extends JPanel implements ActionListener {
 		playBtn.setBorderPainted(false);
 		playBtn.setBorder(null);
 		playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/play.png", 30, 30)));
-		playBtn.addActionListener(new ActionListener() {
-			@Override
-			public void actionPerformed(ActionEvent e) {
-				if (cont.getModel().getActualTimeStep() == cont.getModel().getMaxIterations() - 1)
-					timeSlider.setValue(timeSlider.getMinimum());
-				running = !running;
-				if (running) {
-					timer.setDelay(cont.getModel().getTimerSpeed());
-
-					/*
-					 * start the Performance Test / performanceTime = System.nanoTime();
-					 * timeSlider.setValue(0); timer.setDelay(0); speedSlider.setValue(10);
-					 * timeSlider.setValue(0); //
-					 */
-
-					timer.start();
-					playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/pause.png", 30, 30)));
-				} else {
-					timer.stop();
-					playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/play.png", 30, 30)));
-				}
-			}
-		});
+		playBtn.addActionListener(clicked -> play());
 		timeResetBtn.setToolTipText("Reset");
 
 		timeResetBtn.setContentAreaFilled(false);
@@ -204,11 +169,11 @@ public class TimePanel extends JPanel implements ActionListener {
 		timeResetBtn.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent ae) {
 				timeSlider.setValue(timeSlider.getMinimum());
-				controller.setCurIteration(timeSlider.getValue());
-				// controller.calculateStateForCurrentTimeStep();
-				controller.resetSimulation();
+				control.setCurIteration(timeSlider.getValue());
+				control.resetSimulation();
+				control.calculateStateAndVisualForCurrentTimeStep();
 				if (running) {
-					playBtn.doClick();
+					play();
 				}
 			}
 		});
@@ -220,7 +185,7 @@ public class TimePanel extends JPanel implements ActionListener {
 		timeForwardBtn.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent ae) {
 				timeSlider.setValue(timeSlider.getValue() + 1);
-				controller.setCurIteration(timeSlider.getValue());
+				control.setCurIteration(timeSlider.getValue());
 			}
 		});
 		timeBackwardBtn.setToolTipText("Backward");
@@ -230,7 +195,7 @@ public class TimePanel extends JPanel implements ActionListener {
 		timeBackwardBtn.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent ae) {
 				timeSlider.setValue(timeSlider.getValue() - 1);
-				controller.setCurIteration(timeSlider.getValue());
+				control.setCurIteration(timeSlider.getValue());
 			}
 		});
 
@@ -269,7 +234,7 @@ public class TimePanel extends JPanel implements ActionListener {
 				 * Second and so on,
 				 */
 				int calculationsPerSecond = 1 << speedSlider.getValue();
-				controller.setTimerSpeed(1024 >> speedSlider.getValue());
+				control.setTimerSpeed(1024 >> speedSlider.getValue());
 				speedSlider.setToolTipText("Speed: " + calculationsPerSecond + " Calculations per Second.");
 			}
 		});
@@ -338,7 +303,8 @@ public class TimePanel extends JPanel implements ActionListener {
 			@Override
 			public void actionPerformed(ActionEvent e) {
 				timeSlider.setValue(timeSlider.getValue() - 1);
-				controller.resetSimulation();
+				control.resetSimulation();
+				control.calculateStateAndVisualForCurrentTimeStep();
 			}
 		});
 
@@ -354,6 +320,33 @@ public class TimePanel extends JPanel implements ActionListener {
 		});
 	}
 
+	
+	public void timerAction() {
+		timeSlider.setValue(timeSlider.getValue() + 1);
+		control.setCurIteration(timeSlider.getValue());
+		timer.setDelay(control.getModel().getTimerSpeed());
+		if (timeSlider.getValue() >= control.getModel().getMaxIterations() - 1) {
+			running = false;
+			playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/play.png", 30, 30)));
+			timer.stop();
+		}
+	}
+	
+	public void play() {
+		if (control.getModel().getActualTimeStep() == control.getModel().getMaxIterations() - 1)
+			timeSlider.setValue(timeSlider.getMinimum());
+		running = !running;
+		if (running) {
+			timer.setDelay(control.getModel().getTimerSpeed());
+			timer.start();
+			playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/pause.png", 30, 30)));
+		} else {
+			timer.stop();
+			playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/play.png", 30, 30)));
+		}
+	}
+	
+	
 	/**
 	 * Returns the TimeSlider.
 	 * 
@@ -387,8 +380,8 @@ public class TimePanel extends JPanel implements ActionListener {
 				resetField = false;
 			if (resetField)
 				iterationsField.setText("" + iterations);
-			controller.getModel().setIterations(Integer.parseInt(iterationsField.getText()));
-			timeSlider.setMaximum(controller.getModel().getMaxIterations() - 1);
+			control.getModel().setIterations(Integer.parseInt(iterationsField.getText()));
+			timeSlider.setMaximum(control.getModel().getMaxIterations() - 1);
 			timeSlider.setLabelTable(null);// Otherwise the ticks won't update
 			timeSlider.setMajorTickSpacing((int) Math.ceil(((double) iterations) / 20));
 			timeSlider.setMinorTickSpacing((int) Math.ceil(((double) iterations) / 100));// Even though the final mark

+ 6 - 6
src/ui/view/window/Outliner.java

@@ -16,10 +16,10 @@ import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeCellRenderer;
 
 import model.AbstractCanvasObject;
+import model.Edge;
 import preferences.ColorPreference;
 import ui.controller.Control;
 import ui.model.Consumer;
-import ui.model.DecoratedCable;
 import ui.model.DecoratedNetwork;
 import ui.model.DecoratedState;
 import ui.model.DecoratedSwitch;
@@ -47,7 +47,7 @@ public class Outliner extends JFrame {
 		this.setTitle("Outliner");
 		setLocationRelativeTo(parentFrame);
 		this.setVisible(true);
-		repaintWithDecoratedState(controller.getSimManager().getActualDecorState());
+		controller.getSimManager().getActualDecorState().ifPresent(state -> repaintWithDecoratedState(state));
 		this.getContentPane().add(tabbedPane);
 		this.addWindowListener(new java.awt.event.WindowAdapter() {
 		    @Override
@@ -110,13 +110,13 @@ public class Outliner extends JFrame {
 				objects.add(new DefaultMutableTreeNode(pas.getModel().getName()));
 			}
 			topStatePanel.add(network);
-			for(DecoratedCable cable : dNet.getDecoratedCableList()) {
-				cables.add(new DefaultMutableTreeNode(cable.getModel().toString()));
+			for(Edge cable : dNet.getDecoratedCableList()) {
+				cables.add(new DefaultMutableTreeNode(cable.toString()));
 			}
 		}
 		
-		for(DecoratedCable cable : decoratedState.getLeftOverEdges()) {
-			cables.add(new DefaultMutableTreeNode(cable.getModel().toString()));
+		for(Edge cable : decoratedState.getLeftOverEdges()) {
+			cables.add(new DefaultMutableTreeNode(cable.toString()));
 		}