com.dlsc.flexgantt.swing.layer.system

## Class RelationshipLayer

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

- All Implemented Interfaces:
    IGanttChartModelListener, IRelationshipSelectionModelListener, MouseListener, MouseMotionListener, PropertyChangeListener, EventListener

      public class RelationshipLayer
      extends AbstractSystemLayer
      implements MouseListener, MouseMotionListener, IRelationshipSelectionModelListener, IGanttChartModelListener, PropertyChangeListener

  The relationship layer is reponsible for visualizing the relationships that might exist between two different timeline objects. Relationships are visualized by a line that starts at the end of the source object of the relationship and that ends at the beginning of the target object of the relationship. An arrow is shown at the end of the line. Due to several technical constraints the layer always has to render all relationships, hence the number of relationships shown in a Gantt chart should not be too large.
  Since:
    1.0
  Version:
    $Revision: 1.13 $
  Author:
    Dirk Lemmermann
  See Also:
    `IGanttChartModel.getRelationships()`

- - ### 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
    `RelationshipLayer(LayerContainer lc)` Constructs a new relationship layer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `deleteSelectedRelationships()` Deletes all currently selected relationships.
    `void` | `ganttChartChanged(GanttChartModelEvent evt)` Callback method that gets invoked whenever change occures in the Gantt chart model that is being observed by the listener.
    `IRelationshipRenderer` | `getRelationshipRenderer(Class cl)` Returns a renderer for drawing a relationship.
    `Map<Class<? extends IRelationship>,IRelationshipRenderer>` | `getRelationshipRendererMap()` Returns the renderer map used by this layer.
    `List<IRelationship>` | `getRelationshipsAt(int x, int y)` Returns all relationships that can be found at the given coordinate.
    `Collection<IRelationship>` | `getSelectedRelationships()` Returns all currently selected relationships.
    `IRelationshipSelectionModel` | `getSelectionModel()` Returns the relationship selection model used by the layer to track the currently selected relationships.
    `boolean` | `isDebugRelationshipBounds()` Returns a flag used for debugging the rendering of the relationships.
    `boolean` | `isVisible()` Determines whether the layer is currently 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` | `paintLayer(Graphics g)`
    `protected void` | `paintRelationship(Graphics g, int w, int h, IRelationship relationship, IGanttChartModel model)` Paints the given relationship object.
    `void` | `propertyChange(PropertyChangeEvent evt)`
    `void` | `setDebugRelationshipBounds(boolean debug)` Sets a flag used for debugging the rendering of the relationships.
    `void` | `setRelationshipRenderer(Class<? extends IRelationship> relationshipType, IRelationshipRenderer renderer)` Maps the implementation of a relationship renderer to a class definition.
    `void` | `setRelationshipRendererMap(Map<Class<? extends IRelationship>,IRelationshipRenderer> map)` Sets the renderer map used by this layer.
    `void` | `setSelectionModel(IRelationshipSelectionModel model)` Sets a new selection model to be used by the relationship layer to track the currently selected relationships.
    `void` | `valueChanged(RelationshipSelectionEvent evt)` Callback method that gets invoked when the selection within the observed `RelationshipLayer` changes.

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

    - #### RelationshipLayer

          public RelationshipLayer(LayerContainer lc)

      Constructs a new relationship layer.
      Parameters:
        `lc` - the owning layer container
      Since:
        1.0

  - ### Method Detail

    - #### getSelectionModel

          public IRelationshipSelectionModel getSelectionModel()

      Returns the relationship selection model used by the layer to track the currently selected relationships.
      Returns:
        the relationship selection model
      Since:
        2.0

    - #### setSelectionModel

          public void setSelectionModel(IRelationshipSelectionModel model)

      Sets a new selection model to be used by the relationship layer to track the currently selected relationships.
      Parameters:
        `model` - the new selection model
      Since:
        2.0

    - #### isVisible

          public boolean isVisible()

      Description copied from class: `AbstractLayer`
      Determines whether the layer is currently visible or not.
      Overrides:
        `isVisible` in class `AbstractLayer`
      Returns:
        TRUE if the layer is currently visible
      See Also:
        `AbstractLayer.setVisible(boolean)`

    - #### paintLayer

          protected void paintLayer(Graphics g)

      Overrides:
        `paintLayer` in class `AbstractLayer`

    - #### paintRelationship

          protected void paintRelationship(Graphics g,
                                           int w,
                                           int h,
                                           IRelationship relationship,
                                           IGanttChartModel model)

      Paints the given relationship object.
      Parameters:
        `g` - the graphics context into which to draw
        `w` - the total width of the layer
        `h` - the total height of the layer
        `relationship` - the relationship in need of drawing
        `model` - the data source that returned the relationship
      Since:
        1.0

    - #### setRelationshipRenderer

          public void setRelationshipRenderer(Class<? extends IRelationship> relationshipType,
                                              IRelationshipRenderer renderer)

      Maps the implementation of a relationship renderer to a class definition.
      Parameters:
        `relationshipType` - the type of those relationships that will be rendered with the given renderer
        `renderer` - an implementation that will be used to renderer instances of the given object type
      Since:
        1.0
      See Also:
        `DefaultRelationshipRenderer`, `getRelationshipRenderer(Class)`

    - #### getRelationshipRenderer

          public IRelationshipRenderer getRelationshipRenderer(Class cl)

      Returns a renderer for drawing a relationship. The lookup of the renderer is based on the type of relationship.
      Parameters:
        `cl` - the relationship object type in need of rendering
      Returns:
        a matching relationship renderer implementation
      Since:
        1.0
      See Also:
        `setRelationshipRenderer(Class, IRelationshipRenderer)`, `DefaultRelationshipRenderer`

    - #### getRelationshipsAt

          public List<IRelationship> getRelationshipsAt(int x,
                                                        int y)

      Returns all relationships that can be found at the given coordinate.
      Parameters:
        `x` - the x location
        `y` - the y location
      Returns:
        the relationships at the given location
      Since:
        2.0

    - #### setDebugRelationshipBounds

          public void setDebugRelationshipBounds(boolean debug)

      Sets a flag used for debugging the rendering of the relationships. Setting this flag to TRUE will show the points used by the relationship paths.
      Parameters:
        `debug` - if TRUE the relationships will be drawn with debug information
      Since:
        2.0

    - #### isDebugRelationshipBounds

          public boolean isDebugRelationshipBounds()

      Returns a flag used for debugging the rendering of the relationships. Setting this flag to TRUE will show the points used by the relationship paths.
      Returns:
        if TRUE the relationships will be drawn with debug information
      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`

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

    - #### valueChanged

          public void valueChanged(RelationshipSelectionEvent evt)

      Description copied from interface: `IRelationshipSelectionModelListener`
      Callback method that gets invoked when the selection within the observed `RelationshipLayer` changes.
      Specified by:
        `valueChanged` in interface `IRelationshipSelectionModelListener`
      Parameters:
        `evt` - the event with detailed information about the change that occured

    - #### getSelectedRelationships

          public Collection<IRelationship> getSelectedRelationships()

      Returns all currently selected relationships. This is a convenience method that is delegating to `IRelationshipSelectionModel.getSelection()`.
      Returns:
        the currently selected relationships
      Since:
        2.0

    - #### deleteSelectedRelationships

          public void deleteSelectedRelationships()

      Deletes all currently selected relationships.
      Since:
        2.0

    - #### ganttChartChanged

          public void ganttChartChanged(GanttChartModelEvent evt)

      Description copied from interface: `IGanttChartModelListener`
      Callback method that gets invoked whenever change occures in the Gantt chart model that is being observed by the listener.
      Specified by:
        `ganttChartChanged` in interface `IGanttChartModelListener`
      Parameters:
        `evt` - the event object describing the change that took place in the Gantt chart model

    - #### propertyChange

          public void propertyChange(PropertyChangeEvent evt)

      Specified by:
        `propertyChange` in interface `PropertyChangeListener`

    - #### getRelationshipRendererMap

          public Map<Class<? extends IRelationship>,IRelationshipRenderer> getRelationshipRendererMap()

      Returns the renderer map used by this layer.
      Returns:
        the renderer map
      Since:
        1.1.7

    - #### setRelationshipRendererMap

          public void setRelationshipRendererMap(Map<Class<? extends IRelationship>,IRelationshipRenderer> map)

      Sets the renderer map used by this layer.
      Parameters:
        `map` - the new renderer map
      Since:
        1.1.7

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