xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomas.dewe...@kodak.com
Subject Re: Getting user data in the handleEvent function in java application
Date Wed, 14 Mar 2007 10:49:42 GMT
Hi Emmy,

"Emmy Alex" <ealex@hermes.tietronix.com> wrote on 03/09/2007 08:13:30 AM:

> 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.

   [...] 

> 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.

   In java (most object orient languages actually) you don't use
userData, instead you use the callback object to store your user data.
So in your case you will need to create a separate listener object
that you pass the color you want to when you create it:

    public class MyListener implements EventListener {
        String myColor;
        public MyListener(String myColor) {
                this.myColor = mycolor;
        }
        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", myColor);
      }
    }



---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Mime
View raw message