Class PointsVisualSet<T>

java.lang.Object
com.amalgamasimulation.charts.visualsets.VisualSet<T>
com.amalgamasimulation.charts.visualsets.PointsVisualSet<T>
Type Parameters:
T - visual set data elements type
All Implemented Interfaces:
IClipboardTextPropertyOwner<Double>, ILegendNodePropertiesOwner, IMinMaxValuePropertyOwner, IUpdatePolicyPropertyOwner, IAbstractChartVisualSet, ILineChartVisualSet

Visual set for drawing plots with points.

Can be drawn on AbstractLineChart.

This VisualSet provides the opportunity to arrange points not only in ascending order of the X-axis values, but also in a random order, including the allocation of several different points on the same value of the horizontal axis.

Author:
Aleksey Kirillov
  • Field Details

  • Constructor Details

    • PointsVisualSet

      public PointsVisualSet(String name, Supplier<List<T>> dataElementsProvider, Function<T,Double> argumentExtractor, Function<T,Double> valueExtractor)
      Constructs a PointsVisualSet with given name, data elements and arguments/value extractors, i.e. a functions that specifies the rule for extracting an argument/value from a data element.
      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
      argumentExtractor - a function that specifies the rule for extracting an argument from a data element
      valueExtractor - a function that specifies the rule for extracting a value from a data element
  • Method Details

    • setPointSize

      public PointsVisualSet<T> setPointSize(double pointSize)
      Sets the diameter of the point, in pixels. If this method is called, all point sizes will be set the same.
      Parameters:
      pointSize - the diameter of the point, in pixels
      Returns:
      reference to this object
    • setPointSize

      public PointsVisualSet<T> setPointSize(Function<T,Double> pointSizeExtractor)
      Sets the diameter of the point, in pixels.
      Parameters:
      pointSizeExtractor - a function that specifies the rule for extracting the diameter of the point from a data element
      Returns:
      reference to this object
    • setFillColor

      public PointsVisualSet<T> setFillColor(Color fillColor)
      Sets the point fill color of the plot. Transparent and semi-transparent colors are allowed.
      Parameters:
      fillColor - the point fill color of the plot
      Returns:
      reference to this object
    • setBorderColor

      public PointsVisualSet<T> setBorderColor(Color borderColor)
      Sets the point border color of the plot. Transparent and semi-transparent colors are allowed.
      Parameters:
      borderColor - the point border color of the plot
      Returns:
      reference to this object
    • getBorderColor

      public Color getBorderColor()
      Returns the point border color of the plot.
      Returns:
      the point border color of the plot
    • getFillColor

      public Color getFillColor()
      Returns the point fill color of the plot.
      Returns:
      the point fill color of the plot.
    • getPointSize

      public double getPointSize(T element)
      Returns the diameter of the point, in pixels.
      Parameters:
      element - data element for which the point size is being checked
      Returns:
      the diameter of the point, in pixels
    • getValue

      public double getValue(T element)
      Returns the value of the given data element.
      Parameters:
      element - data element for which the value is being checked
      Returns:
      the value of the given data element
    • setClipboardText

      public PointsVisualSet<T> setClipboardText(Function<Double,String> clipboardTextExtractor)
      Description copied from interface: IClipboardTextPropertyOwner
      Sets the conversion method from values of each plot data element into text that will be copied to clipboard.
      Specified by:
      setClipboardText in interface IClipboardTextPropertyOwner<T>
      Parameters:
      clipboardTextExtractor - an extractor that converts the value of each plot data element into text that will be copied to the clipboard
      Returns:
      reference to this object
    • setTooltipText

      public PointsVisualSet<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
    • setLegendText

      public PointsVisualSet<T> setLegendText(Supplier<String> legendTextProvider)
      Description copied from interface: ILegendNodePropertiesOwner
      Sets the Legend label text represents this visual set.
      Specified by:
      setLegendText in interface ILegendNodePropertiesOwner
      Parameters:
      legendTextProvider - the Legend label text represents this visual set
      Returns:
      reference to this object
    • getLegendText

      public String getLegendText()
      Description copied from interface: ILegendNodePropertiesOwner
      Returns the Legend label text represents this visual set.
      Specified by:
      getLegendText in interface ILegendNodePropertiesOwner
      Returns:
      the Legend label text represents this visual set
    • getClipboardText

      public String getClipboardText(Double object)
      Description copied from interface: IClipboardTextPropertyOwner
      Returns the text that will be copied to clipboard for the given object.
      Specified by:
      getClipboardText in interface IClipboardTextPropertyOwner<T>
      Parameters:
      object - object for which the clipboard text is being checked
      Returns:
      the text that will be copied to clipboard for the given object
    • addContextMenuHandler

      public PointsVisualSet<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 PointsVisualSet<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 PointsVisualSet<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 PointsVisualSet<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 PointsVisualSet<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 PointsVisualSet<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
    • setUpdatePolicy

      public PointsVisualSet<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
    • getValue

      public List<Double> getValue(double argument)
      Returns the value of the given X-axis argument.
      Parameters:
      argument - X-axis argument for which the value is being checked
      Returns:
      the value of the given X-axis argument
    • getVisualElements

      public List<PointsVisualSet<T>.PointsVisualElement> 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 ILineChartVisualSet
      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 PointsVisualSet<T>.PointsVisualElement 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
    • getMinValue

      public double getMinValue()
      Description copied from interface: IMinMaxValuePropertyOwner
      Returns the minimum Y-axis value for all data elements. The minimum value is recalculated and cached at the moment the chart is redrawn. The method returns the value stored in the cache.
      Specified by:
      getMinValue in interface IMinMaxValuePropertyOwner
      Returns:
      the minimum Y-axis value for all data elements
      See Also:
    • getMaxValue

      public double getMaxValue()
      Description copied from interface: IMinMaxValuePropertyOwner
      Returns the maximum Y-axis value for all data elements. The maximum value is recalculated and cached at the moment the chart is redrawn. The method returns the value stored in the cache.
      Specified by:
      getMaxValue in interface IMinMaxValuePropertyOwner
      Returns:
      the maximum Y-axis value for all data elements
      See Also:
    • getLegendColor

      public Color getLegendColor()
      Description copied from interface: ILegendNodePropertiesOwner
      Returns the color of the Legend's icon corresponding to this VisualSet
      Specified by:
      getLegendColor in interface ILegendNodePropertiesOwner
      Returns:
      the color of the Legend's icon corresponding to this VisualSet