Hi Mistercaste,

mistercaste <[email protected]> wrote on 05/20/2009 05:38:12 AM:

> >> Such zoom-invariant elements are for example the stroke size of the
> >> streets, the size of text, some drawings size (like the car 
accident), 
> >> ecc.. I understand it's a large problem.
> 
> >In terms of invariable stroke width, SVG Tiny 1.2 specifically defines
> >that in the "non-scaling-stroke" value for the "vector-effect"
> >property [3]. Unfortunately, as far as I know, Batik doesn't implement
> >this yet (anyone feels like contributing this simple and yet
> >interesting/valuable feature?).

   Let me first say that this isn't particularly simple.  The main
problem is that the BBOx of an element will change when the transform
on another element changes - which trust me is just weird.  To really
support this (and the perhaps more interesting vector effects in general)
you need to support a fairly robust 'event' tracking system in the GVT.
So the child GN can register with all the elements in the tree above it
for transform changes and then update it's stroke (and hence it bounds
when any of them changes).

   The problem is that such systems while simple in concept are
extremely prone to causing memory leaks.

> My first subproblem is how to set the size of the rendered Shape on the 
GVT.
> I tried to solve this feature working on the StrokeShapePainter.

> 
> BridgeContext bc = 
((JSVGCanvas)c).getUpdateManager().getBridgeContext();
> GraphicsNode gn = (GraphicsNode)bc.getGraphicsNode(element);
> 
> StrokeShapePainter ssp = new StrokeShapePainter(gn.getOutline());
> ssp.setStroke(new BasicStroke(...whatever...));

> ...but then how can I do for updating the GraphicsNode on this Shape?

    ShapeNode.setShapePainter(ShapePainter painter)

    Be aware that you will need to account for any possible fill
and marker painters in addition to the stroke painter.

> I tried to get the Paint object and set it on a Graphics2D instance but
> it doesn't work.. or at least I don't know how to make it work.

   Since you are hitting the GVT tree directly (as opposed to say
updating the 'stroke-width' attribute in the DOM (or better adjusting
a stylesheet)  I'm not sure how you are rendering the document.  Also
if the DOM tree is live you need to be careful that DOM tree doesn't
overwrite your changes to the GVT tree.

Reply via email to