Class TracePoint2D
- java.lang.Object
-
- java.awt.geom.Point2D
-
- java.awt.geom.Point2D.Double
-
- info.monitorenter.gui.chart.TracePoint2D
-
- All Implemented Interfaces:
ITracePoint2D
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Comparable<ITracePoint2D>
public class TracePoint2D extends java.awt.geom.Point2D.Double implements ITracePoint2D
A specialized version ofjava.awt.Point2D.Double
who carries two further values:double scaledX
anddouble scaledY
which allow theChart2D
to cache the scaled values (between 0.0 and 1.0) without having to keep a copy of the aggregators (ITrace2D
) complete tracepoints.This avoids the necessity to care for the correct order of a set of scaled tracepoints copied for caching purposes. Especially in the case of new
TracePoint2D
instances added to aITrace2D
instance managed by aChart2D
there remains no responsibility for sorting the cached copy. This allows that the managingChart2D
may just rescale the newly added tracepoint instead of searching for the correct order of the new tracepoint by value - comparisons of x and y: TheTracePoint2D
passed to the methodtraceChanged(Chart2DDataChangeEvent e)
coded in the argument is the original.
Why caching of scaled values for the coordinates?
This takes more RAM but else for everyrepaint()
invocation of theChart2D
would force all tracepoints of all traces to be rescaled again.A TracePoint2D will inform it's listener of type
ITrace
on changes of the internal values.- Version:
- $Revision: 1.34 $
- Author:
- Achim Westermann Achim.Westermann@gmx.de
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface info.monitorenter.gui.chart.ITracePoint2D
STATE_ADDED, STATE_CHANGED, STATE_REMOVED
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
TracePoint2D()
Intended for
only.TracePointProviderDefault
TracePoint2D(double xValue, double yValue)
Construct a TracePoint2D whose coords are initalized to (x,y).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
addAdditionalPointPainter(IPointPainter<?> additionalPointPainter)
Adds a point painter that additionally (to the pointer painters of the trace (
)) paint this point.ITrace2D.getTracePainters()
java.lang.Object
clone()
Returns a cloned instance (deep copy).int
compareTo(ITracePoint2D obj)
boolean
equals(java.lang.Object obj)
java.util.Set<IPointPainter<?>>
getAdditionalPointPainters()
Returns the point painter that additionally (to the trace painter of the chart) paint this point.double
getEuclidDistance(double xNormalized, double yNormalized)
Returns the Euclid distance of this point's normalized values (
) to the given normalized coordinates.ITracePoint2D.getScaledX()
,ITracePoint2D.getScaledY()
ITrace2D
getListener()
Returns the listener trace connected to this trace point.double
getManhattanDistance(double xNormalized, double yNormalized)
Returns the Manhattan distance of this point's normalized values (
) to the given normalized coordinates.ITracePoint2D.getScaledX()
,ITracePoint2D.getScaledY()
double
getManhattanDistance(ITracePoint2D point)
Returns the Manhattan distance of this point to the given one.double
getScaledX()
double
getScaledY()
double
getX()
Returns the x value.double
getY()
Returns the y value.int
hashCode()
boolean
removeAdditionalPointPainter(IPointPainter<?> pointPainter)
Removes a point painter that additionally (to the pointer painters of the trace (
)) paint this point.ITrace2D.getTracePainters()
java.util.Set<IPointPainter<?>>
removeAllAdditionalPointPainters()
Removes all point painters that additionally (to the pointer painters of the trace (
)) paint this point.ITrace2D.getTracePainters()
void
setListener(ITrace2D listener)
AllowsITrace2D
instances to register (or de-register) themselves with this point to receive (or stop receiving) change information viaITrace2D.firePointChanged(ITracePoint2D, int)
events.void
setLocation(double xValue, double yValue)
This method overloads the method ofjava.awt.geom.Point2D.Double
to fire a property change event to listeners of the corresponding
instances via their methodITrace2D
(with int argument set toITrace2D.firePointChanged(ITracePoint2D, int)
).ITracePoint2D.STATE_CHANGED
void
setScaledX(double scaledX)
Only intended for Chart2D!!!.void
setScaledY(double scaledY)
Only intended for Chart2D!!!.java.lang.String
toString()
-
-
-
Constructor Detail
-
TracePoint2D
protected TracePoint2D()
Intended for
only.TracePointProviderDefault
-
TracePoint2D
public TracePoint2D(double xValue, double yValue)
Construct a TracePoint2D whose coords are initalized to (x,y).- Parameters:
xValue
- the x value to use.yValue
- the y value to use.
-
-
Method Detail
-
addAdditionalPointPainter
public final boolean addAdditionalPointPainter(IPointPainter<?> additionalPointPainter)
Description copied from interface:ITracePoint2D
Adds a point painter that additionally (to the pointer painters of the trace (
)) paint this point.ITrace2D.getTracePainters()
No clone will be taken. Outside modifications of the argument later on will also affect this instances state!
Caution! This is a low level mechanism that is also used by the highlighting mechanism. It is being utilized by the
which will use some mouse motion listener to remove outdated highlighters and add highlighters to the new point in focus by taking the highlighter configured in the trace.Chart2D.enablePointHighlighting(boolean)
So to use point highlighting for traces you should not re-program it at this level but just use
andITrace2D.addPointHighlighter(IPointPainter)
Chart2D.enablePointHighlighting(boolean)
.- Specified by:
addAdditionalPointPainter
in interfaceITracePoint2D
- Parameters:
additionalPointPainter
- a point painter that will additionally (to the trace painter of the chart) paint this point.- Returns:
- true if this point painter was accepted (not contained before by
the means of
Comparable.compareTo(Object)
- See Also:
ITracePoint2D.addAdditionalPointPainter(info.monitorenter.gui.chart.IPointPainter)
-
clone
public java.lang.Object clone()
Description copied from interface:ITracePoint2D
Returns a cloned instance (deep copy).- Specified by:
clone
in interfaceITracePoint2D
- Overrides:
clone
in classjava.awt.geom.Point2D
- Returns:
- a cloned instance (deep copy)
- See Also:
ITracePoint2D.clone()
-
compareTo
public int compareTo(ITracePoint2D obj)
- Specified by:
compareTo
in interfacejava.lang.Comparable<ITracePoint2D>
- See Also:
info.monitorenter.gui.chart.ITracePoint2D#compareTo(info.monitorenter.gui.chart.ITracePoint2D)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.awt.geom.Point2D
- See Also:
Point2D.equals(java.lang.Object)
-
getAdditionalPointPainters
public final java.util.Set<IPointPainter<?>> getAdditionalPointPainters()
Description copied from interface:ITracePoint2D
Returns the point painter that additionally (to the trace painter of the chart) paint this point.The original list is returned so painters may be added or removed (even all painters may be cleared).
- Specified by:
getAdditionalPointPainters
in interfaceITracePoint2D
- Returns:
- the point painters that additionally (to the trace painter of the chart) paint this point.
- See Also:
ITracePoint2D.getAdditionalPointPainters()
-
getEuclidDistance
public double getEuclidDistance(double xNormalized, double yNormalized)
Description copied from interface:ITracePoint2D
Returns the Euclid distance of this point's normalized values (
) to the given normalized coordinates.ITracePoint2D.getScaledX()
,ITracePoint2D.getScaledY()
- Specified by:
getEuclidDistance
in interfaceITracePoint2D
- Parameters:
xNormalized
- the normalized x coordinate between 0 and 1.0 to measure the Euclid distance to.yNormalized
- the normalized y coordinate between 0 and 1.0 to measure the Euclid distance to.- Returns:
- the Euclid distance of this point's normalized values (
ITracePoint2D.getScaledX()
,ITracePoint2D.getScaledY()
- See Also:
ITracePoint2D.getEuclidDistance(double, double)
-
getListener
public ITrace2D getListener()
Description copied from interface:ITracePoint2D
Returns the listener trace connected to this trace point.- Specified by:
getListener
in interfaceITracePoint2D
- Returns:
- the listener trace connected to this trace point.
- See Also:
ITracePoint2D.getListener()
-
getManhattanDistance
public double getManhattanDistance(double xNormalized, double yNormalized)
Description copied from interface:ITracePoint2D
Returns the Manhattan distance of this point's normalized values (
) to the given normalized coordinates.ITracePoint2D.getScaledX()
,ITracePoint2D.getScaledY()
- Specified by:
getManhattanDistance
in interfaceITracePoint2D
- Parameters:
xNormalized
- the normalized x coordinate between 0 and 1.0 to measure the Manhattan distance to.yNormalized
- the normalized y coordinate between 0 and 1.0 to measure the Manhattan distance to.- Returns:
- the Manhattan distance of this point's normalized values (
ITracePoint2D.getScaledX()
,ITracePoint2D.getScaledY()
- See Also:
ITracePoint2D.getManhattanDistance(double, double)
-
getManhattanDistance
public double getManhattanDistance(ITracePoint2D point)
Description copied from interface:ITracePoint2D
Returns the Manhattan distance of this point to the given one.- Specified by:
getManhattanDistance
in interfaceITracePoint2D
- Parameters:
point
- the point to measure the Manhattan distance to.- Returns:
- the Manhattan distance of this point to the given one.
- See Also:
ITracePoint2D.getManhattanDistance(info.monitorenter.gui.chart.ITracePoint2D)
-
getScaledX
public final double getScaledX()
- Specified by:
getScaledX
in interfaceITracePoint2D
- Returns:
- the scaledX.
- See Also:
ITracePoint2D.getScaledX()
-
getScaledY
public final double getScaledY()
- Specified by:
getScaledY
in interfaceITracePoint2D
- Returns:
- the scaledY.
- See Also:
ITracePoint2D.getScaledY()
-
getX
public double getX()
Description copied from interface:ITracePoint2D
Returns the x value.- Specified by:
getX
in interfaceITracePoint2D
- Overrides:
getX
in classjava.awt.geom.Point2D.Double
- Returns:
- the x value.
- See Also:
ITracePoint2D.getX()
-
getY
public double getY()
Description copied from interface:ITracePoint2D
Returns the y value.- Specified by:
getY
in interfaceITracePoint2D
- Overrides:
getY
in classjava.awt.geom.Point2D.Double
- Returns:
- the y value.
- See Also:
ITracePoint2D.getY()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.awt.geom.Point2D
- See Also:
Point2D.hashCode()
-
setListener
public void setListener(ITrace2D listener)
Description copied from interface:ITracePoint2D
AllowsITrace2D
instances to register (or de-register) themselves with this point to receive (or stop receiving) change information viaITrace2D.firePointChanged(ITracePoint2D, int)
events.- Specified by:
setListener
in interfaceITracePoint2D
- Parameters:
listener
- The instance that will be informed about changes or null to deregister.- See Also:
ITracePoint2D.setListener(info.monitorenter.gui.chart.ITrace2D)
-
setLocation
public void setLocation(double xValue, double yValue)
Description copied from interface:ITracePoint2D
This method overloads the method ofjava.awt.geom.Point2D.Double
to fire a property change event to listeners of the corresponding
instances via their methodITrace2D
(with int argument set toITrace2D.firePointChanged(ITracePoint2D, int)
).ITracePoint2D.STATE_CHANGED
- Specified by:
setLocation
in interfaceITracePoint2D
- Overrides:
setLocation
in classjava.awt.geom.Point2D.Double
- Parameters:
xValue
- the new x-coordinate for this point.yValue
- the new y-coordinate for this point.- See Also:
ITracePoint2D.setLocation(double, double)
-
setScaledX
public final void setScaledX(double scaledX)
Description copied from interface:ITracePoint2D
Only intended for Chart2D!!!.- Specified by:
setScaledX
in interfaceITracePoint2D
- Parameters:
scaledX
- the scaledX to set- See Also:
ITracePoint2D.setScaledX(double)
-
setScaledY
public final void setScaledY(double scaledY)
Description copied from interface:ITracePoint2D
Only intended for Chart2D!!!.- Specified by:
setScaledY
in interfaceITracePoint2D
- Parameters:
scaledY
- the scaledY to set- See Also:
ITracePoint2D.setScaledY(double)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.awt.geom.Point2D.Double
- See Also:
info.monitorenter.gui.chart.ITracePoint2D#toString()
-
removeAdditionalPointPainter
public boolean removeAdditionalPointPainter(IPointPainter<?> pointPainter)
Description copied from interface:ITracePoint2D
Removes a point painter that additionally (to the pointer painters of the trace (
)) paint this point.ITrace2D.getTracePainters()
- Specified by:
removeAdditionalPointPainter
in interfaceITracePoint2D
- Parameters:
pointPainter
- a point painter that currently is used to additionally (to the trace painter of the chart) paint this point.- Returns:
- true if this point painter was removed (contained before by the
means of
Comparable.compareTo(Object)
- See Also:
ITracePoint2D.removeAdditionalPointPainter(info.monitorenter.gui.chart.IPointPainter)
-
removeAllAdditionalPointPainters
public java.util.Set<IPointPainter<?>> removeAllAdditionalPointPainters()
Description copied from interface:ITracePoint2D
Removes all point painters that additionally (to the pointer painters of the trace (
)) paint this point.ITrace2D.getTracePainters()
- Specified by:
removeAllAdditionalPointPainters
in interfaceITracePoint2D
- Returns:
- all instances that were used before this call.
- See Also:
ITracePoint2D.removeAllAdditionalPointPainters()
-
-