Hi Yasmin,

[EMAIL PROTECTED] wrote on 03/11/2006 05:44:31 PM:

> I did initially try to add the red circles to the svg document
> programatically, infact I think you emailed me a snippet of your code 
but
> it doesn't work, the code compiles but does not display the red-circles, 
I
> tried to repaint my canvas, that don't work... here's the code I'm using
> maybe you might be able to spot where I'm making the error...

   The code looks pretty good.  You aren't that far from a 
standalone example, this would help me help you...

> //I added this in my constructor
> canvas.setDocumentState(JSVGCanvas.ALWAYS_DYNAMIC);

   This must be done _before_ you set the document on the canvas.

> //The following code I added in my ActionListener triggred by a button

   Are you sure this code runs?  Some println's might help make sure
that your spots list isn't empty for some reason, etc.  You don't
need to 'repaint' the canvas.

> canvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new
> Runnable() {
> 
>                       public void run()
>                       {
>                         SVGDocument doc = canvas.getSVGDocument();
>                         String SVGNS = "http://www.w3.org/2000/svg";;
>                         Iterator i = spots.iterator();
>                         Element g = doc.getElementById("circleGroup");
>                        if (g == null)
>                        {
>                           g = doc.createElementNS(SVGNS,"g");
>                           g.setAttributeNS(null, "id", "circleGroup");
>                           doc.getRootElement().appendChild(g);
>                        }
> 
> 
>                         while (i.hasNext())
>                         {
>                           Point2D pt2d = (Point2D) i.next();
>                           Element e = 
doc.createElementNS(SVGNS,"circle");
>                           e.setAttributeNS(null,"cx",""+pt2d.getX());
>                           e.setAttributeNS(null,"cy",""+pt2d.getY());
>                           e.setAttributeNS(null,"r","8");
>                           e.setAttributeNS(null,"fill","Red");
>                           g.appendChild(e);
>                         }
>                       }
>                       });
> 
>                       canvas.repaint();


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to