Hello All,
I want to handle a "click" event in a SVG document.
My code looks like this
public class PositionNrSelect implements EventListener
{
public void handleEvent(Event evt)
{
Element e=(Element)evt.getTarget();
if(e.getFirstChild()!=null)
{
// Do necessary processing....
}
}
}
I am adding the EVent listener as follows
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
svgDocument = (SVGDocument) f.createDocument(svgFileSys.toURL().toString());
svgCanvas.setDocument(svgDocument);
Element elt2 = svgCanvas.getSVGDocument().getRootElement();
EventTarget t2 = (EventTarget)elt2;
t2.addEventListener("click",new PositionNrSelect(),true);
Problem I am facing is ,Whenever I click on a number which is shown on loaded SVG I am able to enter into the evnt handling code that I have written , after this I am getting error Dailog of following type.
----
SVG Error:
E:\Mahesh\projects\geproject\Valid-test-data\new-test-data\case1\F3.072.200--001TKGMUL_03\UT_1 (The system cannot find the file specified)
-----
If I click on "details" button error shown is as folows
java.io.FileNotFoundException: E:\Mahesh\projects\geproject\Valid-test-data\new-test-data\case1\F3.072.200--001TKGMUL_03\UT_1 (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at org.apache.batik.util.ParsedURLData.openStreamInternal(Unknown Source)
at org.apache.batik.util.ParsedURLData.openStream(Unknown Source)
at org.apache.batik.util.ParsedURL.openStream(Unknown Source)
at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)
at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createSVGDocument(Unknown Source)
at org.apache.batik.bridge.DocumentLoader.loadDocument(Unknown Source)
at org.apache.batik.swing.svg.SVGDocumentLoader.run(Unknown Source)
After which click has no effects ,either I donmt get error nor I the control enters the Event handling code.
What is the problem?
Is this possible fource to ignore the error dialog?
Please reply
Note:
I am pasting that part of SVG on which I am clicking...
<g id="UT">
<metadata id="CorelCorpID_2Corel-Layer"/>
<g id="UT_1_REF">
<polyline id="UT_1_REF_1" class="fil2 str2" points="203.483,72.9546 203.483,67.3247 209.113,67.3247 209.113,72.9546 203.483,72.9546 "/>
<line id="UT_1_REF_2" class="fil2 str2" x1="166.739" y1="105.01" x2="203.713" y2= "71.3094" />
<polyline id="UT_1_REF_3" class="fil2 str3" points="203.686,72.7773 203.686,67.5537 208.91,67.5537 208.91,72.7773 203.686,72.7773 "/>
<a xlink:href="">
<rect class="fil4" x="205" y="68" width="1" height="3"/>
<g transform="matrix(0.691005 0 0 1 108.866 -19.0694)">
<text x="140.034" y="90.4591" id="UT_1_REF_4" class="fil5 fnt0">1</text>
</g>
</a>
</g>
Best Regards
Mahesh Karanth
I want to handle a "click" event in a SVG document.
My code looks like this
public class PositionNrSelect implements EventListener
{
public void handleEvent(Event evt)
{
Element e=(Element)evt.getTarget();
if(e.getFirstChild()!=null)
{
// Do necessary processing....
}
}
}
I am adding the EVent listener as follows
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory f = new SAXSVGDocumentFactory(parser);
svgDocument = (SVGDocument) f.createDocument(svgFileSys.toURL().toString());
svgCanvas.setDocument(svgDocument);
Element elt2 = svgCanvas.getSVGDocument().getRootElement();
EventTarget t2 = (EventTarget)elt2;
t2.addEventListener("click",new PositionNrSelect(),true);
Problem I am facing is ,Whenever I click on a number which is shown on loaded SVG I am able to enter into the evnt handling code that I have written , after this I am getting error Dailog of following type.
----
SVG Error:
E:\Mahesh\projects\geproject\Valid-test-data\new-test-data\case1\F3.072.200--001TKGMUL_03\UT_1 (The system cannot find the file specified)
-----
If I click on "details" button error shown is as folows
java.io.FileNotFoundException: E:\Mahesh\projects\geproject\Valid-test-data\new-test-data\case1\F3.072.200--001TKGMUL_03\UT_1 (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at org.apache.batik.util.ParsedURLData.openStreamInternal(Unknown Source)
at org.apache.batik.util.ParsedURLData.openStream(Unknown Source)
at org.apache.batik.util.ParsedURL.openStream(Unknown Source)
at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument(Unknown Source)
at org.apache.batik.dom.svg.SAXSVGDocumentFactory.createSVGDocument(Unknown Source)
at org.apache.batik.bridge.DocumentLoader.loadDocument(Unknown Source)
at org.apache.batik.swing.svg.SVGDocumentLoader.run(Unknown Source)
After which click has no effects ,either I donmt get error nor I the control enters the Event handling code.
What is the problem?
Is this possible fource to ignore the error dialog?
Please reply
Note:
I am pasting that part of SVG on which I am clicking...
<g id="UT">
<metadata id="CorelCorpID_2Corel-Layer"/>
<g id="UT_1_REF">
<polyline id="UT_1_REF_1" class="fil2 str2" points="203.483,72.9546 203.483,67.3247 209.113,67.3247 209.113,72.9546 203.483,72.9546 "/>
<line id="UT_1_REF_2" class="fil2 str2" x1="166.739" y1="105.01" x2="203.713" y2= "71.3094" />
<polyline id="UT_1_REF_3" class="fil2 str3" points="203.686,72.7773 203.686,67.5537 208.91,67.5537 208.91,72.7773 203.686,72.7773 "/>
<a xlink:href="">
<rect class="fil4" x="205" y="68" width="1" height="3"/>
<g transform="matrix(0.691005 0 0 1 108.866 -19.0694)">
<text x="140.034" y="90.4591" id="UT_1_REF_4" class="fil5 fnt0">1</text>
</g>
</a>
</g>
Best Regards
Mahesh Karanth
Yahoo! Photos
Got holiday prints? See all the ways to get quality prints in your hands ASAP.
