java - Adding an element to a DOM document with batik -


good evening,

my problem when adding element (rectangle) dom document.

the addition done follows:

creating element rect light blue / fluo

node node = doc.createelement("rect"); element elem = (element)node; elem.setattribute("fill", obj.getcolor()); 

contained in group of elements g

node newzone = doc.createelement("g"); element elemzone = (element)newzone; elemzone.setattribute("id", zone); 

adding element rect element g

elemzone.appendchild(elem); 

adding document

doc.getelementbyid(iduse).appendchild(elemzone); 

updating document jsvgcanvas (which allows display svg)

svg.setdocument(doc); 

so weird may seem, change taken account, because when save document , displays file, see change.

but nothing in application updated.

also, added element (symbol + use) following same process. jsvgcanvas , update document considered , visible.

thank in advance ...

remarks: - repaint tested np times. - launching application document: rectangle appears good.

svg elements must created in svg namespace replace

node node = doc.createelement("rect"); 

by

node node = doc.createelementns("http://www.w3.org/2000/svg", "rect"); 

same <g> element. serialising , unserialising document fix namespace problem why don't see on reload.

for batik must call

jsvgcanvas.setdocumentstate(jsvgcanvas.always_dynamic); 

before loading content too, , make changes in update manager's thread.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -