Class Positioner
- java.lang.Object
-
- org.pepstock.charba.client.positioner.Positioner
-
public final class Positioner extends Object
Manages the custom tooltip positioner. With a custom positioner you can decide where the tooltip can appear returning the point in the canvas.- Author:
- Andrea "Stock" Stocchero
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Positioner
get()
Singleton object to get the tooltip positioner instanceIsTooltipPosition
getTooltipPosition(String name)
Returns the tooltip positioner implementation by tooltip position name.boolean
hasTooltipPosition(String name)
Returnstrue
if the custom positioner has been registered, otherwisefalse
.Point
invokePositioner(IsTooltipPosition position, IsChart chart, List<DatasetReference> items, Point eventPoint)
Invokes an existing positioner to get the point.void
register(TooltipPositioner positioner)
Register the tooltips positioner to CHART.JS.void
unregister(CustomTooltipPosition position)
Unregister the tooltips positioner to CHART.JS.
Pay attention that when a tooltip positioner is unregistered, if any charts, which still have the tooltip position of the positioner, will fail.
-
-
-
Method Detail
-
get
public static Positioner get()
Singleton object to get the tooltip positioner instance- Returns:
- tooltip positioner instance.
-
hasTooltipPosition
public boolean hasTooltipPosition(String name)
Returnstrue
if the custom positioner has been registered, otherwisefalse
.- Parameters:
name
- the name of custom tooltip position to use in the tooltip- Returns:
true
if the custom positioner has been registered, otherwisefalse
-
getTooltipPosition
public IsTooltipPosition getTooltipPosition(String name)
Returns the tooltip positioner implementation by tooltip position name. If not exists, returnsnull
.- Parameters:
name
- the name of custom tooltip position to use in the tooltip- Returns:
- the tooltip positioner implementation. If not exists, returns
null
.
-
register
public void register(TooltipPositioner positioner)
Register the tooltips positioner to CHART.JS.- Parameters:
positioner
- tooltip positioner instance to register
-
unregister
public void unregister(CustomTooltipPosition position)
Unregister the tooltips positioner to CHART.JS.
Pay attention that when a tooltip positioner is unregistered, if any charts, which still have the tooltip position of the positioner, will fail.- Parameters:
position
- custom tooltip position instance
-
invokePositioner
public Point invokePositioner(IsTooltipPosition position, IsChart chart, List<DatasetReference> items, Point eventPoint)
Invokes an existing positioner to get the point.- Parameters:
position
- position of tooltips to be invokedchart
- chart instanceitems
- list of dataset reference itemseventPoint
- the point of event when the method has been invoked- Returns:
- the point calculated by positioner or
null
if positioner does not exist or the result of invoked positioner isnull
-
-