com.dlsc.flexgantt.swing.layer.system

## Class DefaultRelationshipRenderer

- java.lang.Object
- - com.dlsc.flexgantt.swing.layer.system.DefaultRelationshipRenderer

- All Implemented Interfaces:
    IRelationshipRenderer, IRenderer

      public class DefaultRelationshipRenderer
      extends Object
      implements IRelationshipRenderer

  The default relationship renderer draws a multi edge line from the source to the target timeline object. The renderer can be customized to use different line strokes and paints. These differently colored relationship renderers can then be mapped to different types of relationships.
  Since:
    1.0
  Author:
    Dirk Lemmermann
  See Also:
    `RelationshipLayer.setRelationshipRenderer(Class, IRelationshipRenderer)`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultRelationshipRenderer()` Constructs a new relationship renderer.
    `DefaultRelationshipRenderer(PathCalculator calculator)` Constructs a new relationship renderer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `GeneralPath` | `drawRelationship(RelationshipLayer layer, Graphics g, IRelationship relationship, boolean focused, boolean selected)` Draws a relationship between two timeline objects.
    `int` | `getArrowSize()`
    `Paint` | `getFocusedLinePaint()` Returns the paint used for drawing the relationship when it is focused.
    `BasicStroke` | `getFocusedLineStroke()` Returns the stroke used for drawing the relationship when it is focused.
    `Paint` | `getLinePaint()` Returns the default line paint that will be used to draw the lines of a relationship.
    `BasicStroke` | `getLineStroke()` Returns the default line stroke that will be used to draw the lines of a relationship.
    `protected IGanttChartModel` | `getModel()` Returns the model to which the relationship belongs.
    `IRelationship` | `getRelationship()` Returns the currently drawn relationship object.
    `Paint` | `getSelectedLinePaint()` Returns the paint used for drawing the relationship when it is selected.
    `BasicStroke` | `getSelectedLineStroke()` Returns the stroke used for drawing the relationship when it is selected.
    `protected boolean` | `isFocused()` Returns true if the currently rendered relationship is focused.
    `protected boolean` | `isSelected()` Returns true if the currently rendered relationship is selected.
    `protected void` | `paintArrowHead(Graphics g, IRelationship rel, int x, int y)` Draws an arrow at the end of the relationship line.
    `protected void` | `paintRelationshipPath(Graphics g, IRelationship rel, GeneralPath path)` Performs the actual drawing of the relationship line based on the path that was calculated by the `drawRelationship(RelationshipLayer, Graphics, IRelationship, boolean, boolean)` method via the path calculator object.
    `void` | `setArrowSize(int arrowSize)`
    `void` | `setFocusedLinePaint(Paint paint)` Sets the paint used for drawing the relationship when it is focused.
    `void` | `setFocusedLineStroke(BasicStroke stroke)` Sets the stroke used for drawing the relationship when it is focused.
    `void` | `setLinePaint(Paint paint)` Sets the default line paint that will be used to draw the lines of a relationship.
    `void` | `setLineStroke(BasicStroke stroke)` Sets the default line stroke that will be used to draw the lines of a relationship.
    `void` | `setSelectedLinePaint(Paint paint)` Sets the paint used for drawing the relationship when it is selected.
    `void` | `setSelectedLineStroke(BasicStroke stroke)` Sets the stroke used for drawing the relationship when it is selected.

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

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

- - ### Constructor Detail

    - #### DefaultRelationshipRenderer

          public DefaultRelationshipRenderer(PathCalculator calculator)

      Constructs a new relationship renderer.
      Parameters:
        `calculator` - the calculator used to compute the path to draw
      Since:
        2.0

    - #### DefaultRelationshipRenderer

          public DefaultRelationshipRenderer()

      Constructs a new relationship renderer.
      Since:
        1.0

  - ### Method Detail

    - #### drawRelationship

          public GeneralPath drawRelationship(RelationshipLayer layer,
                                              Graphics g,
                                              IRelationship relationship,
                                              boolean focused,
                                              boolean selected)

      Description copied from interface: `IRelationshipRenderer`
      Draws a relationship between two timeline objects. This is usually a line that starts at the source object and ends at the target object (with an arrow head pointing towards the target).
      Specified by:
        `drawRelationship` in interface `IRelationshipRenderer`
      Parameters:
        `layer` - the relationship layer in which the drawing takes place
        `g` - the graphics context into which to draw
        `relationship` - the relationship object in need of rendering
        `focused` - signals whether the mouse currently hovers over the relationship
        `selected` - signals whether the relationship is currently selected
      Returns:
        a path object, which describes path of the relationship lines (needed for detecting the relationship, e.g. for popup menus)

    - #### paintRelationshipPath

          protected void paintRelationshipPath(Graphics g,
                                               IRelationship rel,
                                               GeneralPath path)

      Performs the actual drawing of the relationship line based on the path that was calculated by the `drawRelationship(RelationshipLayer, Graphics, IRelationship, boolean, boolean)` method via the path calculator object.
      Parameters:
        `g` - the graphics context into which to draw the relationship
        `rel` - the relationship model object
        `path` - the path that was calculated by the path calculator
      Since:
        2.0

    - #### paintArrowHead

          protected void paintArrowHead(Graphics g,
                                        IRelationship rel,
                                        int x,
                                        int y)

      Draws an arrow at the end of the relationship line.
      Parameters:
        `g` - the graphics context to use for the drawing operations
        `rel` - the relationship to draw
        `x` - the starting x coordinate
        `y` - the starting y coordinate
      Since:
        1.0

    - #### getLinePaint

          public Paint getLinePaint()

      Returns the default line paint that will be used to draw the lines of a relationship.
      Returns:
        a paint object used for drawing the relationship lines
      Since:
        1.0

    - #### setLinePaint

          public void setLinePaint(Paint paint)

      Sets the default line paint that will be used to draw the lines of a relationship.
      Parameters:
        `paint` - the paint object that will be used as a default for drawing the lines of a relationship
      Since:
        1.0

    - #### getLineStroke

          public BasicStroke getLineStroke()

      Returns the default line stroke that will be used to draw the lines of a relationship.
      Returns:
        a stroke object used for drawing the relationship lines
      Since:
        1.0

    - #### setLineStroke

          public void setLineStroke(BasicStroke stroke)

      Sets the default line stroke that will be used to draw the lines of a relationship.
      Parameters:
        `stroke` - the stroke object that will be used as a default for drawing the lines of a relationship
      Since:
        1.0

    - #### getSelectedLinePaint

          public Paint getSelectedLinePaint()

      Returns the paint used for drawing the relationship when it is selected.
      Returns:
        the selection paint
      Since:
        2.1

    - #### setSelectedLinePaint

          public void setSelectedLinePaint(Paint paint)

      Sets the paint used for drawing the relationship when it is selected.
      Parameters:
        `paint` - the selection paint
      Since:
        2.1

    - #### getFocusedLinePaint

          public Paint getFocusedLinePaint()

      Returns the paint used for drawing the relationship when it is focused.
      Returns:
        the focused paint
      Since:
        2.1

    - #### setFocusedLinePaint

          public void setFocusedLinePaint(Paint paint)

      Sets the paint used for drawing the relationship when it is focused.
      Parameters:
        `paint` - the focused paint
      Since:
        2.1

    - #### getFocusedLineStroke

          public BasicStroke getFocusedLineStroke()

      Returns the stroke used for drawing the relationship when it is focused.
      Returns:
        the focused stroke
      Since:
        2.1

    - #### setFocusedLineStroke

          public void setFocusedLineStroke(BasicStroke stroke)

      Sets the stroke used for drawing the relationship when it is focused.
      Parameters:
        `stroke` - the focused stroke
      Since:
        2.1

    - #### getSelectedLineStroke

          public BasicStroke getSelectedLineStroke()

      Returns the stroke used for drawing the relationship when it is selected.
      Returns:
        the selection stroke
      Since:
        2.1

    - #### setSelectedLineStroke

          public void setSelectedLineStroke(BasicStroke stroke)

      Sets the stroke used for drawing the relationship when it is selected.
      Parameters:
        `stroke` - the selection stroke
      Since:
        2.1

    - #### getArrowSize

          public int getArrowSize()

      Returns:
        the arrowSize
      Since:
        1.0

    - #### setArrowSize

          public void setArrowSize(int arrowSize)

      Parameters:
        `arrowSize` - the arrowSize to set
      Since:
        1.0

    - #### isSelected

          protected boolean isSelected()

      Returns true if the currently rendered relationship is selected.
      Returns:
        TRUE if the relationship is currently selected
      Since:
        2.0

    - #### isFocused

          protected boolean isFocused()

      Returns true if the currently rendered relationship is focused.
      Returns:
        TRUE if the relationship currently has focus
      Since:
        2.0

    - #### getModel

          protected IGanttChartModel getModel()

      Returns the model to which the relationship belongs.
      Returns:
        the model
      Since:
        2.0

    - #### getRelationship

          public IRelationship getRelationship()

      Returns the currently drawn relationship object.
      Returns:
        the relationship
      Since:
        2.0

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.