Class Trace2DLtdSorted

  • All Implemented Interfaces:
    ITrace2D, java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Comparable<ITrace2D>, java.util.EventListener

    public class Trace2DLtdSorted
    extends Trace2DSorted
    Additional to the Trace2DLtdReplacing all tracepoints will be sorted by their x- value.

    Performance is slower compared to the class named above. Internally a TreeSet is used (instead of RingBufferArrayFast) to keep the comparable TracePoint2D- instances sorted. Internally all tracepoints are TracePoint2D -instances.

    Version:
    $Revision: 1.12 $
    Author:
    Achim Westermann
    See Also:
    Serialized Form
    • Field Detail

      • m_maxsize

        protected int m_maxsize
        The maximum amount of points that will be shown.
    • Constructor Detail

      • Trace2DLtdSorted

        public Trace2DLtdSorted()
        Constructs an instance with a default buffer size of 100.

      • Trace2DLtdSorted

        public Trace2DLtdSorted​(int maxsize)
        Constructs an instance with a buffer size of maxsize.
        Parameters:
        maxsize - the maximum amount of points to show.
    • Method Detail

      • addPointInternal

        protected boolean addPointInternal​(ITracePoint2D point)
        In case point has an x- value already contained, the old trace point with that value will be replaced by the new one. Else the new trace point will be added at an index in order to keep the ascending order of trace points with a higher x- value are contained.

        If points takes additional space (it's x- value is not already contained) and maxsize is reached, the first element (with lowest x- value) will be removed.

        Overrides:
        addPointInternal in class Trace2DSorted
        Parameters:
        point - the point to add.
        Returns:
        true if the point was successfully removed.
      • getMaxSize

        public final int getMaxSize()
        Description copied from interface: ITrace2D

        Returns the maximum amount of TracePoint2D instances that may be added. For implementations that limit the maximum amount this is a reasonable amount. Non-limiting implementations should return Integer.MAX_VALUE. This allows to detect the unlimitedness. Of course no implementation could store that amount of points.

        Specified by:
        getMaxSize in interface ITrace2D
        Overrides:
        getMaxSize in class Trace2DSorted
        Returns:
        The maximum amount of TracePoint2D instances that may be added.
        See Also:
        ITrace2D.getMaxSize()
      • setMaxSize

        public final void setMaxSize​(int amount)
        Sets the maximum amount of points that will be shown.

        Parameters:
        amount - the maximum amount of points that will be shown.