public class

Tooltip

extends FrameLayout
java.lang.Object
   ↳ FrameLayout
     ↳ com.shinobicontrols.charts.Tooltip

Class Overview

Presents information to the user when a tracking gesture is performed, such as a long press to activate the Crosshair or a swipe while the crosshair is active to move it. The tooltip is displayed when the crosshair is made active and disappears when the crosshair is removed.

By default, the tooltip is centered on and displays values for the point the Crosshair is focused on.

On a LineSeries if the crosshair is directly over a data point, then the data point values will be shown. If the crosshair is not over a data point then the values shown will be the values which are interpolated between the adjacent data points. On all other series types the values which correspond to the nearest data point (to the crosshair) will be displayed. Interpolation for a line series can be switched off using the setLineSeriesInterpolationEnabled(boolean) method.

The center position of the tooltip can be changed by implementing the ShinobiChart.OnTrackingInfoChangedForTooltipListener callback interface. This interface's onTrackingInfoChanged(Tooltip, DataPoint, DataPoint, DataPoint) method is called every time a user performs a tracking gesture.

The contents of the tooltip can also be modified. The tooltip's android.view.View can be obtained via the getView() method and cast appropriately. By default the tooltip will have a DefaultTooltipView but this can be set to any type of View. Ordinarily, any updating of the tooltip's view would be done with an implementation of the onTrackingInfoChanged(Tooltip, DataPoint, DataPoint, DataPoint).

Summary

Public Methods
void forceLayout()
Data<?, ?> getCenter()
Returns a Data containing the center X and Y value for this tooltip, in data terms, used for layout.
CartesianSeries<?> getTrackedSeries()
Returns the series this tooltip is currently tracking.
View getView()
Gets the View which will be used to display the tool tip.
void setCenter(Data<?, ?> center)
Sets the center X and Y value of this tooltip, in data terms, used for layout.
void setView(View view)
Sets the View which will be used to display the tool tip.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void forceLayout ()

public Data<?, ?> getCenter ()

Returns a Data containing the center X and Y value for this tooltip, in data terms, used for layout.

The tooltip does not know the types of the X and Y values so returns them each as an java.lang.Object. However, they will be of the corresponding type for the applicable axis and so can be safely cast e.g. for a NumberAxis the value can be cast to a java.lang.Double, for a DateTimeAxis the value can be cast to a java.util.Date.

Note that for a CategoryAxis, which is an extension of the NumberAxis, the returned X or Y value will be a Double. This number represents the index in the getCategories() list of the corresponding category String.

Returns
  • the center X and Y value of this tooltip, in data terms, used for layout

public CartesianSeries<?> getTrackedSeries ()

Returns the series this tooltip is currently tracking.

Returns
  • the series this tooltip is currently tracking

public View getView ()

Gets the View which will be used to display the tool tip. Note by default this will be an instance of a DefaultTooltipView unless it has been changed by the user.

Returns
  • the View which will be used to display the Tooltip.
See Also

public void setCenter (Data<?, ?> center)

Sets the center X and Y value of this tooltip, in data terms, used for layout.

The tooltip only tracks a series when an appropriate user gesture is performed. Without a tracked series center is ignored as it is impossible to determine which axes the point refers to.

If the type of the X or Y value of center is not compatible with the respective X and Y axes for the tracked series a java.lang.ClassCastException will be thrown. Similarly, if either value is null, or if center itself is null, a java.lang.IllegalArgumentException will be thrown.

Parameters
center the center X and Y values of this tooltip, in data terms, used for layout

public void setView (View view)

Sets the View which will be used to display the tool tip. Note this can be any instance of a View. To reinstate the default view, one must pass in an instance of a DefaultTooltipView. Please note that only an instance of a DefaultTooltipView will adhere to the styling options chosen in the Crosshair's CrosshairStyle object. Only this class will be updated by default as user gestures occur.

Parameters
view the View which will be used to display the tool tip.
Throws
IllegalArgumentException if a null parameter is passed into this method.
See Also