Interface ChartModel
- All Known Subinterfaces:
BoxPlotOutlierModel, FlowChartModel, HierarchicalChartModel<T>, MatrixChartModel, MultiDimensionalChartModel, MultiVariateChartModel, TernaryChartModel
- All Known Implementing Classes:
CircularChartModel, CircularFastMedicalModel, DefaultChartModel, DefaultFlowChartModel, DefaultHierarchicalChartModel, DefaultMatrixChartModel, DefaultMultiDimensionalChartModel, DefaultMultiVariateChartModel, DefaultTernaryChartModel, FastMedicalModel
public interface ChartModel
High-Performance Chart Model Interface.
Designed for Zero-Allocation Rendering. Instead of lists of objects, primitive arrays are exposed. This enables CPU-cache-friendly iterations and avoids boxing overhead.
- Since:
- 2025-06-01
- Version:
- 1.0.0
- Author:
- Arber Gashi
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceInterface for change events. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a listener for data changes.default ColorgetColor()Optional visual color for a series; default is null.default double[]Returns the {minX, maxX, minY, maxY} data range based on available X/Y arrays.default double[]Direct access to high values (for financial charts).default StringgetLabel(int index) Returns a label for a specific index (optional).default double[]Direct access to low values (for financial charts).default doublegetMax(int index) Optional per-point maximum value.default doublegetMin(int index) Optional per-point minimum value.getName()Returns the title of the data series.default double[]Direct access to open values (for financial charts).intReturns the number of data points.default longOptional timestamp for model updates; default 0 for simple models.default doublegetValue(int index, int component) Generic multi-component accessor used by statistical/financial renderers.default doublegetWeight(int index) Returns the weight value at the given index.default double[]Optional weight array for pie/donut-like renderers.default doublegetX(int index) Returns the X value at the given index.default double[]getXData()Direct access to the X-coordinate array.default doublegetY(int index) Returns the Y value at the given index.default doublegetY(int index, int channel) Optional multi-channel getter for models that expose multiple components per index (e.g. medical data).default double[]getYData()Direct access to the Y-coordinate array.default booleanisEmpty()Checks if the model is empty.voidRemoves a listener.default voidOptional setter for a visual color; default no-op.
-
Field Details
-
EMPTY_DOUBLE
static final double[] EMPTY_DOUBLE
-
-
Method Details
-
getName
-
getPointCount
int getPointCount()Returns the number of data points.- Returns:
- count
-
getXData
default double[] getXData()Direct access to the X-coordinate array.Framework contract: Implementations may return either:
- a defensive copy sized to
getPointCount()(safe, but potentially slower), or - a backing array with a capacity larger than
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).- Returns:
- X values array (may be larger than logical size)
- a defensive copy sized to
-
getX
default double getX(int index) Returns the X value at the given index.- Parameters:
index- data point index- Returns:
- X value or 0.0 if out of range
-
getYData
default double[] getYData()Direct access to the Y-coordinate array.Warning: For performance reasons, the internal array is often returned. Do not modify!
- Returns:
- double array of Y values
-
getY
default double getY(int index) Returns the Y value at the given index.- Parameters:
index- data point index- Returns:
- Y value or 0.0 if out of range
-
getDataRange
default double[] getDataRange()Returns the {minX, maxX, minY, maxY} data range based on available X/Y arrays.- Returns:
- range array or {0,0,0,0} if data is empty
-
getWeightData
default double[] getWeightData()Optional weight array for pie/donut-like renderers. Default: fallback to Y-data. Renderers should prefer this primitive API for zero-allocation rendering. -
getWeight
default double getWeight(int index) Returns the weight value at the given index.- Parameters:
index- data point index- Returns:
- weight value or 0.0 if out of range
-
getY
default double getY(int index, int channel) Optional multi-channel getter for models that expose multiple components per index (e.g. medical data). Default: fallback to single-channel Y. -
getValue
default double getValue(int index, int component) Generic multi-component accessor used by statistical/financial renderers. Default: fallback to `getY(index)`; implementors may override for boxplot/candlestick semantics. -
getOpenData
default double[] getOpenData()Direct access to open values (for financial charts). Default: Fallback to Y-data. -
getHighData
default double[] getHighData()Direct access to high values (for financial charts). Default: Fallback to Y-data. -
getLowData
default double[] getLowData()Direct access to low values (for financial charts). Default: Fallback to Y-data. -
getMin
default double getMin(int index) Optional per-point minimum value. Default: fallback to the Y value for that index. -
getMax
default double getMax(int index) Optional per-point maximum value. Default: fallback to the Y value for that index. -
getLabel
Returns a label for a specific index (optional).- Parameters:
index- Index of the point- Returns:
- Label or null
-
isEmpty
default boolean isEmpty()Checks if the model is empty. -
addChangeListener
Registers a listener for data changes.- Parameters:
listener- The listener
-
removeChangeListener
Removes a listener.- Parameters:
listener- The listener
-
getUpdateStamp
default long getUpdateStamp()Optional timestamp for model updates; default 0 for simple models. -
getColor
Optional visual color for a series; default is null. -
setColor
Optional setter for a visual color; default no-op.
-