deweese     02/02/04 12:11:34

  Added:       samples/tests/spec/scripting rectResizeOnClick.svg
                        xAnimOnClick.svg
  Log:
  Two new tests of modification via ecma script (still only rects though...).
  
  Revision  Changes    Path
  1.1                  xml-batik/samples/tests/spec/scripting/rectResizeOnClick.svg
  
  Index: rectResizeOnClick.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
  "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.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.                                      -->
  <!-- ====================================================================== -->
  
  <!-- ====================================================================== -->
  <!-- Modification of a rect's x,y,width and height attributes in an         -->
  <!-- 'onclick' event handler. This is actually mostly testing a change in   -->
  <!-- the documents size.                                                    -->
  <!--                                                                        -->
  <!-- @author [EMAIL PROTECTED]                                             -->
  <!-- @version $Id: rectResizeOnClick.svg,v 1.1 2002/02/04 20:11:33 deweese Exp $  
-->
  <!-- ========================================================================= -->
  <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>  
  <svg id="body" width="450" height="500" viewBox="0 0 450 500">
     <title>&lt;rect&gt; width &amp; hieght modification in 'onclick'</title>
  
     <script type="text/ecmascript">
  
      function setRect(evt, target, valX, valY, valW, valH){
          var r = evt.getTarget();
          var doc = r.getOwnerDocument();
          var t = doc.getElementById(target);
          t.setAttribute('x', valX);
          t.setAttribute('y', valY);
          t.setAttribute('width', valW);
          t.setAttribute('height', valH);
      }
  
     </script>
  
     <text x="50%" y="45" class="title">&lt;rect&gt; width &amp; height modification 
in 'onclick'</text>
  
  
     <g id="test-content" >
        <rect style="fill:none; stroke:black" 
              x="182" y="97" width="86" height="46" />
        <text class="legend" x="225" y="160">Position A</text>
  
        <rect style="fill:none; stroke:black" 
              x="182" y="177" width="86" height="46" />
        <text class="legend" x="225" y="240">Click Target</text>
  
        <g stroke="black"
           onclick="setRect(evt, 'targetRect', '5', '5', '440', '490')" >
           <circle cx="225" cy="200"  r="10"           fill="crimson"/>
           <line   x1="225" x2="225" y1="185" y2="215" fill="none" />
           <line   x1="210" x2="240" y1="200" y2="200" fill="none" />
        </g>
  
        <rect id="targetRect" fill="crimson" 
              x="185" y="100" width="80" height="40" />
  
        <text class="legend">
           <tspan x="225" y="270">Click on the Click Target (crimson circle)</tspan>
           <tspan x="225" y="285">to resize the rectangle to fill the 
viewport.</tspan>
           <tspan x="225" y="300">Hiding everything but this text.</tspan>
        </text>
     </g>
  </svg>
  
  
  
  1.1                  xml-batik/samples/tests/spec/scripting/xAnimOnClick.svg
  
  Index: xAnimOnClick.svg
  ===================================================================
  <?xml version="1.0" standalone="no"?>
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
  "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.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.                                      -->
  <!-- ====================================================================== -->
  
  <!-- ====================================================================== -->
  <!-- Modification of a rect's x attribute repeatedly starting from an       -->
  <!-- 'onclick' event handler.                                               -->
  <!--                                                                        -->
  <!-- @author [EMAIL PROTECTED]                                             -->
  <!-- @version $Id: xAnimOnClick.svg,v 1.1 2002/02/04 20:11:34 deweese Exp $ -->
  <!-- ====================================================================== -->
  
  <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>  
  <svg id="body" width="450" height="500" viewBox="0 0 450 500">
      <title>&lt;rect&gt; x Animation in 'onclick'</title>
  
      <text x="50%" y="45" class="title">&lt;rect&gt; x Animation in 'onclick'</text>
  
      <script type="text/ecmascript">
  
      function moveToX(evt, target, val){
          var r = evt.getTarget();
          var doc = r.getOwnerDocument();
          var t = doc.getElementById(target);
          var start = parseInt(t.getAttribute('x'));
          cyclopse(t, start, val, 1, 1);
      }
  
      function cyclopse(t, start, end, frac, inc) {
          while (1) {
          t.setAttribute('x', (end-start)*frac/100+start);
          if (frac == 100) {
            inc = -1;
          } else if (frac == 0) {
            inc = 1;
          }
          frac += inc;
          }
      }
  
      </script>
  
      <g id="test-content" transform="translate(0,125)">
          <g transform="translate(75,0)">
              <text class="legend" x="75" y="70">Position A</text>
  
              <rect id="originalPlaceShadowBorder" stroke="black" fill="none"
                    x="32" y="77" width="86" height="46" />
  
              <g>
                  <circle cx="75" cy="100" r="10" style="fill:crimson;stroke:black;"/>
                  <line x1="75" x2="75" y1="90" y2="110" 
style="stroke:black;fill:none" />
                  <line x1="65" x2="85" y1="100" y2="100" 
style="stroke:black;fill:none" />
              </g>
          </g>
  
          <g transform="translate(225,0)">
              <text class="legend" x="75" y="70">Position B</text>
  
              <rect id="targetPlaceShadowBorder"  fill="yellow" stroke="black"
                    x="32" y="77" width="86" height="46"/>
  
              <g onclick="moveToX(evt, 'targetRect', '260')">
                  <circle cx="75" cy="100" r="10" style="fill:crimson;stroke:black;"/>
                  <line x1="75" x2="75" y1="90" y2="110" 
style="stroke:black;fill:none" />
                  <line x1="65" x2="85" y1="100" y2="100" 
style="stroke:black;fill:none" />
              </g>
          </g>
  
          <rect id="targetRect" x="110" y="80" width="80" height="40" 
style="fill:red;fill-opacity:0.5" />
  
          <text class="legend">
          <tspan x="225" y="145">Click on the Position B target (crimson 
circle)</tspan>
          <tspan x="225" y="160">The transparent red rectangle should move between 
rects.</tspan></text>
      </g>
  </svg>
  
  
  

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

Reply via email to