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 "Jean-Christophe ARNU (JX)" <jc...@wanadoo.fr> on 2003/03/25 15:31:20 UTC

Changing style of an element

Hello,
	I'm quite newbie with Batik. I would like to know how I can change a style
attribute from a given element. This element is out of a pre-loaded
SVGDocument. What is the best way to do such a thing? I looked at the Mailing
list archive and found a code sample using the SVGStylableSupport class which
not seems to be ever in the Batik's API.
	I'm using Batik 1.5 beta4 :)

	Thanx :)

-- 
Jean-Christophe ARNU

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


Re: Changing style of an element

Posted by "Jean-Christophe ARNU (JX)" <ar...@paratronic.fr>.
Le Tue, 25 Mar 2003 15:31:20 +0100
Jean-Christophe ARNU (JX) <jc...@wanadoo.fr> me disait que :

> Hello,
> 	I'm quite newbie with Batik. I would like to know how I can change a
> 	style
> attribute from a given element. This element is out of a pre-loaded
> SVGDocument. What is the best way to do such a thing? I looked at the
> Mailing list archive and found a code sample using the SVGStylableSupport
> class which not seems to be ever in the Batik's API.
> 	I'm using Batik 1.5 beta4 :)

	I managed to get some changes using a code similar to this :

	svgPanel.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
		public void documentLoadingCompleted(SVGDocumentLoaderEvent evt) {
		    SVGDocument svgDoc = svgPanel.getSVGDocument();		 
		    NodeList nl =
svgDoc.getElementsByTagNameNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"path");

		    for(int i=0;i<nl.getLength();i++){
			SVGOMPathElement svgpe = (SVGOMPathElement)nl.item(i);			
			svgpe.setAttribute("style","stroke:black;fill:green");
		    }
		}
	    });

	This is quite brute-force change whereas I would like to change only "fill:"
value.

	I tried to get svgpe.getStyle() but I invariantly get an nullPointerException
while calling this method (getStyle() method is from SVGStylableElement class)

	If I clearly understood JavaDocs,  getStyle() returns a CSSStyleDeclaration
which I could apply the setProperty("fill","green","") on to get what I would
like...

	So what's missing to get things work? Is there any resource I can consult to
be more efficient on the subject?

	Thanx :)
-- 
Jean-Christophe ARNU

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


Re: Changing style of an element

Posted by "Jean-Christophe ARNU (JX)" <jc...@wanadoo.fr>.
Sorry for dup message if any (Used the wrong email address to send to the
list) :/

> Hello,
> 	I'm quite newbie with Batik. I would like to know how I can change a
> 	style
> attribute from a given element. This element is out of a pre-loaded
> SVGDocument. What is the best way to do such a thing? I looked at the
> Mailing list archive and found a code sample using the SVGStylableSupport
> class which not seems to be ever in the Batik's API.
> 	I'm using Batik 1.5 beta4 :)

	I managed to get some changes using a code similar to this :

	svgPanel.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
		public void documentLoadingCompleted(SVGDocumentLoaderEvent evt) {
		    SVGDocument svgDoc = svgPanel.getSVGDocument();		 
		    NodeList nl =
svgDoc.getElementsByTagNameNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"path");

		    for(int i=0;i<nl.getLength();i++){
			SVGOMPathElement svgpe = (SVGOMPathElement)nl.item(i);			
			svgpe.setAttribute("style","stroke:black;fill:green");
		    }
		}
	    });

	This is quite brute-force change whereas I would like to change only "fill:"
value.

	I tried to get svgpe.getStyle() but I invariantly get an nullPointerException
while calling this method (getStyle() method is from SVGStylableElement class)

	If I clearly understood JavaDocs,  getStyle() returns a CSSStyleDeclaration
which I could apply the setProperty("fill","green","") on to get what I would
like...

	So what's missing to get things work? Is there any resource I can consult to
be more efficient on the subject?

	Thanx :)
-- 
Jean-Christophe ARNU

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