xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vha...@apache.org
Subject cvs commit: xml-batik/test-references/org/apache/batik/svggen ContextNegativeLengths.svg NegativeLengths.svg
Date Mon, 10 Jun 2002 12:10:19 GMT
vhardy      2002/06/10 05:10:19

  Modified:    test-sources/org/apache/batik/svggen NegativeLengths.java
               sources/org/apache/batik/svggen SVGClip.java SVGPath.java
               test-references/org/apache/batik/svggen
                        ContextNegativeLengths.svg NegativeLengths.svg
  Log:
  Fixed problem when using rectangle with negative width/height on clip. Added comments to
SVGPath
  
  Revision  Changes    Path
  1.3       +3 -3      xml-batik/test-sources/org/apache/batik/svggen/NegativeLengths.java
  
  Index: NegativeLengths.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/svggen/NegativeLengths.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NegativeLengths.java	7 Jun 2002 17:06:52 -0000	1.2
  +++ NegativeLengths.java	10 Jun 2002 12:10:19 -0000	1.3
  @@ -21,7 +21,7 @@
    * The above behavior is that of the default Graphics2D implementations.
    *
    * @author <a href="mailto:vhardy@sun.com">Vincent Hardy</a>
  - * @version $Id: NegativeLengths.java,v 1.2 2002/06/07 17:06:52 vhardy Exp $
  + * @version $Id: NegativeLengths.java,v 1.3 2002/06/10 12:10:19 vhardy Exp $
    */
   public class NegativeLengths implements Painter {
       public void paint(Graphics2D g){
  @@ -256,12 +256,12 @@
           g.translate(0, 40);
   
           // Clip
  -        rect = new Rectangle(0, 30, 10, -30);
  +        rect = new Rectangle(10, 30, 10, -30);
           g.setPaint(Color.gray);
           g.fill(rect);
           g.setPaint(Color.black);
           g.clip(rect);
  -        g.drawString("Hello There", 0, 25);
  +        g.drawString("Hello There", 10, 25);
       }
   }
   
  
  
  
  1.10      +14 -3     xml-batik/sources/org/apache/batik/svggen/SVGClip.java
  
  Index: SVGClip.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/svggen/SVGClip.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SVGClip.java	3 Jul 2001 09:51:36 -0000	1.9
  +++ SVGClip.java	10 Jun 2002 12:10:19 -0000	1.10
  @@ -20,10 +20,15 @@
    * Utility class that converts a Path object into an SVG clip
    *
    * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  - * @version $Id: SVGClip.java,v 1.9 2001/07/03 09:51:36 cjolif Exp $
  + * @version $Id: SVGClip.java,v 1.10 2002/06/10 12:10:19 vhardy Exp $
    */
   public class SVGClip extends AbstractSVGConverter {
       /**
  +     * Constant used for some degenerate cases
  +     */
  +    public static final Shape ORIGIN = new Line2D.Float(0,0,0,0);
  +
  +    /**
        * Descriptor to use where there is no clip on an element
        */
       public static final SVGClipDescriptor NO_CLIP =
  @@ -121,8 +126,14 @@
           if (clipPath != null) {
               clipDef.appendChild(clipPath);
               return clipDef;
  -        } else
  -            return null; // what means the shape return null ?
  +        } else {
  +            // Here, we know clip is not null but we got a
  +            // null clipDef. This means we ran into a degenerate 
  +            // case which in Java 2D means everything is clippped.
  +            // To provide an equivalent behavior, we clip to a point
  +            clipDef.appendChild(shapeConverter.toSVG(ORIGIN));
  +            return clipDef;
  +        }
       }
   }
   
  
  
  
  1.11      +11 -2     xml-batik/sources/org/apache/batik/svggen/SVGPath.java
  
  Index: SVGPath.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/svggen/SVGPath.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SVGPath.java	12 Mar 2002 17:34:04 -0000	1.10
  +++ SVGPath.java	10 Jun 2002 12:10:19 -0000	1.11
  @@ -32,7 +32,7 @@
    *
    * @author <a href="mailto:cjolif@ilog.fr">Christophe Jolif</a>
    * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
  - * @version $Id: SVGPath.java,v 1.10 2002/03/12 17:34:04 cjolif Exp $
  + * @version $Id: SVGPath.java,v 1.11 2002/06/10 12:10:19 vhardy Exp $
    */
   public class SVGPath extends SVGGraphicObjectConverter {
       /**
  @@ -111,8 +111,17 @@
   
           if (d.length() > 0)
               return d.toString().trim();
  -        else
  +        else {
  +            // This is a degenerate case: there was no initial moveTo
  +            // in the path and no data at all. However, this happens 
  +            // in the Java 2D API (e.g., when clipping to a rectangle
  +            // with negative height/width, the clip will be a GeneralPath
  +            // with no data, which causes everything to be clipped)
  +            // It is the responsibility of the users of SVGPath to detect
  +            // instances where the converted element (see #toSVG above)
  +            // returns null, which only happens for degenerate cases.
               return "";
  +        }
       }
   
       /**
  
  
  
  1.9       +10 -2     xml-batik/test-references/org/apache/batik/svggen/ContextNegativeLengths.svg
  
  Index: ContextNegativeLengths.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-references/org/apache/batik/svggen/ContextNegativeLengths.svg,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ContextNegativeLengths.svg	20 Feb 2002 16:18:46 -0000	1.8
  +++ ContextNegativeLengths.svg	10 Jun 2002 12:10:19 -0000	1.9
  @@ -1,7 +1,7 @@
   <?xml version="1.0" encoding="UTF-8"?>
   
   <!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.0//EN' 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'>
  -<svg contentScriptType="text/ecmascript" xmlns:xlink="http://www.w3.org/1999/xlink"
width="300" zoomAndPan="magnify" class="testC39" contentStyleType="text/css" height="400"
preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" version="1.0">
  +<svg contentScriptType="text/ecmascript" xmlns:xlink="http://www.w3.org/1999/xlink"
width="300" zoomAndPan="magnify" class="testC40" contentStyleType="text/css" height="400"
preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" version="1.0">
     <!--Generated by the Batik Test Framework. Test:éj-->
     <defs id="genericDefs" />
     <g>
  @@ -44,11 +44,15 @@
   .testC36 {fill:white;stroke:none;}
   .testC37 {fill:rgb(134,134,134);stroke:none;}
   .testC38 {fill:rgb(134,134,134);stroke:none;}
  -.testC39 {stroke-dashoffset:0;text-rendering:auto;color-rendering:auto;stroke-linecap:square;fill:black;font-size:12;stroke-linejoin:miter;font-weight:normal;stroke:black;fill-opacity:1;font-style:normal;stroke-dasharray:none;stroke-miterlimit:10;color-interpolation:auto;image-rendering:auto;shape-rendering:auto;font-family:'Arial';stroke-width:1;stroke-opacity:1;}
  +.testC39 {clip-path:url(#testclipPath1);stroke:none;}
  +.testC40 {stroke-dashoffset:0;text-rendering:auto;color-rendering:auto;stroke-linecap:square;fill:black;font-size:12;stroke-linejoin:miter;font-weight:normal;stroke:black;fill-opacity:1;font-style:normal;stroke-dasharray:none;stroke-miterlimit:10;color-interpolation:auto;image-rendering:auto;shape-rendering:auto;font-family:'Arial';stroke-width:1;stroke-opacity:1;}
   ]]>
       </style>
       <g>
         <defs id="testdefs1">
  +        <clipPath clipPathUnits="userSpaceOnUse" id="testclipPath1">
  +          <line y2="0" x1="0" x2="0" y1="0" />
  +        </clipPath>
           <font horiz-adv-x="75.0" id="testfont1">
             <font-face ascent="92.163086" descent="19.555664" units-per-em="100" font-family="Arial"
font-style="normal" font-weight="normal" />
             <missing-glyph horiz-adv-x="75.0" d="M12.5 0 L12.5 62.5 L62.5 62.5 L62.5 0
L12.5 0 ZM14.0625 1.5625 L60.9375 1.5625 L60.9375 60.9375 L14.0625 60.9375 L14.0625 1.5625
Z" />
  @@ -76,6 +80,9 @@
             <glyph unicode="E" horiz-adv-x="66.69922" d="M7.90625 0 L7.90625 71.578125
L59.671875 71.578125 L59.671875 63.140625 L17.390625 63.140625 L17.390625 41.21875 L56.984375
41.21875 L56.984375 32.8125 L17.390625 32.8125 L17.390625 8.453125 L61.328125 8.453125 L61.328125
0 L7.90625 0 Z" />
             <glyph unicode="3" horiz-adv-x="55.615234" d="M4.203125 18.890625 L12.984375
20.0625 Q14.5 12.59375 18.140625 9.296875 Q21.78125 6 27 6 Q33.203125 6 37.4765625 10.296875
Q41.75 14.59375 41.75 20.953125 Q41.75 27 37.796875 30.9296875 Q33.84375 34.859375 27.734375
34.859375 Q25.25 34.859375 21.53125 33.890625 L22.515625 41.609375 Q23.390625 41.5 23.921875
41.5 Q29.546875 41.5 34.0390625 44.4296875 Q38.53125 47.359375 38.53125 53.46875 Q38.53125
58.296875 35.2578125 61.4765625 Q31.984375 64.65625 26.8125 64.65625 Q21.6875 64.65625 18.265625
61.4296875 Q14.84375 58.203125 13.875 51.765625 L5.078125 53.328125 Q6.6875 62.15625 12.3984375
67.015625 Q18.109375 71.875 26.609375 71.875 Q32.46875 71.875 37.3984375 69.359375 Q42.328125
66.84375 44.9453125 62.5 Q47.5625 58.15625 47.5625 53.265625 Q47.5625 48.640625 45.0703125
44.828125 Q42.578125 41.015625 37.703125 38.765625 Q44.046875 37.3125 47.5625 32.6953125 Q51.078125
28.078125 51.078125 21.140625 Q51.078125 11.765625 44.2421875 5.2578125 Q37.40625 -1.25 26.953125
-1.25 Q17.53125 -1.25 11.3046875 4.359375 Q5.078125 9.96875 4.203125 18.890625 Z" />
             <glyph unicode="f" horiz-adv-x="27.783203" d="M8.6875 0 L8.6875 45.015625
L0.921875 45.015625 L0.921875 51.859375 L8.6875 51.859375 L8.6875 57.375 Q8.6875 62.59375
9.625 65.140625 Q10.890625 68.5625 14.0859375 70.6796875 Q17.28125 72.796875 23.046875 72.796875
Q26.765625 72.796875 31.25 71.921875 L29.9375 64.265625 Q27.203125 64.75 24.75 64.75 Q20.75
64.75 19.09375 63.0390625 Q17.4375 61.328125 17.4375 56.640625 L17.4375 51.859375 L27.546875
51.859375 L27.546875 45.015625 L17.4375 45.015625 L17.4375 0 L8.6875 0 Z" />
  +          <glyph unicode="h" horiz-adv-x="55.615234" d="M6.59375 0 L6.59375 71.578125
L15.375 71.578125 L15.375 45.90625 Q21.53125 53.03125 30.90625 53.03125 Q36.671875 53.03125
40.921875 50.7578125 Q45.171875 48.484375 47 44.484375 Q48.828125 40.484375 48.828125 32.859375
L48.828125 0 L40.046875 0 L40.046875 32.859375 Q40.046875 39.453125 37.1875 42.453125 Q34.328125
45.453125 29.109375 45.453125 Q25.203125 45.453125 21.7578125 43.4296875 Q18.3125 41.40625
16.84375 37.9375 Q15.375 34.46875 15.375 28.375 L15.375 0 L6.59375 0 Z" />
  +          <glyph unicode="T" horiz-adv-x="61.083984" d="M25.921875 0 L25.921875 63.140625
L2.34375 63.140625 L2.34375 71.578125 L59.078125 71.578125 L59.078125 63.140625 L35.40625
63.140625 L35.40625 0 L25.921875 0 Z" />
  +          <glyph unicode="H" horiz-adv-x="72.2168" d="M8.015625 0 L8.015625 71.578125
L17.484375 71.578125 L17.484375 42.1875 L54.6875 42.1875 L54.6875 71.578125 L64.15625 71.578125
L64.15625 0 L54.6875 0 L54.6875 33.734375 L17.484375 33.734375 L17.484375 0 L8.015625 0 Z"
/>
           </font>
         </defs>
         <g class="testC1">
  @@ -116,6 +123,7 @@
           <rect x="171" y="30" transform="translate(0,175)" width="3" class="testC36"
height="1" />
           <rect x="171" y="37" transform="translate(0,175)" width="4" class="testC37"
height="1" />
           <rect x="174" y="30" transform="translate(0,175)" width="1" class="testC38"
height="7" />
  +        <text xml:space="preserve" x="10" y="25" class="testC39" transform="translate(0,215)">Hello
There</text>
         </g>
       </g>
     </g>
  
  
  
  1.7       +6 -0      xml-batik/test-references/org/apache/batik/svggen/NegativeLengths.svg
  
  Index: NegativeLengths.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-references/org/apache/batik/svggen/NegativeLengths.svg,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- NegativeLengths.svg	20 Feb 2002 16:18:46 -0000	1.6
  +++ NegativeLengths.svg	10 Jun 2002 12:10:19 -0000	1.7
  @@ -5,6 +5,11 @@
     <!--Generated by the Batik Graphics2D SVG Generator-->
     <defs id="genericDefs" />
     <g>
  +    <defs id="defs1">
  +      <clipPath clipPathUnits="userSpaceOnUse" id="clipPath1">
  +        <line y2="0" x1="0" x2="0" y1="0" />
  +      </clipPath>
  +    </defs>
       <g text-rendering="optimizeLegibility" shape-rendering="geometricPrecision">
         <text xml:space="preserve" x="10" y="20" stroke="none">Rectangle</text>
         <line y2="38" fill="none" x1="110" x2="110" y1="30" />
  @@ -43,6 +48,7 @@
         <rect x="171" y="30" transform="translate(0,175)" fill="white" width="3" height="1"
stroke="none" />
         <rect x="171" y="37" transform="translate(0,175)" fill="rgb(134,134,134)" width="4"
height="1" stroke="none" />
         <rect x="174" y="30" transform="translate(0,175)" fill="rgb(134,134,134)" width="1"
height="7" stroke="none" />
  +      <text x="10" y="25" transform="translate(0,215)" clip-path="url(#clipPath1)" stroke="none"
xml:space="preserve">Hello There</text>
       </g>
     </g>
   </svg>
  
  
  

---------------------------------------------------------------------
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