xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dewe...@apache.org
Subject cvs commit: xml-batik/test-references/org/apache/batik/ext/awt/geom .cvsignore
Date Wed, 20 Feb 2002 13:27:10 GMT
deweese     02/02/20 05:27:10

  Modified:    samples/extensions multi.svg
               sources/org/apache/batik/extension/svg
                        BatikDomExtension.java BatikExtConstants.java
                        BatikMultiImageElementBridge.java
               sources/org/apache/batik/extension/svg/renderable
                        MultiResRable.java
  Added:       sources/org/apache/batik/extension/svg
                        BatikMultiImageElement.java
               test-references/org/apache/batik/ext/awt/geom .cvsignore
  Log:
  1) Wrapped up a few loose ends on <multiImage> extension (renamed tag to
     be consistent with rest of svg).
  
  Revision  Changes    Path
  1.2       +26 -18    xml-batik/samples/extensions/multi.svg
  
  Index: multi.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/extensions/multi.svg,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- multi.svg	19 Feb 2002 22:08:43 -0000	1.1
  +++ multi.svg	20 Feb 2002 13:27:10 -0000	1.2
  @@ -14,7 +14,7 @@
   <!-- regularPoly extension tag test                                         -->
   <!--                                                                        -->
   <!-- @author Thomas.DeWeese@Kodak.com                                       -->
  -<!-- @version $Id: multi.svg,v 1.1 2002/02/19 22:08:43 deweese Exp $ -->
  +<!-- @version $Id: multi.svg,v 1.2 2002/02/20 13:27:10 deweese Exp $ -->
   <!-- ====================================================================== -->
   
   <!-- <?xml-stylesheet type="text/css" href="extension.css" ?> -->
  @@ -23,31 +23,39 @@
        viewBox="0 0 450 500"
        xmlns:batikExt="http://xml.apache.org/batik/ext">
   
  -    <title>Multi-Image Extension Tag</title>
  -  
  +    <title>MultiImage Extension Tag</title>
  +    <defs>
  +       <g id="sample">
  +          <rect fill="#ADA" x="0" y="0" width="280" height="400"/>
  +          <batikExt:multiImage id="img" xlink:href="multi1.jpg"
  +                 x="20" y="20" width="240" height="360" 
  +                 pixel-width="480" pixel-height="720">
  +             <batikExt:subImage xlink:href="multi2.jpg" 
  +                        pixel-width="240" pixel-height="360"/>
  +             <batikExt:subImage xlink:href="multi3.jpg" 
  +                        pixel-width="120" pixel-height="180"/>
  +             <batikExt:subImage xlink:href="multi4.jpg" 
  +                        pixel-width="60" pixel-height="90"/>
  +          </batikExt:multiImage>
  +       </g>
  +    </defs>  
  +
       <!-- ============================================================= -->
       <!-- Test content                                                  -->
       <!-- ============================================================= -->
       <g id="testContent" class="legend" style="text-anchor:middle">
  -        <text x="225" y="40" class="title">Multi-Image Extension Tag</text>
  +        <text x="225" y="40" class="title">MultiImage Extension Tag</text>
     
  -        <g transform="translate(145, 145)">
  -          <rect fill="#DAA" x="0" y="0" width="160" height="220"/>
  -          <batikExt:multi-image id="img" xlink:href="multi1.jpg"
  -                 x="20" y="20" width="120" height="180" 
  -		 pixel-width="480" pixel-height="720">
  -	     <batikExt:sub-image xlink:href="multi2.jpg" 
  -	                pixel-width="240" pixel-height="360"/>
  -	     <batikExt:sub-image xlink:href="multi3.jpg" 
  -	                pixel-width="120" pixel-height="180"/>
  -	     <batikExt:sub-image xlink:href="multi4.jpg" 
  -	                pixel-width="60" pixel-height="90"/>
  -	  </batikExt:multi-image>
  -        </g>
  +        <use transform="translate(10, 50)" xlink:href="#sample"/>
  +
  +        <use transform="translate(300, 50) scale(.5)" xlink:href="#sample"/>
  +
  +        <use transform="translate(300, 260) scale(.25)" xlink:href="#sample"/>
  +
       </g>
   
       <!-- ============================================================= -->
       <!-- Batik sample mark                                             -->
       <!-- ============================================================= -->
  -    <!-- <use xlink:href="../batikLogo.svg#Batik_Tag_Box" /> -->
  +    <use xlink:href="../batikLogo.svg#Batik_Tag_Box" />
   </svg>
  
  
  
  1.7       +20 -0     xml-batik/sources/org/apache/batik/extension/svg/BatikDomExtension.java
  
  Index: BatikDomExtension.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/extension/svg/BatikDomExtension.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BatikDomExtension.java	23 Oct 2001 13:42:29 -0000	1.6
  +++ BatikDomExtension.java	20 Feb 2002 13:27:10 -0000	1.7
  @@ -93,6 +93,11 @@
   
           di.registerCustomElementFactory
               (BATIK_EXT_NAMESPACE_URI,
  +             BATIK_EXT_MULTI_IMAGE_TAG,
  +             new BatikMultiImageElementFactory());
  +
  +        di.registerCustomElementFactory
  +            (BATIK_EXT_NAMESPACE_URI,
                BATIK_EXT_SOLID_COLOR_TAG,
                new SolidColorElementFactory());
   
  @@ -150,6 +155,21 @@
            */
           public Element create(String prefix, Document doc) {
               return new BatikHistogramNormalizationElement
  +                (prefix, (AbstractDocument)doc);
  +        }
  +    }
  +
  +    /**
  +     * To create a 'multiImage' element.
  +     */
  +    protected static class BatikMultiImageElementFactory 
  +        implements SVGDOMImplementation.ElementFactory {
  +        public BatikMultiImageElementFactory() {}
  +        /**
  +         * Creates an instance of the associated element type.
  +         */
  +        public Element create(String prefix, Document doc) {
  +            return new BatikMultiImageElement
                   (prefix, (AbstractDocument)doc);
           }
       }
  
  
  
  1.7       +4 -4      xml-batik/sources/org/apache/batik/extension/svg/BatikExtConstants.java
  
  Index: BatikExtConstants.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/extension/svg/BatikExtConstants.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BatikExtConstants.java	19 Feb 2002 22:08:43 -0000	1.6
  +++ BatikExtConstants.java	20 Feb 2002 13:27:10 -0000	1.7
  @@ -35,13 +35,13 @@
       public static final String BATIK_EXT_HISTOGRAM_NORMALIZATION_TAG =
           "histogramNormalization";
   
  -    /** Tag name for Batik's multi-image extension. */
  +    /** Tag name for Batik's multiImage extension. */
       public static final String BATIK_EXT_MULTI_IMAGE_TAG =
  -        "multi-image";
  +        "multiImage";
   
  -    /** Tag name for Batik's multi-image extension. */
  +    /** Tag name for Batik's subImage multiImage extension. */
       public static final String BATIK_EXT_SUB_IMAGE_TAG =
  -        "sub-image";
  +        "subImage";
   
       /** Attribute name for sides attribute */
       public static final String BATIK_EXT_SIDES_ATTRIBUTE = 
  
  
  
  1.2       +30 -16    xml-batik/sources/org/apache/batik/extension/svg/BatikMultiImageElementBridge.java
  
  Index: BatikMultiImageElementBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/extension/svg/BatikMultiImageElementBridge.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BatikMultiImageElementBridge.java	19 Feb 2002 22:08:43 -0000	1.1
  +++ BatikMultiImageElementBridge.java	20 Feb 2002 13:27:10 -0000	1.2
  @@ -42,10 +42,26 @@
   import org.apache.batik.util.ParsedURL;
   
   /**
  - * Bridge class for the &lt;image> element.
  + * Bridge class for the &lt;multiImage> element.
    *
  - * @author <a href="mailto:tkormann@apache.org">Thierry Kormann</a>
  - * @version $Id: BatikMultiImageElementBridge.java,v 1.1 2002/02/19 22:08:43 deweese Exp
$
  + * The 'multiImage' element is similar to the 'image' element (supports
  + * all the same attributes and properties) except.
  + * <ol>
  + *    <li>It can only be used to reference raster content (this is an
  + *        implementation thing really)</li>
  + *    <li>It has two addtional attributes: 'pixel-width' and
  + *        'pixel-height' which are the maximum width and height of the
  + *        image referenced by the xlink:href attribute.</li>
  + *    <li>It can contain a child element 'subImage' which has only
  + *        three attributes, pixel-width, pixel-height and xlink:href.
  + *        The image displayed is the smallest image such that
  + *        pixel-width and pixel-height are greater than or equal to the
  + *        required image size for display.</li>
  + * </ol>
  + *
  + *
  + * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
  + * @version $Id: BatikMultiImageElementBridge.java,v 1.2 2002/02/20 13:27:10 deweese Exp
$
    */
   public class BatikMultiImageElementBridge extends SVGImageElementBridge
       implements BatikExtConstants {
  @@ -60,7 +76,7 @@
       }
   
       /**
  -     * Returns 'multi-image'.
  +     * Returns 'multiImage'.
        */
       public String getLocalName() {
           return BATIK_EXT_MULTI_IMAGE_TAG;
  @@ -174,31 +190,29 @@
           int w=0, h=0;
           String s;
   
  -        s = e.getAttributeNS
  -            (null,BATIK_EXT_PIXEL_WIDTH_ATTRIBUTE);
  -        if (s.length() == 0) 
  -            throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
  -                                      new Object[] {"pixel-width"});
  +        s = e.getAttributeNS(null,BATIK_EXT_PIXEL_WIDTH_ATTRIBUTE);
  +        if (s.length() == 0) throw new BridgeException
  +            (e, ERR_ATTRIBUTE_MISSING,
  +             new Object[] {BATIK_EXT_PIXEL_WIDTH_ATTRIBUTE});
   
           try {
               w = (int)SVGUtilities.convertSVGNumber(s);
           } catch (NumberFormatException ex) {
               throw new BridgeException
                   (e, ERR_ATTRIBUTE_VALUE_MALFORMED,
  -                 new Object[] {BATIK_EXT_TRIM_ATTRIBUTE, s});
  +                 new Object[] {BATIK_EXT_PIXEL_WIDTH_ATTRIBUTE, s});
           }
   
  -        s = e.getAttributeNS
  -            (null,BATIK_EXT_PIXEL_HEIGHT_ATTRIBUTE);
  -        if (s.length() == 0) 
  -            throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
  -                                      new Object[] {"pixel-height"});
  +        s = e.getAttributeNS(null,BATIK_EXT_PIXEL_HEIGHT_ATTRIBUTE);
  +        if (s.length() == 0) throw new BridgeException
  +            (e, ERR_ATTRIBUTE_MISSING,
  +             new Object[] {BATIK_EXT_PIXEL_HEIGHT_ATTRIBUTE});
           try {
               h = (int)SVGUtilities.convertSVGNumber(s);
           } catch (NumberFormatException ex) {
               throw new BridgeException
                   (e, ERR_ATTRIBUTE_VALUE_MALFORMED,
  -                 new Object[] {BATIK_EXT_TRIM_ATTRIBUTE, s});
  +                 new Object[] {BATIK_EXT_PIXEL_HEIGHT_ATTRIBUTE, s});
           }
   
           return new Dimension(w, h);
  
  
  
  1.1                  xml-batik/sources/org/apache/batik/extension/svg/BatikMultiImageElement.java
  
  Index: BatikMultiImageElement.java
  ===================================================================
  /*****************************************************************************
   * Copyright (C) The Apache Software Foundation. All rights reserved.        *
   * ------------------------------------------------------------------------- *
   * This software is published under the terms of the Apache Software License *
   * version 1.1, a copy of which has been included with this distribution in  *
   * the LICENSE file.                                                         *
   *****************************************************************************/
  
  package org.apache.batik.extension.svg;
  
  import org.w3c.dom.Node;
  
  import org.apache.batik.dom.AbstractDocument;
  import org.apache.batik.extension.PrefixableStylableExtensionElement;
  
  /**
   *  This class implements a multiImage extension to SVG.
   *
   * The 'multiImage' element is similar to the 'image' element (supports
   * all the same attributes and properties) except.
   * <ol>
   *    <li>It can only be used to reference raster content (this is an
   *        implementation thing really)</li>
   *    <li>It has two addtional attributes: 'pixel-width' and
   *        'pixel-height' which are the maximum width and height of the
   *        image referenced by the xlink:href attribute.</li>
   *    <li>It can contain a child element 'subImage' which has only
   *        three attributes, pixel-width, pixel-height and xlink:href.
   *        The image displayed is the smallest image such that
   *        pixel-width and pixel-height are greater than or equal to the
   *        required image size for display.</li>
   * </ol>
   *
   * @author <a href="mailto:thomas.deweese@kodak.com">Thomas DeWeese</a>
   * @version $Id: BatikMultiImageElement.java,v 1.1 2002/02/20 13:27:10 deweese Exp $ */
  public class BatikMultiImageElement
      extends    PrefixableStylableExtensionElement 
      implements BatikExtConstants {
  
      /**
       * Creates a new BatikMultiImageElement object.
       */
      protected BatikMultiImageElement() {
      }
  
      /**
       * Creates a new BatikMultiImageElement object.
       * @param prefix The namespace prefix.
       * @param owner The owner document.
       */
      public BatikMultiImageElement(String prefix, AbstractDocument owner) {
          super(prefix, owner);
      }
  
      /**
       * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getLocalName()}.
       */
      public String getLocalName() {
          return BATIK_EXT_MULTI_IMAGE_TAG;
      }
  
      /**
       * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNamespaceURI()}.
       */
      public String getNamespaceURI() {
          return BATIK_EXT_NAMESPACE_URI;
      }
  
      /**
       * Returns a new uninitialized instance of this object's class.
       */
      protected Node newNode() {
          return new BatikMultiImageElement();
      }
  }
  
  
  
  1.2       +16 -4     xml-batik/sources/org/apache/batik/extension/svg/renderable/MultiResRable.java
  
  Index: MultiResRable.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/extension/svg/renderable/MultiResRable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MultiResRable.java	19 Feb 2002 22:08:44 -0000	1.1
  +++ MultiResRable.java	20 Feb 2002 13:27:10 -0000	1.2
  @@ -11,6 +11,7 @@
   import java.awt.Dimension;
   import java.awt.Rectangle;
   import java.awt.RenderingHints;
  +import java.awt.Shape;
   import java.awt.geom.AffineTransform;
   import java.awt.geom.Rectangle2D;
   import java.awt.image.RenderedImage;
  @@ -28,7 +29,7 @@
    * RenderableImage world.
    *
    * @author <a href="mailto:Thomas.DeWeese@Kodak.com>Thomas DeWeese</a>
  - * @version $Id: MultiResRable.java,v 1.1 2002/02/19 22:08:44 deweese Exp $
  + * @version $Id: MultiResRable.java,v 1.2 2002/02/20 13:27:10 deweese Exp $
    */
   public class MultiResRable
       extends    AbstractRable {
  @@ -72,6 +73,10 @@
               srcs[idx] = new SoftReference(f);
           }
   
  +        // Just copy over the rendering hints.
  +        RenderingHints rh = rc.getRenderingHints();
  +        if (rh == null) rh = new RenderingHints(null);
  +
           double sx = bounds.getWidth() /(double)f.getWidth();
           double sy = bounds.getHeight()/(double)f.getHeight();
           
  @@ -79,8 +84,15 @@
           AffineTransform at = rc.getTransform();
           at.scale(sx, sy);
   
  -        rc.setTransform(at);
  -        return f.createRendering(rc);
  +        // Map the area of interest to our input...
  +        Shape aoi = rc.getAreaOfInterest();
  +        if (aoi != null) {
  +            AffineTransform invAt = AffineTransform.getScaleInstance
  +                (1/sx, 1/sy);
  +            aoi = invAt.createTransformedShape(aoi);
  +        }
  +
  +        return f.createRendering(new RenderContext(at, aoi, rh));
       }
   
       public RenderedImage createRendering(RenderContext rc) {
  @@ -93,7 +105,7 @@
           
           double w = bounds.getWidth()*det;
           for (int i=1; i<sizes.length; i++) {
  -            if (w >= sizes[i].width) 
  +            if (w > sizes[i].width) 
                   return getImage(i-1, rc);
           }
   
  
  
  
  1.1                  xml-batik/test-references/org/apache/batik/ext/awt/geom/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  candidate
  variation
  
  
  

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


Mime
View raw message