Hi Javid:
In the Java code, along with Thomas's reminder to have the SVGDocument
as Always dynamic, you need to cast into a EventTarget the SVG Element
that will respond to your events.
Also, I recommend using the DOM Objects, instead of the Batik
Implementation (i.e. Element instead of SVGOMElement) unless you need
specific functionality. The more general you are in your handling, the
hess class cast exemptions you may get.
I would have the java excerpt as:
target = (Element) svgRoot.getElementById("legend");
frame = (Element) svgRoot.getElementById("frame");
filtered = (Element) svgRoot.getElementById("filtered");
EventTarget t = (EventTarget)frame;
frame.addEventListener("mousedown", newListener, false);
...
public class newListener implements EventListener {
public void handleEvent(org.w3c.dom.events.Event evt) {
// Handle your event
}
}
On Jul 8, 2005, at 12:34 AM, Javid Alimohideen wrote:
Hi,
I am trying to do a drag and drop of a legend polygon in my SVG
document
using JAVA
and i tried to add an eventlistener to an existing element in my SVG
document and for some reason the element does not respond to my mouse
events. I use JSVGCanvas and Applet.
Can someone tell me what i am doing wrong? Here is my sample code
SVG Code:
<g id="legend" transform="translate(80, 70)" style="pointer-events:
all">
<g id="frame">
<polygon id="filtered" points ="0,0 48,0 53,5 224,5 224,166, 218,172
93,172
87,178 0,178"
style="opacity: 0.7; fill: #ffffff; stroke:#000000; filter:
url(#dropShadow);" />
<g id="upperCubes" style="fill: #999999;" transform="translate(3,3)">
<use xlink:href="#square" />
<use xlink:href="#square" x="6" style="opacity: 0.85" />
</g>
<g id="lowerCubes" style="fill: #999999;"
transform="translate(3,172)">
<use xlink:href="#square" style="opacity: 0.1" />
<use xlink:href="#square" x="6" style="opacity: 0.25" />
<use xlink:href="#square" x="12" style="opacity: 0.4" />
</g>
</g>
</g>
JAVA code:
target = (SVGOMGElement) svgRoot.getElementById("legend");
frame = (SVGOMGElement) svgRoot.getElementById("frame");
filtered = (SVGOMPolygonElement) svgRoot.getElementById("filtered");
frame.addEventListener("mousedown", newListener, false);
My problem is the frame never responds to my mouse down events.
Thanks,
Javid
A clever person solves a problem.
A wise person avoids it.
-- Einstein
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail:
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]