com.dlsc.flexgantt.swing.layer.system

## Class LinkLayer

- java.lang.Object
- - com.dlsc.flexgantt.swing.layer.AbstractLayer
  - - com.dlsc.flexgantt.swing.layer.system.AbstractSystemLayer
    - - com.dlsc.flexgantt.swing.layer.system.LinkLayer

- All Implemented Interfaces:
    MouseListener, MouseMotionListener, EventListener

      public class LinkLayer
      extends AbstractSystemLayer
      implements MouseListener, MouseMotionListener

  A layer used for displaying everything needed for the interactive linking (creation of relationships / constraints) between two timeline objects: the linking line and the linking handles.
  Since:
    2.0
  Author:
    Dirk Lemmermann

- - ### Field Summary

    - ### Fields inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer

      `alpha, changeSupport, ganttChart, layerContainer, PROPERTY_ALPHA, PROPERTY_VISIBLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LinkLayer(LayerContainer lc)` Constructs a new layer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Rectangle` | `calculateBox(ObjectBounds bounds, boolean source, boolean left)` Calculates the "hot spots" for the given object bounds (timeline object).
    `protected int` | `calculateHandleIconOffset(Icon icon, boolean source, boolean left)` Calculates the offset of the given handle icon.
    `protected Icon` | `getHandleIcon(ObjectBounds bounds, boolean source, boolean left, boolean focus)` Returns the icon to be shown as a handle depending on various parameters.
    `int` | `getHandleIconOffset()` Returns the distance of the handle icon to the timeline object that it is decorating.
    `Stroke` | `getLineStroke()` Returns the stroke used for drawing the linking line.
    `PathCalculator` | `getPathCalculator()` Returns the object used for calculating the path that the linking line will take when it gets drawn.
    `int` | `getProximity()` Returns the maximum distance to the timeline object when the linking points become visible.
    `boolean` | `isLinking()` Determines if the layer is currently used for linking two timeline objects with each other.
    `boolean` | `isLinkStartLocation(Point p)` Determines if the given point is a location where a linking operation can start.
    `boolean` | `isVisible()` Determines if the layer is visible or not.
    `void` | `mouseClicked(MouseEvent e)`
    `void` | `mouseDragged(MouseEvent e)`
    `void` | `mouseEntered(MouseEvent e)`
    `void` | `mouseExited(MouseEvent e)`
    `void` | `mouseMoved(MouseEvent e)`
    `void` | `mousePressed(MouseEvent e)`
    `void` | `mouseReleased(MouseEvent e)`
    `protected void` | `paintHandle(Graphics g, Rectangle r, ObjectBounds bounds, boolean source, boolean left, boolean focus)` Performs the actual drawing of a handle icon.
    `protected void` | `paintLayer(Graphics g)`
    `void` | `setHandleIconOffset(int handleIconOffset)` Sets the distance of the handle icon to the timeline object that it is decorating.
    `void` | `setLineStroke(Stroke lineStroke)` Sets the stroke used for drawing the linking line.
    `void` | `setPathCalculator(PathCalculator calculator)` Sets the object used for calculating the path that the linking line will take when it gets drawn.
    `void` | `setProximity(int proximity)` Sets the maximum distance to the timeline object when the linking points become visible.

    - ### Methods inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer

      `addPropertyChangeListener, getAlpha, getDateline, getEventline, getGanttChart, getHeight, getLayerContainer, getLayerPolicyProvider, getModel, getName, getStartRow, getTimeAt, getTimeline, getTimeLocation, getTimeSpanUsed, getToolTipText, getTreeTable, getTreeTablePolicyProvider, getWidth, removePropertyChangeListener, repaint, repaint, repaint, setAlpha, setVisible, tearDown`

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

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

- - ### Constructor Detail

    - #### LinkLayer

          public LinkLayer(LayerContainer lc)

      Constructs a new layer.
      Parameters:
        `lc` - the owner of the layer
      Since:
        2.0

  - ### Method Detail

    - #### setLineStroke

          public void setLineStroke(Stroke lineStroke)

      Sets the stroke used for drawing the linking line.
      Parameters:
        `lineStroke` - the stroke
      Since:
        2.0

    - #### getLineStroke

          public Stroke getLineStroke()

      Returns the stroke used for drawing the linking line.
      Returns:
        the stroke
      Since:
        2.0

    - #### setProximity

          public void setProximity(int proximity)

      Sets the maximum distance to the timeline object when the linking points become visible.
      Parameters:
        `proximity` - the distance to the timeline object
      Since:
        2.0

    - #### getProximity

          public int getProximity()

      Returns the maximum distance to the timeline object when the linking points become visible.
      Returns:
        the maximum distance to the timeline object
      Since:
        2.0

    - #### setPathCalculator

          public void setPathCalculator(PathCalculator calculator)

      Sets the object used for calculating the path that the linking line will take when it gets drawn.
      Parameters:
        `calculator` - the path calculator
      Since:
        2.0

    - #### getPathCalculator

          public PathCalculator getPathCalculator()

      Returns the object used for calculating the path that the linking line will take when it gets drawn.
      Returns:
        the path calculator
      Since:
        2.0

    - #### setHandleIconOffset

          public void setHandleIconOffset(int handleIconOffset)

      Sets the distance of the handle icon to the timeline object that it is decorating.
      Parameters:
        `handleIconOffset` - the distance of the icon to the timeline object
      Since:
        2.0

    - #### getHandleIconOffset

          public int getHandleIconOffset()

      Returns the distance of the handle icon to the timeline object that it is decorating.
      Returns:
        the distance of the icon to the timeline object
      Since:
        2.0

    - #### getHandleIcon

          protected Icon getHandleIcon(ObjectBounds bounds,
                                       boolean source,
                                       boolean left,
                                       boolean focus)

      Returns the icon to be shown as a handle depending on various parameters.
      Parameters:
        `bounds` - the bounds of the timeline object that will be linked (either as a source or as a target of the new relationship)
        `source` - a flag indicating whether the timeline object will be used as the source or the target of the new relationship
        `left` - if TRUE then the icon will be shown on the left side of the timeline object
        `focus` - if TRUE then the handle will be focused (the mouse cursor is hovering on top of it)
      Returns:
        the icon used for visualizing the link handle
      Since:
        2.0

    - #### calculateHandleIconOffset

          protected int calculateHandleIconOffset(Icon icon,
                                                  boolean source,
                                                  boolean left)

      Calculates the offset of the given handle icon. In most cases this method will return the already specified handle icon offset (see `setHandleIconOffset(int)`), but certain circumstances might require a more detailed calculation.
      Parameters:
        `icon` - the handle icon
        `source` - a flag indicating whether the icon will be used as the source or the target of the new relationship
        `left` - if TRUE then the icon will be shown on the left side of the timeline object
      Returns:
        the icon offset
      Since:
        2.0

    - #### isVisible

          public boolean isVisible()

      Determines if the layer is visible or not.
      Overrides:
        `isVisible` in class `AbstractLayer`
      Returns:
        TRUE if the layer is currently visible
      Since:
        2.0
      See Also:
        `LayerContainer.setLinkingEnabled(boolean)`

    - #### paintLayer

          protected void paintLayer(Graphics g)

      Overrides:
        `paintLayer` in class `AbstractLayer`

    - #### paintHandle

          protected void paintHandle(Graphics g,
                                     Rectangle r,
                                     ObjectBounds bounds,
                                     boolean source,
                                     boolean left,
                                     boolean focus)

      Performs the actual drawing of a handle icon.
      Parameters:
        `g` - the graphics context into which to draw
        `r` - the bounds of the handle icon
        `bounds` - the bounds of the timeline object that will be decorated
        `source` - a flag indicating whether the icon will be used as the source or the target of the new relationship
        `left` - if TRUE then the icon will be shown on the left side of the timeline object
        `focus` - if TRUE then the icon is currently focused (mouse cursor hovers over it)
      Since:
        2.0

    - #### isLinking

          public boolean isLinking()

      Determines if the layer is currently used for linking two timeline objects with each other.
      Returns:
        TRUE if the layer is linking
      Since:
        2.0

    - #### mouseClicked

          public void mouseClicked(MouseEvent e)

      Specified by:
        `mouseClicked` in interface `MouseListener`

    - #### mouseEntered

          public void mouseEntered(MouseEvent e)

      Specified by:
        `mouseEntered` in interface `MouseListener`

    - #### mouseExited

          public void mouseExited(MouseEvent e)

      Specified by:
        `mouseExited` in interface `MouseListener`

    - #### isLinkStartLocation

          public boolean isLinkStartLocation(Point p)

      Determines if the given point is a location where a linking operation can start.
      Parameters:
        `p` - the point to check
      Returns:
        TRUE if the point can be used for starting a linking operation
      Since:
        2.0

    - #### mousePressed

          public void mousePressed(MouseEvent e)

      Specified by:
        `mousePressed` in interface `MouseListener`

    - #### mouseReleased

          public void mouseReleased(MouseEvent e)

      Specified by:
        `mouseReleased` in interface `MouseListener`

    - #### mouseDragged

          public void mouseDragged(MouseEvent e)

      Specified by:
        `mouseDragged` in interface `MouseMotionListener`

    - #### mouseMoved

          public void mouseMoved(MouseEvent e)

      Specified by:
        `mouseMoved` in interface `MouseMotionListener`

    - #### calculateBox

          protected Rectangle calculateBox(ObjectBounds bounds,
                                           boolean source,
                                           boolean left)

      Calculates the "hot spots" for the given object bounds (timeline object). The returned rectangle is used for detecting mouse overs and for drawing the handle icons.
      Parameters:
        `bounds` - the object bounds of the timeline object for which to perform the calculation
        `source` - a flag indicating whether we want to calculate a source or a target hot spot
        `left` - a flag indicating whether we want to calculate the left or the right hot spot
      Returns:
        the bounds of the hot spot
      Since:
        2.0

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