tkormann    01/09/18 02:23:39

  Modified:    sources/org/apache/batik/bridge SVGCircleElementBridge.java
                        SVGEllipseElementBridge.java
                        SVGRectElementBridge.java
                        SVGShapeElementBridge.java
               test-resources/org/apache/batik/test samplesRendering.xml
  Added:       samples/tests zero.svg
  Log:
  - width, height with a zero value on rect now disable the rendering
  - r with a zero value on circle now disable the rendering
  - rx, ry with a zero value on ellipse now disable the rendering
  
  - add a new test
  
  Revision  Changes    Path
  1.1                  xml-batik/samples/tests/zero.svg
  
  Index: zero.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
  "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd";>
  
  <!-- ========================================================================= -->
  <!-- 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.                                                         -->
  <!-- ========================================================================= -->
  
  <!-- ========================================================================= -->
  <!--  Test 'visibility' property inheritance                                   -->
  <!--                                                                           -->
  <!-- @author [EMAIL PROTECTED]                                               -->
  <!-- @version $Id: zero.svg,v 1.1 2001/09/18 09:23:39 tkormann Exp $ -->
  <!-- ========================================================================= -->
  
  <?xml-stylesheet type="text/css" href="test.css" ?>
  
  <svg  id="body" width="450" height="500" viewBox="0 0 450 500">
  <title>Test zero length on various shapes</title>
      <!-- ============================================================= -->
      <!-- Test content                                                  -->
      <!-- ============================================================= -->
  <g id="testContent">
    <text x="225" y="30" class="title">Test zero length on various shapes</text>
    <text x="225" y="50" class="title">Value of zero disables rendering of the 
elements</text>
  
  <!-- dashboard -->
  <g style="stroke:black; fill:none">
        <rect x="40" y="80" width="360" height="120" />
        <rect x="40" y="200" width="360" height="120" />
        <rect x="40" y="320" width="360" height="120" />
  </g>
  <g style="fill:rgb(240, 240, 240); stroke:black;">
        <rect x="40" y="80" width="20" height="120" />
        <rect x="40" y="200" width="20" height="120" />
        <rect x="40" y="320" width="20" height="120" />
        <g style="stroke:none; fill:black; font-size:12pt; font-family: Arial">
                <text transform="translate(55, 170) rotate(-90)">&lt;rect></text>
                <text transform="translate(55, 290) rotate(-90)">&lt;circle></text>
                <text transform="translate(55, 410) rotate(-90)">&lt;ellipse></text>
        </g>
  </g>
  
  <!-- ########### rect ############# -->
  <g style="stroke:none; fill:crimson">
        <rect x="90" y="95" width="0" height="80" />
        <rect x="190" y="95" width="80" height="0" />
        <rect x="290" y="95" width="0" height="0" />
  </g>
  <g style="stroke:none; fill:black; font-size:12; font-family: Arial; 
text-anchor:middle">
        <text x="130" y="194">width="0"</text>
        <text x="230" y="194">height="0"</text>
        <text x="330" y="194">width &amp; height="0"</text>
  </g>
  
  <!-- ########### circle ############# -->
  <g style="stroke:none; fill:crimson">
        <circle cx="225" cy="255" r="0"/>
  </g>
  <g style="stroke:none; fill:black; font-size:12; font-family: Arial; 
text-anchor:middle">
        <text x="225" y="314">r="0"</text>
  </g>
  
  <!-- ########### ellipse ############# -->
  <g style="stroke:none; fill:crimson">
        <ellipse cx="130" cy="365" rx="0" ry="30" />
        <ellipse cx="230" cy="365" rx="40" ry="0" />
        <ellipse cx="330" cy="365" rx="0" ry="0" />
  </g>
  <g style="stroke:none; fill:black; font-size:12; font-family: Arial; 
text-anchor:middle">
        <text x="130" y="415">rx="0"</text>
        <text x="230" y="415">ry="0"</text>
        <text x="330" y="415">rx &amp; ry="0"</text>
  </g>
  
  
  
  </g>
  
  </svg>
  
  
  
  1.4       +5 -2      
