A discussion forum for JFreeChart (a 2D chart library for the Java platform).
-
Rahan
- Posts: 12
- Joined: Fri Jul 08, 2005 3:30 pm
Post
by Rahan » Wed Aug 16, 2006 6:26 pm
Hallo i need an idea
The Title of my chart should have a new line break.
And the second line should be in the centre (not left like a big title)
gives a substitution like \n ?
Thanks

-
oacis
- Posts: 101
- Joined: Fri Jan 07, 2005 5:57 am
- Location: Australia, Sydney
Post
by oacis » Thu Aug 17, 2006 12:16 am
There is a problem with drawing strings with a new line character in them. One workaraund at the moment is to add subtitles for each line you wish to display.
-
Rahan
- Posts: 12
- Joined: Fri Jul 08, 2005 3:30 pm
Post
by Rahan » Thu Aug 17, 2006 10:00 am
Subtitles have the Problem that they are not have a method "setFont()" and then the font is very smal. You know an other method?
-
matinh
- Posts: 483
- Joined: Fri Aug 11, 2006 10:08 am
- Location: Austria
Post
by matinh » Thu Aug 17, 2006 10:11 am
Rahan wrote:Subtitles have the Problem that they are not have a method "setFont()" and then the font is very smal. You know an other method?
They do. Try something like this:
Code: Select all
TextTitle t = new TextTitle("whatever");
t.setFont(new Font("Arial", Font.PLAIN, 14));
chart.addSubtitle(t);
hth,
- martin
-
Rahan
- Posts: 12
- Joined: Fri Jul 08, 2005 3:30 pm
Post
by Rahan » Thu Aug 17, 2006 6:34 pm
Yes i try it, too.
Here my Code for update the header with linebreak substituon -n
Code: Select all
protected void generateTitle (String titles, JFreeChart chart) {
int numberOfSubtitle = (int)chart.getSubtitleCount();
String[] result = titles.split("-n");
chart.setTitle( result[0]);
System.out.println(result.length);
for (int a=0+numberOfSubtitle; a<result.length; ++a) {
TextTitle subtitle = new TextTitle(result[a]);
chart.addSubtitle(subtitle);
chart.getSubtitle(a).setPosition(RectangleEdge.TOP);
TextTitle subi = (TextTitle) chart.getSubtitle(a);
subi.setFont(chart.getTitle().getFont());
}
-
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 » Fri Aug 18, 2006 9:02 am
The title/subtitle mechanism is supposed to make it easy to add new types of titles, so if someone wants to contribute a custom title class that can handle multiple lines, that would be welcome.