Using an AttributedString for an LegendItem

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
unknownfrog
Posts: 6
Joined: Thu Mar 20, 2008 5:38 pm

Using an AttributedString for an LegendItem

Post by unknownfrog » Thu Mar 20, 2008 5:52 pm

Hi,

I tried to colorize an LegendItem with code similar to the following:

Code: Select all

AttributedString txt = new AttributedString("colored");
txt.addAttribute(TextAttribute.FOREGROUND, Color.RED);
legendItems.add(new LegendItem(txt, null, null, null,
    new Line2D.Double(-lineLength, 0.0, lineLength, 0.0), 
    new BasicStroke(1), 
    Color.BLUE));
I exspected to get an item with a blue line and a red text. The line is drawn as exspected, but the text is black. During debugging I recognized, that the getAttributedLabel() method of the LegendItem was never called during the rendering of the legend.

Is this a bug, or do I something wrong. I am using JFreeChart 1.0.9.

best regards and happy Easter

Tom

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 » Tue Mar 25, 2008 4:49 am

From memory, although there is some attributed string code in there, it doesn't actually get used. I think we had some experimental code using it at one point, but I've lost track of it sorry.
David Gilbert
JFreeChart Project Leader

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

Locked