Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public abstract class HierarchySeries

  1. Object
  2. Series
  3. HierarchySeries

Known subtypesFlameGraphSeries, SunburstSeries, TreemapSeries

Base of the hierarchical series. It keeps the tree, the node currently zoomed into and the geometry of the last paint for hit testing, and handles drill down: tapping a node with children zooms into it, tapping the breadcrumb goes back up.

Constructors

protected HierarchySeries(String name, TreeNode root)Creates the series.

Methods

public boolean isCartesian()True for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.
public HierarchySeries setRoot(TreeNode root)Replaces the tree and zooms back out to its root.
protected void attached()Called by the chart when this series is added to it, and again when the chart comes back on screen (its initComponent); a series may be told more than once.
protected void detached()Called by the chart when this series is removed from it, or the chart leaves the screen (its deinitialize); a series may be told more than once.
public TreeNode getRoot()The root node.
public TreeNode getCurrent()The node currently zoomed into.
public HierarchySeries setCurrent(TreeNode node)Zooms into a node, animated.
protected boolean crumbContains(float ax, float ay)True when a point, in screen coordinates, is on the breadcrumb that goes back up.
public HierarchySeries setDrillDown(boolean d)Enables zooming into a node by tapping it.
public HierarchySeries setMaxDepth(int depth)How many levels below the current node are drawn.
public int getMaxDepth()The number of levels drawn.
protected void captureEntryStart()Records a zero baseline as the start of the entry animation.
protected void captureTransitionStart()Records the values currently on screen as the start of the next transition.
protected void transitionEnded()Called by the chart when a transition has finished, so a subclass can drop the start values it captured; a later change that forgot to snapshot then shows its new values instead of replaying a transition from long gone data.
protected final void tween(ChartContext ctx, TreeNode n, float[] geometry)Moves a node’s geometry, in place, part of the way from where the node was drawn before the data changed to geometry, by the progress of the change.
protected float[] collapsed(float[] geometry)The geometry a node added by a data change grows from: by default the geometry itself, so the node appears in place.
protected float growth(ChartContext ctx)The fraction of the zoom or entry animation done, 1 when idle.
protected int colorOf(ChartContext ctx, TreeNode n)The colour of a node: its own, its nearest coloured ancestor’s tinted by depth, or the palette colour of its top level branch.
protected int paintBreadcrumb(ChartContext ctx)Paints the breadcrumb row when zoomed in and returns its height.
protected void record(TreeNode n, float[] geometry)
protected abstract boolean contains(float[] geometry, float x, float y)True if the absolute point lies in a recorded geometry.
protected abstract float[] anchor(float[] geometry)The anchor point of a recorded geometry, {x, y} absolute.
public ChartPoint hitTest(ChartContext ctx, int x, int y, int radius)Finds the data point nearest a screen position.
protected boolean isPointCountFromLayout()True when getPointCount() counts points a paint laid out (treemap, sunburst, Sankey) rather than the model’s points, so an index past it may exist after the next paint.
public int getPointCount()The number of points along x, for a shared tooltip; -1 when not index aligned.
public ChartPoint getPoint(ChartContext ctx, int index)The point at index for a shared tooltip, or null.
public TreeNode getNode(ChartPoint p)The node behind a point from hitTest or a selection event.
public boolean handleTap(ChartPoint p)Called when a point of this series is tapped, before the chart selects it.
public String formatTooltip(ChartContext ctx, ChartPoint p)The tooltip row for a point: the series or point name and its formatted value.
public void collectTableRows(List<String[]> rows)Adds this series’ data to an accessible table, one {series, item, value} row per point.

Inherited methods

Constructor details

HierarchySeries

protected HierarchySeries(String name, TreeNode root)
Creates the series.

Parameters

name String
the series name
root TreeNode
the tree’s root

Method details

isCartesian

public boolean isCartesian()
True for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.

setRoot

public HierarchySeries setRoot(TreeNode root)
Replaces the tree and zooms back out to its root.

Parameters

root TreeNode
the new root

Returns

this series

attached

protected void attached()
Called by the chart when this series is added to it, and again when the chart comes back on screen (its initComponent); a series may be told more than once. A series that listens to a model outliving it (a TreeNode tree) registers here, so the model does not keep a discarded chart reachable: a chart taken off screen, or a series removed from its chart, stops listening.

detached

protected void detached()
Called by the chart when this series is removed from it, or the chart leaves the screen (its deinitialize); a series may be told more than once. Undoes attached().

getRoot

public TreeNode getRoot()
The root node.

getCurrent

public TreeNode getCurrent()
The node currently zoomed into.

setCurrent

public HierarchySeries setCurrent(TreeNode node)
Zooms into a node, animated.

Parameters

node TreeNode
a node of this tree, or null for the root

