Class VisualSet<T>
java.lang.Object
com.amalgamasimulation.charts.visualsets.VisualSet<T>
- Type Parameters:
T- visual set data elements type
- All Implemented Interfaces:
IUpdatePolicyPropertyOwner,IAbstractChartVisualSet
- Direct Known Subclasses:
AbstractGridLineVisualSet,AbstractLineVisualSet,BarLabeledVisualSet,BoxAndWhiskerVisualSet,ConnectionVisualSet,LabeledVisualSet,LineBarVisualSet,PointsVisualSet,TriangleMarkerVisualSet
public abstract class VisualSet<T>
extends Object
implements IAbstractChartVisualSet, IUpdatePolicyPropertyOwner
Abstract parent class for all visual sets. A visual set is an object that
knows how to extract the data from some source and how to present it on a
specific chart. Note that visual sets do not store the data. Visual sets
provide the information about colors, number formats, line widths of plots,
etc.
Typically, a visual set takes a collection of data elements and contains a set of extractor methods that specify how to extract colors, text labels, etc from these data elements.
- Author:
- Aleksey Kirillov
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceContext menu open event handler.static enumEnumeration that determines a policy of how the visual set is updated in response to an update of underlying collection of visual elements corresponding data elements.classInternal class that represents visual element for a data element. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<T, VisualSet<T>.VisualElement> protected List<VisualSet.ContextMenuHandler<T>> protected List<IVisualSetListener> protected doubleprotected doubleprotected doubleprotected doubleprotected List<BiConsumer<T, javafx.scene.input.MouseEvent>> protected List<BiConsumer<T, javafx.scene.input.MouseEvent>> protected List<BiConsumer<T, javafx.scene.input.MouseEvent>> protected booleanprotected Stringprotected booleanprotected VisualSet.UpdatePolicyprotected List<Consumer<VisibilityChangeDescriptor<? extends IAbstractChartVisualSet>>> protected List<VisualSet<T>.VisualElement> -
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.protected voidaddVisualElement(int injectionIndex, VisualSet<T>.VisualElement visualElement) protected voidaddVisualElement(VisualSet<T>.VisualElement visualElement) voidAdds the action to be executed every time the elements list of this VisualSet is changed.protected voidclearDependencies(VisualSet<T>.VisualElement visualElement) abstract VisualSet<T>.VisualElementcreateVisualElement(T contents) Creates a new instance ofVisualSet<T>.VisualElementcorresponding to the current VisualSet type.doublegetArgument(T element) Returns the argument for given data element.Returns the list of visual set contents.Return the list of the actions to be executed every time a context menu for given data element is called.Returns the actual list of all data elements.protected intgetInjectionIndex(List<VisualSet<T>.VisualElement> list, VisualSet<T>.VisualElement element, T contents, int contentsIndex, Map<VisualSet<T>.VisualElement, Double> beginArgumentsCache) doubleReturns the maximum possible value that stored in the current data elements list.doubleReturns the minimum possible value that stored in the current data elements list.List<BiConsumer<T, javafx.scene.input.MouseEvent>> Returns the list of the actions to be executed every time a mouse enters to any visual element borders.List<BiConsumer<T, javafx.scene.input.MouseEvent>> Returns the list of the actions to be executed every time the mouse exits the previously entered element's bounds.List<BiConsumer<T, javafx.scene.input.MouseEvent>> Return the list of the actions to be executed every time a mouse button is pressed.getName()Returns visual set name i.e.getTooltipText(T element) Returns the text that is displayed on the popup tooltip above the visual element that represents the given data element.Return the currentVisualSet.UpdatePolicy.List<Consumer<VisibilityChangeDescriptor<? extends IAbstractChartVisualSet>>> Return the list of the actions to be executed every time the visibility of this VisualSet is changed.protected intgetVisibleVisualElementIndex(double argument, List<? extends VisualSet<T>.VisualElement> visualElements, boolean searchByEndArgument) intgetVisibleVisualElementsCount(double beginArgument, double endArgument) Returns the number of VisualElements drawn within the bounds of the specified begin and end X-axis arguments.List<? extends VisualSet<T>.VisualElement> getVisualElements(boolean recalculationRequired) Returns the list of visual elements corresponding to current data elements.booleanReturns the value of the property mouseTransparent.booleanReturnstrueif VisualSet structure needs to be recalculated.protected voidremoveContextMenuHandler(VisualSet.ContextMenuHandler<T> contextMenuHandler) Removes the action to be executed every time a context menu for given data element is called.removeMouseEnterHandler(BiConsumer<T, javafx.scene.input.MouseEvent> handler) Removes the mouse enter action.removeMouseExitHandler(BiConsumer<T, javafx.scene.input.MouseEvent> handler) Removes the mouse exit action.removeMousePressedHandler(BiConsumer<T, javafx.scene.input.MouseEvent> handler) Removes the previously added mouse button press action.removeVisibilityChangeHandler(Consumer<VisibilityChangeDescriptor<? extends IAbstractChartVisualSet>> visibilityChangeHandler) Removes the action to be executed every time the visibility of this VisualSet is changed.protected voidremoveVisualElement(VisualSet<T>.VisualElement visualElement) voidRemoves the action to be executed every time the elements list of this VisualSet is changed.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.protected voidtoString()voidupdate()Raises the flag of the need for a recalculation of the structure of this VisualSet.protected voidupdateMinMaxArgumentsValues(List<VisualSet<T>.VisualElement> visualElements)
-
Field Details
-
minArgument
protected double minArgument -
maxArgument
protected double maxArgument -
name
-
mouseTransparent
protected boolean mouseTransparent -
updatePolicy
-
needsUpdate
protected boolean needsUpdate -
minValueCache
protected double minValueCache -
maxValueCache
protected double maxValueCache -
dataElementsProvider
-
argumentExtractor
-
tooltipTextExtractor
-
contextMenuHandlers
-
mouseEnterHandlers
-
mouseExitHandlers
-
mousePressedHandlers
-
visibilityChangeHandlers
protected List<Consumer<VisibilityChangeDescriptor<? extends IAbstractChartVisualSet>>> visibilityChangeHandlers -
listeners
-
contentsToVisualElements
-
contentsToBeginArguments
-
contentsToEndArguments
-
oldContentsList
-
visualElementsList
-
-
Constructor Details
-
VisualSet
public VisualSet(String name, Supplier<List<T>> dataElementsProvider, Function<T, Double> argumentExtractor) Constructs a VisualSet 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 chartdataElementsProvider- data elements list provider. The provider is invalidated every time the chart is beging redrawnargumentExtractor- a function that specifies the rule for extracting an argument from a data element
-
-
Method Details
-
setTooltipText
Adds tooltip text to display when the mouse is hovered over a visual element representing given data element.- Parameters:
tooltipTextExtractor- a function that specifies the rule for extracting a tooltip text from a data element- Returns:
- reference to this object
-
createVisualElement
Creates a new instance ofVisualSet<T>.VisualElementcorresponding to the current VisualSet type.- Parameters:
contents- data element for which theVisualSet<T>.VisualElementis being checked- Returns:
- a new instance of
VisualSet<T>.VisualElementcorresponding to the current VisualSet type
-
addMouseEnterHandler
Adds the action to be executed every time mouse enters to any visual element borders.- Parameters:
handler- new mouse enter action- Returns:
- reference to this object
-
removeMouseEnterHandler
Removes the mouse enter action.- Parameters:
handler- new mouse enter action- Returns:
- reference to this object
-
addMouseExitHandler
Adds the action to be executed every time the mouse exits the previously entered element's bounds.- Parameters:
handler- new mouse exit action- Returns:
- reference to this object
-
removeMouseExitHandler
Removes the mouse exit action.- Parameters:
handler- removed mouse exit action- Returns:
- reference to this object
-
addMousePressedHandler
Adds the action to be executed every time a mouse button is pressed.- Parameters:
handler- new mouse button pressed action- Returns:
- reference to this object
-
removeMousePressedHandler
Removes the previously added mouse button press action.- Parameters:
handler- removed mouse button press action- Returns:
- reference to this object
-
getMouseEnterHandlers
Returns the list of the actions to be executed every time a mouse enters to any visual element borders.- Returns:
- the list of the actions to be executed every time a mouse enters to any visual element borders
-
getMouseExitHandlers
Returns the list of the actions to be executed every time the mouse exits the previously entered element's bounds.- Returns:
- the list of the actions to be executed every time the mouse exits the previously entered element's bounds
-
getMousePressedHandlers
Return the list of the actions to be executed every time a mouse button is pressed.- Returns:
- the list of the actions to be executed every time a mouse button is pressed
-
addContextMenuHandler
Adds the action to be executed every time a context menu for given data element is called.- Parameters:
contextMenuHandler- context menu call action- Returns:
- reference to this object
-
removeContextMenuHandler
Removes the action to be executed every time a context menu for given data element is called.- Parameters:
contextMenuHandler- context menu call action- Returns:
- reference to this object
-
getContextMenuHandlers
Return the list of the actions to be executed every time a context menu for given data element is called.- Returns:
- the list of the actions to be executed every time a context menu for given data element is called
-
isNeedsUpdate
public boolean isNeedsUpdate()Returnstrueif VisualSet structure needs to be recalculated.The recalculation will be done the next time the chart requests data from this VisualSet.
- Returns:
trueif VisualSet structure needs to be recalculated,falseotherwise
-
getDataElements
Returns the actual list of all data elements.- Returns:
- the actual list of all data elements
-
getArgument
Returns the argument for given data element. Argument is a numeric value on X-axis in which the visual element for the given data element is located.- Parameters:
element- data element for which the argument for given data element is being checked- Returns:
- the argument for given data element
-
getTooltipText
Returns the text that is displayed on the popup tooltip above the visual element that represents the given data element.- Parameters:
element- data element for which the tooltip text is being checked- Returns:
- the text that is displayed on the popup tooltip
-
update
public void update()Raises the flag of the need for a recalculation of the structure of this VisualSet.The recalculation will be done the next time the chart requests data from this VisualSet.
Recalculation involves updating the list of elements, their sequence, as well as additional properties of their display.
-
getName
Description copied from interface:IAbstractChartVisualSetReturns visual set name i.e. theStringis used to sort and name the visual sets on the chart.- Specified by:
getNamein interfaceIAbstractChartVisualSet- Returns:
- visual set name
-
getMinArgument
public double getMinArgument()Description copied from interface:IAbstractChartVisualSetReturns the minimum possible value that stored in the current data elements list.- Specified by:
getMinArgumentin interfaceIAbstractChartVisualSet- 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 interfaceIAbstractChartVisualSet- Returns:
- the maximum possible value that stored in the current data elements list
-
addVisibilityChangeHandler
public VisualSet<T> 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- Parameters:
visibilityChangeHandler- visibility change action- Returns:
- reference to this object
-
removeVisibilityChangeHandler
public VisualSet<T> removeVisibilityChangeHandler(Consumer<VisibilityChangeDescriptor<? extends IAbstractChartVisualSet>> visibilityChangeHandler) Description copied from interface:IAbstractChartVisualSetRemoves the action to be executed every time the visibility of this VisualSet is changed.- Specified by:
removeVisibilityChangeHandlerin interfaceIAbstractChartVisualSet- Parameters:
visibilityChangeHandler- visibility change action- Returns:
- reference to this object
-
addVisualSetChangeHandler
Description copied from interface:IAbstractChartVisualSetAdds the action to be executed every time the elements list of this VisualSet is changed.- Specified by:
addVisualSetChangeHandlerin interfaceIAbstractChartVisualSet- Parameters:
handler- visibility change action
-
removeVisualSetChangeHandler
Description copied from interface:IAbstractChartVisualSetRemoves the action to be executed every time the elements list of this VisualSet is changed.- Specified by:
removeVisualSetChangeHandlerin interfaceIAbstractChartVisualSet- Parameters:
handler- visibility change action
-
getUpdatePolicy
Description copied from interface:IAbstractChartVisualSetReturn the currentVisualSet.UpdatePolicy.- Specified by:
getUpdatePolicyin interfaceIAbstractChartVisualSet- Specified by:
getUpdatePolicyin interfaceIUpdatePolicyPropertyOwner- Returns:
- the current
VisualSet.UpdatePolicy
-
setUpdatePolicy
Description copied from interface:IAbstractChartVisualSetSets the newVisualSet.UpdatePolicyi.e. the VisualSet update control rule.- Specified by:
setUpdatePolicyin interfaceIAbstractChartVisualSet- Specified by:
setUpdatePolicyin interfaceIUpdatePolicyPropertyOwner- Parameters:
updatePolicy- newVisualSet.UpdatePolicyi.e. the VisualSet update control rule- Returns:
- reference to this object
-
getVisibilityChangeHandlers
public List<Consumer<VisibilityChangeDescriptor<? extends IAbstractChartVisualSet>>> getVisibilityChangeHandlers()Description copied from interface:IAbstractChartVisualSetReturn the list of the actions to be executed every time the visibility of this VisualSet is changed.- Specified by:
getVisibilityChangeHandlersin interfaceIAbstractChartVisualSet- Returns:
- the list of the actions to be executed every time the visibility of this VisualSet is changed
-
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- Parameters:
mouseTransparent- new value of property mouseTransparent- Returns:
- reference to this object
-
isMouseTransparent
public boolean isMouseTransparent()Description copied from interface:IAbstractChartVisualSetReturns 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:
isMouseTransparentin interfaceIAbstractChartVisualSet- Returns:
- the value of the property mouseTransparent
-
recalculateVisualElements
protected void recalculateVisualElements() -
addVisualElement
-
addVisualElement
-
removeVisualElement
-
clearDependencies
-
sortVisualElements
protected void sortVisualElements() -
getVisibleVisualElementsCount
public int getVisibleVisualElementsCount(double beginArgument, double endArgument) Description copied from interface:IAbstractChartVisualSetReturns the number of VisualElements drawn within the bounds of the specified begin and end X-axis arguments.- Specified by:
getVisibleVisualElementsCountin interfaceIAbstractChartVisualSet- Parameters:
beginArgument- begin bounds X-axis argumentendArgument- end bounds X-axis argument- Returns:
- the number of VisualElements drawn within the bounds of the specified begin and end X-axis arguments
-
getVisibleVisualElementIndex
protected int getVisibleVisualElementIndex(double argument, List<? extends VisualSet<T>.VisualElement> visualElements, boolean searchByEndArgument) -
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 interfaceIAbstractChartVisualSet- Parameters:
recalculationRequired- flag of the need to recalculate the visual elements- Returns:
- the list of visual elements corresponding to current data elements
-
updateMinMaxArgumentsValues
-
getContents
Description copied from interface:IAbstractChartVisualSetReturns the list of visual set contents.- Specified by:
getContentsin interfaceIAbstractChartVisualSet- Returns:
- the list of visual set contents
-
getInjectionIndex
protected int getInjectionIndex(List<VisualSet<T>.VisualElement> list, VisualSet<T>.VisualElement element, T contents, int contentsIndex, Map<VisualSet<T>.VisualElement, Double> beginArgumentsCache) -
toString
-