Class HierarchySeries

java.lang.Object
com.codename1.ui.chart.Series
com.codename1.ui.chart.series.HierarchySeries
Direct Known Subclasses:
FlameGraphSeries, SunburstSeries, TreemapSeries

public abstract class HierarchySeries extends Series
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.
  • Constructor Details

    • HierarchySeries

      protected HierarchySeries(String name, TreeNode root)

      Creates the series.

      Parameters
      • name: the series name

      • root: the tree's root

  • Method Details

    • isCartesian

      public boolean isCartesian()
      Description copied from class: Series
      True for series drawn against x and y axes; false for pies, treemaps and other series that fill the plot themselves.
      Specified by:
      isCartesian in class Series
    • setRoot

      public HierarchySeries setRoot(TreeNode root)

      Replaces the tree and zooms back out to its root.

      Parameters
      • root: the new root
      Returns

      this series

    • attached

      protected void attached()
      Description copied from class: Series
      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.
      Overrides:
      attached in class Series
    • detached

      protected void detached()
      Description copied from class: Series
      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().
      Overrides:
      detached in class Series
    • 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: 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: the x coordinate

      • ay: the y coordinate

      Returns

      true on the breadcrumb

    • setDrillDown

      public HierarchySeries setDrillDown(boolean d)

      Enables zooming into a node by tapping it.

      Parameters
      • d: 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: 1 or more
      Returns

      this series

    • getMaxDepth

      public int getMaxDepth()
      The number of levels drawn.
    • captureEntryStart

      protected void captureEntryStart()
      Description copied from class: Series
      Records a zero baseline as the start of the entry animation.
      Overrides:
      captureEntryStart in class Series
    • captureTransitionStart

      protected void captureTransitionStart()
      Description copied from class: Series
      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.
      Overrides:
      captureTransitionStart in class Series
    • transitionEnded

      protected void transitionEnded()
      Description copied from class: Series
      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.
      Overrides:
      transitionEnded in class Series
    • 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: the paint context

      • n: the node

      • geometry: 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: 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: 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: the paint context

      • n: 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: 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: a recorded geometry

      • x: absolute x

      • y: 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: a recorded geometry
      Returns

      the point a tooltip points at

    • hitTest

      public ChartPoint hitTest(ChartContext ctx, int x, int y, int radius)
      Description copied from class: Series

      Finds the data point nearest a screen position.

      Parameters
      • ctx: the frame the series was last painted in

      • x: chart relative x

      • y: chart relative y

      • radius: how far from the point a touch may land and still hit it

      Returns

      the point, or null

      Overrides:
      hitTest in class Series
    • isPointCountFromLayout

      protected boolean isPointCountFromLayout()
      Description copied from class: Series
      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.
      Overrides:
      isPointCountFromLayout in class Series
    • getPointCount

      public int getPointCount()
      Description copied from class: Series
      The number of points along x, for a shared tooltip; -1 when not index aligned.
      Overrides:
      getPointCount in class Series
    • getPoint

      public ChartPoint getPoint(ChartContext ctx, int index)
      Description copied from class: Series
      The point at index for a shared tooltip, or null.
      Overrides:
      getPoint in class Series
    • getNode

      public TreeNode getNode(ChartPoint p)

      The node behind a point from hitTest or a selection event.

      Parameters
      • p: the point
      Returns

      the node, or null

    • handleTap

      public boolean handleTap(ChartPoint p)
      Description copied from class: Series

      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: the tapped point
      Returns

      true if the tap was consumed

      Overrides:
      handleTap in class Series
    • formatTooltip

      public String formatTooltip(ChartContext ctx, ChartPoint p)
      Description copied from class: Series

      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: the last paint context

      • p: the point

      Returns

      one line of text

      Overrides:
      formatTooltip in class Series
    • collectTableRows

      public void collectTableRows(List<String[]> rows)
      Description copied from class: Series

      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: the list to append rows to
      Overrides:
      collectTableRows in class Series