Returns

this series

crumbContains

protected boolean crumbContains(float ax, float ay)
True when a point, in screen coordinates, is on the breadcrumb that goes back up.

Parameters

ax float
the x coordinate
ay float
the y coordinate

Returns

true on the breadcrumb

setDrillDown

public HierarchySeries setDrillDown(boolean d)
Enables zooming into a node by tapping it.

Parameters

d boolean
true to allow drill down

Returns

this series

setMaxDepth

public HierarchySeries setMaxDepth(int depth)
How many levels below the current node are drawn.

Parameters

depth int
1 or more

Returns

this series

getMaxDepth

public int getMaxDepth()
The number of levels drawn.

captureEntryStart

protected void captureEntryStart()
Records a zero baseline as the start of the entry animation.

captureTransitionStart

protected void captureTransitionStart()
Records the values currently on screen as the start of the next transition. Called by the chart before data changes; a subclass with animated data overrides it.

transitionEnded

protected void transitionEnded()
Called by the chart when a transition has finished, so a subclass can drop the start values it captured; a later change that forgot to snapshot then shows its new values instead of replaying a transition from long gone data.

tween

protected final void tween(ChartContext ctx, TreeNode n, float[] geometry)
Moves a node’s geometry, in place, part of the way from where the node was drawn before the data changed to geometry, by the progress of the change. A node the change added starts from collapsed(geometry). Does nothing when no change is animating.

Parameters

ctx ChartContext
the paint context
n TreeNode
the node
geometry float[]
the node’s geometry after the change, replaced by this frame’s

collapsed

protected float[] collapsed(float[] geometry)
The geometry a node added by a data change grows from: by default the geometry itself, so the node appears in place.

Parameters

geometry float[]
the node’s geometry after the change

Returns

a new array of the same length

growth

protected float growth(ChartContext ctx)
The fraction of the zoom or entry animation done, 1 when idle.

Parameters

ctx ChartContext
the paint context

Returns

0 to 1

colorOf

protected int colorOf(ChartContext ctx, TreeNode n)
The colour of a node: its own, its nearest coloured ancestor’s tinted by depth, or the palette colour of its top level branch.

Parameters

ctx ChartContext
the paint context
n TreeNode
the node

Returns

an RGB colour

paintBreadcrumb

protected int paintBreadcrumb(ChartContext ctx)
Paints the breadcrumb row when zoomed in and returns its height.

Parameters

ctx ChartContext
the paint context

Returns

the height used, 0 at the root

record

protected void record(TreeNode n, float[] geometry)

contains

protected abstract boolean contains(float[] geometry, float x, float y)
True if the absolute point lies in a recorded geometry.

Parameters

geometry float[]
a recorded geometry
x float
absolute x
y float
absolute y

Returns

true on a hit

anchor

protected abstract float[] anchor(float[] geometry)
The anchor point of a recorded geometry, {x, y} absolute.

Parameters

geometry float[]
a recorded geometry

Returns

the point a tooltip points at

hitTest

public ChartPoint hitTest(ChartContext ctx, int x, int y, int radius)
Finds the data point nearest a screen position.

Parameters

ctx ChartContext
the frame the series was last painted in
x int
chart relative x
y int
chart relative y
radius int
how far from the point a touch may land and still hit it

Returns

the point, or null

isPointCountFromLayout

protected boolean isPointCountFromLayout()
True when getPointCount() counts points a paint laid out (treemap, sunburst, Sankey) rather than the model’s points, so an index past it may exist after the next paint.

getPointCount

public int getPointCount()
The number of points along x, for a shared tooltip; -1 when not index aligned.

getPoint

public ChartPoint getPoint(ChartContext ctx, int index)
The point at index for a shared tooltip, or null.

getNode

public TreeNode getNode(ChartPoint p)
The node behind a point from hitTest or a selection event.

Parameters

p ChartPoint
the point

Returns

the node, or null

handleTap

public boolean handleTap(ChartPoint p)
Called when a point of this series is tapped, before the chart selects it. A series that navigates on tap (drilling into a treemap node) returns true to stop the selection.

Parameters

p ChartPoint
the tapped point

Returns

true if the tap was consumed

formatTooltip

public String formatTooltip(ChartContext ctx, ChartPoint p)
The tooltip row for a point: the series or point name and its formatted value. Series with several values per point (open/high/low/close, ranges, box plots) override this.

Parameters

ctx ChartContext
the last paint context
p ChartPoint
the point

Returns

one line of text

collectTableRows

public void collectTableRows(List<String[]> rows)
Adds this series’ data to an accessible table, one {series, item, value} row per point. Used by Chart.toTable() and the chart’s accessibility text.

Parameters

rows List<String[]>
the list to append rows to