You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by vh...@apache.org on 2001/09/19 15:21:55 UTC

cvs commit: xml-batik/test-resources/org/apache/batik/svggen regsvggen.xml

vhardy      01/09/19 06:21:55

  Modified:    sources/org/apache/batik/svggen SVGGraphics2D.java
               sources/org/apache/batik/util XMLConstants.java
               test-resources/org/apache/batik/svggen regsvggen.xml
  Added:       test-sources/org/apache/batik/svggen TextSpacePreserve.java
  Log:
  Fixed bug #2657 (white space handling in SVGGraphics2D). Added
  test case showing that the bug is fixed: TextSpacePreserve in
  regsvggen.
  
  Revision  Changes    Path
  1.23      +6 -2      xml-batik/sources/org/apache/batik/svggen/SVGGraphics2D.java
  
  Index: SVGGraphics2D.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/svggen/SVGGraphics2D.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- SVGGraphics2D.java	2001/09/18 10:47:57	1.22
  +++ SVGGraphics2D.java	2001/09/19 13:21:55	1.23
  @@ -20,6 +20,7 @@
   
   import org.w3c.dom.*;
   
  +import org.apache.batik.util.XMLConstants;
   import org.apache.batik.ext.awt.g2d.AbstractGraphics2D;
   import org.apache.batik.ext.awt.g2d.GraphicContext;
   
  @@ -44,7 +45,7 @@
    *
    *
    * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  - * @version $Id: SVGGraphics2D.java,v 1.22 2001/09/18 10:47:57 vhardy Exp $
  + * @version $Id: SVGGraphics2D.java,v 1.23 2001/09/19 13:21:55 vhardy Exp $
    * @see                org.apache.batik.ext.awt.g2d.GraphicContext
    * @see                org.apache.batik.svggen.DOMTreeManager
    * @see                org.apache.batik.svggen.DOMGroupManager
  @@ -53,7 +54,7 @@
    * @see                org.w3c.dom.Document
    */
   public class SVGGraphics2D extends AbstractGraphics2D
  -    implements Cloneable, SVGSyntax, ErrorConstants {
  +    implements Cloneable, SVGSyntax, XMLConstants, ErrorConstants {
       /*
        * Constants definitions
        */
  @@ -977,6 +978,9 @@
                                   AbstractSVGConverter.doubleString(x));
               text.setAttributeNS(null, SVG_Y_ATTRIBUTE,
                                   AbstractSVGConverter.doubleString(y));
  +            text.setAttributeNS(XML_NAMESPACE_URI,
  +                                XML_SPACE_ATTRIBUTE,
  +                                XML_PRESERVE_VALUE);
               text.appendChild(getDOMFactory().createTextNode(s));
               domGroupManager.addElement(text, DOMGroupManager.FILL);
           } else {
  
  
  
  1.2       +20 -1     xml-batik/sources/org/apache/batik/util/XMLConstants.java
  
  Index: XMLConstants.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/XMLConstants.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLConstants.java	2001/04/27 03:41:13	1.1
  +++ XMLConstants.java	2001/09/19 13:21:55	1.2
  @@ -12,9 +12,28 @@
    * Contains common XML constants.
    *
    * @author <a href="mailto:vhardy@eng.sun.com">Vincent Hardy</a>
  - * @version $Id: XMLConstants.java,v 1.1 2001/04/27 03:41:13 vhardy Exp $
  + * @version $Id: XMLConstants.java,v 1.2 2001/09/19 13:21:55 vhardy Exp $
    */
   public interface XMLConstants {
  +    /**
  +     * The XML namespace URI.
  +     */
  +    String XML_NAMESPACE_URI =
  +	"http://www.w3.org/XML/1998/namespace";
  +
  +    /**
  +     * The xmlns namespace URI.
  +     */
  +    String XMLNS_NAMESPACE_URI =
  +	"http://www.w3.org/2000/xmlns/";
  +
  +    String XML_PREFIX = "xml";
  +    String XML_LANG_ATTRIBUTE  = XML_PREFIX + ":lang";
  +    String XML_SPACE_ATTRIBUTE = XML_PREFIX + ":space";
  +
  +    String XML_DEFAULT_VALUE = "default";
  +    String XML_PRESERVE_VALUE = "preserve";
  +    
       String XML_TAB = "    ";
       String XML_OPEN_TAG_END_CHILDREN = " >";
       String XML_OPEN_TAG_END_NO_CHILDREN = " />";
  
  
  
  1.1                  xml-batik/test-sources/org/apache/batik/svggen/TextSpacePreserve.java
  
  Index: TextSpacePreserve.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.svggen;
  
  import java.awt.*;
  import java.awt.geom.*;
  
  /**
   * This test validates that spaces are preserved correctly in drawString
   * calls. Validates bug #2657 fix.
   *
   * @author <a href="mailto:vincent.hardy@sun.com">Vincent Hardy</a>
   * @version $Id: TextSpacePreserve.java,v 1.1 2001/09/19 13:21:55 vhardy Exp $
   */
  public class TextSpacePreserve implements Painter {
      public void paint(Graphics2D g) {
          g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                             RenderingHints.VALUE_ANTIALIAS_ON);
  
          g.setPaint(Color.black); // new Color(102, 102, 144));
  
          int legendX = 10, legendY = 12;
          g.translate(0, 30);
  
  
          // Print text with spaces.
          g.drawString("     space before.", legendX, legendY);
          g.drawString("Multiple spaces between A and B: A    B", legendX, legendY + 20);
          g.drawString("This is a first line\n     and this is a second line starting with spaces", 
                       legendX, legendY + 40);
  
      }
  }
  
  
  
  1.6       +18 -3     xml-batik/test-resources/org/apache/batik/svggen/regsvggen.xml
  
  Index: regsvggen.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/svggen/regsvggen.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- regsvggen.xml	2001/09/18 10:55:54	1.5
  +++ regsvggen.xml	2001/09/19 13:21:55	1.6
  @@ -8,7 +8,7 @@
   
   <!-- ========================================================================= -->
   <!-- @author vincent.hardy@eng.sun.com                                         -->
  -<!-- @version $Id: regsvggen.xml,v 1.5 2001/09/18 10:55:54 vhardy Exp $ -->
  +<!-- @version $Id: regsvggen.xml,v 1.6 2001/09/19 13:21:55 vhardy Exp $ -->
   <!-- ========================================================================= -->
   <testSuite name="SVGGraphics2D Accuracy Testing">
       <test class="org.apache.batik.svggen.SVGAccuracyTest">
  @@ -116,12 +116,19 @@
   	<arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ShearTest.svg"/>
           <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ShearTest.svg" />
       </test>
  +
       <test class="org.apache.batik.svggen.SVGAccuracyTest">
           <arg class="org.apache.batik.svggen.Texture" />
  -	<arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Texture.svg"/>
  +	    <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/Texture.svg"/>
           <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/Texture.svg" />
       </test>
   
  +    <test class="org.apache.batik.svggen.SVGAccuracyTest">
  +        <arg class="org.apache.batik.svggen.TextSpacePreserve" />
  +	    <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/TextSpacePreserve.svg"/>
  +        <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/TextSpacePreserve.svg" />
  +    </test>
  +
       
       <!-- The same test set but with a customized SVGGeneratorContext -->
   
  @@ -229,9 +236,17 @@
   	<arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextShearTest.svg"/>
           <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextShearTest.svg" />
       </test>
  +
       <test class="org.apache.batik.svggen.GeneratorContext">
           <arg class="org.apache.batik.svggen.Texture" />
  -	<arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextTexture.svg"/>
  +	    <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextTexture.svg"/>
           <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextTexture.svg" />
       </test>
  +
  +    <test class="org.apache.batik.svggen.GeneratorContext">
  +        <arg class="org.apache.batik.svggen.TextSpacePreserve" />
  +	    <arg class="java.net.URL" value="file:test-references/org/apache/batik/svggen/ContextTextSpacePreserve.svg"/>
  +        <property name="SaveSVG" class="java.io.File" value="test-references/org/apache/batik/svggen/candidate-ref/ContextTextSpacePreserve.svg" />
  +    </test>
  +
   </testSuite>
  
  
  

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