Browse Source

Updates Readme

TomTroppmann 2 years ago
parent
commit
b8f40754e8
37 changed files with 416 additions and 441 deletions
  1. 12 12
      README.md
  2. BIN
      res/images/git/gradle.png
  3. BIN
      res/images/git/import.png
  4. 1 1
      src/holeg/model/HolonSwitch.java
  5. 9 7
      src/holeg/ui/view/Main.java
  6. 0 135
      src/holeg/ui/view/component/ButtonTabComponent.java
  7. 0 2
      src/holeg/ui/view/component/Console.java
  8. 4 0
      src/holeg/ui/view/component/TrippleCheckBox.java
  9. 0 96
      src/holeg/ui/view/dialog/AboutUsPopUp.java
  10. 0 3
      src/holeg/ui/view/dialog/AddElementPopUp.java
  11. 0 2
      src/holeg/ui/view/dialog/AddObjectPopUp.java
  12. 3 0
      src/holeg/ui/view/dialog/CanvasResizePopUp.java
  13. 0 2
      src/holeg/ui/view/dialog/EditEdgesPopUp.java
  14. 3 0
      src/holeg/ui/view/dialog/NewCategoryDialog.java
  15. 1 1
      src/holeg/ui/view/image/Import.java
  16. 12 3
      src/holeg/ui/view/information/HolonInformationPanel.java
  17. 10 6
      src/holeg/ui/view/inspector/Inspector.java
  18. 18 9
      src/holeg/ui/view/inspector/InspectorTable.java
  19. 44 59
      src/holeg/ui/view/inspector/UnitGraph.java
  20. 6 2
      src/holeg/ui/view/inspector/UnitGraphPoint.java
  21. 3 1
      src/holeg/ui/view/main/Appearance.java
  22. 15 7
      src/holeg/ui/view/main/Gui.java
  23. 3 19
      src/holeg/ui/view/main/TimePanel.java
  24. 25 28
      src/holeg/ui/view/window/AddOnWindow.java
  25. 34 12
      src/holeg/ui/view/window/FlexWindow.java
  26. 44 8
      src/holeg/ui/view/window/Outliner.java
  27. 20 6
      src/holeg/utility/events/Action.java
  28. 17 1
      src/holeg/utility/events/Event.java
  29. 3 0
      src/holeg/utility/listener/LostFocusListener.java
  30. 3 1
      src/holeg/utility/listener/ResizeListener.java
  31. 3 1
      src/holeg/utility/listener/SimpleDocumentListener.java
  32. 3 0
      src/holeg/utility/listener/WindowClosingListener.java
  33. 22 3
      src/holeg/utility/math/decimal/Format.java
  34. 31 7
      src/holeg/utility/math/decimal/Sampler.java
  35. 56 5
      src/holeg/utility/math/vector/Geometry.java
  36. 2 2
      src/holeg/utility/math/vector/Vec2f.java
  37. 9 0
      src/holeg/utility/math/vector/Vec2i.java

+ 12 - 12
README.md

@@ -2,18 +2,18 @@
 
 Cyber-physical systems simulation software following a Holon-based smart grid system.
 
-## Introduction and User Manual
-
-The Wiki contains some
-general [Information](https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons/wiki/Introduction)
-and
-a [User Manual](https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons/wiki/User+Manual)
-
-## API Instructions
-
-Check out
-the [API Instructions Wiki](https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons/wiki/Algorithms)
-for some Instructions
+## Installation
+This project uses gradle as build tool. Gradle is not needed to be installed on your local machine.
+#### Commandline
+When using the commandline 'gradlew' is used. For Windows change with 'gradlew.bat'.
+```
+./gradlew build
+./gradlew run
+```
+#### Eclipse
+When using the Eclipse IDE to develop. Import the project as existing gradle project.
+![alt text](res/images/git/import.png "Import")
+![alt text](res/images/git/gradle.png "Gradle")
 
 ## License
 

BIN
res/images/git/gradle.png


BIN
res/images/git/import.png


+ 1 - 1
src/holeg/model/HolonSwitch.java

