Hello,

I'm currently trying to do the same. I load a document in a Panel where there is an expension of the JSVGCanvas. I already use the zoom interactors that I customized and registered.
Now I want to make a new interactor, following the example of the zoom's one.
So I made a class StiffAction, that extends AbstractAction, where I define the actionPerformed as a function that adds a shape to the DOM (I think I'll be doing that through the DOM, with an SVGGeneratorContext, somebody could tell me if I'm totally wrong)
I also wrote an AbstractStiffInteractor, where the methods for drawing the pre-shape on the canvas are defined. And In my extension of JSVGCanvas, I made an interactor extending this class.
Finally, I add this interactor in the constructor of MySVGCanvas (by doing getInteractor.add(stiffInteractor); and I also add this in the actionMap.But... it doesn't work :(
I'm explaining all this hoping somebody would understand the way I'm trying to do it, and maybe correct me.
The first problem I have is that when I add my new interactor, the link-function I made doesn't work anymore...
I know I'm not so clear, but the problem I have seems even nebulous...
Every help here is always a good help, thank you




Eric Delacroix
Facult� des Sciences appliqu�es
ULB Brussels





From: "Baron, Randy {PRG~Basel}" <[EMAIL PROTECTED]>
Reply-To: "Batik Users" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Subject: Interactors and MouseEvents
Date: Thu, 13 Mar 2003 12:54:48 +0100

hi-
  I'm trying to figure out how to use the Interactors (and why actually,
instead of just using listeners).  I made a small test class that
displays an svg document (a couple of circles) and adds a custom
Interactor.  I wanted to print out some info when I clicked on the
JSVGCanvas, like what Element was clicked on.  I did this before in a
different way, by adding listeners to the JSVGCanvas (snippet below).  I
was wondering if the same info could be obtained from within the
Interactor context (some kind of 'casting' java.awt.event.MouseEvent
into an org.w3c.dom.events.MouseEvent)?
   In the end I need to write a program that displays svg elements (no
big surprise) and allows the user to modify them (location or other
properties) and so need to know what element is clicked on.

-Randy


--------------------------- Snippet of code to get info about object clicked on:

 public void registerListeners() {
        Element maindoc = (Element)  document.getDocumentElement();
        EventTarget doctarg = (EventTarget) maindoc;
        doctarg.addEventListener("click", new OnMouseClick(), false);
 }

/** Prints out some info about what was clicked on */
  public class OnMouseClick implements EventListener {
        public void handleEvent(Event evt) {
            int mx, my;
            int sx, sy;
            Element svgRoot = document.getDocumentElement();
            String svgNS = SVGDOMImplementation.SVG_NAMESPACE_URI;

            MouseEvent mevt = (MouseEvent) evt;
            mx = mevt.getClientX();
            my = mevt.getClientY();
            sx = mevt.getScreenX();
            sy = mevt.getScreenY();

SVGElement targ = (SVGElement) mevt.getTarget();

            System.out.println("   Mouse X:" + mx + " Y: " + my);
            System.out.println("   in screen coordinates - x: " + sx + "
y: " + sy);
            System.out.println("   Type of event: " + mevt.getType());
            System.out.println("   getTarget: " + mevt.getTarget());
            System.out.println("   getCurrentTarget: " +
mevt.getCurrentTarget());
            System.out.println("   Element id = " + targ.getId());


if (targ instanceof org.apache.batik.dom.svg.SVGOMTextElement) { double maxX, maxY, minX, minY; int rx, ry, rw, rh;

                SVGOMTextElement ttarg = (SVGOMTextElement) targ;
                SVGRect rectsiz = new AnSVGRect();

                System.out.println("HIT SOME TEXT");
                NodeList nlist = targ.getChildNodes();
                System.out.println(" text node length: " +
nlist.getLength());
                System.out.println(" text node item: " + " ele: " +
nlist.item(1));
         //   ....etc.



_________________________________________________________________
Utilisez votre MSN Messenger via votre GSM ! http://www.fr.msn.be/gsm/servicesms/messengerparsms



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



Reply via email to