use of org.apache.batik.bridge.BridgeContext in project yamcs-studio by yamcs.
the class SimpleImageTranscoder method initCSSEngine.
/**
* Call before querying for CSS properties. If document has CSS engine installed returns null. Client is responsible
* to dispose bridge context if it was returned by this method.
*/
public BridgeContext initCSSEngine() {
if (this.document == null) {
return null;
}
SVGOMDocument sd = (SVGOMDocument) this.document;
if (sd.getCSSEngine() != null) {
return null;
}
class BridgeContextEx extends BridgeContext {
public BridgeContextEx() {
super(SimpleImageTranscoder.this.userAgent);
BridgeContextEx.this.setDocument(SimpleImageTranscoder.this.document);
BridgeContextEx.this.initializeDocument(SimpleImageTranscoder.this.document);
}
}
return new BridgeContextEx();
}
use of org.apache.batik.bridge.BridgeContext in project charts by vaadin.
the class PdfExportDemo method buildBatikGraphicsNode.
/**
* Use Batik SVG Toolkit to create GraphicsNode for the target SVG.
* <ol>
* <li>Create SVGDocument</li>
* <li>Create BridgeContext</li>
* <li>Build GVT tree. Results to GraphicsNode</li>
* </ol>
*
* @param svg
* SVG as a String
* @return GraphicsNode
* @throws IOException
* Thrown when SVG could not be read properly.
*/
private GraphicsNode buildBatikGraphicsNode(String svg) throws IOException {
UserAgent agent = new UserAgentAdapter();
SVGDocument svgdoc = createSVGDocument(svg, agent);
DocumentLoader loader = new DocumentLoader(agent);
BridgeContext bridgeContext = new BridgeContext(agent, loader);
bridgeContext.setDynamicState(BridgeContext.STATIC);
GVTBuilder builder = new GVTBuilder();
GraphicsNode imageGraphics = builder.build(bridgeContext, svgdoc);
return imageGraphics;
}
Aggregations