Change Shapes size dinamically

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
garzy
Posts: 6
Joined: Thu Jan 15, 2009 5:36 pm

Change Shapes size dinamically

Post by garzy » Thu Jan 15, 2009 5:44 pm

Hi, I'm a JFreeChart user and I love this library, but I need to know how to change the shapes size dinamically, when change the chart zoom.

Thanxs!!! Great Library!!

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 Jan 15, 2009 6:31 pm

It isn't supported. I'm not even sure how I'd go about this...maybe you could have the renderer scale the shape according to the current axis range?
David Gilbert
JFreeChart Project Leader

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

garzy
Posts: 6
Joined: Thu Jan 15, 2009 5:36 pm

Post by garzy » Thu Jan 15, 2009 6:38 pm

Yes, it's exactly that I want

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 Jan 15, 2009 6:41 pm

OK, if you look in the XYLineAndShapeRenderer class (if that's the one you are using) at the drawSecondaryPass() method, you'll see where a Shape is fetched and translated into position...at that point, you could add some code to scale the shape as well (scaling it before it is translated would be easiest).
David Gilbert
JFreeChart Project Leader

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

garzy
Posts: 6
Joined: Thu Jan 15, 2009 5:36 pm

Post by garzy » Fri Jan 16, 2009 9:15 am

Sorry but I haven't the source code :O, can you paste the code of this method?. Thanks

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

Post by paradoxoff » Fri Jan 16, 2009 9:50 am

You could also have a look at the XYBlockRenderer. That renderer allows to set a "blockWidth" and "blockHeight" that are defined in data coordinates, i.e. the width/height are added to the x/y coordinate of the given data point before it is transferred from data space to java2D space. In other words, the blocks will get bigger if you zoom in.
The entire JFreeChart sourcecode is available online. If you go to the API docs (e. g. the main page of the XYBlockRenderer), you will see that the name of the class (i.e. the word "BlockRenderer" in the line "public class XYBlockRenderer") is a link, and this directly brings you to the source code.

garzy
Posts: 6
Joined: Thu Jan 15, 2009 5:36 pm

Post by garzy » Fri Jan 16, 2009 12:00 pm

Thanks paradoxoff but I need draw custom Shapes, not Block Shapes, if the XYBlockRenderer draw custom Shapes this renderes would be perfect!!.

Thanks for the code acclaration, I will search now...

garzy
Posts: 6
Joined: Thu Jan 15, 2009 5:36 pm

Post by garzy » Mon Jan 19, 2009 3:36 pm

Finally I've overwritten drawSecondaryPass() method of the XYLineAndShapeRenderer class and change que size of Shape with an AffineTransformer before translate this.

Thank you very much!!

Locked