public void drawItem(Graphics2D g2,
XYItemRendererState state,
Rectangle2D dataArea,
PlotRenderingInfo info,
XYPlot plot,
ValueAxis domainAxis,
ValueAxis rangeAxis,
XYDataset dataset,
int series,
int item,
CrosshairState crosshairState,
int pass) {
// setup for collecting optional entity info...
Shape entityArea = null;
EntityCollection entities = null;
if (info != null) {
entities = info.getOwner().getEntityCollection();
}
IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset;
double x = intervalDataset.getXValue(series, item);
double yLow = intervalDataset.getStartYValue(series, item);
double yHigh = intervalDataset.getEndYValue(series, item);
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
double xx = domainAxis.valueToJava2D(x, dataArea, xAxisLocation);
double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, yAxisLocation);
double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, yAxisLocation);
Paint p = getItemPaint(series, item);
Stroke s = getItemStroke(series, item);
Line2D line = null;
Shape shape = getItemShape(series, item);
Shape top = null;
Shape bottom = null;
PlotOrientation orientation = plot.getOrientation();
if (orientation == PlotOrientation.HORIZONTAL) {
line = new Line2D.Double(yyLow, xx, yyHigh, xx);
top = ShapeUtilities.createTranslatedShape(shape, yyHigh, xx);
bottom = ShapeUtilities.createTranslatedShape(shape, yyLow, xx);
}
else if (orientation == PlotOrientation.VERTICAL) {
line = new Line2D.Double(xx, yyLow, xx, yyHigh);
top = ShapeUtilities.createTranslatedShape(shape, xx, yyHigh);
bottom = ShapeUtilities.createTranslatedShape(shape, xx, yyLow);
}
g2.setPaint(p);
g2.setStroke(s);
g2.draw(line);
g2.fill(top);
g2.fill(bottom);
// for item labels, we have a special case because there is the
// possibility to draw (a) the regular item label near to just the
// upper y-value, or (b) the regular item label near the upper y-value
// PLUS an additional item label near the lower y-value.
if (isItemLabelVisible(series, item)) {
drawItemLabel(g2, orientation, dataset, series, item, xx, yyHigh,
false);
drawAdditionalItemLabel(g2, orientation, dataset, series, item,
xx, yyLow);
}
// add an entity for the item...
if (entities != null) {
if (entityArea == null) {
entityArea = line.getBounds();
}
String tip = null;
XYToolTipGenerator generator = getToolTipGenerator(series, item);
if (generator != null) {
tip = generator.generateToolTip(dataset, series, item);
}
String url = null;
if (getURLGenerator() != null) {
url = getURLGenerator().generateURL(dataset, series, item);
}
XYItemEntity entity = new XYItemEntity(entityArea, dataset, series,
item, tip, url);
entities.add(entity);
}
}
Draws the visual representation of a single data item. |