Im trying to layer annotations on my JFreeChart
. Currently the annotations appear above my graph, but I want them to appear bellow the point.
xyPlot.addAnnotation(MECamVisArea, Layer.BACKGROUND);
When I enter this line, I get an error message that says incompatible type layer can't be converted to Boolean
. I'll leave my full annotation code bellow.
XYPolygonAnnotation MECamVisArea = new XYPolygonAnnotation(new double[]{0.0, 0.0,
defaultPosX, (defaultPosX*tan(0.907571)), defaultPosX, -(defaultPosX*tan(0.907571))}) {
@Override
public void draw(Graphics2D g2, XYPlot plot, Rectangle2D dataArea, ValueAxis
domainAxis, ValueAxis rangeAxis, int rendererIndex, PlotRenderingInfo info) {
Graphics2D g22 = (Graphics2D) g2.create();
g22.setXORMode(new Color(0xff3300));
super.draw(g22, plot, dataArea, domainAxis, rangeAxis, rendererIndex, info);
}
};
xyPlot.addAnnotation(MECamVisArea, Layer.BACKGROUND);
As shown here, you are adding your XYPolygonAnnotation
to an XYPlot
, which offers an addAnnotation()
method that expects a boolean
parameter. Instead, add the annotation to your chosen XYItemRenderer
, which offer an addAnnotation()
method that expects an org.jfree.ui.Layer
parameter.