You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by ���� �������� <ki...@mail.ru> on 2001/09/10 08:25:34 UTC

JSVGCanvas' s problem

Hello!
I have some problems with JSVGCanvas
When i write:
/-------------------------------------------------
        JFrame f = new JFrame("MY FRAME");
        JSVGCanvas svgCanvas = new JSVGCanvas();
        f.getContentPane().add(svgCanvas);
        f.setSize(400, 400);
        f.setVisible(true);
        f.show();
	Graphics2D g = (Graphics2D)svgCanvas.getGraphics();
	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                           RenderingHints.VALUE_ANTIALIAS_ON);

// and, for example, paint some ellipse

        Ellipse2D ellipse = new Ellipse2D.Float(20, 0, 60, 60);
        g.setPaint(new Color(176, 22, 40));
        g.fill(ellipse);


/-------------------------------------------------

why the ellipse disappear after any manipulation with the window
And maybe smth else i should use in the program to view 
a graphical object properly?

Thanks 

Ivan Kardashov


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


Re: JSVGCanvas' s problem

Posted by Thierry Kormann <tk...@ilog.fr>.
On Monday 10 September 2001 08:25, é×ÁÎ ëÁÒÄÁÛÏ× wrote:
> Hello!
> I have some problems with JSVGCanvas
> When i write:
> /-------------------------------------------------
>         JFrame f = new JFrame("MY FRAME");
>         JSVGCanvas svgCanvas = new JSVGCanvas();
>         f.getContentPane().add(svgCanvas);
>         f.setSize(400, 400);
>         f.setVisible(true);
>         f.show();
> 	Graphics2D g = (Graphics2D)svgCanvas.getGraphics();
> 	g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
>                            RenderingHints.VALUE_ANTIALIAS_ON);
>
> // and, for example, paint some ellipse
>
>         Ellipse2D ellipse = new Ellipse2D.Float(20, 0, 60, 60);
>         g.setPaint(new Color(176, 22, 40));
>         g.fill(ellipse);
>
>
> /-------------------------------------------------
>
> why the ellipse disappear after any manipulation with the window
> And maybe smth else i should use in the program to view
> a graphical object properly?

The paintComponnet method of the JSVGCanvas just draw a BufferedImage that 
represents your SVG drawing. The size of the image is set according to the 
size of the component. That means that each time, the paintComponent is 
called, the whole surface is covered by the image.

You could draw your stuffs *after* calling super.paintComponent. In that 
case, your drawing will be done on top of the image.

Hope that helps.

Thierry.


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