* also be an instance of <code>EventTarget</code> otherwise no listener
* will be added.
* @param node the <code>GraphicsNode</code>.
*/
public static void addDOMListener(BridgeContext ctx, Element eee) {
SVGElement element = null;
EventTarget target = null;
try {
element = (SVGElement)eee;
// ability for scripts to be called
target = (EventTarget)element;
} catch (ClassCastException e) {
// will not work on this one!
return;
}
SVGSVGElement svgElement = (SVGSVGElement)element.getOwnerSVGElement();
if (svgElement == null) {
if (element.getLocalName().equals(SVG_SVG_TAG)) {
svgElement = (SVGSVGElement)element;
} else {
// something goes wrong => disable scripting
return;
}
}
String language = svgElement.getContentScriptType();
String script = null;
if (element.getLocalName().equals(SVG_SVG_TAG)) {
for (int i = 0; i < EVENT_ATTRIBUTES_SVG.length; i++) {
if (!(script = element.getAttribute(EVENT_ATTRIBUTES_SVG[i])).
equals("")) {
// <!> TODO this will stop working if someone change
// the content of the event attribute
addScriptCaller(target, EVENT_NAMES[i+FIRST_SVG_EVENT],
new ScriptCaller(ctx, script, language));
}
}
// continue
} else
if (element.getLocalName().equals("set") ||
element.getLocalName().startsWith("animate")) {
for (int i = 0; i < EVENT_ATTRIBUTES_ANIMATION.length; i++) {
if (!(script =
element.getAttribute(EVENT_ATTRIBUTES_ANIMATION[i])).
equals("")) {
// <!> TODO this will stop working if someone change
// the content of the event attribute
addScriptCaller(target, EVENT_NAMES[i+
FIRST_ANIMATION_EVENT],
new ScriptCaller(ctx, script, language));
}
}
// not other stuff to do on this kind of events
return;
}
for (int i = 0; i < EVENT_ATTRIBUTES_GRAPHICS.length; i++) {
if (!(script = element.getAttribute(EVENT_ATTRIBUTES_GRAPHICS[i])).
equals("")) {
// <!> TODO this will stop working if someone change
// the content of the event attribute
addScriptCaller(target, EVENT_NAMES[i],
new ScriptCaller(ctx, script, language));