Lasse Riis wrote:
No, but It won't compile without it either. At least not here. My IDE tells me to make it static, but i don't understand why.
But the problem was that you were using 'java.awt.Color.RED' not 'java.awt.Color.red'. What is below works.
Someone should do a thorough howto on using an overlay in a jsvgcanvas and put it in the wiki. At least I think so :)
Using an overlay is pretty trivial, your problems seem to mostly be with the Java language. This is not an appropriate forum to learn Java. There are _lots_ of resources for that.
-----
import java.awt.*; import java.awt.Graphics2D; import javax.swing.*;
import org.apache.batik.swing.JSVGCanvas; import org.apache.batik.swing.gvt.GVTTreeRendererAdapter; import org.apache.batik.swing.gvt.GVTTreeRendererEvent; import org.apache.batik.swing.gvt.Overlay;
public class MapIt implements Overlay { public static void main(String[] args) { JFrame frame = buildGUI(); frame.setSize(200, 600); frame.setVisible(true); }
public static JSVGCanvas buildCanvas(){ final JSVGCanvas canvas = new JSVGCanvas();
canvas.setBackground(Color.green);
canvas.setURI("file:/C:/Apps/cygwin/home/l449433/dev/batik/xml-batik/samples/anne.svg");
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(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]