JFreeChart的文本注释不工作? [英] JFreeChart Text Annotations not Working?

查看:294
本文介绍了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?

========

我似乎想通了这个问题。在我的code为阴阳烛图的数据集在施工时添加到图。添加文本注释似乎正常工作。在我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.

如果我添加文字标注,然后设置帧可见字体的变化(颜色和类型)没有得到应用。如果我设置帧可见,然后应用注释一切似乎罚款。它开始看起来像一个bug ....

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....

=======

推荐答案

在我的code的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天全站免登陆