info.monitorenter.gui.chart
Class TracePoint2D

java.lang.Object
  extended by java.awt.geom.Point2D
      extended by java.awt.geom.Point2D.Double
          extended by info.monitorenter.gui.chart.TracePoint2D
All Implemented Interfaces:
Serializable, Cloneable, Comparable

public class TracePoint2D
extends Point2D.Double
implements Comparable, Serializable, Cloneable

A specialized version of java.awt.Point2D.Double who carries two further values: double scaledX and double scaledY which allow the Chart2D 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 a ITrace2D instance managed by a Chart2D there remains no responsibility for sorting the cached copy. This allows that the managing Chart2D 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: The TracePoint2D passed to the method traceChanged(Chart2DDataChangeEvent e) coded in the argument is the original.

Why caching of scaled values for the coordinates?
This takes more RAM but else for every repaint() invocation of the Chart2D 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.11 $
Author:
Achim Westermann Achim.Westermann@gmx.de
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Point2D
Point2D.Double, Point2D.Float
 
Field Summary
protected  boolean m_scaledOnce
          Flag for the Chart2D painter that allows it to render only instances he has processed before.
 double m_scaledX
          Public level for the access of AAxis.
 double m_scaledY
          Public level for the access of AAxis.
static int STATE_ADDED
          The state flag used to inform the ITrace2D listener via ITrace2D.firePointChanged(TracePoint2D, int) in case a point was added.
static int STATE_CHANGED
          The state flag used to inform the ITrace2D listener via ITrace2D.firePointChanged(TracePoint2D, int) in case a point was changed.
static int STATE_REMOVED
          The state flag used to inform the ITrace2D listener via ITrace2D.firePointChanged(TracePoint2D, int) in case a point was removed.
 
Fields inherited from class java.awt.geom.Point2D.Double
x, y
 
Constructor Summary
TracePoint2D(double xValue, double yValue)
          Construct a TracePoint2D whose coords are initalized to (x,y).
 
Method Summary
 Object clone()
           
 int compareTo(Object obj)
          Compares to TracePoint2D instances by their x value in ascending order.
 boolean equals(Object o)
           
 int hashCode()
           
 void setListener(ITrace2D listener)
          Allows ITrace2D instances to register (or deregister) themselves with this point to receive (or stop receiving) change information via ITrace2D.firePointChanged(TracePoint2D, int) events.
 void setLocation(double xValue, double yValue)
          This method overloads the method of java.awt.geom.Point2D.Double to fire a property change event to listeners of the corresponding ITrace2D instances via their method ITrace2D.firePointChanged(TracePoint2D, int) (with int argument set to STATE_CHANGED).
 
Methods inherited from class java.awt.geom.Point2D.Double
getX, getY, toString
 
Methods inherited from class java.awt.geom.Point2D
distance, distance, distance, distanceSq, distanceSq, distanceSq, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

STATE_ADDED

public static final transient int STATE_ADDED
The state flag used to inform the ITrace2D listener via ITrace2D.firePointChanged(TracePoint2D, int) in case a point was added.

See Also:
Constant Field Values

STATE_REMOVED

public static final transient int STATE_REMOVED
The state flag used to inform the ITrace2D listener via ITrace2D.firePointChanged(TracePoint2D, int) in case a point was removed.

See Also:
Constant Field Values

STATE_CHANGED

public static final transient int STATE_CHANGED
The state flag used to inform the ITrace2D listener via ITrace2D.firePointChanged(TracePoint2D, int) in case a point was changed.

Will be used by setLocation(double, double) and Point2D.setLocation(Point2D).

See Also:
Constant Field Values

m_scaledOnce

protected boolean m_scaledOnce
Flag for the Chart2D painter that allows it to render only instances he has processed before.


m_scaledX

public double m_scaledX
Public level for the access of AAxis.


m_scaledY

public double m_scaledY
Public level for the access of AAxis.

Constructor Detail

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

clone

public Object clone()
Overrides:
clone in class Point2D
See Also:
Object.clone()

compareTo

public int compareTo(Object obj)
              throws ClassCastException
Compares to TracePoint2D instances by their x value in ascending order.

Specified by:
compareTo in interface Comparable
Parameters:
obj - the point to compare to this instance.
Returns:
-1 if the given point has a higher x value, 0 if it has the same value or 1 if it has a lower x value.
Throws:
ClassCastException - if the given instance is not of this type.
See Also:
Comparable.compareTo(java.lang.Object)

equals

public boolean equals(Object o)
Overrides:
equals in class Point2D
See Also:
Object.equals(java.lang.Object)

hashCode

public int hashCode()
Overrides:
hashCode in class Point2D
See Also:
Object.hashCode()

setListener

public void setListener(ITrace2D listener)
Allows ITrace2D instances to register (or deregister) themselves with this point to receive (or stop receiving) change information via ITrace2D.firePointChanged(TracePoint2D, int) events.

Parameters:
listener - The instance that will be informed about changes or null to deregister.

setLocation

public void setLocation(double xValue,
                        double yValue)
This method overloads the method of java.awt.geom.Point2D.Double to fire a property change event to listeners of the corresponding ITrace2D instances via their method ITrace2D.firePointChanged(TracePoint2D, int) (with int argument set to STATE_CHANGED).

Overrides:
setLocation in class Point2D.Double
Parameters:
xValue - the new x-coordinate for this point.
yValue - the new y-coordinate for this point.


Copyright © 2001 - 2007 LGPL, All Rights Footloose.