Is there a way in the standard JFreeChart packages to add a label to a Marker Line to describe what the line represents?
If not I have a simple implementation you guys may want to include.
First I overrode Marker to create my own class WBSMarker that contained a TextTitle property called label.
Then I overrode VeriticalBarRenderer and created my own "drawRangeMarker"
My guess is you guys could do a better job of implementing this feature and I problem just can't find how to do it.
Thanks for the great charting package.
Jeff Chaney
/**
* Draws a marker for the range axis.
* <P>
* A marker is a constant value, usually represented by a line.
*
* @param g2 the graphics device.
* @param plot the plot.
* @param axis the range axis.
* @param marker the marker to be drawn.
* @param axisDataArea the area inside the axes.
* @param dataClipRegion the data clip area.
*/
public void drawRangeMarker(Graphics2D g2,
CategoryPlot plot,
ValueAxis axis,
Marker marker,
Rectangle2D axisDataArea,
Shape dataClipRegion) {
super.drawRangeMarker(g2, plot, axis, marker, axisDataArea, dataClipRegion);
if (marker instanceof WBSMarker) {
TextTitle label = ((WBSMarker)marker).getLabel();
String s = label.getText();
Double x = new Double(axisDataArea.getMinX());
Double y = new Double(axis.translateValueToJava2D(marker.getValue(), axisDataArea));
int w = g2.getFontMetrics(label.getFont()).stringWidth(label.getText());
g2.setFont(label.getFont());
g2.setPaint(label.getPaint());
g2.drawString(s, x.floatValue() - w, y.floatValue());
}
}