import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.swing.svg.SVGUserAgent;
import org.apache.batik.swing.svg.SVGUserAgentAdapter;
import java.io.File;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JTextArea;

public class CanvasUserAgentExample {

    public static void main(String[] args) {
        // A text area for messages
        final JTextArea t = new JTextArea();
        t.setPreferredSize(new Dimension(600, 100));
        t.setBackground(new Color(0x44, 0x44, 0x44));
        t.setForeground(Color.WHITE);

        // A user agent object
        SVGUserAgent ua = new SVGUserAgentAdapter() {
            public void showAlert(String message) {
                t.append(message + "\n");
            }
        };

        // A canvas to show "circles.svg"
        JSVGCanvas c = new JSVGCanvas(ua, true, false);
        c.setURI(new File("circles.svg").toURI().toString());

        // A frame for the canvas to live in
        JFrame f = new JFrame("Canvas user agent example");
        f.setSize(600, 300);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().setLayout(new BorderLayout());

        // Add the canvas and text area to the frame
        f.getContentPane().add(c);
        f.getContentPane().add(t, BorderLayout.SOUTH);

        // Show the frame
        f.setVisible(true);
    }
}

