JFreeChart 文本注释不起作用? [英] JFreeChart Text Annotations not Working?

查看:44
本文介绍了JFreeChart 文本注释不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎遇到了 JFreeChart XYPlot 中的测试注释问题.我可以如下设置文本注释

I seem to be getting problems with test annotations in JFreeChart XYPlot. I can set a text annotation as follows

XYTextAnnotation textAnnotaion = new XYTextAnnotation(description, xMid, yMid);
plot.addAnnotation(textAnnotaion);

我也可以通过添加来旋转文本

I can also rotate the text by adding

textAnnotaion.setRotationAngle(90.0);

但是如果我尝试更改字体类型/大小或颜色,它似乎不起作用

But if I try to change the font type/size or colour it doesn't seem to work

textAnnotaion.setFont(new Font("Tahoma", Font.BOLD, 20));
textAnnotaion.setPaint(new Color(255, 255, 255, 15));

字体保持黑色和默认类型/大小.奇怪的是,功能在烛台图表上看起来不错,但不是普通的 XYPlot

The font stays black and of the default type/size. Strangely the functionality seems fine on a candlestick chart but not a plain vanilla XYPlot

有没有其他人遇到过这种情况,或者我做错了什么?

Has anyone else experienced this or am I doing something wrong?

========

我似乎已经解决了这个问题.在我的烛台图表代码中,数据集在构建时添加到图表中.添加文本注释似乎可以正常工作.在我的 XYPlot 的情况下,我使用空的 XYSeriesCollection 创建绘图,然后即时添加数据系列.

I seem to have figured out the issue. In my code for the candlestick chart the dataset is added to the chart at time of construction. Adding text annotations appears to work correctly. In the case of my XYPlot I create the plot with an empty XYSeriesCollection and, subsequently, add data series on the fly.

如果我添加文本注释,然后将框架设置为可见,则不会应用字体更改(颜色和类型).如果我将框架设置为可见,然后应用注释,一切似乎都很好.它开始看起来像一个错误......

If I add the text annotation and then set the frame visible the font changes (colour and type) do not get applied. If I set the frame visible and then apply the annotation all seems fine. It's beginning to look like a bug....

========

推荐答案

恐怕我的代码中存在错误.在更改注释格式之前,似乎必须应用主题....

A bug in my code I'm afraid. It looks like a theme must be applied before you alter the format of an annotation....

这篇关于JFreeChart 文本注释不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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