Hello, I'm trying to open an SVG file in JAVA using batik-1.7 library, and add 
some mouse events to it.But this is not possible unless i add a "script" tag to 
the SVG file.(If i don't write "<script> </script>" in the SVG file, i cannot 
access the "handleEvent" method) (Windows 7, jdk1.6.0_20_x32)   Here is a part 
of my JAVA file : 
-------------------------------------------------------------------------------------------------------
 svgCanvas.addSVGDocumentLoaderListener(new SVGDocumentLoaderAdapter() {
      public void documentLoadingStarted(SVGDocumentLoaderEvent e) {
               label.setText("Document Loading...");
      }
      public void documentLoadingCompleted(SVGDocumentLoaderEvent e) {
               label.setText("Document Loaded.");
               addListeners(svgCanvas.getSVGDocument().getRootElement());       
                      }         });     private void addListeners(SVGSVGElement 
element) {
          element.addEventListener("mousedown"                                  
              , new EventListener() {
                                                          public void 
handleEvent(Event evt) {                                                        
          /*Add handling code*/
                                                          }                     
                                         }                                      
              , false);} 
-------------------------------------------------------------------------------------------------------
  The SVG file that i'm loading is "circles.svg" :  
-------------------------------------------------------------------------------------------------------<?xml
 version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" 
              "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd";>
<script></script>             <svg xmlns="http://www.w3.org/2000/svg";>    <g 
style="fill-opacity:0.7;">
        <circle cx="6.5cm" cy="2cm" r="100" style="fill:red; stroke:black; 
stroke-width:0.1cm" transform="translate(0,50)" />
        <circle cx="6.5cm" cy="2cm" r="100" style="fill:blue; stroke:black; 
stroke-width:0.1cm" transform="translate(70,150)" />
        <circle cx="6.5cm" cy="2cm" r="100" style="fill:green; stroke:black; 
stroke-width:0.1cm" transform="translate(-70,150)"/>
    </g>
</svg>-------------------------------------------------------------------------------------------------------
  How can i be able to access the eventHandler without adding a script tag (The 
RED part in SVG file) ? Thank you for your help, and hope to hear from you soon 
Regards,Bashir                                       

Reply via email to