[prev in list] [next in list] [prev in thread] [next in thread]
List: batik-users
Subject: EventListener doesn't work
From: sjm2932 <sjm2932 () chol ! com>
Date: 2011-08-16 7:37:05
Message-ID: 1313480225530-3746550.post () n4 ! nabble ! com
[Download RAW message or body]
Hi,
I have written a Swing component which wraps JSVGCanvas, and I would
like to capture DOM elements using eventlistener.
So some source code of the program is as follows:
@Override
public void run() {
try {
while (true) {
// Only update the DOM while rendering is not in progress
Element newNode = null;
Element parent = null;
UpdateManager um = jSVGCanvas1.getUpdateManager();
doc = um.getDocument();
Element svgRoot = doc.getDocumentElement();
synchronized (updateList) {
switch (EditType) {
case ADD: {
Element newNode =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, "line");
newNode =
doc.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI, "line");
newNode.setAttributeNS(null, "id",
"currentdrawing_111123");
newNode.setIdAttribute("", true);
newNode.setIdAttribute("id", true);
newNode.setAttributeNS(null, "stroke",
"black");
newNode.setAttributeNS(null, "stroke-width", "1");
newNode.setAttributeNS(null, "x1", "7");
newNode.setAttributeNS(null, "y1", "22");
newNode.setAttributeNS(null, "x2", "115");
newNode.setAttributeNS(null, "y2", "223");
parent = svgRoot;
parent.appendChild(newNode); \
break;
}
case UPDATE: {
break;
}
case REMOVE: {
break;
}
}
} else {
updateList.wait();
}
}
if ((parent != null) && (newNode != null)) {
parent.appendChild(newNode);
if (!buttonGroup1.isSelected(cursorbutton.getModel())) {
t1 = (EventTarget) doc.getElementById
(newNode.getAttribute("id").toString());
t1.addEventListener ("click", new
OnClickCircleAction (), false);
}
} else {
log.log(Level.WARNING, "Unknown parent element ID {0},
element {1} not added", new Object[]{parent, newNode});
}
// Check to see if we emptied the list this run
if (updateList.size() == 0) {
rendering = new Date().getTime();
// Resize the SVG Canvas
svgRoot.setAttribute("width",
String.valueOf(getWidth()));
svgRoot.setAttribute("height",
String.valueOf(getHeight()));
log.info("--- Forcing Canvas Repaint ---");
// This can take a while, and putting it inside the
synchronized
// block seems to deadlock due to updates being
enqueued
um.forceRepaint();
}
}
} catch (InterruptedException ex) {
log.warning("Caught Interrupted Exception, exiting update
thread");
}
}
But my event handler is never called.
I do not understand why it is not called.
Using JDK 1.6.25 and Batik 1.7.
Any suggestions would be greatly appreciated.
--
View this message in context: \
http://batik.2283329.n4.nabble.com/EventListener-doesn-t-work-tp3746550p3746550.html \
Sent from the Batik - Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic