Mmm, promising but no joy.  I tried two event handlers that looked
promising...

           canvas.addGVTTreeRendererListener(this);     
           canvas.addJGVTComponentListener(this);
 
then we have, called by paint

            canvas.setRenderingTransform(currentTX);         
            Graphics2D g2 = (Graphics2D) backbuffer.getGraphics();
            g2.drawImage(img, new AffineTransform(), this);
   

...and in the event handler(s)


       public void gvtRenderingCompleted(GVTTreeRendererEvent arg0) {
            img = new BufferedImage(getWidth(), getHeight(),
BufferedImage.TYPE_USHORT_565_RGB);       
            Graphics2D gimg = (Graphics2D) img.getGraphics();
            gimg.fill3DRect(0, 0, 500, 500, true);
            canvas.paint(gimg);         
        }

        public void componentTransformChanged(ComponentEvent arg0) {           
            img = new BufferedImage(getWidth(), getHeight(),
BufferedImage.TYPE_USHORT_565_RGB);       
            Graphics2D gimg = (Graphics2D) img.getGraphics();
            gimg.fill3DRect(0, 0, 500, 500, true);
            canvas.paint(gimg);         
         }


I tried with just the GVTEventHandler at first but the
canvas.setRenderingTransform() method doesn't cause that event to fire.  So
then I hunted around and found the componentTransformChanged event, but
while it does seem to make the performance better the issues remain.  So I
think it is indeed a timing issue as suggested, its just that these events
are apparently not the ones to use when wanting to know when the canvas is
done rendering.


EUBanana wrote:
> 
> Thanks Thomas, that sounds very promising, it sounds right to me.
> 
> I'll have a play with this and see how it goes.
> 
> 
> thomas.deweese wrote:
>> 
>> Hi EUBanana,
>> 
>> EUBanana <[EMAIL PROTECTED]> wrote on 11/25/2008 11:08:26 AM:
>> 
>>> Well, it almost certainly is generic misuse of Batik - but the DOM isn't
>>> actually being touched at all (to my knowledge anyway).  The only thing
>>> being altered in the JSVGCanvas is the setRenderingTransform.
>>> 
>>> And the canvas itself always displays perfectly, the problem is in the 
>> image
>>> I'm trying to paint it onto.
>> 
>>    I suspect the problem is that you are not waiting for the rendering
>> to complete.  You need to wait until the 'gvtRenderingCompleted' event
>> is sent before you paint the buffer image.  You can get notified by
>> adding a 'GVTTreeRendererListener' to the canvas (
>> addGVTTreeRendererListener).
>> 
>>> Helder Magalhães wrote:
>>> > 
>>> >> The problem is that while sometimes it renders perfectly, as the
>>> >> transform
>>> >> changes various parts of the SVG image fail to be drawn onto the
>>> >> BufferedImage and you get weird effects.  The most common thing is 
>> for
>>> >> the
>>> >> text elements to be missing, but sometimes it misses out other parts 
>> of
>>> >> the
>>> >> image too.  This isn't a predictable thing, it doesn't seem to be
>>> >> replicatable per se - sometimes a given transform will work, 
>> sometimes it
>>> >> won't!  The first screenshot shows it working as intended, the second
>>> >> shows
>>> >> it with a problem...
>>> > 
>>> > Weird/unpredictable behavior? This sounds like another attack of a
>>> > general misuse of Batik [1] (I noticed several manipulations through
>>> > code but I couldn't find any reference to the UpdateManager [2]). :-D
>>> > 
>>> > Sorry if my assumption is wrong (I only took a quick look at the code,
>>> > no decent analysis made). ;-)
>>> > 
>>> > Hope this helps,
>>> > 
>>> >  Helder Magalhães
>>> > 
>>> > [1]
>>> > http://mail-archives.apache.org/mod_mbox/xmlgraphics-batik-
>>> users/200811.mbox/%
>>> [EMAIL PROTECTED]
>>> > [2] 
>> http://xmlgraphics.apache.org/batik/using/scripting/java.html#Threads
>>> > 
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> > For additional commands, e-mail: 
>> [EMAIL PROTECTED]
>>> > 
>>> > 
>>> > 
>>> 
>>> -- 
>>> View this message in context: http://www.nabble.com/Batik-rendering-
>>> issues-tp20682211p20684261.html
>>> Sent from the Batik - Users mailing list archive at Nabble.com.
>>> 
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Batik-rendering-issues-tp20682211p20686111.html
Sent from the Batik - Users mailing list archive at Nabble.com.


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

Reply via email to