Class GanttVisualSet<T>

Type Parameters:
T - visual set data elements type
All Implemented Interfaces:
IBeginEndArgumentPropertyOwner<T>, IGanttChartRowPropertyOwner, IUpdatePolicyPropertyOwner, IAbstractChartVisualSet, IGanttChartVisualSet
Direct Known Subclasses:
SlotsVisualSet

Visual set for drawing rectangles.

Can be drawn on TimeGanttChart.

Usually it is used to show history of some state changes or schedules within time-related X-axis.

Author:
Aleksey Kirillov
  • Constructor Details

    • GanttVisualSet

      public GanttVisualSet(String name, Supplier<List<T>> dataElementsProvider, Function<T,Double> beginArgumentExtractor, Function<T,Double> endArgumentExtractor)
      Constructs a GanttVisualSet with given name, data elements and begin/end argument extractors, i.e. a functions that specifies the rule for extracting a begin/end arguments from a data element. Creates a default GanttChartRow based on the given name.
      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 being redrawn
      beginArgumentExtractor - a function that specifies the rule for extracting a begin argument from a data element
      endArgumentExtractor - a function that specifies the rule for extracting an end argument from a data element
    • GanttVisualSet

      public GanttVisualSet(String name, GanttChartRow ganttChartRow, Supplier<List<T>> dataElementsProvider, Function<T,Double> beginArgumentExtractor, Function<T,Double> endArgumentExtractor)
      Constructs a GanttVisualSet with given name, data elements and begin/end argument extractors, i.e. a functions that specifies the rule for extracting a begin/end arguments from a data element.
      Parameters:
      name - visual set name is used to sort and name the visual sets on the chart
      ganttChartRow - GanttChartRow which displays this visual set i.e. the Y-axis value
      dataElementsProvider - data elements list provider. The provider is invalidated every time the chart is being redrawn
      beginArgumentExtractor - a function that specifies the rule for extracting a begin argument from a data element
      endArgumentExtractor - a function that specifies the rule for extracting an end argument from a data element
  • Method Details

    • setBackgroundColor

      public GanttVisualSet<T> setBackgroundColor(Function<? extends T,Color> backgroundColorExtractor)
      Sets the background color for each data element. The color may be different for different data elements.
      Parameters:
      backgroundColorExtractor - the background color extractor, i.e. method returning color depending on the data element
      Returns:
      reference to this object
    • setBorderColor

      public GanttVisualSet<T> setBorderColor(Function<? extends T,Color> borderColorExtractor)
      Sets the border color for each data element. The color may be different for different data elements.
      Parameters:
      borderColorExtractor - the border color extractor, i.e. method returning color depending on the data element
      Returns:
      reference to this object
    • setBorderWidth

      public GanttVisualSet<T> setBorderWidth(Function<? extends T,Double> borderWidthExtractor)
      Sets the border width in pixels for each data element. The width may be different for different data elements.
      Parameters:
      borderWidthExtractor - the border width extractor, i.e. method returning width in pixels depending on the data element
      Returns:
      reference to this object
    • setRowHeightFraction

      public GanttVisualSet<T> setRowHeightFraction(Function<? extends T,Double> rowHeightFractionExtractor)
      Sets the fraction height of the region in which rectangle is drawn. The fraction may be different for different data elements. Fraction is calculated relative to the height of the region allocated for corresponding GanttChartRow.

      The value must be greater than zero and not greater than 1.

      The default value is 1.

      Parameters:
      rowHeightFractionExtractor - the row height fraction extractor, i.e. method returning row height fraction depending on the data element
      Returns:
      the fraction height of the region in which rectangle is drawn
    • getRowHeightFraction

      public double getRowHeightFraction(T element)
      Returns the fraction height of the region in which polyline is drawn.
      Parameters:
      element - data element for which the fraction height is being checked
      Returns:
      the fraction height of the region in which polyline is drawn
    • getBackgroundColor

      public Color getBackgroundColor(T element)
      Returns the background color for given data element.
      Parameters:
      element - data element for which the background color is being checked
      Returns:
      the background color for given data element
    • getBorderColor

      public Color getBorderColor(T element)
      Returns the border color for given data element.
      Parameters:
      element - data element for which the border color is being checked
      Returns:
      the border color for given data element
    • getBorderWidth

      public Double getBorderWidth(T element)
      Returns the border width in pixels for given data element.
      Parameters:
      element - data element for which the border width in pixels is being checked
      Returns:
      the border width in pixels for given data element
    • setLabelText

      public GanttVisualSet<T> setLabelText(LabelSide labelSide, Function<? extends T,String> labelTextExtractor, Function<? extends T,Double> labelFontSizeExtractor)
      Sets the labels of the rectangles representing plot data elements. The label of each rectangle is set independently of the labels on other sides of this rectangle or the labels on other rectangles. The label will not be displayed if the specified text is empty. The label color is generated automatically based on the inverted background color of the rectangle.
      Parameters:
      labelSide - the LabelSide of bar where the corresponding label will be drawn
      labelTextExtractor - the text of the label
      labelFontSizeExtractor - the font size of the label
      Returns:
      reference to this object
    • setTooltipText

      public GanttVisualSet<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 GanttVisualSet<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
    • 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
    • getGanttChartRow

      public GanttChartRow getGanttChartRow()
      Description copied from interface: IGanttChartRowPropertyOwner
      Returns the reference to the GanttChartRow row on which the visuals will be drawn
      Specified by:
      getGanttChartRow in interface IGanttChartRowPropertyOwner
      Returns:
      the reference to the GanttChartRow row on which the visuals will be drawn
    • setLabelText

      public GanttVisualSet<T> setLabelText(LabelSide labelSide, Function<? extends T,String> labelTextExtractor, Function<? extends T,Double> labelFontSizeExtractor, Function<? extends T,Color> labelColorExtractor)
      Description copied from class: LabeledVisualSet
      Sets the labels of the rectangles representing plot data elements. The label of each rectangle is set independently of the labels on other sides of this rectangle or the labels on other rectangles. The label will not be displayed if the specified text is empty.
      Overrides:
      setLabelText in class LabeledVisualSet<T>
      Parameters:
      labelSide - the LabelSide of rectangle where the corresponding label will be drawn
      labelTextExtractor - the text of the label
      labelFontSizeExtractor - the font size of the label
      labelColorExtractor - the color of the label
      Returns:
      reference to this object
    • addContextMenuHandler

      public GanttVisualSet<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 GanttVisualSet<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 GanttVisualSet<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 GanttVisualSet<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 GanttVisualSet<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 GanttVisualSet<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<GanttVisualSet<T>.GanttVisualElement> 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 GanttVisualSet<T>.GanttVisualElement 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