Class FastMedicalModel
java.lang.Object
com.arbergashi.charts.model.FastMedicalModel
- All Implemented Interfaces:
ChartModel
- Direct Known Subclasses:
CircularFastMedicalModel
Optimized model for real-time medical data (ECG, EEG).
Uses primitive arrays with dynamic resizing. Thread-safe for append operations (single-writer, multiple-reader scenario).
- Since:
- 2025-06-01
- Version:
- 1.0.0
- Author:
- Arber Gashi
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface ChartModel
ChartModel.ChartModelListener -
Field Summary
Fields inherited from interface ChartModel
EMPTY_DOUBLE -
Constructor Summary
ConstructorsConstructorDescriptionFastMedicalModel(String name) FastMedicalModel(String name, int initialCapacity) -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters a listener for data changes.voidaddPoint(double x, double y) Adds a new point.voidaddPoints(double[] x, double[] y) Adds multiple points efficiently (bulk operation).voidclear()protected voidgetName()Returns the title of the data series.intReturns the number of data points.double[]getXData()Direct access to the X-coordinate array.double[]getYData()Direct access to the Y-coordinate array.voidRemoves a listener.voidMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ChartModel
getColor, getDataRange, getHighData, getLabel, getLowData, getMax, getMin, getOpenData, getUpdateStamp, getValue, getWeight, getWeightData, getX, getY, getY, isEmpty, setColor
-
Constructor Details
-
FastMedicalModel
-
FastMedicalModel
-
-
Method Details
-
addPoint
public void addPoint(double x, double y) Adds a new point. Thread-safe. -
addPoints
public void addPoints(double[] x, double[] y) Adds multiple points efficiently (bulk operation). -
clear
public void clear() -
getName
Description copied from interface:ChartModelReturns the title of the data series.- Specified by:
getNamein interfaceChartModel- Returns:
- Name of the series
-
getPointCount
public int getPointCount()Description copied from interface:ChartModelReturns the number of data points.- Specified by:
getPointCountin interfaceChartModel- Returns:
- count
-
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
-
trimToSize
public void trimToSize() -
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
-
fireDataChanged
protected void fireDataChanged()
-