override CategoryPlot.getLegendItems

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
cris-rj
Posts: 16
Joined: Mon Oct 11, 2004 2:44 pm
Location: rio de janeiro, brazil

override CategoryPlot.getLegendItems

Post by cris-rj » Fri Nov 19, 2004 6:16 pm

I created a subclass of CategoryPlot because I needed to override the getLegendItems method. I want to edit the legends items.
here is my code:

Code: Select all

public class LegendCategoryPlot extends CategoryPlot{

	public LegendItemCollection getLegendItems(Paint[] paint){
		System.out.println("teste");
		LegendItemCollection lc = new LegendItemCollection();
		LegendItem li1 = new LegendItem("item1",paint[1]);
		LegendItem li2 = new LegendItem("item2",paint[2]);
		LegendItem li3 = new LegendItem("item3",paint[4]);
		lc.add(li1);
		lc.add(li2);
		lc.add(li3);
		return lc;
	}

}
my problem is that when I get the plot from chart and put it in the variable
of type that I create.

Code: Select all

 LegendCategoryPlot plot = (LegendCategoryPlot)chart.getCategoryPlot()
or 
 LegendCategoryPlot plot = (LegendCategoryPlot)chart.getPlot()
both of lines compiles but raise runtime errors.

does anybody have an idea?
thanks .
[]´s
Cristiano

Locked