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 ch...@gmx.de on 2006/03/07 12:49:22 UTC

Drawing svg

Hi batik-users,

I still want to draw an svg to my graphics context. I tried the following
little java programm without success. I would have expected that the svg
woulb be drawn to my frame. (At least after waiting some time to give the
app the chance to load the svg file and then forcing the frame to be redrawn
...)

What am I missing here?
Thanks
Charly


import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Color;
import java.awt.geom.AffineTransform;

import javax.swing.JFrame;
import javax.swing.JPanel;

import org.apache.batik.swing.JSVGCanvas;

public class xmt extends JFrame
{
    public static void main(String[] args) {
        xmt myFrame = new xmt();
        myFrame.setSize(400,400);
        myFrame.setVisible(true);
    }

    private JSVGCanvas svg;

    xmt() {
        svg = new JSVGCanvas();
        svg.setURI("file:../fc02.svg");
    }


    public void paint(Graphics g) {
System.out.println("paint");
        super.paint(g);
//      svg.setPaintingTransform(new AffineTransform(0.5, 0.0, 0.0, 0.5,
100.0, 100.0));
        svg.paintComponent(g);
    }
}

-- 
"Feel free" mit GMX FreeMail!
Monat f�r Monat 10 FreeSMS inklusive! http://www.gmx.net

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


Re: Drawing svg

Posted by Tonny Kohar <to...@kiyut.com>.
Hi,

On Tue, 2006-03-07 at 12:49 +0100, charlyM@gmx.de wrote:
> Hi batik-users,
> 
> I still want to draw an svg to my graphics context. I tried the following
> little java programm without success. I would have expected that the svg
> woulb be drawn to my frame. (At least after waiting some time to give the
> app the chance to load the svg file and then forcing the frame to be redrawn
> ...)
> 
> What am I missing here?
> Thanks
> Charly

If you are using JSVGCanvas from Batik, it might be better if you add JSVGCanvas into the frame / panel as a component and let it paint itself.
JSVGCanvas is Swing JComponent, you could add it directly into frame /
panel.

Regards
Tonny Kohar
-- 
Sketsa 
SVG Graphics Editor
http://www.kiyut.com


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


Re: Drawing svg

Posted by th...@kodak.com.
Hi Charly,

charlyM@gmx.de wrote on 03/07/2006 06:49:22 AM:

> I still want to draw an svg to my graphics context. I tried the 
following
> little java programm without success. I would have expected that the svg
> woulb be drawn to my frame. (At least after waiting some time to give 
the
> app the chance to load the svg file and then forcing the frame to be 
redrawn
> ...)
> 
> What am I missing here?

   You haven't provided a size for the JSVGCanvas, so it's size is zero.
As to what an affine transform is see the JavaDocs for: 
        java.awt.geom.AffineTransform

   Take a look at the Batik Wiki:
        http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom

   The 'rootGN' has a method called 'paint' that takes
a java Graphics2D.

> Thanks
> Charly
> 
> 
> import java.awt.Graphics;
> import java.awt.Graphics2D;
> import java.awt.Color;
> import java.awt.geom.AffineTransform;
> 
> import javax.swing.JFrame;
> import javax.swing.JPanel;
> 
> import org.apache.batik.swing.JSVGCanvas;
> 
> public class xmt extends JFrame
> {
>     public static void main(String[] args) {
>         xmt myFrame = new xmt();
>         myFrame.setSize(400,400);
>         myFrame.setVisible(true);
>     }
> 
>     private JSVGCanvas svg;
> 
>     xmt() {
>         svg = new JSVGCanvas();
>         svg.setURI("file:../fc02.svg");
>     }
> 
> 
>     public void paint(Graphics g) {
> System.out.println("paint");
>         super.paint(g);
> //      svg.setPaintingTransform(new AffineTransform(0.5, 0.0, 0.0, 0.5,
> 100.0, 100.0));
>         svg.paintComponent(g);
>     }
> }
> 
> -- 
> "Feel free" mit GMX FreeMail!
> Monat für Monat 10 FreeSMS inklusive! http://www.gmx.net
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 


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