Class Trace2DArithmeticMeanX
- java.lang.Object
-
- info.monitorenter.gui.chart.traces.ATrace2D
-
- info.monitorenter.gui.chart.traces.computing.Trace2DArithmeticMeanX
-
- All Implemented Interfaces:
ITrace2D,java.beans.PropertyChangeListener,java.io.Serializable,java.lang.Comparable<ITrace2D>,java.util.EventListener
public class Trace2DArithmeticMeanX extends ATrace2D
A trace that accumulates the latest n x values added to points with the arithmetic mean x value and the latest y value.This trace will not reduce the amount of n points added to one carrying the arithmetic mean but always add a point that has the average of the recent added n points.
Please note that this trace scan be used in two modes:
- Stand alone:
Add theITrace2Dimplementation to a chart and add data points to it as normal. - Computing trace:
Add theITrace2Dimplementation as a computing trace to an existing trace viaand only add data points to the original trace. Add the computing trace to the same chart and updates of the original trace will be reflected on the computing trace as well.ITrace2D.addComputingTrace(info.monitorenter.gui.chart.ITrace2D)
- Version:
- $Revision: 1.4 $
- Author:
- Achim Westermann
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface info.monitorenter.gui.chart.ITrace2D
ITrace2D.DistancePoint
-
-
Field Summary
-
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
Constructors Constructor Description Trace2DArithmeticMeanX(int arithmenticMeanSpan)The amount of n recent points to buffer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanaddPointInternal(ITracePoint2D p)Override this template method for the custom add operation that depends on the policies of the implementation.intgetMaxSize()Returns the maximum amount ofTracePoint2Dinstances that may be added.intgetSize()Returns the amount ofTracePoint2Dinstances currently contained.booleanisEmpty()Returns false if internalinstances are contained or true if not.TracePoint2Djava.util.Iterator<ITracePoint2D>iterator()Returns anIteratorover the internalinstances.TracePoint2Dprotected voidremoveAllPointsInternal()Override this template method for the custom remove operation that depends on theCollectionused in the implementation.protected ITracePoint2DremovePointInternal(ITracePoint2D point)Override this template method for the custom remove operation that depends on the internal storage the implementation.-
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
-
-
-
-
Constructor Detail
-
Trace2DArithmeticMeanX
public Trace2DArithmeticMeanX(int arithmenticMeanSpan)
The amount of n recent points to buffer. private int m_pointBufferSize; /** Constructor with the given amount of points to merge into one point with their arithmetic mean.- Parameters:
arithmenticMeanSpan- the amount of points to merge into one point with their arithmetic mean.
-
-
Method Detail
-
addPointInternal
protected boolean addPointInternal(ITracePoint2D p)
Description copied from class:ATrace2DOverride 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
truethe outer logic of the calling methodwill 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:
addPointInternalin classATrace2D- Parameters:
p- the point to add.- Returns:
- true if the given point was accepted or false if not.
- See Also:
ATrace2D.addPointInternal(info.monitorenter.gui.chart.ITracePoint2D)
-
getMaxSize
public int getMaxSize()
Description copied from interface:ITrace2DReturns the maximum amount of
TracePoint2Dinstances 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.- Returns:
- The maximum amount of
TracePoint2Dinstances that may be added. - See Also:
ITrace2D.getMaxSize()
-
getSize
public int getSize()
Description copied from interface:ITrace2DReturns the amount ofTracePoint2Dinstances currently contained.- Returns:
- The amount of
instances currently contained.TracePoint2D - See Also:
ITrace2D.getSize()
-
isEmpty
public boolean isEmpty()
Description copied from interface:ITrace2DReturns false if internalinstances are contained or true if not.TracePoint2D- Returns:
- false if internal
instances are contained or true if not.TracePoint2D - See Also:
ITrace2D.isEmpty()
-
iterator
public java.util.Iterator<ITracePoint2D> iterator()
Description copied from interface:ITrace2DReturns anIteratorover the internalinstances.TracePoint2DImplementations should be synchronized. This method is meant to allow modifications of the intenal
TracePoint2Dinstances, 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
TracePoint2Dinstances decides how theChart2Dwill paint the trace.- Returns:
- an
Iteratorover the internalinstances.TracePoint2D - See Also:
ITrace2D.iterator()
-
removeAllPointsInternal
protected void removeAllPointsInternal()
Description copied from class:ATrace2DOverride this template method for the custom remove operation that depends on theCollectionused in the implementation.No change events have to be fired, this is done by
ATrace2D.- Specified by:
removeAllPointsInternalin classATrace2D- See Also:
ATrace2D.removeAllPointsInternal()
-
removePointInternal
protected ITracePoint2D removePointInternal(ITracePoint2D point)
Description copied from class:ATrace2DOverride this template method for the custom remove operation that depends on the internal storage the implementation.The returned point may be the same as the given. But some "computing" traces like
will internally delete a different point and return that one.Trace2DArithmeticMeanNo property change events have to be fired by default. If this method returns
nullthe outer logic of the calling methodwill perform bound checks for the returned point and fire property changes for the propertiesATrace2D.removePoint(ITracePoint2D),ITrace2D.PROPERTY_MAX_X,ITrace2D.PROPERTY_MIN_XandITrace2D.PROPERTY_MAX_Y.ITrace2D.PROPERTY_MIN_YIn special cases - when additional modifications to the internal set of points take place (e.g. a further point get added) this method should return false (regardless whether the old point was really removed or not) and perform bound checks and fire the property changes as mentioned above "manually".
- Specified by:
removePointInternalin classATrace2D- Parameters:
point- the point to remove.- Returns:
- null if unsuccessful (and no events should be fired) or the point that actually was removed (in case different than the given one it should be somehow related to the given one).
- See Also:
ATrace2D.removePointInternal(info.monitorenter.gui.chart.ITracePoint2D)
-
-