Lasse Riis wrote:
I've been looking in to your answers and trying to build my app. But I'm
stuck now. I restructured it to use some methods to build the app, as
oppose to a huge main(). [...] Here we go:
You are close, basically you want to make your class implement
the Overlay interface from Batik, and associate your mapIt instance
with the canvas as an overlay
import org.apache.batik.swing.gvt.Overlay; // Interface
public class mapIt implements Overlay { // Note Overlay!!!!
public static JSVGCanvas buildCanvas(){
JSVGCanvas canvas = new JSVGCanvas();
canvas.setBackground(Color.green);
canvas.setURI("file:/home/riis/P2/maps/gangen.svg");
// It will now call your paint method whenever it
// update the canvas!
canvas.getOverlays().add(new mapIt());
return canvas;
}
public static JFrame buildGUI(){
JFrame f = new JFrame("PANTS - MapIt");
JSVGCanvas svgCanvas = buildCanvas();
JSlider slider = new JSlider();
JPanel panel = new JPanel(new BorderLayout());
panel.add("North", slider);
panel.add("Center", svgCanvas);
f.getContentPane().add(panel);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
return f;
}
public void paint(java.awt.Graphics g) {
g.setColor(java.awt.Color.RED);
g.fillRect(10,10,100,100);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]