@@ -184,7 +184,7 @@ public class HolonSwitch extends AbstractCanvasObject implements TimelineDepende
     boolean[] activeTriggerPos = new boolean[sampleLength];
     for (int i = 0; i < sampleLength; i++) {
       double graphX = (double) i / (double) (sampleLength - 1); // from 0.0 to 1.0
-      if (graphX > after.x) {
+      if (graphX > after.getX()) {
         before = after;
         after = iter.next();
       }

+ 9 - 7
src/holeg/ui/view/Main.java

@@ -14,16 +14,14 @@ import javax.swing.UIManager;
 import javax.swing.UnsupportedLookAndFeelException;
 
 /**
- * The main Class in this Program. The GUI is created in this Class.
- *
- * @author Gruppe14
+ * The main entry of this program.
  */
 public class Main {
-
   private static final LogManager logManager = LogManager.getLogManager();
   private static final Logger log = Logger.getLogger(Main.class.getName());
 
   static {
+    //Initialize logging
     try {
       logManager.readConfiguration(new FileInputStream("./config/log.properties"));
     } catch (IOException exception) {
@@ -32,9 +30,10 @@ public class Main {
   }
 
   /**
-   * main method of this program.
-   *
-   * @param args standard
+   * Main method of this program.
+   * No arguments are evaluated.
+   * Sets the look and feel, creates the gui and start the EventQueue.
+   * @param args arguments
    */
   public static void main(String[] args) {
     setLookAndFeel();
@@ -48,6 +47,9 @@ public class Main {
     });
   }
 
+  /**
+   * Sets the locale.
+   */
   private static void setLocale() {
     Locale.setDefault(Locale.US);
   }

+ 0 - 135
src/holeg/ui/view/component/ButtonTabComponent.java

@@ -1,135 +0,0 @@
-package holeg.ui.view.component;
-
-import java.awt.BasicStroke;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-import javax.swing.AbstractButton;
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTabbedPane;
-import javax.swing.plaf.basic.BasicButtonUI;
-
-/**
- * Component to be used as tabComponent; Contains a JLabel to show the text and a JButton to close
- * the tab it belongs to
- */
-public class ButtonTabComponent extends JPanel {
-
-  private final static MouseListener buttonMouseListener = new MouseAdapter() {
-    public void mouseEntered(MouseEvent e) {
-      Component component = e.getComponent();
-      if (component instanceof AbstractButton button) {
-        button.setBorderPainted(true);
-      }
-    }
-
-    public void mouseExited(MouseEvent e) {
-      Component component = e.getComponent();
-      if (component instanceof AbstractButton button) {
-        button.setBorderPainted(false);
-      }
-    }
-  };
-  private final JTabbedPane pane;
-
-  public ButtonTabComponent(final JTabbedPane pane) {
-    // unset default FlowLayout' gaps
-    super(new FlowLayout(FlowLayout.LEFT, 0, 0));
-    if (pane == null) {
-      throw new NullPointerException("TabbedPane is null");
-    }
-    this.pane = pane;
-    setOpaque(false);
-
-    // make JLabel read titles from JTabbedPane
-    JLabel label = new JLabel() {
-      public String getText() {
-        int i = pane.indexOfTabComponent(ButtonTabComponent.this);
-        if (i != -1) {
-          return pane.getTitleAt(i);
-        }
-        return null;
-      }
-    };
-
-    add(label);
-    // add more space between the label and the button
-    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
-    // tab button
-    JButton button = new TabButton();
-    add(button);
-    // add more space to the top of the component
-    setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
-  }
-
-  /**
-   * removes both Tabs
-   */
-  public void removeTabs() {
-    int i = pane.indexOfTabComponent(ButtonTabComponent.this);
-    if (i != -1) {
-      pane.remove(i);
-    }
-  }
-
-  private class TabButton extends JButton implements ActionListener {
-
-    public TabButton() {
-      int size = 17;
-      setPreferredSize(new Dimension(size, size));
-      setToolTipText("close this tab");
-      // Make the button looks the same for all Laf's
-      setUI(new BasicButtonUI());
-      // Make it transparent
-      setContentAreaFilled(false);
-      // No need to be focusable
-      setFocusable(false);
-      setBorder(BorderFactory.createEtchedBorder());
-      setBorderPainted(false);
-      // Making nice rollover effect
-      // we use the same listener for all buttons
-      addMouseListener(buttonMouseListener);
-      setRolloverEnabled(true);
-      // Close the proper tab by clicking the button
-      addActionListener(this);
-    }
-
-    public void actionPerformed(ActionEvent e) {
-      removeTabs();
-    }
-
-    // we don't want to update UI for this button
-    public void updateUI() {
-    }
-
-    // paint the cross
-    protected void paintComponent(Graphics g) {
-      super.paintComponent(g);
-      Graphics2D g2 = (Graphics2D) g.create();
-      // shift the image for pressed buttons
-      if (getModel().isPressed()) {
-        g2.translate(1, 1);
-      }
-      g2.setStroke(new BasicStroke(2));
-      g2.setColor(Color.BLACK);
-      if (getModel().isRollover()) {
-        g2.setColor(Color.MAGENTA);
-      }
-      int delta = 6;
-      g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1);
-      g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1);
-      g2.dispose();
-    }
-  }
-}

+ 0 - 2
src/holeg/ui/view/component/Console.java

@@ -14,8 +14,6 @@ import javax.swing.text.DefaultCaret;
 
 /**
  * Little new swing object to print data to a console.
- *
- * @author tom
  */
 public class Console extends JPanel {
 

+ 4 - 0
src/holeg/ui/view/component/TrippleCheckBox.java

@@ -9,6 +9,10 @@ import javax.swing.Icon;
 import javax.swing.JCheckBox;
 import javax.swing.UIManager;
 
+/**
+ * A checkbox with tree states. Specially for the indication that none, all or partial amount of
+ * things are selected.
+ */
 public class TrippleCheckBox extends JCheckBox implements Icon, ActionListener {
 
   final static Icon icon = UIManager.getIcon("CheckBox.icon");

+ 0 - 96
src/holeg/ui/view/dialog/AboutUsPopUp.java

@@ -1,96 +0,0 @@
-package holeg.ui.view.dialog;
-
-import holeg.preferences.ImagePreference;
-import holeg.ui.view.image.Import;
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.Font;
-import javax.swing.Box;
-import javax.swing.BoxLayout;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
-/**
- * AboutUs Pop Up Window.
- *
- * @author Gruppe14
- */
-public class AboutUsPopUp extends JFrame {
-
-  /**
-   * Constructor
-   */
-  public AboutUsPopUp(JFrame parentFrame) {
-    super("About Us");
-
-    // Set fonts
-    Font fontTitle = new Font("Titel", Font.ITALIC, 35);
-    JLabel titel = new JLabel("HOLEG Simulator");
-    titel.setFont(fontTitle);
-    titel.setBounds(150, 30, 100, 20);
-    Font headerFont = new Font("Header", Font.ITALIC, 20);
-    JLabel h1 = new JLabel("Project Management & Architect");
-    h1.setFont(headerFont);
-    JLabel h2 = new JLabel("Software Developers");
-    h2.setFont(headerFont);
-    JLabel h3 = new JLabel("Documentation");
-    h3.setFont(headerFont);
-    JLabel h4 = new JLabel("Additional Collaborators");
-    h4.setFont(headerFont);
-
-    // Set labels
-    titel.setHorizontalAlignment(JLabel.CENTER);
-
-    // Set layout
-    JPanel contentPanel = new JPanel();
-    contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
-    JPanel contentPanel2 = new JPanel();
-    contentPanel2.setLayout(new BoxLayout(contentPanel2, BoxLayout.Y_AXIS));
-    JPanel contentPanel3 = new JPanel();
-    contentPanel3.setLayout(new BoxLayout(contentPanel3, BoxLayout.Y_AXIS));
-
-    this.setIconImage(Import.loadImage(ImagePreference.Logo, 30, 30));
-    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
-    setBounds(100, 100, 500, 800);
-    setLocationRelativeTo(parentFrame);
-
-    contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-    contentPanel.add(titel);
-    contentPanel.add(Box.createRigidArea(new Dimension(0, 15)));
-    JLabel description = new JLabel(
-        "A discrete-time simulator for modeling Smart Grids that follow a Holon-based model.");
-    contentPanel.add(description);
-    contentPanel.add(Box.createRigidArea(new Dimension(0, 60)));
-    getContentPane().add(contentPanel, BorderLayout.NORTH);
-
-    contentPanel2.add(h1);
-    JLabel namesManagement = new JLabel("C. Garcia Cordero");
-    contentPanel2.add(namesManagement);
-    contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
-    contentPanel2.add(h2);
-    JLabel namesDevelopersUntilV2 = new JLabel(
-        "K. Trometer, D. Rieder, T. Zheng, J. Widhalm, E. Palza, I. Dix");
-    contentPanel2.add(namesDevelopersUntilV2);
-    JLabel namesDevelopersV2_1 = new JLabel(
-        "A.T. Meyer-Berg, A. Schneider, T. Troppmann and L. Tietze");
-    contentPanel2.add(namesDevelopersV2_1);
-    contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
-    contentPanel2.add(h3);
-    JLabel namesDocumentation = new JLabel("E. Palza, C. Garcia Cordero");
-    contentPanel2.add(namesDocumentation);
-    contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
-    contentPanel2.add(h4);
-    JLabel namesCollaborators = new JLabel("R. Egert and F. Volk");
-    contentPanel2.add(namesCollaborators);
-    contentPanel2.add(Box.createRigidArea(new Dimension(0, 50)));
-    JLabel credits = new JLabel();
-    contentPanel2.add(credits);
-    getContentPane().add(contentPanel2, BorderLayout.CENTER);
-
-    contentPanel3.add(Box.createRigidArea(new Dimension(0, 50)));
-    //contentPanel3.add(namesDevelopers);
-    getContentPane().add(contentPanel3, BorderLayout.SOUTH);
-    this.setVisible(true);
-  }
-}

+ 0 - 3
src/holeg/ui/view/dialog/AddElementPopUp.java

@@ -22,9 +22,6 @@ import javax.swing.border.EmptyBorder;
 
 /**
  * popup for adding an Holon Element to a holon Object.
- *
- * @author Gruppe14
- * @author improved by A.T.M.-B. (Gruppe007)
  */
 public class AddElementPopUp extends JDialog {
 

+ 0 - 2
src/holeg/ui/view/dialog/AddObjectPopUp.java

@@ -41,8 +41,6 @@ import javax.swing.filechooser.FileNameExtensionFilter;
 
 /**
  * Popup for adding a Holon Object to a Category.
- *
- * @author Gruppe14
  */
 public class AddObjectPopUp extends JDialog {
 

+ 3 - 0
src/holeg/ui/view/dialog/CanvasResizePopUp.java

@@ -14,6 +14,9 @@ import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
 
+/**
+ * A Dialog for changing the canvas size.
+ */
 public class CanvasResizePopUp extends JDialog {
 
   private final JTextField widthTextField = new JTextField();

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

@@ -20,8 +20,6 @@ import javax.swing.border.EmptyBorder;
 
 /**
  * Popup for Editing Edges.
- *
- * @author Gruppe14
  */
 public class EditEdgesPopUp extends JDialog {
 

+ 3 - 0
src/holeg/ui/view/dialog/NewCategoryDialog.java

@@ -12,6 +12,9 @@ import javax.swing.JLabel;
 import javax.swing.JPanel;
 import javax.swing.JTextField;
 
+/**
+ * A simple Dialog for creating new Categories.
+ */
 public class NewCategoryDialog extends JDialog {
 
   private final JPanel contentPanel = new JPanel(new BorderLayout());

+ 1 - 1
src/holeg/ui/view/image/Import.java

@@ -12,7 +12,7 @@ import java.util.HashMap;
 import javax.imageio.ImageIO;
 
 /**
- * @author TU-Darmstadt BP Gruppe 7 WS17/18 Centralized resource loading methods for improved
+ * Centralized resource loading methods for improved
  * performance and easier troubleshooting.
  */
 public class Import {

+ 12 - 3
src/holeg/ui/view/information/HolonInformationPanel.java

@@ -44,8 +44,10 @@ import org.knowm.xchart.XChartPanel;
 import org.knowm.xchart.style.PieStyler;
 import org.knowm.xchart.style.PieStyler.LabelType;
 
+/**
+ * This panel shows aggregated information of the selection of the canvas objects.
+ */
 public class HolonInformationPanel extends JPanel {
-
   private static final Logger log = Logger.getLogger(HolonInformationPanel.class.getName());
   private static final Color[] supplyStateColors = new Color[]{ColorPreference.HolonObject.Producer,
       ColorPreference.HolonObject.OverSupplied, ColorPreference.HolonObject.Supplied,
@@ -113,7 +115,7 @@ public class HolonInformationPanel extends JPanel {
     this.add(graphPanel, BorderLayout.CENTER);
   }
 
-  public void updateCharts() {
+  private void updateCharts() {
     TempGroupNode tempGroupNode = new TempGroupNode();
     if (GuiSettings.getSelectedObjects().isEmpty()) {
       tempGroupNode.add(control.getModel().getCanvas());
@@ -497,6 +499,9 @@ public class HolonInformationPanel extends JPanel {
     return chart;
   }
 
+  /**
+   * A MenuButton that shows a popupmenu on click.
+   */
   public static class MenuButton extends JToggleButton {
 
     JPopupMenu popup;
@@ -528,12 +533,16 @@ public class HolonInformationPanel extends JPanel {
     }
   }
 
+  /**
+   * A temporary groupNode that don't interfere with ownership like a normal GroupNode.
+   */
   private static class TempGroupNode extends GroupNode {
 
     public TempGroupNode() {
       super("temp");
     }
 
+    @Override
     public void add(AbstractCanvasObject object) {
       if (object instanceof HolonObject hObject) {
         objectList.add(hObject);
@@ -545,7 +554,7 @@ public class HolonInformationPanel extends JPanel {
         groupNodeList.add(groupNode);
       }
     }
-
+    @Override
     public void remove(AbstractCanvasObject object) {
       if (object instanceof HolonObject hObject) {
         objectList.remove(hObject);

+ 10 - 6
src/holeg/ui/view/inspector/Inspector.java

@@ -32,6 +32,11 @@ import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
 import javax.swing.JToolBar;
 
+/**
+ * With the Inspector you can inspect the selection of the canvas objects.
+ * For all HolonElements in all selected HolonObjects a table is generated.
+ * When selecting a HolonSwitch the OnOff Cycle can be adjusted.
+ */
 public class Inspector extends JSplitPane {
 
   private static final Logger log = Logger.getLogger(Inspector.class.getName());
@@ -51,11 +56,11 @@ public class Inspector extends JSplitPane {
       Import.loadImage(ImagePreference.Button.Inspector.Graph));
   private final ImageIcon localPeriodButtonImageDisabled = new ImageIcon(
       GrayFilter.createDisabledImage(Import.loadImage(ImagePreference.Button.Inspector.Graph)));
-  private String[] comboContext = {"", "5", "10", "20", "100", "1000"};
-  private JComboBox<String> localPeriodInput = new JComboBox<String>(comboContext);
-  private JButton resetButton = new JButton("",
+  private final String[] comboContext = {"", "5", "10", "20", "100", "1000"};
+  private final JComboBox<String> localPeriodInput = new JComboBox<>(comboContext);
+  private final JButton resetButton = new JButton("",
       new ImageIcon(Import.loadImage(ImagePreference.Button.Inspector.Reset)));
-  private JButton localPeriodButton = new JButton("", localPeriodButtonImageEnabled);
+  private final JButton localPeriodButton = new JButton("", localPeriodButtonImageEnabled);
 
   public Inspector(Control control) {
     table = new InspectorTable(control);
@@ -194,7 +199,6 @@ public class Inspector extends JSplitPane {
             Float::sum);
     double percentage = Maths.invLerp(maxEnergy, minEnergy, 0.0);
     int widgetHeight = this.globalCurveLabel.getHeight();
-    int textMiddle = this.zeroEnergy.getPreferredSize().height / 4;
     int zeroYPos = (int) (widgetHeight * percentage) - 5;
     this.minEnergy.setText(Format.doubleTwoPlaces(minEnergy));
     this.maxEnergy.setText(Format.doubleTwoPlaces(maxEnergy));
@@ -215,7 +219,7 @@ public class Inspector extends JSplitPane {
   /**
    * Displayed the actual LocalModeState.
    *
-   * @param enabled
+   * @param enabled the state
    */
   private void changeLocalPeriodButtonAppearance(boolean enabled) {
     localPeriodInput.setVisible(enabled);

+ 18 - 9
src/holeg/ui/view/inspector/InspectorTable.java

@@ -52,6 +52,9 @@ import javax.swing.SwingConstants;
 import javax.swing.text.NumberFormatter;
 import net.miginfocom.swing.MigLayout;
 
+/**
+ * This class shows all HolonElements of the selected HolonObjects.
+ */
 public class InspectorTable extends JPanel {
 
   private static final Logger log = Logger.getLogger(InspectorTable.class.getName());
@@ -132,8 +135,6 @@ public class InspectorTable extends JPanel {
     initHeaderButtons();
   }
 
-  ;
-
   private void initKeyControls() {
     this.getInputMap(WHEN_IN_FOCUSED_WINDOW)
         .put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, InputEvent.ALT_DOWN_MASK), "PageRight");
@@ -210,12 +211,10 @@ public class InspectorTable extends JPanel {
     selectAllCheckBox.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 0));
     // Pixel Perfect alignment
     selectAllCheckBox.setBorder(BorderFactory.createEmptyBorder(2, 3, 0, 0));
-    selectAllCheckBox.addActionListener(clicked -> {
-      selectAllChanges(selectAllCheckBox.getSelectionState());
-    });
+    selectAllCheckBox.addActionListener(clicked -> selectAllChanges(selectAllCheckBox.getSelectionState()));
   }
 
-  void selectAllChanges(TrippleCheckBox.State oldState) {
+  private void selectAllChanges(TrippleCheckBox.State oldState) {
     switch (oldState) {
       case mid_state_selection:
       case selected: {
@@ -401,6 +400,9 @@ public class InspectorTable extends JPanel {
     None, Descending, Ascending
   }
 
+  /**
+   * An ElementRow is a container to access an HolonElement with the right manipulation.
+   */
   private class ElementRow {
 
     private final Container[] cellsInRow = new Container[7];
@@ -436,7 +438,9 @@ public class InspectorTable extends JPanel {
             selectionBox.isSelected() ? ColorPreference.Inspector.Selected : Color.white);
       }
     }
-
+    /**
+     * Connects the ElementRow with a HolonElement.
+     */
     public void setElement(HolonElement element) {
       objectNameTextField.setText(element.parentObject.getName());
       idObjectTextField.setText(Integer.toString(element.parentObject.getId()));
@@ -448,6 +452,9 @@ public class InspectorTable extends JPanel {
       setSelected(false);
     }
 
+    /**
+     * Removes the connection to the HolonElement.
+     */
     public void clear() {
       this.element = null;
     }
@@ -551,8 +558,10 @@ public class InspectorTable extends JPanel {
 
   }
 
-  ;
-
+  /**
+   * This class handles the Sorting by tapping on the header of the InspectorTable.
+   * @param <T>
+   */
   private class SortButton<T> extends JButton {
 
     private final Comparator<T> comp;

+ 44 - 59
src/holeg/ui/view/inspector/UnitGraph.java

@@ -7,6 +7,7 @@ import holeg.model.HolonElement;
 import holeg.model.Model;
 import holeg.preferences.ColorPreference;
 import holeg.ui.controller.Control;
+import holeg.utility.listener.ResizeListener;
 import holeg.utility.math.Maths;
 import holeg.utility.math.vector.Vec2f;
 import holeg.utility.math.vector.Vec2i;
@@ -35,11 +36,8 @@ import javax.swing.JPanel;
 /**
  * This Class represents a Graph where the User can model the behavior of elements and switches over
  * time.
- *
- * @author Tom Troppmann
  */
-public class UnitGraph extends JPanel implements MouseListener, MouseMotionListener,
-    ComponentListener {
+public class UnitGraph extends JPanel implements MouseListener, MouseMotionListener{
 
   private static final Logger log = Logger.getLogger(UnitGraph.class.getName());
   // Normal Settings
@@ -77,17 +75,19 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     this.control = control;
     this.addMouseListener(this);
     this.addMouseMotionListener(this);
-    this.addComponentListener(this);
+    this.addComponentListener((ResizeListener) e -> {
+      calculateWidthHeight();
+      updateRepresentativePositions();
+      repaint();
+    });
     control.OnCanvasUpdate.addListener(this::repaint);
   }
 
-  ;
-
   /**
    * When the UnitGraph should represent a new GraphEditable Element. Its Updates the Graph and give
    * access to the Element.
    *
-   * @param element
+   * @param element a series
    */
   public void addNewSeries(TimelineDependent element) {
     Series series = new Series();
@@ -100,6 +100,9 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     repaint();
   }
 
+  /**
+   * Removes all series from the graph.
+   */
   public void clearSeries() {
     seriesList.clear();
     repaint();
@@ -387,7 +390,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 		if (series.points.size() <= 1) {
 			return;
 		}
-    LinkedList<Vec2i> cornerPoints = new LinkedList<Vec2i>();
+    LinkedList<Vec2i> cornerPoints = new LinkedList<>();
     ListIterator<UnitGraphPoint> iter = series.points.listIterator();
     Vec2i actual = series.points.getFirst().displayedPosition;
     Path2D.Double path = new Path2D.Double();
@@ -418,8 +421,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
    * @param g to draw.
    */
   private void drawBoolGraphInEditMode(Graphics2D g, Series series) {
-    LinkedList<Vec2i> before = new LinkedList<Vec2i>();
-    LinkedList<Vec2i> after = new LinkedList<Vec2i>();
+    LinkedList<Vec2i> before = new LinkedList<>();
+    LinkedList<Vec2i> after = new LinkedList<>();
     for (UnitGraphPoint p : series.points) {
 			if (p.displayedPosition.getX() < editPosition.getX()) {
 				before.add(p.displayedPosition);
@@ -432,7 +435,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     g.setColor(series.color);
     drawBoolGraphFromList(g, after);
     // EditGraph
-    LinkedList<Vec2i> middle = new LinkedList<Vec2i>();
+    LinkedList<Vec2i> middle = new LinkedList<>();
 		if (!before.isEmpty()) {
 			middle.add(before.getLast());
 		}
@@ -458,7 +461,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     // ColorHint
     g.setColor(Color.RED);
     // Threshhold Line
-    final float dash1[] = {10.0f};
+    final float[] dash1 = {10.0f};
     final BasicStroke dashed = new BasicStroke(2.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER,
         10.0f, dash1,
         0.0f);
@@ -483,7 +486,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 			return;
 		}
     ListIterator<Vec2i> iter = list.listIterator();
-    LinkedList<Vec2i> cornerPoints = new LinkedList<Vec2i>();
+    LinkedList<Vec2i> cornerPoints = new LinkedList<>();
     Vec2i actual = list.getFirst();
     Path2D.Double path = new Path2D.Double();
     path.moveTo(actual.getX(), actual.getY());
@@ -533,8 +536,8 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
    * @param g to draw.
    */
   private void drawDoubleGraphInEditMode(Graphics2D g, Series series) {
-    LinkedList<Vec2i> before = new LinkedList<Vec2i>();
-    LinkedList<Vec2i> after = new LinkedList<Vec2i>();
+    LinkedList<Vec2i> before = new LinkedList<>();
+    LinkedList<Vec2i> after = new LinkedList<>();
     for (UnitGraphPoint p : series.points) {
 			if (p.displayedPosition.getX() < editPosition.getX()) {
 				before.add(p.displayedPosition);
@@ -545,7 +548,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     drawUnitGraphFromList(g, before);
     drawUnitGraphFromList(g, after);
     // EditGraph
-    LinkedList<Vec2i> middle = new LinkedList<Vec2i>();
+    LinkedList<Vec2i> middle = new LinkedList<>();
 		if (!before.isEmpty()) {
 			middle.add(before.getLast());
 		}
@@ -647,7 +650,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
    * Remove a UnitGraphPoint from the UnitGraphPoint list ({@link #seriesList} when its near a given
    * Position.
    *
-   * @param mPosition
+   * @param mPosition the position
    */
   private void removePointNearPosition(Series series, Vec2i mPosition) {
     ListIterator<UnitGraphPoint> iter = series.points.listIterator();
@@ -743,35 +746,25 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
    * For Switches the Point have to be Snap to the Top or the Bottem.
    *
    * @param p the Position
-   * @return the updated Position.
    */
-  private Vec2i snapBoolean(Vec2i p) {
+  private void snapBoolean(Vec2i p) {
     if (p.getY() < border + heightWithBorder / 2) {
       p.setY(border);
     } else {
       p.setY(border + heightWithBorder);
     }
-    return p;
   }
 
   /**
    * The First Point has to be at 0(LeftSide) and Last Point has to be at 1(RightSide).
    *
    * @param p the Position
-   * @return the updated Position.
    */
-  private Vec2i attachToBorder(Vec2i p, EditPointType editPointType) {
+  private void attachToBorder(Vec2i p, EditPointType editPointType) {
     switch (editPointType) {
-      case StartPoint:
-        p.setX(border);
-        break;
-      case EndPoint:
-        p.setX(border + widthWithBorder);
-        break;
-      default:
-        break;
+      case StartPoint -> p.setX(border);
+      case EndPoint -> p.setX(border + widthWithBorder);
     }
-    return p;
   }
 
   /**
@@ -889,30 +882,6 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     repaint();
   }
 
-  /**
-   * When the Component is Resized.
-   *
-   * @param e ComponentEvent
-   */
-  public void componentResized(ComponentEvent e) {
-    calculateWidthHeight();
-    updateRepresentativePositions();
-    repaint();
-  }
-
-  @Override
-  public void componentHidden(ComponentEvent e) {
-  }
-
-  @Override
-  public void componentMoved(ComponentEvent e) {
-
-  }
-
-  @Override
-  public void componentShown(ComponentEvent e) {
-  }
-
   /**
    * Resets the graph to normal.
    */
@@ -924,21 +893,37 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
     repaint();
   }
 
+  /**
+   * set the local period of all selected series elements.
+   * @param period the period
+   */
   public void setPeriod(LocalMode.Period period) {
     for (Series series : seriesList) {
       series.element.setPeriod(new LocalMode.Period(period));
     }
   }
 
+  /**
+   * Check if selected series are different from another.
+   * @return true or false
+   */
   public boolean isLocalPeriedDifferentInSeries() {
     return seriesList.stream().map(series -> series.element.getPeriod().getInterval()).distinct()
         .count() > 1;
   }
 
+  /**
+   * Returns the local period of the first series
+   * @return the first series local period
+   */
   public int getFirstLocalPeriod() {
     return seriesList.isEmpty() ? 0 : seriesList.get(0).element.getPeriod().getInterval();
   }
 
+  /**
+   * Check if using the local period of the series.
+   * @return true or false
+   */
   public boolean isUsingLocalPeriod() {
     return seriesList.stream().anyMatch(
         series -> series.element.getPeriod().getType() != LocalMode.Period.PeriodType.Global);
@@ -951,7 +936,7 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
   // Intern Variables
   private static class Series {
 
-    public LinkedList<UnitGraphPoint> points = new LinkedList<UnitGraphPoint>();
+    public LinkedList<UnitGraphPoint> points = new LinkedList<>();
     public TimelineDependent element;
     public GraphType type;
     public Color color;
@@ -959,10 +944,10 @@ public class UnitGraph extends JPanel implements MouseListener, MouseMotionListe
 
   private static class GlobalCurve {
 
-    public LinkedList<UnitGraphPoint> points = new LinkedList<UnitGraphPoint>();
+    public LinkedList<UnitGraphPoint> points = new LinkedList<>();
     public float minEnergy;
     public float maxEnergy;
-    public LinkedList<UnitGraphPoint> zeroLinePoints = new LinkedList<UnitGraphPoint>();
+    public LinkedList<UnitGraphPoint> zeroLinePoints = new LinkedList<>();
   }
 
 }

+ 6 - 2
src/holeg/ui/view/inspector/UnitGraphPoint.java

@@ -5,8 +5,6 @@ import holeg.utility.math.vector.Vec2i;
 
 /**
  * A class for saving all points of a Object with a editable state. e.g HolonElement, HolonSwitch
- *
- * @author Tom Troppmann
  */
 public class UnitGraphPoint {
 
@@ -50,6 +48,12 @@ public class UnitGraphPoint {
     this.changed = false;
   }
 
+  /**
+   * Calculate the corresponding position in pixels [0,width] from the relative position [0.0,1.0].
+   * @param border the border size
+   * @param widthWithBorder the width
+   * @param heightWithBorder the height
+   */
   public void calcDisplayedPosition(int border, int widthWithBorder, int heightWithBorder) {
     //Relativ to Border
     //1-p.y because its on the Top

+ 3 - 1
src/holeg/ui/view/main/Appearance.java

@@ -3,8 +3,10 @@ package holeg.ui.view.main;
 import holeg.preferences.PreferenceKeys;
 import java.util.prefs.Preferences;
 
+/**
+ * Class for storing the appearance flags chosen by the user.
+ */
 public class Appearance {
-
   private static final Preferences prefs = Preferences.userNodeForPackage(Appearance.class);
   public static boolean supplyBarVisible = true;
   public static boolean edgeCapacityVisible = true;

+ 15 - 7
src/holeg/ui/view/main/Gui.java

@@ -9,7 +9,6 @@ import holeg.ui.model.GuiSettings;
 import holeg.ui.view.canvas.Canvas;
 import holeg.ui.view.canvas.CanvasCollectionPanel;
 import holeg.ui.view.category.CategoryPanel;
-import holeg.ui.view.dialog.AboutUsPopUp;
 import holeg.ui.view.dialog.CanvasResizePopUp;
 import holeg.ui.view.dialog.EditEdgesPopUp;
 import holeg.ui.view.image.Import;
@@ -47,8 +46,10 @@ import javax.swing.KeyStroke;
 import javax.swing.filechooser.FileNameExtensionFilter;
 import javax.swing.filechooser.FileSystemView;
 
+/**
+ * The main frame of this program.
+ */
 public class Gui extends JFrame {
-
   private static final Logger log = Logger.getLogger(Model.class.getName());
   private static final Preferences prefs = Preferences.userNodeForPackage(Gui.class);
   public final CanvasCollectionPanel canvasCollection;
@@ -74,6 +75,9 @@ public class Gui extends JFrame {
     init();
   }
 
+  /**
+   * Initialize the gui.
+   */
   private void init() {
     initFrame();
     initLayout();
@@ -108,7 +112,6 @@ public class Gui extends JFrame {
 
   private void initLayout() {
     this.setJMenuBar(new GuiMenuBar());
-
     final JSplitPane categorySplit = new JSplitPane();
     final JSplitPane canvasSplit = new JSplitPane();
     final JSplitPane elementSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
@@ -146,6 +149,9 @@ public class Gui extends JFrame {
   }
 
 
+  /**
+   * This class handles all Menu of the gui.
+   */
   private class GuiMenuBar extends JMenuBar {
 
     private final static int IconSize = 15;
@@ -183,7 +189,6 @@ public class Gui extends JFrame {
     private final JMenuItem userManualButton = new JMenuItem("User Manual");
     private final JMenuItem algorithmHelpButton = new JMenuItem("Algorithm Introduction");
     private final JMenuItem codeDocumentationButton = new JMenuItem("Code Documentation");
-    private final JMenuItem aboutUsButton = new JMenuItem("About Us");
     //ViewMenu
     private final JMenu appearanceMenu = new JMenu("Appearance");
     private final JMenuItem canvasSizeButton = new JMenuItem("Set View Size");
@@ -260,7 +265,6 @@ public class Gui extends JFrame {
       helpMenu.add(userManualButton);
       helpMenu.add(algorithmHelpButton);
       helpMenu.add(codeDocumentationButton);
-      helpMenu.add(aboutUsButton);
 
       viewMenu.add(appearanceMenu);
       appearanceMenu.add(showSupplyBarsCheckBox);
@@ -342,7 +346,6 @@ public class Gui extends JFrame {
           clicked -> openWebpage(tkWikiWebpage + "Algorithms+V2.1"));
       codeDocumentationButton.addActionListener(
           clicked -> openWebpage(tkWikiWebpage + "Code+documentation+V2.1"));
-      aboutUsButton.addActionListener(clicked -> new AboutUsPopUp(Gui.this));
     }
 
 
@@ -354,6 +357,9 @@ public class Gui extends JFrame {
       }
     }
 
+    /**
+     * Initialize all shortcuts of the program.
+     */
     private void initButtonShortCuts() {
       int defaultModifier = Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
       int defaultShiftModifier = defaultModifier + InputEvent.SHIFT_DOWN_MASK;
@@ -378,7 +384,9 @@ public class Gui extends JFrame {
       flexMenuButton.setAccelerator(KeyStroke.getKeyStroke('F', InputEvent.ALT_DOWN_MASK));
     }
 
-
+    /**
+     * Save if save file is selected else open the dialog.
+     */
     private void saveFile() {
       GuiSettings.getActualSaveFile().ifPresentOrElse(control::saveFile, this::saveNewFile);
     }

+ 3 - 19
src/holeg/ui/view/main/TimePanel.java

@@ -41,8 +41,6 @@ import javax.swing.plaf.basic.BasicSliderUI;
 /**
  * This Class represents a Panel where the User can start and stop the Simulation. He Can also reset
  * the Simulation and click through every Iteration.
- *
- * @author Gruppe14
  */
 public class TimePanel extends JPanel implements ActionListener {
 
@@ -50,7 +48,6 @@ public class TimePanel extends JPanel implements ActionListener {
   /*
    * variable for calculating the performance
    */
-  // private long performanceTime;
   final JButton playBtn = new JButton();
   final JButton timeResetBtn = new JButton();
   final JButton timeForwardBtn = new JButton();
@@ -62,7 +59,7 @@ public class TimePanel extends JPanel implements ActionListener {
   private final Timer timer;
   JTextField iterationsField;
   JLabel hint = new JLabel("Invalid", SwingConstants.RIGHT);
-  // private LabelHint iterationsLblHint;
+
   JSlider timeSlider = new JSlider() {
 
     {
@@ -230,7 +227,7 @@ public class TimePanel extends JPanel implements ActionListener {
     speedSlider.addChangeListener(new ChangeListener() {
       @Override
       public void stateChanged(ChangeEvent e) {
-        /**
+        /*
          * Shifting Powers of two: e.g. 1<<0 -> 1 step per Second 1<<3 -> 8 steps per
          * Second and so on,
          */
@@ -256,7 +253,6 @@ public class TimePanel extends JPanel implements ActionListener {
     c.gridx = 0;
     c.gridy = 0;
     iterationsPanel.add(iterationsLabel, c);
-    // iterationsLblHint=new LabelHint(iterationsLabel);
     hint.setForeground(Color.red);
     hint.setText(" ");
     iterationsField = new JTextField(6);// Considering hundreds of thousands in an extreme case
@@ -303,7 +299,6 @@ public class TimePanel extends JPanel implements ActionListener {
     // Left arrow Key
     timeSlider.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, false), "LEFT_ARROW");
     timeSlider.getActionMap().put("LEFT_ARROW", new AbstractAction() {
-      private static final long serialVersionUID = 1L;
 
       @Override
       public void actionPerformed(ActionEvent e) {
@@ -317,7 +312,6 @@ public class TimePanel extends JPanel implements ActionListener {
     timeSlider.getInputMap()
         .put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, false), "Right_ARROW");
     timeSlider.getActionMap().put("Right_ARROW", new AbstractAction() {
-      private static final long serialVersionUID = 1L;
 
       @Override
       public void actionPerformed(ActionEvent e) {
@@ -356,16 +350,6 @@ public class TimePanel extends JPanel implements ActionListener {
     }
   }
 
-
-  /**
-   * Returns the TimeSlider.
-   *
-   * @return the TimeSlider
-   */
-  public JSlider getTimeSlider() {
-    return timeSlider;
-  }
-
   @Override
   public void actionPerformed(ActionEvent arg0) {
     updateIterationsInput();
@@ -399,7 +383,7 @@ public class TimePanel extends JPanel implements ActionListener {
           (int) Math.ceil(((double) iterations) / 100));// Even though the final mark
       // can't actually be
       // reached.
-    } catch (NumberFormatException e) {
+    } catch (NumberFormatException ignored) {
     }
   }
 }

+ 25 - 28
src/holeg/ui/view/window/AddOnWindow.java

@@ -28,11 +28,13 @@ import javax.swing.text.StyleConstants;
 import javax.tools.JavaCompiler;
 import javax.tools.ToolProvider;
 
+/**
+ * This window is for the loading of additional add-ons like algorithm or randomizer.
+ */
 public class AddOnWindow extends JFrame {
 
-  private AddOn actual;
-  private Control control;
-  private JPanel content = new JPanel();
+  private final Control control;
+  private final JPanel content = new JPanel();
 
   public AddOnWindow(JFrame parentFrame, Control control) {
     this.control = control;
@@ -122,37 +124,36 @@ public class AddOnWindow extends JFrame {
 
   /**
    * Compile and load a java File.
-   *
-   * @param javafile
+   * @param javaFile file
    */
 
-  private void loadAlgorithm(File javafile) {
+  private void loadAlgorithm(File javaFile) {
     //Get Class name:
-    String name = getNameWithoutExtension(javafile);
+    String name = getNameWithoutExtension(javaFile);
     //get Package name
     String packageName = "";
     Scanner in = null;
     try {
-      in = new Scanner(javafile);
+      in = new Scanner(javaFile);
+      while (in.hasNext()) {
+        String line = in.nextLine().trim();
+        if (line.startsWith("package")) {
+          packageName = line.substring(8, line.length() - 1);
+          break;
+        }
+      }
     } 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();
+    //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 {
-      compiler.run(null, null, null, javafile.getAbsolutePath());
+      compiler.run(null, null, null, javaFile.getAbsolutePath());
     }
     try {
       URLClassLoader classLoader = URLClassLoader.newInstance(new URL[]{folder.toURI().toURL()});
@@ -160,9 +161,8 @@ public class AddOnWindow extends JFrame {
           classLoader);
       Object object = cls.getDeclaredConstructor().newInstance();
       if (object instanceof AddOn addon) {
-        actual = addon;
-        actual.setController(control);
-        this.setContentPane(actual.getPanel());
+        addon.setController(control);
+        this.setContentPane(addon.getPanel());
         this.pack();
       } else {
         generateErrorDialog("Class does not implement CpsAlgorithm!");
@@ -183,9 +183,8 @@ public class AddOnWindow extends JFrame {
 
   /**
    * Returns the Name of a file without Extension.
-   *
-   * @param file
-   * @return
+   * @param file the file
+   * @return filename without extension like ".java"
    */
   private String getNameWithoutExtension(File file) {
     return file.getName().substring(0, file.getName().lastIndexOf("."));
@@ -193,12 +192,10 @@ public class AddOnWindow extends JFrame {
 
   /**
    * Generate a little Error Dialog to inform the User.
-   *
-   * @param message
+   * @param message error message
    */
   private void generateErrorDialog(String message) {
-    System.out.println(message);
-    JOptionPane.showConfirmDialog(this, message, "Error", JOptionPane.OK_OPTION,
+    JOptionPane.showConfirmDialog(this, message, "Error", JOptionPane.YES_NO_OPTION,
         JOptionPane.ERROR_MESSAGE);
   }
 }

+ 34 - 12
src/holeg/ui/view/window/FlexWindow.java

@@ -60,7 +60,9 @@ import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreePath;
 
-
+/**
+ * An overview for flexibilities in holeg, with basic manipulation of flexibilities.
+ */
 public class FlexWindow extends JFrame {
 
   private final static int boxSideLength = 70;
@@ -84,6 +86,11 @@ public class FlexWindow extends JFrame {
   private DefaultTreeModel treeModel;
   Runnable update = this::update;
 
+  /**
+   * Construct the window.
+   * @param parentFrame parent
+   * @param control control
+   */
   public FlexWindow(JFrame parentFrame, Control control) {
     this.intermediateFlex.name = "name";
     this.control = control;
@@ -96,7 +103,10 @@ public class FlexWindow extends JFrame {
     control.OnCanvasUpdate.addListener(update);
   }
 
-
+  /**
+   * Init panel
+   * @param parentFrame parent
+   */
   private void initWindowPanel(JFrame parentFrame) {
     this.setBounds(0, 0, 400,
         parentFrame.getHeight() > 20 ? parentFrame.getHeight() - 20 : parentFrame.getHeight());
@@ -116,6 +126,9 @@ public class FlexWindow extends JFrame {
 
   }
 
+  /**
+   * Creates the menu bar of this frame.
+   */
   private void createMenuBar() {
     JMenuBar menuBar = new JMenuBar();
     JMenu canvas = new JMenu("Canvas");
@@ -209,7 +222,7 @@ public class FlexWindow extends JFrame {
         flex.order();
         control.calculateStateForCurrentIteration();
       });
-      labelButton.setToolTipText(createToolTip(flex));
+      labelButton.setToolTipText(createToolTipText(flex));
       i++;
     }
     //AddSpacer
@@ -225,7 +238,12 @@ public class FlexWindow extends JFrame {
   }
 
 
-  private String createToolTip(Flexibility actual) {
+  /**
+   * Create a tooltip text for a flexibility.
+   * @param actual flexibility
+   * @return description
+   */
+  private String createToolTipText(Flexibility actual) {
     return "<html>" +
         "<b>" + actual.name + "( </b>" + actual.getElement().getName() + "<b> )</b><br>"
         + ((actual.remainingDuration() != 0) ? "<i>Remaining Duration:" + actual.remainingDuration()
@@ -242,7 +260,10 @@ public class FlexWindow extends JFrame {
   }
 
 
-  public void update() {
+  /**
+   * Updates the panel
+   */
+  private void update() {
     updateSelectedPanel();
     createUsageViewPanel();
     contentPanel.setComponentAt(contentPanel.indexOfTab(orderTabString), usageViewPanel);
@@ -332,7 +353,7 @@ public class FlexWindow extends JFrame {
     nothingSelectedPanel.add(Box.createVerticalGlue());
   }
 
-  public void updateSelectedPanel() {
+  private void updateSelectedPanel() {
     //Should not remove add so many Components
 
     listOfAllSelectedHolonObjects.removeAllChildren();
@@ -358,12 +379,14 @@ public class FlexWindow extends JFrame {
     this.revalidate();
   }
 
-
+  /**
+   * Helper function to expand the branches of a JTree.
+   * @param tree the JTree
+   */
   private void expandAll(JTree tree) {
     for (int i = 0; i < tree.getRowCount(); i++) {
       tree.expandRow(i);
     }
-
   }
 
 
@@ -636,15 +659,14 @@ public class FlexWindow extends JFrame {
     addDialog.setVisible(true);
   }
 
-
+  /**
+   * Wrapper class for a Element
+   */
   static class ElementInfo {
-
     HolonElement ele;
-
     public ElementInfo(HolonElement ele) {
       this.ele = ele;
     }
-
     @Override
     public String toString() {
       return ele.getName() + " Priority:" + ele.getPriority();

+ 44 - 8
src/holeg/ui/view/window/Outliner.java

@@ -23,6 +23,9 @@ import javax.swing.JTree;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeCellRenderer;
 
+/**
+ * This is a class to get an overview over each HolonObject on the canvas.
+ */
 public class Outliner extends JFrame {
 
   private static final Logger log = Logger.getLogger(Outliner.class.getName());
@@ -44,10 +47,9 @@ public class Outliner extends JFrame {
   private static final String NoEnergyNodeText = getColoredHtmlText(
       ColorPreference.HolonObject.NoEnergy, "No energy");
   private final Control control;
-  JTabbedPane tabbedPane = new JTabbedPane();
-  JPanel hierarchyPanel = new JPanel(new BorderLayout());
-  JPanel holonPanel = new JPanel(new BorderLayout());
-  Runnable update = this::update;
+  private final JPanel hierarchyPanel = new JPanel(new BorderLayout());
+  private final JPanel holonPanel = new JPanel(new BorderLayout());
+  private final Runnable update = this::update;
 
   public Outliner(JFrame parentFrame, Control control) {
     setBounds(0, 0, 400, parentFrame.getHeight());
@@ -57,6 +59,7 @@ public class Outliner extends JFrame {
     this.setVisible(true);
     this.control = control;
     update();
+    JTabbedPane tabbedPane = new JTabbedPane();
     this.getContentPane().add(tabbedPane);
     this.addWindowListener(
         (WindowClosingListener) e -> control.OnCanvasUpdate.removeListener(update));
@@ -65,13 +68,22 @@ public class Outliner extends JFrame {
     tabbedPane.addTab("Holons", holonPanel);
   }
 
+  /**
+   * Pads a text with a color html.
+   * @param color a color
+   * @param text a text
+   * @return the padded text
+   */
   private static String getColoredHtmlText(Color color, String text) {
     return "<html><font bgcolor='#"
         + Integer.toHexString(color.getRGB()).substring(2) + "'>" +
         text + FontClosingBracket;
   }
 
-  public void update() {
+  /**
+   * Updates the outliner after changes to represent the new changes.
+   */
+  private void update() {
     hierarchyPanel.removeAll();
     holonPanel.removeAll();
     DefaultMutableTreeNode topListPanel = new DefaultMutableTreeNode();
@@ -106,6 +118,10 @@ public class Outliner extends JFrame {
     hierarchyPanel.repaint();
   }
 
+  /**
+   * Init of the HolonNode
+   * @return the HolonNode
+   */
   private DefaultMutableTreeNode createHolonNode() {
     DefaultMutableTreeNode topHolonNode = new DefaultMutableTreeNode();
     for (Holon holon : control.getModel().holons) {
@@ -135,7 +151,10 @@ public class Outliner extends JFrame {
     }
     return topHolonNode;
   }
-
+  /**
+   * Init of the HierarchyNode
+   * @return the HierarchyNode
+   */
   private DefaultMutableTreeNode createHierarchyNode() {
     DefaultMutableTreeNode hierarchyNode = new DefaultMutableTreeNode();
     hierarchyNode.add(getNodeFromGroupNode(control.getModel().getCanvas()));
@@ -147,6 +166,11 @@ public class Outliner extends JFrame {
     return hierarchyNode;
   }
 
+  /**
+   * Constructs a node from a groupNode.
+   * @param groupNode the groupNode
+   * @return a tree node
+   */
   private DefaultMutableTreeNode getNodeFromGroupNode(GroupNode groupNode) {
     DefaultMutableTreeNode node = new DefaultMutableTreeNode(groupNode.getName());
     groupNode.getHolonObjects().forEach(obj -> node.add(canvasObjectToNode(obj)));
@@ -155,12 +179,19 @@ public class Outliner extends JFrame {
     groupNode.getGroupNodes().forEach(obj -> node.add(getNodeFromGroupNode(obj)));
     return node;
   }
-
+  /**
+   * Constructs a node from a canvas object.
+   * @param obj a canvas object
+   * @return a tree node
+   */
   private DefaultMutableTreeNode canvasObjectToNode(AbstractCanvasObject obj) {
     return new DefaultMutableTreeNode(obj.getName() + " [" + obj.getId() + "]");
   }
 
-
+  /**
+   * Updates the appearance of a JTree.
+   * @param t a JTree
+   */
   private void signIconsForTree(JTree t) {
     ImageIcon ClosedIcon = new ImageIcon(
         Import.loadImage(ImagePreference.Button.Outliner.Closed, 9, 9));
@@ -176,6 +207,11 @@ public class Outliner extends JFrame {
   }
 
 
+  /**
+   * Create a colored node from a HolonObject.
+   * @param obj a holonObject
+   * @return the colored node
+   */
   private DefaultMutableTreeNode createColoredTreeNodeFromHolonObject(HolonObject obj) {
     float energy = obj.getActualEnergy();
     String context = "<html>" + obj.getName() + "&nbsp;&nbsp;&nbsp;&nbsp;"

+ 20 - 6
src/holeg/utility/events/Action.java

@@ -4,19 +4,33 @@ import java.util.HashSet;
 import java.util.Set;
 import java.util.function.Consumer;
 
+/**
+ * An Action is a parametrized event. Classes can assign functions to this action. When the event should occur it can be broadcast to all listener.
+ * @param <T>
+ */
 public class Action<T> {
-
+  /**
+   * Holds all lambdas that will trigger when the event is broadcast.
+   */
   private final Set<Consumer<T>> listeners = new HashSet<Consumer<T>>();
-
+  /**
+   * Adds an event listener. Normally a lambda function.
+   * @param listener the action that is triggered
+   */
   public void addListener(Consumer<T> listener) {
     listeners.add(listener);
   }
-
+  /**
+   * Broadcast the action.
+   */
   public void removeListener(Consumer<T> listener) {
     listeners.remove(listener);
   }
-
-  public void broadcast(T argument) {
-    listeners.forEach(x -> x.accept(argument));
+  /**
+   * Removes an event listener.
+   * @param listener the action that is triggered
+   */
+  public void broadcast(T listener) {
+    listeners.forEach(x -> x.accept(listener));
   }
 }

+ 17 - 1
src/holeg/utility/events/Event.java

@@ -3,18 +3,34 @@ package holeg.utility.events;
 import java.util.HashSet;
 import java.util.Set;
 
+/**
+ * This class represents an event that classes can assign functions to. When the event should occur it can be broadcast to all listener.
+ */
 public class Event {
 
+  /**
+   * Holds all lambdas that will trigger when the event is broadcast.
+   */
   private final Set<Runnable> listeners = new HashSet<Runnable>();
 
+  /**
+   * Adds an event listener. Normally a lambda function.
+   * @param listener the action that is triggered
+   */
   public void addListener(Runnable listener) {
     listeners.add(listener);
   }
 
+  /**
+   * Broadcast the event.
+   */
   public void broadcast() {
     listeners.forEach(Runnable::run);
   }
-
+  /**
+   * Removes an event listener.
+   * @param listener the action that is triggered
+   */
   public void removeListener(Runnable listener) {
     listeners.remove(listener);
   }

+ 3 - 0
src/holeg/utility/listener/LostFocusListener.java

@@ -3,6 +3,9 @@ package holeg.utility.listener;
 import java.awt.event.FocusEvent;
 import java.awt.event.FocusListener;
 
+/**
+ * A functional interface to streamline lost focus events.
+ */
 @FunctionalInterface
 public interface LostFocusListener extends FocusListener {
 

+ 3 - 1
src/holeg/utility/listener/ResizeListener.java

@@ -2,7 +2,9 @@ package holeg.utility.listener;
 
 import java.awt.event.ComponentEvent;
 import java.awt.event.ComponentListener;
-
+/**
+ * A functional interface to streamline resize events.
+ */
 @FunctionalInterface
 public interface ResizeListener extends ComponentListener {
 

+ 3 - 1
src/holeg/utility/listener/SimpleDocumentListener.java

@@ -2,7 +2,9 @@ package holeg.utility.listener;
 
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
-
+/**
+ * A functional interface to streamline document change events.
+ */
 @FunctionalInterface
 public interface SimpleDocumentListener extends DocumentListener {
 

+ 3 - 0
src/holeg/utility/listener/WindowClosingListener.java

@@ -3,6 +3,9 @@ package holeg.utility.listener;
 import java.awt.event.WindowEvent;
 import java.awt.event.WindowListener;
 
+/**
+ * A functional interface to streamline window closing events.
+ */
 @FunctionalInterface
 public interface WindowClosingListener extends WindowListener {
 

+ 22 - 3
src/holeg/utility/math/decimal/Format.java

@@ -5,12 +5,16 @@ import java.text.DecimalFormat;
 import java.text.NumberFormat;
 import java.util.Locale;
 
+/**
+ * A class with format shortcuts for common formats.
+ */
 public class Format {
 
-  private static DecimalFormat formatter;
-  private static DecimalFormat twoFormatter;
+  private static final DecimalFormat formatter;
+  private static final DecimalFormat twoFormatter;
 
   static {
+    // Initializes the formatters statically
     NumberFormat nf = NumberFormat.getNumberInstance(Locale.US);
     formatter = (DecimalFormat) nf;
     formatter.applyPattern("#.###########");
@@ -21,14 +25,29 @@ public class Format {
     twoFormatter.setRoundingMode(RoundingMode.UP);
   }
 
+  /**
+   * Format a double with variable amount of places.
+   * @param places the amount of decimals after the '.' - separator
+   * @param value the value to format
+   * @return the formatted string
+   */
   public static String doubleFixedPlaces(int places, double value) {
     return String.format(Locale.US, "%." + places + "f", value);
   }
 
+  /**
+   * Format a double value with two decimals after the '.' - separator.
+   * @param value the value to format
+   * @return the formatted string
+   */
   public static String doubleTwoPlaces(double value) {
     return twoFormatter.format(value);
   }
-
+  /**
+   * Format a double value with ten decimals after the '.' - separator.
+   * @param value the value to format
+   * @return the formatted string
+   */
   public static String doubleAllPlaces(double value) {
     return formatter.format(value);
   }

+ 31 - 7
src/holeg/utility/math/decimal/Sampler.java

@@ -3,11 +3,22 @@ package holeg.utility.math.decimal;
 import java.util.HashMap;
 import java.util.stream.Collectors;
 
-//To sample floats and get basic statistical values;
+/**
+ * To sample floats and get basic statistical values.
+ */
+
 public class Sampler {
 
+  /**
+   * A map containing all samples.
+   */
   public HashMap<String, SampleInfo> logMap = new HashMap<String, SampleInfo>();
 
+  /**
+   * Add a sample by a string key.
+   * @param parameterName a key
+   * @param sample a sample
+   */
   public void addSample(String parameterName, float sample) {
     //Puts the sample in the right LogInfo container or create a new container if not exist jet
     if (logMap.containsKey(parameterName)) {
@@ -21,22 +32,31 @@ public class Sampler {
     }
   }
 
-  public String toString() {
-    return logMap.values().stream().map(Object::toString).collect(Collectors.joining("\n"));
-  }
-
+  /**
+   * Clears the sample map.
+   */
   public void clear() {
     logMap.clear();
   }
 
-  public class SampleInfo {
+  public String toString() {
+    return logMap.values().stream().map(Object::toString).collect(Collectors.joining("\n"));
+  }
 
+  /**
+   * A class to store all sample of a key.
+   */
+  public static class SampleInfo {
     public String parameterName;
     public int sampleSize = 0;
     public float min = Float.MAX_VALUE;
     public float max = Float.MIN_VALUE;
     private float sum = 0;
 
+    /**
+     * Returns the average of all floats.
+     * @return the average
+     */
     public float getAvg() {
       if (sampleSize > 0) {
         return sum / (float) sampleSize;
@@ -44,6 +64,10 @@ public class Sampler {
       return 0;
     }
 
+    /**
+     * Stores a sample in the struct.
+     * @param sample a sample
+     */
     public void addSample(float sample) {
       if (sample < min) {
         min = sample;
@@ -57,7 +81,7 @@ public class Sampler {
 
     public String toString() {
       return "[" + parameterName + " in Range(" + min + ", " + max + ") with a Average of "
-          + getAvg() + " from " + sampleSize + " Smaples]";
+          + getAvg() + " from " + sampleSize + " Samples]";
     }
   }
 }

+ 56 - 5
src/holeg/utility/math/vector/Geometry.java

@@ -6,8 +6,19 @@ import holeg.utility.math.Maths;
 import java.awt.Rectangle;
 import java.util.Optional;
 
+/**
+ * A helper class for geometric shapes and operations.
+ */
 public class Geometry {
 
+  /**
+   * Construct a Rectangle with only the points from two corners.
+   * The Rectangle is axis aligned.
+   * The ordering of the corner is irrelevant.
+   * @param corner a corner of the Rectangle
+   * @param otherCorner another corner of the Rectangle
+   * @return the corresponding rectangle
+   */
   public static Rectangle createRectangleFromCorners(Vec2i corner, Vec2i otherCorner) {
     //Calculate left top corner, width, height
     Vec2i topLeft = new Vec2i(Math.min(corner.getX(), otherCorner.getX()),
@@ -19,10 +30,16 @@ public class Geometry {
     return new Rectangle(topLeft.getX(), topLeft.getY(), width, height);
   }
 
+  /**
+   * If the line Intersect the circle the projection is returned.
+   * @param line the 2d line
+   * @param circle the 2d circle
+   * @return the projection
+   */
   public static Optional<Vec2f> getProjectionOnSegmentIfInRange(Line line, Circle circle) {
-    float lineLengthSqr = line.distanceSqr();
+    float lineLengthSqr = line.lengthSqr();
     if (lineLengthSqr < EPSILON) {
-      if (line.p1.getSquaredDistance(circle.position) < circle.radius * circle.radius) {
+      if (line.p1.getDistanceSqr(circle.position) < circle.radius * circle.radius) {
         return Optional.of(new Vec2f(line.p1));
       } else {
         return Optional.empty();
@@ -32,36 +49,70 @@ public class Geometry {
     float t = Maths.clamp(Vec2f.dot(circle.position.subtract(line.p1), p2p1) / lineLengthSqr, 0.0f,
         1.0f);
     Vec2f projection = line.p1.add(p2p1.multiply(t));
-    if (projection.getSquaredDistance(circle.position) < circle.radius * circle.radius) {
+    if (projection.getDistanceSqr(circle.position) < circle.radius * circle.radius) {
       return Optional.of(projection);
     } else {
       return Optional.empty();
     }
   }
 
+  /**
+   * A simple representation of a 2d circle via a center point and a radius.
+   */
   public static class Circle {
 
+    /**
+     * The center of the circle.
+     */
     public Vec2f position;
+    /**
+     * The radius of the circle.
+     */
     public float radius;
 
+    /**
+     * Construct the circle with a center point and a radius.
+     * @param position center of the circle
+     * @param radius radius of the circle
+     */
     public Circle(Vec2f position, float radius) {
       this.position = position;
       this.radius = radius;
     }
   }
 
+  /**
+   * A simple representation of a 2D-line via two points.
+   */
   public static class Line {
 
+    /**
+     * First point
+     */
     Vec2f p1;
+    /**
+     * Second Point
+     */
     Vec2f p2;
 
+    /**
+     * Construct a line via two points.
+     *
+     * @param p1 first point
+     * @param p2 second point
+     */
     public Line(Vec2f p1, Vec2f p2) {
       this.p1 = p1;
       this.p2 = p2;
     }
 
-    float distanceSqr() {
-      return p1.getSquaredDistance(p2);
+    /**
+     * Returns the squared length of the line.
+     *
+     * @return the squared length of the line
+     */
+    float lengthSqr() {
+      return p1.getDistanceSqr(p2);
     }
   }
 }

+ 2 - 2
src/holeg/utility/math/vector/Vec2f.java

@@ -120,7 +120,7 @@ public class Vec2f {
    * @return distance to the vector.
    */
   public float getDistance(Vec2f other) {
-    return (float) Math.sqrt(getSquaredDistance(other));
+    return (float) Math.sqrt(getDistanceSqr(other));
   }
 
   /**
@@ -130,7 +130,7 @@ public class Vec2f {
    * @param other the other Position.
    * @return squared distance to the Position
    */
-  public float getSquaredDistance(Vec2f other) {
+  public float getDistanceSqr(Vec2f other) {
     float xDistance = other.x - x;
     float yDistance = other.x - y;
     return xDistance * xDistance + yDistance * yDistance;

+ 9 - 0
src/holeg/utility/math/vector/Vec2i.java

@@ -69,11 +69,20 @@ public class Vec2i {
     this.y = y;
   }
 
+  /**
+   * Set the entries of the vector
+   * @param x first entry
+   * @param y second entry
+   */
   public void set(int x, int y) {
     this.x = x;
     this.y = y;
   }
 
+  /**
+   * Copies the entries from another vector
+   * @param other another Vector
+   */
   public void set(Vec2i other) {
     x = other.x;
     y = other.y;