deweese     2003/03/26 07:36:19

  Modified:    sources/org/apache/batik/apps/svgbrowser
                        ThumbnailDialog.java
  Log:
  The Thumbnail dialog now takes document viewbox transform into account
  when setting it's rendering transform up.
  
  Revision  Changes    Path
  1.9       +41 -2     
xml-batik/sources/org/apache/batik/apps/svgbrowser/ThumbnailDialog.java
  
  Index: ThumbnailDialog.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/apps/svgbrowser/ThumbnailDialog.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ThumbnailDialog.java      29 Aug 2001 17:01:47 -0000      1.8
  +++ ThumbnailDialog.java      26 Mar 2003 15:36:19 -0000      1.9
  @@ -48,6 +48,10 @@
   
   import org.apache.batik.util.gui.resource.ResourceManager;
   
  +import org.apache.batik.gvt.CanvasGraphicsNode;
  +import org.apache.batik.gvt.CompositeGraphicsNode;
  +import org.apache.batik.gvt.GraphicsNode;
  +
   import org.w3c.dom.svg.SVGDocument;
   import org.w3c.dom.svg.SVGSVGElement;
   
  @@ -106,7 +110,8 @@
           // register listeners to maintain consistency
           this.svgCanvas = svgCanvas;
           svgCanvas.addGVTTreeRendererListener(new ThumbnailGVTListener());
  -        svgCanvas.addSVGDocumentLoaderListener(new ThumbnailDocumentListener());
  +        svgCanvas.addSVGDocumentLoaderListener(new ThumbnailDocumentListener());    
    svgCanvas.addComponentListener(new ThumbnailCanvasComponentListener());
  +
   
           // create the thumbnail
           svgThumbnailCanvas = new JGVTComponent();
  @@ -128,6 +133,16 @@
           updateThumbnailRenderingTransform();
       }
   
  +    protected CanvasGraphicsNode getCanvasGraphicsNode(GraphicsNode gn) {
  +        if (!(gn instanceof CompositeGraphicsNode))
  +            return null;
  +        CompositeGraphicsNode cgn = (CompositeGraphicsNode)gn;
  +        gn = (GraphicsNode)cgn.getChildren().get(0);
  +        if (!(gn instanceof CanvasGraphicsNode))
  +            return null;
  +        return (CanvasGraphicsNode)gn;
  +    }
  +
       /**
        * Updates the thumbnail component rendering transform.
        */
  @@ -147,6 +162,19 @@
                   double s = Math.min(sx, sy);
                   Tx = AffineTransform.getScaleInstance(s, s);
               }
  +
  +            GraphicsNode gn = svgCanvas.getGraphicsNode();
  +            CanvasGraphicsNode cgn = getCanvasGraphicsNode(gn);
  +            AffineTransform vTx = cgn.getViewingTransform();
  +            if ((vTx != null) && !vTx.isIdentity()) {
  +                try {
  +                    AffineTransform invVTx = vTx.createInverse();
  +                    Tx.concatenate(invVTx);
  +                } catch (NoninvertibleTransformException nite) {
  +                    /* nothing */
  +                }
  +            }
  +
               svgThumbnailCanvas.setRenderingTransform(Tx);
               overlay.synchronizeAreaOfInterest();
           }
  @@ -258,6 +286,17 @@
        * resized properly.
        */
       protected class ThumbnailComponentListener extends ComponentAdapter {
  +
  +        public void componentResized(ComponentEvent e) {
  +            updateThumbnailRenderingTransform();
  +        }
  +    }
  +
  +    /**
  +     * Used to allow the SVG document being displayed by the thumbnail to be
  +     * resized properly when parent resizes.
  +     */
  +    protected class ThumbnailCanvasComponentListener extends ComponentAdapter {
   
           public void componentResized(ComponentEvent e) {
               updateThumbnailRenderingTransform();
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to