Browse Source

#76: added wasted energy to statistics panel

I. Dix 7 years ago
parent
commit
8b0b2e417f

+ 3 - 2
src/classes/TrackedDataSet.java

@@ -1,9 +1,9 @@
 package classes;
 
-import java.awt.Color;
-
 import com.google.gson.annotations.Expose;
 
+import java.awt.*;
+
 public class TrackedDataSet {
 
 	//Property Integers
@@ -31,6 +31,7 @@ public class TrackedDataSet {
 	public static final int AVG_AMOUNT_ACTIVE_ELEMENTS_IN_HOLONS = 21;
 	public static final int AVG_AMOUNT_INACTIVE_ELEMENTS_IN_HOLONS = 22;
 	public static final int AVG_PRODUCED_ENERGY_IN_HOLONS = 23;
+	public static final int WASTED_ENERGY = 24;
 	
 	//Variables of the Data Set
 	private AbstractCpsObject cps;

+ 5 - 7
src/interfaces/GraphListener.java

@@ -1,14 +1,12 @@
 package interfaces;
 
-import java.util.ArrayList;
-
 import classes.AbstractCpsObject;
 
+import java.util.ArrayList;
+
 public interface GraphListener {
-	
-	public void repaintTree();
-	
-	public void addTrackedObject(ArrayList<AbstractCpsObject> hlList);
-	
 
+    void repaintTree();
+
+    void addTrackedObject(ArrayList<AbstractCpsObject> hlList);
 }

+ 0 - 1
src/ui/controller/SimulationManager.java

@@ -90,7 +90,6 @@ public class SimulationManager {
             }
         }
         canvas.repaint();
-//        printNetsToConsole();
         flexPane.recalculate();
     }
 

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

