Changing the size of shapes that are drawn

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
superfield
Posts: 26
Joined: Thu Jun 07, 2007 10:07 pm

Changing the size of shapes that are drawn

Post by superfield » Thu Jul 19, 2007 5:11 pm

I have seen a few post about this but no one seems to have a solution. Does anyone know if it is possible to change the size of the shapes that are drawn on a series. I am using an XYLineAndShape renderer, I want to change the size of specific shapes in a series, is this possible?
Thank you.

superfield
Posts: 26
Joined: Thu Jun 07, 2007 10:07 pm

Post by superfield » Thu Jul 19, 2007 5:48 pm

Nevermind, I just read a post where David said it's impossible :(

potterd64
Posts: 13
Joined: Fri Aug 18, 2006 7:54 pm

Post by potterd64 » Fri Jul 20, 2007 12:47 am

impossible?
Do you mean you want to change the size of all of the shapes of a series or that you want a few shapes in a series to be changed?
If you want to change all shapes you can use setShape and pick a new shape to use.

Code: Select all

XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);
plot.setRenderer(0,renderer);
renderer.setShape(new Rectangle(-3,-3,6,6));
Or if you want only a few points in a series to big bigger than the others you could subclass the XYLineAndShapeRenderer. I did that when I wanted a series that could change color in the middle of the series, and change shape as well.

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 » Fri Jul 20, 2007 9:53 am

superfield wrote:Nevermind, I just read a post where David said it's impossible :(
It's not impossible. Subclass the renderer and override getItemShape(int, int) to return whatever shape you want for any given item.
David Gilbert
JFreeChart Project Leader

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

superfield
Posts: 26
Joined: Thu Jun 07, 2007 10:07 pm

Post by superfield » Mon Jul 23, 2007 4:00 pm

Thank you, it worked!

lucas luky
Posts: 14
Joined: Wed Sep 12, 2007 7:05 pm

Post by lucas luky » Tue Sep 18, 2007 6:44 pm

worked for me too...

but if ure reading this and using JF1.0.6, DONT try to use the "setBaseShape" method. it simply doesnt work.

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 » Thu Sep 20, 2007 4:43 pm

lucas luky wrote:but if ure reading this and using JF1.0.6, DONT try to use the "setBaseShape" method. it simply doesnt work.
Only because the 'autoPopulateSeriesShape' flag defaults to true. If you set this to false, the renderer will use the baseShape if no series shape is specified (rather than doing an automatic lookup on the current DrawingSupplier).
David Gilbert
JFreeChart Project Leader

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

Locked