Hi,
Is it possible to keep a series' automatically given rendering properties (like color, shape, etc) after removing another series from chart?
Maybe there is a boolean flag somewhere, that I did not find yet....
like setKeepEverythingLikeItWas(damnidTrue) ?
Thanks for help!
How to keep series' rendering props after remove?
-
- Posts: 47
- Joined: Thu Dec 11, 2008 7:59 pm
Re: How to keep series' rendering props after remove?
By default the Plot uses a DrawingSupplier to internally automatically generate some default Series colors, shapes, etc. Each time you add a Series to the Plot, the Plot basically does a DrawingSupplier.getNextColor() and .getNextShape(). If you then remove the Series and add it back, you're going to get the next color and shape. You can turn this off and manually set each Series colors and shapes. Or you can play with the DrawingSupplier.
Re: How to keep series' rendering props after remove?
Thank you for your response.MitchBuell wrote:You can turn this off and manually set each Series colors and shapes. Or you can play with the DrawingSupplier.
What do you mean with turn off? To set null for plot's DrawingSupplier?
-
- Posts: 47
- Joined: Thu Dec 11, 2008 7:59 pm
Re: How to keep series' rendering props after remove?
The AbstractRenderer class, which ALL of the renderers extends, offers a bunch of setAutoPopulateSeriesXXX(boolean) methods to turn on or off the automatic generation of colors/shapes/etc. If you set all of these to false, then your chart will have a whole bunch of exactly similar looking lines. Then you can manually set specific series colors/shapes/etc.
Check out AbstractRenderer in the Javadoc.
Check out AbstractRenderer in the Javadoc.
Code: Select all
((AbstractRenderer)chart.getXYPlot().getRenderer()).setAutoPopulateSeriesPaint(false);
((AbstractRenderer)chart.getXYPlot().getRenderer()).setAutoPopulateSeriesShape(false);
etc.
Re: How to keep series' rendering props after remove?
I have a similar problem. I allow users to turn each data series on and off with a checkbox. By default (even when I set the colors manually on the renderer), removing one series changes the colors of every other series that comes after it. This is because the API maps paint color to the index of the series instead of the actual XYSeries object. I would love it if instead of calling setSeriesPaint(0, Color.red), I could call setSeriesPaint(mySeries, Color.red).
Right now, my only real workaround is to maintain my own map and reset all the colors (by index) every time a series is added or removed.
Any suggestions welcome!
Right now, my only real workaround is to maintain my own map and reset all the colors (by index) every time a series is added or removed.
Any suggestions welcome!