xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m.@mherrn.de
Subject Re: "high-level" way to create SVG Elements of specific type?
Date Fri, 22 Jun 2012 12:12:09 GMT
Hi Thomas,

>> final Element element= document.createElement("rect");
>
> 	This creates a 'rect' element in the no name namespace.
> I think you want to use createElementNS with the SVG Namespace.
> If you are using a Batik SVGDocument then this will return an
> SVGRectElement.

Yes, actually I am doing it that way and just ommited it from my example.
I didn't know that batik actually creates an SVGRectElement out of it.
So it is enough to just cast the created element to the relevant
interface? e.g.:

final SVGRectElement rect= (SVGRectElement) document.createElementNS(ns,
"rect");

But that gives me an SVGRectElement that has the getters for the specific
attributes. Is there a way to get a class that provides the setters as in
my second (hypothetical) example?:

-------------------------/--------------------------
final SVGRect rectElement= ..... //create the element
rectElement.setX(10);
rectElement.setY(10);
rectElement.setWidth(100);
rectElement.setHeight(100);
document.getDocumentElement().appendChild(rectElement);
-------------------------/--------------------------

> Make sure you read about booting the CSS and
> SVG DOM on the Wiki, otherwise some of the more advanced SVG
> methods won't work (also the element needs to be part of the SVG
> tree for some of those methods to work).

I will have a look at the wiki again. Quite possible that I have
overlooked some important info there.


Thanks and regards
Marco


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


Mime
View raw message