A brief note for those looking for dot-specific labels when using XYDotRenderer...
For some reason the capability to make labels visible does not appear to be in XYDotRenderer.
A rapid temporary work around is as follows:
Code: Select all
/*
* !!!!!! TEMPORARY WORK AROUND. USES CODE COPIED FROM JFreeChart (LGPL)
*/
public class XYDotRendererWithLabels extends XYDotRenderer {
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) {
super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis,
dataset, series, item, crosshairState, pass);
PlotOrientation orientation = plot.getOrientation();
double x = dataset.getXValue(series, item);
double y = dataset.getYValue(series, item);
RectangleEdge xAxisLocation = plot.getDomainAxisEdge();
RectangleEdge yAxisLocation = plot.getRangeAxisEdge();
double transX1 = domainAxis.valueToJava2D(x, dataArea, xAxisLocation);
double transY1 = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation);
if(isItemLabelVisible(series, item)) {
drawItemLabel(g2, orientation, dataset, series, item, transX1, transY1, (y < 0.0));
}
}
}
Regards, Matthew