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 de...@apache.org on 2001/10/23 15:42:30 UTC

cvs commit: xml-batik/test-sources/org/apache/batik/util Base64Test.java

deweese     01/10/23 06:42:30

  Modified:    .        build.sh build.xml
               samples  batikLogo.svg
               samples/extensions colorSwitch.svg solidColor.svg
               samples/tests/spec/fonts fontOnPath.svg
               samples/tests/spec/text textBiDi.svg verticalText.svg
                        verticalTextOnPath.svg
               sources/org/apache/batik/extension/svg
                        BatikDomExtension.java BatikExtConstants.java
                        SolidColorBridge.java
               sources/org/apache/batik/gvt/renderer
                        StrokingTextPainter.java
               test-resources/org/apache/batik/test regard.xml
               test-sources/org/apache/batik/util Base64Test.java
  Added:       test-resources/org/apache/batik/gvt unitTesting.xml
               test-resources/org/apache/batik/gvt/resources
                        TestMessages.properties
               test-sources/org/apache/batik/gvt Messages.java
                        TextSelectionTest.java
  Log:
  1) Solid Color now uses the CSS engine extension mechanism so it can use
     the solid-color and solid-opacity (weird name, I know) properties for
     it's values.
  2) Added TextSelection API Tests.
  3) Fixed a small bug in getMarker on TextNode.
  4) Added id's to several text elements for text selection tests.
  
  Revision  Changes    Path
  1.11      +1 -1      xml-batik/build.sh
  
  Index: build.sh
  ===================================================================
  RCS file: /home/cvs/xml-batik/build.sh,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- build.sh	2001/10/18 07:40:11	1.10
  +++ build.sh	2001/10/23 13:42:29	1.11
  @@ -27,5 +27,5 @@
     shift 1
   fi
   
  -$JAVA_HOME/bin/java $ANT_OPTS -classpath $CP org.apache.tools.ant.Main -Dant.home=$ANT_HOME $TARGET -Dargs="$*"
  +$JAVA_HOME/bin/java $ANT_OPTS -classpath $CP org.apache.tools.ant.Main -emacs -Dant.home=$ANT_HOME $TARGET -Dargs="$*"
   
  
  
  
  1.92      +5 -3      xml-batik/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/build.xml,v
  retrieving revision 1.91
  retrieving revision 1.92
  diff -u -r1.91 -r1.92
  --- build.xml	2001/10/22 15:29:53	1.91
  +++ build.xml	2001/10/23 13:42:29	1.92
  @@ -44,7 +44,7 @@
     [win32] .\build.bat help
   
    
  - $Id: build.xml,v 1.91 2001/10/22 15:29:53 vhardy Exp $
  + $Id: build.xml,v 1.92 2001/10/23 13:42:29 deweese Exp $
   
   -->
   
  @@ -219,7 +219,7 @@
             description="Compiles the tests infrastructure source files">
       <mkdir dir="${dest}"/>
   
  -    <javac srcdir="${testsrc}" destdir="${dest}" deprecation="on">
  +    <javac srcdir="${testsrc}" destdir="${dest}" deprecation="on" debug="on">
         <classpath>
           <pathelement location="${dest}" />
           <path refid="libs-classpath"/>
  @@ -233,7 +233,7 @@
             description="Compiles the source files">
       <mkdir dir="${dest}"/>
   
  -    <javac srcdir="${src}" destdir="${dest}" deprecation="on">
  +    <javac srcdir="${src}" destdir="${dest}" deprecation="on" debug="on">
         <classpath refid="libs-classpath"/>
         <exclude name="**/*.html"/>
         <exclude name="**/rhino/*" unless="rhino.present"/>      
  @@ -757,6 +757,8 @@
       <mkdir dir="${test-references}/org/apache/batik/svggen/rendering/candidate-variation" />
       <mkdir dir="${test-references}/org/apache/batik/svggen/rendering/candidate-reference" />
       <mkdir dir="${test-references}/org/apache/batik/svggen/rendering/accepted-variation" />
  +    <mkdir dir="${test-references}/org/apache/batik/gvt/candidate" />
  +    <mkdir dir="${test-references}/org/apache/batik/gvt/variation" />
     </target>
   
     <target name="ttf2svg"
  
  
  
  1.7       +2 -2      xml-batik/samples/batikLogo.svg
  
  Index: batikLogo.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/batikLogo.svg,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- batikLogo.svg	2001/10/16 09:07:42	1.6
  +++ batikLogo.svg	2001/10/23 13:42:29	1.7
  @@ -15,7 +15,7 @@
   <!-- Defines the Batik Logo using an SVG font.                              -->
   <!--                                                                        -->
   <!-- @author bella.robinson@cmis.csiro.au                                   -->
  -<!-- @version $Id: batikLogo.svg,v 1.6 2001/10/16 09:07:42 tkormann Exp $    -->
  +<!-- @version $Id: batikLogo.svg,v 1.7 2001/10/23 13:42:29 deweese Exp $    -->
   <!-- ====================================================================== -->
   
   <svg id="body" width="450" height="500" viewBox="0 0 450 500">
  @@ -141,7 +141,7 @@
             
             <g id="Batik_Logo_Shadow" filter="url(#dropShadow)">
                 <g id="Batik_Logo">
  -                 <text x="0" y="0" font-family="Batik SVGFont" 
  +                 <text id="text" x="0" y="0" font-family="Batik SVGFont" 
                          font-size="180">Batik</text>
                    <use xlink:href="#Batik_Logo_Underline"/>
                 </g> <!-- End Batik_Logo -->
  
  
  
  1.2       +5 -5      xml-batik/samples/extensions/colorSwitch.svg
  
  Index: colorSwitch.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/extensions/colorSwitch.svg,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- colorSwitch.svg	2001/10/17 12:33:00	1.1
  +++ colorSwitch.svg	2001/10/23 13:42:29	1.2
  @@ -14,7 +14,7 @@
   <!-- regularPoly extension tag test                                         -->
   <!--                                                                        -->
   <!-- @author Thomas.DeWeese@Kodak.com                                       -->
  -<!-- @version $Id: colorSwitch.svg,v 1.1 2001/10/17 12:33:00 deweese Exp $ -->
  +<!-- @version $Id: colorSwitch.svg,v 1.2 2001/10/23 13:42:29 deweese Exp $ -->
   <!-- ====================================================================== -->
   
   <?xml-stylesheet type="text/css" href="extension.css" ?>
  @@ -51,9 +51,9 @@
                fill="#0D0" stroke="#88F" stroke-width="2">
   
               <batik:colorSwitch id="TransPurple">
  -                <batik:solidColor color="red" 
  +                <batik:solidColor solid-color="red" 
                          requiredExtensions="NonExistantExtension"/>
  -                <batik:solidColor color="#FF00FF" opacity=".5"
  +                <batik:solidColor solid-color="#FF00FF" solid-opacity=".5"
                          requiredExtensions="http://xml.apache.org/batik/ext/solidColor/1.0"/>
                   <linearGradient>
                       <stop offset="0" stop-color="#FF0000" stop-opacity="0.5"/>
  @@ -61,7 +61,7 @@
               </batik:colorSwitch>
   
               <batik:colorSwitch id="SolidPurple">
  -                <batik:solidColor color="#FF00FF" 
  +                <batik:solidColor solid-color="#FF00FF" 
                          requiredExtensions="http://xml.apache.org/batik/ext/solidColor/1.0"/>
                   <linearGradient>
                       <stop offset="0" stop-color="#FFFF00" />
  @@ -69,7 +69,7 @@
               </batik:colorSwitch>
   
               <batik:colorSwitch id="orange">
  -                <batik:solidColor color="orange" opacity="1"
  +                <batik:solidColor solid-color="orange" solid-opacity="1"
                          requiredExtensions="NonExistantExtension" />
                   <linearGradient y2="100%">
                       <stop offset=".1" stop-color="crimson" />
  
  
  
  1.3       +6 -4      xml-batik/samples/extensions/solidColor.svg
  
  Index: solidColor.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/extensions/solidColor.svg,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- solidColor.svg	2001/10/17 12:33:00	1.2
  +++ solidColor.svg	2001/10/23 13:42:29	1.3
  @@ -14,7 +14,7 @@
   <!-- regularPoly extension tag test                                         -->
   <!--                                                                        -->
   <!-- @author Thomas.DeWeese@Kodak.com                                       -->
  -<!-- @version $Id: solidColor.svg,v 1.2 2001/10/17 12:33:00 deweese Exp $ -->
  +<!-- @version $Id: solidColor.svg,v 1.3 2001/10/23 13:42:29 deweese Exp $ -->
   <!-- ====================================================================== -->
   
   <?xml-stylesheet type="text/css" href="extension.css" ?>
  @@ -50,9 +50,11 @@
             <g requiredExtensions="http://xml.apache.org/batik/ext/solidColor/1.0"
                fill="#0D0" stroke="#88F" stroke-width="2">
   
  -            <batik:solidColor id="TransPurple" color="#FF00FF" opacity=".5"/>
  -            <batik:solidColor id="SolidPurple" color="#FF00FF" />
  -            <batik:solidColor id="orange"      color="orange" opacity="1"/>
  +            <batik:solidColor id="SolidPurple" solid-color="#FF00FF" />
  +            <batik:solidColor id="TransPurple" 
  +                   solid-color="#FF00FF" solid-opacity=".5"/>
  +            <batik:solidColor id="orange"      
  +                   solid-color="orange" solid-opacity="1"/>
   
               <circle fill="url(#SolidPurple)"   cx="85"  cy="135" r="50"/>
               <circle fill="url(#TransPurple)"   cx="225" cy="135" r="50"/>
  
  
  
  1.2       +5 -3      xml-batik/samples/tests/spec/fonts/fontOnPath.svg
  
  Index: fontOnPath.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/tests/spec/fonts/fontOnPath.svg,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- fontOnPath.svg	2001/10/15 09:10:05	1.1
  +++ fontOnPath.svg	2001/10/23 13:42:29	1.2
  @@ -14,7 +14,7 @@
   <!-- Render some text on a path using an SVG font                              -->
   <!--                                                                           -->
   <!-- @author bella.robinson@cmis.csiro.au                                      -->
  -<!-- @version $Id: fontOnPath.svg,v 1.1 2001/10/15 09:10:05 vhardy Exp $        -->
  +<!-- @version $Id: fontOnPath.svg,v 1.2 2001/10/23 13:42:29 deweese Exp $        -->
   <!-- ========================================================================= -->
   <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>  
   
  @@ -85,7 +85,8 @@
   
            <g transform="translate(150,220)">
               <use xlink:href="#Path1" style="fill:none; stroke:blue; stroke-width:2"/>
  -	      <text font-family="'SVGComic'" font-size="20" style="text-anchor:middle">
  +	      <text id="middle50" font-family="'SVGComic'" 
  +                    font-size="20" style="text-anchor:middle">
                   <textPath xlink:href="#Path1" startOffset="50%">Font <tspan fill="red" dy="-10">on</tspan><tspan dy="10"> a Path</tspan></textPath>
               </text>
               <text font-size="10" x="35" y="60">startOffset="50%"</text>
  @@ -104,7 +105,8 @@
   
           <g transform="translate(0,370)">
               <use xlink:href="#Path1" style="fill:none; stroke:blue; stroke-width:2"/>
  -	      <text font-family="'SVGComic'" font-size="20" style="text-anchor:start">
  +	      <text id="start35" font-family="'SVGComic'" 
  +                    font-size="20" style="text-anchor:start">
                   <textPath xlink:href="#Path1" startOffset="35">Font <tspan fill="red" dy="-10">on</tspan><tspan dy="10"> a Path</tspan></textPath>
               </text>
               <text font-size="10" x="35" y="60">startOffset="35"</text>
  
  
  
  1.2       +7 -7      xml-batik/samples/tests/spec/text/textBiDi.svg
  
  Index: textBiDi.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/tests/spec/text/textBiDi.svg,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- textBiDi.svg	2001/10/16 10:26:11	1.1
  +++ textBiDi.svg	2001/10/23 13:42:29	1.2
  @@ -14,7 +14,7 @@
   <!-- Test description here                                                     -->
   <!--                                                                           -->
   <!-- @author bill.haneman@ireland.sun.com                                      -->
  -<!-- @version $Id: textBiDi.svg,v 1.1 2001/10/16 10:26:11 vhardy Exp $                                                             -->
  +<!-- @version $Id: textBiDi.svg,v 1.2 2001/10/23 13:42:29 deweese Exp $                                                             -->
   <!-- ========================================================================= -->
   <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
   
  @@ -35,33 +35,33 @@
                  selections across bi-directional text.
           </text>
         <g font-family="dialog" font-size="3%" text-anchor="start">
  -        <text fill="MidnightBlue" x="10%" y="45%">latin:
  +        <text id="latin" fill="MidnightBlue" x="10%" y="45%">latin:
            ABCDEFG
            abcdefg
            hijklmnop
            qrstuvwxyz
           </text> 
  -        <text fill="Sienna" x="10%" y="50%">latin-extended: 
  +        <text id="latin-extended" fill="Sienna" x="10%" y="50%">latin-extended: 
            &#x0e6;&#x0e7;&#x0e8;&#x0e9;&#x0ea;&#x0eb;&#x0ec;
            &#x0ed;&#x0ee;&#x0ef;&#x0f0;&#x0f1;&#x0f2;&#x0f3;&#x0f4;
           </text>
  -        <text fill="Indigo" x="10%" y="55%">cyrillic: 
  +        <text id="cyrillic" fill="Indigo" x="10%" y="55%">cyrillic: 
            &#x411;&#x412;&#x413;&#x414;&#x415;&#x416;&#x417;&#x418;&#x419;
            &#x41a;&#x41b;&#x41c;&#x41d;&#x41e;&#x41f;&#x420;&#x421;&#x422;
            &#x423;&#x424;&#x425;&#x426;&#x427;
           </text>
  -        <text fill="Maroon" x="10%" y="60%">greek:
  +        <text id="greek" fill="Maroon" x="10%" y="60%">greek:
            &#x391;&#x392;&#x393;&#x394;&#x3b1;&#x3b2;&#x3b3;&#x3b4;&#x3b5;  
            &#x3b6;&#x3b7;&#x3b8;&#x3b9;&#x3ba;&#x3bb;&#x3bc;&#x3bd;&#x3be;  
            &#x3bf;&#x3c0;&#x3c1;&#x3c2;&#x3c3;&#x3c4;&#x3c5;&#x3c6;&#x3c7;  
            &#x3c8;&#x3c9;  
           </text> 
  -        <text fill="DarkOliveGreen" x="10%" y="65%">hebrew: 
  +        <text id="hebrew" fill="DarkOliveGreen" x="10%" y="65%">hebrew: 
            &#x5d0;&#x5d1;&#x5d2;&#x5d3;&#x5d4;&#x5d5;&#x5d6;&#x5d7;&#x5d8;
            &#x5d9;&#x5da;&#x5db;&#x5dc;&#x5dd;&#x5de;&#x5df;&#x5e0;&#x5e1;
            &#x5e2;&#x5e3;&#x5e4;&#x5e5;&#x5e6;&#x5e7;&#x5e8;&#x5e9;&#x5ea;
           </text>
  -        <text fill="DarkRed" x="10%" y="70%">arabic: 
  +        <text id="arabic" fill="DarkRed" x="10%" y="70%">arabic: 
            &#x621;&#x623;&#x624;&#x625;&#x626;&#x627;&#x628;&#x629;&#x62a;
            &#x62b;&#x62c;&#x62d;&#x62e;&#x62f;&#x630;&#x631;&#x632;&#x633;
            &#x634;&#x635;&#x636;&#x637;&#x638;&#x639;&#x640;&#x641;&#x642;
  
  
  
  1.2       +9 -5      xml-batik/samples/tests/spec/text/verticalText.svg
  
  Index: verticalText.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/tests/spec/text/verticalText.svg,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- verticalText.svg	2001/10/16 10:26:12	1.1
  +++ verticalText.svg	2001/10/23 13:42:29	1.2
  @@ -14,7 +14,7 @@
   <!-- Vertical <text>                                                           -->
   <!--                                                                           -->
   <!-- @author dean.jackson@cmis.csiro.au                                       -->
  -<!-- @version $Id: verticalText.svg,v 1.1 2001/10/16 10:26:12 vhardy Exp $     -->
  +<!-- @version $Id: verticalText.svg,v 1.2 2001/10/23 13:42:29 deweese Exp $     -->
   <!-- ========================================================================= -->
   <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>  
   
  @@ -58,10 +58,14 @@
   
           <text x="50" y="75" writing-mode="tb" font-size="15">Writing top to bottom&#x753b;&#x50cf;</text>
           <text x="100" y="75" glyph-orientation-vertical="auto" writing-mode="tb" font-size="15">Glyph Orientation:auto&#x753b;&#x50cf;</text>
  -        <text x="150" y="75" glyph-orientation-vertical="0" writing-mode="tb" font-size="15">Glyph Orientation:0&#x753b;&#x50cf;</text>
  -        <text x="200" y="75" glyph-orientation-vertical="90" writing-mode="tb" font-size="15">Glyph Orientation:90&#x753b;&#x50cf;</text>
  -        <text x="250" y="75" glyph-orientation-vertical="180" writing-mode="tb" font-size="15">Glyph Orientation:180&#x753b;&#x50cf;</text>
  -        <text x="300" y="75" glyph-orientation-vertical="270" writing-mode="tb" font-size="15">Glyph Orientation:270&#x753b;&#x50cf;</text>
  +        <text id="orient0"   x="150" y="75" glyph-orientation-vertical="0" 
  +              writing-mode="tb" font-size="15">Glyph Orientation:0&#x753b;&#x50cf;</text>
  +        <text id="orient90"  x="200" y="75" glyph-orientation-vertical="90" 
  +              writing-mode="tb" font-size="15">Glyph Orientation:90&#x753b;&#x50cf;</text>
  +        <text id="orient180" x="250" y="75" glyph-orientation-vertical="180" 
  +              writing-mode="tb" font-size="15">Glyph Orientation:180&#x753b;&#x50cf;</text>
  +        <text id="orient270" x="300" y="75" glyph-orientation-vertical="270" 
  +              writing-mode="tb" font-size="15">Glyph Orientation:270&#x753b;&#x50cf;</text>
           <text x="350" y="75" writing-mode="tb" font-size="15">Embedded <tspan fill="red">&lt;tspan&gt;</tspan> element</text>
           <text x="400" y="75" writing-mode="tb" font-size="15">Embedded <tspan fill="blue" glyph-orientation-vertical="0">orientated</tspan> element</text>
          
  
  
  
  1.2       +7 -4      xml-batik/samples/tests/spec/text/verticalTextOnPath.svg
  
  Index: verticalTextOnPath.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/tests/spec/text/verticalTextOnPath.svg,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- verticalTextOnPath.svg	2001/10/16 10:26:12	1.1
  +++ verticalTextOnPath.svg	2001/10/23 13:42:29	1.2
  @@ -14,7 +14,7 @@
   <!-- Tests vertical text on a path                                              -->
   <!--                                                                           -->
   <!-- @author bella.robinson@cmis.csiro.au                                      -->
  -<!-- @version $Id: verticalTextOnPath.svg,v 1.1 2001/10/16 10:26:12 vhardy Exp $        -->
  +<!-- @version $Id: verticalTextOnPath.svg,v 1.2 2001/10/23 13:42:29 deweese Exp $        -->
   <!-- ========================================================================= -->
   <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>  
   
  @@ -135,7 +135,8 @@
   
           <g transform="translate(10,370)">
               <use xlink:href="#Path2" style="fill:none; stroke:blue; stroke-width:2"/>
  -            <text font-size="15" writing-mode="tb" glyph-orientation-vertical="auto">
  +            <text id="supersub" font-size="15" writing-mode="tb" 
  +                  glyph-orientation-vertical="auto">
                  <textPath xlink:href="#Path2"><tspan baseline-shift="super" fill="green">super</tspan> and <tspan baseline-shift="sub" fill="red">sub</tspan>scripts</textPath>
               </text>
               <text font-size="10" x="20" y="65">baseline-shift="super"</text>
  @@ -146,7 +147,8 @@
   
            <g transform="translate(300,370)">
               <use xlink:href="#Path2" style="fill:none; stroke:blue; stroke-width:2"/>
  -	      <text font-size="15" writing-mode="tb" glyph-orientation-vertical="auto">
  +	      <text id="negpos" font-size="15" writing-mode="tb" 
  +                    glyph-orientation-vertical="auto">
                   <textPath xlink:href="#Path2"><tspan baseline-shift="+20%" fill="green">positive</tspan> and <tspan baseline-shift="-20%" fill="red">negative </tspan></textPath>
               </text>
   		<text font-size="10" x="20" y="65">baseline-shift="+/-20%"</text>
  @@ -156,7 +158,8 @@
           <g transform="translate(180,370)">
               <g transform="scale(0.75)">
               <use xlink:href="#Path2" style="fill:none; stroke:blue; stroke-width:2"/>
  -            <text font-size="20" x="10" y="-20" writing-mode="tb" glyph-orientation-vertical="auto">before path
  +            <text id="beforeafter" font-size="20" x="10" y="-20" 
  +                  writing-mode="tb" glyph-orientation-vertical="auto">before path
                  <textPath xlink:href="#Path2" fill="red" startOffset="10%">on path</textPath>after path
               </text>
               </g>
  
  
  
  1.6       +11 -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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BatikDomExtension.java	2001/10/17 12:33:00	1.5
  +++ BatikDomExtension.java	2001/10/23 13:42:29	1.6
  @@ -16,6 +16,10 @@
   import org.apache.batik.dom.svg.DomExtension;
   import org.apache.batik.dom.AbstractDocument;
   
  +import org.apache.batik.css.value.DefaultSystemColorResolver;
  +import org.apache.batik.css.svg.SimpleColorFactory;
  +import org.apache.batik.css.svg.OpacityFactory;
  +
   /**
    * This is a Service interface for classes that want to extend the
    * functionality of the Dom, to support new tags in the rendering tree.
  @@ -91,6 +95,13 @@
               (BATIK_EXT_NAMESPACE_URI,
                BATIK_EXT_SOLID_COLOR_TAG,
                new SolidColorElementFactory());
  +
  +        di.registerCustomCSSValueFactory
  +            (new SimpleColorFactory(null, BATIK_EXT_SOLID_COLOR_PROPERTY, 
  +                                    new DefaultSystemColorResolver()));
  +
  +        di.registerCustomCSSValueFactory
  +            (new OpacityFactory(null, BATIK_EXT_SOLID_OPACITY_PROPERTY));
   
           di.registerCustomElementFactory
               (BATIK_EXT_NAMESPACE_URI,
  
  
  
  1.5       +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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BatikExtConstants.java	2001/10/17 12:33:00	1.4
  +++ BatikExtConstants.java	2001/10/23 13:42:29	1.5
  @@ -48,11 +48,11 @@
           "trim";
   
       /** Attribute name for color attribute */
  -    public static final String BATIK_EXT_COLOR_ATTRIBUTE = 
  -        "color";
  +    public static final String BATIK_EXT_SOLID_COLOR_PROPERTY = 
  +        "solid-color";
   
       /** Attribute name for opacity attribute */
  -    public static final String BATIK_EXT_OPACITY_ATTRIBUTE = 
  -        "opacity";
  +    public static final String BATIK_EXT_SOLID_OPACITY_PROPERTY = 
  +        "solid-opacity";
   
   }
  
  
  
  1.2       +10 -4     xml-batik/sources/org/apache/batik/extension/svg/SolidColorBridge.java
  
  Index: SolidColorBridge.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/extension/svg/SolidColorBridge.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SolidColorBridge.java	2001/10/16 23:25:31	1.1
  +++ SolidColorBridge.java	2001/10/23 13:42:29	1.2
  @@ -69,12 +69,18 @@
                                float opacity) {
           CSSOMReadOnlyStyleDeclaration decl;
           decl = CSSUtilities.getComputedStyle(paintElement);
  -        float attr = PaintServer.convertOpacity
  -            (decl.getPropertyCSSValueInternal(CSS_OPACITY_PROPERTY));
  -        opacity *= attr;
  +        CSSValue opacityVal = decl.getPropertyCSSValueInternal
  +            (BATIK_EXT_SOLID_OPACITY_PROPERTY);
  +        if (opacityVal != null) {
  +            float attr = PaintServer.convertOpacity(opacityVal);
  +            opacity *= attr;
  +        }
   
           CSSValue colorDef
  -            = decl.getPropertyCSSValueInternal(CSS_COLOR_PROPERTY);
  +            = decl.getPropertyCSSValueInternal(BATIK_EXT_SOLID_COLOR_PROPERTY);
  +        if (colorDef == null)
  +            return new Color(0f, 0f, 0f, opacity);
  +
           Color ret = null;
           if (colorDef.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
               CSSPrimitiveValue v = (CSSPrimitiveValue)colorDef;
  
  
  
  1.18      +11 -3     xml-batik/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java
  
  Index: StrokingTextPainter.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/renderer/StrokingTextPainter.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- StrokingTextPainter.java	2001/09/27 21:19:44	1.17
  +++ StrokingTextPainter.java	2001/10/23 13:42:29	1.18
  @@ -60,7 +60,7 @@
    * @see org.apache.batik.gvt.text.GVTAttributedCharacterIterator
    *
    * @author <a href="bill.haneman@ireland.sun.com>Bill Haneman</a>
  - * @version $Id: StrokingTextPainter.java,v 1.17 2001/09/27 21:19:44 deweese Exp $
  + * @version $Id: StrokingTextPainter.java,v 1.18 2001/10/23 13:42:29 deweese Exp $
    */
   public class StrokingTextPainter extends BasicTextPainter {
   
  @@ -1086,12 +1086,20 @@
       public Mark getMark(TextNode node, int index, boolean leadingEdge) {
           AttributedCharacterIterator aci;
           aci = node.getAttributedCharacterIterator();
  +        if ((index < aci.getBeginIndex()) ||
  +            (index > aci.getEndIndex()))
  +            return null;
  +
  +        // get the list of text runs, this also may update the node's
  +        // aci with char index information.  So we need to refetch the
  +        // node's ACI...
  +        List textRuns = getTextRuns(node, aci);
  +        aci = node.getAttributedCharacterIterator();
  +
           aci.setIndex(index);
           int charIndex = ((Integer)aci.getAttribute
            (GVTAttributedCharacterIterator.TextAttribute.CHAR_INDEX)).intValue();
           
  -        // get the list of text runs
  -        List textRuns = getTextRuns(node, aci);
   
           // for each text run, see if it contains the current char.
           for (int i = 0; i < textRuns.size(); ++i) {
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/gvt/unitTesting.xml
  
  Index: unitTesting.xml
  ===================================================================
  <!-- ====================================================================== -->
  <!-- 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.                                      -->
  <!-- ====================================================================== -->
  
  <!-- ====================================================================== -->
  <!-- @author deweese@apache.org                                             -->
  <!-- @author vincent.hardy@sun.com                                          -->
  <!-- @version $Id: unitTesting.xml,v 1.1 2001/10/23 13:42:30 deweese Exp $  -->
  <!-- ====================================================================== -->
  <testSuite id="gvt.unitTesting" name="org.apache.batik.gvt Unit Testing">
  
      <!-- ================================================================== -->
      <!--                         Text Selection Tests                       -->
      <!-- ================================================================== -->
  
      <test id="ts.latin" class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select most of the latin entry -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/textBiDi.svg" />
          <arg class="java.lang.String"  value="latin" />
          <arg class="java.lang.Integer" value="0" />
          <arg class="java.lang.Integer" value="20" />
          <arg class="java.lang.String"  value="ts.latin.txt" />
      </test>
  
      <test id="ts.latin-ext" 
            class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select most of the latin-extended entry -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/textBiDi.svg" />
          <arg class="java.lang.String"  value="latin-extended" />
          <arg class="java.lang.Integer" value="0" />
          <arg class="java.lang.Integer" value="15" />
          <arg class="java.lang.String"  value="ts.latin-ext.txt" />
      </test>
  
      <test id="ts.cyrillic" class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select most of the cyrillic entry -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/textBiDi.svg" />
          <arg class="java.lang.String"  value="cyrillic" />
          <arg class="java.lang.Integer" value="4" />
          <arg class="java.lang.Integer" value="24" />
          <arg class="java.lang.String"  value="ts.cyrillic.txt" />
      </test>
  
      <test id="ts.greek" class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select most of the greek entry -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/textBiDi.svg" />
          <arg class="java.lang.String"  value="greek" />
          <arg class="java.lang.Integer" value="0" />
          <arg class="java.lang.Integer" value="35" />
          <arg class="java.lang.String"  value="ts.greek.txt" />
      </test>
  
      <test id="ts.hebrew" class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select just the hebrew part of entry -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/textBiDi.svg" />
          <arg class="java.lang.String"  value="hebrew" />
          <arg class="java.lang.Integer" value="10" />
          <arg class="java.lang.Integer" value="20" />
          <arg class="java.lang.String"  value="ts.hebrew.txt" />
      </test>
  
      <test id="ts.arabic" class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select most of the arabic entry -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/textBiDi.svg" />
          <arg class="java.lang.String"  value="arabic" />
          <arg class="java.lang.Integer" value="5" />
          <arg class="java.lang.Integer" value="40" />
          <arg class="java.lang.String"  value="ts.arabic.txt" />
      </test>
  
      <test id="ts.svgpath.middle50" 
            class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select most of the arabic entry -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/fonts/fontOnPath.svg" />
          <arg class="java.lang.String"  value="middle50" />
          <arg class="java.lang.Integer" value="1" />
          <arg class="java.lang.Integer" value="13" />
          <arg class="java.lang.String"  value="ts.svgpath.middle50.txt" />
      </test>
  
      <test id="ts.svgpath.start35" 
            class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select most of the arabic entry -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/fonts/fontOnPath.svg" />
          <arg class="java.lang.String"  value="start35" />
          <arg class="java.lang.Integer" value="0" />
          <arg class="java.lang.Integer" value="13" />
          <arg class="java.lang.String"  value="ts.svgpath.start35.txt" />
      </test>
  
      <test id="ts.vertpath.supersub" 
            class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select most of the arabic entry -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/verticalTextOnPath.svg" />
          <arg class="java.lang.String"  value="supersub" />
          <arg class="java.lang.Integer" value="3" />
          <arg class="java.lang.Integer" value="18" />
          <arg class="java.lang.String"  value="ts.vertpath.supersub.txt" />
      </test>
  
      <test id="ts.vertpath.beforeafter" 
            class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select most of the arabic entry -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/verticalTextOnPath.svg" />
          <arg class="java.lang.String"  value="beforeafter" />
          <arg class="java.lang.Integer" value="0" />
          <arg class="java.lang.Integer" value="28" />
          <arg class="java.lang.String"  value="ts.vertpath.beforeafter.txt" />
      </test>
  
      <test id="ts.vertpath.negpos" 
            class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select most of the arabic entry -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/verticalTextOnPath.svg" />
          <arg class="java.lang.String"  value="negpos" />
          <arg class="java.lang.Integer" value="3" />
          <arg class="java.lang.Integer" value="17" />
          <arg class="java.lang.String"  value="ts.vertpath.negpos.txt" />
      </test>
  
      <test id="ts.vert.orient0" 
            class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select vertical text with orientation 0 -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/verticalText.svg" />
          <arg class="java.lang.String"  value="orient0" />
          <arg class="java.lang.Integer" value="3" />
          <arg class="java.lang.Integer" value="18" />
          <arg class="java.lang.String"  value="ts.vert.orient0.txt" />
      </test>
  
      <test id="ts.vert.orient90" 
            class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select vertical text with orientation 90 -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/verticalText.svg" />
          <arg class="java.lang.String"  value="orient90" />
          <arg class="java.lang.Integer" value="3" />
          <arg class="java.lang.Integer" value="18" />
          <arg class="java.lang.String"  value="ts.vert.orient90.txt" />
      </test>
  
      <test id="ts.vert.orient180" 
            class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select vertical text with orientation 180 -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/verticalText.svg" />
          <arg class="java.lang.String"  value="orient180" />
          <arg class="java.lang.Integer" value="3" />
          <arg class="java.lang.Integer" value="18" />
          <arg class="java.lang.String"  value="ts.vert.orient180.txt" />
      </test>
  
      <test id="ts.vert.orient270" 
            class="org.apache.batik.gvt.TextSelectionTest">
          <!-- Select vertical text with orientation 270 -->
          <arg class="java.lang.String"  
               value="samples/tests/spec/text/verticalText.svg" />
          <arg class="java.lang.String"  value="orient270" />
          <arg class="java.lang.Integer" value="3" />
          <arg class="java.lang.Integer" value="18" />
          <arg class="java.lang.String"  value="ts.vert.orient270.txt" />
      </test>
  </testSuite>
  
  
  
  1.1                  xml-batik/test-resources/org/apache/batik/gvt/resources/TestMessages.properties
  
  Index: TestMessages.properties
  ===================================================================
  #############################################################################
  # 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.                                                         #
  #############################################################################
  
  #
  # Error Message values for Text Selection Tests
  #
  TextSelectionTest.error.reading.svg =\
  Error while read SVG file: \n\
  SVG URL: "{0}" \n\
  Got stack trace {1}
  
  TextSelectionTest.error.bad.id =\
  Given ID doesn''t reference an element:\n\
  ID: "{0}"
  
  TextSelectionTest.error.id.not.text =\
  Given ID doesn''t reference a text element:\n\
  ID: "{0}"\n\
  Element: {1}
  
  TextSelectionTest.error.getting.selection =\
  Error while getting text selection: \n\
  ID:"{0}" ({1}->{2}) \n\
  Stack Trace {3}
  
  TextSelectionTest.error.cannot.read.ref.url =\
  Error while reading reference file: \n\
  URL: "{0}" \n\
  Stack Trace {1}
  
  TextSelectionTest.error.wrong.result =\
  Error result doesn''t match, starting at byte: {0}
  
  TextSelectionTest.error.no.reference =\
  Reference file doesn''t exist: {0}
  
  #
  # Entry Keys
  # 
  TextSelectionTest.entry.key.error.description = \
  Error Description.
  
  
  
  1.14      +3 -1      xml-batik/test-resources/org/apache/batik/test/regard.xml
  
  Index: regard.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-resources/org/apache/batik/test/regard.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- regard.xml	2001/10/16 10:39:08	1.13
  +++ regard.xml	2001/10/23 13:42:30	1.14
  @@ -11,7 +11,7 @@
   <!-- regression testing.                                                       -->
   <!--                                                                           -->
   <!-- @author vincent.hardy@eng.sun.com                                         -->
  -<!-- @version $Id: regard.xml,v 1.13 2001/10/16 10:39:08 vhardy Exp $  -->
  +<!-- @version $Id: regard.xml,v 1.14 2001/10/23 13:42:30 deweese Exp $  -->
   <!-- ========================================================================= -->
   <testRun id="regard" name="Batik Standard Regression Test Run">
       <testReportProcessor class="org.apache.batik.test.xml.XMLTestReportProcessor" > 
  @@ -53,5 +53,7 @@
       <testSuite href="file:test-resources/org/apache/batik/ext/awt/image/codec/unitTesting.xml" />
       <testSuite href="file:test-resources/org/apache/batik/util/unitTesting.xml" />
       <testSuite href="file:test-resources/org/apache/batik/dom/unitTesting.xml" /> 
  +
  +    <testSuite href="file:test-resources/org/apache/batik/gvt/unitTesting.xml" /> 
   
   </testRun>
  
  
  
  1.1                  xml-batik/test-sources/org/apache/batik/gvt/Messages.java
  
  Index: Messages.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.gvt;
  
  import java.util.Locale;
  import java.util.MissingResourceException;
  import org.apache.batik.i18n.Localizable;
  import org.apache.batik.i18n.LocalizableSupport;
  
  /**
   * This class manages the message for the test.svg module.
   *
   * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
   * @version $Id: Messages.java,v 1.1 2001/10/23 13:42:30 deweese Exp $
   */
  public class Messages {
  
      /**
       * This class does not need to be instantiated.
       */
      protected Messages() { }
  
      /**
       * The error messages bundle class name.
       */
      protected final static String RESOURCES =
          "org.apache.batik.gvt.resources.TestMessages";
  
      /**
       * The localizable support for the error messages.
       */
      protected static LocalizableSupport localizableSupport =
          new LocalizableSupport(RESOURCES);
  
      /**
       * Implements {@link org.apache.batik.i18n.Localizable#setLocale(Locale)}.
       */
      public static void setLocale(Locale l) {
          localizableSupport.setLocale(l);
      }
  
      /**
       * Implements {@link org.apache.batik.i18n.Localizable#getLocale()}.
       */
      public static Locale getLocale() {
          return localizableSupport.getLocale();
      }
  
      /**
       * Implements {@link
       * org.apache.batik.i18n.Localizable#formatMessage(String,Object[])}.
       */
      public static String formatMessage(String key, Object[] args)
          throws MissingResourceException {
          return localizableSupport.formatMessage(key, args);
      }
  }
  
  
  
  1.1                  xml-batik/test-sources/org/apache/batik/gvt/TextSelectionTest.java
  
  Index: TextSelectionTest.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.gvt;
  
  import org.apache.batik.test.AbstractTest;
  import org.apache.batik.test.DefaultTestReport;
  import org.apache.batik.test.TestReport;
  
  import org.apache.batik.util.Base64Test;
  
  import org.apache.batik.gvt.GraphicsNode;
  import org.apache.batik.gvt.TextNode;
  import org.apache.batik.gvt.text.Mark;
  import org.apache.batik.bridge.UserAgent;
  import org.apache.batik.bridge.UserAgentAdapter;
  import org.apache.batik.bridge.DocumentLoader;
  import org.apache.batik.bridge.BridgeContext;
  import org.apache.batik.bridge.GVTBuilder;
  
  import org.w3c.dom.svg.SVGDocument;
  import org.w3c.dom.Element;
  
  import java.awt.Shape;
  import java.awt.geom.PathIterator;
  
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.PipedOutputStream;
  import java.io.PipedInputStream;
  import java.io.InputStream;
  import java.io.OutputStream;
  import java.io.IOException;
  import java.io.StringWriter;
  import java.io.PrintWriter;
  import java.io.PrintStream;
  
  import java.net.MalformedURLException;
  import java.net.URL;
  
  
  /**
   * This test validates that the text selection API's work properly.
   *
   * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
   * @version $Id: TextSelectionTest.java,v 1.1 2001/10/23 13:42:30 deweese Exp $
   */
  public class TextSelectionTest extends AbstractTest {
  
      /**
       * Directory for reference files
       */
      public static final String REFERENCE_DIR
          = "test-references/org/apache/batik/gvt/";
  
      public static final String VARIATION_DIR
          = "variation/";
  
      public static final String CANDIDATE_DIR
          = "candidate/";
  
  
      /**
       * Error when unable to load requested SVG file
       * {0} = file
       * {1} = exception
       */
      public static final String ERROR_READING_SVG
          = "TextSelectionTest.error.reading.svg";
  
      /**
       * Error id doesn't reference an element
       * {0} = id
       */
      public static final String ERROR_BAD_ID
          = "TextSelectionTest.error.bad.id";
  
      /**
       * Error id doesn't reference a text element
       * {0} = id
       * {1} = element referenced
       */
      public static final String ERROR_ID_NOT_TEXT
          = "TextSelectionTest.error.id.not.text";
  
      /**
       * Error couldn't get selection highlight specified.
       * {0} = id
       * {1} = start index
       * {2} = end index
       * {3} = exception
       */
      public static final String ERROR_GETTING_SELECTION
          = "TextSelectionTest.error.getting.selection";
  
      /**
       * Error when unable to read/open ref URL
       * {0} = URL
       * {1} = exception stack trace.
       */
      public static final String ERROR_CANNOT_READ_REF_URL
          = "TextSelectionTest.error.cannot.read.ref.url";
  
      /**
       * Result didn't match reference result.
       * {0} = first byte of mismatch
       */
      public static final String ERROR_WRONG_RESULT
          = "TextSelectionTest.error.wrong.result";
  
      /**
       * No Reference or Variation file to compaire with.
       * {0} = reference url
       */
      public static final String ERROR_NO_REFERENCE
          = "TextSelectionTest.error.no.reference";
  
  
      public static final String ENTRY_KEY_ERROR_DESCRIPTION
          = "TextSelectionTest.entry.key.error.description";
  
      protected URL    svg   = null;
      protected String id    = null;
      protected int    start;
      protected int    end;
      protected URL    ref   = null;
      protected URL    var   = null;
      protected File   can   = null;
  
      /**
       * Constructor. ref is ignored if action == ROUND.
       * @param svg    The svg file to load
       * @param id     The element to select text from (must be a <text> element)
       * @param start  The first character to select
       * @param end    The last character to select
       * @param ref    The reference file.
       */
      public TextSelectionTest(String svg, String id, 
                               Integer start, Integer end, 
                               String ref) {
          this.svg   = resolveURL(svg);
          this.id    = id;
          this.start = start.intValue();
          this.end   = end.intValue();
          this.ref   = resolveURL(REFERENCE_DIR+ref);
          this.var   = resolveURL(REFERENCE_DIR+VARIATION_DIR+ref);
          this.can   = new File(REFERENCE_DIR+CANDIDATE_DIR+ref);
      }
  
      /**
       * Resolves the input string as follows.
       * + First, the string is interpreted as a file description.
       *   If the file exists, then the file name is turned into
       *   a URL.
       * + Otherwise, the string is supposed to be a URL. If it
       *   is an invalid URL, an IllegalArgumentException is thrown.
       */
      protected URL resolveURL(String url){
          // Is url a file?
          File f = (new File(url)).getAbsoluteFile();
          if(f.getParentFile().exists()){
              try{
                  return f.toURL();
              }catch(MalformedURLException e){
                  throw new IllegalArgumentException();
              }
          }
          
          // url is not a file. It must be a regular URL...
          try{
              return new URL(url);
          }catch(MalformedURLException e){
              throw new IllegalArgumentException(url);
          }
      }
  
      /**
       * Returns this Test's name
       */
      public String getName() {
          return svg + "#" + id + "(" + start + "," + end + ")";
      }
  
  
      /**
       * This method will only throw exceptions if some aspect
       * of the test's internal operation fails.
       */
      public TestReport runImpl() throws Exception {
          DefaultTestReport report = new DefaultTestReport(this);
  
          SVGDocument  svgDoc;
          GraphicsNode gvtRoot;
          BridgeContext  ctx;
          try {
              UserAgent      userAgent = new UserAgentAdapter();
              DocumentLoader loader    = new DocumentLoader(userAgent);
              GVTBuilder     builder   = new GVTBuilder();
  
              ctx     = new BridgeContext(userAgent, loader);
              svgDoc  = (SVGDocument)loader.loadDocument(svg.toString());
              gvtRoot = builder.build(ctx, svgDoc);
          } catch(Exception e) {
              StringWriter trace = new StringWriter();
              e.printStackTrace(new PrintWriter(trace));
              report.setErrorCode(ERROR_READING_SVG);
              report.setDescription(new TestReport.Entry[] {
                  new TestReport.Entry
                      (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null),
                       Messages.formatMessage
                       (ERROR_READING_SVG,
                        new String[]{svg.toString(), trace.toString()}))
                      });
              report.setPassed(false);
              return report;
          }
  
          Shape highlight = null;
          try {
              Element e = svgDoc.getElementById(id);
              // System.out.println("Element: " + e + " CTX: " + ctx );
              GraphicsNode gn = ctx.getGraphicsNode(e);
              if (gn == null) {
                  report.setErrorCode(ERROR_BAD_ID);
                  report.setDescription(new TestReport.Entry[] {
                      new TestReport.Entry
                          (Messages.formatMessage
                           (ENTRY_KEY_ERROR_DESCRIPTION, null),
                           Messages.formatMessage
                           (ERROR_BAD_ID, new String[]{ id }))
                          });
                  report.setPassed(false);
                  return report;
              }
  
              if (!(gn instanceof TextNode)) {
                  report.setErrorCode(ERROR_ID_NOT_TEXT);
                  report.setDescription(new TestReport.Entry[] {
                      new TestReport.Entry
                          (Messages.formatMessage
                           (ENTRY_KEY_ERROR_DESCRIPTION, null),
                           Messages.formatMessage
                           (ERROR_ID_NOT_TEXT, new String[]{id, gn.toString()}))
                          });
                  report.setPassed(false);
                  return report;
              }
  
  
              TextNode tn = (TextNode)gn;
              Mark f = tn.getMarkerForChar(start,true);
              Mark l = tn.getMarkerForChar(end,false);
              tn.setSelection(f, l);
              highlight = tn.getHighlightShape();
          } catch(Exception e) {
              StringWriter trace = new StringWriter();
              e.printStackTrace(new PrintWriter(trace));
              report.setErrorCode(ERROR_GETTING_SELECTION);
              report.setDescription(new TestReport.Entry[] {
                  new TestReport.Entry
                      (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null),
                       Messages.formatMessage
                       (ERROR_GETTING_SELECTION,
                        new String[]{id, ""+start, ""+end, trace.toString()}))
                      });
              report.setPassed(false);
              return report;
          }
  
          boolean usingVar = false;
          boolean usingRef = false;
          InputStream refIS = null;
          try {
              refIS = var.openStream();
          } catch(Exception e) { try {
              refIS = ref.openStream();
          } catch(Exception ex) {
              StringWriter trace = new StringWriter();
              e.printStackTrace(new PrintWriter(trace));
              report.setErrorCode(ERROR_CANNOT_READ_REF_URL);
              report.setDescription
                  (new TestReport.Entry[] {
                      new TestReport.Entry
                          (Messages.formatMessage
                           (ENTRY_KEY_ERROR_DESCRIPTION, null),
                           Messages.formatMessage
                           (ERROR_CANNOT_READ_REF_URL,
                            new String[]{ref.toString(), trace.toString()}))
                          });
              report.setPassed(false);
          }
          }
  
          int mismatch = -2;
          if (refIS != null) {
              PipedOutputStream pos  = new PipedOutputStream();
              InputStream       inIS = new PipedInputStream(pos);
              Checker check = new Checker(inIS, refIS);
              check.start();
              PrintStream pw = new PrintStream(pos);
              printShape(highlight, pw);
              pw.flush();
              pw.close();
              pos.close();
              mismatch = check.getMismatch();
  
          }
  
          if (mismatch == -1) {
            report.setPassed(true);
            return report;
          }
  
          if (mismatch == -2) {
              report.setErrorCode(ERROR_NO_REFERENCE);
              report.setDescription(new TestReport.Entry[] {
                  new TestReport.Entry
                      (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null),
                       Messages.formatMessage(ERROR_NO_REFERENCE, 
                                              new String[]{ref.toString()}))
                      });
          } else {
              report.setErrorCode(ERROR_WRONG_RESULT);
              report.setDescription(new TestReport.Entry[] {
                  new TestReport.Entry
                      (Messages.formatMessage(ENTRY_KEY_ERROR_DESCRIPTION, null),
                       Messages.formatMessage(ERROR_WRONG_RESULT, 
                                              new String[]{""+mismatch}))
                      });
          }
          report.setPassed(false);
  
          // Now write a canidate reference/variation file...
          if (can.exists())
              can.delete();
  
          printShape(highlight, new PrintStream(new FileOutputStream(can)));
  
          return report;
      }
  
      public static class Checker extends Thread {
          int mismatch = -2;
          InputStream is1, is2;
          public Checker(InputStream is1, InputStream is2) {
              this.is1 = is1;
              this.is2 = is2;
          }
          public int getMismatch() {
              while (true) {
                  try {
                      this.join();
                      break;
                  } catch (InterruptedException ie) { }
              }
  
              return mismatch;
          }
          public void run() {
              mismatch = Base64Test.compareStreams (is1, is2, false);
          }
      }
  
      public static void printShape(Shape s, PrintStream ps) {
          PathIterator pi = s.getPathIterator(null);
          float pts [] = new float[6];
          int type;
          while (!pi.isDone()) {
              type = pi.currentSegment(pts);
              switch (type) {
              case PathIterator.SEG_MOVETO:
                  ps.println(" MoveTo: [" + 
                                     pts[0] + ", " + pts[1] + "]");
                  break;
              case PathIterator.SEG_LINETO:
                  ps.println(" LineTo: [" + 
                                     pts[0] + ", " + pts[1] + "]");
                  break;
  
              case PathIterator.SEG_QUADTO:
                  ps.println(" QuadTo: [" + 
                                     pts[0] + ", " + pts[1] + "] [" +
                                     pts[2] + ", " + pts[3] + "]");
                  break;
  
              case PathIterator.SEG_CUBICTO:
                  ps.println("CurveTo: [" + 
                                     pts[0] + ", " + pts[1] + "] [" +
                                     pts[2] + ", " + pts[3] + "] [" +
                                     pts[4] + ", " + pts[5] + "]");
                  break;
  
              case PathIterator.SEG_CLOSE:
                  ps.println("Close");
                  break;
              }
              pi.next();
          }
      }
  
  
  }
  
  
  
  
  1.2       +3 -4      xml-batik/test-sources/org/apache/batik/util/Base64Test.java
  
  Index: Base64Test.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/test-sources/org/apache/batik/util/Base64Test.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Base64Test.java	2001/07/05 16:54:35	1.1
  +++ Base64Test.java	2001/10/23 13:42:30	1.2
  @@ -23,11 +23,10 @@
   import java.net.URL;
   
   /**
  - * This test validates that the ParsedURL class properly parses and
  - * cascades URLs.
  + * This test validates that the Base65 encoder/decoders work properly.
    *
    * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
  - * @version $Id: Base64Test.java,v 1.1 2001/07/05 16:54:35 deweese Exp $
  + * @version $Id: Base64Test.java,v 1.2 2001/10/23 13:42:30 deweese Exp $
    */
   public class Base64Test extends AbstractTest {
       /**
  @@ -200,7 +199,7 @@
        * Returns true if the contents of <tt>is1</tt> match the
        * contents of <tt>is2</tt>
        */
  -    static int compareStreams(InputStream is1, InputStream is2, 
  +    public static int compareStreams(InputStream is1, InputStream is2, 
                                 boolean skipws) {
           byte [] data1 = new byte[100];
           byte [] data2 = new byte[100];
  
  
  

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


cvs commit: xml-batik/test-sources/org/apache/batik/util Base64Test.java

Posted by Thomas E Deweese <th...@kodak.com>.
>>>>> "TD" == Thomas E DeWeese <de...@apache.org> writes:

      I should also have mentioned that I turned debug on for the
javac calls (otherwise I didn't get line numbers in stack traces).

      build.sh now invokes ant with '-emacs' which makes emacs
compiles easier.

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