Hi Mistercaste,
mistercaste <[email protected]> wrote on 07/17/2009 06:04:41 AM:
> Hi, I'm trying to change the GraphicsNode color of a relative DOM
element via
> the BridgeContext but I get as casting error "CompositeGraphicsNode
cannot
> be cast to ShapeNode". Here is my code:
You can't change the color on a CompositeGraphicsNode. You can set
the color of an SVG 'g' Element, which will then cascade to it's children
according to the rules of CSS.
> BridgeContext bc = ((JSVGCanvas)
c).getUpdateManager().getBridgeContext();
> bc.setDynamic(true);
> bc.setInteractive(true);
>
> // This is a CompositeGraphicsNode (implements GraphicsNode)
> GraphicsNode gn = (GraphicsNode) bc.getGraphicsNode(element);
>
> ShapeNode sn = (ShapeNode)gn; <---------- THIS CAST DOESN'T WORK
> ShapePainter sp = sn.getShapePainter();
> StrokeShapePainter painter = new StrokeShapePainter(sn.getShape());
> painter.setPaint(Color.YELLOW);
> painter.setStroke(new BasicStroke(10.0f));
> sn.setShapePainter(painter);
> Any ideas or suggestion on what to do? Thanks
I would suggest code more like:
element.setAttributeNS(null, "stroke", "yellow");
element.setAttributeNS(null, "stroke-width", "10");