You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Denis Bohm <de...@fireflydesign.com> on 2001/04/13 18:21:25 UTC
CompositeShapePainter.getShapePainters()?
Hi,
I'm using Batik in an interactive context and would like to be able to get
the shape painters in a composite shape painter. Currently there is a
public method to add a shape painter, but no method to get the shape
painters. Would it be possible to have a public method added to get all the
shape painters? Something like:
org/apache/batik/gvt/CompositeShapePainter.java:
public ShapePainter[] getShapePainters() {
return painters;
}
Just in general it seems like good practice to have a getter if there is a
setter. For collections like this one it would be nice to use the
Collection interface rather than an array. That would provide a nice API
for getting, setting, adding, removing, and iterating. Something like:
protected List shapePainters = new ArrayList(2);
public Collection getShapePainters() {
return shapePainters;
}
public Collection setShapePainters(Collection shapePainters) {
this.shapePainters = shapePainters;
}
Thanks,
Denis
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org
Re: CompositeShapePainter.getShapePainters()?
Posted by Thierry Kormann <tk...@sophia.inria.fr>.
On Friday 13 April 2001 18:21, Denis Bohm wrote:
> I'm using Batik in an interactive context and would like to be able to get
> the shape painters in a composite shape painter. Currently there is a
> public method to add a shape painter, but no method to get the shape
> painters. Would it be possible to have a public method added to get all
> the shape painters? Something like:
>
> org/apache/batik/gvt/CompositeShapePainter.java:
>
> public ShapePainter[] getShapePainters() {
> return painters;
> }
Well, we have not provided such a method because the CompositeShapePainter is
caching some values and we were a bit nervous about people changing an
enclosed ShapePainter. As it's quite easy to keep a reference on an enclosed
ShapePainter and modify it (after adding it to a CompositeShapePainter) - I
think I could add such a method.
> Just in general it seems like good practice to have a getter if there is a
> setter. For collections like this one it would be nice to use the
> Collection interface rather than an array. That would provide a nice API
> for getting, setting, adding, removing, and iterating. Something like:
Well, I agree with you except that in this particular case, I have decided to
use an array for performance reason. Basically, you can easily have a huge
number of shapes in an SVG document (9000 for example :) and creating a List
per shape may increase a lot the size of a GVT tree.
I will do some additional tests before changing this one.
Thanks for your feedback
Regards,
Thierry
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-dev-help@xml.apache.org