如何调整xyimageannotation中的图像位置
我在 JFreeChart 中有一个图标:
BufferedImage torreIcon = null;
try {
torreIcon = ImageIO.read(getClass().getClassLoader().getResource(
"Resources/Imagenes/torre_control_2.png"));
} catch (IOException e) {
e.printStackTrace();
}
}
我已将此图标添加到 XYPlot
中:
XYAnnotation xyannotation = new XYImageAnnotation(0, 1900, torreIcon);
this.xyplot.addAnnotation(xyannotation);
图表中的结果是:
问题是当我放大时:
<一个href="https://i.sstatic.net/kQO0S.png" rel="nofollow noreferrer">
我希望图标始终位于 x 轴旁边,没有空格,并且大小当然相同。是否可以?
I have a icon in JFreeChart:
BufferedImage torreIcon = null;
try {
torreIcon = ImageIO.read(getClass().getClassLoader().getResource(
"Resources/Imagenes/torre_control_2.png"));
} catch (IOException e) {
e.printStackTrace();
}
}
And I have added this icon to the XYPlot
:
XYAnnotation xyannotation = new XYImageAnnotation(0, 1900, torreIcon);
this.xyplot.addAnnotation(xyannotation);
And the result in the chart is:
The problem is when I make zoom in:
I would like that the icon always be next to the x axis, without space, and with the same size of course. Is it possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正确的;除非另有说明,否则
XYImageAnnotation
使用RectangleAnchor.CENTER
在指定数据空间坐标处居中。相反,指定所需的 <构造
XYImageAnnotation
时的 code>RectangleAnchor:下面的示例将蓝色框架添加到方便的图像中,以便查看图像相对于锚点的绘制方式。原点处的
RectangleAnchor.BOTTOM
如下图所示。当您平移和缩放时,图像保持锚定在原点。尝试其他 RectangleAnchor 实例以查看效果。Correct; unless otherwise specified, an
XYImageAnnotation
is centered at the specified data space coordinates usingRectangleAnchor.CENTER
.Instead, specify the desired
RectangleAnchor
when you construct theXYImageAnnotation
:The example below adds a blue frame to a convenient image in order to see how the image is drawn relative to the anchor.
RectangleAnchor.BOTTOM
at the origin is illustrated below. The image stays anchored to the origin as you pan and zoom. Try the otherRectangleAnchor
instances to see the effect.