无需图形缩放即可绘制注释形状 [英] Drawing annotation shapes without graph scaling

查看:46
本文介绍了无需图形缩放即可绘制注释形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JFreeChart创建图:

I'm creating graphs using JFreeChart:

问题应该很清楚.我在图形上绘制的圆圈显示为椭圆形,因为我的图形已按比例缩小以适合我的尺寸.

The problem should be fairly clear. My circles which I'm drawing on the graph are showing up as ovals, since my graph is being scaled down to fit within my dimensions.

这是我绘制圆圈注释的方式:

Here's how I'm drawing the circle annotations:

chart.getXYPlot().addAnnotation(
    new XYShapeAnnotation(
        new Ellipse2D.Float(pointX - 15, pointY - 15, 30, 30),
        new BasicStroke(0.5), Color.BLACK, Color.GREEN
    )
);

如何在不缩小注释的情况下绘制注释?有没有办法在图形上绘制图形,将全局/实际X/Y点转换为局部/缩放的X/Y点?

How can I draw an annotation without it being scaled down? Is there a way to draw on top of the graph, translating global/real X/Y points into local/scaled X/Y points?

推荐答案

作为替代方法,请尝试使用不缩放比例的

As an alternative, try one of the scale-invariant annotations such as XYImageAnnotation or XYPointerAnnotation. For example,

chart.getXYPlot().addAnnotation(
        new XYPointerAnnotation("Bam!", pointX, pointY, 0));

这篇关于无需图形缩放即可绘制注释形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