Class BarVisualSet<T,C>
java.lang.Object
com.amalgamasimulation.charts.visualsets.VisualSet<T>
com.amalgamasimulation.charts.visualsets.BarLabeledVisualSet<T,C>
com.amalgamasimulation.charts.visualsets.BarVisualSet<T,C>
- Type Parameters:
T- visual set data elements typeC- data categories type
- All Implemented Interfaces:
IAbstractBarVisualSet<T,,C> IUpdatePolicyPropertyOwner,IAbstractChartVisualSet,IBarChartVisualSet
- Direct Known Subclasses:
WaterfallVisualSet
public class BarVisualSet<T,C>
extends BarLabeledVisualSet<T,C>
implements IAbstractBarVisualSet<T,C>, IBarChartVisualSet
Visual set for drawing bars.
Can be drawn on AbstractBarChart.
Used to draw the statistical data by categories.
- Author:
- Aleksey Kirillov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassInternal class that represents visual element for bar data element.Nested classes/interfaces inherited from class com.amalgamasimulation.charts.visualsets.BarLabeledVisualSet
BarLabeledVisualSet.BarLabeledVisualElementNested classes/interfaces inherited from class com.amalgamasimulation.charts.visualsets.VisualSet
VisualSet.ContextMenuHandler<T>, VisualSet.UpdatePolicy, VisualSet.VisualElement -
Field Summary
Fields inherited from class com.amalgamasimulation.charts.visualsets.BarLabeledVisualSet
barLabelColorExtractor, barLabelFontSizeExtractor, barLabelTextExtractor, labelColorExtractors, labelFontSizeExtractors, labelTextExtractorsFields inherited from class com.amalgamasimulation.charts.visualsets.VisualSet
argumentExtractor, contentsToBeginArguments, contentsToEndArguments, contentsToVisualElements, contextMenuHandlers, dataElementsProvider, listeners, maxArgument, maxValueCache, minArgument, minValueCache, mouseEnterHandlers, mouseExitHandlers, mousePressedHandlers, mouseTransparent, name, needsUpdate, oldContentsList, tooltipTextExtractor, updatePolicy, visibilityChangeHandlers, visualElementsList -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddContextMenuHandler(VisualSet.ContextMenuHandler<T> contextMenuHandler) Adds the action to be executed every time a context menu for given data element is called.addMouseEnterHandler(BiConsumer<T, javafx.scene.input.MouseEvent> handler) Adds the action to be executed every time mouse enters to any visual element borders.addMouseExitHandler(BiConsumer<T, javafx.scene.input.MouseEvent> handler) Adds the action to be executed every time the mouse exits the previously entered element's bounds.addMousePressedHandler(BiConsumer<T, javafx.scene.input.MouseEvent> handler) Adds the action to be executed every time a mouse button is pressed.addVisibilityChangeHandler(Consumer<VisibilityChangeDescriptor<? extends IAbstractChartVisualSet>> visibilityChangeHandler) Adds the action to be executed every time the visibility of this VisualSet is changed.createVisualElement(T contents) Creates a new instance ofVisualSet<T>.VisualElementcorresponding to the current VisualSet type.getBackgroundColor(C category) Returns the background color for given category.getBorderColor(C category) Returns the border color for given category.doublegetBorderWidth(C category) Returns the border width in pixels for given category.Returns the list of data categories.doubleReturns the width fraction to region allocated for each individual category-bar.getElementText(T element) Returns the label text for each data element.getLegendLabelText(C category) Returns the legend label text for given category.doubleReturns the maximum possible value that stored in the current data elements list.doubleReturns the maximum value for any data group within all existed data elements.doublegetMaxGroupValue(Predicate<C> categoryPredicate) Returns the maximum value for any data group within all existed data elements.doubleReturns the maximum value for any category within all existed data elements.doublegetMaxValueByAnyCategory(Predicate<C> categoryPredicate) Returns the maximum value between given filtered categories within all existed data elements.doubleReturns the minimum possible value that stored in the current data elements list.doubleReturns the ratio of the value for the maximum group to the total sum of the all values across the entire statistics.doublegetPercentOfMaxValue(Predicate<C> categoryPredicate) Returns the ratio of the value for the maximum group to the total sum of the all values across the entire statistics.doublegetSummaryValue(T element) Returns the total value for all categories within the given data element.doublegetSummaryValue(T element, Predicate<C> categoryPredicate) Returns the total value for specified categories within the specified data element.doubleReturns the value for given category within the given data element.getVisualElements(boolean recalculationRequired) Returns the list of visual elements corresponding to current data elements.doubleReturns the fraction width of the region in which category-bars are drawn.setBackgroundColor(Function<C, Color> backgroundColorExtractor) Sets the background color for each category.setBarLabelColor(Function<T, Color> barLabelColorExtractor) Sets the label color for each visual element.setBarLabelFontSize(Function<T, Double> barLabelFontSizeExtractor) Sets the label font size for each visual element.setBarLabelText(Function<T, String> barLabelTextExtractor) Sets the label text for each visual element.setBorderColor(Function<C, Color> borderColorExtractor) Sets the border color for each category.setBorderWidth(Function<C, Double> borderWidthExtractor) Sets the border width in pixels for each category.setCategoriesComparator(Comparator<C> categoriesComparator) Specifies the comparator used to sort the categories.setColumnWidthFraction(double columnWidthFraction) Sets the width fraction to region allocated for each individual category-bar.setElementText(Function<T, String> elementTextExtractor) Sets the label text for each data element.setLabelText(LabelSide labelSide, BiFunction<T, C, String> labelText, BiFunction<T, C, Double> labelTextSize, BiFunction<T, C, Color> labelTextColor) Sets the labels of the bars representing plot data elements.setLegendLabelText(Function<C, String> legendLabelTextExtractor) Sets the legend label text for each category.setMouseTransparent(boolean mouseTransparent) Sets the value of the property mouseTransparent.setTooltipText(Function<T, String> tooltipTextExtractor) Adds tooltip text to display when the mouse is hovered over a visual element representing given data element.setUpdatePolicy(VisualSet.UpdatePolicy updatePolicy) Sets the newVisualSet.UpdatePolicyi.e.setVisualWidthFraction(double visualWidthFraction) Sets the fraction width of the region in which bars are drawn.Methods inherited from class com.amalgamasimulation.charts.visualsets.BarLabeledVisualSet
getBarLabelColor, getBarLabelFontSize, getBarLabelText, getLabelColor, getLabelFontSize, getLabelSides, getLabelTextMethods inherited from class com.amalgamasimulation.charts.visualsets.VisualSet
addVisualElement, addVisualElement, addVisualSetChangeHandler, clearDependencies, getArgument, getContents, getContextMenuHandlers, getDataElements, getInjectionIndex, getMouseEnterHandlers, getMouseExitHandlers, getMousePressedHandlers, getName, getTooltipText, getUpdatePolicy, getVisibilityChangeHandlers, getVisibleVisualElementIndex, getVisibleVisualElementsCount, isMouseTransparent, isNeedsUpdate, recalculateVisualElements, removeContextMenuHandler, removeMouseEnterHandler, removeMouseExitHandler, removeMousePressedHandler, removeVisibilityChangeHandler, removeVisualElement, removeVisualSetChangeHandler, sortVisualElements, toString, update, updateMinMaxArgumentsValuesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.amalgamasimulation.charts.visualsets.types.IAbstractChartVisualSet
addVisualSetChangeHandler, getContents, getName, getUpdatePolicy, getVisibilityChangeHandlers, getVisibleVisualElementsCount, isMouseTransparent, removeVisibilityChangeHandler, removeVisualSetChangeHandler
-
Constructor Details
-
BarVisualSet
public BarVisualSet(String name, Supplier<List<T>> dataElementsProvider, BiFunction<T, C, Double> valueExtractor, List<C> categories) Constructs a BarVisualSet with given name, data elements, categories and value extractor, i.e. a function that specifies the rule for extracting a value from a data element.- Parameters:
name- visual set name is used to sort and name the visual sets on the chartdataElementsProvider- data elements list provider. The provider is invalidated every time the chart is beging redrawncategories- the list of data categories
-
-
Method Details
-
setColumnWidthFraction
Sets the width fraction to region allocated for each individual category-bar. Note than depending on the type ofBarsLayout, the visual can be drawn with category-bars stacked on top of each other or a series of category-bars in a row. The fraction is applied to the region calculation results for each data element with respect to summary bars width fraction, set by the callsetVisualWidthFraction(double). The resulting region is divided by the number of category-bars arranged in a row horizontally and then the width of each bar is multiplied by columnWidthFraction.The value must be greater than zero and not greater than 1.
The default value is 0.8.
- Parameters:
columnWidthFraction-- Returns:
- reference to this object
-
setVisualWidthFraction
Sets the fraction width of the region in which bars are drawn. Fraction is calculated relative to the width of the region allocated for each data element. By controlling this parameter, the total width of the bars region is configured, in which bars can be drawn. As a result the width of the bars themselves can be adjusted.The value must be greater than zero and not greater than 1.
The default value is 0.8.
- Parameters:
visualWidthFraction- the fraction width of the region in which bars are drawn- Returns:
- reference to this object
-
setCategoriesComparator
Specifies the comparator used to sort the categories. Sorting affects the display order of the bars and the order of the legend elements.- Parameters:
categoriesComparator- the comparator used to sort the categories- Returns:
- reference to this object
-
getVisualWidthFraction
public double getVisualWidthFraction()Returns the fraction width of the region in which category-bars are drawn.- Returns:
- the fraction width of the region in which category-bars are drawn
-
getColumnWidthFraction
public double getColumnWidthFraction()Description copied from interface:IAbstractBarVisualSetReturns the width fraction to region allocated for each individual category-bar.- Specified by:
getColumnWidthFractionin interfaceIAbstractBarVisualSet<T,C> - Returns:
- the width fraction to region allocated for each individual category-bar
-
setElementText
Description copied from interface:IAbstractBarVisualSetSets the label text for each data element. This label is displayed on the ticks of the X-axis, below the corresponding bars.- Specified by:
setElementTextin interfaceIAbstractBarVisualSet<T,C> - Parameters:
elementTextExtractor- the text of the bar label- Returns:
- reference to this object
-
getElementText
Description copied from interface:IAbstractBarVisualSetReturns the label text for each data element.- Specified by:
getElementTextin interfaceIAbstractBarVisualSet<T,C> - Parameters:
element- data element for which the label text is being checked- Returns:
- the label text for each data element
-
setLegendLabelText
Description copied from interface:IAbstractBarVisualSetSets the legend label text for each category.- Specified by:
setLegendLabelTextin interfaceIAbstractBarVisualSet<T,C> - Parameters:
legendLabelTextExtractor- the legend label text extractor, i.e. method returning text depending on the category- Returns:
- reference to this object
-
setBackgroundColor
Description copied from interface:IAbstractBarVisualSetSets the background color for each category. The color may be different for different categories and it does not depend on different data elements. Also used to display a color icon in theLegend.- Specified by:
setBackgroundColorin interfaceIAbstractBarVisualSet<T,C> - Parameters:
backgroundColorExtractor- the background color extractor, i.e. method returning color depending on the category- Returns:
- reference to this object
-
setBorderColor
Description copied from interface:IAbstractBarVisualSetSets the border color for each category. The color may be different for different categories and it does not depend on different data elements.- Specified by:
setBorderColorin interfaceIAbstractBarVisualSet<T,C> - Parameters:
borderColorExtractor- the border color extractor, i.e. method returning color depending on the category- Returns:
- reference to this object
-
setBorderWidth
Description copied from interface:IAbstractBarVisualSetSets the border width in pixels for each category. The width may be different for different categories and it does not depend on different data elements.- Specified by:
setBorderWidthin interfaceIAbstractBarVisualSet<T,C> - Parameters:
borderWidthExtractor- the border width extractor, i.e. method returning the width depending on the category- Returns:
- reference to this object
-
setTooltipText
Description copied from class:VisualSetAdds tooltip text to display when the mouse is hovered over a visual element representing given data element.- Specified by:
setTooltipTextin classVisualSet<T>- Parameters:
tooltipTextExtractor- a function that specifies the rule for extracting a tooltip text from a data element- Returns:
- reference to this object
-
setUpdatePolicy
Description copied from interface:IAbstractChartVisualSetSets the newVisualSet.UpdatePolicyi.e. the VisualSet update control rule.- Specified by:
setUpdatePolicyin interfaceIAbstractChartVisualSet- Specified by:
setUpdatePolicyin interfaceIUpdatePolicyPropertyOwner- Overrides:
setUpdatePolicyin classVisualSet<T>- Parameters:
updatePolicy- newVisualSet.UpdatePolicyi.e. the VisualSet update control rule- Returns:
- reference to this object
-
getCategories
Description copied from interface:IAbstractBarVisualSetReturns the list of data categories.- Specified by:
getCategoriesin interfaceIAbstractBarVisualSet<T,C> - Returns:
- the list of data categories
-
getBackgroundColor
Description copied from interface:IAbstractBarVisualSetReturns the background color for given category.- Specified by:
getBackgroundColorin interfaceIAbstractBarVisualSet<T,C> - Parameters:
category- category for which the background color is being checked- Returns:
- the background color for given category
-
getBorderColor
Description copied from interface:IAbstractBarVisualSetReturns the border color for given category.- Specified by:
getBorderColorin interfaceIAbstractBarVisualSet<T,C> - Parameters:
category- category for which the border color is being checked- Returns:
- the border color for given category
-
getBorderWidth
Description copied from interface:IAbstractBarVisualSetReturns the border width in pixels for given category.- Specified by:
getBorderWidthin interfaceIAbstractBarVisualSet<T,C> - Parameters:
category- category for which the border width in pixels is being checked- Returns:
- the border width in pixels for given category
-
getLegendLabelText
Description copied from interface:IAbstractBarVisualSetReturns the legend label text for given category.- Specified by:
getLegendLabelTextin interfaceIAbstractBarVisualSet<T,C> - Parameters:
category- category for which the legend label text is being checked- Returns:
- the legend label text for given category
-
setBarLabelText
Description copied from class:BarLabeledVisualSetSets the label text for each visual element. This label is displayed above the corresponding bars.- Overrides:
setBarLabelTextin classBarLabeledVisualSet<T,C> - Parameters:
barLabelTextExtractor- the text of the bar label- Returns:
- reference to this object
-
setBarLabelFontSize
Description copied from class:BarLabeledVisualSetSets the label font size for each visual element. This label is displayed above the corresponding bars.- Overrides:
setBarLabelFontSizein classBarLabeledVisualSet<T,C> - Parameters:
barLabelFontSizeExtractor- the font size of the bar label- Returns:
- reference to this object
-
setBarLabelColor
Description copied from class:BarLabeledVisualSetSets the label color for each visual element. This label is displayed above the corresponding bars.- Overrides:
setBarLabelColorin classBarLabeledVisualSet<T,C> - Parameters:
barLabelColorExtractor- the color of the bar label- Returns:
- reference to this object
-
setMouseTransparent
Description copied from interface:IAbstractChartVisualSetSets 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:
setMouseTransparentin interfaceIAbstractChartVisualSet- Overrides:
setMouseTransparentin classVisualSet<T>- Parameters:
mouseTransparent- new value of property mouseTransparent- Returns:
- reference to this object
-
getMinArgument
public double getMinArgument()Description copied from interface:IAbstractChartVisualSetReturns the minimum possible value that stored in the current data elements list.- Specified by:
getMinArgumentin interfaceIAbstractBarVisualSet<T,C> - Specified by:
getMinArgumentin interfaceIAbstractChartVisualSet- Overrides:
getMinArgumentin classVisualSet<T>- Returns:
- the minimum possible value that stored in the current data elements list
-
getMaxArgument
public double getMaxArgument()Description copied from interface:IAbstractChartVisualSetReturns the maximum possible value that stored in the current data elements list.- Specified by:
getMaxArgumentin interfaceIAbstractBarVisualSet<T,C> - Specified by:
getMaxArgumentin interfaceIAbstractChartVisualSet- Overrides:
getMaxArgumentin classVisualSet<T>- Returns:
- the maximum possible value that stored in the current data elements list
-
getPercentOfMaxValue
public double getPercentOfMaxValue()Description copied from interface:IAbstractBarVisualSetReturns the ratio of the value for the maximum group to the total sum of the all values across the entire statistics.- Specified by:
getPercentOfMaxValuein interfaceIAbstractBarVisualSet<T,C> - Returns:
- the ratio of the value for the maximum group to the total sum of the all values across the entire statistics
-
getPercentOfMaxValue
Description copied from interface:IAbstractBarVisualSetReturns the ratio of the value for the maximum group to the total sum of the all values across the entire statistics.Considers only the categories filtered by the corresponding predicate.
- Specified by:
getPercentOfMaxValuein interfaceIAbstractBarVisualSet<T,C> - Parameters:
categoryPredicate- filter for categories for which the ratio is calculated- Returns:
- the ratio of the value for the maximum group to the total sum of the all values across the entire statistics
-
getValue
Description copied from interface:IAbstractBarVisualSetReturns the value for given category within the given data element.- Specified by:
getValuein interfaceIAbstractBarVisualSet<T,C> - Parameters:
element- data element for which the total value is being checkedcategory- category for which the total value is being checked- Returns:
- the value for given category within the given data element
-
getSummaryValue
Description copied from interface:IAbstractBarVisualSetReturns the total value for all categories within the given data element.- Specified by:
getSummaryValuein interfaceIAbstractBarVisualSet<T,C> - Parameters:
element- data element for which the total value is being checked- Returns:
- the total value for all categories within the given date element
-
getSummaryValue
Description copied from interface:IAbstractBarVisualSetReturns the total value for specified categories within the specified data element.- Specified by:
getSummaryValuein interfaceIAbstractBarVisualSet<T,C> - Parameters:
element- data element for which the total value is being checkedcategoryPredicate- filter for categories for which the amount is calculated- Returns:
- the total value for specified categories within the specified data element
-
getMaxGroupValue
public double getMaxGroupValue()Description copied from interface:IAbstractBarVisualSetReturns the maximum value for any data group within all existed data elements. The data group in the case of a histogram is the range of the X-axis arguments, and in the case of a bar chart, each individual data element.- Specified by:
getMaxGroupValuein interfaceIAbstractBarVisualSet<T,C> - Returns:
- the maximum value for any data group within all existed data elements
-
getMaxGroupValue
Description copied from interface:IAbstractBarVisualSetReturns the maximum value for any data group within all existed data elements.The data group in the case of a histogram is the range of the X-axis arguments, and in the case of a bar chart, each individual data element.
Considers only the categories filtered by the corresponding predicate.
- Specified by:
getMaxGroupValuein interfaceIAbstractBarVisualSet<T,C> - Parameters:
categoryPredicate- filter for categories for which the maximum value is calculated- Returns:
- the maximum value for any data group within all existed data elements
-
getMaxValueByAnyCategory
public double getMaxValueByAnyCategory()Description copied from interface:IAbstractBarVisualSetReturns the maximum value for any category within all existed data elements.- Specified by:
getMaxValueByAnyCategoryin interfaceIAbstractBarVisualSet<T,C> - Returns:
- the maximum value for any category within all existed data elements
-
getMaxValueByAnyCategory
Description copied from interface:IAbstractBarVisualSetReturns the maximum value between given filtered categories within all existed data elements.- Specified by:
getMaxValueByAnyCategoryin interfaceIAbstractBarVisualSet<T,C> - Parameters:
categoryPredicate- filter for categories for which the maximum value is calculated- Returns:
- the maximum value between given filtered categories within all existed data elements
-
setLabelText
public BarVisualSet<T,C> setLabelText(LabelSide labelSide, BiFunction<T, C, String> labelText, BiFunction<T, C, Double> labelTextSize, BiFunction<T, C, Color> labelTextColor) Description copied from class:BarLabeledVisualSetSets 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.- Overrides:
setLabelTextin classBarLabeledVisualSet<T,C> - Parameters:
labelSide- theLabelSideof bar where the corresponding label will be drawnlabelText- the text of the labellabelTextSize- the font size of the labellabelTextColor- the color of the label- Returns:
- reference to this object
-
addContextMenuHandler
Description copied from class:VisualSetAdds the action to be executed every time a context menu for given data element is called.- Overrides:
addContextMenuHandlerin classVisualSet<T>- Parameters:
contextMenuHandler- context menu call action- Returns:
- reference to this object
-
addMouseEnterHandler
Description copied from class:VisualSetAdds the action to be executed every time mouse enters to any visual element borders.- Overrides:
addMouseEnterHandlerin classVisualSet<T>- Parameters:
handler- new mouse enter action- Returns:
- reference to this object
-
addMouseExitHandler
Description copied from class:VisualSetAdds the action to be executed every time the mouse exits the previously entered element's bounds.- Overrides:
addMouseExitHandlerin classVisualSet<T>- Parameters:
handler- new mouse exit action- Returns:
- reference to this object
-
addMousePressedHandler
public BarVisualSet<T,C> addMousePressedHandler(BiConsumer<T, javafx.scene.input.MouseEvent> handler) Description copied from class:VisualSetAdds the action to be executed every time a mouse button is pressed.- Overrides:
addMousePressedHandlerin classVisualSet<T>- Parameters:
handler- new mouse button pressed action- Returns:
- reference to this object
-
addVisibilityChangeHandler
public BarVisualSet<T,C> addVisibilityChangeHandler(Consumer<VisibilityChangeDescriptor<? extends IAbstractChartVisualSet>> visibilityChangeHandler) Description copied from interface:IAbstractChartVisualSetAdds the action to be executed every time the visibility of this VisualSet is changed.- Specified by:
addVisibilityChangeHandlerin interfaceIAbstractChartVisualSet- Overrides:
addVisibilityChangeHandlerin classVisualSet<T>- Parameters:
visibilityChangeHandler- visibility change action- Returns:
- reference to this object
-
getVisualElements
Description copied from interface:IAbstractChartVisualSetReturns the list of visual elements corresponding to current data elements. Cannot be changed by the user.- Specified by:
getVisualElementsin interfaceIAbstractBarVisualSet<T,C> - Specified by:
getVisualElementsin interfaceIAbstractChartVisualSet- Specified by:
getVisualElementsin interfaceIBarChartVisualSet- Overrides:
getVisualElementsin classVisualSet<T>- Parameters:
recalculationRequired- flag of the need to recalculate the visual elements- Returns:
- the list of visual elements corresponding to current data elements
-
createVisualElement
Description copied from class:VisualSetCreates a new instance ofVisualSet<T>.VisualElementcorresponding to the current VisualSet type.- Specified by:
createVisualElementin classVisualSet<T>- Parameters:
contents- data element for which theVisualSet<T>.VisualElementis being checked- Returns:
- a new instance of
VisualSet<T>.VisualElementcorresponding to the current VisualSet type
-