Class Legend<T>

java.lang.Object
com.amalgamasimulation.charts.Legend<T>
Type Parameters:
T - legend item content type

public class Legend<T> extends Object
A chart legend that displays a list of items with symbols in a box.
Author:
Aleksey Kirillov
  • Field Details

    • chartInternal

      protected com.amalgamasimulation.charts.internals.charts.ILegendableChartInternal<T> chartInternal
  • Constructor Details

    • Legend

      protected Legend(com.amalgamasimulation.charts.internals.charts.ILegendableChartInternal<T> chartInternal)
      Constructs a legend for a subclass of ILegendableChartInternal which is the owner of this object
      Parameters:
      chartInternal - a subclass of ILegendableChartInternal which is the owner of this object
  • Method Details

    • getChartInternal

      protected com.amalgamasimulation.charts.internals.charts.ILegendableChartInternal<T> getChartInternal()
    • setVisible

      public Legend<T> setVisible(boolean visible)
      Specifies whether the legend should be drawn.
      Parameters:
      visible - new legend visibility
      Returns:
      true if the legend should be drawn
    • isLegendVisible

      public boolean isLegendVisible()
      Checks whether the legend should be drawn.
      Returns:
      true if the legend should be drawn, false otherwise
    • setFont

      public Legend<T> setFont(javafx.scene.text.Font font)
      Sets the new font to the legend.
      Parameters:
      font - new legend font
      Returns:
      reference to this object
    • setFontSize

      public Legend<T> setFontSize(int fontSize)
      Sets the new font size to the legend.
      Parameters:
      fontSize - new legend font
      Returns:
      reference to this object
    • setBackgroundColor

      public Legend<T> setBackgroundColor(Color color)
      Sets the new background color to the legend.
      Parameters:
      color - new legend background color
      Returns:
      reference to this object
    • setBackgroundColor

      public Legend<T> setBackgroundColor(javafx.scene.paint.Color color)
      Sets the new background color to the legend.
      Parameters:
      color - new legend background color
      Returns:
      reference to this object
    • getBackgroundColor

      public javafx.scene.paint.Color getBackgroundColor()
      Returns the background color of the legend.
      Returns:
      the background color of the legend
    • getLegendFont

      public javafx.scene.text.Font getLegendFont()
      Returns the font of the legend.
      Returns:
      the font of the legend
    • getLegendFontSize

      public int getLegendFontSize()
      Returns the font font of the legend.
      Returns:
      the font font of the legend
    • setLegendItemsStatesToDefault

      public Legend<T> setLegendItemsStatesToDefault()
      Resets the set of enabled states of legend items to the default setting. The default setting is {REGULAR, SHADOWED}.
      Returns:
      reference to this object
    • setLegendValuesFormat

      public Legend<T> setLegendValuesFormat(Function<Double,String> format)
      Sets the formatter to legend values, i.e. the function that takes a Double value and produces a String that should be drawn to represent this value.
      Parameters:
      format - new legend values formatter
      Returns:
      reference to this object
    • getLegendValuesFormat

      public Function<Double,String> getLegendValuesFormat()
      Returns the formatter of the legend values, i.e. the function that takes a Double value and produces a String that should be drawn to represent this value.
      Returns:
      the formatter of the legend values
    • getLegendItemState

      public LegendItemState getLegendItemState(T legendItem)
      Returns the current state of legend item.
      Parameters:
      legendItem - checked legend item
      Returns:
      legend item state, one of the list [SHADOWED, REGULAR, HIDDEN]
    • setLegendItemState

      public Legend<T> setLegendItemState(T legendItem, LegendItemState state)
      Sets the new state to legend item. Redraws the chart to refresh its contents, axis and legend.
      Parameters:
      legendItem - legend item for which the state changes
      state - legend item state, one of the list [SHADOWED, REGULAR, HIDDEN]
      Returns:
      reference to this object
      See Also:
    • setShadowedLegendItemStateEnabled

      public Legend<T> setShadowedLegendItemStateEnabled(boolean enabled)
      Specifies the enabled SHADOWED state of legend items.
      Parameters:
      enabled - new SHADOWED state enabled status
      Returns:
      reference to this object
    • isShadowedLegendItemStateEnabled

      public boolean isShadowedLegendItemStateEnabled()
      Checks if SHADOWED state of legend items is enabled.
      Returns:
      true if SHADOWED state of legend items is enabled, false otherwise
    • setHiddenLegendItemStateEnabled

      public Legend<T> setHiddenLegendItemStateEnabled(boolean enabled)
      Specifies the enabled HIDDEN state of legend items.
      Parameters:
      enabled - new HIDDEN state enabled status
      Returns:
      reference to this object
    • setHiddenVisualSetsStackingPolicy

      public Legend<T> setHiddenVisualSetsStackingPolicy(HiddenVisualSetsStackingPolicy hiddenVisualSetsStackingPolicy)
      Specifies the stacking policy of visual sets HIDDEN state of legend items.
      Parameters:
      hiddenVisualSetsStackingPolicy - new stacking policy
      Returns:
      reference to this object
    • getHiddenVisualSetsStackingPolicy

      public HiddenVisualSetsStackingPolicy getHiddenVisualSetsStackingPolicy()
      Returns the current stacking policy of visual sets HIDDEN state of legend items.
      Returns:
      the current stacking policy of visual sets HIDDEN state of legend items
    • isHiddenLegendItemStateEnabled

      public boolean isHiddenLegendItemStateEnabled()
      Checks if HIDDEN state of legend items is enabled.
      Returns:
      true if HIDDEN state of legend items is enabled to this object, false otherwise
    • addLegendItemStateHandler

      public Legend<T> addLegendItemStateHandler(Consumer<LegendItemStateChangeDescriptor<T>> handler)
      Adds the action to be executed every time the legend item state changed.
      Parameters:
      handler - new legend item state change action
      Returns:
      reference to this object
    • removeLegendItemStateHandler

      public Legend<T> removeLegendItemStateHandler(Consumer<LegendItemStateChangeDescriptor<T>> handler)
      Removes the legend item state change action.
      Parameters:
      handler - removed legend item state change action
      Returns:
      reference to this object
    • clearLegendItemStateHandler

      public Legend<T> clearLegendItemStateHandler()
      Clear all the legend item state change actions.
      Returns:
      reference to this object