Hi
I would like to know how can one change the font colour of the title, legend axis and so on.
Thanxs
A.M
changing font colour of title& axis
Re: changing font colour of title& axis
For axes, there are two methods in the Axis class:
setLabelFont(...);
setTickLabelFont(...);
You need to do something like this (example assumes a CategoryPlot):
CategoryPlot plot = myChart.getCategoryPlot();
ValueAxis axis = plot.getRangeAxis();
axis.setLabelFont(font1);
axis.setTickLabelFont(font2);
For chart titles, there is a setFont(...) method, but the trick is getting hold of the TextTitle object. The chart maintains a list of titles (you can add as many as you want). Use these methods in the JFreeChart class:
getTitleCount();
getTitle(int);
getTitles;
When you access a particular title, it will be returned as an AbstractTitle...you need to cast it to the correct subclass:
AbstractTitle t1 = myChart.getTitle(0);
if (t1 instanceof TextTitle) {
TextTitle t = (TextTitle)t1;
t.setFont(myFont);
}
Regards,
DG.
setLabelFont(...);
setTickLabelFont(...);
You need to do something like this (example assumes a CategoryPlot):
CategoryPlot plot = myChart.getCategoryPlot();
ValueAxis axis = plot.getRangeAxis();
axis.setLabelFont(font1);
axis.setTickLabelFont(font2);
For chart titles, there is a setFont(...) method, but the trick is getting hold of the TextTitle object. The chart maintains a list of titles (you can add as many as you want). Use these methods in the JFreeChart class:
getTitleCount();
getTitle(int);
getTitles;
When you access a particular title, it will be returned as an AbstractTitle...you need to cast it to the correct subclass:
AbstractTitle t1 = myChart.getTitle(0);
if (t1 instanceof TextTitle) {
TextTitle t = (TextTitle)t1;
t.setFont(myFont);
}
Regards,
DG.
Re: changing font colour of title& axis
Sorry, I didn't read that very closely...to change the color use:
setPaint(...) in the TextTitle class;
setLabelPaint(...) in the axis class;
Regards,
DG.
setPaint(...) in the TextTitle class;
setLabelPaint(...) in the axis class;
Regards,
DG.