Package com.amalgamasimulation.charts
Class Legend<T>
java.lang.Object
com.amalgamasimulation.charts.Legend<T>
- Type Parameters:
T- legend item content type
A chart legend that displays a list of items with symbols in a box.
- Author:
- Aleksey Kirillov
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.amalgamasimulation.charts.internals.charts.ILegendableChartInternal<T> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds the action to be executed every time the legend item state changed.Clear all the legend item state change actions.javafx.scene.paint.ColorReturns the background color of the legend.protected com.amalgamasimulation.charts.internals.charts.ILegendableChartInternal<T> Returns the current stacking policy of visual sets HIDDEN state of legend items.javafx.scene.text.FontReturns the font of the legend.intReturns the font font of the legend.getLegendItemState(T legendItem) Returns the current state of legend item.Returns the formatter of the legend values, i.e.booleanChecks if HIDDEN state of legend items is enabled.booleanChecks whether the legend should be drawn.booleanChecks if SHADOWED state of legend items is enabled.Removes the legend item state change action.setBackgroundColor(Color color) Sets the new background color to the legend.setBackgroundColor(javafx.scene.paint.Color color) Sets the new background color to the legend.setFont(javafx.scene.text.Font font) Sets the new font to the legend.setFontSize(int fontSize) Sets the new font size to the legend.setHiddenLegendItemStateEnabled(boolean enabled) Specifies the enabled HIDDEN state of legend items.setHiddenVisualSetsStackingPolicy(HiddenVisualSetsStackingPolicy hiddenVisualSetsStackingPolicy) Specifies the stacking policy of visual sets HIDDEN state of legend items.Resets the set of enabled states of legend items to the default setting.setLegendItemState(T legendItem, LegendItemState state) Sets the new state to legend item.setLegendValuesFormat(Function<Double, String> format) Sets the formatter to legend values, i.e.setShadowedLegendItemStateEnabled(boolean enabled) Specifies the enabled SHADOWED state of legend items.setVisible(boolean visible) Specifies whether the legend should be drawn.
-
Field Details
-
chartInternal
-
-
Constructor Details
-
Legend
protected Legend(com.amalgamasimulation.charts.internals.charts.ILegendableChartInternal<T> chartInternal) Constructs a legend for a subclass ofILegendableChartInternalwhich is the owner of this object- Parameters:
chartInternal- a subclass ofILegendableChartInternalwhich is the owner of this object
-
-
Method Details
-
getChartInternal
protected com.amalgamasimulation.charts.internals.charts.ILegendableChartInternal<T> getChartInternal() -
setVisible
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:
trueif the legend should be drawn,falseotherwise
-
setFont
Sets the new font to the legend.- Parameters:
font- new legend font- Returns:
- reference to this object
-
setFontSize
Sets the new font size to the legend.- Parameters:
fontSize- new legend font- Returns:
- reference to this object
-
setBackgroundColor
Sets the new background color to the legend.- Parameters:
color- new legend background color- Returns:
- reference to this object
-
setBackgroundColor
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
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
Sets the formatter to legend values, i.e. the function that takes aDoublevalue and produces aStringthat should be drawn to represent this value.- Parameters:
format- new legend values formatter- Returns:
- reference to this object
-
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
Returns the current state of legend item.- Parameters:
legendItem- checked legend item- Returns:
- legend item state, one of the list [SHADOWED, REGULAR, HIDDEN]
-
setLegendItemState
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 changesstate- legend item state, one of the list [SHADOWED, REGULAR, HIDDEN]- Returns:
- reference to this object
- See Also:
-
setShadowedLegendItemStateEnabled
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:
trueif SHADOWED state of legend items is enabled,falseotherwise
-
setHiddenLegendItemStateEnabled
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
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:
trueif HIDDEN state of legend items is enabled to this object,falseotherwise
-
addLegendItemStateHandler
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
Removes the legend item state change action.- Parameters:
handler- removed legend item state change action- Returns:
- reference to this object
-
clearLegendItemStateHandler
Clear all the legend item state change actions.- Returns:
- reference to this object
-