Mysterious subtitle

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
vcardona
Posts: 10
Joined: Tue Mar 29, 2005 9:31 pm

Mysterious subtitle

Post by vcardona » Tue Mar 29, 2005 10:11 pm

I am writing a custom chart customization panel that people can use to change the appearance of charts created with JFreeChart. None of the charts should have any subtitles by default so I expected that the code inside the if statement would be skipped.

Code: Select all

if (chart.getSubtitleCount() > 0)
{
        this.txtSubTitle.setText(((TextTitle) chart.getSubtitle(0)).getText());
        this.txtSubtitleFont.setText(((TextTitle) chart.getSubtitle(0)).getFont().toString());
}
It isn't skipped, and instead I get a ClassCastException. Apparently, the call to getSubtitle is returning a LegendTitle instance. I have looked at the code for JFreeChart, and can't find where this mysterious subtitle is being created. Can someone shed some light on this please.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Wed Mar 30, 2005 11:02 pm

In the latest release, a new LegendTitle class is used to display the legend. It is now a regular chart title (or subtitle) so you can place it anywhere a chart title can go, and you can have more than one legend. The legend is created in the JFreeChart constructor.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

vcardona
Posts: 10
Joined: Tue Mar 29, 2005 9:31 pm

Post by vcardona » Thu Mar 31, 2005 4:11 pm

Great! Thanks for shedding some light on that.

Locked