package com.proteus.svg.DuplicateEventsTest;

import java.io.FileReader;
import java.io.IOException;

import javax.swing.JFrame;

import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
import org.apache.batik.dom.svg.SVGDocumentFactory;
import org.apache.batik.swing.JSVGCanvas;
import org.apache.batik.swing.svg.SVGUserAgentAdapter;

public class TestEvents extends JFrame {

	private JSVGCanvas canvas;
	private final String xmlName = "eventTest.xml";
	private SVGDocumentFactory factory;
	
	public static void main(String[] args) {
		new TestEvents();
	}
	
	public TestEvents() {
		super("Test for duplicate events");
		
		canvas = new JSVGCanvas(new MyUserAgent(), true, false);
		canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);
		factory = new SAXSVGDocumentFactory("org.apache.xerces.parsers.SAXParser");
		
		try {
			canvas.setDocument(factory.createSVGDocument(null, new FileReader(xmlName)));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		setSize(300,300);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		getContentPane().add(canvas);
		show();
	}
	
	private class MyUserAgent extends SVGUserAgentAdapter {

		public void openLink(String link, boolean arg1) {
			System.out.println("SVGUserAgent.openLink: " + link);
		}
		
	}

}



