Class CircularChartModel
- All Implemented Interfaces:
ChartModel
Threading contract: readers are lock-free and use per-slot sequencing to ensure consistent field reads. Writers are serialized by an internal spin lock so multiple writer threads are safe but will be ordered. For highest throughput, prefer a single writer.
Atomic reads: use readPoint(int, double[]) when you need a consistent
snapshot of x/y/min/max/weight. Individual getters are safe but may observe different points
if called separately.
Capacity is rounded to the next power-of-two to enable fast index masking.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ChartModel
ChartModel.ChartModelListener -
Field Summary
Fields inherited from interface ChartModel
EMPTY_DOUBLE -
Constructor Summary
ConstructorsConstructorDescriptionCircularChartModel(int capacity) CircularChartModel(String name, int capacity) -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a listener for data changes.voidaddOHLC(double time, double open, double high, double low, double close) voidvoidvoidvoidvoidaddWithError(double x, double y, double error) voidaddWithError(double x, double y, double errorLow, double errorHigh) voidaddWithError(ErrorBarPoint point) voidaddXY(double x, double y) voidvoidclear()intgetColor()Optional visual color for a series; default is null.double[]Returns the {minX, maxX, minY, maxY} data range based on available X/Y arrays.double[]Direct access to high values (for financial charts).getLabel(int index) Returns a label for a specific index (optional).double[]Direct access to low values (for financial charts).doublegetMax(int index) Optional per-point maximum value.doublegetMin(int index) Optional per-point minimum value.getName()Returns the title of the data series.intReturns the number of data points.longOptional timestamp for model updates; default 0 for simple models.doublegetValue(int index, int component) Generic multi-component accessor used by statistical/financial renderers.doublegetWeight(int index) Returns the weight value at the given index.double[]Optional weight array for pie/donut-like renderers.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.booleanreadPoint(int index, double[] buffer) Reads a stable point into the provided buffer.voidRemoves a listener.voidOptional setter for a visual color; default no-op.setDispatchOnEdt(boolean enabled) setLabelsEnabled(boolean enabled) voidvoidsetSubtitle(String subtitle) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChartModel
getOpenData, getY, isEmpty
-
Constructor Details
-
CircularChartModel
public CircularChartModel(int capacity) -
CircularChartModel
-
-
Method Details
-
getCapacity
public int getCapacity() -
setLabelsEnabled
-
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
-
getMin
public double getMin(int index) Description copied from interface:ChartModelOptional per-point minimum value. Default: fallback to the Y value for that index.- Specified by:
getMinin interfaceChartModel
-
getMax
public double getMax(int index) Description copied from interface:ChartModelOptional per-point maximum value. Default: fallback to the Y value for that index.- Specified by:
getMaxin interfaceChartModel
-
getWeight
public double getWeight(int index) Description copied from interface:ChartModelReturns the weight value at the given index.- Specified by:
getWeightin interfaceChartModel- Parameters:
index- data point index- Returns:
- weight value or 0.0 if out of range
-
getValue
public double getValue(int index, int component) Description copied from interface:ChartModelGeneric multi-component accessor used by statistical/financial renderers. Default: fallback to `getY(index)`; implementors may override for boxplot/candlestick semantics.- Specified by:
getValuein interfaceChartModel
-
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
-
getLowData
public double[] getLowData()Description copied from interface:ChartModelDirect access to low values (for financial charts). Default: Fallback to Y-data.- Specified by:
getLowDatain interfaceChartModel
-
getHighData
public double[] getHighData()Description copied from interface:ChartModelDirect access to high values (for financial charts). Default: Fallback to Y-data.- Specified by:
getHighDatain interfaceChartModel
-
getWeightData
public double[] getWeightData()Description copied from interface:ChartModelOptional weight array for pie/donut-like renderers. Default: fallback to Y-data. Renderers should prefer this primitive API for zero-allocation rendering.- Specified by:
getWeightDatain interfaceChartModel
-
getLabel
Description copied from interface:ChartModelReturns a label for a specific index (optional).- Specified by:
getLabelin interfaceChartModel- Parameters:
index- Index of the point- Returns:
- Label or null
-
getDataRange
public double[] getDataRange()Description copied from interface:ChartModelReturns the {minX, maxX, minY, maxY} data range based on available X/Y arrays.- Specified by:
getDataRangein interfaceChartModel- Returns:
- range array or {0,0,0,0} if data is empty
-
getName
Description copied from interface:ChartModelReturns the title of the data series.- Specified by:
getNamein interfaceChartModel- Returns:
- Name of the series
-
setName
-
getSubtitle
-
setSubtitle
-
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
-
setDispatchOnEdt
-
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
-
getUpdateStamp
public long getUpdateStamp()Description copied from interface:ChartModelOptional timestamp for model updates; default 0 for simple models.- Specified by:
getUpdateStampin interfaceChartModel
-
clear
public void clear() -
addPoint
-
addPoint
-
addPoint
-
addXY
public void addXY(double x, double y) -
addXY
-
addOHLC
-
addOHLC
public void addOHLC(double time, double open, double high, double low, double close) -
addWithError
-
addWithError
public void addWithError(double x, double y, double error) -
addWithError
public void addWithError(double x, double y, double errorLow, double errorHigh) -
readPoint
public boolean readPoint(int index, double[] buffer) Reads a stable point into the provided buffer.This method uses a per-slot sequence guard to ensure all fields are from the same write. For concurrent usage, prefer this method over calling
getX/getY/getMin/getMaxindividually.Buffer order: x, y, min, max, weight.
- Parameters:
index- point index in the logical seriesbuffer- output buffer with length >= 5- Returns:
truewhen a stable point was read
-