Search in sources :

Example 1 with ImageRenderer

use of org.apache.batik.gvt.renderer.ImageRenderer in project yamcs-studio by yamcs.

the class SimpleImageTranscoder method transcode.

@Override
protected void transcode(Document document, String uri, TranscoderOutput output) throws TranscoderException {
    super.transcode(document, uri, output);
    int w = (int) (this.width + 0.5);
    int h = (int) (this.height + 0.5);
    ImageRenderer renderer = createImageRenderer();
    renderer.updateOffScreen(w, h);
    // curTxf.translate(0.5, 0.5);
    renderer.setTransform(curTxf);
    renderer.setTree(this.root);
    // We're done with it...
    this.root = null;
    try {
        Shape raoi = new Rectangle2D.Float(0, 0, width, height);
        // Warning: the renderer's AOI must be in user space
        renderer.repaint(curTxf.createInverse().createTransformedShape(raoi));
        bufferedImage = renderer.getOffScreen();
    } catch (Exception ex) {
        throw new TranscoderException(ex);
    }
}
Also used : ImageRenderer(org.apache.batik.gvt.renderer.ImageRenderer) Shape(java.awt.Shape) TranscoderException(org.apache.batik.transcoder.TranscoderException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) TranscoderException(org.apache.batik.transcoder.TranscoderException)

Example 2 with ImageRenderer

use of org.apache.batik.gvt.renderer.ImageRenderer in project yamcs-studio by yamcs.

the class SVGHandler method createImageRenderer.

/**
 * Creates a new renderer.
 */
protected ImageRenderer createImageRenderer() {
    ImageRenderer renderer = null;
    if (isDynamicDocument) {
        renderer = rendererFactory.createDynamicImageRenderer();
    } else {
        renderer = rendererFactory.createStaticImageRenderer();
    }
    renderer.getRenderingHints().add(renderingHints);
    return renderer;
}
Also used : ImageRenderer(org.apache.batik.gvt.renderer.ImageRenderer)

Aggregations

ImageRenderer (org.apache.batik.gvt.renderer.ImageRenderer)2 Shape (java.awt.Shape)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TranscoderException (org.apache.batik.transcoder.TranscoderException)1