xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Grant Mc Auley" <gmcau...@som.llu.edu>
Subject Dynamic JSVGCanvas Updates
Date Fri, 08 Aug 2003 19:21:53 GMT

My simple test program (relevant code below) loads an SVG file into a
JSVGCanvas.  Clicking a button calls a method that iteratively resizes a
circle in the SVG document.

What I am observing is this:
1) After clicking the toolbar button, I do not see the circle resize
unless I move my mouse into the canvas.
2) Further, unless I continually move my mouse over the canvas I do not
see the iterative resizing.  That is, when I continuously move the
mouse, I see the circle change size every second.  When I stop, the
circle size does not change.  When I move again, I see the updates.  If
I move outside of the canvas I see no updates.

How are canvas updates related to mouse position and movement?  Is there
something else that I must do to see live or dynamic canvas updates?

// ------- Code:

JSVGCanvas canvas = new JSVGCanvas();
File f = new File(shapes.svg");
String parser = XMLResourceDescriptor.getXMLParserClassName();
SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
Document doc = factory.createDocument(f.toURL().toString());


button.addActionListener(new ActionListener() {

  public void actionPerformed(ActionEvent e) {
    Thread t = new Thread(new Runnable() {
      public void run() {



private void resizeCircle() throws DOMException {

  SVGDocument doc = canvas.getSVGDocument();
  Element el = doc.getElementById("circleOne");
  for (int i = 0; i < 10; i++) {

    if (el.getAttribute("r").equals("20")) { // initial value of r
(radius) is 20
      el.setAttribute("r", "50");
      el.setAttribute("r", "20");
    try {
    catch (InterruptedException ex) {


// -------

To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
For additional commands, e-mail: batik-users-help@xml.apache.org

View raw message