xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Serialization with FileStreams
Date Fri, 03 Nov 2006 00:16:55 GMT
Hi Nebojša,

Nebojša Miletić <nebojsa@accordia.co.yu> wrote on 10/28/2006 01:05:59 PM:

> Let's say that I create SVG elements using the SVGDocument as a factory. 

>   Element myRect = document.createElementNS(svgNS, "rect");

> After that I attach event listener to the rect:
>   ((EventTarget)myRect).addEventListener("click", new CEventListener(), 
false);
> 
> I use batik.dom.util.DOMUtilities methods to serialize myRect. But this
> ignores all information about the event handlers attached to myRect.
> 
> My event handling is written in Java and cannot be transferred to
> JavaScript.
> 
> How should I deal with this?

   Well you could always use your XML Serializer to serialize just
your event listener instance (into a separate namespace) and attach 
it as a child of the rect element in the XML file.

   Then when you read in the XML you can use getElementsByTagNameNS
to find your listeners and attach them to their parent elements.

> thomas.deweese wrote:
> > 
> > Hi Nebojša,
> > 
> > Nebojša Miletić <nebojsa@accordia.co.yu> wrote on 10/27/2006 01:39:09 
PM:
> > 
> >> I am working on complex relationship management desktop application. 
The
> >> user can load or create some graph on the JSVGCanvas. He is able to 
edit
> >> that graph (move nodes, edit relations etc). 
> >> 
> >> The user should be able to save the state of the edited graph and 
load 
> > that
> >> state whenever he wants. 
> > 
> >    Sure this is a pretty standard thing to do with SVG as well.
> > 
> >> In some other (non-SVG) parts of my application, I use this kind of
> >> serialization (and it works):
> >> 
> >> <code>
> >>    import java.beans.XMLEncoder;
> >> </code>
> >> 
> >> The object I try to serialize is:
> >> <code>
> >>    SVGOMRectElement serializedObject = new 
SVGOMRectElement("customNS",
> >> jsvgCanvas.getDocument());
> >> </code>
> > 
> >     This is not the correct way to create an SVG Rect element.
> > You should use the document as a factory to create your elements:
> > 
> >         Element rect = jsvgCanvas.getDocument().createElement
> >           ("http://www.w3.org/2000/svg", "rect");
> > 
> >> This is the reported exception:
> >> java.lang.IllegalAccessException: Class sun.reflect.misc.Trampoline 
can 
> > not
> >> access a member of class org.apache.batik.dom.svg.SVGOMRectElement 
with
> >> modifiers "protected"
> > 
> >> Is there some other way to serialize this (and deserialize it 
> > afterwards)?
> >> Or I am doing something wrong?
> > 
> >     So I don't know much about XMLEncoder but I presume it
> > uses reflection to try and turn the given Java object into XML.
> > However, this would be a really round about way to serialize
> > a DOM object into XML (A DOM object is essentially an in-memory
> > version of an XML element).  You can use the methods in 
> > batik.dom.util.DOMUtilities to serialize individual elements 
> > or whole documents.
> > 
> >> Or I have to dive into the Batik source code and deal with the 
> > unaccessible
> >> members?
> >> Or any other suggestion?
> > 
> >     For this sort of stuff I would normally 'annotate'
> > a standard SVG file with extra elements/attributes in 
> > a custom namespace.  Often with this approach you can
> > have a static SVG picture that any SVG client can 
> > display, but still enable editing within your application.
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> > For additional commands, e-mail: 
batik-users-help@xmlgraphics.apache.org
> > 
> > 
> > 
> 
> -- 
> View this message in context: http://www.nabble.com/Serialization-with-
> FileStreams-tf2522028.html#a7051942
> Sent from the Batik - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


---------------------------------------------------------------------
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