Hi Mark,
> Please forgive me as I have no doubt this has already been covered, [...] Probably this was already covered (see a few related threads [1] [2] which may help). ;-) > [...] but unfortunately I couldn't find anything on this in the archives or > on the Internet as a whole (at least, nothing I had any chance of > understanding!) As Martin has stated, this is one common problem while introducing SVG. I'd only leave a slightly different suggestion: if you have control on the SVG content being viewed, you may achieve a similar effect by tweaking the root "svg" element's properties: "width" and "height" [2], as well as "viewBox" [3] and (maybe also) "preserveAspectRatio" [4]. As the default values for width and height are reasonable (100%, which is to fill the available canvas) and the preserveAspectRatio default value is also to fit by adjusting the image to the canvas by resizing proportionally (which is the typical use-case). Your intended behavior could then be achieved with: <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 1200"> <!-- content will be visible from (0, 0) to (1200, 1200), in user coordinates, independently of canvas dimension and/or screen resolution --> </svg> > [...] I would like to scale it down so that > it fits on my Swing JFrame, but I cannot seem to grasp how to do it. [...] > JSVGCanvas svgCanvas = new JSVGCanvas(); > svgCanvas.loadSVGDocument("test.svg"); > AffineTransform transform = new AffineTransform(); > transform.scale(0.2d,0.2d); > svgCanvas.setRenderingTransform(transform); > svgCanvas.setSize(1200,1200); > > frame.add(svgCanvas); > frame.setVisible(true); My guess this isn't working not because of any logical error but because you add the "svgCanvas" to the frame (and set it visible) _after_ setting the rendering transform: if I'm not mistaken, this will cause the rendering engine to recalculate everything, thereby discarding your previous changes...? In order for this to work, I guess you'll need to use the update manager thread [2] [6]. > Thanks and regards, Hope this helps, Helder Magalhães [1] http://www.nabble.com/A-plan-for-resizing-a-document--to16752041.html [2] http://www.nabble.com/Re%3A-About-setRenderingTransform()-method-from-JSVGCanvas!-to24053334.html [3] http://www.w3.org/TR/SVG/struct.html#SVGElement [4] http://www.w3.org/TR/SVG/coords.html#ViewBoxAttribute [5] http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute [6] http://xmlgraphics.apache.org/batik/using/scripting/java.html --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
