Class BarLabeledVisualSet<T,C>

java.lang.Object
com.amalgamasimulation.visualsets.VisualSet<T>
com.amalgamasimulation.visualsets.BarLabeledVisualSet<T,C>
Type Parameters:
T - visual set data elements type
C - data categories type
All Implemented Interfaces:
IUpdatePolicyPropertyOwner, IAbstractChartVisualSet
Direct Known Subclasses:
BarVisualSet, HistogramVisualSet

public abstract class BarLabeledVisualSet<T,C> extends VisualSet<T>
Class that is the parent for all visual sets drawn as bar charts with labels on it.
Author:
Aleksey Kirillov
  • Field Details

  • Constructor Details

    • BarLabeledVisualSet

      public BarLabeledVisualSet(String name, Supplier<List<T>> dataElementsProvider, Function<T,Double> argumentExtractor)
      Constructs a BarLabeledVisualSet 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 BarLabeledVisualSet<T,C> setLabelText(LabelSide labelSide, BiFunction<T,C,String> labelTextExtractor, BiFunction<T,C,Double> labelFontSizeExtractor, BiFunction<T,C,Color> labelColorExtractor)
      Sets the labels of the bars representing plot data elements. The label of each bar is set independently of the labels on other sides of this bar or the labels on other bars. The label will not be displayed if the specified text is empty.
      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
      labelColorExtractor - the color of the label
      Returns:
      reference to this object
    • setBarLabelText

      public BarLabeledVisualSet<T,C> setBarLabelText(Function<T,String> barLabelTextExtractor)
      Sets the label text for each visual element. This label is displayed above the corresponding bars.
      Parameters:
      barLabelTextExtractor - the text of the bar label
      Returns:
      reference to this object
    • setBarLabelFontSize

      public BarLabeledVisualSet<T,C> setBarLabelFontSize(Function<T,Double> barLabelFontSizeExtractor)
      Sets the label font size for each visual element. This label is displayed above the corresponding bars.
      Parameters:
      barLabelFontSizeExtractor - the font size of the bar label
      Returns:
      reference to this object
    • setBarLabelColor

      public BarLabeledVisualSet<T,C> setBarLabelColor(Function<T,Color> barLabelColorExtractor)
      Sets the label color for each visual element. This label is displayed above the corresponding bars.
      Parameters:
      barLabelColorExtractor - the color of the bar label
      Returns:
      reference to this object
    • getBarLabelText

      public String getBarLabelText(T element)
      Returns the bar label text for given data element.
      Parameters:
      element - data element for which the bar label text is being checked
      Returns:
      the bar label text for given data element.
    • getBarLabelFontSize

      public double getBarLabelFontSize(T element)
      Returns the bar label font size for given data element.
      Parameters:
      element - data element for which the bar label font size is being checked
      Returns:
      the bar label font size for given data element.
    • getBarLabelColor

      public Color getBarLabelColor(T element)
      Returns the bar label color for given data element.
      Parameters:
      element - data element for which the bar label color is being checked
      Returns:
      the bar label color for given data element.
    • 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, C category, LabelSide labelSide)
      Returns the text of the label drawn for the specified data element, category, 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
      category - data category for which the label text is being checked
      labelSide - the LabelSide of bar 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, C category, LabelSide labelSide)
      Returns the font size of the label drawn for the specified data element, category, 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
      category - data category for which the label font size is being checked
      labelSide - the LabelSide of bar 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, C category, LabelSide labelSide)
      Returns the color of the label drawn for the specified data element, category, 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
      category - data category for which the label text is being checked
      labelSide - the LabelSide of bar 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