public class CandleStick extends TracePoint2D
See http://en.wikipedia.org/wiki/Candlestick_chart
This implementation only works correctly with a special candlestick point painter.
The original TracePoint2D.getY()
method is mapped to getStart()
. The
original TracePoint2D.getX()
method is sufficient to be related to all other y
values as a candlestick has a single point in time (x value).
Point2D.Double, Point2D.Float
ITracePoint2D.STATE
x, y
Constructor and Description |
---|
CandleStick(double xValue,
double startY,
double endY,
double highY,
double lowY)
Constructor with every argument needed.
|
Modifier and Type | Method and Description |
---|---|
double |
getEnd()
Returns the end y value.
|
double |
getEuclidDistance(double xNormalized,
double yNormalized)
Returns the Euclid distance of this point's normalized values (
) to the given
normalized coordinates. |
protected double |
getEuclidDistance(double xNormalized,
double yNormalized,
double myScaledX,
double myScaledY)
Internal helper that returns the eculid distance between the given
"outside" coordinates (mouse move) and the "inside" coordinates.
|
double |
getHigh()
Returns the high y value.
|
double |
getLow()
Returns the low y value.
|
double |
getManhattanDistance(double xNormalized,
double yNormalized)
Returns the Manhattan distance of this point's normalized values (
) to the given
normalized coordinates. |
double |
getManhattanDistance(double xNormalized,
double yNormalized,
double myScaledX,
double myScaledY)
Internal helper that returns the manhattan distance between the given
"outside" coordinates (mouse move) and the "inside" 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 |
getStart()
Returns the start y value.
|
String |
getTooltipText()
Returns the tool tip text that should be displayed in case this trace point
is selected to show a tool tip.
|
protected double |
scaleX(double value)
Helper to scale the additional values in this trace.
|
protected double |
scaleY(double value)
Helper to scale the additional values in this trace.
|
addAdditionalPointPainter, clone, compareTo, equals, getAdditionalPointPainters, getListener, getScaledX, getScaledY, getX, getY, hashCode, isDiscontinuation, isVisble, removeAdditionalPointPainter, removeAllAdditionalPointPainters, setListener, setLocation, setScaledX, setScaledY, toString
distance, distance, distance, distanceSq, distanceSq, distanceSq, setLocation
public CandleStick(double xValue, double startY, double endY, double highY, double lowY)
xValue
- the x coordinate.startY
- the start y value.endY
- the end y value.highY
- the high y value.lowY
- the low y value.public double getEnd()
public double getEuclidDistance(double xNormalized, double yNormalized)
ITracePoint2D
ITracePoint2D.getScaledX()
, ITracePoint2D.getScaledY()
) to the given
normalized coordinates.
getEuclidDistance
in interface ITracePoint2D
getEuclidDistance
in class TracePoint2D
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.
ITracePoint2D.getScaledX()
, ITracePoint2D.getScaledY()
) to the given
normalized coordinates.TracePoint2D.getEuclidDistance(double,
double)
protected final double getEuclidDistance(double xNormalized, double yNormalized, double myScaledX, double myScaledY)
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.myScaledX
- the normalized x "inside" coordinate between 0 and 1.0 to measure
the Euclid distance to.myScaledY
- the normalized y "inside" coordinate between 0 and 1.0 to measure
the Euclid distance to.public double getHigh()
public double getLow()
public double getManhattanDistance(double xNormalized, double yNormalized)
ITracePoint2D
ITracePoint2D.getScaledX()
, ITracePoint2D.getScaledY()
) to the given
normalized coordinates.
getManhattanDistance
in interface ITracePoint2D
getManhattanDistance
in class TracePoint2D
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.
ITracePoint2D.getScaledX()
, ITracePoint2D.getScaledY()
) to the given
normalized coordinates.TracePoint2D.getManhattanDistance(double,
double)
public double getManhattanDistance(double xNormalized, double yNormalized, double myScaledX, double myScaledY)
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.myScaledX
- the normalized x "inside" coordinate between 0 and 1.0 to measure
the manhattan distance to.myScaledY
- the normalized y "inside" coordinate between 0 and 1.0 to measure
the manhattan distance to.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 ITracePoint2D
getNormalizedHighlightSweetSpotCoordinates
in class TracePoint2D
ITracePoint2D.getX()
and ITracePoint2D.getY()
.TracePoint2D.getNormalizedHighlightSweetSpotCoordinates()
public double getStart()
Note: this is the reused inherited TracePoint2D.getY()
.
public String getTooltipText()
ITracePoint2D
getTooltipText
in interface ITracePoint2D
getTooltipText
in class TracePoint2D
ITracePoint2D.getTooltipText()
protected double scaleX(double value)
FIXME: Think about caching or move this to the axis code along with setters? Should be profiled.
value
- the internal value to scale.protected double scaleY(double value)
FIXME: Think about caching or move this to the axis code along with setters? Should be profiled.
value
- the internal value to scale.Copyright © 2019. All rights reserved.