xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andres Toussaint <and...@onemileup.com>
Subject Re: Opening an SVG image to a certain scale
Date Tue, 25 Jan 2005 14:06:15 GMT
I would suggest the following:

//...
         svgCanvas.addSVGDocumentLoaderListener(new 
SVGDocumentLoaderAdapter() {
             public void documentLoadingStarted(SVGDocumentLoaderEvent 
e) {
		//....
             }

             public void documentLoadingCompleted(SVGDocumentLoaderEvent 
e) {
                 SVGDocument document = e.getSVGDocument();
                 SVGOMSVGElement  documentElement = 
(SVGOMSVGElement)document.getDocumentElement();

                 String theW = "yourWidthHere";
                 String theH = "yourHeightHere";

                 documentElement.setAttributeNS(svgNS, "viewBox",  "0 0 
"+ theW +" "+ theH);
                 documentElement.setAttributeNS(svgNS, "width",  theW );
                 documentElement.setAttributeNS(svgNS, "height",  theH );
            }
         });
//...

I use this on Dynamic JSVGCanvas, and have not tried it on Static 
Canvas.

Andres.

On Jan 24, 2005, at 3:38 PM, Caron, Michael R wrote:

> Each tile is a separate JSVGCanvas, not loading them as <image> 
> elements.
>  
> Output is a JPanel:
>  
> //...
> private void init() {
>         addListeners();
>         setLayout(new BorderLayout());
>  
>         // status is a JLabel
>         status.setFont(new Font(PANEL_FONT_NAME,PANEL_FONT_STYLE,
>                 PANEL_FONT_SIZE));
>         status.setText("svg");
>         status.setHorizontalAlignment(SwingConstants.CENTER);
>        
>          // stick the SVG into an etched pane to make it look nice
>         JPanel borderedPanel = new JPanel(new 
> FlowLayout(FlowLayout.CENTER,
>                 0,0));
>         borderedPanel.setBorder(BorderFactory.createEtchedBorder());
>         
>         // svgThumbnail is a JSVGCanvas
>         svgThumbnail.setPreferredSize(new Dimension(ICON_HEIGHT, 
> ICON_WIDTH));
>         borderedPanel.add(svgThumbnail);
>        
>          // add the SVG
>         add(borderedPanel, BorderLayout.CENTER);
>        
>          // add the status line
>         add(status, BorderLayout.SOUTH);
>  
>     }
> //...
>  
> Mike
>
>
> From: Andres Toussaint [mailto:andres@onemileup.com]
>  Sent: Monday, January 24, 2005 2:34 PM
> To: Batik Users
> Subject: Re: Opening an SVG image to a certain scale
>
> Is each of your SVG tiles a separate JSVGCanvas?
>
>
>  Or are you loading your SVG Tiles as <image> elements?
>
>
>  What is your output? A Java Swing window, a raster image, a web page?
>
>
>
>
>  On Jan 24, 2005, at 2:55 PM, Caron, Michael R wrote:
>
>
>  Hi all,
>
>
> I'd like to open an SVG file to certain dimensions. Essentially, 
> create a thumbnail, but forget about the original sizes. I've tried to 
> go with the code example from the Squiggle app, but I can't seem to 
> get any output. I've looked at the transcoding option, but that 
> doesn't do what I want. What I want is to load up a bunch of svgs into 
> a grid of svg tiles no bigger than 40px x 40px. I figured I could do a 
> transform after the GVTTree was built, but that just gave me some null 
> pointers.
>
>
> Any ideas?
>
>
> L
> Michael Caron
> Software Development
> IR&D - PCES Program
>
>
> x4889

Mime
View raw message