public class TracePoint2D extends Point2D.Double implements ITracePoint2D
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.
Point2D.Double, Point2D.FloatITracePoint2D.STATEx, y| Modifier | Constructor and Description |
|---|---|
protected |
TracePoint2D()
Intended for
only. |
|
TracePoint2D(double xValue,
double yValue)
Construct a TracePoint2D whose coords are initalized to (x,y).
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addAdditionalPointPainter(IPointPainter<?> additionalPointPainter)
Adds a point painter that additionally (to the pointer painters of the
trace (
)) paint this
point. |
Object |
clone()
Returns a cloned instance (deep copy).
|
int |
compareTo(ITracePoint2D obj) |
boolean |
equals(Object obj) |
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. |
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. |
double[] |
getNormalizedHighlightSweetSpotCoordinates()
Returns the normalized coordinates of this point that should be highlighted
or null if
new double[]{this.getX(), this.getY()};
is the position to highlight. |
double |
getScaledX() |
double |
getScaledY() |
String |
getTooltipText()
Returns the tool tip text that should be displayed in case this trace point
is selected to show a tool tip.
|
double |
getX()
Returns the x value.
|
double |
getY()
Returns the y value.
|
int |
hashCode() |
boolean |
isDiscontinuation()
Returns true if
ITracePoint2D.getX() and/or ITracePoint2D.getY() is
Double.NaN which signals a discontinuation. |
boolean |
isVisble()
Returns true if
ITracePoint2D.getScaledX() AND ITracePoint2D.getScaledY() is in the
range [0.0..1.0] and ITracePoint2D.isDiscontinuation() returns false. |
boolean |
removeAdditionalPointPainter(IPointPainter<?> pointPainter)
Removes a point painter that additionally (to the pointer painters of the
trace (
)) paint this
point. |
Set<IPointPainter<?>> |
removeAllAdditionalPointPainters()
Removes all point painters that additionally (to the pointer painters of
the trace (
)) paint this
point. |
void |
setListener(ITrace2D listener)
Allows
ITrace2D instances to register (or de-register)
themselves with this point to receive (or stop receiving) change
information via
ITrace2D#firePointChanged(ITracePoint2D, STATE, Object, Object)
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 instances
via their method
(with int argument set to ). |
void |
setScaledX(double scaledX)
Only intended for Chart2D!!!.
|
void |
setScaledY(double scaledY)
Only intended for Chart2D!!!.
|
String |
toString() |
distance, distance, distance, distanceSq, distanceSq, distanceSq, setLocationprotected TracePoint2D()
TracePointProviderDefault only.
public TracePoint2D(double xValue,
double yValue)
xValue - the x value to use.yValue - the y value to use.public final boolean addAdditionalPointPainter(IPointPainter<?> additionalPointPainter)
ITracePoint2DITrace2D.getTracePainters() )) paint this
point.
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
and
ITrace2D.addPointHighlighter(IPointPainter)Chart2D.enablePointHighlighting(boolean).
addAdditionalPointPainter in interface ITracePoint2DadditionalPointPainter - a point painter that will additionally (to the trace painter of
the chart) paint this point. Comparable.compareTo(Object)
.ITracePoint2D.addAdditionalPointPainter(info.monitorenter.gui.chart.IPointPainter)public Object clone()
ITracePoint2Dclone in interface ITracePoint2Dclone in class Point2DITracePoint2D.clone()public int compareTo(ITracePoint2D obj)
compareTo in interface Comparable<ITracePoint2D>info.monitorenter.gui.chart.ITracePoint2D#compareTo(info.monitorenter.gui.chart.ITracePoint2D)public boolean equals(Object obj)
equals in class Point2DPoint2D.equals(java.lang.Object)public final Set<IPointPainter<?>> getAdditionalPointPainters()
ITracePoint2DThe original list is returned so painters may be added or removed (even all painters may be cleared).
getAdditionalPointPainters in interface ITracePoint2DITracePoint2D.getAdditionalPointPainters()public double getEuclidDistance(double xNormalized,
double yNormalized)
ITracePoint2DITracePoint2D.getScaledX(), ITracePoint2D.getScaledY()) to the given
normalized coordinates.
getEuclidDistance in interface ITracePoint2DxNormalized - 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.
ITracePoint2D.getScaledX(), ITracePoint2D.getScaledY()) to the given
normalized coordinates.ITracePoint2D.getEuclidDistance(double,
double)public final ITrace2D getListener()
ITracePoint2DgetListener in interface ITracePoint2DITracePoint2D.getListener()public double getManhattanDistance(double xNormalized,
double yNormalized)
ITracePoint2DITracePoint2D.getScaledX(), ITracePoint2D.getScaledY()) to the given
normalized coordinates.
getManhattanDistance in interface ITracePoint2DxNormalized - 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.
ITracePoint2D.getScaledX(), ITracePoint2D.getScaledY()) to the given
normalized coordinates.ITracePoint2D.getManhattanDistance(double,
double)public double[] getNormalizedHighlightSweetSpotCoordinates()
ITracePoint2D
new double[]{this.getX(), this.getY()};
is the position to highlight.
Trace point implementations (like CandleStick) render larger spaces
than their center coordinate. Those may return the area of interest that
should be highlighted.
getNormalizedHighlightSweetSpotCoordinates in interface ITracePoint2DITracePoint2D.getX() and ITracePoint2D.getY().ITracePoint2D.getNormalizedHighlightSweetSpotCoordinates()public final double getScaledX()
getScaledX in interface ITracePoint2DITracePoint2D.getScaledX()public final double getScaledY()
getScaledY in interface ITracePoint2DITracePoint2D.getScaledY()public String getTooltipText()
ITracePoint2DgetTooltipText in interface ITracePoint2DITracePoint2D.getTooltipText()public double getX()
ITracePoint2DgetX in interface ITracePoint2DgetX in class Point2D.DoubleITracePoint2D.getX()public double getY()
ITracePoint2DgetY in interface ITracePoint2DgetY in class Point2D.DoubleITracePoint2D.getY()public int hashCode()
hashCode in class Point2DPoint2D.hashCode()public boolean isDiscontinuation()
ITracePoint2DITracePoint2D.getX() and/or ITracePoint2D.getY() is
Double.NaN which signals a discontinuation.
isDiscontinuation in interface ITracePoint2DITracePoint2D.getX() and/or ITracePoint2D.getY() is
Double.NaN which signals a discontinuation.ITracePoint2D.isDiscontinuation()public boolean isVisble()
ITracePoint2DITracePoint2D.getScaledX() AND ITracePoint2D.getScaledY() is in the
range [0.0..1.0] and ITracePoint2D.isDiscontinuation() returns false.
This call only makes sense after the point has been added to a trace.
isVisble in interface ITracePoint2DITracePoint2D.getScaledX() AND ITracePoint2D.getScaledY() is in the
range [0.0..1.0] and ITracePoint2D.isDiscontinuation() returns false.ITracePoint2D.isVisble()public boolean removeAdditionalPointPainter(IPointPainter<?> pointPainter)
ITracePoint2DITrace2D.getTracePainters() )) paint this
point.
removeAdditionalPointPainter in interface ITracePoint2DpointPainter - a point painter that currently is used to additionally (to the
trace painter of the chart) paint this point. Comparable.compareTo(Object) .ITracePoint2D.removeAdditionalPointPainter(info.monitorenter.gui.chart.IPointPainter)public Set<IPointPainter<?>> removeAllAdditionalPointPainters()
ITracePoint2DITrace2D.getTracePainters() )) paint this
point.
removeAllAdditionalPointPainters in interface ITracePoint2DITracePoint2D.removeAllAdditionalPointPainters()public final void setListener(ITrace2D listener)
ITracePoint2DITrace2D instances to register (or de-register)
themselves with this point to receive (or stop receiving) change
information via
ITrace2D#firePointChanged(ITracePoint2D, STATE, Object, Object)
events.
setListener in interface ITracePoint2Dlistener - The instance that will be informed about changes or null to
deregister.ITracePoint2D.setListener(info.monitorenter.gui.chart.ITrace2D)public void setLocation(double xValue,
double yValue)
ITracePoint2Djava.awt.geom.Point2D.Double to fire a property change event
to listeners of the corresponding ITrace2D instances
via their method
ITrace2D#firePointChanged(ITracePoint2D, STATE, Object, Object)
(with int argument set to ITracePoint2D.STATE.CHANGED).
setLocation in interface ITracePoint2DsetLocation in class Point2D.DoublexValue - the new x-coordinate for this point.yValue - the new y-coordinate for this point.ITracePoint2D.setLocation(double, double)public final void setScaledX(double scaledX)
ITracePoint2DsetScaledX in interface ITracePoint2DscaledX - the scaledX to setITracePoint2D.setScaledX(double)public final void setScaledY(double scaledY)
ITracePoint2DsetScaledY in interface ITracePoint2DscaledY - the scaledY to setITracePoint2D.setScaledY(double)public String toString()
toString in class Point2D.Doubleinfo.monitorenter.gui.chart.ITracePoint2D#toString()Copyright © 2017. All rights reserved.