Search in sources :

Example 1 with DynamicGVTBuilder

use of org.apache.batik.bridge.DynamicGVTBuilder in project scout.rt by eclipse.

the class SVGUtility method readSVGDocumentForGraphicalModification.

/**
 * Parses a SVG document read by the given input stream and attaches a GVT tree. An attached GVT tree is required for
 * performing CSS, text size and and bounding box operations on the SVG document.
 * <p/>
 * The resulting bridge context holds a reference to the SVG document {@link BridgeContext#getDocument()}
 * <p/>
 * <h1>Important:</h1> Callers are required to invoke {@link BridgeContext#dispose()} on the returned bridge context
 * as soon as the bridge or the document it references is not required anymore.
 * <p/>
 * If the documents needs not be manipulated, use {@link #readSVGDocument(InputStream)} instead.
 *
 * @param in
 *          input stream the SVG document is read from.
 * @return Returns a bridge context that holds references to the SVG document as well as to the GVT tree wrapping
 *         objects.
 */
public static BridgeContext readSVGDocumentForGraphicalModification(InputStream in) {
    SVGDocument doc = readSVGDocument(in);
    // add a gvt tree for text and alignment calculations
    BridgeContext bc = new BridgeContext(new UserAgentAdapter());
    bc.setDynamic(true);
    GVTBuilder builder = new DynamicGVTBuilder();
    builder.build(bc, doc);
    return bc;
}
Also used : DynamicGVTBuilder(org.apache.batik.bridge.DynamicGVTBuilder) UserAgentAdapter(org.apache.batik.bridge.UserAgentAdapter) BridgeContext(org.apache.batik.bridge.BridgeContext) SVGDocument(org.w3c.dom.svg.SVGDocument) GVTBuilder(org.apache.batik.bridge.GVTBuilder) DynamicGVTBuilder(org.apache.batik.bridge.DynamicGVTBuilder)

Aggregations

BridgeContext (org.apache.batik.bridge.BridgeContext)1 DynamicGVTBuilder (org.apache.batik.bridge.DynamicGVTBuilder)1 GVTBuilder (org.apache.batik.bridge.GVTBuilder)1 UserAgentAdapter (org.apache.batik.bridge.UserAgentAdapter)1 SVGDocument (org.w3c.dom.svg.SVGDocument)1