You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by Peter Armstrong <ar...@intalio.com> on 2001/03/13 03:10:17 UTC

bug in org.apache.batik.swing.JSVGCanvas

The following code in org.apache.batik.swing.JSVGCanvas does not clip
correctly (for example, when the JSVGCanvas is used in a JInternalFrame):

        Graphics2D g2d = (Graphics2D)g;
        g2d.setComposite(AlphaComposite.SrcOver);
        g2d.setClip(0, 0, w, h);//bug - incorrectly uses the size (w,h) of
the component, not the visible rect
        g2d.setPaint(getBackground());
        g2d.fillRect(0, 0, w, h);//bug - incorrectly uses the size (w,h) of
the component, not the visible rect

It should be changed to:

        Graphics2D g2d = (Graphics2D)g;
        g2d.setComposite(AlphaComposite.SrcOver);
        Rectangle visible = getVisibleRect();				//NEW
        g2d.setClip(0, 0, visible.width, visible.height);		//MODIFIED
        g2d.setPaint(getBackground());
        g2d.fillRect(0, 0, visible.width, visible.height);		//MODIFIED

Hope this helps,

Peter Armstrong


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


Re: bug in org.apache.batik.swing.JSVGCanvas

Posted by Stephane Hillion <St...@sophia.inria.fr>.
On Tuesday 13 March 2001 03:10, Peter Armstrong wrote:
> The following code in org.apache.batik.swing.JSVGCanvas does not clip
> correctly (for example, when the JSVGCanvas is used in a JInternalFrame):
>
>         Graphics2D g2d = (Graphics2D)g;
>         g2d.setComposite(AlphaComposite.SrcOver);
>         g2d.setClip(0, 0, w, h);//bug - incorrectly uses the size (w,h) of
> the component, not the visible rect
>         g2d.setPaint(getBackground());
>         g2d.fillRect(0, 0, w, h);//bug - incorrectly uses the size (w,h) of
> the component, not the visible rect
>
> It should be changed to:
>
>         Graphics2D g2d = (Graphics2D)g;
>         g2d.setComposite(AlphaComposite.SrcOver);
>         Rectangle visible = getVisibleRect();				//NEW
>         g2d.setClip(0, 0, visible.width, visible.height);		//MODIFIED
>         g2d.setPaint(getBackground());
>         g2d.fillRect(0, 0, visible.width, visible.height);		//MODIFIED

In fact the JSVGCanvas has been removed.
It has been replaced by the components in batik/swing/gvt and batik/swing/svg.
I will investigate how getVisibleRect() can be used with the new components 
to optimize the rendering area to repaint.

>
> Hope this helps,

Thanks a lot.
--
  Stephane.

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