xml-batik/sources/org/apache/batik/bridge/SVGCircleElementBridge.java
  
  Index: SVGCircleElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGCircleElementBridge.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SVGCircleElementBridge.java       2001/05/02 14:33:38     1.3
  +++ SVGCircleElementBridge.java       2001/09/18 09:23:39     1.4
  @@ -20,7 +20,7 @@
    * Bridge class for the &lt;circle> element.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Thierry Kormann</a>
  - * @version $Id: SVGCircleElementBridge.java,v 1.3 2001/05/02 14:33:38 tkormann Exp 
$
  + * @version $Id: SVGCircleElementBridge.java,v 1.4 2001/09/18 09:23:39 tkormann Exp 
$
    */
   public class SVGCircleElementBridge extends SVGShapeElementBridge {
   
  @@ -76,7 +76,10 @@
               throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
                                         new Object[] {SVG_R_ATTRIBUTE, s});
           }
  -
  +     // A value of zero disables rendering of the element
  +     if (r == 0) {
  +         return;
  +     }
           float x = cx - r;
           float y = cy - r;
           float w = r * 2;
  
  
  
  1.4       +9 -1      
xml-batik/sources/org/apache/batik/bridge/SVGEllipseElementBridge.java
  
  Index: SVGEllipseElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGEllipseElementBridge.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SVGEllipseElementBridge.java      2001/05/02 14:33:40     1.3
  +++ SVGEllipseElementBridge.java      2001/09/18 09:23:39     1.4
  @@ -20,7 +20,7 @@
    * Bridge class for the &lt;ellipse> element.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Thierry Kormann</a>
  - * @version $Id: SVGEllipseElementBridge.java,v 1.3 2001/05/02 14:33:40 tkormann 
Exp $
  + * @version $Id: SVGEllipseElementBridge.java,v 1.4 2001/09/18 09:23:39 tkormann 
Exp $
    */
   public class SVGEllipseElementBridge extends SVGShapeElementBridge {
   
  @@ -76,6 +76,10 @@
               throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
                                         new Object[] {SVG_RX_ATTRIBUTE, s});
           }
  +     // A value of zero disables rendering of the element
  +     if (rx == 0) {
  +         return;
  +     }
   
           // 'ry' attribute - required
           s = e.getAttributeNS(null, SVG_RY_ATTRIBUTE);
  @@ -87,6 +91,10 @@
               throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
                                         new Object[] {SVG_RY_ATTRIBUTE, s});
           }
  +     // A value of zero disables rendering of the element
  +     if (ry == 0) {
  +         return;
  +     }
   
           shapeNode.setShape(new Ellipse2D.Float(cx-rx, cy-ry, rx*2, ry*2));
       }
  
  
  
  1.4       +9 -1      
xml-batik/sources/org/apache/batik/bridge/SVGRectElementBridge.java
  
  Index: SVGRectElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGRectElementBridge.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SVGRectElementBridge.java 2001/05/02 14:34:14     1.3
  +++ SVGRectElementBridge.java 2001/09/18 09:23:39     1.4
  @@ -21,7 +21,7 @@
    * Bridge class for the &lt;rect> element.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Thierry Kormann</a>
  - * @version $Id: SVGRectElementBridge.java,v 1.3 2001/05/02 14:34:14 tkormann Exp $
  + * @version $Id: SVGRectElementBridge.java,v 1.4 2001/09/18 09:23:39 tkormann Exp $
    */
   public class SVGRectElementBridge extends SVGShapeElementBridge {
   
  @@ -77,6 +77,10 @@
               throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
                                         new Object[] {SVG_WIDTH_ATTRIBUTE, s});
           }
  +     // A value of zero disables rendering of the element
  +     if (w == 0) {
  +         return;
  +     }
   
           // 'height' attribute - required
           s = e.getAttributeNS(null, SVG_HEIGHT_ATTRIBUTE);
  @@ -88,6 +92,10 @@
               throw new BridgeException(e, ERR_ATTRIBUTE_MISSING,
                                         new Object[] {SVG_HEIGHT_ATTRIBUTE, s});
           }
  +     // A value of zero disables rendering of the element
  +     if (h == 0) {
  +         return;
  +     }
   
           // 'rx' attribute - default is 0
           s = e.getAttributeNS(null, SVG_RX_ATTRIBUTE);
  
  
  
  1.11      +4 -1      
