Class 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 Detail

      • get

        public static Positioner get()
        Singleton object to get the tooltip positioner instance
        Returns:
        tooltip positioner instance.
      • hasTooltipPosition

        public boolean hasTooltipPosition​(String name)
        Returns true if the custom positioner has been registered, otherwise false.
        Parameters:
        name - the name of custom tooltip position to use in the tooltip
        Returns:
        true if the custom positioner has been registered, otherwise false
      • getTooltipPosition

        public IsTooltipPosition getTooltipPosition​(String name)
        Returns the tooltip positioner implementation by tooltip position name. If not exists, returns null.
        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 invoke
      • 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 invoked
        chart - chart instance
        items - list of dataset reference items
        eventPoint - 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 is null