Class FastMedicalModel

java.lang.Object
com.arbergashi.charts.model.FastMedicalModel
All Implemented Interfaces:
ChartModel
Direct Known Subclasses:
CircularFastMedicalModel

public class FastMedicalModel extends Object implements ChartModel
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:
  • Constructor Details

    • FastMedicalModel

      public FastMedicalModel(String name, int initialCapacity)
    • FastMedicalModel

      public FastMedicalModel(String name)
  • 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

      public String getName()
      Description copied from interface: ChartModel
      Returns the title of the data series.
      Specified by:
      getName in interface ChartModel
      Returns:
      Name of the series
    • getPointCount

      public int getPointCount()
      Description copied from interface: ChartModel
      Returns the number of data points.
      Specified by:
      getPointCount in interface ChartModel
      Returns:
      count
    • getXData

      public double[] getXData()
      Description copied from interface: ChartModel
      Direct access to the X-coordinate array.

      Framework contract: Implementations may return either:

      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:
      getXData in interface ChartModel
      Returns:
      X values array (may be larger than logical size)
    • getYData

      public double[] getYData()
      Description copied from interface: ChartModel
      Direct access to the Y-coordinate array.

      Warning: For performance reasons, the internal array is often returned. Do not modify!

      Specified by:
      getYData in interface ChartModel
      Returns:
      double array of Y values
    • trimToSize

      public void trimToSize()
    • addChangeListener

      public void addChangeListener(ChartModel.ChartModelListener listener)
      Description copied from interface: ChartModel
      Registers a listener for data changes.
      Specified by:
      addChangeListener in interface ChartModel
      Parameters:
      listener - The listener
    • removeChangeListener

      public void removeChangeListener(ChartModel.ChartModelListener listener)
      Description copied from interface: ChartModel
      Removes a listener.
      Specified by:
      removeChangeListener in interface ChartModel
      Parameters:
      listener - The listener
    • fireDataChanged

      protected void fireDataChanged()