Browse Source

Topologie working State

Troppmann, Tom 3 years ago
parent
commit
21c0945fa6

+ 1 - 1
src/addOns/RandomSwitch.java

@@ -68,7 +68,7 @@ public class RandomSwitch implements AddOn {
 			// Generate a random number between 0 and 1
 			double randomDouble = Math.random();
 			if (randomDouble < randomChance) {
-				s.setManualState(!s.getActiveManual());
+				s.setManualState(!s.getManualState());
 			} 
 		}
 		control.calculateStateAndVisualForCurrentTimeStep();

+ 3 - 3
src/addOns/Randomizer.java

@@ -46,7 +46,7 @@ import classes.HolonObject;
 import ui.controller.Control;
 import ui.view.RandomPriotity;
 import utility.Random;
-import utility.Util;
+import utility.ImageImport;
 
 public class Randomizer implements AddOn {
 	private Control  control;
@@ -117,7 +117,7 @@ public class Randomizer implements AddOn {
 		headPanel.setLayout(new BoxLayout(headPanel, BoxLayout.LINE_AXIS));
 		headPanel.add(new JLabel("FILTER"));
 		JButton updateButton = new JButton();
-		updateButton.setIcon(new ImageIcon(Util.loadImage("Images/replace.png", 15, 15)));
+		updateButton.setIcon(new ImageIcon(ImageImport.loadImage("Images/replace.png", 15, 15)));
 		updateButton.addActionListener(action -> {
 			this.updateFilterList();
 			content.updateUI();
@@ -138,7 +138,7 @@ public class Randomizer implements AddOn {
 			//Entry
 			JPanel entryPanel = new JPanel();
 			entryPanel.setLayout(new BoxLayout(entryPanel, BoxLayout.LINE_AXIS));
-			JLabel label = new JLabel(hObject.getName() + "[" + hObject.getId() + "]", new ImageIcon(Util.loadImage(hObject.getImage(), lineSpace, lineSpace)), JLabel.LEFT);
+			JLabel label = new JLabel(hObject.getName() + "[" + hObject.getId() + "]", new ImageIcon(ImageImport.loadImage(hObject.getImage(), lineSpace, lineSpace)), JLabel.LEFT);
 			entryPanel.add(label);
 			entryPanel.add(Box.createHorizontalGlue());
 			JCheckBox checkbox = new JCheckBox();

+ 26 - 3
src/algorithm/objectiveFunction/GraphMetrics.java

@@ -1,9 +1,12 @@
 package algorithm.objectiveFunction;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.LinkedList;
+import java.util.List;
 
 import classes.AbstractCanvasObject;
+import classes.HolonSwitch;
 import ui.model.Consumer;
 import ui.model.DecoratedCable;
 import ui.model.DecoratedNetwork;
@@ -60,8 +63,8 @@ public class GraphMetrics {
 		
 		
 		
-		G.E = new Edge[net.getDecoratedCableList().size()];
-		int edgeCount = 0;
+		//Generate EdgeList 
+		List<Edge> edgeList = new ArrayList<Edge>();
 		for(DecoratedCable cable : net.getDecoratedCableList()){
 			
 			AbstractCanvasObject objectA = cable.getModel().getA();
@@ -74,6 +77,15 @@ public class GraphMetrics {
 				System.out.println("Edge: " + cable + "objectB == null");
 				continue;
 			}
+			
+			//SpecialCase for open switches
+			if(objectA instanceof HolonSwitch && !((HolonSwitch)objectA).getManualState()) {
+				continue;
+			}
+			if(objectB instanceof HolonSwitch && !((HolonSwitch)objectB).getManualState()) {
+				continue;
+			}
+			
 			int idA = -1;
 			if(objectToId.containsKey(objectA)) {
 				idA = objectToId.get(objectA);
@@ -89,8 +101,15 @@ public class GraphMetrics {
 				objectToId.put(objectB, count++);
 			}
 			double length = cable.getModel().getLength();
-			G.E[edgeCount++] = new Edge(idA, idB, length);
+			edgeList.add(new Edge(idA, idB, length));
 		}
+		//Generate EdgeArray
+		G.E = new Edge[edgeList.size()];
+		for(int i=0;i<edgeList.size();i++)
+	    {
+				G.E[i] =  edgeList.get(i);
+	    }
+		//Generate VertexArray
 		G.V = new Vertex[objectToId.size()];
 		for(int i=0;i<G.V.length;i++)
 	    {
@@ -334,8 +353,12 @@ public class GraphMetrics {
 	static double[][] generateWeightMatrix(Vertex[] V, Edge[] E){
 		double[][] L = new double[V.length][V.length];
 		for(int i = 0; i < E.length; i++) {
+			try {
 			L[E[i].idA][E[i].idB] = E[i].weight;
 			L[E[i].idB][E[i].idA] = E[i].weight;
+			}catch(java.lang.NullPointerException e) {
+				System.out.println("E[i].idA:" + E[i].idA + " E[i].idB:" + E[i].idB + " E[i].weight:" + E[i].weight);
+			}
 		}
 		for(int i=0;i<L.length;i++)
         {

+ 16 - 4
src/algorithm/objectiveFunction/ObjectiveFunctionByCarlos.java

@@ -46,6 +46,18 @@ public class ObjectiveFunctionByCarlos {
 	static double range_for_kappa_f_dur = range(kappa_f_dur);
 	
 	
+	public static void main(String[] args) {
+		System.out.println("Hello World");
+		System.out.println("range_for_kappa_f_unre:" + range_for_kappa_f_unre);
+		double input = 0;
+		System.out.println(input + ": " + durationPenalty(input));
+		input = 60;
+		System.out.println(input + ": " + durationPenalty(input));
+		input = 1000;
+		System.out.println(input + ": " + durationPenalty(input));
+		input = 3600;
+		System.out.println(input + ": " + durationPenalty(input));
+	}
 	static {
         //init
 		checkParameter();
@@ -227,7 +239,7 @@ public class ObjectiveFunctionByCarlos {
 	 * @return
 	 */
 	private static double range(double kappa) {
-		return kappa / Math.log(Math.pow(2.0, 0.05) - 1.0 );
+		return - kappa / Math.log(Math.pow(2.0, 0.05) - 1.0 );
 	}
 	/**
 	 * f_unre
@@ -235,7 +247,7 @@ public class ObjectiveFunctionByCarlos {
 	 * @return
 	 */
 	private static double unresponsivnessPenalty(double unresponsiv) {
-		return (2.0 * lambda_f_unre) / Math.exp(- unresponsiv/ range_for_kappa_f_unre) - lambda_f_unre;
+		return (2.0 * lambda_f_unre) / (1 + Math.exp(- unresponsiv/ range_for_kappa_f_unre)) - lambda_f_unre;
 	}
 	/**
 	 * f_cool
@@ -243,13 +255,13 @@ public class ObjectiveFunctionByCarlos {
 	 * @return
 	 */
 	private static double cooldownPenalty(double cooldown) {
-		return (2.0 * lambda_f_cool) / Math.exp(- cooldown/ range_for_kappa_f_cool) - lambda_f_cool;
+		return (2.0 * lambda_f_cool) / (1 + Math.exp(- cooldown/ range_for_kappa_f_cool)) - lambda_f_cool;
 	}
 
 	
 	private static double durationPenalty(double duration) {
 		double lambda_dur_times2 = 2.0 * lambda_f_dur;
-		return - lambda_dur_times2 / Math.exp(- duration/ range_for_kappa_f_dur) + lambda_dur_times2;
+		return - lambda_dur_times2 / (1 + Math.exp(- duration/ range_for_kappa_f_dur)) + lambda_dur_times2;
 	}
 
 }

+ 68 - 58
src/algorithm/objectiveFunction/TopologieObjectiveFunction.java

@@ -15,49 +15,47 @@ public class TopologieObjectiveFunction {
 	//Parameters
 	
 	//weight for f_g(H)
-	static double w_eb = .3, w_max = 0.2, w_holon=.1, w_selection = .1, w_grid = .3;
+	static double w_eb = 0.2, w_max = 0.05, w_holon= 0.1, w_selection = .3, w_grid = 0.35;
 	
 	
 	//--> f_eb parameter
 	/**
 	 * Maximum Energie Difference(kappa)
 	 */
-	static double k_eb = 100000.f;
+	static double k_eb = 400000.f;
 	/**
 	 * Maximum when all on Energie Difference(kappa)
 	 */
-	static double k_max = 100000.f;
+	static double k_max = 350000.f;
 	
 	//--> f_holon parameter
 	/**
 	 * maximum penalty from holon flexibilities 
 	 */
-	static double k_holon= 200000;
+	static double k_holon= 220000;
 	
 	
 	//--> f_selection paramaeter;
 	/**
 	 *  average Maximum Cost for selction(kappa) of switch and elements.
 	 */
-	static double k_selection = 4000;
-	
-	static double cost_switch = 10;
-	private static int cost_of_cable_per_meter = 200;
+	static double k_selection = 50000;
+	static double cost_switch = 20;
+	private static double cost_of_cable_per_meter = 0.8;
 	//--> f_grid parameter
-	/**
-	 * The avergae shortest path maximum length -> kappa for the squash function
-	 */
-	static double k_avg_shortest_path = 400;
 	
-	// Disjoint Path Parameter
-	//Function1 Decreasing 
-	static double seperate_X_Value = 3.0;
-	// Value between 0 and 100
-	static double seperate_Y_Value = 10;
-	//Stretching the e-function
-	static double lowPenaltyGrowth = 3.0;
 	
 	
+	/**
+	 * The avergae shortest path maximum length -> kappa for the squash function
+	 */
+	static double k_avg_shortest_path = 1650;
+	//Disjpijoint path cant have zero as output it starts with the value 1
+	static double centerValue_disjoint_path = 1.0; 
+	static double k_disjoint_path = 2.4;
+	static double lambda_avg_shortest_path = 10;
+	static double lambda_disjoint_path = 10;
+	static double k_grid = lambda_avg_shortest_path + lambda_disjoint_path;
 	
 	
 	
@@ -68,7 +66,8 @@ public class TopologieObjectiveFunction {
 	 *  {@link TopologieObjectiveFunction#squash}
 	 */
 	static double squash_subtract = 1.0f / (1.f + (float) Math.exp(5.0));
-
+	static double range_for_k_avg_shortest_path = range(k_avg_shortest_path);
+	static double range_for_k_disjoint_path = range(k_disjoint_path - centerValue_disjoint_path);
 
 	
 	
@@ -116,11 +115,13 @@ public class TopologieObjectiveFunction {
 		}
 		
 		double f_maximum = 0;
+		final int timestep = state.getTimestepOfState();
 		for(DecoratedNetwork net : state.getNetworkList()) {
-			final int timestep = state.getTimestepOfState();
-			f_maximum += Math.abs(net.getConsumerList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum));
-			f_maximum += Math.abs(net.getConsumerSelfSuppliedList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum));
-			f_maximum += Math.abs(net.getSupplierList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum));
+			double maximumEnergy = 0;
+			maximumEnergy += net.getConsumerList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum);
+			maximumEnergy += net.getConsumerSelfSuppliedList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum);
+			maximumEnergy += net.getSupplierList().stream().map(con -> con.getModel().getMaximumConsumptionPossible(timestep) - con.getModel().getMaximumProductionPossible(timestep)).reduce(0.f, Float::sum);
+			f_maximum += Math.abs(maximumEnergy);
 		}
 		
 		
@@ -136,7 +137,6 @@ public class TopologieObjectiveFunction {
 		//calculating f_selection
 		double f_selection = 0;
 		double cost = 0;
-		int amountOfElemetsInWildcard = 0;
 		for(DecoratedNetwork net : state.getNetworkList()) {
 			for(DecoratedHolonObject dHobject : net.getConsumerList()) {
 				if(dHobject.getModel().getName().contains("Wildcard")){
@@ -177,60 +177,56 @@ public class TopologieObjectiveFunction {
 		for(DecoratedNetwork net: state.getNetworkList()) {
 			Graph G = GraphMetrics.convertDecoratedNetworkToGraph(net);
 			//We have to penalize single Networks;
-			//100 is the maximum penalty for a holon/network
 			if(G.V.length <= 1) {
-				f_grid += 100;
+				f_grid += lambda_avg_shortest_path + lambda_disjoint_path;
 				continue;
 			}
-			
-			
+		
 			double avgShortestPath = GraphMetrics.averageShortestDistance(G.V,  G.E);
+			//TODO replace minimumCut with avg (edge-) disjoint s-t path  
 			//k-edge-conneted
-			//int maximumK = G.V.length - 1;
-			int k = GraphMetrics.minimumCut(G.V, G.E);				
-			double penalty = disjoinPathPenalty(k);
-			 
-			f_grid += 0.5 * squash(penalty, 100) + 0.5 *squash(avgShortestPath, k_avg_shortest_path);
-		}
-		//Average over all networks
-		if(!state.getNetworkList().isEmpty()) {
-			f_grid /= state.getNetworkList().size();		
+			int disjpointPaths = GraphMetrics.minimumCut(G.V, G.E);
+			f_grid += avgShortestPathPenalty(avgShortestPath) + disjoinPathPenalty(disjpointPaths);
 		}
+		//take average to encourage splitting
+		f_grid /= state.getNetworkList().size();
+		
+		
+		
+		
+		//avg disjoint path in jeden holon von jedem zu jedem element
 		
 		
-//      System.out.println("f_grid:" + f_grid);
-//		System.out.print(" f_eb(" + w_eb * squash(f_eb, k_eb) + ") ");
-//		System.out.print(" f_holon(" + w_holon * squash(f_holon, k_holon)  + ") ");
-//		System.out.print(" f_selection(" + w_selection * squash(f_selection, k_selection)  + ") ");
-//		System.out.println(" f_grid(" + w_grid * f_grid + ") ");
 		
-		/**
-		 * F_grid is already squashed
-		 */
+		
+		
+		printUnsquashedValues(f_eb, f_maximum, f_holon, f_selection, f_grid);
 		return (float) (w_eb * squash(f_eb, k_eb) 
 				+ w_max * squash(f_maximum, k_max) 
 				+ w_holon * squash(f_holon, k_holon) 
 				+ w_selection * squash(f_selection, k_selection) 
-				+ w_grid * f_grid);
+				+ w_grid * squash(f_grid, k_grid));
 	}
 
 	private static String doubleToString(double value) {
 		return String.format (Locale.US, "%.2f", value);
 	}
 	
-	
+
 	private static double disjoinPathPenalty(double value) {
-		//von 100 auf 10% bis seperateFunctionValue linear
-		//Big Penalty
-		if( value < seperate_X_Value) {
-			return 100 - ((100 - seperate_Y_Value) / seperate_X_Value) * value;
-		}
-		//Low Penalty
-		else {
-			return seperate_Y_Value * Math.exp(lowPenaltyGrowth * (-value + seperate_X_Value));
-		}
+		return -(2.0 * lambda_disjoint_path) / (1 + Math.exp(- (value - centerValue_disjoint_path)/ range_for_k_disjoint_path)) + (2.0 * lambda_disjoint_path);
+	}
+	private static double avgShortestPathPenalty(double value) {
+		return (2.0 * lambda_avg_shortest_path) / (1 + Math.exp(- value/ range_for_k_avg_shortest_path)) - lambda_avg_shortest_path;
+	}
+	/**
+	 * Attention Math.log calcultae ln not log
+	 * @param kappa
+	 * @return
+	 */
+	private static double range(double kappa) {
+		return - kappa / Math.log(Math.pow(2.0, 0.05) - 1.0 );
 	}
-	
 	
 	/**
 	 * The squashing function in paper
@@ -252,5 +248,19 @@ public class TopologieObjectiveFunction {
 		return (supplyPercentage < 100) ? -0.5 * supplyPercentage + 50: supplyPercentage - 100;
 	}
 	
+	static void printDistribution(double f_eb, double f_maximum, double f_holon, double f_selection, double f_grid){
+		 System.out.print(" f_eb(" + w_eb * squash(f_eb, k_eb) + ") ");
+		 System.out.print(" f_maximum(" + w_max * squash(f_maximum, k_max) + ") ");
+		 System.out.print(" f_holon(" + w_holon * squash(f_holon, k_holon)  + ") ");
+		 System.out.print(" f_selection(" + w_selection * squash(f_selection, k_selection)  + ") ");
+		 System.out.println(" f_grid(" + w_grid * f_grid + ") ");
+	}
+	static void printUnsquashedValues(double f_eb, double f_maximum, double f_holon, double f_selection, double f_grid){
+		 System.out.print(" f_eb(" + f_eb + ") ");
+		 System.out.print(" f_maximum(" + f_maximum + ") ");
+		 System.out.print(" f_holon(" + f_holon + ") ");
+		 System.out.print(" f_selection(" + f_selection + ") ");
+		 System.out.println(" f_grid(" + f_grid + ") ");
+	}
 
 }

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

@@ -13,6 +13,7 @@ import api.TopologieAlgorithmFramework;
 import api.AlgorithmFrameworkFlex.Individual;
 import api.TopologieAlgorithmFramework.IndexCable;
 import ui.model.DecoratedState;
+import utility.Random;
 
 public class AcoAlgorithm extends TopologieAlgorithmFramework {
 

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

@@ -13,6 +13,7 @@ import api.TopologieAlgorithmFramework;
 import api.AlgorithmFrameworkFlex.Individual;
 import api.TopologieAlgorithmFramework.IndexCable;
 import ui.model.DecoratedState;
+import utility.Random;
 
 public class GaAlgorithm extends TopologieAlgorithmFramework {
 

+ 7 - 6
src/algorithm/topologie/PsoAlgorithm.java

@@ -13,19 +13,20 @@ import api.TopologieAlgorithmFramework;
 import api.AlgorithmFrameworkFlex.Individual;
 import api.TopologieAlgorithmFramework.IndexCable;
 import ui.model.DecoratedState;
+import utility.Random;
 
 public class PsoAlgorithm extends TopologieAlgorithmFramework {
 
 	private int popsize = 20;
-	private int maxGenerations = 100;
+	private int maxGenerations = 500;
 	private double dependency = 2.07; 
 	private double c1, c2, w;
-	private double maxVelocity = 4.0;
+	private double maxVelocity = 10.0;
 	private double deviation = 0.5;
 	//mutation
 	private int mutationInterval = 1;
-	private boolean useIntervalMutation = true;
-	private double mutationRate = 0.01;
+	private boolean useIntervalMutation = false;
+	private double mutationRate = 0.005;
 	private double mutateProbabilityInterval = 0.01;
 	private double maxMutationPercent = 0.01;
 	
@@ -156,12 +157,12 @@ public class PsoAlgorithm extends TopologieAlgorithmFramework {
 
 	@Override
 	protected String algoInformationToPrint() {
-		return "GA for topologie generation";
+		return "PSO for topologie generation";
 	}
 
 	@Override
 	protected String plottFileName() {
-		return "ga-topologie.txt";
+		return "pso-topologie.txt";
 	}
 	
 	

+ 7 - 67
src/api/TopologieAlgorithmFramework.java

@@ -68,7 +68,7 @@ import ui.view.Console;
 public abstract class TopologieAlgorithmFramework implements AddOn{
 	//Algo
 	protected int rounds = 1;
-	protected int amountOfNewCables = 3;
+	protected int amountOfNewCables = 50;
 	
 	
 	//Panel
@@ -452,6 +452,8 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 			console.println("Run have to be cancelled First.");
 			return;
 		}
+//		reset();
+//		this.extractPositionAndAccess();
 		double currentFitness = evaluateNetwork();
 		console.println("Actual Fitnessvalue: " + currentFitness);
 	}
@@ -585,6 +587,10 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 		
 		control.getSimManager().resetFlexManagerForTimeStep(control.getModel().getCurIteration());
 		setState(runBest.position);
+		for(HolonSwitch hSwitch: switchList) {
+			hSwitch.setManualMode(true);
+			hSwitch.setManualState(false);
+		}
 		updateVisual();
 		console.println("Start: " + startFitness);
 		console.println("AlgoResult: " + runBest.fitness);
@@ -1126,72 +1132,6 @@ public abstract class TopologieAlgorithmFramework implements AddOn{
 	
 	
 	
-	/**
-	* To create Random and maybe switch the random generation in the future.
-	*/
-	protected static class Random{
-		private static java.util.Random random = new java.util.Random();
-		/**
-		 * True or false
-		 * @return the random boolean.
-		 */
-		public static boolean nextBoolean(){
-			return random.nextBoolean();
-		}
-		/**
-		 * Between 0.0(inclusive) and 1.0 (exclusive)
-		 * @return the random double.
-		 */
-		public static double nextDouble() {
-			return random.nextDouble();
-		}
-		
-		public static double nextGaussian(double mean, double deviation) {
-			return mean + random.nextGaussian() * deviation;
-		}
-		
-		
-		/**
-		 * Random Int in Range [min;max[ with UniformDistirbution
-		 * @param min
-		 * @param max
-		 * @return
-		 */
-		public static int nextIntegerInRange(int min, int max) {
-			int result = min;
-			try {
-				result = min + random.nextInt(max - min);
-			}catch(java.lang.IllegalArgumentException e){
-				System.err.println("min : " + min + " max : " + max);
-				System.err.println("max should be more then min");
-			}
-			return result;
-		}
-		/**
-		 * Random Int in Range [min;max[ with UniformDistirbution
-		 * @param min
-		 * @param max
-		 * @param valueBetween a value between min and max
-		 * @return
-		 */
-		public static int nextIntegerInRangeExcept(int min, int max,int valueBetween) {
-			int result = min;
-			if(max - min == 1) {
-				return (valueBetween == min)? max:min;
-			}
-			try {
-				result = min + random.nextInt((max - 1) - min);
-				if(result >= valueBetween) {
-					result++;
-				}
-			}catch(java.lang.IllegalArgumentException e){
-				System.err.println("min : " + min + " max : " + max + " valueBetween:" + valueBetween);
-				System.err.println("Except max should be more then min");
-			}
-			return result;
-		}
-	}
-	
 	private   class  Handle<T>{
 		public T object;
 		Handle(T object){

+ 2 - 2
src/classes/HolonSwitch.java

@@ -94,7 +94,7 @@ public class HolonSwitch extends AbstractCanvasObject implements LocalMode, Grap
 		setUseLocalPeriod(copyObj.isUsingLocalPeriod());
 		activeAt=new boolean[LocalMode.STANDARD_GRAPH_ACCURACY];
 		super.setName(obj.getName());
-		setManualState(copyObj.getActiveManual());
+		setManualState(copyObj.getManualState());
 		setAutoState(true);
 		setGraphPoints(new LinkedList<Point2D.Double>());
 		for (Point2D.Double p : copyObj.getGraphPoints()) {
@@ -212,7 +212,7 @@ public class HolonSwitch extends AbstractCanvasObject implements LocalMode, Grap
 	 * 
 	 * @return boolean Manual State
 	 */
-	public boolean getActiveManual() {
+	public boolean getManualState() {
 		return this.manualActive;
 	}
 

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

@@ -313,7 +313,7 @@ public class UpdateController {
 				Object[] tempMode = { Languages.getLanguage()[74], ((HolonSwitch) obj).getManualMode() };
 				model.getPropertyTable().addRow(tempMode);
 				if (((HolonSwitch) obj).getManualMode()) {
-					Object[] tempActive = { Languages.getLanguage()[75], ((HolonSwitch) obj).getActiveManual() };
+					Object[] tempActive = { Languages.getLanguage()[75], ((HolonSwitch) obj).getManualState() };
 					model.getPropertyTable().addRow(tempActive);
 					model.getPropertyTable().setCellEditable(3, 1, true);
 				} else {

+ 2 - 2
src/ui/view/AboutUsPopUp.java

@@ -2,7 +2,7 @@ package ui.view;
 
 import javax.swing.*;
 
-import utility.Util;
+import utility.ImageImport;
 
 import java.awt.*;
 
@@ -56,7 +56,7 @@ public class AboutUsPopUp extends JFrame {
         contentPanel2.setLayout(new BoxLayout(contentPanel2, BoxLayout.Y_AXIS));
         contentPanel3.setLayout(new BoxLayout(contentPanel3, BoxLayout.Y_AXIS));
         
-        this.setIconImage(Util.loadImage("/Images/Holeg.png",30,30));
+        this.setIconImage(ImageImport.loadImage("/Images/Holeg.png",30,30));
         setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
         setBounds(100, 100, 500, 800);
         setLocationRelativeTo(parentFrame);

+ 2 - 2
src/ui/view/AddElementPopUp.java

@@ -4,7 +4,7 @@ import classes.AbstractCanvasObject;
 import classes.HolonElement;
 import classes.HolonObject;
 import ui.model.Model;
-import utility.Util;
+import utility.ImageImport;
 
 import javax.swing.*;
 import javax.swing.border.EmptyBorder;
@@ -55,7 +55,7 @@ public class AddElementPopUp extends JDialog {
 	 */
 	AddElementPopUp(JFrame parentFrame, Model model) {
 		super((java.awt.Frame) null, true);
-		this.setIconImage(Util.loadImage("/Images/Holeg.png", 30, 30));
+		this.setIconImage(ImageImport.loadImage("/Images/Holeg.png", 30, 30));
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
 		setBounds(100, 100, 400, 245);
 		setLocationRelativeTo(parentFrame);

+ 4 - 4
src/ui/view/AddObjectPopUp.java

@@ -8,7 +8,7 @@ import classes.Pair;
 import ui.controller.Control;
 import java.lang.NumberFormatException;
 import ui.model.Model;
-import utility.Util;
+import utility.ImageImport;
 
 import javax.swing.*;
 import javax.swing.border.EmptyBorder;
@@ -82,7 +82,7 @@ public class AddObjectPopUp extends JDialog {
         toEdit = obj;
 		editState = edit;
 		this.model=model;
-		this.setIconImage(Util.loadImage("/Images/Holeg.png",30,30));
+		this.setIconImage(ImageImport.loadImage("/Images/Holeg.png",30,30));
 		setBounds(100, 100, 450, 342);
         setLocationRelativeTo(parentFrame);
         getContentPane().setLayout(new BorderLayout());
@@ -156,7 +156,7 @@ public class AddObjectPopUp extends JDialog {
 				}
 			});
 			if (edit) {
-				lblImagePreview.setIcon(new ImageIcon(Util.loadImage(obj.getImage(), 50, 50)));
+				lblImagePreview.setIcon(new ImageIcon(ImageImport.loadImage(obj.getImage(), 50, 50)));
 			}
 			sourcePath.setBounds(148, 77, 271, 20);
 			if(edit) {
@@ -287,7 +287,7 @@ public class AddObjectPopUp extends JDialog {
     	//TODO: Click mich <3 
     	HolonBattery editBat = (HolonBattery) obj;
     	//Window Settings
-    	this.setIconImage(Util.loadImage("/Images/battery.png",30,30));
+    	this.setIconImage(ImageImport.loadImage("/Images/battery.png",30,30));
     	this.setTitle("Edit Battery");
     	setBounds(0, 0, 285, 290);
         setLocationRelativeTo(parentFrame);

+ 2 - 2
src/ui/view/AddOnWindow.java

@@ -33,7 +33,7 @@ import javax.tools.ToolProvider;
 
 import api.AddOn;
 import ui.controller.Control;
-import utility.Util;
+import utility.ImageImport;
 
 @SuppressWarnings("serial")
 public class AddOnWindow extends JFrame{
@@ -45,7 +45,7 @@ public class AddOnWindow extends JFrame{
 		this.setTitle("Add-Ons");
 		this.setVisible(true);
 		this.setContentPane(content);
-		this.setIconImage(Util.loadImage("/Images/Holeg.png", 30, 30));
+		this.setIconImage(ImageImport.loadImage("/Images/Holeg.png", 30, 30));
 		initMenuBar();
 		initDefaultContentPanel();
 		this.pack();

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

@@ -3,7 +3,7 @@ package ui.view;
 import classes.GroupNode;
 import ui.controller.Control;
 import ui.model.Model;
-import utility.Util;
+import utility.ImageImport;
 
 import javax.swing.*;
 import javax.swing.filechooser.FileNameExtensionFilter;
@@ -65,7 +65,7 @@ public class BackgroundPopUp extends JDialog {
 			imageWidth.setText("" + icon.getIconWidth());
 			imageHeight.setText("" + icon.getIconHeight());
 		}
-		this.setIconImage(Util.loadImage("/Images/Holeg.png",30,30));
+		this.setIconImage(ImageImport.loadImage("/Images/Holeg.png",30,30));
 		setBounds(100, 100, 600, 340);
         setLocationRelativeTo(parentFrame);
 

+ 2 - 2
src/ui/view/CanvasResizePopUp.java

@@ -2,7 +2,7 @@ package ui.view;
 
 import ui.controller.Control;
 import ui.model.Model;
-import utility.Util;
+import utility.ImageImport;
 
 import javax.swing.*;
 import java.awt.*;
@@ -39,7 +39,7 @@ public class CanvasResizePopUp extends JDialog {
 		this.canvas = canvas;
 
 		// properties and stuff
-		this.setIconImage(Util.loadImage("/Images/Holeg.png",30,30));
+		this.setIconImage(ImageImport.loadImage("/Images/Holeg.png",30,30));
 		this.setTitle("Set the Size of the View");
 		setBounds(200, 100, 200, 100);
         setLocationRelativeTo(parentFrame);

+ 4 - 4
src/ui/view/Console.java

@@ -13,7 +13,7 @@ import javax.swing.JTextArea;
 import javax.swing.JToolBar;
 import javax.swing.text.DefaultCaret;
 
-import utility.Util;
+import utility.ImageImport;
 /**
  * Little new swing object to print data to a console.
  * @author tom
@@ -33,16 +33,16 @@ public class Console extends JPanel {
 		this.add(scrollPane, BorderLayout.CENTER);
 		JToolBar toolBar = new JToolBar();
 		toolBar.setFloatable(false);
-		JButton clearButton  = new JButton("", new ImageIcon(Util.loadImage("/Button_Images/Clear.png", 24, 24)));
+		JButton clearButton  = new JButton("", new ImageIcon(ImageImport.loadImage("/Button_Images/Clear.png", 24, 24)));
 		clearButton.setToolTipText("Clear Console");
 		clearButton.addActionListener(actionEvent -> clear());
 		toolBar.add(clearButton);
 		toolBar.add(Box.createHorizontalGlue());
-		JButton topButton = new JButton("", new ImageIcon(Util.loadImage("/Button_Images/Top.png", 24, 24)));
+		JButton topButton = new JButton("", new ImageIcon(ImageImport.loadImage("/Button_Images/Top.png", 24, 24)));
 		topButton.setToolTipText("Scroll to top");
 		topButton.addActionListener(actionEvent -> scrollToTop());
 		toolBar.add(topButton);
-		JButton botButton = new JButton("", new ImageIcon(Util.loadImage("/Button_Images/Bottom.png", 24, 24)));
+		JButton botButton = new JButton("", new ImageIcon(ImageImport.loadImage("/Button_Images/Bottom.png", 24, 24)));
 		botButton.setToolTipText("Scroll to bottom");
 		botButton.addActionListener(actionEvent -> scrollToBottom());
 		toolBar.add(botButton);

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

@@ -7,7 +7,7 @@ import classes.HolonObject;
 import classes.Pair;
 import ui.controller.Control;
 import ui.model.Model;
-import utility.Util;
+import utility.ImageImport;
 
 import javax.swing.*;
 import javax.swing.border.EmptyBorder;
@@ -112,7 +112,7 @@ public class CreateTemplatePopUp extends JDialog {
 		/*
 		 * create Frame and GUI
 		 */
-		setIconImage(Util.loadImage("/Images/Holeg.png", 30, 30));
+		setIconImage(ImageImport.loadImage("/Images/Holeg.png", 30, 30));
 		setBounds(100, 100, 476, 344);
 		setLocationRelativeTo(parentFrame);
 		getContentPane().setLayout(new BorderLayout());
@@ -196,7 +196,7 @@ public class CreateTemplatePopUp extends JDialog {
 		 * Image Preview
 		 */
 		lblImagePreview = new JLabel("Image Preview");
-		lblImagePreview.setIcon(new ImageIcon(Util.loadImage(
+		lblImagePreview.setIcon(new ImageIcon(ImageImport.loadImage(
 				template.getImage(), 62, 62)));
 		lblImagePreview.setBounds(298, 13, 62, 62);
 		contentPanel.add(lblImagePreview);
@@ -282,7 +282,7 @@ public class CreateTemplatePopUp extends JDialog {
 			File selectedFile = fileChooser.getSelectedFile();
 			String filePath = selectedFile.getAbsolutePath();
 			textField_imagePath.setText(filePath);
-			ImageIcon icon = new ImageIcon(Util.loadImage(filePath, 62,
+			ImageIcon icon = new ImageIcon(ImageImport.loadImage(filePath, 62,
 					62));
 			lblImagePreview.setIcon(icon);
 		} else {

+ 2 - 2
src/ui/view/FlexWindow.java

@@ -61,7 +61,7 @@ import ui.controller.FlexManager;
 import ui.controller.FlexManager.FlexState;
 import ui.controller.FlexManager.FlexWrapper;
 import ui.model.Model;
-import utility.Util;
+import utility.ImageImport;
 
 
 public class FlexWindow extends JFrame {
@@ -118,7 +118,7 @@ public class FlexWindow extends JFrame {
 
 	private void initWindowPanel(JFrame parentFrame) {
 		this.setBounds(0, 0, 400, parentFrame.getHeight()>20?parentFrame.getHeight()- 20:parentFrame.getHeight());
-		this.setIconImage(Util.loadImage("/Images/Holeg.png", 30, 30));
+		this.setIconImage(ImageImport.loadImage("/Images/Holeg.png", 30, 30));
 		this.setTitle("Flexibility");
 		this.setLocationRelativeTo(parentFrame);
 		this.setVisible(true);

+ 12 - 12
src/ui/view/GUI.java

@@ -19,7 +19,7 @@ import ui.model.DecoratedState;
 import ui.model.Model;
 import ui.model.Model.FairnessModel;
 import ui.view.NewPopUp.Option;
-import utility.Util;
+import utility.ImageImport;
 
 import javax.swing.*;
 import javax.swing.border.Border;
@@ -195,8 +195,8 @@ public class GUI implements CategoryListener {
 	         "", "5", "10", "20" ,"100", "1000"
 	};
 	private JComboBox<String> localPeriodInput = new JComboBox<String>(comboContext);
-	JButton resetButton = new JButton("", new ImageIcon(Util.loadImage("/Images/resetIcon3.png")));
-	ImageIcon localPeriodButtonImage = new ImageIcon(GrayFilter.createDisabledImage(Util.loadImage("/Images/Graph.png")));
+	JButton resetButton = new JButton("", new ImageIcon(ImageImport.loadImage("/Images/resetIcon3.png")));
+	ImageIcon localPeriodButtonImage = new ImageIcon(GrayFilter.createDisabledImage(ImageImport.loadImage("/Images/Graph.png")));
 	private JButton localPeriodButton = new JButton("", localPeriodButtonImage);
 	private final JPanel graphLabel = new JPanel();
 	private final JScrollPane scrollProperties = new JScrollPane();
@@ -693,7 +693,7 @@ public class GUI implements CategoryListener {
 
 		holegJFrame.setJMenuBar(menuBar);
 
-		holegJFrame.setIconImage(Util.loadImage(
+		holegJFrame.setIconImage(ImageImport.loadImage(
 				"/Images/Holeg.png", 30, 30));
 
 		menuBar.add(mnNewMenu);
@@ -1722,7 +1722,7 @@ public class GUI implements CategoryListener {
 					for (Category cat : model.getCategories()) {
 						for (AbstractCanvasObject cps : cat.getObjects()) {
 							if (value.toString().compareTo(cps.getObjName()) == 0) {
-								imgR = Util.loadImage(cps.getImage(), 50,
+								imgR = ImageImport.loadImage(cps.getImage(), 50,
 										50);
 								if (imgR != null) {
 									label.setIcon(new ImageIcon(imgR));
@@ -1740,7 +1740,7 @@ public class GUI implements CategoryListener {
 				if (label.getText().length() == 0) {
 					label.setText(value.toString());
 					if (value.toString().compareTo("Categories") != 0) {
-						label.setIcon(new ImageIcon(Util.loadImage(
+						label.setIcon(new ImageIcon(ImageImport.loadImage(
 								"/Images/folder.png")));
 					}
 				}
@@ -1981,7 +1981,7 @@ public class GUI implements CategoryListener {
 														32,
 														java.awt.Image.SCALE_SMOOTH);
 									} else {
-										img = Util.loadImage(
+										img = ImageImport.loadImage(
 												cps.getImage(), 32, 32);
 									}
 									tempCps = cps;
@@ -2525,21 +2525,21 @@ public class GUI implements CategoryListener {
 	private void initWindowMenu() {
 		menuBar.add(menuWindow);
 		//Algo
-		JMenuItem openMenu =  new JMenuItem("Open Algorithm Panel", new ImageIcon(Util.loadImage("/Button_Images/iconAlgo.png").getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH)));
+		JMenuItem openMenu =  new JMenuItem("Open Algorithm Panel", new ImageIcon(ImageImport.loadImage("/Button_Images/iconAlgo.png").getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH)));
 		openMenu.addActionListener(actionEvent -> {
 			new AddOnWindow(holegJFrame, controller);
 		});
 		openMenu.setAccelerator(KeyStroke.getKeyStroke('N', Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask()));
 		menuWindow.add(openMenu);
 		//Outliner
-		JMenuItem openOutliner =  new JMenuItem("Open Outliner", new ImageIcon(Util.loadImage("/Button_Images/iconOutliner.png").getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH)));
+		JMenuItem openOutliner =  new JMenuItem("Open Outliner", new ImageIcon(ImageImport.loadImage("/Button_Images/iconOutliner.png").getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH)));
 		openOutliner.addActionListener(actionEvent -> {
 			outlinerList.add(new Outliner(holegJFrame, model, controller));
 		});
 		openOutliner.setAccelerator(KeyStroke.getKeyStroke('O', Toolkit.getDefaultToolkit ().getMenuShortcutKeyMask()));
 		menuWindow.add(openOutliner);
 		//FlexWindow
-		JMenuItem openFlexMenuItem =  new JMenuItem("Open Flexibility Panel", new ImageIcon(Util.loadImage("/Button_Images/iconAlgo.png").getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH)));
+		JMenuItem openFlexMenuItem =  new JMenuItem("Open Flexibility Panel", new ImageIcon(ImageImport.loadImage("/Button_Images/iconAlgo.png").getScaledInstance(20, 20, java.awt.Image.SCALE_SMOOTH)));
 		openFlexMenuItem.addActionListener(actionEvent -> {
 			flexList.add(new FlexWindow(holegJFrame, controller));
 		});
@@ -3133,9 +3133,9 @@ public class GUI implements CategoryListener {
 		localPeriodInput.setVisible(enabled);
 		if(enabled)
 		{
-			localPeriodButtonImage.setImage(Util.loadImage("/Images/Graph.png"));
+			localPeriodButtonImage.setImage(ImageImport.loadImage("/Images/Graph.png"));
 		}else {
-			localPeriodButtonImage.setImage(GrayFilter.createDisabledImage(Util.loadImage("/Images/Graph.png")));
+			localPeriodButtonImage.setImage(GrayFilter.createDisabledImage(ImageImport.loadImage("/Images/Graph.png")));
 		}
 	}
 	/**

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

@@ -17,7 +17,7 @@ import ui.model.Supplier;
 import ui.model.VisualRepresentationalState;
 import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.DecoratedSwitch.SwitchState;
-import utility.Util;
+import utility.ImageImport;
 
 import javax.swing.*;
 
@@ -371,7 +371,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 	}
 	
 	private void drawCanvasObject(Graphics2D g, String Image, Position pos) {
-		g.drawImage(Util.loadImage(Image, controller.getScale(), controller.getScale()) , 
+		g.drawImage(ImageImport.loadImage(Image, controller.getScale(), controller.getScale()) , 
 				pos.x - controller.getScaleDiv2(),
 				pos.y - controller.getScaleDiv2(),
 				controller.getScale(), controller.getScale() , null);
@@ -645,7 +645,7 @@ public class GroupNodeCanvas extends AbstractCanvas implements MouseListener, Mo
 		if(mayBeReplaced != null){
 			g2d.setColor(Color.RED);
 			Position pos = mayBeReplaced.getPosition();
-			g.drawImage(Util.loadImage("/Images/replace.png") , 
+			g.drawImage(ImageImport.loadImage("/Images/replace.png") , 
 					pos.x + controller.getScaleDiv2(),
 					pos.y - controller.getScale(),
 					controller.getScaleDiv2(), controller.getScaleDiv2(), null);

+ 2 - 2
src/ui/view/Languages.java

@@ -5,7 +5,7 @@ import java.io.IOException;
 import java.io.InputStreamReader;
 import java.nio.charset.Charset;
 
-import utility.Util;
+import utility.ImageImport;
 
 public class Languages {
 
@@ -118,7 +118,7 @@ public class Languages {
 		String[] langArr;
 		try {
 			//read File from Jar
-			InputStreamReader reader = new InputStreamReader(Util.loadStream(/*Languages.class.getClassLoader(),*/path));
+			InputStreamReader reader = new InputStreamReader(ImageImport.loadStream(/*Languages.class.getClassLoader(),*/path));
 			BufferedReader br = new BufferedReader(reader);
 			
 			//store Lines in Array

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

@@ -15,7 +15,7 @@ import ui.model.DecoratedHolonObject.HolonObjectState;
 import ui.model.DecoratedNetwork;
 import ui.model.DecoratedSwitch;
 import ui.model.DecoratedSwitch.SwitchState;
-import utility.Util;
+import utility.ImageImport;
 import ui.model.Model;
 import ui.model.Passiv;
 import ui.model.Supplier;
@@ -380,7 +380,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 	}
 	
 	private void drawCanvasObject(Graphics2D g, String Image, Position pos) {
-		g.drawImage(Util.loadImage(Image, controller.getScale(), controller.getScale()) , 
+		g.drawImage(ImageImport.loadImage(Image, controller.getScale(), controller.getScale()) , 
 				pos.x - controller.getScaleDiv2(),
 				pos.y - controller.getScaleDiv2(),
 				controller.getScale(), controller.getScale() , null);
@@ -619,7 +619,7 @@ public class MyCanvas extends AbstractCanvas implements MouseListener,
 		if(mayBeReplaced != null){
 			g2d.setColor(Color.RED);
 			Position pos = mayBeReplaced.getPosition();
-			g2d.drawImage(Util.loadImage("/Images/replace.png") , 
+			g2d.drawImage(ImageImport.loadImage("/Images/replace.png") , 
 					pos.x + controller.getScaleDiv2(),
 					pos.y - controller.getScale(),
 					controller.getScaleDiv2(), controller.getScaleDiv2(), null);

+ 5 - 5
src/ui/view/Outliner.java

@@ -26,7 +26,7 @@ import ui.controller.Control;
 import ui.model.Consumer;
 import ui.model.DecoratedCable;
 import ui.model.DecoratedHolonObject.HolonObjectState;
-import utility.Util;
+import utility.ImageImport;
 import ui.model.DecoratedNetwork;
 import ui.model.DecoratedState;
 import ui.model.DecoratedSwitch;
@@ -49,7 +49,7 @@ public class Outliner extends JFrame {
 	ArrayList<MinimumNetwork> list;
 	Outliner(JFrame parentFrame, Model model, Control controller){ 
 		setBounds(0, 0, 400, parentFrame.getHeight());
-		this.setIconImage(Util.loadImage("/Images/Holeg.png", 30, 30));
+		this.setIconImage(ImageImport.loadImage("/Images/Holeg.png", 30, 30));
 		this.setTitle("Outliner");
 		setLocationRelativeTo(parentFrame);
 		this.setVisible(true);
@@ -154,9 +154,9 @@ public class Outliner extends JFrame {
 
 
 	private void signIconsForTree(JTree t) {
-		ImageIcon ClosedIcon = new ImageIcon(Util.loadImage("/Button_Images/Close.png",9,9));
-		ImageIcon OpenIcon = new ImageIcon(Util.loadImage("/Button_Images/Open.png",9,9));
-		ImageIcon LeafIcon = new ImageIcon(Util.loadImage("/Button_Images/Leaf.png",9,9));
+		ImageIcon ClosedIcon = new ImageIcon(ImageImport.loadImage("/Button_Images/Close.png",9,9));
+		ImageIcon OpenIcon = new ImageIcon(ImageImport.loadImage("/Button_Images/Open.png",9,9));
+		ImageIcon LeafIcon = new ImageIcon(ImageImport.loadImage("/Button_Images/Leaf.png",9,9));
 		if (ClosedIcon != null && OpenIcon != null && LeafIcon!= null) {
 		    DefaultTreeCellRenderer renderer = 
 		        new DefaultTreeCellRenderer();

+ 2 - 2
src/ui/view/StatisticGraph.java

@@ -348,7 +348,7 @@ public class StatisticGraph extends JPanel {
                     break;
                 case TrackedDataSet.ON_OFF:
                     if (((HolonSwitch) set.getCpsObject()).getManualMode()) {
-                        if (((HolonSwitch) set.getCpsObject()).getActiveManual()) {
+                        if (((HolonSwitch) set.getCpsObject()).getManualState()) {
                             set.setValAt(1, model.getCurIteration());
                         } else {
                             set.setValAt(0, model.getCurIteration());
@@ -444,7 +444,7 @@ public class StatisticGraph extends JPanel {
                 case TrackedDataSet.AMOUNT_BROKEN_EDGES:
                     for (SubNet sub : controller.getSimManager().getSubNets()) {
                         for (HolonSwitch s : sub.getSwitches()) {
-                            if (s.getManualMode()?s.getActiveManual():s.getAutoActive()) {
+                            if (s.getManualMode()?s.getManualState():s.getAutoActive()) {
                                 val++;
                             }
                         }

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

@@ -3,7 +3,7 @@ package ui.view;
 import ui.controller.Control;
 import ui.controller.SingletonControl;
 import ui.model.Model;
-import utility.Util;
+import utility.ImageImport;
 
 import javax.swing.*;
 import javax.swing.event.ChangeEvent;
@@ -118,7 +118,7 @@ public class TimePanel extends JPanel implements ActionListener{
 							+ (performanceTime%1000000)/1000 + " Mikrosekunden ");
 					//*/
 					running = false;
-					playBtn.setIcon(new ImageIcon(Util.loadImage("/Button_Images/play.png", 30, 30)));
+					playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/play.png", 30, 30)));
 					timer.stop();
 				}
 			}
@@ -166,7 +166,7 @@ public class TimePanel extends JPanel implements ActionListener{
 		playBtn.setContentAreaFilled(false);
 		playBtn.setBorderPainted(false);
 		playBtn.setBorder(null);
-		playBtn.setIcon(new ImageIcon(Util.loadImage("/Button_Images/play.png",30,30)));
+		playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/play.png",30,30)));
 		playBtn.addActionListener(new ActionListener() {
 			@Override
 			public void actionPerformed(ActionEvent e) {
@@ -187,10 +187,10 @@ public class TimePanel extends JPanel implements ActionListener{
 					//*/
 					
 					timer.start();
-					playBtn.setIcon(new ImageIcon(Util.loadImage("/Button_Images/pause.png", 30, 30)));
+					playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/pause.png", 30, 30)));
 				} else {
 					timer.stop();
-					playBtn.setIcon(new ImageIcon(Util.loadImage("/Button_Images/play.png", 30, 30)));
+					playBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/play.png", 30, 30)));
 				}
 			}
 		});
@@ -198,7 +198,7 @@ public class TimePanel extends JPanel implements ActionListener{
 
 		timeResetBtn.setContentAreaFilled(false);
 		timeResetBtn.setBorder(null);
-		timeResetBtn.setIcon(new ImageIcon(Util.loadImage("/Button_Images/reset.png", 30, 30)));
+		timeResetBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/reset.png", 30, 30)));
 		timeResetBtn.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent ae) {
 				timeSlider.setValue(timeSlider.getMinimum());
@@ -214,7 +214,7 @@ public class TimePanel extends JPanel implements ActionListener{
 
 		timeForwardBtn.setContentAreaFilled(false);
 		timeForwardBtn.setBorder(null);
-		timeForwardBtn.setIcon(new ImageIcon(Util.loadImage("/Button_Images/forward.png",30,30)));
+		timeForwardBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/forward.png",30,30)));
 		timeForwardBtn.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent ae) {
 				if (!cont.getModel().getIsSimRunning()) {
@@ -227,7 +227,7 @@ public class TimePanel extends JPanel implements ActionListener{
 		timeBackwardBtn.setToolTipText(Languages.getLanguage()[92]);
 
 		timeBackwardBtn.setBorder(null);
-		timeBackwardBtn.setIcon(new ImageIcon(Util.loadImage("/Button_Images/backward.png", 30,30)));
+		timeBackwardBtn.setIcon(new ImageIcon(ImageImport.loadImage("/Button_Images/backward.png", 30,30)));
 		timeBackwardBtn.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent ae) {
 				timeSlider.setValue(timeSlider.getValue() - 1);

+ 3 - 3
src/utility/Util.java → src/utility/ImageImport.java

@@ -18,7 +18,7 @@ import javax.swing.JLabel;
  *	Centralized resource loading methods
  *	for improved performance and easier troubleshooting.
  */
-public class Util {
+public class ImageImport {
 	
 	/**
 	 * 30x30 pixel FileNotFound Icon, which can be shown without using I/O operations
@@ -34,7 +34,7 @@ public class Util {
 	private static final byte SAVE_NOTHING=0, /*SAVE_EXTERNAL=1,*/ SAVE_RAW=2, SAVE_EVERYTHING=4,
 								SAVE_MODE=SAVE_EVERYTHING;
 	private static HashMap<String, Image> imgStorage;
-	private static Util xmp=new Util();//Used to load resources from the JAR.
+	private static ImageImport xmp=new ImageImport();//Used to load resources from the JAR.
 	
 	static{
 		/*
@@ -150,5 +150,5 @@ public class Util {
 	}
 	
 	//Nobody needs an instance of this. I do, because I use it to load images from inside the JAR.
-	private Util(){}
+	private ImageImport(){}
 }

+ 38 - 3
src/utility/Random.java

@@ -1,5 +1,9 @@
 package utility;
 
+
+
+
+
 public class Random {
 		
 		
@@ -23,8 +27,16 @@ public class Random {
 		public static float nextFloatInRange(float min, float max) {
 			return min + random.nextFloat() * Math.abs(max - min);
 		}
-		
-		
+		/**
+		 * Returns the next pseudorandom, Gaussian ("normally") distributed double value with mean
+		 * and standard deviation from this random number generator's sequence. 
+		 * @param mean
+		 * @param deviation
+		 * @return
+		 */
+		public static double nextGaussian(double mean, double deviation) {
+			return mean + random.nextGaussian() * deviation;
+		}
 		public static double nextDoubleInRange(double min, double max) {
 			return min + random.nextDouble() * Math.abs(max - min);
 		}
@@ -38,5 +50,28 @@ public class Random {
 		public static int nextIntegerInRange(int min, int max) {
 			return min + random.nextInt(max - min);
 		}
-	
+		/**
+		 * Random Int in Range [min;max[ with UniformDistirbution
+		 * @param min
+		 * @param max
+		 * @param valueBetween a value between min and max
+		 * @return
+		 */
+		public static int nextIntegerInRangeExcept(int min, int max,int valueBetween) {
+			int result = min;
+			if(max - min == 1) {
+				//return the other value
+				return (valueBetween == min)? max:min;
+			}
+			try {
+				result = min + random.nextInt((max - 1) - min);
+				if(result >= valueBetween) {
+					result++;
+				}
+			}catch(java.lang.IllegalArgumentException e){
+				System.err.println("min : " + min + " max : " + max + " valueBetween:" + valueBetween);
+				System.err.println("Except max should be more then min");
+			}
+			return result;
+		}
 }