Thomas E Deweese wrote:

>     Ok as I thought you are definitely beeing called from multiple
> threads (as you admit later :).

Yes there are multiple threads in my program, but my graphics code is
only being called by one thread.  I tried printing the SVGGraphics2D
and thread name as you suggested, and there's only one thread
(originated by the servlet's doGet()) manipulating the SVGGraphics2D.

> GA>       // my pre-existing SVGGraphics2D, that I wish to paint on
> GA> SVGGraphics2D g = ...;
> 
>     I assume by this you mean it is some sort of singleton or shared
> instance (from a static or some such)?

No not static or shared, but rather dynamically created for each
doGet().  

> GA>       // create a copy of this SVG SVGGraphics2D g2 =
> GA> (SVGGraphics2D) g.create();
> 
>     Be aware that this does not appear to do a deep copy , and this
> method is not thread safe (so if two threads call g.create() at the
> same time you will be in trouble).

To be honest I'm not sure why the create() is needed; I'm just
mimicking what's being done in SwingSVGPrettyPrint.  I'd love to hear
an explanation from the author of what that's all about.  But as I
said before, it's always the same thread calling the create().

>     Have you tried putting the above code in a synchronize block on g?

Yes, and I still get ArrayIndexOutOfBoundsException.

> GA> Actually it's being called from a Servlet so there are certainly
> GA> multiple threads in play, but a new SVGGraphics2D is created for
> GA> each doPost/doGet, and I do all my painting serially from that
> GA> thread.  I'm not doing any painting in response to GUI/Swing
> GA> events.
> 
>     When you say a new SVGGraphics2D is created for each one are you
> counting 'create' as creating a new one?  If so this is the problem.

No.  I'm doing the following for each doGet():

    DOMImplementation impl =
SVGDOMImplementation.getDOMImplementation();
    Document doc = impl.createDocument(svgNS, "svg", null);
    g = new SVGGraphics2D(doc);

(Perhaps the DOMImplementation should be cached...)

Thanks again for your help in debugging this.


--
George Armhold
Rutgers University
Bioinformatics Initiative

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

Reply via email to