Hi Andre,
André Ávila <[EMAIL PROTECTED]> wrote on 03/22/2006 07:53:45 AM:
> I will eagerly wait for your commit of this fix, then. Please let us now
> when you do it, ok?
The fix is now in SVN. For static documents that only use AWT Fonts
the Document can now go to GC once the GVT tree is built (I've attached
a small sample app that shows this).
Note that SVG Fonts currently still hold a reference to the DOM.
This can probably also be fixed but is a bigger job. Since I doubt
you need to use SVG Fonts I figured I put out what I have.
> In the meantime, I'm doing some tests on splitting the big SVGs and
> displaying them on layered, transparent canvases. I'm not sure as
whether
> this will be enough to render the big documents, though.
If you have split the document I would build the GVT tree for them
sequentially and append the generated GVT tree's. This way you will only
have the DOM for one piece in memory at a time, and you won't have to
worry about synching multiple canvases.
Anyway good luck!
> I think I can try to come up with some sort of server-side rendering,
> sending to the clients the components with the files already rendered. I
> haven't explored this possibility yet, so I'll see if I can get
something up
> and running before asking more dumb questions. :)
package org.test;
import java.util.ArrayList;
import java.util.List;
import java.lang.ref.SoftReference;
import org.w3c.dom.Document;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.DocumentLoader;
import org.apache.batik.bridge.GVTBuilder;
import org.apache.batik.bridge.UserAgentAdapter;
import org.apache.batik.gvt.GraphicsNode;
public class GVTGC {
SoftReference sr;
public GVTGC() {
}
public GraphicsNode buildGN(String file) {
UserAgentAdapter svgUA = new UserAgentAdapter();
BridgeContext bridgeContext = new BridgeContext(svgUA);
DocumentLoader documentLoader = new DocumentLoader(svgUA);
Document d = null;
try {
java.io.File fi = new java.io.File(file);
d = documentLoader.loadDocument(fi.toURL().toString());
} catch (Exception e) { e.printStackTrace();}
GVTBuilder builder = new GVTBuilder();
sr = new SoftReference(d);
return builder.build(bridgeContext, d);
}
final static int ALLOC_SZ=10000; // 1KB
public static void main(String args[]) {
try {
GVTGC tst = new GVTGC();
GraphicsNode gn = tst.buildGN(args[0]);
System.err.println("Document SoftRef: " + tst.sr.get());
System.err.println("GraphicsNode: " + gn);
System.err.println("Forcing OutOfMemeory error");
List l = new ArrayList();
try {
while (true) {
l.add(new byte[ALLOC_SZ]);
}
} catch (OutOfMemoryError oom) { }
finally { l = null; }
System.err.println("After OutOfMemeory error:");
System.err.println("Document SoftRef: " + tst.sr.get());
System.err.println("GraphicsNode: " + gn);
} finally { System.exit(0); }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]