Hi André
André Ávila <[EMAIL PROTECTED]> wrote on 02/02/2006 09:16:44 AM:
> I think I didn't state my problem clearly, sorry for that. I really
cannot
> change the source, nor do I know exactly which elements have to be
updated.
I strongly suspected that from your original note...
> This method should work for any SVG currently displayed in an SVGCanvas.
The
> idea is a very simple 'replace color' feature: the user selects the
original
> color and the destination color, clicks 'replace' and the whole SVG gets
> updated.
Apparently not "very simple" ;)
> Well, this code doesn't really work, but it was the closest I could get.
> Ideally, it should produce the same effect as the first one, but it's
far
> from it:
>
> 1) I couldn't find a way to read the color of the current GraphicsNode.
I
> didn't use Cameron's code (from the "How do I parse..." thread), because
he
> grabs the color from an SVGElement, and I don't have one - unless I
could
> build one from a GraphicsNode, is it possible?
Tonny's response is the correct way to go from a GraphicsNode to the
associated SVG Element. You must have built the GVT tree with the Bridge
set to be 'dynamic'.
The Painter objects should have a getter for the Paint.
> 2) I'm not sure that updating the ShapeNodes will cover all the elements
in
> the SVG. Should I try to cast to other kinds of nodes as well?
Well there is also Text, Marker (used to 'decorate' paths), and Image
(which might have an entire 'child' SVG tree) Nodes. In particular Text
is pretty tricky as a text element can change color several times within
one Node. This is part of the reason working with the SVG is a bit
cleaner.
> 3) The Painter update is not working as I would expect. Instead of being
> repainted, the nodes that have the Painter updated are disappearing from
the
> SVG. Odd.
This is odd. There are a few things I noticed in the code.
First you aren't providing a Stroke object for the StrokeShapePainter
(so I would expect all strokes to disappear), there should also be a
getter for the current stroke.
Also many objects will have a CompositeShapePainter on them which
is a shape painter that uses multiple shape painters to do the work
(to support, fill, stroke and markers).
> I'm very new to Batik, SVG and most of its concepts, so I'm still
confused
> about how things are supposed to work. I really appreciate you guys help
on
> this.
Well you are doing something that the system isn't really designed to
support so I don't know that there is anything close to an official way
to do what you want...
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]