Hi All,
I have an SVG that passes mouse click events to a function in a java 
application (SVGApllication.jar).

The code for the SVG is as given below
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" 
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd";>
<svg xmlns="http://www.w3.org/2000/svg";
     xmlns:xlink="http://www.w3.org/1999/xlink";>

   <script type="application/java-archive"  xlink:href="SVGApplication.jar" />
   <circle id="myclic-circle" cx="25" cy="25" r="25" fill="blue" />

</svg>

The SVG Application.jar has a SVGApplication class. This class has a run method 
that registers the mouse click event. It also implements the handleEvent method 
of the org.w3c.dom.events.EventListener interface. When the user click on the 
SVG control goes to the handleEvent function in my SVGApplication class. On 
click in the circle we change the color of the circle in the SVG.

The code for SVGApplication.java is given below:
import org.w3c.dom.*;
import org.w3c.dom.events.*;
import org.apache.batik.script.ScriptHandler;
import org.apache.batik.script.Window;

public class SVGApplication implements ScriptHandler, EventListener {
    private Document document;
   
    public SVGApplication()
        {
                
                System.out.println("In constructor!!!");
        }
    public void run (final Document document, final Window win) {
        System.out.println("In run of the function!!!");
        this.document = document;
        EventTarget changecolor = 
(EventTarget)document.getElementById("myclic-circle");
        changecolor.addEventListener("click", this, false);
    }
   
    public void handleEvent(Event evt) {
        System.out.println("In handleEvent of the function!!!");
        Element changecolor = document.getElementById("myclic-circle");
        System.out.println("changecolor:" + changecolor);
        changecolor.setAttributeNS(null, "fill", "#0F0000");
    }

My question is how can I pass the color I intend to change from the SVG. I mean 
can handleEvent in the java file take in any UserData.I know in javascript we 
can do a onclick and send in parameters how do we do this for a Dom 
EventListener interface.

Thank you,
Emmy 
             

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to