Re: "high-level" way to create SVG Elements of specific type?

[email protected]
Newsgroups gmane.text.xml.batik.user
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.