setSeriesPaint(Color[]) ??

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Irv Thomae

setSeriesPaint(Color[]) ??

Post by Irv Thomae » Tue Feb 11, 2003 4:22 pm

David,
What happened to the setSeriesPaint() method that accepted an array of Color's ? In designing and builiding a multi-series application, it was very logical to use parallel arrays for the series names, colors, and so on. Losing that capability seems a step backwards, IMHO.

Irv

morpheus

Re: setSeriesPaint(Color[]) ??

Post by morpheus » Tue Feb 11, 2003 5:05 pm

Well doing a loop would solve the problem I think... but I share the same opinion...

Irv Thomae

Re: setSeriesPaint(Color[]) ??

Post by Irv Thomae » Tue Feb 11, 2003 5:07 pm

Sorry, my title incorporates some brain-fade: the array argument was Paint[], not Color[] - but of course my real point is, it 's inconvenient not to have a method that accepts an arrray argument to specify the color treatment.

Jamey Johnston

Re: setSeriesPaint(Color[]) ??

Post by Jamey Johnston » Tue Feb 11, 2003 5:15 pm

I would think you could add the following method to XYPlot. I have not done this or tested this but it should work (or some variant of this).

public void setSeriesPaint(Paint[] seriesPaints)
{
for (int i = 0; i < seriesPaints.length; i++)
{
this.getRenderer().setSeriesPaint( i, seriesPaints);
}
}

Regards,

Jamey Johnston

Jamey Johnston

Re: setSeriesPaint(Color[]) ??

Post by Jamey Johnston » Tue Feb 11, 2003 5:16 pm

Above code should read:

public void setSeriesPaint(Paint[] seriesPaints)
{
for (int i = 0; i < seriesPaints.length; i++)
{
this.getRenderer().setSeriesPaint( i, seriesPaints[ i ]);
}
}

morpheus

Re: setSeriesPaint(Color[]) ??

Post by morpheus » Tue Feb 11, 2003 5:34 pm

The thing is that u have two renderers since u can have two datasets. Maybe u should add a parameter indicating which render u use:

public void setSeriesPaint(int whichRenderer, Paint[] seriesPaints)
{
Renderer renderer;

switch( whichRenderer ) {
case 2: renderer = this.getSecondaryRenderer();
break;

default: renderer = this.getRenderer();

}


for (int i = 0; i < seriesPaints.length; i++)
{
renderer.setSeriesPaint( i, seriesPaints[ i ]);
}
}

Regards
Morpheus

Jamey Johnston

Re: setSeriesPaint(Color[]) ??

Post by Jamey Johnston » Tue Feb 11, 2003 8:54 pm

Thanks Morpheus.

I have added this method as you have outlined and it works fine.

- Jamey

Locked