Class LabeledVisualSet<T>

java.lang.Object
com.amalgamasimulation.charts.visualsets.VisualSet<T>
com.amalgamasimulation.charts.visualsets.LabeledVisualSet<T>
Type Parameters:
T - visual set data elements type
All Implemented Interfaces:
IUpdatePolicyPropertyOwner, IAbstractChartVisualSet
Direct Known Subclasses:
AbstractRegionVisualSet, GanttVisualSet, HeatmapVisualSet

public abstract class LabeledVisualSet<T> extends VisualSet<T>
Class that is the parent for all visual sets drawn on the chart by rectangles with labels on it.
Author:
Aleksey Kirillov
  • Field Details

  • Constructor Details

    • LabeledVisualSet

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

    • setLabelText

      public LabeledVisualSet<T> setLabelText(LabelSide labelSide, Function<? extends T,String> labelTextExtractor, Function<? extends T,Double> labelFontSizeExtractor, Function<? extends T,Color> labelColorExtractor)
      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.
      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
    • getLabelSides

      public List<LabelSide> getLabelSides()
      Returns list of all LabelSide for which at least one text label is specified.
      Returns:
      list of all LabelSide for which at least one text label is specified
    • getLabelText

      public String getLabelText(T element, LabelSide labelSide)
      Returns the text of the label drawn for the specified data element and LabelSide. Returns an empty string if no label text is specified for the corresponding combination of parameters.
      Parameters:
      element - data element for which the label text is being checked
      labelSide - the LabelSide of rectangle where the corresponding label is drawn
      Returns:
      the font size of the label drawn for the specified parameters, or empty string if no label text is specified for the corresponding combination of parameters
    • getLabelFontSize

      public Double getLabelFontSize(T element, LabelSide labelSide)
      Returns the font size of the label drawn for the specified data element and LabelSide. Returns a zero if no label text is specified for the corresponding combination of parameters.
      Parameters:
      element - data element for which the label font size is being checked
      labelSide - the LabelSide of rectangle where the corresponding label is drawn
      Returns:
      the font size of the label drawn for the specified parameters, or zero if no label text is specified for the corresponding combination of parameters
    • getLabelColor

      public Color getLabelColor(T element, LabelSide labelSide)
      Returns the color of the label drawn for the specified data element and LabelSide. Returns a default white color if no label text is specified for the corresponding combination of parameters.
      Parameters:
      element - data element for which the label text is being checked
      labelSide - the LabelSide of rectangle where the corresponding label is drawn
      Returns:
      the color of the label drawn for the specified parameters, or default white color if no label text is specified for the corresponding combination of parameters