0

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));

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?

========

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

=======

Richard B
  • 895
  • 13
  • 39

1 Answers1

1

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

Richard B
  • 895
  • 13
  • 39