hi Lewis,
 
i have created a plugin project in eclipse and in the createPartControl method in myView class, i have created a Composite in the display and a frame in the composite. i then create a JSVGCanvas. i set the SVGDocument to the canvas and then add the canvas to the frame.
 
i have another class to create the SVGDocument. in this class, i use a for loop to create 'rect' elements for the bar segments.
Element e = document.createElementNS(svgNS, "rect");
e.setAttributeNS(null, "x", "xPos");
....
root.appendChild(e);

based on ur solution, does it mean that i would have to  do something like assign an id to the rect element and then:
e = myView.registerListener(....); //myView is the views class
 
and i would have to write the methods registerListener(...)?
 
also i would have to create another class for the DisplayAbout EventListener. does this mean that for each event, i have to create a seperate class? or can i put them all into a single class?
 
 
 
On 4/26/06, Lewis Keen <[EMAIL PROTECTED]> wrote:
Janice,

In my project (Texas Hold'em poker game) I have an about button
element called "about" that has the register listener following line
in Java:

       pokerTable.registerListener("about","click",new DisplayAbout());

which calls the following method in my PokerTable (Main GUI) class:

       public void registerListener(String element,String
action,EventListener listener)
       {
               try
               {
                       Element elt = doc.getElementById(element);
                       EventTarget t = (EventTarget)elt;
                       t.addEventListener(action,listener,false);
               }catch(Exception ex)
               {
                       System.out.println("Error whilst registering Listener: "+ex.getMessage());
               }
       }

then my DisplayAbout EventListener does this:

   public class DisplayAbout implements EventListener {
       public void handleEvent(Event evt) {
           Thread displayThread=new Thread(){
               public void run(){
                   try{
                       SplashScreen splash=new SplashScreen();
                       splash.setVisible(true);
                       }
                       catch (Exception ex)
                       {
                   System.out.println("An error with the poker client has
occured: "+ex.getMessage());
                       }
               }
             };
       displayThread.start();
       }
   }

So basically my method assigns a click EventListener on an XML element
in the document.

Rinse and repeat for other elements/eventlisteners. I love how simple
and consequently how quick it is to expand :)

Hope this helps,

Lewis Keen
Final Year, Software Engineering
De Montfort University, Leicester

On 4/25/06, janice tan < [EMAIL PROTECTED]> wrote:
>
> hi,
>
> am trying to implement a java application and have been trying to make use
> of the batik plugin with eclipse. i have been sucessful in creating a svg
> document for a bar chart and adding it to a JSVGCanvas to display. however,
> i would like to make my svg interactive and would need to include some
> mouseevents, linking and even loading anotehr svg on top.
> i have previously managed to do this in _javascript_. but am not sure if its
> possible through java.
>
> thanks

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


Reply via email to