You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Steve Lamont <sp...@ncmir.ucsd.edu> on 2005/03/09 20:24:47 UTC

Changing the color of an individual GVT node

How does one go about changing the color attribute of an individual
GVT node?  I've spent most of the morning fishing through the
documentation, the mailing list archives, and the source code to no
avail.  I'm clearly missing something.

							spl

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Changing the color of an individual GVT node

Posted by Steve Lamont <sp...@ncmir.ucsd.edu>.
> you mean you want to change the color of a shape in your svg file?
>
> (untested syntax)
> 1) lookup the node using methods like
> node=document.getElementById("...")
> 2) set the node attribute like node.setAttribute("fill", "blue");

I'm already doing something quite similar that but it's very slow,
since the SVG has to be transformed into GraphicsNodes.

I'm doing the following to turn off text in the displayed document by
walking the GVT tree:

    private void setTextState( CompositeGraphicsNode cgn,
			       boolean text_state )
	
    {
	
	for ( int i = 0; i < cgn.size(); i++ ) {

	    Object object = cgn.get( i );
	    Class object_class = object.getClass();

	    if ( object_class.equals( CompositeGraphicsNode.class ) )
		this.setTextState( ( CompositeGraphicsNode ) object,
                                   text_state );
	    else if ( object_class.equals( TextNode.class ) ) {

		TextNode text_node = ( TextNode ) object;

		text_node.setVisible( text_state );

	    }

	}
	
    }

and I was hoping that there was some similar

I'm not interested in saving the changes to the document -- the
document is effectively "read only".

There are Graphics2D objects fed to the paint() methods of the
individual objects but it's not clear to me whence those objects come
or how they are manipulated.

							spl

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org


Re: Changing the color of an individual GVT node

Posted by Jorg Heymans <jh...@domek.be>.
you mean you want to change the color of a shape in your svg file?

(untested syntax)
1) lookup the node using methods like
node=document.getElementById("...")
2) set the node attribute like node.setAttribute("fill", "blue");

make sure you do this from the canvas update thread, as specified in
http://xml.apache.org/batik/javaScripting.html

Manipulating the SVG document is nothing different from manipulating any 
other DOM tree.

HTH
Jorg
Steve Lamont wrote:
> How does one go about changing the color attribute of an individual
> GVT node?  I've spent most of the morning fishing through the
> documentation, the mailing list archives, and the source code to no
> avail.  I'm clearly missing something.
> 
> 							spl


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org