Search in sources :

Example 1 with TranscoderException

use of org.apache.batik.transcoder.TranscoderException 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 TranscoderException

use of org.apache.batik.transcoder.TranscoderException in project yamcs-studio by yamcs.

the class SimpleImageTranscoder method updateImage.

private void updateImage() {
    if (document == null) {
        return;
    }
    if (colorToApply != null) {
        if (appliedColor == null) {
            appliedColor = colorToChange != null ? colorToChange : new Color(Display.getCurrent(), (int) 0, (int) 0, (int) 0);
        }
        changeColor(document, appliedColor, colorToApply);
        appliedColor = colorToApply;
    }
    try {
        if (canvasWidth > 0) {
            addTranscodingHint(ImageTranscoder.KEY_WIDTH, new Float(canvasWidth));
        } else {
            removeTranscodingHint(ImageTranscoder.KEY_WIDTH);
        }
        if (canvasHeight > 0) {
            addTranscodingHint(ImageTranscoder.KEY_HEIGHT, new Float(canvasHeight));
        } else {
            removeTranscodingHint(ImageTranscoder.KEY_HEIGHT);
        }
        if (canvasAOI != null) {
            addTranscodingHint(ImageTranscoder.KEY_AOI, canvasAOI);
        } else {
            removeTranscodingHint(ImageTranscoder.KEY_AOI);
        }
        transcode(new TranscoderInput(document), new TranscoderOutput());
    } catch (TranscoderException e) {
    }
}
Also used : TranscoderOutput(org.apache.batik.transcoder.TranscoderOutput) TranscoderInput(org.apache.batik.transcoder.TranscoderInput) TranscoderException(org.apache.batik.transcoder.TranscoderException) Color(org.eclipse.swt.graphics.Color)

Aggregations

TranscoderException (org.apache.batik.transcoder.TranscoderException)2 Shape (java.awt.Shape)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 ImageRenderer (org.apache.batik.gvt.renderer.ImageRenderer)1 TranscoderInput (org.apache.batik.transcoder.TranscoderInput)1 TranscoderOutput (org.apache.batik.transcoder.TranscoderOutput)1 Color (org.eclipse.swt.graphics.Color)1