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 Classes
    Modifier and Type
    Interface
    Description
    static interface 
    Interface for change events.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double[]
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Registers a listener for data changes.
    default Color
    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 String
    getLabel(int index)
    Returns a label for a specific index (optional).
    default double[]
    Direct access to low values (for financial charts).
    default double
    getMax(int index)
    Optional per-point maximum value.
    default double
    getMin(int index)
    Optional per-point minimum value.
    Returns the title of the data series.
    default double[]
    Direct access to open values (for financial charts).
    int
    Returns the number of data points.
    default long
    Optional timestamp for model updates; default 0 for simple models.
    default double
    getValue(int index, int component)
    Generic multi-component accessor used by statistical/financial renderers.
    default double
    getWeight(int index)
    Returns the weight value at the given index.
    default double[]
    Optional weight array for pie/donut-like renderers.
    default double
    getX(int index)
    Returns the X value at the given index.
    default double[]
    Direct access to the X-coordinate array.
    default double
    getY(int index)
    Returns the Y value at the given index.
    default double
    getY(int index, int channel)
    Optional multi-channel getter for models that expose multiple components per index (e.g. medical data).
    default double[]
    Direct access to the Y-coordinate array.
    default boolean
    Checks if the model is empty.
    void
    Removes a listener.
    default void
    setColor(Color color)
    Optional setter for a visual color; default no-op.
  • Field Details

    • EMPTY_DOUBLE

      static final double[] EMPTY_DOUBLE
  • Method Details

    • getName

      String getName()
      Returns the title of the data series.
      Returns:
      Name of the series
    • 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)
    • 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

      default String getLabel(int index)
      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

      void addChangeListener(ChartModel.ChartModelListener listener)
      Registers a listener for data changes.
      Parameters:
      listener - The listener
    • removeChangeListener

      void removeChangeListener(ChartModel.ChartModelListener listener)
      Removes a listener.
      Parameters:
      listener - The listener
    • getUpdateStamp

      default long getUpdateStamp()
      Optional timestamp for model updates; default 0 for simple models.
    • getColor

      default Color getColor()
      Optional visual color for a series; default is null.
    • setColor

      default void setColor(Color color)
      Optional setter for a visual color; default no-op.