@@ -53,7 +53,7 @@ public class Model {
     private float maxCapacity;
     // Table for HolonElements --> all cells are editable
     private JTable tableHolonElement;
-    private ArrayList<GraphListener> graphListeners = new ArrayList<GraphListener>();
+    private ArrayList<GraphListener> graphListeners = new ArrayList();
     // Iteration Speed
     private int timerSpeed = 1000;
     private int selectedID = 0;

+ 83 - 38
src/ui/view/StatisticGraph.java

@@ -17,21 +17,24 @@ public class StatisticGraph extends JPanel {
     private static final long serialVersionUID = 1L;
 
     // Maximum y Value
-    float maximum = 0;
+    private float maximum = 0;
 
     // is the Simulation running?
 //	private boolean isSimRunning;
-    GeneralPath path = new GeneralPath();
+    private GeneralPath path = new GeneralPath();
     // model and controller
     private Model model;
     private Control controller;
     // Graphics2D
     private Graphics2D g2;
+
     // Data
     private ArrayList<TrackedDataSet> dataSets = new ArrayList<>();
 
     private boolean showGrid = true;
 
+    private float DISTANCE_IN_GRAPH = 1.0f;
+
 //	private JTable table = new JTable();
 //	private ArrayList<Line2D> gridLines = new ArrayList<>();
 
@@ -41,7 +44,7 @@ public class StatisticGraph extends JPanel {
      * @param model   the Model
      * @param control the Controller
      */
-    public StatisticGraph(final Model model, Control control) {
+    StatisticGraph(final Model model, Control control) {
         this.controller = control;
         this.model = model;
         this.setBackground(Color.WHITE);
@@ -90,6 +93,7 @@ public class StatisticGraph extends JPanel {
                 case TrackedDataSet.ACTIVATED_ELEMENTS:
                 case TrackedDataSet.TOTAL_PRODUCTION:
                 case TrackedDataSet.TOTAL_CONSUMPTION:
+                case TrackedDataSet.WASTED_ENERGY:
                 case TrackedDataSet.AMOUNT_HOLONS:
                 case TrackedDataSet.GROUP_CONSUMPTION:
                 case TrackedDataSet.GROUP_PRODUCTION:
@@ -147,7 +151,7 @@ public class StatisticGraph extends JPanel {
      * @param d the number to convert
      * @return the converted number
      */
-    public double convertToCanvasY(float d) {
+    private double convertToCanvasY(float d) {
         return Math.abs((this.getHeight() - (d * (this.getHeight() / maximum))));
     }
 
@@ -170,7 +174,7 @@ public class StatisticGraph extends JPanel {
     /**
      * Calculate the Max Value of the Graph
      */
-    public void calcMaximum() {
+    void calcMaximum() {
         maximum = 0;
         for (TrackedDataSet set : dataSets) {
             float val = 0;
@@ -205,6 +209,9 @@ public class StatisticGraph extends JPanel {
                     val = getMaxTotalConsumption(model.getObjectsOnCanvas());
                     val *= -1;
                     break;
+                case TrackedDataSet.WASTED_ENERGY:
+                    val = getMaxWastedEnergy(model.getObjectsOnCanvas());
+                    break;
                 case TrackedDataSet.PERCENT_SUPPLIED:
                 case TrackedDataSet.PERCENT_NOT_SUPPLIED:
                 case TrackedDataSet.PERCENT_PARTIAL_SUPPLIED:
@@ -258,7 +265,7 @@ public class StatisticGraph extends JPanel {
                     break;
                 case TrackedDataSet.AVG_CONSUMED_ENERGY_IN_HOLONS:
                     for (SubNet sub : controller.getSimManager().getSubNets()) {
-                        float tempVal = -getMaxTotalConsumption(new ArrayList<AbstractCpsObject>(sub.getObjects()));
+                        float tempVal = -getMaxTotalConsumption(new ArrayList<>(sub.getObjects()));
                         if (val < tempVal) {
                             val = tempVal;
                         }
@@ -266,7 +273,7 @@ public class StatisticGraph extends JPanel {
                     break;
                 case TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS:
                     for (SubNet sub : controller.getSimManager().getSubNets()) {
-                        float tempVal = getMaxTotalProduction(new ArrayList<AbstractCpsObject>(sub.getObjects()));
+                        float tempVal = getMaxTotalProduction(new ArrayList<>(sub.getObjects()));
                         if (val < tempVal) {
                             val = tempVal;
                         }
@@ -290,7 +297,7 @@ public class StatisticGraph extends JPanel {
                     break;
                 case TrackedDataSet.AVG_PRODUCED_ENERGY_IN_HOLONS:
                     for (SubNet sub : controller.getSimManager().getSubNets()) {
-                        float tempVal = getMaxTotalProduction(new ArrayList<AbstractCpsObject>(sub.getObjects()));
+                        float tempVal = getMaxTotalProduction(new ArrayList<>(sub.getObjects()));
                         if (val < tempVal) {
                             val = tempVal;
                         }
@@ -310,7 +317,7 @@ public class StatisticGraph extends JPanel {
     /**
      * Add the Current Values to each set
      */
-    public void addValues() {
+    void addValues() {
         for (TrackedDataSet set : dataSets) {
             float val = 0;
             switch (set.getProperty()) {
@@ -362,6 +369,10 @@ public class StatisticGraph extends JPanel {
                     set.setValAt(-getTotalConsumptionAt(model.getObjectsOnCanvas(), model.getCurIteration()),
                             model.getCurIteration());
                     break;
+                case TrackedDataSet.WASTED_ENERGY:
+                    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());
@@ -424,7 +435,7 @@ public class StatisticGraph extends JPanel {
                     break;
                 case TrackedDataSet.AVG_CONSUMED_ENERGY_IN_HOLONS:
                     for (SubNet sub : controller.getSimManager().getSubNets()) {
-                        val += -getTotalConsumptionAt(new ArrayList<AbstractCpsObject>(sub.getObjects()),
+                        val += -getTotalConsumptionAt(new ArrayList<>(sub.getObjects()),
                                 model.getCurIteration());
                     }
                     val /= controller.getSimManager().getSubNets().size();
@@ -432,9 +443,9 @@ public class StatisticGraph extends JPanel {
                     break;
                 case TrackedDataSet.AVG_WASTED_ENERGY_IN_HOLONS:
                     for (SubNet sub : controller.getSimManager().getSubNets()) {
-                        val += (getTotalProductionAt(new ArrayList<AbstractCpsObject>(sub.getObjects()),
+                        val += (getTotalProductionAt(new ArrayList<>(sub.getObjects()),
                                 model.getCurIteration())
-                                + getTotalConsumptionAt(new ArrayList<AbstractCpsObject>(sub.getObjects()),
+                                + getTotalConsumptionAt(new ArrayList<>(sub.getObjects()),
                                 model.getCurIteration()));
                     }
                     val /= controller.getSimManager().getSubNets().size();
@@ -500,7 +511,7 @@ public class StatisticGraph extends JPanel {
                     break;
                 case TrackedDataSet.AVG_PRODUCED_ENERGY_IN_HOLONS:
                     for (SubNet sub : controller.getSimManager().getSubNets()) {
-                        val += getTotalProductionAt(new ArrayList<AbstractCpsObject>(sub.getObjects()),
+                        val += getTotalProductionAt(new ArrayList<>(sub.getObjects()),
                                 model.getCurIteration());
                     }
                     val /= controller.getSimManager().getSubNets().size();
@@ -515,7 +526,7 @@ public class StatisticGraph extends JPanel {
     /**
      * create Path with floats
      *
-     * @param set
+     * @param set tracked data
      */
     private void createPathFloats(TrackedDataSet set) {
         int range = model.getCurIteration(); //to which iteration
@@ -525,7 +536,7 @@ public class StatisticGraph extends JPanel {
         if (set.getValues()[0] != -1) {
             path.moveTo(0, convertToCanvasY(set.getValues()[0]));
         } else {
-            path.moveTo(1 * this.getWidth() / model.getIterations(), convertToCanvasY(set.getValues()[1]));
+            path.moveTo(DISTANCE_IN_GRAPH * this.getWidth() / model.getIterations(), convertToCanvasY(set.getValues()[1]));
         }
         for (int i = 0; i < range; i++) {
             if (set.getValues()[i + 1] != -1) {
@@ -543,24 +554,24 @@ public class StatisticGraph extends JPanel {
     /**
      * create Path with booleans(0 and 1)
      *
-     * @param set
+     * @param set tracked data
      */
     private void createPathBooleans(TrackedDataSet set) {
         if (set.getValues()[0] != -1) {
-            path.moveTo(0, convertToCanvasY((float) (set.getValues()[0] * (maximum / 3 * 2)) + (maximum / 6)));
+            path.moveTo(0, convertToCanvasY((set.getValues()[0] * (maximum / 3 * 2)) + (maximum / 6)));
         } else {
-            path.moveTo(1 * this.getWidth() / model.getIterations(),
-                    convertToCanvasY((float) (set.getValues()[1] * (maximum / 3 * 2)) + (maximum / 6)));
+            path.moveTo(DISTANCE_IN_GRAPH * this.getWidth() / model.getIterations(),
+                    convertToCanvasY((set.getValues()[1] * (maximum / 3 * 2)) + (maximum / 6)));
         }
         for (int i = 0; i < model.getCurIteration(); i++) {
             controller.addTextToConsole(set.getValues()[i] + "");
             if (set.getValues()[i + 1] != -1) {
                 path.lineTo((i + 1) * this.getWidth() / model.getIterations(),
-                        convertToCanvasY((float) (set.getValues()[i + 1] * (maximum / 3 * 2)) + (maximum / 6)));
+                        convertToCanvasY((set.getValues()[i + 1] * (maximum / 3 * 2)) + (maximum / 6)));
             } else {
                 if (i + 2 < model.getCurIteration()) {
                     path.moveTo((i + 2) * this.getWidth() / model.getIterations(),
-                            convertToCanvasY((float) (set.getValues()[i + 2] * (maximum / 3 * 2)) + (maximum / 6)));
+                            convertToCanvasY((set.getValues()[i + 2] * (maximum / 3 * 2)) + (maximum / 6)));
                 }
             }
         }
@@ -569,13 +580,13 @@ public class StatisticGraph extends JPanel {
     /**
      * create Path for percent values
      *
-     * @param set
+     * @param set tracked data
      */
     private void createPathPercent(TrackedDataSet set) {
         if (set.getValues()[0] != -1) {
             path.moveTo(0, convertToCanvasY(set.getValues()[0] * maximum));
         } else {
-            path.moveTo(1 * this.getWidth() / model.getIterations(), convertToCanvasY(set.getValues()[1] * maximum));
+            path.moveTo(DISTANCE_IN_GRAPH * this.getWidth() / model.getIterations(), convertToCanvasY(set.getValues()[1] * maximum));
         }
         for (int i = 0; i < model.getCurIteration(); i++) {
             if (set.getValues()[i + 1] != -1) {
@@ -593,8 +604,6 @@ public class StatisticGraph extends JPanel {
 
     /**
      * get the max total production of the given Objects
-     *
-     * @param objects List of Objects
      */
     private float getMaxTotalProduction(ArrayList<AbstractCpsObject> objects) {
         float val = 0;
@@ -615,8 +624,6 @@ public class StatisticGraph extends JPanel {
 
     /**
      * get the max total consumption of the given Objects
-     *
-     * @param objects List of Objects
      */
     private float getMaxTotalConsumption(ArrayList<AbstractCpsObject> objects) {
         float val = 0;
@@ -635,11 +642,30 @@ public class StatisticGraph extends JPanel {
         return val;
     }
 
+
     /**
-     * get the max total production of the given Objects
-     *
-     * @param objects List of Objects
-     * @param tStep
+     * get the max total wasted energy of the given Objects
+     * if it is smaller than 0, return 0
+     */
+    private float getMaxWastedEnergy(ArrayList<AbstractCpsObject> objects) {
+        float val = 0;
+
+        for (AbstractCpsObject obj : objects) {
+            if (obj instanceof HolonObject) {
+                for (HolonElement ele : ((HolonObject) obj).getElements()) {
+                    val += (ele.getEnergy() + ele.getFlexibility()) * ele.getAmount();
+                }
+            } else if (obj instanceof CpsUpperNode) {
+                val += getMaxWastedEnergy(((CpsUpperNode) obj).getNodes());
+            }
+        }
+
+        return val < 0 ? 0 : val;
+    }
+
+
+    /**
+     * get the max total production of the given objects at the given timestep
      */
     private float getTotalProductionAt(ArrayList<AbstractCpsObject> objects, int tStep) {
         float val = 0;
@@ -659,10 +685,7 @@ public class StatisticGraph extends JPanel {
     }
 
     /**
-     * get the total consumption of the given Objects at the given timestep
-     *
-     * @param objects List of Objects
-     * @param tStep
+     * get the total consumption of the given objects at the given timestep
      */
     private float getTotalConsumptionAt(ArrayList<AbstractCpsObject> objects, int tStep) {
         float val = 0;
@@ -681,6 +704,28 @@ public class StatisticGraph extends JPanel {
         return val;
     }
 
+    /**
+     * get the total wasted energy of the given objects at the given timestep
+     */
+    private float getTotalWastedEnergyAt(ArrayList<AbstractCpsObject> objects, int tStep) {
+        float val = 0;
+
+        for (AbstractCpsObject obj : objects) {
+            if (obj instanceof HolonObject) {
+                for (HolonElement ele : ((HolonObject) obj).getElements()) {
+                    if (ele.getActive()) {
+                        val += ele.getTotalEnergyAtTimeStep(tStep);
+                    }
+                }
+            } else if (obj instanceof CpsUpperNode) {
+                val += getTotalWastedEnergyAt(((CpsUpperNode) obj).getNodes(), tStep);
+            }
+        }
+
+        return val;
+    }
+
+
     /**
      * get the Percentage of how many objects with the given state are in the
      * given List
@@ -706,13 +751,13 @@ public class StatisticGraph extends JPanel {
     /**
      * Reset the Graph. Delete all calculated values.
      */
-    public void resetGraph() {
+    void resetGraph() {
         for (TrackedDataSet s : dataSets) {
             s.resetValues();
         }
     }
 
-    protected void hideGrid() {
+    void hideGrid() {
         Graphics g = this.getGraphics();
         showGrid = false;
         // clear the area
@@ -720,7 +765,7 @@ public class StatisticGraph extends JPanel {
         paintComponent(g);
     }
 
-    protected void showGrid() {
+    void showGrid() {
         Graphics g = this.getGraphics();
         showGrid = true;
         paintComponent(g);

+ 3 - 0
src/ui/view/StatisticGraphPanel.java

@@ -197,6 +197,9 @@ public class StatisticGraphPanel extends JSplitPane {
                 property = "consumption";
                 break;
             case TrackedDataSet.PRODUCTION:
+            case TrackedDataSet.WASTED_ENERGY:
+                property = "wasted energy";
+                break;
             case TrackedDataSet.GROUP_PRODUCTION:
                 property = "production";
                 break;

+ 37 - 35
src/ui/view/StatisticPanel.java

@@ -19,37 +19,36 @@ import java.util.Hashtable;
 import java.util.Random;
 
 public class StatisticPanel extends JSplitPane implements GraphListener {
-    public static final String MAIN_GRID = "Main Grid";
-    public static final String HOLON = "Holons";
-
-    // Property Strings
-    public static final String TOT_PROD_HOLON = "total production";
-    public static final String TOT_CONS_HOLON = "total consumption";
-    public static final String SUPPLIED_OBJ = "supplied objects' percentage";
-    public static final String NOT_SUPPLIED_OBJ = "not supplied objects' percentage";
-    public static final String PART_SUPPLIED_OBJ = "partially supplied objects' percentage";
-    public static final String NR_HOLONS = "nr. of Holons";
-    public static final String NR_CLOSED_SWITCHES = "nr. of closed switches";
-    public static final String AVG_OBJ_IN_HOLONS = "average amount of objects";
-    public static final String AVG_ELEM_IN_HOLONS = "average amount of elements";
-    public static final String AVG_PRODS_IN_HOLONS = "average amount of producers";
-    public static final String AVG_CONS_ENERGY_IN_HOLONS = "average consumed energy";
-    public static final String AVG_WASTED_ENERGY_HOLONS = "average wasted energy";
-    public static final String NR_BROKEN_EDGES = "nr. of broken eedges";
-    public static final String PROD_CONS_RATIO = "producer/consumer ratio";
-    public static final String AVG_CLOSED_SW_HOLON = "average of closed switches per Holon";
-    public static final String AVG_ACTIVE_ELEMENTS_HOLON = "average of active elements per Holon";
     public static final String AVG_INACTIVE_ELEMENTS_HOLON = "average of inactive elements per Holon";
     public static final String AVG_PRODUCTION_HOLON = "average production per Holon";
-
+    // for tracked objects
     public static final String TOT_PROD_OBJ = "total production";
     public static final String TOT_CONS_OBJ = "total consumption";
     public static final String NR_ACTIVE_ELEMENTS = "active elements";
-
     public static final String SW_ACTIVE = "active";
-
     public static final String TOT_PROD_GRID = "total Grid production";
     public static final String TOT_CONS_GRID = "total Grid consumption";
+    private static final String MAIN_GRID = "Main Grid";
+    private static final String HOLON = "Holons";
+    // Property Strings
+    // for whole grid
+    private static final String TOT_PROD_HOLON = "total production";
+    private static final String TOT_CONS_HOLON = "total consumption";
+    private static final String TOT_WASTED_HOLON = "total wasted energy";
+    private static final String SUPPLIED_OBJ = "supplied objects' percentage";
+    private static final String NOT_SUPPLIED_OBJ = "not supplied objects' percentage";
+    private static final String PART_SUPPLIED_OBJ = "partially supplied objects' percentage";
+    private static final String NR_HOLONS = "nr. of Holons";
+    private static final String NR_CLOSED_SWITCHES = "nr. of closed switches";
+    private static final String AVG_OBJ_IN_HOLONS = "average amount of objects";
+    private static final String AVG_ELEM_IN_HOLONS = "average amount of elements";
+    private static final String AVG_PRODS_IN_HOLONS = "average amount of producers";
+    private static final String AVG_CONS_ENERGY_IN_HOLONS = "average consumed energy";
+    private static final String AVG_WASTED_ENERGY_HOLONS = "average wasted energy";
+    private static final String NR_BROKEN_EDGES = "nr. of broken edges";
+    private static final String PROD_CONS_RATIO = "producer/consumer ratio";
+    private static final String AVG_CLOSED_SW_HOLON = "average of closed switches per Holon";
+    private static final String AVG_ACTIVE_ELEMENTS_HOLON = "average of active elements per Holon";
     private DefaultTreeModel treeModel;
     private DefaultMutableTreeNode objectsNode;
     private DefaultMutableTreeNode mainGrid;
@@ -96,6 +95,7 @@ public class StatisticPanel extends JSplitPane implements GraphListener {
         holonHashtable = new Hashtable<>();
         holonHashtable.put(TOT_PROD_HOLON, new PropertyDataSet("", defaultGraphColor));
         holonHashtable.put(TOT_CONS_HOLON, new PropertyDataSet("", defaultGraphColor));
+        holonHashtable.put(TOT_WASTED_HOLON, new PropertyDataSet("", defaultGraphColor));
         holonHashtable.put(SUPPLIED_OBJ, new PropertyDataSet("", defaultGraphColor));
         holonHashtable.put(NOT_SUPPLIED_OBJ, new PropertyDataSet("", defaultGraphColor));
         holonHashtable.put(PART_SUPPLIED_OBJ, new PropertyDataSet("", defaultGraphColor));
@@ -118,6 +118,7 @@ public class StatisticPanel extends JSplitPane implements GraphListener {
         propValTable = new Hashtable<>();
         propValTable.put(TOT_PROD_OBJ, TrackedDataSet.PRODUCTION);
         propValTable.put(TOT_CONS_OBJ, TrackedDataSet.CONSUMPTION);
+        propValTable.put(TOT_WASTED_HOLON, TrackedDataSet.WASTED_ENERGY);
         propValTable.put(NR_ACTIVE_ELEMENTS, TrackedDataSet.ACTIVATED_ELEMENTS);
         propValTable.put(SW_ACTIVE, TrackedDataSet.ON_OFF);
         propValTable.put(TOT_PROD_HOLON, TrackedDataSet.TOTAL_PRODUCTION);
@@ -171,6 +172,7 @@ public class StatisticPanel extends JSplitPane implements GraphListener {
         mainGrid = new DefaultMutableTreeNode(MAIN_GRID);
         mainGrid.add(new DefaultMutableTreeNode(TOT_PROD_HOLON));
         mainGrid.add(new DefaultMutableTreeNode(TOT_CONS_HOLON));
+        mainGrid.add(new DefaultMutableTreeNode(TOT_WASTED_HOLON));
         mainGrid.add(new DefaultMutableTreeNode(SUPPLIED_OBJ));
         mainGrid.add(new DefaultMutableTreeNode(NOT_SUPPLIED_OBJ));
         mainGrid.add(new DefaultMutableTreeNode(PART_SUPPLIED_OBJ));
@@ -540,12 +542,12 @@ public class StatisticPanel extends JSplitPane implements GraphListener {
         btnAdd.addActionListener(actionEvent -> {
             DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) objectTree
                     .getLastSelectedPathComponent();
-            if (selectedNode == null) {
-                return;
-            } else {
-                if (selectedNode.getLevel() == 3 || (selectedNode.getLevel() == 2 &&
-                        (selectedNode.getParent().toString().equals(HOLON) || selectedNode.getParent().toString().equals(MAIN_GRID)))) {
-                    StatisticGraphPanel tmp = null;
+            if (selectedNode != null) {
+                int nodeLevel = selectedNode.getLevel();
+                String parentString = selectedNode.getParent().toString();
+                if (nodeLevel == 3 ||
+                        (nodeLevel == 2 && (parentString.equals(HOLON) || parentString.equals(MAIN_GRID)))) {
+                    StatisticGraphPanel tmp;
                     if (graphNrTxtField.getText().length() > 0) {
                         if (!graphHashtable.containsKey(graphNrTxtField.getText())
                                 && graphNrTxtField.getText().length() > 0) {
@@ -721,11 +723,11 @@ public class StatisticPanel extends JSplitPane implements GraphListener {
 
     }
 
-    public void colorChanged(Color color) {
+    private void colorChanged(Color color) {
         colorPanel.setBackground(color);
     }
 
-    public void resetFields() {
+    private void resetFields() {
         colorPanel.setBackground(defaultGraphColor);
         redField.setText("");
         greenField.setText("");
@@ -733,7 +735,7 @@ public class StatisticPanel extends JSplitPane implements GraphListener {
         colorComboBox.setSelectedIndex(0);
     }
 
-    public void disableFields() {
+    private void disableFields() {
         redField.setEnabled(false);
         greenField.setEnabled(false);
         blueField.setEnabled(false);
@@ -742,7 +744,7 @@ public class StatisticPanel extends JSplitPane implements GraphListener {
         colorPanel.setBackground(Color.LIGHT_GRAY);
     }
 
-    public void enableFields() {
+    private void enableFields() {
         redField.setEnabled(true);
         greenField.setEnabled(true);
         blueField.setEnabled(true);
@@ -751,7 +753,7 @@ public class StatisticPanel extends JSplitPane implements GraphListener {
         colorPanel.setBackground(defaultGraphColor);
     }
 
-    public void repaintGraphs() {
+    void repaintGraphs() {
         for (StatisticGraphPanel sg : graphHashtable.values()) {
             sg.calcMaximum();
             sg.addValues();
@@ -759,7 +761,7 @@ public class StatisticPanel extends JSplitPane implements GraphListener {
         }
     }
 
-    public JPanel getGraphPanel() {
+    JPanel getGraphPanel() {
         return graphPanel;
     }
 

+ 21 - 46
src/ui/view/TimePanel.java

@@ -1,31 +1,14 @@
 package ui.view;
 
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Image;
-import java.awt.Point;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import javax.swing.AbstractAction;
-import javax.swing.Box;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JSlider;
-import javax.swing.KeyStroke;
-import javax.swing.Timer;
+import ui.controller.Control;
+import ui.model.Model;
+
+import javax.swing.*;
 import javax.swing.event.ChangeEvent;
 import javax.swing.event.ChangeListener;
 import javax.swing.plaf.basic.BasicSliderUI;
-
-import ui.controller.Control;
-import ui.model.Model;
+import java.awt.*;
+import java.awt.event.*;
 
 /**
  * This Class represents a Panel where the User can start and stop the
@@ -36,13 +19,18 @@ import ui.model.Model;
  */
 public class TimePanel extends JPanel {
 
-	private Model model;
-	private Control controller;
-	private int dragResetIteration = 0;
-
+	private static final long serialVersionUID = 1L;
+	final JButton playBtn = new JButton();
+	final JButton timeResetBtn = new JButton();
+	final JButton timeForwardBtn = new JButton();
+	;
+	final JButton timeBackwardBtn = new JButton();
+	private final JPanel btnAndSpeedPanel = new JPanel();
+	private final JPanel speedPanel = new JPanel();
+	private final JPanel timeBtnPanel = new JPanel();
 	JSlider timeSlider = new JSlider() {
 		/**
-		 * 
+		 *
 		 */
 		private static final long serialVersionUID = 1L;
 
@@ -70,23 +58,15 @@ public class TimePanel extends JPanel {
 			};
 			addMouseListener(tl);
 		}
-	};;
-
+	};
+	private Model model;
+	private Control controller;
+	private int dragResetIteration = 0;
 	private JLabel simSpeedLabel = new JLabel("Speed:");
 	private JSlider speedSlider = new JSlider();
-
-	private final JPanel btnAndSpeedPanel = new JPanel();
-	private final JPanel speedPanel = new JPanel();
-	private final JPanel timeBtnPanel = new JPanel();
-	final JButton playBtn = new JButton();
-	final JButton timeResetBtn = new JButton();
-	final JButton timeForwardBtn = new JButton();
-	final JButton timeBackwardBtn = new JButton();
 	private Timer timer;
 	private boolean running = false;
 
-	private static final long serialVersionUID = 1L;
-
 	/**
 	 * Constructor.
 	 * 
@@ -127,12 +107,7 @@ public class TimePanel extends JPanel {
 		timeSlider.setToolTipText(Languages.getLanguage()[93]);
 		timeSlider.setMaximum(model.getIterations() - 1);
 		timeSlider.setValue(0);
-		timeSlider.addChangeListener(new ChangeListener() {
-			@Override
-			public void stateChanged(ChangeEvent e) {
-				controller.setCurIteration(timeSlider.getValue());
-			}
-		});
+		timeSlider.addChangeListener(changeEvent -> controller.setCurIteration(timeSlider.getValue()));
 
 		timeSlider.addMouseListener(new MouseAdapter() {
 			@Override