Class DefaultHierarchicalChartModel
java.lang.Object
com.arbergashi.charts.model.DefaultHierarchicalChartModel
- All Implemented Interfaces:
ChartModel, HierarchicalChartModel<DefaultHierarchicalChartModel.DefaultNode>
public class DefaultHierarchicalChartModel
extends Object
implements HierarchicalChartModel<DefaultHierarchicalChartModel.DefaultNode>
Default implementation for a hierarchical chart model.
It uses a generic Node class to build the tree structure.
- Since:
- 2025-06-01
- Version:
- 1.0.0
- Author:
- Arber Gashi
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface ChartModel
ChartModel.ChartModelListenerNested classes/interfaces inherited from interface HierarchicalChartModel
HierarchicalChartModel.Node<T> -
Field Summary
Fields inherited from interface ChartModel
EMPTY_DOUBLE -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a listener for data changes.voidaddPoint(ChartPoint point) voidaddPoints(List<ChartPoint> points) voidclear()getColor()Optional visual color for a series; default is null.getName()Returns the title of the data series.intReturns the number of data points.Returns the root node of the hierarchy.longOptional timestamp for model updates; default 0 for simple models.doublegetX(int index) Returns the X value at the given index.double[]getXData()Direct access to the X-coordinate array.doublegetY(int index) Returns the Y value at the given index.double[]getYData()Direct access to the Y-coordinate array.voidRemoves a listener.voidOptional setter for a visual color; default no-op.voidvoidsetPoints(List<ChartPoint> points) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChartModel
getDataRange, getHighData, getLabel, getLowData, getMax, getMin, getOpenData, getValue, getWeight, getWeightData, getY, isEmpty
-
Constructor Details
-
DefaultHierarchicalChartModel
-
-
Method Details
-
getRootNode
Description copied from interface:HierarchicalChartModelReturns the root node of the hierarchy.- Specified by:
getRootNodein interfaceHierarchicalChartModel<DefaultHierarchicalChartModel.DefaultNode>- Returns:
- The root node.
-
getName
Description copied from interface:ChartModelReturns the title of the data series.- Specified by:
getNamein interfaceChartModel- Returns:
- Name of the series
-
setName
-
getColor
Description copied from interface:ChartModelOptional visual color for a series; default is null.- Specified by:
getColorin interfaceChartModel
-
setColor
Description copied from interface:ChartModelOptional setter for a visual color; default no-op.- Specified by:
setColorin interfaceChartModel
-
getUpdateStamp
public long getUpdateStamp()Description copied from interface:ChartModelOptional timestamp for model updates; default 0 for simple models.- Specified by:
getUpdateStampin interfaceChartModel
-
getPointCount
public int getPointCount()Description copied from interface:ChartModelReturns the number of data points.- Specified by:
getPointCountin interfaceChartModel- Returns:
- count
-
getX
public double getX(int index) Description copied from interface:ChartModelReturns the X value at the given index.- Specified by:
getXin interfaceChartModel- Parameters:
index- data point index- Returns:
- X value or 0.0 if out of range
-
getY
public double getY(int index) Description copied from interface:ChartModelReturns the Y value at the given index.- Specified by:
getYin interfaceChartModel- Parameters:
index- data point index- Returns:
- Y value or 0.0 if out of range
-
addPoint
-
addPoints
-
setPoints
-
clear
public void clear() -
getXData
public double[] getXData()Description copied from interface:ChartModelDirect access to the X-coordinate array.Framework contract: Implementations may return either:
- a defensive copy sized to
ChartModel.getPointCount()(safe, but potentially slower), or - a backing array with a capacity larger than
ChartModel.getPointCount()(fast, zero-allocation).
Consumers must never assume
getXData().length == getPointCount(). Always bound iteration by the logical size:int n = Math.min(model.getPointCount(), model.getXData().length);
Performance note: If you need strict size and immutability semantics, use a model implementation that returns copies (e.g.
DefaultChartModel).- Specified by:
getXDatain interfaceChartModel- Returns:
- X values array (may be larger than logical size)
- a defensive copy sized to
-
getYData
public double[] getYData()Description copied from interface:ChartModelDirect access to the Y-coordinate array.Warning: For performance reasons, the internal array is often returned. Do not modify!
- Specified by:
getYDatain interfaceChartModel- Returns:
- double array of Y values
-
addChangeListener
Description copied from interface:ChartModelRegisters a listener for data changes.- Specified by:
addChangeListenerin interfaceChartModel- Parameters:
listener- The listener
-
removeChangeListener
Description copied from interface:ChartModelRemoves a listener.- Specified by:
removeChangeListenerin interfaceChartModel- Parameters:
listener- The listener
-