Class ConnectionVisualSet<T>

java.lang.Object
com.amalgamasimulation.charts.visualsets.VisualSet<T>
com.amalgamasimulation.charts.visualsets.ConnectionVisualSet<T>
Type Parameters:
T - visual set data elements type
All Implemented Interfaces:
IBeginEndArgumentPropertyOwner<T>, IUpdatePolicyPropertyOwner, IAbstractChartVisualSet, IGanttChartVisualSet

public class ConnectionVisualSet<T> extends VisualSet<T> implements IGanttChartVisualSet, IBeginEndArgumentPropertyOwner<T>
Visual set for drawing arrowed polylines.

Can be drawn on TimeGanttChart.

Used to draw connections or dependencies. Each dependency is defined by a source and target points, with each of these points being a pair of a GanttChartRow and an X-axis argument.

Author:
Aleksey Kirillov
  • Field Details

  • Constructor Details

    • ConnectionVisualSet

      public ConnectionVisualSet(String name, Supplier<List<T>> dataElementsProvider, Function<T,Pair<GanttChartRow,Double>> sourceArgumentExtractor, Function<T,Pair<GanttChartRow,Double>> targetArgumentExtractor)
      Constructs a ConnectionVisualSet with given name, data elements and a set of parameters required to describe a dependency. The source and target of the dependence are described by pairs from the GanttChartRow and the argument along the X-axis.
      Parameters:
      name - visual set name is used to sort and name the visual sets on the chart
      dataElementsProvider - data elements list provider. The provider is invalidated every time the chart is beging redrawn
      sourceArgumentExtractor - a function that specifies the rule for extracting a source dependency point from a data element
      targetArgumentExtractor - a function that specifies the rule for extracting a target dependency point from a data element
  • Method Details

    • setLineColor

      public ConnectionVisualSet<?> setLineColor(Color lineColor)
      Sets the line color of the plot. Transparent and semi-transparent colors are allowed.
      Parameters:
      lineColor - the line color of the plot
      Returns:
      reference to this object
    • setWidth

      public ConnectionVisualSet<T> setWidth(double width)
      Sets the width of the line, in pixels.
      Parameters:
      width - the width of the line, in pixels
      Returns:
      reference to this object
    • setLineStyle

      public ConnectionVisualSet<T> setLineStyle(Function<T,LineStyle> lineStyleExtractor)
      Sets the LineStyle of the lines representing plot data elements. The LineStyle of each line is set independently of the LineStyle of other lines.
      Parameters:
      lineStyleExtractor - a function that specifies the rule for extracting a LineStyle from a data element
      Returns:
      reference to this object
    • getLineStyle

      public LineStyle getLineStyle(T element)
      Returns the current LineStyle for given data element.
      Parameters:
      element - data element for which the current LineStyle is being checked
      Returns:
      the current LineStyle for given data element
    • getWidth

      public double getWidth()
      Returns the line width of the plot, in pixels.
      Returns:
      the line color of the plot
    • getLineColor

      public Color getLineColor()
      Returns the line color of the plot.
      Returns:
      the line color of the plot
    • getSourceArgument

      public double getSourceArgument(T element)
      Returns a source dependency argument for a given data element.
      Parameters:
      element - data element for which the source dependency point is being checked
      Returns:
      a source dependency argument for a given data element
    • getSourceGanttChartRow

      public GanttChartRow getSourceGanttChartRow(T element)
      Returns a source dependency GanttChartRow for a given data element.
      Parameters:
      element - data element for which the source dependency point is being checked
      Returns:
      a source dependency GanttChartRow for a given data element
    • getTargetArgument

      public double getTargetArgument(T element)
      Returns a target dependency argument for a given data element.
      Parameters:
      element - data element for which the target dependency point is being checked
      Returns:
      a target dependency argument for a given data element
    • getTargetGanttChartRow

      public GanttChartRow getTargetGanttChartRow(T element)
      Returns a target dependency GanttChartRow for a given data element.
      Parameters:
      element - data element for which the target dependency point is being checked
      Returns:
      a target dependency GanttChartRow for a given data element
    • getBeginArgument

      public double getBeginArgument(T element)
      Description copied from interface: IBeginEndArgumentPropertyOwner
      Returns the begin X-axis argument of the visual corresponding to the given element.
      Specified by:
      getBeginArgument in interface IBeginEndArgumentPropertyOwner<T>
      Parameters:
      element - data element for which the begin argument is being checked
      Returns:
      the begin X-axis argument of the visual corresponding to the given element
    • getEndArgument

      public double getEndArgument(T element)
      Description copied from interface: IBeginEndArgumentPropertyOwner
      Returns the end X-axis argument of the visual corresponding to the given element.
      Specified by:
      getEndArgument in interface IBeginEndArgumentPropertyOwner<T>
      Parameters:
      element - data element for which the end argument is being checked
      Returns:
      the end X-axis argument of the visual corresponding to the given element
    • setTooltipText

      public ConnectionVisualSet<T> setTooltipText(Function<T,String> tooltipTextExtractor)
      Description copied from class: VisualSet
      Adds tooltip text to display when the mouse is hovered over a visual element representing given data element.
      Specified by:
      setTooltipText in class VisualSet<T>
      Parameters:
      tooltipTextExtractor - a function that specifies the rule for extracting a tooltip text from a data element
      Returns:
      reference to this object
    • setUpdatePolicy

      public ConnectionVisualSet<T> setUpdatePolicy(VisualSet.UpdatePolicy updatePolicy)
      Description copied from interface: IAbstractChartVisualSet
      Sets the new VisualSet.UpdatePolicy i.e. the VisualSet update control rule.
      Specified by:
      setUpdatePolicy in interface IAbstractChartVisualSet
      Specified by:
      setUpdatePolicy in interface IUpdatePolicyPropertyOwner
      Overrides:
      setUpdatePolicy in class VisualSet<T>
      Parameters:
      updatePolicy - new VisualSet.UpdatePolicy i.e. the VisualSet update control rule
      Returns:
      reference to this object
    • addContextMenuHandler

      public ConnectionVisualSet<T> addContextMenuHandler(VisualSet.ContextMenuHandler<T> contextMenuHandler)
      Description copied from class: VisualSet
      Adds the action to be executed every time a context menu for given data element is called.
      Overrides:
      addContextMenuHandler in class VisualSet<T>
      Parameters:
      contextMenuHandler - context menu call action
      Returns:
      reference to this object
    • addMouseEnterHandler

      public ConnectionVisualSet<T> addMouseEnterHandler(BiConsumer<T,javafx.scene.input.MouseEvent> handler)
      Description copied from class: VisualSet
      Adds the action to be executed every time mouse enters to any visual element borders.
      Overrides:
      addMouseEnterHandler in class VisualSet<T>
      Parameters:
      handler - new mouse enter action
      Returns:
      reference to this object
    • addMouseExitHandler

      public ConnectionVisualSet<T> addMouseExitHandler(BiConsumer<T,javafx.scene.input.MouseEvent> handler)
      Description copied from class: VisualSet
      Adds the action to be executed every time the mouse exits the previously entered element's bounds.
      Overrides:
      addMouseExitHandler in class VisualSet<T>
      Parameters:
      handler - new mouse exit action
      Returns:
      reference to this object
    • addMousePressedHandler

      public ConnectionVisualSet<T> addMousePressedHandler(BiConsumer<T,javafx.scene.input.MouseEvent> handler)
      Description copied from class: VisualSet
      Adds the action to be executed every time a mouse button is pressed.
      Overrides:
      addMousePressedHandler in class VisualSet<T>
      Parameters:
      handler - new mouse button pressed action
      Returns:
      reference to this object
    • addVisibilityChangeHandler

      public ConnectionVisualSet<T> addVisibilityChangeHandler(Consumer<VisibilityChangeDescriptor<? extends IAbstractChartVisualSet>> visibilityChangeHandler)
      Description copied from interface: IAbstractChartVisualSet
      Adds the action to be executed every time the visibility of this VisualSet is changed.
      Specified by:
      addVisibilityChangeHandler in interface IAbstractChartVisualSet
      Overrides:
      addVisibilityChangeHandler in class VisualSet<T>
      Parameters:
      visibilityChangeHandler - visibility change action
      Returns:
      reference to this object
    • setMouseTransparent

      public ConnectionVisualSet<T> setMouseTransparent(boolean mouseTransparent)
      Description copied from interface: IAbstractChartVisualSet
      Sets the value of the property mouseTransparent. If true, this VisualSet is completely transparent to mouse events. When choosing target for mouse event, VisualSets with mouseTransparent set to true won't be taken into account.
      Specified by:
      setMouseTransparent in interface IAbstractChartVisualSet
      Overrides:
      setMouseTransparent in class VisualSet<T>
      Parameters:
      mouseTransparent - new value of property mouseTransparent
      Returns:
      reference to this object
    • getVisualElements

      public List<ConnectionVisualSet<T>.ConnectionVisualElement> getVisualElements(boolean recalculationRequired)
      Description copied from interface: IAbstractChartVisualSet
      Returns the list of visual elements corresponding to current data elements. Cannot be changed by the user.
      Specified by:
      getVisualElements in interface IAbstractChartVisualSet
      Specified by:
      getVisualElements in interface IGanttChartVisualSet
      Overrides:
      getVisualElements in class VisualSet<T>
      Parameters:
      recalculationRequired - flag of the need to recalculate the visual elements
      Returns:
      the list of visual elements corresponding to current data elements
    • createVisualElement

      public ConnectionVisualSet<T>.ConnectionVisualElement createVisualElement(T contents)
      Description copied from class: VisualSet
      Creates a new instance of VisualSet<T>.VisualElement corresponding to the current VisualSet type.
      Specified by:
      createVisualElement in class VisualSet<T>
      Parameters:
      contents - data element for which the VisualSet<T>.VisualElement is being checked
      Returns:
      a new instance of VisualSet<T>.VisualElement corresponding to the current VisualSet type