[reportlab-users] Re: [reportlab-team] widgets/markers.py

Dinu Gherman reportlab-users@reportlab.com
Mon, 5 Aug 2002 12:59:00 +0200


Robin Becker:

> well in the Guieditor thing we explicitly list widgets/shapes which can
> be added to a drawing. There are already more than a hundred & if I add
> in hundreds of markers, flags, logos and other specialized shapes then I
> will end up needing to add filters etc. Probably I need to do that
> already, I feel we have too many graphic classes.

Well, you probably can't do without filtering, anyway...

> As for adding iterators that is just more bloat which needs to be
> maintained and updated as new classes are added/removed.

Not quite true, this can be automatic! I'm attaching a Dinu-style
sample version with only a Smiley marker to illustrate my point.
Without knowing what you need for the GUI I can't say if what I
call "shadow clones" there is sufficient for you or not. I'm only
using them to count the number of alive marker instances, and for
that they are already overfeatured.

Actually, the more I think about it the more rotten all this seems
to appear to me from an OO point of view. After all, a marker is
nothing else, but a widget (in the charting domain), adding not
much more, but a tiny shell of functionality to place, (and dis-
place), size and possibly rotate the wrapped widget.

That means, what we speak about when saying "markers" is a mere
wrapper on widgets! Therefore, it would all make much more sense,
neither to fiddle with more and more *methods* of one Marker class
(as you did for regular Polygons), nor to make, maybe many, sub-
classes (as I was suggesting), but to create the equivalent widgets,
so they become reusable in other contexts, too, i.e. outside the
charting domain...

Then markers can just become the true wrappers they really are!
If you haven't heard it already, I'm ringing the Decorator bell,
for those familiar with the pattern lingo...

Dinu