lv.lumii.layoutengine

## Class Line

- java.lang.Object
- - lv.lumii.layoutengine.Element
  - - lv.lumii.layoutengine.Line

- All Implemented Interfaces:
    Connectible

      public class Line
      extends Element
      implements Connectible

  Line connects diagram elements

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Line.LineType` Defines the line type.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `cleanup()` Cleans up this line, removing unnecessary corners.
    `Line` | `connectTo(Connectible element, Line.LineType lineType, double spacing)` Adds a line to this diagram.
    `Line` | `connectTo(Connectible element, Line.LineType lineType, double spacing, java.util.ArrayList<java.awt.geom.Point2D.Double> points)` Adds a line to this diagram going along the given points.
    `Line` | `connectTo(Connectible element, Line.LineType lineType, double spacing, java.util.ArrayList<java.awt.geom.Point2D.Double> points, boolean cleanup)` Adds a line to this diagram going along the given points.
    `OutsideLabel.LineLabel` | `createLabel(double width, double height, double position, OutsideLabel.LineLabel.Orientation orientation, LayoutConstraints.ConstraintType constraintType, double spacing)` Creates a new label for this line.
    `OutsideLabel.LineLabel` | `createLabel(double width, double height, java.awt.geom.Point2D.Double point, OutsideLabel.LineLabel.Orientation orientation, LayoutConstraints.ConstraintType constraintType, double spacing)` Creates a new label for this line.
    `Element` | `getEnd()` Returns the ending element of the line, could be a box or a line.
    `java.awt.geom.Point2D.Double` | `getEndPoint()` Returns the ending point that is on the border of the end element of this line.
    `int` | `getEndSides()` Returns the mask of the allowed end sides for this box.
    `java.util.ArrayList<Line>` | `getIncidentLines()` Returns a list of all lines incident to this element.
    `boolean` | `getIsFlowEdge()` Gets the flag whether flow layout treats this line as directed.
    `java.util.ArrayList<OutsideLabel.LineLabel>` | `getLabels()` Returns the labels of the line.
    `Container` | `getOwner()` Each element can be owned by some other element.
    `java.util.ArrayList<java.awt.geom.Point2D.Double>` | `getPoints()` Returns the points representing the geometrical form of the line.
    `double` | `getSpacing()` Returns the spacing value of the line.
    `Element` | `getStart()` Returns the starting element of the line, could be a box or a line.
    `java.awt.geom.Point2D.Double` | `getStartPoint()` Returns the starting point that is on the border of the start element of this line.
    `int` | `getStartSides()` Returns the mask of the allowed start sides for this line.
    `Line.LineType` | `getType()` Returns the geometrical type of the line.
    `void` | `remove()` Removes the element and its descendant elements.
    `void` | `remove(boolean adjust)` Removes this line.
    `void` | `resetEndSides()` Resets the end sides of this line to allow it to end at any side of the end box.
    `void` | `resetStartSides()` Resets the start sides of this line to allow it to start from any side of the start box.
    `void` | `retrace()` Retraces this line from scratch so that it connects its end elements.
    `void` | `retrace(Element newStart, Element newEnd)` Retraces this line from scratch so that it connects its new end elements.
    `void` | `retrace(Line.LineType type)` Retraces this line from scratch so that it connects its end elements.
    `void` | `retrace(Line.LineType type, Element newStart, Element newEnd)` Retraces this line from scratch so that it connects its new end elements.
    `void` | `setEndSides(Box.BoxSide[] sides)` Sets the sides of the end box this line is allowed to end at.
    `void` | `setEndSides(int sides)` Sets the sides of the end box this line is allowed to end at.
    `void` | `setIsFlowEdge(boolean directed)` Sets the flag whether flow layout treats this line as directed.
    `void` | `setPoints(java.util.ArrayList<java.awt.geom.Point2D.Double> points)` Sets the points of this line.
    `void` | `setPoints(java.util.ArrayList<java.awt.geom.Point2D.Double> points, boolean cleanup)` Sets the points of this line.
    `void` | `setPoints(java.util.ArrayList<java.awt.geom.Point2D.Double> points, Element newStart, Element newEnd)` Sets the points of this line and changes its start and end elements.
    `void` | `setPoints(java.util.ArrayList<java.awt.geom.Point2D.Double> points, Element newStart, Element newEnd, boolean cleanup)` Sets the points of this line and changes its start and end elements.
    `void` | `setSpacing(double spacing)` Sets the spacing value of the line.
    `void` | `setStartSides(Box.BoxSide[] sides)` Sets the sides of the start box this line is allowed to start from.
    `void` | `setStartSides(int sides)` Sets the sides of the start box this line is allowed to start from.
    `void` | `setType(Line.LineType type)` Changes the line geometry to the given line type, possibly taking the previous line layout into account.

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

      `getDiagram`

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

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

- - ### Method Detail

    - #### getStart

          public final Element getStart()

      Returns the starting element of the line, could be a box or a line.
      Returns:
        the starting element of the line, could be a box or a line.

    - #### getEnd

          public final Element getEnd()

      Returns the ending element of the line, could be a box or a line.
      Returns:
        the ending element of the line, could be a box or a line.

    - #### getPoints

          public java.util.ArrayList<java.awt.geom.Point2D.Double> getPoints()

      Returns the points representing the geometrical form of the line.
      Returns:
        the points representing the geometrical form of the line.

    - #### setPoints

          public void setPoints(java.util.ArrayList<java.awt.geom.Point2D.Double> points)

      Sets the points of this line. The points may be corrected to match the line type. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Parameters:
        `points` - the new points of the line, their exact meaning may vary depending on the current line type

    - #### setPoints

          public void setPoints(java.util.ArrayList<java.awt.geom.Point2D.Double> points,
                                boolean cleanup)

      Sets the points of this line. The points may be corrected to match the line type. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Parameters:
        `points` - the new points of the line, their exact meaning may vary depending on the current line type
        `cleanup` - whether to clean up the resulting line in order to minimize corner count

    - #### setPoints

          public void setPoints(java.util.ArrayList<java.awt.geom.Point2D.Double> points,
                                Element newStart,
                                Element newEnd,
                                boolean cleanup)

      Sets the points of this line and changes its start and end elements. The points may be corrected to match the line type and to connect the given elements. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Parameters:
        `points` - the new points of the line, their exact meaning may vary depending on the current line type
        `newStart` - the new start of the line
        `newEnd` - the new end of the line
        `cleanup` - whether to clean up the resulting line in order to minimize corner count

    - #### setPoints

          public void setPoints(java.util.ArrayList<java.awt.geom.Point2D.Double> points,
                                Element newStart,
                                Element newEnd)

      Sets the points of this line and changes its start and end elements. The points may be corrected to match the line type and to connect the given elements. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Parameters:
        `points` - the new points of the line, their exact meaning may vary depending on the current line type
        `newStart` - the new start of the line
        `newEnd` - the new end of the line

    - #### getStartPoint

          public java.awt.geom.Point2D.Double getStartPoint()

      Returns the starting point that is on the border of the start element of this line.
      Returns:
        the starting point that is on the border of the start element of this line.

    - #### getEndPoint

          public java.awt.geom.Point2D.Double getEndPoint()

      Returns the ending point that is on the border of the end element of this line.
      Returns:
        the ending point that is on the border of the end element of this line.

    - #### getType

          public Line.LineType getType()

      Returns the geometrical type of the line.
      Returns:
        the geometrical type of the line.

    - #### setType

          public void setType(Line.LineType type)

      Changes the line geometry to the given line type, possibly taking the previous line layout into account.
      Parameters:
        `type` - the line type to change the line to

    - #### getSpacing

          public double getSpacing()

      Returns the spacing value of the line.
      Overrides:
        `getSpacing` in class `Element`
      Returns:
        the spacing value of the line.

    - #### setSpacing

          public void setSpacing(double spacing)

      Sets the spacing value of the line. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Specified by:
        `setSpacing` in class `Element`
      Parameters:
        `spacing` - the spacing of the line

    - #### getIncidentLines

          public java.util.ArrayList<Line> getIncidentLines()

      Description copied from interface: `Connectible`
      Returns a list of all lines incident to this element.
      Specified by:
        `getIncidentLines` in interface `Connectible`
      Returns:
        a list of all lines incident to this element.

    - #### getLabels

          public java.util.ArrayList<OutsideLabel.LineLabel> getLabels()

      Returns the labels of the line.
      Returns:
        the labels of the line.

    - #### getOwner

          public final Container getOwner()

      Description copied from class: `Element`
      Each element can be owned by some other element. When an owner is deleted, it deletes all objects owned by it. A box's owner is a container (or one of its derived classes — another box or diagram), a line is owned by a container. A label is owned by a box, a line, a label or a container. Container's owner is a container. A diagram is not owned by any other element.
      Overrides:
        `getOwner` in class `Element`
      Returns:
        the owner of this object, or possibly `null`, if this element is a diagram.

    - #### setStartSides

          public void setStartSides(Box.BoxSide[] sides)

      Sets the sides of the start box this line is allowed to start from. The sides are given as an array of `BoxSides`, at least one side must be allowed.
      Parameters:
        `sides` - the array of allowed start box sides for this line

    - #### setEndSides

          public void setEndSides(Box.BoxSide[] sides)

      Sets the sides of the end box this line is allowed to end at. The sides are given as an array of `BoxSides`, at least one side must be allowed.
      Parameters:
        `sides` - the array of allowed end box sides for this line

    - #### setStartSides

          public void setStartSides(int sides)

      Sets the sides of the start box this line is allowed to start from. The sides are given as an mask, at least one side must be allowed. The mask bits are as follows:

           0b0001: top
           0b0010: right
           0b0100: bottom
           0b1000: left

      Parameters:
        `sides` - the mask of allowed start box sides for this line

    - #### setIsFlowEdge

          public void setIsFlowEdge(boolean directed)

      Sets the flag whether flow layout treats this line as directed.
      Parameters:
        `directed` - the new value of this setting

    - #### getIsFlowEdge

          public boolean getIsFlowEdge()

      Gets the flag whether flow layout treats this line as directed.

    - #### setEndSides

          public void setEndSides(int sides)

      Sets the sides of the end box this line is allowed to end at. The sides are given as a mask, at least one side must be allowed. The mask bits are as follows:

           0b0001: top
           0b0010: right
           0b0100: bottom
           0b1000: left

      Parameters:
        `sides` - the mask of allowed end box sides for this line

    - #### getStartSides

          public int getStartSides()

      Returns the mask of the allowed start sides for this line. The mask bits are as follows:

           0b0001: top
           0b0010: right
           0b0100: bottom
           0b1000: left

      Returns:
        the mask of the allowed start sides for this line.

    - #### getEndSides

          public int getEndSides()

      Returns the mask of the allowed end sides for this box. The mask bits are as follows:

           0b0001: top
           0b0010: right
           0b0100: bottom
           0b1000: left

      Returns:
        the mask of the allowed end sides for this box.

    - #### resetStartSides

          public void resetStartSides()

      Resets the start sides of this line to allow it to start from any side of the start box.

    - #### resetEndSides

          public void resetEndSides()

      Resets the end sides of this line to allow it to end at any side of the end box.

    - #### 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 `Element`

    - #### remove

          public void remove(boolean adjust)

      Removes this line. The whole diagram is reordered afterwards, or at the end of the current transaction if `adjust` is set to `true`.
      Overrides:
        `remove` in class `Element`
      Parameters:
        `adjust` - whether to adjust the diagram after removing this line.

    - #### createLabel

          public OutsideLabel.LineLabel createLabel(double width,
                                                    double height,
                                                    java.awt.geom.Point2D.Double point,
                                                    OutsideLabel.LineLabel.Orientation orientation,
                                                    LayoutConstraints.ConstraintType constraintType,
                                                    double spacing)

      Creates a new label for this line. The position for the new label is determined by the given point, which is moved to the line perimeter if necessary. The minimum size of the new label is the size of the given rectangle. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Parameters:
        `width` - the width for the new label
        `height` - the height for the new label
        `point` - the point from which to determine the position of the label relative to the line perimeter
        `orientation` - the orientation for the label positioning
        `constraintType` - the type of the layout constraints for the new label
        `spacing` - the spacing value for the new label
      Returns:
        the new inside label object.

    - #### createLabel

          public OutsideLabel.LineLabel createLabel(double width,
                                                    double height,
                                                    double position,
                                                    OutsideLabel.LineLabel.Orientation orientation,
                                                    LayoutConstraints.ConstraintType constraintType,
                                                    double spacing)

      Creates a new label for this line. The minimum size of the new label is the size of the given rectangle. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Parameters:
        `width` - the width for the new label
        `height` - the height for the new label
        `position` - the relative position on the line perimeter for the new label
        `orientation` - the orientation for the label positioning
        `constraintType` - the type of the layout constraints for the new label
        `spacing` - the spacing value for the new label
      Returns:
        the new inside label object.

    - #### connectTo

          public Line connectTo(Connectible element,
                                Line.LineType lineType,
                                double spacing)

      Description copied from interface: `Connectible`
      Adds a line to this diagram. A line can connect boxes or other lines. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Specified by:
        `connectTo` in interface `Connectible`
      Parameters:
        `element` - the element to connect to this Connectible
        `lineType` - the type of the new line
        `spacing` - the width of the empty buffer around the line
      Returns:
        the new line connecting this Connectible with the given element.

    - #### connectTo

          public Line connectTo(Connectible element,
                                Line.LineType lineType,
                                double spacing,
                                java.util.ArrayList<java.awt.geom.Point2D.Double> points)

      Description copied from interface: `Connectible`
      Adds a line to this diagram going along the given points. A line can connect boxes or other lines. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Specified by:
        `connectTo` in interface `Connectible`
      Parameters:
        `element` - the element to connect to this Connectible
        `lineType` - the type of the new line
        `spacing` - the width of the empty buffer around the line
        `points` - the desired vertices of the new line
      Returns:
        the new line connecting this Connectible with the given element.

    - #### connectTo

          public Line connectTo(Connectible element,
                                Line.LineType lineType,
                                double spacing,
                                java.util.ArrayList<java.awt.geom.Point2D.Double> points,
                                boolean cleanup)

      Description copied from interface: `Connectible`
      Adds a line to this diagram going along the given points. A line can connect boxes or other lines. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Specified by:
        `connectTo` in interface `Connectible`
      Parameters:
        `element` - the element to connect to this Connectible
        `lineType` - the type of the new line
        `spacing` - the width of the empty buffer around the line
        `points` - the desired vertices of the new line
        `cleanup` - whether to clean up the given line, removing unnecessary corners
      Returns:
        the new line connecting this Connectible with the given element.

    - #### retrace

          public void retrace()

      Retraces this line from scratch so that it connects its end elements. The whole diagram is reordered afterwards, or at the end of the current transaction.

    - #### retrace

          public void retrace(Line.LineType type)

      Retraces this line from scratch so that it connects its end elements. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Parameters:
        `type` - the new line type

    - #### retrace

          public void retrace(Line.LineType type,
                              Element newStart,
                              Element newEnd)

      Retraces this line from scratch so that it connects its new end elements. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Parameters:
        `type` - the new line type
        `newStart` - the new start of the line
        `newEnd` - the new end of the line

    - #### retrace

          public void retrace(Element newStart,
                              Element newEnd)

      Retraces this line from scratch so that it connects its new end elements. The whole diagram is reordered afterwards, or at the end of the current transaction.
      Parameters:
        `newStart` - the new start of the line
        `newEnd` - the new end of the line

    - #### cleanup

          public void cleanup()

      Cleans up this line, removing unnecessary corners.