HI,
I am trying to use XYShapeAnnotation to draw shapes in a candlestick chart, at coordinates of specific candles. But I got stuck at the coordinates that have to be given to a shape before it can be drawn.
The DomainAxis consists of date objects. How can I translate those into java coordinates?
thanks alot!
Coordinates for XYShapeAnnotation?
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Coordinates for XYShapeAnnotation?
As shown here, XYShapeAnnotation coordinates should be specified relative to the data. As shown here, date values represent the number of milliseconds from the Java epoch. As shown here, use TimeSeries::getDataItem to get a particular TimeSeriesDataItem, and use TimeSeriesDataItem::getPeriod to get the item's timestamp.
Re: Coordinates for XYShapeAnnotation?
Thanks for your answer and the links. I really appreciate it.
There is one thing I don't understand though.
Shapes need int for x and y. But Epoch with milliseconds is long and too big for conversion to int (and y in my case is double, which would be the next problem). How can I use Shapes then? If it is not possible, is there another way to draw geometric shapes (all I need is triangles, rectangles and circles)?
There is one thing I don't understand though.
Shapes need int for x and y. But Epoch with milliseconds is long and too big for conversion to int (and y in my case is double, which would be the next problem). How can I use Shapes then? If it is not possible, is there another way to draw geometric shapes (all I need is triangles, rectangles and circles)?
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Coordinates for XYShapeAnnotation?
The shape's coordinates are data coordinates, not screen coordinates. A typical concrete implementation of java.awt.Shape contains nested classes with constructors that accept float or double arguments, e.g. Ellipse2D.Double in the first example cited.