Class Trace2DLtd
- All Implemented Interfaces:
ITrace2D
,PropertyChangeListener
,Serializable
,Comparable<ITrace2D>
,EventListener
- Direct Known Subclasses:
Trace2DLtdReplacing
- The amount of internal tracepoints is limited to the maxsize, passed to the constructor.
- If a new tracepoint is inserted and the maxsize has been reached, the tracepoint residing for the longest time in this trace is thrown away.
- Version:
- $Revision: 1.19 $
- Author:
- Achim Westermann
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface info.monitorenter.gui.chart.ITrace2D
ITrace2D.DistancePoint
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected IRingBuffer<ITracePoint2D>
Internal fast FIFO buffer implementation based upon indexed access to an array.Fields inherited from class info.monitorenter.gui.chart.traces.ATrace2D
m_computingTraces, m_maxX, m_maxXErrorBar, m_maxY, m_maxYErrorBar, m_minX, m_minXErrorBar, m_minY, m_minYErrorBar, m_name, m_physicalUnitsX, m_physicalUnitsY, m_propertyChangeSupport, m_renderer
Fields inherited from interface info.monitorenter.gui.chart.ITrace2D
PROPERTY_COLOR, PROPERTY_ERRORBARPOLICY, PROPERTY_ERRORBARPOLICY_CONFIGURATION, PROPERTY_LABEL, PROPERTY_MAX_X, PROPERTY_MAX_Y, PROPERTY_MIN_X, PROPERTY_MIN_Y, PROPERTY_NAME, PROPERTY_PAINTERS, PROPERTY_PHYSICALUNITS, PROPERTY_POINT_CHANGED, PROPERTY_POINT_HIGHLIGHTERS_CHANGED, PROPERTY_STROKE, PROPERTY_TRACEPOINT, PROPERTY_VISIBLE, PROPERTY_ZINDEX, Z_INDEX_MIN, ZINDEX_MAX
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs an instance with a default buffer size of 100.Trace2DLtd
(int maxsize) Constructs an instance with a buffersize of maxsize and a default name.Trace2DLtd
(int maxsize, String name) Constructs an instance with a buffersize of maxsize and a default name.Trace2DLtd
(String name) Creates an instance with a default buffersize of 100 and the given name. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Override this template method for the custom add operation that depends on the policies of the implementation.boolean
int
Returns the maximum amount ofTracePoint2D
instances that may be added.int
getSize()
Returns the acutal amount of points in this trace.int
hashCode()
boolean
isEmpty()
Returns false if internal
instances are contained or true if not.TracePoint2D
iterator()
Returns anIterator
over the internalTracePoint2D
void
Override this template method for the custom remove operation that depends on theCollection
used in the implementation.protected ITracePoint2D
removePointInternal
(ITracePoint2D point) Returns null always because internally a ring buffer is used which does not allow removing of values because that would break the contract of a ring buffer.final void
setMaxSize
(int amount) Sets the maximum amount of points that may be displayed.Methods inherited from class info.monitorenter.gui.chart.traces.ATrace2D
addComputingTrace, addErrorBarPolicy, addPoint, addPoint, addPointHighlighter, addPropertyChangeListener, addTracePainter, compareTo, containsTracePainter, ensureInitialized, finalize, firePointAdded, firePointChanged, firePointRemoved, firePropertyChange, getChangeListeners, getColor, getErrorBarPolicies, getHasErrorBars, getInstanceCount, getLabel, getMaxX, getMaxY, getMinX, getMinY, getName, getNearestPointEuclid, getNearestPointManhattan, getPhysicalUnits, getPhysicalUnitsX, getPhysicalUnitsY, getPointHighlighters, getPropertyChangeListeners, getRenderer, getStroke, getTracePainters, getZIndex, isVisible, maxXSearch, maxYSearch, minXSearch, minYSearch, propertyChange, removeAllPointHighlighters, removeAllPoints, removeComputingTrace, removeErrorBarPolicy, removePoint, removePointHighlighter, removePropertyChangeListener, removePropertyChangeListener, removeTracePainter, setColor, setErrorBarPolicy, setName, setPhysicalUnits, setPointHighlighter, setRenderer, setStroke, setTracePainter, setVisible, setZIndex, showsErrorBars, showsNegativeXErrorBars, showsNegativeYErrorBars, showsPositiveXErrorBars, showsPositiveYErrorBars, toString
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface info.monitorenter.gui.chart.ITrace2D
addComputingTrace, addErrorBarPolicy, addPoint, addPoint, addPointHighlighter, addPropertyChangeListener, addTracePainter, containsTracePainter, firePointChanged, getColor, getErrorBarPolicies, getHasErrorBars, getLabel, getMaxX, getMaxY, getMinX, getMinY, getName, getNearestPointEuclid, getNearestPointManhattan, getPhysicalUnits, getPhysicalUnitsX, getPhysicalUnitsY, getPointHighlighters, getPropertyChangeListeners, getRenderer, getStroke, getTracePainters, getZIndex, isVisible, removeAllPointHighlighters, removeAllPoints, removeComputingTrace, removeErrorBarPolicy, removePoint, removePointHighlighter, removePropertyChangeListener, removePropertyChangeListener, removeTracePainter, setColor, setErrorBarPolicy, setName, setPhysicalUnits, setPointHighlighter, setRenderer, setStroke, setTracePainter, setVisible, setZIndex, showsErrorBars, showsNegativeXErrorBars, showsNegativeYErrorBars, showsPositiveXErrorBars, showsPositiveYErrorBars
Methods inherited from interface java.beans.PropertyChangeListener
propertyChange
-
Field Details
-
m_buffer
Internal fast FIFO buffer implementation based upon indexed access to an array.
-
-
Constructor Details
-
Trace2DLtd
public Trace2DLtd()Constructs an instance with a default buffer size of 100. -
Trace2DLtd
public Trace2DLtd(int maxsize) Constructs an instance with a buffersize of maxsize and a default name.- Parameters:
maxsize
- the buffer size for the maximum amount of points that will be shown.
-
Trace2DLtd
Constructs an instance with a buffersize of maxsize and a default name.- Parameters:
maxsize
- the buffer size for the maximum amount of points that will be shown.name
- the name that will be displayed for this trace.
-
Trace2DLtd
Creates an instance with a default buffersize of 100 and the given name.- Parameters:
name
- the name that will be displayed for the trace.
-
-
Method Details
-
addPointInternal
Description copied from class:ATrace2D
Override this template method for the custom add operation that depends on the policies of the implementation.
No property change events have to be fired by default. If this method returns
true
the outer logic of the calling method
will perform bound checks for the new point and fire property changes as described in methodATrace2D.addPoint(ITracePoint2D)
.ATrace2D.firePointChanged(ITracePoint2D, int)
In special cases - when additional modifications to the internal set of points take place (e.g. a further point gets removed) this method should return false (regardless whether the new point was accepted or not) and perform bound checks and fire the property changes as mentioned above "manually".
- Specified by:
addPointInternal
in classATrace2D
- Parameters:
p
- the point to add.- Returns:
- true if the given point was accepted or false if not.
- See Also:
-
equals
-
getMaxSize
public 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 returnInteger.MAX_VALUE
. This allows to detect the unlimitedness. Of course no implementation could store that amount of points.- Specified by:
getMaxSize
in interfaceITrace2D
- Returns:
- The maximum amount of
TracePoint2D
instances that may be added. - See Also:
-
getSize
public int getSize()Returns the acutal amount of points in this trace. -
hashCode
public int hashCode() -
isEmpty
public boolean isEmpty()Description copied from interface:ITrace2D
Returns false if internal
instances are contained or true if not.TracePoint2D
- Specified by:
isEmpty
in interfaceITrace2D
- Returns:
- false if internal
instances are contained or true if not.TracePoint2D
- See Also:
-
iterator
Description copied from interface:ITrace2D
Returns anIterator
over the internalTracePoint2D
Implementations should be synchronized. This method is meant to allow modifications of the intenal
TracePoint2D
instances, so the original points should be returned.There is no guarantee that changes made to the contained tracepoints will be reflected in the display immediately. The order the iterator returns the
TracePoint2D
instances decides how theChart2D
will paint the trace.- Specified by:
iterator
in interfaceITrace2D
- Returns:
- an
Iterator
over the internalTracePoint2D
- See Also:
-
removeAllPointsInternal
public void removeAllPointsInternal()Description copied from class:ATrace2D
Override this template method for the custom remove operation that depends on theCollection
used in the implementation.No change events have to be fired, this is done by
ATrace2D
.- Specified by:
removeAllPointsInternal
in classATrace2D
- See Also:
-
removePointInternal
Returns null always because internally a ring buffer is used which does not allow removing of values because that would break the contract of a ring buffer.- Specified by:
removePointInternal
in classATrace2D
- Parameters:
point
- the point to remove.- Returns:
- null always because internally a ring buffer is used which does not allow removing of values because that would break the contract of a ring buffer.
-
setMaxSize
public final void setMaxSize(int amount) Sets the maximum amount of points that may be displayed.Don't use this too often as decreases in size may cause expensive array copy operations and new searches on all points for bound changes.
TODO: Only search for bounds if size is smaller than before, debug and test.
- Parameters:
amount
- the new maximum amount of points to show.
-