Hi all,

Please forgive me as I have no doubt this has already been covered,
but unfortunately I couldn't find anything on this in the archives or
on the Internet as a whole (at least, nothing I had any chance of
understanding!)

I have a small Swing programme that uses a JSVGCanvas to render an SVG
image. The image is very large (1200 × 1200 pixels) but only has a
couple of simple shapes on it. I would like to scale it down so that
it fits on my Swing JFrame, but I cannot seem to grasp how to do it.
Does anyone have any pointers?



// ---- My Code ----

import java.awt.geom.AffineTransform;
import java.io.IOException;
import javax.swing.JFrame;
import org.apache.batik.swing.JSVGCanvas;

public class SVGTest5
{

    public static void main(String[] args) throws IOException
    {

        JFrame frame = new JFrame("SVGTest");
        frame.setLayout(null);
        frame.setSize(1000,600);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JSVGCanvas svgCanvas = new JSVGCanvas();
        svgCanvas.loadSVGDocument("test.svg");
        AffineTransform transform = new AffineTransform();
        transform.scale(0.2d,0.2d);
        svgCanvas.setRenderingTransform(transform);
        svgCanvas.setSize(1200,1200);

        frame.add(svgCanvas);
        frame.setVisible(true);

    }

}

// ---- End Code ----



NB: The code outlined above renders 'test.svg' perfectly, but at full
size (it should be at 20% by dimensions).

Thanks and regards,

Mark.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to