Browse Source

Clean Up 1.

Tom Troppmann 5 years ago
parent
commit
d8e991c5c2

+ 3 - 87
src/classes/CpsEdge.java

@@ -13,36 +13,10 @@ import java.util.ArrayList;
  */
 public class CpsEdge {
 
-    public static final int CON_UPPER_NODE = 0;
-    public static final int CON_UPPER_NODE_AND_INSIDE = 1;
-    public static final int CON_UPPER_NODE_NOT_INSIDE = 2;
-
-    public static final float CAPACITY_INFINITE = -1;
-    public static final float CAPACITY_TO_UPPER_NODE = -2;
     // Max. capacity of the Edge, if flow is greater than the status --> is
     // Working would be false
     @Expose
     float maxCapacity;
-    // for internal use --> flow of electricity (simulation state)
-    // Current flow of electricity (through the edge)
-    @Expose
-    float flow;
-    /*
-     * Represents the actual status of the Edge (true = flows electricity; false
-     * = no flow of electricity) State represents the real status of the edge If
-     * it breaks --> stay ruin no matter the actual scenario The only way to
-     * repair it is through manual change (setStateEdge)
-     */
-    @Expose
-    boolean isWorking;
-    /*
-     * 0 = not connected to an upper node
-     * 1 = connected to an uppder node & connected inside
-     * 2 = connected to an upper node but not inside
-     * Is false when not
-     */
-    @Expose
-    int isConnected;
     ArrayList<Integer> tags;
     // for internal use --> flow of electricity (simulation state)
     ArrayList<Integer> pseudoTags;
@@ -63,8 +37,6 @@ public class CpsEdge {
         this.a.addConnection(this);
         this.b.addConnection(this);
         this.maxCapacity = 100;
-        flow = 0;
-        isWorking = true;
         pseudoTags = new ArrayList<>();
     }
 
@@ -81,9 +53,6 @@ public class CpsEdge {
         this.a.addConnection(this);
         this.b.addConnection(this);
         this.maxCapacity = maxCap;
-        flow = 0;
-        isWorking = true;
-        isConnected = CON_UPPER_NODE;
         pseudoTags = new ArrayList<>();
     }
 
@@ -105,39 +74,9 @@ public class CpsEdge {
         this.maxCapacity = cap;
     }
 
-    /**
-     * Getter fot the current flow.
-     *
-     * @return the flow
-     */
-    public float getFlow() {
-        return flow;
-    }
 
-    /**
-     * Set the flow into a new one.
-     *
-     * @param flow the flow to set
-     */
-    public void setFlow(float flow) {
-        this.flow = flow;
-        /**
-         * if (flow <= maxCapacity || flow == -1) { isWorking = true; } else {
-         * isWorking = false; state = false;
-         **/
-    }
 
-    /**
-     * Calculates the state of the edge (see description of isWorking).
-     */
-    public void calculateState() {
-        if (flow > maxCapacity
-                && maxCapacity != CAPACITY_INFINITE
-                && maxCapacity != CAPACITY_TO_UPPER_NODE) {
-            isWorking = false;
-            flow = 0;
-        }
-    }
+
 
     /**
      * Getter for the Source.
@@ -175,23 +114,9 @@ public class CpsEdge {
         this.b = b;
     }
 
-    /**
-     * Getter for the status.
-     *
-     * @return the state
-     */
-    public boolean isWorking() {
-        return isWorking;
-    }
 
-    /**
-     * Set the state manually to a new one.
-     *
-     * @param state the state
-     */
-    public void setWorkingState(boolean state) {
-        isWorking = state;
-    }
+
+
 
     /**
      * Getter for the ArrayList of tags.
@@ -264,16 +189,7 @@ public class CpsEdge {
         }
     }
 
-    public int getConnected() {
-        return isConnected;
-    }
 
-    public void setConnected(int state) {
-        isConnected = state;
-        if (state == CON_UPPER_NODE_AND_INSIDE) {
-            //maxCapacity = CAPACITY_TO_UPPER_NODE;
-        }
-    }
     
     /**
      * Check if a CpsEdge is Connected to the AbstractCpsObject.

+ 2 - 3
src/classes/HolonElement.java

@@ -235,9 +235,8 @@ public class HolonElement implements LocalMode, GraphEditable{
      *
      * @return totalEnergy (actual)
      */
-    public float getOverallEnergy() {
-        float totalEnergy =  amount * energyPerElement;
-        return totalEnergy;
+    public float getMaximumEnergy() {
+        return amount * energyPerElement;
     }
 
     /**

+ 3 - 175
src/classes/HolonObject.java

@@ -14,53 +14,16 @@ import javafx.util.converter.PercentageStringConverter;
  *
  * @author Gruppe14
  */
-public class HolonObject extends AbstractCpsObject {
-	@Deprecated
-	enum State{
-		NO_ENERGY, NOT_SUPPLIED, SUPPLIED, PRODUCER, PARTIALLY_SUPPLIED, OVER_SUPPLIED
-	}
-	@Deprecated
-    public final static int NO_ENERGY = 0;
-	@Deprecated
-    public final static int NOT_SUPPLIED = 1;
-	@Deprecated
-    public final static int SUPPLIED = 2;
-	@Deprecated
-    public final static int PRODUCER = 3;
-	@Deprecated
-    public final static int PARTIALLY_SUPPLIED = 4;
-	@Deprecated
-    public final static int OVER_SUPPLIED = 5;
-    
-    /*
-     * Color of the actual state (red = no supplied, yellow = partially supplied
-     * and green = supplied)
-     */
-    @Expose
-    private Color stateColor; //TODO: to draw function 
+public class HolonObject extends AbstractCpsObject { 
     /* Array of all consumers */
     private ArrayList<HolonElement> elements;
-    /* Total of consumption */
-    @Expose
-    private float currentEnergy;
     /* Array for tracking Production */
     private float[] trackingProd;
     /* Array for tracking Consumption */
     private float[] trackingCons;
     /* Total Flexibility */
     private float totalFlex;
-    @Deprecated
-    @Expose 
-    private int state = 0;
-    /**
-     * Energy level that was supplied by other HolonObjects in the current Calculation
-     */
-    private float currentSupply;
     
-    /** TODO: outsourcing 
-     * Percentage of supplied energy of the energy level needed to supply all elements
-     */
-    private float suppliedPercentage;
     /**
      * Constructor Set by default the name of the object equals to the category
      * name, until the user changes it.
@@ -123,45 +86,10 @@ public class HolonObject extends AbstractCpsObject {
     public void deleteElement(int idx) {
     	elements.remove(idx);
     }
-    /**
-     * Calculate the maximum energy a holonObject can consume from all object that are aktive this moment;
-     *
-     * @return the maximal active energy possibel
-     */
-    public float getMaxActiveEnergy() {
-        float temp = 0;
-        for (HolonElement e : getElements()) {
-            if (e.isActive()) {
-                temp += e.getOverallEnergy();
-            }
-        }
-        currentEnergy = temp;
-        return temp;
-    }
-    
     
 
     
 
-    /**
-     * Getter for the current energy at a given timestep.
-     *
-     * @param x timestep
-     * @return corresponding energy
-     */
-    @Deprecated
-    public float getCurrentEnergyAtTimeStepWithoutFlexiblesAndResetFlexibles(int x) {
-        float temp = 0;
-        for (HolonElement e : getElements()) {
-            if (e.isActive() && !e.isFlexible()) {
-                temp += e.getOverallEnergyAtTimeStep(x);
-            } else if (e.isFlexible()) {
-                e.setEnergyPerElement(0);
-            }
-        }
-        currentEnergy = temp;
-        return currentEnergy;
-    }
 
 
     /**
@@ -196,52 +124,6 @@ public class HolonObject extends AbstractCpsObject {
         return newArr;
     }
 
-    /**
-     * Get the state of the Object.
-     *
-     * @return state the State of the Element
-     */
-    @Deprecated
-    public int getState() {
-        return this.state;
-    }
-
-    /**
-     * Set the state of the Object.
-     *
-     * @param state boolean if the Object is fully supplied
-     */
-    @Deprecated
-    public void setState(int state) {
-        this.state = state;
-        switch (state) {
-            case NO_ENERGY:
-                stateColor = Color.WHITE;
-                break;
-
-            case NOT_SUPPLIED:
-                stateColor = new Color(230, 120, 100);
-                break;
-
-            case SUPPLIED:
-                stateColor = Color.GREEN;
-                break;
-
-            case PRODUCER:
-                stateColor = Color.lightGray;
-                break;
-
-            case PARTIALLY_SUPPLIED:
-                stateColor = Color.YELLOW;
-                break;
-
-            case OVER_SUPPLIED:
-                // find different purple-tones at
-                // http://www.rapidtables.com/web/color/purple-color.htm
-                stateColor = new Color(138, 43, 226);
-                break;
-        }
-    }
 
     /**
      * Search for the first element with the name.
@@ -346,23 +228,9 @@ public class HolonObject extends AbstractCpsObject {
     public int countProducingElements(int timestep) {
     	return (int) getElements().stream().filter(element -> element.isActive() && (element.getEnergyAtTimeStep(timestep) > 0)).count();
     }
-    /**
-     * Get the Color.
-     *
-     * @return stateColor the Color
-     */
-    public Color getColor() {
-        return stateColor;
-    }
+    
+
 
-    /**
-     * Set the State Color.
-     *
-     * @param color the Color
-     */
-    public void setColor(Color color) {
-        stateColor = color;
-    }
 
     /**
      * Get the Array Production
@@ -480,26 +348,6 @@ public class HolonObject extends AbstractCpsObject {
         sb.append("id=").append(id)
                 .append(", name=").append(name)
                 .append(", state=");
-        switch (state) {
-            case NO_ENERGY:
-                sb.append("NO_ENERGY");
-                break;
-            case NOT_SUPPLIED:
-                sb.append("NOT_SUPPLIED");
-                break;
-            case SUPPLIED:
-                sb.append("SUPPLIED");
-                break;
-            case PRODUCER:
-                sb.append("PRODUCER");
-                break;
-            case PARTIALLY_SUPPLIED:
-                sb.append("PARTIALLY_SUPPLIED");
-                break;
-            case OVER_SUPPLIED:
-                sb.append("OVER_SUPPLIED");
-                break;
-        }
         sb.append(", elements=[");
         for (int i = 0; i < getElements().size(); i++) {
             HolonElement el = getElements().get(i);
@@ -513,24 +361,4 @@ public class HolonObject extends AbstractCpsObject {
         return sb.toString();
     }
 
-	/**
-	 * @return the {@link #currentSupply}
-	 */
-	public float getCurrentSupply() {
-		return currentSupply;
-	}
-
-	/**
-	 * @param currentSupply the {@link #currentSupply} to set
-	 */
-	public void setCurrentSupply(float currentSupply) {
-		this.currentSupply = currentSupply;
-	}
-	
-	/**
-	 * @return {@link #suppliedPercentage}
-	 */
-	public float getSuppliedPercentage(){
-		return suppliedPercentage;
-	}
 }

+ 0 - 35
src/exampleAlgorithms/RandomSwitchesAlgorithm.java

@@ -1,35 +0,0 @@
-package exampleAlgorithms;
-
-import api.CpsAlgorithm;
-import ui.controller.Control;
-import ui.model.Model;
-import classes.*;
-
-public class RandomSwitchesAlgorithm implements CpsAlgorithm {
-
-	@Override
-	public void runAlgorithm(Model model, Control controller) {
-		randomSwitches(model);
-	}
-
-	/**
-	 * Sets every Switch to a random state.
-	 * 
-	 * @param model
-	 *            the Model
-	 */
-	private void randomSwitches(Model model) {
-		for (HolonSwitch s : model.getSwitches()) {
-			// Set to Manual Mode
-			s.setManualMode(true);
-			// Generate a random number between 0 and 1
-			double randomDouble = Math.random();
-			if (randomDouble < 0.5) {
-				s.setManualState(true);
-			} else {
-				s.setManualState(false);
-			}
-		}
-		
-	}
-}

+ 0 - 44
src/exampleAlgorithms/RepairAllEdges.java

@@ -1,44 +0,0 @@
-package exampleAlgorithms;
-
-import api.CpsAlgorithm;
-import classes.AbstractCpsObject;
-import classes.CpsEdge;
-import classes.CpsUpperNode;
-import ui.controller.Control;
-import ui.model.Model;
-
-public class RepairAllEdges implements CpsAlgorithm {
-
-	@Override
-	public void runAlgorithm(Model model, Control controller) {
-		repairAllEdgesOnMainCanvas(model);
-	}
-
-	/**
-	 * Repairs all Edges on the main Canvas.
-	 * 
-	 * @param model
-	 *            the Model
-	 */
-	private void repairAllEdgesOnMainCanvas(Model model) {
-		for (AbstractCpsObject obj : model.getObjectsOnCanvas()) {
-			if (obj instanceof CpsUpperNode) {
-				repairAllEdgesInUpperNode((CpsUpperNode) obj);
-			}
-			for (CpsEdge e : obj.getConnections()) {
-				e.setWorkingState(true);
-			}
-		}
-	}
-
-	private void repairAllEdgesInUpperNode(CpsUpperNode uNode) {
-		for (AbstractCpsObject obj : uNode.getNodes()) {
-			if (obj instanceof CpsUpperNode) {
-				repairAllEdgesInUpperNode((CpsUpperNode) obj);
-			}
-			for (CpsEdge e : obj.getConnections()) {
-				e.setWorkingState(true);
-			}
-		}
-	}
-}

+ 0 - 11
src/ui/controller/Control.java

@@ -562,7 +562,6 @@ public class Control {
      * @param x current Iteration
      */
     public void calculateStateForTimeStep(int x) {
-        // simulationManager.reset();
         simulationManager.calculateStateForTimeStep(x);
     }
 
@@ -572,7 +571,6 @@ public class Control {
      */
     public void resetSimulation() {
         setIsSimRunning(false);
-        simulationManager.resetSimulation();
     }
 
     /**
@@ -889,15 +887,6 @@ public class Control {
         return objectController.getNumberHolonObjects(list);
     }
 
-    /**
-     * Get the number of HolonObjects with the given state in the given List
-     *
-     * @param list
-     * @param state
-     */
-    public int getNumberStateObjects(ArrayList<AbstractCpsObject> list, int state) {
-        return objectController.getNumberStateObjects(list, state);
-    }
 
     /**
      * Returns HolonBodySCALE.

+ 1 - 20
src/ui/controller/ObjectController.java

@@ -177,26 +177,7 @@ public class ObjectController {
         return val;
     }
 
-    /**
-     * Get the number of HolonObjects with the given state in the given List
-     *
-     * @param list
-     * @param state
-     */
-    public int getNumberStateObjects(ArrayList<AbstractCpsObject> list, int state) {
-        int val = 0;
-
-        for (AbstractCpsObject obj : list) {
-            if (obj instanceof HolonObject) {
-                if (((HolonObject) obj).getState() == state || (state == 2 && ((HolonObject) obj).getState() == 3)) {
-                    val++;
-                }
-            } else if (obj instanceof CpsUpperNode) {
-                val += getNumberStateObjects(((CpsUpperNode) obj).getNodes(), state);
-            }
-        }
-        return val;
-    }
+   
 
     /**
      * add the ID of a HolonBody.

+ 5 - 430
src/ui/controller/SimulationManager.java

@@ -343,117 +343,7 @@ public class SimulationManager {
 	 * @param sN
 	 *            Subnet
 	 */
-	private void setFlowSimulation(SubNet sN) {
-		ArrayList<AbstractCpsObject> producers = new ArrayList<>();
-		AbstractCpsObject tmp = null;
-		tagTable = new HashMap<>();
-		// traverse all objects in this subnet
-		for (HolonObject hl : sN.getObjects()) {
-			float energy = hl.getEnergyAtTimeStep(timeStep);
-			// if their production is higher than their consumption
-			if (energy > 0) {
-				tagTable.put(hl.getId(), energy);
-				hl.addTag(hl.getId());
-				for (CpsEdge edge : hl.getConnections()) {
-					if (edge.isWorking()) {
-						// set other end of edge as tmp-object
-						// and add this end to the other end's tag-list
-						AbstractCpsObject a = edge.getA();
-						AbstractCpsObject b = edge.getB();
-						if (a.getId() == hl.getId()) {
-							b.addTag(hl.getId());
-							tmp = b;
-						}
-						if (b.getId() == hl.getId()) {
-							a.addTag(hl.getId());
-							tmp = a;
-						}
-
-						edge.setFlow(edge.getFlow() + energy);
-						edge.calculateState();
-						edge.addTag(hl.getId());
-						if (edge.isWorking() && !producers.contains(tmp)) {
-							if (tmp instanceof HolonSwitch) {
-								if (((HolonSwitch) tmp).getState(timeStep)) {
-									producers.add(tmp);
-								}
-							} else if (!(tmp instanceof CpsUpperNode)) {
-								producers.add(tmp);
-							}
-						}
-					}
-				}
-			}
-		}
-		setFlowSimRec(producers, 0);
-	}
-
-	/**
-	 * Set Flow Simulation Rec.
-	 *
-	 * @param nodes
-	 *            the nodes
-	 * @param iter
-	 *            the Iteration
-	 */
-	private void setFlowSimRec(ArrayList<AbstractCpsObject> nodes, int iter) {
-		ArrayList<AbstractCpsObject> newNodes = new ArrayList<>();
-		ArrayList<CpsEdge> changedEdges = new ArrayList<>();
-		AbstractCpsObject tmp;
-		if (nodes.size() != 0) {
-			for (AbstractCpsObject cps : nodes) {
-				// check whether the cps is in a legit state if it is a switch
-				if (legitState(cps)) {
-					for (CpsEdge edge : cps.getConnections()) {
-						// is edge working
-						// and does the edge's tag-list not (yet) contain all
-						// tags of the cps
-						if (edge.isWorking()
-								&& (!(edge.containsTags(edge.getTags(),
-										cps.getTag())))) {
-							if (edge.getA().getId() == cps.getId()) {
-								tmp = edge.getB();
-							} else {
-								tmp = edge.getA();
-							}
-							for (Integer tag : cps.getTag()) {
-								if (!(edge.getTags().contains(tag))
-										&& !(edge.getPseudoTags().contains(tag))) {
-									edge.setFlow(edge.getFlow()
-											+ tagTable.get(tag));
-									edge.addTag(tag);
-								}
-							}
-							// uppernodes do not spread energy
-							if (!(tmp instanceof CpsUpperNode)) {
-								for (Integer tag : tmp.getTag()) {
-									if (!(edge.getTags().contains(tag))
-											&& tagTable.get(tag) != null
-											&& !(edge.getPseudoTags()
-													.contains(tag))) {
-										edge.setFlow(edge.getFlow()
-												+ tagTable.get(tag));
-										edge.addPseudoTag(tag);
-										changedEdges.add(edge);
-									}
-								}
-							}
-							edge.calculateState();
-							if (edge.isWorking()
-									&& !(tmp instanceof CpsUpperNode)) {
-								tmp.addAllPseudoTags(cps.getTag());
-								if (!newNodes.contains(tmp)) {
-									newNodes.add(tmp);
-								}
-							}
-						}
-					}
-				}
-			}
-			setPseudoTags(newNodes, changedEdges);
-			setFlowSimRec(newNodes, iter + 1);
-		}
-	}
+	
 
 	/**
 	 * Set the Pseudo Tags.
@@ -473,277 +363,8 @@ public class SimulationManager {
 		}
 	}
 
-	/**
-	 * Reset the Connection.
-	 *
-	 * @param cps
-	 *            CpsObject
-	 * @param visitedObj
-	 *            the visited Objects
-	 * @param visitedEdges
-	 *            the visited Edges
-	 */
-	private void resetConnections(AbstractCpsObject cps,
-			ArrayList<Integer> visitedObj, ArrayList<CpsEdge> visitedEdges) {
-		visitedObj.add(cps.getId());
-		cps.resetTags();
-		for (CpsEdge e : cps.getConnections()) {
-			if (!(visitedEdges.contains(e))) {
-				e.setFlow(0);
-				e.calculateState();
-				e.setTags(new ArrayList<>());
-				visitedEdges.add(e);
-				if (!(visitedObj.contains(e.getA().getId()))) {
-					resetConnections(e.getA(), visitedObj, visitedEdges);
-					e.getA().resetTags();
-				}
-				if (!(visitedObj.contains(e.getB().getId()))) {
-					resetConnections(e.getB(), visitedObj, visitedEdges);
-					e.getB().resetTags();
-				}
-			}
-		}
-	}
-
-	/**
-	 * calculates the energy of either all producers or consumers. Flexible
-	 * devices are filtered out
-	 *
-	 * @param type
-	 *            Type
-	 * @param sN
-	 *            Subnet
-	 * @param x
-	 *            Integer
-	 * @return The Energy
-	 */
-	private float calculateEnergyWithoutFlexDevices(String type, SubNet sN,
-			int x) {
-		float energy = 0;
-		for (HolonObject hl : sN.getObjects()) {
-			float currentEnergyWithoutFlexibles = hl
-					.getCurrentEnergyAtTimeStepWithoutFlexiblesAndResetFlexibles(x);
-
-			if (type.equals("prod")) {
-				if (currentEnergyWithoutFlexibles > 0) {
-					energy += currentEnergyWithoutFlexibles;
-					hl.setState(HolonObject.PRODUCER);
-				}
-			}
-			if (type.equals("cons")) {
-				if (currentEnergyWithoutFlexibles < 0) {
-					energy += currentEnergyWithoutFlexibles;
-					hl.setState(HolonObject.NOT_SUPPLIED);
-				}
-			}
-			if (currentEnergyWithoutFlexibles == 0) {
-				hl.setState(HolonObject.NO_ENERGY);
-			}
-		}
-		return energy;
-	}
-
-	/**
-	 * calculates the energy of either all producers or consumers. Flexible
-	 * devices are filtered out
-	 *
-	 * @param type
-	 *            Type
-	 * @param sN
-	 *            Subnet
-	 * @param x
-	 *            Integer
-	 * @return The Energy
-	 */
-	private float calculateEnergyWithFlexDevices(String type, SubNet sN, int x) {
-		float energy = 0;
-		for (HolonObject hl : sN.getObjects()) {
-			float currentEnergy = hl.getEnergyAtTimeStep(x);
-
-			if (type.equals("prod")) {
-				if (currentEnergy > 0) {
-					energy += currentEnergy;
-					hl.setState(HolonObject.PRODUCER);
-				}
-			}
-			if (type.equals("cons")) {
-				if (currentEnergy < 0) {
-					energy = energy + currentEnergy;
-					hl.setState(HolonObject.NOT_SUPPLIED);
-				}
-			}
-			if (currentEnergy == 0) {
-				hl.setState(HolonObject.NO_ENERGY);
-			}
-		}
-		return energy;
-	}
 
-	/**
-	 * Calculate the Minimum Energy of a Subnet.
-	 *
-	 * @param sN
-	 *            Subnet
-	 * @param x
-	 *            Integer
-	 * @return the Calculated minimum Energy of a Subnet
-	 */
-	private float calculateMinimumEnergy(SubNet sN, int x) {
-		float minimummConsumptionSubnet = 0;
-		for (HolonObject hl : sN.getObjects()) {
-			float minElement = 0;
-			// Search for a activ element
-			for (HolonElement he : hl.getElements()) {
-				if (he.isActive()) {
-					float overallEnergy = he.getOverallEnergyAtTimeStep(x);
-					if (overallEnergy < 0) {
-						// Is a consumer
-						minElement = overallEnergy;
-					}
-				}
-			}
-			for (HolonElement he : hl.getElements()) {
-				if (he.isActive()) {
-					float overallEnergy = he.getOverallEnergyAtTimeStep(x);
 
-					if (minElement < overallEnergy && overallEnergy < 0) {
-						// is a smaller consumer
-						minElement = overallEnergy;
-					}
-				}
-			}
-			minimummConsumptionSubnet += minElement;
-		}
-		System.out.println("MinimumEnergy = "+ minimummConsumptionSubnet);
-		return minimummConsumptionSubnet;
-	}
-
-	/**
-	 * generates all subNets from all objectsToHandle.
-	 */
-	private void searchForSubNets() {
-		subNets = new ArrayList<>();
-		brokenEdges.clear();
-		boolean end = false;
-		int i = 0;
-		AbstractCpsObject cps;
-		if (objectsToHandle.size() > 0) {
-			while (!end) {
-				cps = objectsToHandle.get(i);
-				SubNet singleSubNet = new SubNet(new ArrayList<>(),
-						new ArrayList<>(), new ArrayList<>(), new ArrayList<>());
-				singleSubNet = buildSubNet(cps, new ArrayList<>(), singleSubNet);
-				if (singleSubNet.getObjects().size() + singleSubNet.getBatteries().size() != 0 ) {
-					subNets.add(singleSubNet);
-				}
-				if (0 == objectsToHandle.size()) {
-					end = true;
-				}
-			}
-		}
-	}
-
-	/**
-	 * recursivly generates a subnet of all objects, that one specific object is
-	 * connected to.
-	 *
-	 * @param cps
-	 *            AbstractCpsObject
-	 * @param visited
-	 *            visited Array of Integer
-	 * @param sN
-	 *            Subnets
-	 * @return Subnet
-	 */
-	private SubNet buildSubNet(AbstractCpsObject cps,
-			ArrayList<Integer> visited, SubNet sN) {
-		visited.add(cps.getId());
-		if (cps instanceof HolonObject) {
-			sN.getObjects().add((HolonObject) cps);
-		}
-		if (cps instanceof HolonSwitch) {
-			sN.getSwitches().add((HolonSwitch) cps);
-		}
-		if (cps instanceof HolonBattery) {
-			sN.getBatteries().add((HolonBattery) cps);
-		}
-		removeFromToHandle(cps.getId());
-		AbstractCpsObject a;
-		AbstractCpsObject b;
-		for (CpsEdge edge : cps.getConnections()) {
-			if (edge.isWorking()) {
-				a = edge.getA();
-				b = edge.getB();
-				if (!(cps instanceof HolonSwitch)) {
-					if (!(sN.getEdges().contains(edge))) {
-						sN.getEdges().add(edge);
-					}
-				}
-				if (cps instanceof HolonSwitch
-						&& ((HolonSwitch) cps).getState(timeStep)) {
-					if (!(sN.getEdges().contains(edge))) {
-						sN.getEdges().add(edge);
-					}
-				}
-				if (!visited.contains(a.getId()) && legitState(cps)
-						&& !(a instanceof CpsUpperNode)) {
-					sN = buildSubNet(a, visited, sN);
-				}
-				if (!visited.contains(b.getId()) && legitState(cps)
-						&& !(b instanceof CpsUpperNode)) {
-					sN = buildSubNet(b, visited, sN);
-				}
-				if (a instanceof CpsUpperNode && a.getId() != cps.getId()) {
-					edge.setConnected(CpsEdge.CON_UPPER_NODE_NOT_INSIDE);
-					checkForConnectedStates(b, (CpsUpperNode) a, edge);
-				}
-				if (b instanceof CpsUpperNode && b.getId() != cps.getId()) {
-					edge.setConnected(CpsEdge.CON_UPPER_NODE_NOT_INSIDE);
-					checkForConnectedStates(a, (CpsUpperNode) b, edge);
-				}
-			} else {
-				brokenEdges.add(edge);
-			}
-		}
-		return sN;
-	}
-
-	/**
-	 * is the Switch in a legitimate State.
-	 *
-	 * @param current
-	 *            AbstractCpsObject
-	 * @return boolean
-	 */
-	private boolean legitState(AbstractCpsObject current) {
-		return !(current instanceof HolonSwitch)
-				|| ((HolonSwitch) current).getState(timeStep);
-	}
-
-	// /**
-	// * ensures that objectsToHandle only contains HolonObjects.
-	// */
-	// public void cleanObjectsToHandle() {
-	// for (int i = 0; i < objectsToHandle.size(); i++) {
-	// if (!(objectsToHandle.get(i) instanceof HolonObject)) {
-	// objectsToHandle.remove(i);
-	// }
-	// }
-	// }
-
-	/**
-	 * removes an Object that already has been handled.
-	 *
-	 * @param id
-	 *            the Object ID
-	 */
-	private void removeFromToHandle(int id) {
-		for (int i = 0; i < objectsToHandle.size(); i++) {
-			if (objectsToHandle.get(i).getId() == id) {
-				objectsToHandle.remove(i);
-			}
-		}
-	}
 
 	/**
 	 * copies the data of an array of Objects.
@@ -761,16 +382,7 @@ public class SimulationManager {
 		}
 	}
 
-	/**
-	 * Prints the Components auf all subnets.
-	 */
-	private void printNetsToConsole() {
-		for (int i = 0; i < subNets.size(); i++) {
-			SubNet subNet = subNets.get(i);
-			System.out.println("SUBNET NR:" + i);
-			subNet.toString(timeStep);
-		}
-	}
+
 
 	/**
 	 * Set the Canvas.
@@ -797,28 +409,14 @@ public class SimulationManager {
 		flexDevicesTurnedOnThisTurn = new HashMap<>();
 	}
 
-	/**
-	 * Resets the State of all Edges
-	 */
-	private void resetEdges() {
-		for (CpsEdge e : brokenEdges) {
-			e.setWorkingState(true);
-		}
-	}
 
-	/**
-	 * Resets the State for the whole Simulation Model
-	 */
-	void resetSimulation() {
-		reset();
-		resetEdges();
-	}
 
 	/**
-	 * Get all Subnets.
+	 * Get all Subnets.Not functional.
 	 *
 	 * @return all Subnets
 	 */
+	@Deprecated
 	public ArrayList<SubNet> getSubNets() {
 		return subNets;
 	}
@@ -830,30 +428,7 @@ public class SimulationManager {
 	// return brokenEdges;
 	// }
 
-	/**
-	 * checks whether a given object is connected to an object inside the
-	 * upperNode. if yes, the state for the edge is changed in "connected" or
-	 * "not connected"
-	 */
-	private void checkForConnectedStates(AbstractCpsObject cps,
-			CpsUpperNode cUNode, CpsEdge theEdge) {
-		AbstractCpsObject tmp;
-		for (CpsEdge edge : cps.getConnections()) {
-			if (edge.getA().getId() == cps.getId()) {
-				tmp = edge.getB();
-			} else {
-				tmp = edge.getA();
-			}
-			if (cUNode.getNodes().contains(tmp)) {
-				if (tmp instanceof CpsUpperNode) {
-					checkForConnectedStates(cps, (CpsUpperNode) tmp, theEdge);
-				} else {
-					theEdge.setConnected(CpsEdge.CON_UPPER_NODE_AND_INSIDE);
-					break;
-				}
-			}
-		}
-	}
+
 
 	public FlexiblePane getFlexiblePane() {
 		return flexPane;

+ 5 - 4
src/ui/controller/UpdateController.java

@@ -48,7 +48,7 @@ public class UpdateController {
 			if (tempCps != null && tempCps.getClass() == HolonObject.class) {
 				if (table.getRowCount() != 0) {
 					table.removeRow(2);
-					Object[] tempEnergy = { Languages.getLanguage()[73], ((HolonObject) tempCps).getMaxActiveEnergy() };
+					Object[] tempEnergy = { Languages.getLanguage()[73], ((HolonObject) tempCps).getEnergyNeededFromConsumingElements(model.getCurIteration()) };
 					table.insertRow(2, tempEnergy);
 					((HolonObject) tempCps).updateTotalFlex();
 					table.removeRow(3);
@@ -297,7 +297,7 @@ public class UpdateController {
 			// consumption) is calculated
 			if (obj instanceof HolonObject) {
 				refreshTableHolonElement(model.getMultiTable(), model.getSingleTable());
-				Object[] tempEnergy = { Languages.getLanguage()[73], ((HolonObject) obj).getMaxActiveEnergy() };
+				Object[] tempEnergy = { Languages.getLanguage()[73], ((HolonObject) obj).getEnergyNeededFromConsumingElements(model.getCurIteration()) };
 				Object[] tempFlex = { "Flexibility", ((HolonObject) obj).getTotalFlex() };
 				model.getPropertyTable().addRow(tempEnergy);
 				model.getPropertyTable().addRow(tempFlex);
@@ -392,13 +392,13 @@ public class UpdateController {
 							+ model.getSelectedEdge().getB().getName() };
 			model.getPropertyTable().addRow(tempName);
 			// Current Flow displayed
-			Object[] tempFlow = { Languages.getLanguage()[80], model.getSelectedEdge().getFlow() };
+			Object[] tempFlow = { Languages.getLanguage()[80], "" };
 			model.getPropertyTable().addRow(tempFlow);
 			// Max Capacity displayed
 			Object[] tempCapacity = { Languages.getLanguage()[81], model.getSelectedEdge().getCapacity() };
 			model.getPropertyTable().addRow(tempCapacity);
 			// Status displayed
-            Object[] tempStatus = {Languages.getLanguage()[82], model.getSelectedEdge().isWorking()};
+            Object[] tempStatus = {Languages.getLanguage()[82], ""};
             model.getPropertyTable().addRow(tempStatus);
             // For edges, the only possible editable cell is the max
 			// flow
@@ -436,6 +436,7 @@ public class UpdateController {
 	 */
 	public void paintHolonBody(int id) {
 		if (id != -1) {
+			
 			ArrayList<SubNet> subs = controller.getSimManager().getSubNets();
 			if (!subs.isEmpty()) {
 				SubNet sub = subs.get(id);

+ 0 - 138
src/ui/view/AbstractCanvas.java

@@ -95,145 +95,7 @@ public abstract class AbstractCanvas extends JPanel {
 	
 
 	
-	/**
-	 * Paints the SupplyBar for the given cps object on the canvas
-	 * 
-	 * @param g
-	 *            Graphics used
-	 * @param cps
-	 *            cpsObject which the supplyBar should be drawn for
-	 * @deprecated
-	 */
-	protected void paintSupplyBar(Graphics g, AbstractCpsObject cps) {
-		g2.setColor(Color.black);
-		/**
-		 * draw and fill the supply Bar
-		 */
-		if (model.getShowSupplyBars() && (cps instanceof HolonObject || cps instanceof HolonBattery))
-		{
-			// set Color & Percentage
-			/**
-			 * percentage the SupplyBar is representing
-			 */
-			float percentage = 0;
-			/**
-			 * color of the SupplyBar
-			 */
-			Color paintColor = Color.WHITE;
-			if(cps instanceof HolonObject)
-			{
-				HolonObject hl = (HolonObject) cps;
-				if (hl == null || !(hl.getState() == HolonObject.NOT_SUPPLIED
-						|| hl.getState() == HolonObject.PARTIALLY_SUPPLIED || hl.getState() == HolonObject.OVER_SUPPLIED)) {
-					/**
-					 * don't show Bars for unsupplied oder fully supplied Objects
-					 */
-					return;
-				}
-				/**
-				 * calculate Percentage & set Color
-				 */
-				percentage = hl.getSuppliedPercentage();
-				paintColor = hl.getColor();
-			}
-			else if (cps instanceof HolonBattery){
-				HolonBattery hB = (HolonBattery) cps;
-				if(hB == null || hB.getCapacity() == 0){
-					return;
-				}
-				/**
-				 *  get percentage filled
-				 */
-				percentage = hB.getStateOfChargeAtTimeStep(model.getCurIteration()-1) / hB.getCapacity();
-
-				/**
-				 * calculate the Color (Red->Yellow->Green)
-				 */
-				Color color1 = Color.RED;
-				Color color2 = Color.GREEN;
-				//
-				float colorPercentage;
-				if(percentage < 0.5f){
-					colorPercentage = percentage * 2;
-					color1 = Color.RED;
-					color2 = Color.YELLOW;
-				}
-				else {
-					colorPercentage = (percentage - 0.5f) * 2;
-					color1 = Color.YELLOW;
-					color2 = Color.GREEN;
-				}
-				final int dRed = color2.getRed() - color1.getRed();
-				final int dGreen = color2.getGreen() - color1.getGreen();
-				final int dBlue = color2.getBlue() - color1.getBlue();	
-				
-				int resultRed = color1.getRed() +  (int)(colorPercentage * dRed);
-				int resultGreen = color1.getGreen() +  (int)(colorPercentage * dGreen);
-				int resultBlue = color1.getBlue() + (int)( colorPercentage * dBlue);
-				
-				paintColor = new Color(	resultRed,resultGreen,resultBlue);
-			}
-			
-			/**
-			 * Starting position x of the bar
-			 */
-			int barX = (int) (cps.getPosition().x - controller.getScaleDiv2() - scalediv20);
-			
-			/**
-			 * Starting position y of the bar
-			 */
-			int barY = (int) (cps.getPosition().y - controller.getScaleDiv2() + controller.getScale() + 1);
-			
-			/**
-			 * if object should be replaced -> move bar below the ReplacementIndicator
-			 */
-			if(mayBeReplaced==cps) barY += 3;
-			
-			/**
-			 * Width of the bar
-			 */
-			int barWidth = (int) (controller.getScale() + ((scalediv20) * 2) - 1);
-			
-			/**
-			 * Height of the bar 
-			 */
-			int barHeight = (int) (controller.getScale() / 5);
-
-			/** 
-			 * draw Rectangle below the image 
-			 */
-			g2.setStroke(new BasicStroke(1));
-			g2.drawRect(barX, barY, barWidth, barHeight);
-				
-			g2.setColor(paintColor);
-
-			/** fill it accordingly if filled partially */
-			if (percentage < 1)
-				g2.fillRect(barX + 1, barY + 1, (int) ((barWidth - 1) * percentage), barHeight - 1);
-			else /** over supplied / supplied bar should be fully filled */
-				g2.fillRect(barX + 1, barY + 1, (int) (barWidth - 1), barHeight - 1);
-			
-			/** write percentage */
-			if(percentage>1)
-				g2.setColor(Color.WHITE);
-			else
-				g2.setColor(Color.BLACK);
-			
-			/** original font */
-			Font oldFont = g2.getFont();
-			
-			g.setFont(new Font("TimesRoman", Font.PLAIN, (int) (barHeight * 1.5) - 2));
-			
-			String percentageString = (Math.round((percentage * 100))) + "%";
-			int stringWidth = (int) g2.getFontMetrics().getStringBounds(percentageString, g2).getWidth();
-			g2.drawString(percentageString, barX + barWidth / 2 + 1 - stringWidth / 2, barY + barHeight);
 	
-			/** recover Font and Color */
-			g2.setFont(oldFont);
-			g2.setColor(Color.BLACK);
-				
-		}
-	}
 
 	protected class ACpsHandle{
 		public AbstractCpsObject object;

+ 95 - 82
src/ui/view/AlgoWindow.java

@@ -20,9 +20,11 @@ import javax.swing.JLabel;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JTextArea;
 import javax.swing.JTextPane;
+import javax.swing.filechooser.FileNameExtensionFilter;
 import javax.swing.text.SimpleAttributeSet;
 import javax.swing.text.StyleConstants;
 import javax.swing.text.StyledDocument;
@@ -33,8 +35,8 @@ import api.Algorithm;
 import ui.controller.Control;
 
 //TODO delete old class AlgorithmMenu and change this class to AlgorithmMenu;
+@SuppressWarnings("serial")
 public class AlgoWindow extends JFrame{
-	private File root;
 	private Algorithm actual;
 	private Control control;
 	private JPanel content = new JPanel();
@@ -52,78 +54,10 @@ public class AlgoWindow extends JFrame{
 	private void initMenuBar() {
 		JMenuBar menuBar = new JMenuBar();
 		JMenu menuSelect = new JMenu("File");
-		JMenuItem menuItemFolder= new JMenuItem("Open Folder..");
-		
-		
 		JMenuItem menuItemAlgorithm= new JMenuItem("Open .java-File..");
-		menuItemAlgorithm.addActionListener(actionEvent -> {
-			System.out.println("Test");
-			JFileChooser fileChooser = new JFileChooser();
-			fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
-			fileChooser.setAcceptAllFileFilterUsed(false);
-			int result = fileChooser.showOpenDialog(this);
-			if(result == JFileChooser.APPROVE_OPTION) {
-				//Found a file
-				File founded = fileChooser.getSelectedFile();
-				//Get Class name:
-				String name = founded.getName().substring(0, founded.getName().lastIndexOf("."));
-				//get Package name
-				String packageName = "";
-				Scanner in = null;
-				try {
-					in = new Scanner(founded);
-				} catch (FileNotFoundException e) {
-					System.out.println("File not Found");
-				}
-				while(in.hasNext()) {
-					String line = in.nextLine().trim();
-					if(line.startsWith("package")) {
-						packageName = line.substring(8, line.length()-1);
-						break;
-					}
-				}
-				//GetPathName
-				String path =  founded.getParentFile().isDirectory() ? founded.getParentFile().getAbsolutePath() : "";
-				File folder = founded.getParentFile();
-				System.out.println(founded.getName() + ", Name:" + name + ", Package:" + packageName + ", Path:" + path);
-				// Compile source file.
-				JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
-				if (ToolProvider.getSystemJavaCompiler() == null) {
-					System.out.println("MissingCompiler");
-				}else {
-					compiler.run(null, null, null, founded.getAbsolutePath());					
-				}
-				try {
-				URLClassLoader classLoader = URLClassLoader.newInstance(new URL[] { folder.toURI().toURL() });
-				Class<?> cls = Class.forName(packageName.isEmpty()?name:packageName + "." +name, true, classLoader);
-				Object object = cls.newInstance();
-				if(!(object instanceof Algorithm)) {
-					System.out.println("Class does not implement CpsAlgorithm!");
-				}else {
-					actual = (Algorithm)object;
-					actual.setController(control);
-					this.setContentPane(actual.getAlgorithmPanel());
-					this.pack();
-				}
-				} catch (MalformedURLException e) {
-					System.out.println("URLClassLoader error");
-					e.printStackTrace();
-				} catch (ClassNotFoundException e) {
-					System.out.println("ClassNotFound error" + e.getMessage());
-				} catch (InstantiationException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				} catch (IllegalAccessException e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
-				}
-			}else {
-				//Not
-			}
-				
-			
-		});
+		menuItemAlgorithm.addActionListener(actionEvent -> openJavaFile());
 		menuSelect.add(menuItemAlgorithm);
+		JMenuItem menuItemFolder= new JMenuItem("Open Folder..");
 		menuItemFolder.addActionListener(actionEvent->openFolder(menuSelect));
 		menuSelect.add(menuItemFolder);
 		menuSelect.addSeparator();
@@ -132,6 +66,7 @@ public class AlgoWindow extends JFrame{
 		menuBar.add(menuHelp);
 		this.setJMenuBar(menuBar);
 	}
+	
 	private void initDefaultContentPanel() {
 		content.setLayout(new BorderLayout());
 		JTextPane textPane = new JTextPane();
@@ -142,27 +77,37 @@ public class AlgoWindow extends JFrame{
 				+"\n OPTION[1]:"
 				+"\n•  Select '.java'-file via the file browser. (File\u2192Open .jave-File..)"
 				+"\n"
-				+"\n OPTION[2]: CURRENTLY NOT WORKING"
+				+"\n OPTION[2]:"
 				+"\n• First select the folder where the algorithm '.java'-file is located. (File\u2192Open Folder..)"
 				+"\n• Second load the algorithm. (File\u2192'YourAlgo')");
 		textPane.setFont(new Font("Serif", Font.PLAIN, 16));
 		
 		
 		content.add(textPane, BorderLayout.CENTER);
-		//content.add(new JButton("Run"),BorderLayout.PAGE_END );
 		content.setPreferredSize(new Dimension(500, 500));
 	}
 	
+	/**
+	 * 
+	 */
+	private void openJavaFile() {
+		JFileChooser fileChooser = new JFileChooser();
+		fileChooser.setFileFilter(new FileNameExtensionFilter("JAVA Source Files", "java"));
+		fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+		fileChooser.setAcceptAllFileFilterUsed(false);
+		int result = fileChooser.showOpenDialog(this);
+		if(result == JFileChooser.APPROVE_OPTION) {
+			//Found a file
+			loadAlgorithm(fileChooser.getSelectedFile());
+		}
+	}
+	
 	private void openFolder(JMenu menuSelect) {
-		System.out.println("OpenFolder");
 		JFileChooser fileChooser = new JFileChooser();
 		fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
 		fileChooser.setAcceptAllFileFilterUsed(false);
 		int result = fileChooser.showOpenDialog(this);
 		if(result == JFileChooser.APPROVE_OPTION) {
-			System.out.println("Richtig" + menuSelect.getItemCount());
-			System.out.println(fileChooser.getSelectedFile().getAbsolutePath());
-			root = fileChooser.getSelectedFile();
 			File[] files = fileChooser.getSelectedFile().listFiles(file -> file.getName().endsWith(".java"));
 			
 			//Remove all Index from old Folder
@@ -170,13 +115,81 @@ public class AlgoWindow extends JFrame{
 				menuSelect.remove(i);
 			}
 			for(File file: files) {
-				menuSelect.add(new JMenuItem(file.getName().substring(0, file.getName().lastIndexOf("."))));
+				JMenuItem insertMenuItem = new JMenuItem(getNameWithoutExtension(file));
+				insertMenuItem.addActionListener(actionEvent -> loadAlgorithm(file));
+				menuSelect.add(insertMenuItem);
 			}
-			//System.out.println(Arrays.asList(files).stream().map(Object::toString).collect(Collectors.joining(", ")));
+		}
+	}
+	/**
+	 * Compile and load a java File.
+	 * @param javafile
+	 */
+	
+	private void loadAlgorithm(File javafile) {
+		//Get Class name:
+		String name = getNameWithoutExtension(javafile);
+		//get Package name
+		String packageName = "";
+		Scanner in = null;
+		try {
+			in = new Scanner(javafile);
+		} catch (FileNotFoundException e) {
+			generateErrorDialog("File not Found");
+		}
+		while(in.hasNext()) {
+			String line = in.nextLine().trim();
+			if(line.startsWith("package")) {
+				packageName = line.substring(8, line.length()-1);
+				break;
+			}
+		}
+		//GetPathName
+		//String path =  javafile.getParentFile().isDirectory() ? javafile.getParentFile().getAbsolutePath() : "";
+		File folder = javafile.getParentFile();
+		// Compile source file.
+		JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+		if (ToolProvider.getSystemJavaCompiler() == null) {
+			generateErrorDialog("Please install the JDK on your system.");
 		}else {
-			System.out.println("Falsch");
+			compiler.run(null, null, null, javafile.getAbsolutePath());					
 		}
-			
-		//
+		try {
+		URLClassLoader classLoader = URLClassLoader.newInstance(new URL[] { folder.toURI().toURL() });
+		Class<?> cls = Class.forName(packageName.isEmpty()?name:packageName + "." +name, true, classLoader);
+		Object object = cls.newInstance();
+		if(!(object instanceof Algorithm)) {
+			generateErrorDialog("Class does not implement CpsAlgorithm!");
+		}else {
+			actual = (Algorithm)object;
+			actual.setController(control);
+			this.setContentPane(actual.getAlgorithmPanel());
+			this.pack();
+		}
+		} catch (MalformedURLException e) {
+			generateErrorDialog("URLClassLoader error");
+		} catch (ClassNotFoundException e) {
+			generateErrorDialog("ClassNotFound error" + e.getMessage());
+		} catch (InstantiationException e) {
+			generateErrorDialog("Class does not implement a Constructor." + e.getMessage());
+		} catch (IllegalAccessException e) {
+			generateErrorDialog("Class set this method privat or protected needs to be public." + e.getMessage());
+		}
+	}
+	/**
+	 * Returns the Name of a file without Extension.
+	 * @param file
+	 * @return
+	 */
+	private String getNameWithoutExtension(File file) {
+		return file.getName().substring(0, file.getName().lastIndexOf("."));
+	}
+	/**
+	 * Generate a little Error Dialog to inform the User.
+	 * @param message
+	 */
+	private void generateErrorDialog(String message) {
+		System.out.println(message);
+		JOptionPane.showConfirmDialog(this, message, "Error", JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE);
 	}
 }

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

@@ -210,7 +210,7 @@ public class CreateTemplatePopUp extends JDialog {
 		 */
 		for (HolonElement he : template.getElements())
 			listModel.addElement(he.getAmount() + " * " + he.getEleName()
-					+ ": " + he.getOverallEnergy() + "U");
+					+ ": " + he.getMaximumEnergy() + "U");
 
 		/**
 		 * Add ScrollPane to List
@@ -321,7 +321,7 @@ public class CreateTemplatePopUp extends JDialog {
 		HolonElement he = popUp.getElement();
 		if (he != null) {
 			listModel.addElement(he.getAmount() + " * " + he.getEleName()
-					+ ": " + he.getOverallEnergy() + "U");
+					+ ": " + he.getMaximumEnergy() + "U");
 			template.addElement(he);
 			he.setSaving(new Pair<>(category, textField_name.getText()));
 		}
@@ -354,7 +354,7 @@ public class CreateTemplatePopUp extends JDialog {
 		if (he != null) {
 			listModel.remove(index);
 			listModel.addElement(he.getAmount() + " * " + he.getEleName()
-					+ ": " + he.getOverallEnergy() + "U");
+					+ ": " + he.getMaximumEnergy() + "U");
 			template.deleteElement(index);
 			template.addElement(he);
 			he.setSaving(new Pair<>(category, textField_name.getText()));

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

@@ -183,7 +183,6 @@ public class EditEdgesPopUp extends JDialog {
 		 */
 		for (CpsEdge edge : controller.getModel().getEdgesOnCanvas()) {
 			edge.setCapacity(cap);
-            edge.setWorkingState(true);
         }
         for (AbstractCpsObject abs : controller.getModel().getObjectsOnCanvas()) {
 			if (abs instanceof CpsUpperNode) {

+ 2 - 10
src/ui/view/GUI.java

@@ -491,16 +491,12 @@ public class GUI implements CategoryListener {
 
 				// check whether a producer was deleted (this triggers a
 				// complete re-evaluation of the net)
-				boolean wasProducerDeleted = false;
+				boolean wasProducerDeleted = true;
 
 				if (canvasOrUpperNodeCanvas instanceof UpperNodeCanvas) {
 					UpperNodeCanvas uNC = (UpperNodeCanvas) canvasOrUpperNodeCanvas;
 					for (AbstractCpsObject cps : model.getSelectedCpsObjects()) {
 
-						if (cps instanceof HolonObject
-								&& ((HolonObject) cps).getState() == HolonObject.PRODUCER) {
-							wasProducerDeleted = true;
-						}
 
 						controller.removeTrackingObj(cps);
 						if (uNC.upperNode.getNodes().contains(cps)) {
@@ -545,10 +541,7 @@ public class GUI implements CategoryListener {
 						AbstractCpsObject cps = model.getSelectedCpsObjects()
 								.get(j);
 
-						if (cps instanceof HolonObject
-								&& ((HolonObject) cps).getState() == HolonObject.PRODUCER) {
-							wasProducerDeleted = true;
-						}
+					
 
 						controller.removeTrackingObj(cps);
 						if (j < model.getSelectedCpsObjects().size() - 1)
@@ -1659,7 +1652,6 @@ public class GUI implements CategoryListener {
 				// Status edition through a check box
 				if (selValueYBool == 3) {
 					Boolean bbTemp = Boolean.parseBoolean(btemp.toString());
-					model.getSelectedEdge().setWorkingState(bbTemp);
 				}
 			}
 			canvas.repaint();

+ 3 - 24
src/ui/view/StatisticGraph.java

@@ -373,18 +373,8 @@ public class StatisticGraph extends JPanel {
                     float wasted = getTotalWastedEnergyAt(model.getObjectsOnCanvas(), model.getCurIteration());
                     set.setValAt(wasted, model.getCurIteration());
                     break;
-                case TrackedDataSet.PERCENT_SUPPLIED:
-                    set.setValAt(getPercentState(model.getObjectsOnCanvas(), HolonObject.SUPPLIED),
-                            model.getCurIteration());
-                    break;
-                case TrackedDataSet.PERCENT_NOT_SUPPLIED:
-                    set.setValAt(getPercentState(model.getObjectsOnCanvas(), HolonObject.NOT_SUPPLIED),
-                            model.getCurIteration());
-                    break;
-                case TrackedDataSet.PERCENT_PARTIAL_SUPPLIED:
-                    set.setValAt(getPercentState(model.getObjectsOnCanvas(), HolonObject.PARTIALLY_SUPPLIED),
-                            model.getCurIteration());
-                    break;
+               
+              
                 case TrackedDataSet.GROUP_PRODUCTION:
                     set.setValAt(
                             getTotalProductionAt(((CpsUpperNode) set.getCpsObject()).getNodes(), model.getCurIteration()),
@@ -725,18 +715,7 @@ public class StatisticGraph extends JPanel {
     }
 
 
-    /**
-     * get the Percentage of how many objects with the given state are in the
-     * given List
-     *
-     * @param objects List of Objects
-     */
-    private float getPercentState(ArrayList<AbstractCpsObject> objects, int state) {
-        float count = controller.getNumberHolonObjects(objects);
-        float stateObjectss = controller.getNumberStateObjects(objects, state);
-
-        return stateObjectss / count;
-    }
+  
 
     /**
      * Return all TrackedDataSets

+ 5 - 24
tests/tests/PraktikumHolonsTestClasses.java

@@ -60,16 +60,16 @@ public class PraktikumHolonsTestClasses {
 		arr.add(ele);
 		arr.add(ele);
 		assertTrue("Should be Empty", test2.getElements().isEmpty());
-		assertTrue("Current Energy not corrent", test2.getMaxActiveEnergy() == 0);
+
 		test2.setElements(arr);
 		assertTrue("Should not be Empty", !test2.getElements().isEmpty());
-		assertTrue("Current Energy not corrent", test2.getMaxActiveEnergy() == 20);
+
 		assertTrue("Current Energy not corrent", test2.getEnergyAtTimeStep(20) == 20);
 		String str = test2.toStringElements();
 		assertTrue("String not corrent", str.equals("Element, Element"));
 		test2.deleteElement(0);
 		test2.addElement(ele);
-		assertTrue("Current Energy not corrent", test2.getMaxActiveEnergy() == 20);
+
 		assertTrue("Should be Empty", test3.getElements().isEmpty());
 		test3.setElements(test2.copyElements(test2.getElements()));
 		
@@ -116,29 +116,10 @@ public class PraktikumHolonsTestClasses {
 		CpsEdge edge1 = new CpsEdge(node1, node2, 100);
 		CpsEdge edge2 = new CpsEdge(node2, node3);
 
-		assertTrue("Flow not 0", edge1.getFlow() == 0);
-		edge1.setFlow(50);
-		assertTrue("Capacity not right", edge1.getCapacity() == 100);
-		edge2.setFlow(50);
-		edge1.setCapacity(200);
-		assertTrue("Flow was not changed", edge1.getFlow() == 50);
-		assertTrue("Capacity not right", edge1.getCapacity() == 200);
-        assertTrue("line broken", edge2.isWorking());
-        edge2.calculateState();
-        assertTrue("line broken", edge2.isWorking());
-        edge2.setFlow(200);
-        edge2.calculateState();
-        assertTrue("line not broken", !edge2.isWorking());
-        edge1.setCapacity(-1);
-        edge1.calculateState();
-		edge1.setCapacity(500);
-		edge1.calculateState();
 		node1 = (CpsNode) edge1.getB();
 		node2 = (CpsNode) edge2.getA();
 		assertTrue("Not Same", node1 == node2);
-        assertTrue("State not right", edge1.isWorking());
-        edge1.setWorkingState(false);
-        assertTrue("State not right", !edge1.isWorking());
+    
         edge2.setTags(new ArrayList<>());
         edge1.setTags(new ArrayList<>());
 		assertTrue("Tags not Empty", edge2.getTags().isEmpty());
@@ -164,7 +145,7 @@ public class PraktikumHolonsTestClasses {
 		assertTrue("Amount not correct", ele2.getAmount() == 1);
 		ele2.setAmount(5);
 		assertTrue("Amount not correct", ele2.getAmount() == 5);
-        assertTrue("Total Energy not Correct", ele2.getOverallEnergy() == ele2.getAmount() * ele2.getEnergyPerElement());
+        assertTrue("Total Energy not Correct", ele2.getMaximumEnergy() == ele2.getAmount() * ele2.getEnergyPerElement());
 	}
 	/**
 	 * Test for Position.

+ 1 - 3
tests/tests/PraktikumHolonsTestObjectController.java

@@ -69,9 +69,7 @@ public class PraktikumHolonsTestObjectController {
 		for (int i = 2; i < 27; i++) {
 			controller.addNewElementIntoCategoryObject("Building", "House", adapter.generate(i), i, -10);
 			// n(n+1) / 2
-			assertTrue("Total Energy does not match", ((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House"))
-					.getMaxActiveEnergy() == -1800 + ((i * (i + 1)) / 2) * -10);
-			assertTrue("Number of Elements does not Match",
+					assertTrue("Number of Elements does not Match",
 					((HolonObject) mp.searchCatObj(mp.searchCat("Building"), "House")).getElements().size() == 6 + i);
 		}