Return-Path: Delivered-To: apmail-xml-batik-users-archive@www.apache.org Received: (qmail 72829 invoked from network); 25 Jan 2005 22:32:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 25 Jan 2005 22:32:09 -0000 Received: (qmail 20466 invoked by uid 500); 25 Jan 2005 22:32:08 -0000 Delivered-To: apmail-xml-batik-users-archive@xml.apache.org Received: (qmail 20454 invoked by uid 500); 25 Jan 2005 22:32:08 -0000 Mailing-List: contact batik-users-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: "Batik Users" Delivered-To: mailing list batik-users@xml.apache.org Received: (qmail 20438 invoked by uid 99); 25 Jan 2005 22:32:07 -0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of Thomas.DeWeese@kodak.com designates 192.232.121.200 as permitted sender) Received: from smtp1.kodak.com (HELO smtp1.kodak.com) (192.232.121.200) by apache.org (qpsmtpd/0.28) with ESMTP; Tue, 25 Jan 2005 14:32:06 -0800 Received: from roc-us-e1000-112.kodak.com (roc-us-e1000-112.kodak.com [192.232.121.192]) by smtp1.kodak.com (8.11.3/8.11.1) with SMTP id j0PMW4Q10051 for ; Tue, 25 Jan 2005 17:32:04 -0500 (EST) Received: from (150.220.57.136) by roc-us-e1000-112.kodak.com via smtp id 1ed1_3b25be0c_6f21_11d9_8ded_0002b3c946b6; Tue, 25 Jan 2005 17:34:09 -0500 (EST) Message-ID: <41F6C8E3.6080801@Kodak.com> Date: Tue, 25 Jan 2005 17:32:03 -0500 From: Thomas DeWeese Organization: Eastman Kodak Company User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Batik Users Subject: Re: Opening an SVG image to a certain scale References: In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi Mike, You aren't setting the viewBox to the right value. You want to set the viewBox to the box that will "cover" your content (often although not always the bounding box of the outermost SVG element). Also the width/height/viewBox _attributes_ are in the 'null' (or no) namespace (_elements_ are in the SVG namespace). Probably the easiest thing to do would be to subclass the canvas and override it's calculateViewingTransform call to be based on the bbox of the root SVG element and the size of the JSVGComponent. This would avoid modifying the SVG Document. Caron, Michael R wrote: > I'm not getting the same results with this code: > > // Set the JSVGCanvas listeners. > svgOrig.addSVGDocumentLoaderListener(new > SVGDocumentLoaderAdapter() { > public void documentLoadingStarted(SVGDocumentLoaderEvent e) > { > status.setText("Document Loading..."); > System.out.println("Document Loading..."); > } > public void documentLoadingCompleted(SVGDocumentLoaderEvent > e) { > svgOrigDocument = e.getSVGDocument(); > > // here is setting the document height and width > String svgNS = "http://www.w3.org/2000/svg"; > SVGOMSVGElement documentElement = (SVGOMSVGElement) > svgOrigDocument.getDocumentElement(); > documentElement.setAttributeNS(svgNS, > "viewBox", "0 0 "+ ICON_WIDTH +" "+ ICON_HEIGHT); > documentElement.setAttributeNS(svgNS, > "width", ""+ICON_WIDTH); > documentElement.setAttributeNS(svgNS, > "height", ""+ICON_HEIGHT); > > //debug only so I can see results > DOMBuilder b = new DOMBuilder(); > Document d = b.build(svgOrigDocument); > XMLOutputter writer = new XMLOutputter(); > try { > writer.output(d, new FileOutputStream(new > File("src/xml/out.xml"))); > } catch ( IOException x ) { > x.printStackTrace(); > } > // end debug > > status.setText("Document Loaded."); > System.out.println("Document Loaded."); > } > }); > > An interesting thing is that in the outputted XML document, I get the > following for the root element: > xmlns:xlink="http://www.w3.org/1999/xlink" > contentScriptType="text/ecmascript" zoomAndPan="magnify" width="450" > > contentStyleType="text/css" version="1.0" > preserveAspectRatio="xMidYMid meet" viewBox="0 0 60 60" height="60"> > > Notice that the WIDTH was never changed. (why? Is that because of this > preserverAspectRatio thing?) > > Back to the drawing board. I think that I will attempt to load the > document before the GUI stuff, then > I'll make the transform, then calculate the size of the canvas that I'll > need and stick in the image. Will that work? > > I'm not too familiar with the 2D graphics API and these Affine Transform > deals. I don't know what a ViewBox is and I'm guessing that I'll have to > just start reading about SVG... Yuck. APIs are supposed to take away > these frustrations: > > int HEIGHT = 40; > int WIDTH = 60; > JSVGCanvas canvas = > batik.lite.Renderer.openImg("C:/Tmp/MyImage",HEIGHT,WIDTH); > // bam! > JFrame f = new Jpanel(); > f.add(canvas); > f.show(); > // bam! > > > Dreamy. > Mike > > ________________________________ > > From: Andres Toussaint [mailto:andres@onemileup.com] > Sent: Tuesday, January 25, 2005 8:06 AM > To: Batik Users > Subject: Re: Opening an SVG image to a certain scale > > > 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 > 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 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 > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org > For additional commands, e-mail: batik-users-help@xml.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org For additional commands, e-mail: batik-users-help@xml.apache.org