lv.lumii.layoutengine

## Class Diagram

- java.lang.Object
- - lv.lumii.layoutengine.Element
  - - lv.lumii.layoutengine.AbstractContainer
    - - lv.lumii.layoutengine.Container
      - - lv.lumii.layoutengine.Box
        - - lv.lumii.layoutengine.Diagram

- All Implemented Interfaces:
    Connectible

      public class Diagram
      extends Box

  This class defines the diagram element. A diagram stores a fully independent set of elements and has methods for manipulating and arranging these elements.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Diagram.State` The states diagram can be in.

    - ### Nested classes/interfaces inherited from class lv.lumii.layoutengine.Box

      `Box.BoxSide`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Diagram(org.w3c.dom.Element element, java.util.LinkedHashMap<java.lang.Integer,java.lang.Object> objectMap)` Loads a diagram from the given XML element representing one.
    `Diagram(java.awt.geom.Rectangle2D.Double rectangle, ArrangeData.ArrangeStyle arrangeStyle, LayoutConstraints.ConstraintType constraintType)` Creates a new diagram.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `arrange()` Lays out the diagram from scratch according to its current position without necessarily maintaining existing element positions.
    `void` | `endManual()` Ends manual mode, fixing the diagram if necessary.
    `void` | `endTransaction()` Performs all the work needed to effect all accumulated position changes since `startTransaction()`, then ends the current transaction.
    `java.awt.geom.Rectangle2D.Double` | `getBounds()` Returns union of the user-defined default bounds and children enclosing rectangle.
    `double` | `getRetraceDistance()` Returns the distance a box has to be moved before its lines are retraced instead of reconnected.
    `Diagram.State` | `getState()` Returns the current state of the diagram.
    `void` | `remove()` Removes the element and its descendant elements.
    `org.w3c.dom.Element` | `saveToXML(org.w3c.dom.Document doc, java.util.LinkedHashMap<java.lang.Object,java.lang.Integer> idMap)` Saves this diagram to an XML element in the given document.
    `void` | `setRetraceDistance(double distance)` Sets the distance a box has to be moved before its lines are retraced instead of reconnected.
    `void` | `startManual()` Sets the diagram to manual mode, where only line connections and rectangle nesting are maintained.
    `void` | `startTransaction()` Starts a transaction of diagram operations.

    - ### Methods inherited from class lv.lumii.layoutengine.Box

      `connectTo, connectTo, connectTo, createOutsideLabel, createOutsideLabel, getChildren, getIncidentLines, getOutsideLabels, getShape, move, move, move, move, resize, setMinHeight, setMinSize, setMinWidth, setSpacing`

    - ### Methods inherited from class lv.lumii.layoutengine.Container

      `convertToBox, convertToBox, convertToContainer, convertToContainer, createBox, createBox, createBox, createContainer, createContainer, findChildContainerEnclosingRectangle, findDescendantEnclosingRectangle, getArrangeData, getArrangeStyle, getBoxes, getContainers, getDescendantBoxes, getDescendantBoxes, getDescendantBoxOutsideLabels, getDescendantContainers, getDescendantLines, getDescendantOutsideLabels, getLines, getOwner, getPureContainers, getUsedArrangeData, getUsedArrangeStyle, setArrangeStyle`

    - ### Methods inherited from class lv.lumii.layoutengine.AbstractContainer

      `contains, createInsideLabel, createInsideLabel, createInsideLabel, findNextRectangleEnclosingRectangle, getBottom, getCenter, getCenterX, getCenterY, getHeight, getInsideLabels, getLayoutConstraints, getLeft, getMinHeight, getMinWidth, getRight, getTop, getWidth, setConstraintType`

    - ### Methods inherited from class lv.lumii.layoutengine.Element

      `getDiagram, getSpacing, remove`

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

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

- - ### Constructor Detail

    - #### Diagram

          public Diagram(java.awt.geom.Rectangle2D.Double rectangle,
                         ArrangeData.ArrangeStyle arrangeStyle,
                         LayoutConstraints.ConstraintType constraintType)

      Creates a new diagram.
      Parameters:
        `rectangle` - the bounding rectangle of the new diagram
        `arrangeStyle` - the style according to which to arrange the elements of the diagram
        `constraintType` - the type of the layout constraints for the diagram

    - #### Diagram

          public Diagram(org.w3c.dom.Element element,
                         java.util.LinkedHashMap<java.lang.Integer,java.lang.Object> objectMap)

      Loads a diagram from the given XML element representing one. Maps the objects of the resulting diagram in `objectMap`, from their IDs in the given XML.
      Parameters:
        `element` - an XML element representing a diagram.
        `objectMap` - a map from object IDs in the XML to the objects of this diagram.

  - ### Method Detail

    - #### getState

          public Diagram.State getState()

      Returns the current state of the diagram.
      Returns:
        the current state of the diagram.

    - #### getRetraceDistance

          public double getRetraceDistance()

      Returns the distance a box has to be moved before its lines are retraced instead of reconnected.
      Returns:
        the distance a box has to be moved before its lines are retraced instead of reconnected

    - #### setRetraceDistance

          public void setRetraceDistance(double distance)

      Sets the distance a box has to be moved before its lines are retraced instead of reconnected.
      Parameters:
        `distance` - the new minimum retrace distance

    - #### getBounds

          public java.awt.geom.Rectangle2D.Double getBounds()

      Returns union of the user-defined default bounds and children enclosing rectangle.
      Overrides:
        `getBounds` in class `AbstractContainer`
      Returns:
        union of the user-defined default bounds and children enclosing rectangle.

    - #### arrange

          public void arrange()

      Lays out the diagram from scratch according to its current position without necessarily maintaining existing element positions.

    - #### startTransaction

          public void startTransaction()

      Starts a transaction of diagram operations. While a transaction is active, operations are not executed immediately, they are collected and executed on `endTransaction()`, if possible. Some operations may still be performed earlier, particularly if multiple operation types are mixed in a single transaction. Transactions achieve better performance than performing operations individually. Note that changes to the diagram's element hierarchy are still immediate, only changes to their position are delayed.

    - #### endTransaction

          public void endTransaction()

      Performs all the work needed to effect all accumulated position changes since `startTransaction()`, then ends the current transaction.

    - #### startManual

          public void startManual()

      Sets the diagram to manual mode, where only line connections and rectangle nesting are maintained.

    - #### endManual

          public void endManual()

      Ends manual mode, fixing the diagram if necessary.

    - #### remove

          public void remove()

      Description copied from class: `Element`
      Removes the element and its descendant elements. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Overrides:
        `remove` in class `Box`

    - #### saveToXML

          public org.w3c.dom.Element saveToXML(org.w3c.dom.Document doc,
                                               java.util.LinkedHashMap<java.lang.Object,java.lang.Integer> idMap)

      Saves this diagram to an XML element in the given document. Maps the objects of this diagram in `idMap`, using `idMap.size()` as the ID for each new element.
      Parameters:
        `doc` - the document in which to create the element
        `idMap` - a map from the objects of this diagram to their IDs in the resulting XML.
      Returns:
        an XML element corresponding to this diagram