xmlgraphics-batik-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Xmlgraphics-batik Wiki] Update of "BootSvgAndCssDom" by ThomasDeWeese
Date Sat, 09 Apr 2005 12:36:59 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Xmlgraphics-batik Wiki" for change
notification.

The following page has been changed by ThomasDeWeese:
http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom

New page:
##language:en
== The SVG and CSS DOM Interfaces ==

When you first create an SVG Document from Java
it will only support the DOM Core calls (basically
traversal of the tree and accessing attributes).

The really interesting CSS and SVG specific DOM 
interfaces will not work properly until you
initialize them. The code below is the simplest
example of how to initialize them.

This defaults a lot of behaviour and in particular
for real uses most people will want to provide
a custom implementation of the UserAgent class.

If you are using the JSVGCanvas it does this when
you associate an SVGDocument with the canvas.
It will do this for you asynchronously you can
be notified when it is done by registering
a GVTTreeBuilderListener with the canvas before
setting an SVGDocument (or URL) on the canvas.

=== Example ===
{{{
import org.apache.batik.bridge.UserAgent;
import org.apache.batik.bridge.UserAgentAdapter;
import org.apache.batik.bridge.DocumentLoader;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.GVTBuilder;

/* ..... */
        SVGDocument    svgDoc;
        UserAgent      userAgent;
        DocumentLoader loader;
        BridgeContext  ctx;
        GVTBuilder     builder;
        
        userAgent = new UserAgentAdapter();
        loader    = new DocumentLoader(userAgent);
        ctx       = new BridgeContext(userAgent, loader);
	ctx.setDynamicState(BridgeContext.DYNAMIC);
        builder   = new GVTBuilder();
        builder.build(ctx, svgDoc);    
}}} 

Mime
View raw message