JFreeChart 的分层注释
Layering annotations for JFreeChart
我正在尝试在 JFreeChart
上添加注释。目前注释出现在我的图表上方,但我希望它们出现在点下方。
xyPlot.addAnnotation(MECamVisArea, Layer.BACKGROUND);
当我输入这一行时,我收到一条错误消息,指出不兼容的类型图层无法转换为 Boolean
。我将在下面留下我的完整注释代码。
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);
如图所示 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()
需要 org.jfree.ui.Layer
参数的方法。
我正在尝试在 JFreeChart
上添加注释。目前注释出现在我的图表上方,但我希望它们出现在点下方。
xyPlot.addAnnotation(MECamVisArea, Layer.BACKGROUND);
当我输入这一行时,我收到一条错误消息,指出不兼容的类型图层无法转换为 Boolean
。我将在下面留下我的完整注释代码。
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);
如图所示 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()
需要 org.jfree.ui.Layer
参数的方法。