DefaultPolarItemRenderer setSeriesVisible

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
PatrickN
Posts: 7
Joined: Thu Feb 05, 2015 9:48 am
antibot: No, of course not.

DefaultPolarItemRenderer setSeriesVisible

Post by PatrickN » Thu Feb 05, 2015 10:03 am

Hi Guys,

just a basic and very simple question: Does the DefaultPolarItemRenderer/PolarItemRenderer support the setSeriesVisible(index,boolean) method of AbstractRenderer? And if not, is it possible to realize that as a patch?

Looking forward to your answers:)

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: DefaultPolarItemRenderer setSeriesVisible

Post by paradoxoff » Mon Feb 09, 2015 12:06 pm

A look in the source of DefaultPolarItemRenderer suggests that this renderer does not care about the series or item visibility. You probably have to extend DefaultPolarItemRenderer and overwrite both getItemVisible() to return a suitable boolean and the drawSeries-Methode to use this flag.

PatrickN
Posts: 7
Joined: Thu Feb 05, 2015 9:48 am
antibot: No, of course not.

Re: DefaultPolarItemRenderer setSeriesVisible

Post by PatrickN » Mon Feb 09, 2015 3:22 pm

Thank you for your answer!

I thought about extendig the DefaultPolarItemRenderer but don't know how... Do you have an example or little code snippet of how to do that?

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: DefaultPolarItemRenderer setSeriesVisible

Post by paradoxoff » Tue Feb 10, 2015 9:03 am

I have never worked with the Polar-classes. A look ih the source suggests that the drawSeries-Method of DefaultPolarItemRenderer does the actual rendering.
if you want to hide an entire series, you could check for the visibility of the series at the beginning of this method:

Code: Select all

if(!isSeriesVisible(seriesIndex)) return;
To hide individual items, you would have to override getItemVisible(int, int)and wrap the block between line 511 and 520 in an if-block

Code: Select all

if(getItemVisible(seriesIndex, i)){
    double theta = dataset.getXValue(seriesIndex, i);
    double radius = dataset.getYValue(seriesIndex, i);
    ....
}

PatrickN
Posts: 7
Joined: Thu Feb 05, 2015 9:48 am
antibot: No, of course not.

Re: DefaultPolarItemRenderer setSeriesVisible

Post by PatrickN » Tue Feb 10, 2015 10:08 am

Seems to be simple...

So do I have to decompile the JFreeChart-Library to modify the source code? Or is there a better way?

(I never had to modify a library before....)

PatrickN
Posts: 7
Joined: Thu Feb 05, 2015 9:48 am
antibot: No, of course not.

Re: DefaultPolarItemRenderer setSeriesVisible

Post by PatrickN » Tue Feb 10, 2015 11:14 am

PatrickN wrote:Seems to be simple...

So do I have to decompile the JFreeChart-Library to modify the source code? Or is there a better way?

(I never had to modify a library before....)
It wooooorks!! Thank you:)

Just added

Code: Select all

if(!isSeriesVisible(seriesIndex)) return;
to draw-method of DefaultPolarItemRenderer to make whole series visible/invisible.

To modify the library I created a new (eclipse) project based on the source-files of jfreechart.

Locked