ui.controller

## Class Control

- java.lang.Object
- - ui.controller.Control

-     public class Control
      extends java.lang.Object

  The Class represents the controller in the model, controller view Pattern.
  Author:
    Gruppe14

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `Control(Model model)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addCategory(java.lang.String cat)` Adds New Category into Model.
    `void` | `addEdgeOnCanvas(CpsEdge edge)` Add an edge to the Canvas.
    `void` | `addElementCanvasObject(int id, java.lang.String ele, int amount, float energy)` Add a new Element into a Object on the Canvas.
    `void` | `addElementCategoryObject(java.lang.String catName, java.lang.String objName, java.lang.String eleName, int amount, float energy)` Add a new Element into a Object in Category.
    `void` | `addObject(Category cat, java.lang.String obj, java.util.ArrayList<HolonElement> ele, java.lang.String img)` Add new Holon Object to a Category.
    `void` | `addObjectCanvas(AbstractCpsObject object)` Add a new Object.
    `void` | `addSelectedObject(AbstractCpsObject obj)` add an Object to selectedObject.
    `void` | `addSwitch(Category cat, java.lang.String obj)` Add new Holon Switch to a Category.
    `void` | `addTextToConsole(java.lang.String text)` Print Text on the console in black and font size 12.
    `void` | `addTextToConsole(java.lang.String text, java.awt.Color color, int p, boolean bold, boolean italic, boolean nl)` Getter for selected CpsObject.
    `void` | `addTransformer(Category cat, java.lang.String obj)` Add new Holon Transformer to a Category.
    `void` | `autoSave()` make an autosave.
    `void` | `calculateStateForCurrentTimeStep()` calculates the flow of the edges and the supply for objects for the current Timestep.
    `void` | `calculateStateForTimeStep(int x)` calculates the flow of the edges and the supply for objects.
    `void` | `clearConsole()` Clears the console.
    `void` | `copyObjects()` Copy all Selected Objects.
    `void` | `cutObjects()` Cut all Selected Objects.
    `void` | `delCanvasObject(AbstractCpsObject obj)` Deletes an CpsObject on the Canvas and its connections.
    `void` | `deleteCategory(java.lang.String cat)` delete a given Category.
    `void` | `deleteDirectory(java.io.File path)` Delete a Directory.
    `void` | `deleteElementCanvas(HolonObject obj, HolonElement ele)` deletes a Element from a given Object.
    `void` | `deleteElementCanvas(int id, int elementid)` deletes a Element from a given Canvas Object.
    `void` | `deleteSelectedObject(AbstractCpsObject obj)` deletes a selectedObject.
    `void` | `delObjectCategory(java.lang.String cat, java.lang.String obj)` Delete an Object from a Category.
    `Model` | `getModel()` Getter for Model.
    `java.lang.String` | `getRedoSave()` Returns the redo save.
    `int` | `getScale()` Returns SCALE.
    `int` | `getScaleDiv2()` Returns SCALE Divided by 2.
    `SimulationManager` | `getSimManager()` get the Simulation Manager.
    `java.lang.String` | `getUndoSave()` Returns the undo save.
    `void` | `initListener(CategoryListener catLis)` Init the CategoryListener.
    `void` | `loadFile(java.lang.String path)` Reads the the JSON File and load the state into the Model.
    `void` | `pasteObjects(java.awt.Point point)` Paste all Selected Objects.
    `void` | `removeEdgesOnCanvas(CpsEdge edge)` Removes an Edge from the Canvas.
    `void` | `resetCategorys()` init default category and objects.
    `void` | `saveFile(java.lang.String path)` Writes the current State of the Modelling into a JSON File which can be loaded.
    `AbstractCpsObject` | `searchByID(int id)` Search for Object by ID.
    `Category` | `searchCategory(java.lang.String cat)` search for category.
    `AbstractCpsObject` | `searchCategoryObject(java.lang.String category, java.lang.String object)` Search for Object in a Category.
    `void` | `setCanvas(MyCanvas can)` Set the Canvas.
    `void` | `setClipboardObjects(java.util.ArrayList<AbstractCpsObject> list)` Sets the ClipboardObjects.
    `void` | `setCurIteration(int curit)` sets the current Iteration.
    `void` | `setIsSimulation(boolean b)` Set if its simulating or not.
    `void` | `setScale(int s)` Changes the value of SCALE and SCALEDIV2.
    `void` | `setSelectedObjectID(int id)` Returns the ID of the selected Object 0 = no Object is selected.
    `void` | `setSelecteEdge(CpsEdge edge)` Set the selected Edge.
    `void` | `setTimerSpeed(int t)` Set the timerSpeed.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Control

          public Control(Model model)

      Constructor.
      Parameters:
        `model` - the Model

  - ### Method Detail

    - #### deleteDirectory

          public void deleteDirectory(java.io.File path)

      Delete a Directory.
      Parameters:
        `path` - to delete

    - #### searchByID

          public AbstractCpsObject searchByID(int id)

      Search for Object by ID.
      Parameters:
        `id` - the id of the Object
      Returns:
        the CpsObject

    - #### searchCategoryObject

          public AbstractCpsObject searchCategoryObject(java.lang.String category,
                                                        java.lang.String object)

      Search for Object in a Category.
      Parameters:
        `category` - name of the Category
        `object` - Name of the Object
      Returns:
        The Object

    - #### searchCategory

          public Category searchCategory(java.lang.String cat)

      search for category.
      Parameters:
        `cat` - name of the Category
      Returns:
        the Category

    - #### resetCategorys

          public void resetCategorys()

      init default category and objects.

    - #### addCategory

          public void addCategory(java.lang.String cat)

      Adds New Category into Model.
      Parameters:
        `cat` - name of the new Category

    - #### addObject

          public void addObject(Category cat,
                                java.lang.String obj,
                                java.util.ArrayList<HolonElement> ele,
                                java.lang.String img)

      Add new Holon Object to a Category.
      Parameters:
        `cat` - Category
        `obj` - New Object Name
        `ele` - Array of Elements
        `img` - the image Path

    - #### addTransformer

          public void addTransformer(Category cat,
                                     java.lang.String obj)

      Add new Holon Transformer to a Category.
      Parameters:
        `cat` - Category
        `obj` - New Object Name

    - #### addSwitch

          public void addSwitch(Category cat,
                                java.lang.String obj)

      Add new Holon Switch to a Category.
      Parameters:
        `cat` - Category
        `obj` - New Object Name

    - #### deleteCategory

          public void deleteCategory(java.lang.String cat)

      delete a given Category.
      Parameters:
        `cat` - the Category

    - #### delObjectCategory

          public void delObjectCategory(java.lang.String cat,
                                        java.lang.String obj)

      Delete an Object from a Category.
      Parameters:
        `cat` - the Category
        `obj` - the Object

    - #### deleteSelectedObject

          public void deleteSelectedObject(AbstractCpsObject obj)

      deletes a selectedObject.
      Parameters:
        `obj` - Cpsobject

    - #### addSelectedObject

          public void addSelectedObject(AbstractCpsObject obj)

      add an Object to selectedObject.
      Parameters:
        `obj` - AbstractCpsobject

    - #### addEdgeOnCanvas

          public void addEdgeOnCanvas(CpsEdge edge)

      Add an edge to the Canvas.
      Parameters:
        `edge` - the edge

    - #### removeEdgesOnCanvas

          public void removeEdgesOnCanvas(CpsEdge edge)

      Removes an Edge from the Canvas.
      Parameters:
        `edge` - the edge to remove

    - #### setSelecteEdge

          public void setSelecteEdge(CpsEdge edge)

      Set the selected Edge.
      Parameters:
        `edge` - that is selected

    - #### addObjectCanvas

          public void addObjectCanvas(AbstractCpsObject object)

      Add a new Object.
      Parameters:
        `object` - the Object

    - #### setSelectedObjectID

          public void setSelectedObjectID(int id)

      Returns the ID of the selected Object 0 = no Object is selected.
      Parameters:
        `id` - the ID of the selected Object

    - #### delCanvasObject

          public void delCanvasObject(AbstractCpsObject obj)

      Deletes an CpsObject on the Canvas and its connections.
      Parameters:
        `obj` - AbstractCpsObject

    - #### addElementCanvasObject

          public void addElementCanvasObject(int id,
                                             java.lang.String ele,
                                             int amount,
                                             float energy)

      Add a new Element into a Object on the Canvas.
      Parameters:
        `id` - the Object ID
        `ele` - the Name of the Element
        `amount` - the Amount
        `energy` - the Energy

    - #### addElementCategoryObject

          public void addElementCategoryObject(java.lang.String catName,
                                               java.lang.String objName,
                                               java.lang.String eleName,
                                               int amount,
                                               float energy)

      Add a new Element into a Object in Category.
      Parameters:
        `catName` - the Category
        `objName` - the Object
        `eleName` - the Element Name
        `amount` - the amount
        `energy` - the Energy

    - #### deleteElementCanvas

          public void deleteElementCanvas(int id,
                                          int elementid)

      deletes a Element from a given Canvas Object.
      Parameters:
        `id` - the ID
        `elementid` - the Element ID

    - #### deleteElementCanvas

          public void deleteElementCanvas(HolonObject obj,
                                          HolonElement ele)

      deletes a Element from a given Object.
      Parameters:
        `obj` - the Oject
        `ele` - the Element

    - #### setClipboardObjects

          public void setClipboardObjects(java.util.ArrayList<AbstractCpsObject> list)

      Sets the ClipboardObjects.
      Parameters:
        `list` - Array of Objects

    - #### getScale

          public int getScale()

      Returns SCALE.
      Returns:
        SCALE

    - #### getScaleDiv2

          public int getScaleDiv2()

      Returns SCALE Divided by 2.
      Returns:
        SCALE Divided by 2

    - #### setScale

          public void setScale(int s)

      Changes the value of SCALE and SCALEDIV2.
      Parameters:
        `s` - Scale

    - #### setCurIteration

          public void setCurIteration(int curit)

      sets the current Iteration.
      Parameters:
        `curit` - the current Iteration

    - #### saveFile

          public void saveFile(java.lang.String path)
                        throws java.io.IOException

      Writes the current State of the Modelling into a JSON File which can be loaded.
      Parameters:
        `path` - the Path
      Throws:
        `java.io.IOException` - exception

    - #### loadFile

          public void loadFile(java.lang.String path)
                        throws java.io.IOException

      Reads the the JSON File and load the state into the Model.
      Parameters:
        `path` - the Path
      Throws:
        `java.io.IOException` - exception

    - #### initListener

          public void initListener(CategoryListener catLis)

      Init the CategoryListener.
      Parameters:
        `catLis` - the CategoryListener

    - #### calculateStateForCurrentTimeStep

          public void calculateStateForCurrentTimeStep()

      calculates the flow of the edges and the supply for objects for the current Timestep.

    - #### calculateStateForTimeStep

          public void calculateStateForTimeStep(int x)

      calculates the flow of the edges and the supply for objects.
      Parameters:
        `x` - current Iteration

    - #### setCanvas

          public void setCanvas(MyCanvas can)

      Set the Canvas.
      Parameters:
        `can` - the Canvas

    - #### autoSave

          public void autoSave()
                        throws java.io.IOException

      make an autosave.
      Throws:
        `java.io.IOException` - Exception

    - #### getUndoSave

          public java.lang.String getUndoSave()

      Returns the undo save.
      Returns:
        the undo save

    - #### getRedoSave

          public java.lang.String getRedoSave()

      Returns the redo save.
      Returns:
        the redo save

    - #### copyObjects

          public void copyObjects()

      Copy all Selected Objects.

    - #### pasteObjects

          public void pasteObjects(java.awt.Point point)

      Paste all Selected Objects.
      Parameters:
        `point` - the mouse Position

    - #### cutObjects

          public void cutObjects()

      Cut all Selected Objects.

    - #### getModel

          public Model getModel()

      Getter for Model.
      Returns:
        the Model

    - #### getSimManager

          public SimulationManager getSimManager()

      get the Simulation Manager.
      Returns:
        the Simulation Manager

    - #### addTextToConsole

          public void addTextToConsole(java.lang.String text,
                                       java.awt.Color color,
                                       int p,
                                       boolean bold,
                                       boolean italic,
                                       boolean nl)

      Getter for selected CpsObject.
      Parameters:
        `text` - String the Text
        `color` - the color of the Text
        `p` - size of the Text
        `bold` - bold or not
        `italic` - italic or not
        `nl` - new line or not

    - #### addTextToConsole

          public void addTextToConsole(java.lang.String text)

      Print Text on the console in black and font size 12.
      Parameters:
        `text` - String the Text

    - #### clearConsole

          public void clearConsole()

      Clears the console.

    - #### setTimerSpeed

          public void setTimerSpeed(int t)

      Set the timerSpeed.
      Parameters:
        `t` - interval in ms

    - #### setIsSimulation

          public void setIsSimulation(boolean b)

      Set if its simulating or not.
      Parameters:
        `b` - isSimulation