ERROR: JSVGCanvas.setDocument() method

2009-12-28 Thread dao
hello,

I am trying to initiate a JSVGCanvas from a String I get from a RMI remote
object

public CanvasProxy(long fps, String rmiRegistryLocation)
throwsNotBoundException, ParserConfigurationException, SAXException,
IOException {

connect(rmiRegistryLocation);

canvas = new JSVGCanvas();

canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);

canvas.setDocument(createDoc());


...




 private Document createDoc() throws ParserConfigurationException,

RemoteException, SAXException, IOException {

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

InputStream inStream = new ByteArrayInputStream(remoteEngine
.getSvgDocument().getBytes());

return builder.parse(inStream);

}



I get This exception

java.lang.ClassCastException: org.apache.batik.dom.GenericElement cannot be
cast to org.w3c.dom.svg.SVGSVGElement
at
org.apache.batik.dom.svg.SVGOMDocument.getRootElement(SVGOMDocument.java:233)
at
org.apache.batik.bridge.BridgeContext.getBridgeExtensions(BridgeContext.java:2049)
at
org.apache.batik.bridge.BridgeContext.registerSVGBridges(BridgeContext.java:2038)
at org.apache.batik.bridge.BridgeContext.setDocument(BridgeContext.java:442)
at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:54)
at org.apache.batik.swing.svg.GVTTreeBuilder.run(GVTTreeBuilder.java:96)


When I do this, it is all right. What's wrong?


 public CanvasProxy(long fps, String rmiRegistryLocation)
throwsNotBoundException, ParserConfigurationException, SAXException,
IOException {

connect(rmiRegistryLocation);

canvas = new JSVGCanvas();

canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);

canvas.setURI(remoteEngine.getSvgDocumentURI().toString());
-- 
Dao Hodac


Re: jsvgcanvas serialization

2009-12-28 Thread Helder Magalhães
Hi Dao,


Response inline...


 Considering the different messages I find, the JSVGCanvas is not
 serializable. So, why does it implements serializable?

I didn't check the code for sure, but it might have been
(serializable) in the past and afterward, during some feature
implementation, broken by accident (technically a regression). One
will probably need to crawl the SVN log and/or the source code itself
for sure... :-)


Pasting or attaching the messages you found might help, as well as a
reduced testcase. ;-)


Hope this helps,
 Helder

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



Re: ERROR: JSVGCanvas.setDocument() method

2009-12-28 Thread thomas . deweese
Hi Dao,

dao dao.ho...@gmail.com wrote on 12/28/2009 07:12:30 AM:

 I get This exception
 
 java.lang.ClassCastException: org.apache.batik.dom.GenericElement 
 cannot be cast to org.w3c.dom.svg.SVGSVGElement
 at org.apache.batik.dom.svg.SVGOMDocument.getRootElement
 (SVGOMDocument.java:233)

Almost certainly this is a problem with namespaces (so your
root element might be an svg element but not an svg:svg element).

Also you aren't using our DocumentFactory implementation,  this
is at least a performance hit.

 When I do this, it is all right. What's wrong?
 
 public CanvasProxy(long fps, String rmiRegistryLocation) throws 
 NotBoundException, ParserConfigurationException, SAXException, 
IOException {
 connect(rmiRegistryLocation);
 canvas = new JSVGCanvas();
 canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
 canvas.setURI(remoteEngine.getSvgDocumentURI().toString());
 -- 
 Dao Hodac


Re: ERROR: JSVGCanvas.setDocument() method

2009-12-28 Thread dao
I don't get why I have a namespace problem.

The string representing the doc is created in the server side like this


 private static String formatDoc(SVGDocument doc) throws IOException {

StringWriter stringWriter = new StringWriter();

org.apache.batik.dom.util.DOMUtilities.writeDocument(doc, stringWriter);

stringWriter.flush();

stringWriter.close();

return stringWriter.toString();

}



 public String getSvgDocument() throws RemoteException {

try {

return formatDoc(getCanvas().getSVGDocument());

} catch (IOException e) {

throw new RemoteException(could not format the document,e);

}

}


Why it does not contain the namespaces when I reread the string?does the
writeDocument is not the right way to serialize a document?

And by talking about the DocumentFactoryImplementation, you
mean org.apache.batik.dom.svg.SAXSVGDocumentFactory ?

By the way, thank's for the several answers or directions you often give to
me, they have largely contributed to my project.

On Mon, Dec 28, 2009 at 4:14 PM, thomas.dewe...@kodak.com wrote:

 Hi Dao,

 dao dao.ho...@gmail.com wrote on 12/28/2009 07:12:30 AM:

  I get This exception
 
  java.lang.ClassCastException: org.apache.batik.dom.GenericElement
  cannot be cast to org.w3c.dom.svg.SVGSVGElement
  at org.apache.batik.dom.svg.SVGOMDocument.getRootElement
  (SVGOMDocument.java:233)

 Almost certainly this is a problem with namespaces (so your
 root element might be an svg element but not an svg:svg element).

 Also you aren't using our DocumentFactory implementation,  this
 is at least a performance hit.

  When I do this, it is all right. What's wrong?
 
  public CanvasProxy(long fps, String rmiRegistryLocation) throws
  NotBoundException, ParserConfigurationException, SAXException,
 IOException {
  connect(rmiRegistryLocation);
  canvas = new JSVGCanvas();
  canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
  canvas.setURI(remoteEngine.getSvgDocumentURI().toString());
  --
  Dao Hodac




-- 
Dao Hodac