xml-batik/sources/org/apache/batik/bridge/SVGShapeElementBridge.java
  
  Index: SVGShapeElementBridge.java
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/sources/org/apache/batik/bridge/SVGShapeElementBridge.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SVGShapeElementBridge.java        2001/03/30 11:46:06     1.10
  +++ SVGShapeElementBridge.java        2001/09/18 09:23:39     1.11
  @@ -21,7 +21,7 @@
    * The base bridge class for shapes. Subclasses bridge <tt>ShapeNode</tt>.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Thierry Kormann</a>
  - * @version $Id: SVGShapeElementBridge.java,v 1.10 2001/03/30 11:46:06 tkormann Exp 
$
  + * @version $Id: SVGShapeElementBridge.java,v 1.11 2001/09/18 09:23:39 tkormann Exp 
$
    */
   public abstract class SVGShapeElementBridge extends AbstractGraphicsNodeBridge {
   
  @@ -42,6 +42,9 @@
           ShapeNode shapeNode = (ShapeNode)super.createGraphicsNode(ctx, e);
           // delegates to subclasses the shape construction
           buildShape(ctx, e, shapeNode);
  +     if (shapeNode.getShape() == null) {
  +         return null; // Disable the rendering if something bad happens
  +     }
           // 'shape-rendering' and 'color-rendering'
           Map shapeHints = CSSUtilities.convertShapeRendering(e);
           Map colorHints = CSSUtilities.convertColorRendering(e);
  
  
  
  1.22      +8 -1      
xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml
  
  Index: samplesRendering.xml
  ===================================================================
  RCS file: 
/home/cvs/xml-batik/test-resources/org/apache/batik/test/samplesRendering.xml,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- samplesRendering.xml      2001/09/13 08:40:48     1.21
  +++ samplesRendering.xml      2001/09/18 09:23:39     1.22
  @@ -8,7 +8,7 @@
   
   <!-- ========================================================================= -->
   <!-- @author [EMAIL PROTECTED]                                         -->
  -<!-- @version $Id: samplesRendering.xml,v 1.21 2001/09/13 08:40:48 vhardy Exp $ -->
  +<!-- @version $Id: samplesRendering.xml,v 1.22 2001/09/18 09:23:39 tkormann Exp $ 
-->
   <!-- ========================================================================= -->
   <testSuite name="samples and samples/test Rendering">
       <!-- ========================================================================== 
-->
  @@ -767,6 +767,13 @@
           <arg class="java.net.URL" 
value="file:test-references/samples/tests/textEffect3.png" />
           <property name="VariationURL" class="java.net.URL" 
value="file:test-references/samples/tests/accepted-variation/textEffect3.png" />
           <property name="SaveVariation" class="java.io.File" 
value="test-references/samples/tests/candidate-variation/textEffect3.png" />
  +    </test>
  +
  +    <test class="org.apache.batik.test.svg.SVGRenderingAccuracyTest">
  +        <arg class="java.net.URL" value="file:samples/tests/zero.svg" />
  +        <arg class="java.net.URL" 
value="file:test-references/samples/tests/zero.png" />
  +        <property name="VariationURL" class="java.net.URL" 
value="file:test-references/samples/tests/accepted-variation/zero.png" />
  +        <property name="SaveVariation" class="java.io.File" 
value="test-references/samples/tests/candidate-variation/zero.png" />
       </test>
   
   </testSuite>
  
  
  

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

Reply via email to