I will tell the whole story...
The task is to draw in a Timeseries chart items as vertical lines, the line length should be the lenght of my items, that means :
I have objects which has begin time and end time, the line should start in the begin time and ends in the end time, to do this I built another time serieses for the end times but didn't display them, and then override the getItemShape function to make it create a line shape for the item in the series.
I use the getXValue and getYvalue for each point and then use valueToJava2D with the value and the (domainAxisEdge,rangeAxisEdge) and the PROBLEMATIC one dataArea as the second parameter......
if I use the plotArea or dataArea the items in the chart displayed in the wrong places, but if I use like this
Code: Select all
Rectangle2D rect = new Rectangle2D.Double(0,0,0,0);
valueToJava2D(endYValue, rect, yEdge);
Code: Select all
private Shape createShape(BusinessActionInstance bai, Rectangle2D dataArea, int series, int item) {
RectangleEdge xEdge = getPlot().getDomainAxisEdge();
RectangleEdge yEdge = getPlot().getRangeAxisEdge();
// Rectangle2D rect = new Rectangle2D.Double(0, 0, 700, 250);
// Rectangle2D rect = new Rectangle2D.Double(0,0,0,0);
double beginXValue = this.dataset.getXValue(series, item);
double endXValue = this.dataset.getXValue(series + 6, item);
double beginYValue = this.dataset.getYValue(series, item);
double endYValue = this.dataset.getYValue(series, item);
double x1 = getPlot().getDomainAxis().valueToJava2D(beginXValue, dataArea, xEdge);
double x2 = getPlot().getDomainAxis().valueToJava2D(endXValue, dataArea, xEdge);
double y1 = getPlot().getRangeAxis().valueToJava2D(beginYValue, dataArea, yEdge);
double y2 = getPlot().getRangeAxis().valueToJava2D(endYValue, dataArea, yEdge);
// if((x2 - x1) < 1) x2 = x1 + 5;
Double line = new Line2D.Double(x1, y1, x2, y2);
return ShapeUtilities.createLineRegion(line, 2.0f);
}
Thanks