xmlgraphics-batik-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dewe...@apache.org
Subject cvs commit: xml-batik/test-resources/org/apache/batik/test samplesRendering.xml
Date Sat, 12 Feb 2005 01:48:24 GMT
deweese     2005/02/11 17:48:24

  Modified:    .        build.xml
               samples/tests/spec/scripting remove.svg removeOnclick.svg
               sources/org/apache/batik/bridge CursorManager.java
                        ScriptingEnvironment.java
               sources/org/apache/batik/dom AbstractParentNode.java
               sources/org/apache/batik/dom/util SAXDocumentFactory.java
               sources/org/apache/batik/gvt AbstractGraphicsNode.java
                        CompositeGraphicsNode.java ImageNode.java
                        UpdateTracker.java
               sources/org/apache/batik/gvt/filter GraphicsNodeRed8Bit.java
               sources/org/apache/batik/swing/gvt JGVTComponent.java
               sources/org/apache/batik/util/gui DOMViewer.java
               test-resources/org/apache/batik/test samplesRendering.xml
  Added:       samples/tests/spec/scripting visibilityOnClick.svg
  Log:
  1) Massive performance improvement (>10X) for drawing on Mac OS X.
  2) The DOM tree viewer now has an option to hide text nodes that
     only contain whitespace.
  3) The DOM tree viewer now includes the id of an element in the
     tree view if it has one.
  4) Fixed handling of gzip data in getURL/postURL.
  5) SAXParser now includes 'ignorableWhitespace' when building the
     DOM tree.  I also tweaked the way text and CDATA sections are
     created.
  6) Improvements to empty bounds handling, should decrease update areas.
  7) Fixed visibility bug on image elements.
  8) New test for visibility updates.
  
  Revision  Changes    Path
  1.157     +2 -2      xml-batik/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-batik/build.xml,v
  retrieving revision 1.156
  retrieving revision 1.157
  diff -u -r1.156 -r1.157
  --- build.xml	6 Feb 2005 10:29:09 -0000	1.156
  +++ build.xml	12 Feb 2005 01:48:23 -0000	1.157
  @@ -955,7 +955,7 @@
             description="Runs Squiggle - the SVG browser">
       <java fork="yes" 
             classname="${class-prefix}.apps.svgbrowser.Main">
  -<!--      jvm="C:\Documents and Settings\<user>\.netbeans\4.0\modules\profiler-ea-vm\jre\bin\java">
 -->
  +<!--          jvm="C:\Documents and Settings\<user>\.netbeans\4.0\modules\profiler-ea-vm\jre\bin\java">
-->
         <classpath>
           <pathelement location="${dest}" />
           <path refid="libs-classpath"/>
  
  
  
  1.7       +13 -1     xml-batik/samples/tests/spec/scripting/remove.svg
  
  Index: remove.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/tests/spec/scripting/remove.svg,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- remove.svg	18 Aug 2004 07:12:05 -0000	1.6
  +++ remove.svg	12 Feb 2005 01:48:23 -0000	1.7
  @@ -39,9 +39,21 @@
       <script type="text/ecmascript">
   
       var svgNamespaceURI = "http://www.w3.org/2000/svg";
  +    var TEXT_NODE = 3;
   
       function remove(evt) {
           var g = evt.currentTarget;
  +        // First remove any text node children.
  +        var fc = g.firstChild;
  +        while (fc) {
  +          if (fc.getNodeType() == TEXT_NODE) {
  +            var x = fc;
  +            fc = fc.nextSibling;
  +            g.removeChild(x);
  +          } else {
  +            fc = fc.nextSibling;
  +          }
  +        }
           g.removeChild(g.firstChild); // remove grey
           g.removeChild(g.firstChild.nextSibling); // remove crimson
           g.removeChild(g.firstChild.nextSibling); // remove orange
  
  
  
  1.4       +13 -1     xml-batik/samples/tests/spec/scripting/removeOnclick.svg
  
  Index: removeOnclick.svg
  ===================================================================
  RCS file: /home/cvs/xml-batik/samples/tests/spec/scripting/removeOnclick.svg,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- removeOnclick.svg	18 Aug 2004 07:12:05 -0000	1.3
  +++ removeOnclick.svg	12 Feb 2005 01:48:23 -0000	1.4
  @@ -39,9 +39,21 @@
       <script type="text/ecmascript">
   
       var svgNamespaceURI = "http://www.w3.org/2000/svg";
  +    var TEXT_NODE = 3;
   
       function remove(evt) {
           var g = evt.currentTarget;
  +        // First remove any text node children.
  +        var fc = g.firstChild;
  +        while (fc) {
  +          if (fc.getNodeType() == TEXT_NODE) {
  +            var x = fc;
  +            fc = fc.nextSibling;
  +            g.removeChild(x);
  +          } else {
  +            fc = fc.nextSibling;
  +          }
  +        }
           g.removeChild(g.firstChild); // remove grey
           g.removeChild(g.firstChild.nextSibling); // remove crimson
           g.removeChild(g.firstChild.nextSibling); // remove orange
  
  
  
  1.1                  xml-batik/samples/tests/spec/scripting/visibilityOnClick.svg
  
  Index: visibilityOnClick.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 2002-2003  The Apache Software Foundation 
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  
  -->
  <!-- ====================================================================== -->
  <!-- Modification of the visibility property                                -->
  <!--                                                                        -->
  <!-- @author tkormann@ilog.fr                                               -->
  <!-- @version $Id: visibilityOnClick.svg,v 1.1 2005/02/12 01:48:23 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>'visibility' property on 'onclick</title>
  
    <text x="50%" y="45" class="title">'visibility' property on 'onclick'</text>
  
    <script type="text/ecmascript"><![CDATA[
      function changeVisibility(elem, newValue) {
         elem.style.setProperty("visibility", newValue, "");
      }
      function doChange() {
         changeVisibility(document.getElementById("gHide"),  "hidden");
         changeVisibility(document.getElementById("r1Hide"), "hidden");
         changeVisibility(document.getElementById("r2Hide"), "hidden");
         changeVisibility(document.getElementById("r3Hide"), "hidden");
         changeVisibility(document.getElementById("r4Hide"), "hidden");
         changeVisibility(document.getElementById("i1Hide"), "hidden");
  
         changeVisibility(document.getElementById("gShow"),  "visible");
         changeVisibility(document.getElementById("r1Show"), "visible");
         changeVisibility(document.getElementById("r2Show"), "visible");
         changeVisibility(document.getElementById("r3Show"), "visible");
         changeVisibility(document.getElementById("r4Show"), "visible");
         changeVisibility(document.getElementById("i1Show"), "visible");
      }
  
      // This function is only called if test is run from regard.
      function regardStart() {
         doChange();
         setTimeout('regardTestInstance.scriptDone()', 200);
      }
      ]]></script>
  
    <linearGradient id="grad">
      <stop style="stop-color:crimson" offset="0" />
      <stop style="stop-color:gold" offset="1" />
    </linearGradient>
  
  
  
    <g id="test-content" stroke="black" stroke-width="1">
        <g stroke="black" onclick="doChange()" >
           <circle cx="100" cy="100"  r="10"           fill="crimson"/>
           <line   x1="85"  x2="115" y1="100" y2="100" fill="none" />
           <line   x1="100" x2="100" y1="85"  y2="115" fill="none" />
        </g>
        <text class="legend" style="text-anchor:start" stroke="none">
           <tspan x="150" y="97">Click on the Click Target (crimson circle)</tspan>
           <tspan x="150" y="113">to toggle visibility on elements.</tspan>
        </text>
  
      <g id="gHide" style="visibility:visible">
        <rect  x="100" y="150" width="100" height="50" style="fill:#eee"/>
        <rect  x="150" y="150" width="100" height="50" style="fill:gold"/>
        <rect  x="200" y="150" width="100" height="50" style="fill:crimson"/>
        <rect  x="250" y="150" width="100" height="50" style="fill:url(#grad)"/>
        <image x="350" y="150" width="50"  height="50" 
          xlink:href="../../resources/images/png2.png"/>
      </g>
  
      <g>
        <g style="fill:#eee">
           <rect  id="r1Hide" x="100" y="225" width="100" height="50"
                  style="visibility:visible"/></g>
        <g style="fill:gold">
           <rect  id="r2Hide" x="150" y="225" width="100" height="50" 
                  style="visibility:visible"/></g>
        <g style="fill:crimson">
           <rect  id="r3Hide" x="200" y="225" width="100" height="50"
                  style="visibility:visible"/></g>
        <g style="fill:url(#grad)">
           <rect  id="r4Hide" x="250" y="225" width="100" height="50" 
                  style="visibility:visible"/></g>
        <image id="i1Hide" x="350" y="225" width="50" height="50" 
               xlink:href="../../resources/images/png2.png"/>
      </g>
  
      <g id="gShow" style="visibility:hidden">
        <rect  x="100" y="300" width="100" height="50" style="fill:#eee"/>
        <rect  x="150" y="300" width="100" height="50" style="fill:gold"/>
        <rect  x="200" y="300" width="100" height="50" style="fill:crimson"/>
        <rect  x="250" y="300" width="100" height="50" style="fill:url(#grad)"/>
        <image x="350" y="300" width="50"  height="50" 
          xlink:href="../../resources/images/png2.png"/>
      </g>
  
      <g>
       <g style="fill:#eee">
           <rect  id="r1Show" x="100" y="375" width="100" height="50"
                  style="visibility:hidden"/></g>
        <g style="fill:gold">
           <rect  id="r2Show" x="150" y="375" width="100" height="50"
                  style="visibility:hidden"/></g>
        <g style="fill:crimson">
           <rect  id="r3Show" x="200" y="375" width="100" height="50"
                  style="visibility:hidden"/></g>
        <g style="fill:url(#grad)">
           <rect  id="r4Show" x="250" y="375" width="100" height="50"
                  style="visibility:hidden"/></g>
        <g><image id="i1Show" x="350" y="375" width="50" height="50" 
                  style="visibility:hidden"
                  xlink:href="../../resources/images/png2.png"/></g>
      </g>
    </g>
  </svg>
  
  
  
  1.14      +28 -22    xml-batik/sources/org/apache/batik/bridge/CursorManager.java
  
  Index: CursorManager.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/CursorManager.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- CursorManager.java	20 Aug 2004 19:29:46 -0000	1.13
  +++ CursorManager.java	12 Feb 2005 01:48:23 -0000	1.14
  @@ -150,14 +150,16 @@
       }
   
       /**
  -     * Returns a Cursor object for a given cursor value. This initial implementation
  -     * does not handle user-defined cursors, so it always uses the cursor at the 
  -     * end of the list
  +     * Returns a Cursor object for a given cursor value. This initial
  +     * implementation does not handle user-defined cursors, so it
  +     * always uses the cursor at the end of the list
        */
       public static Cursor getPredefinedCursor(String cursorName){
           return (Cursor)cursorMap.get(cursorName);
       }
   
  +
  +
       /**
        * Returns the Cursor corresponding to the input element's cursor property
        *
  @@ -210,27 +212,31 @@
               //
               // Handle 'auto' value.
               //
  -            // - <a> The following sets the cursor for <a> element enclosing
  -            //   text nodes. Setting the proper cursor (i.e., depending on the
  -            //   children's 'cursor' property, is handled in the SVGAElementBridge
  -            //   so as to avoid going up the tree on mouseover events (looking for
  -            //   an anchor ancestor.
  +            // - <a> The following sets the cursor for <a> element
  +            // enclosing text nodes. Setting the proper cursor (i.e.,
  +            // depending on the children's 'cursor' property, is
  +            // handled in the SVGAElementBridge so as to avoid going
  +            // up the tree on mouseover events (looking for an anchor
  +            // ancestor.
               //
  -            // - <image> The following does not change the cursor if the 
  -            //   element's cursor property is set to 'auto'. Otherwise, it takes
  -            //   precedence over any child (in case of SVG content) cursor setting.
  -            //   This means that for images referencing SVG content, a cursor 
  -            //   property set to 'auto' on the <image> element will not override

  -            //   the cursor settings inside the SVG image. Any other cursor property
  -            //   will take precedence.
  +            // - <image> The following does not change the cursor if
  +            // the element's cursor property is set to
  +            // 'auto'. Otherwise, it takes precedence over any child
  +            // (in case of SVG content) cursor setting.  This means
  +            // that for images referencing SVG content, a cursor
  +            // property set to 'auto' on the <image> element will not
  +            // override the cursor settings inside the SVG image. Any
  +            // other cursor property will take precedence.
               //
  -            // - <use> Same behavior as for <image> except that the behavior

  -            //   is controlled from the <use> element bridge (SVGUseElementBridge).
  +            // - <use> Same behavior as for <image> except that the
  +            // behavior is controlled from the <use> element bridge
  +            // (SVGUseElementBridge).
               //
  -            // - <text>, <tref> and <tspan> : a cursor value of auto
will cause the
  -            //   cursor to be set to a text cursor. Note that text content with an
  -            //   'auto' cursor and descendant of an anchor will have its cursor
  -            //   set to the anchor cursor through the SVGAElementBridge.
  +            // - <text>, <tref> and <tspan> : a cursor value of auto
  +            // will cause the cursor to be set to a text cursor. Note
  +            // that text content with an 'auto' cursor and descendant
  +            // of an anchor will have its cursor set to the anchor
  +            // cursor through the SVGAElementBridge.
               //
               String nameSpaceURI = e.getNamespaceURI();
               if (SVGConstants.SVG_NAMESPACE_URI.equals(nameSpaceURI)) {
  
  
  
  1.48      +41 -22    xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java
  
  Index: ScriptingEnvironment.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/bridge/ScriptingEnvironment.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- ScriptingEnvironment.java	6 Feb 2005 00:58:47 -0000	1.47
  +++ ScriptingEnvironment.java	12 Feb 2005 01:48:23 -0000	1.48
  @@ -25,6 +25,7 @@
   import java.io.OutputStreamWriter;
   import java.io.Reader;
   import java.io.StringReader;
  +import java.io.UnsupportedEncodingException;
   import java.io.Writer;
   
   import java.net.URL;
  @@ -37,6 +38,7 @@
   import java.util.zip.GZIPOutputStream;
   import java.util.zip.DeflaterOutputStream;
   
  +import org.apache.batik.dom.GenericDOMImplementation;
   import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
   import org.apache.batik.dom.svg.SVGOMDocument;
   import org.apache.batik.dom.util.SAXDocumentFactory;
  @@ -897,26 +899,34 @@
                           }
                       }
                   } catch (Exception exc) {
  -                    /* nothing */
  +                    /* nothing - try something else*/
                   }
               }
   
               // Parse as a generic XML document.
  -                    SAXDocumentFactory sdf = new SAXDocumentFactory
  -                        (doc.getImplementation(),
  -                         XMLResourceDescriptor.getXMLParserClassName());
  -                    try {
  +            SAXDocumentFactory sdf;
  +            if (doc != null) {
  +                sdf = new SAXDocumentFactory
  +                    (doc.getImplementation(),
  +                     XMLResourceDescriptor.getXMLParserClassName());
  +            } else {
  +                sdf = new SAXDocumentFactory
  +                    (new GenericDOMImplementation(),
  +                     XMLResourceDescriptor.getXMLParserClassName());
  +            }
  +            try {
                   Document d = sdf.createDocument(uri, new StringReader(text));
                   if (doc == null) 
                       return d;
   
                   Node result = doc.createDocumentFragment();
  -                        result.appendChild(doc.importNode(d.getDocumentElement(), true));
  +                result.appendChild(doc.importNode(d.getDocumentElement(), 
  +                                                  true));
                   return result;
  -                    } catch (Exception ext) {
  -                        if (userAgent != null)
  -                            userAgent.displayError(ext);
  -                    }
  +            } catch (Exception ext) {
  +                if (userAgent != null)
  +                    userAgent.displayError(ext);
  +            }
               
               return null;
           }
  @@ -929,6 +939,9 @@
               getURL(uri, h, null);
           }
   
  +        final static String DEFLATE="deflate";
  +        final static String GZIP   ="gzip";
  +        final static String UTF_8  ="UTF-8";
           /**
            * Implements {@link
            * org.apache.batik.script.Window#getURL(String,org.apache.batik.script.Window.URLResponseHandler,String)}.
  @@ -949,13 +962,18 @@
                               }
   
                               InputStream is = purl.openStream();
  -                            if (e == null)
  -                                e = purl.getContentEncoding();
                               Reader r;
  -                            if (e == null) 
  +                            if (e == null) {
  +                                // Not really a char encoding.
                                   r = new InputStreamReader(is);
  -                            else
  -                                r = new InputStreamReader(is, e);
  +                            } else {
  +                                try {
  +                                    r = new InputStreamReader(is, e);
  +                                } catch (UnsupportedEncodingException uee) {
  +                                    // Try with no encoding.
  +                                    r = new InputStreamReader(is);
  +                                }
  +                            }
                               r = new BufferedReader(r);
                               final StringBuffer sb = new StringBuffer();
                               int read;
  @@ -1002,9 +1020,6 @@
           }
   
   
  -        final static String DEFLATE="deflate";
  -        final static String GZIP   ="gzip";
  -
           public void postURL(String uri, String content, URLResponseHandler h) {
               postURL(uri, content, h, "text/plain", null);
           }
  @@ -1044,6 +1059,8 @@
                                           enc = enc.substring(DEFLATE.length()+1);
                                       else
                                           enc = "";
  +                                    conn.setRequestProperty("Content-Encoding",
  +                                                            DEFLATE);
                                   }
                                   if (enc.startsWith(GZIP)) {
                                       os = new GZIPOutputStream(os);
  @@ -1051,12 +1068,14 @@
                                           enc = enc.substring(GZIP.length()+1);
                                       else
                                           enc ="";
  +                                    conn.setRequestProperty("Content-Encoding",
  +                                                            DEFLATE);
                                   }
                                   if (enc.length() != 0) {
                                       e = EncodingUtilities.javaEncoding(enc);
  -                                    if (e == null) e = "UTF-8"; 
  +                                    if (e == null) e = UTF_8; 
                                   } else {
  -                                    e = enc;
  +                                    e = UTF_8;
                                   }
                               }
                               Writer w;
  @@ -1071,7 +1090,7 @@
   
                               InputStream is = conn.getInputStream();
                               Reader r;
  -                            e =  conn.getContentEncoding();
  +                            e = UTF_8;
                               if (e == null) 
                                   r = new InputStreamReader(is);
                               else
  
  
  
  1.24      +5 -7      xml-batik/sources/org/apache/batik/dom/AbstractParentNode.java
  
  Index: AbstractParentNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/AbstractParentNode.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- AbstractParentNode.java	20 Aug 2004 19:29:47 -0000	1.23
  +++ AbstractParentNode.java	12 Feb 2005 01:48:23 -0000	1.24
  @@ -745,12 +745,10 @@
   	public ExtendedNode append(ExtendedNode n) {
   	    if (lastChild == null) {
   		firstChild = n;
  -		lastChild  = n;
  -		children++;
  -		return n;
  -	    }
  -	    lastChild.setNextSibling(n);
  -	    n.setPreviousSibling(lastChild);
  +	    } else {
  +	      lastChild.setNextSibling(n);
  +              n.setPreviousSibling(lastChild);
  +            }
   	    lastChild = n;
   	    children++;
   	    return n;
  
  
  
  1.25      +100 -58   xml-batik/sources/org/apache/batik/dom/util/SAXDocumentFactory.java
  
  Index: SAXDocumentFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/dom/util/SAXDocumentFactory.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- SAXDocumentFactory.java	18 Nov 2004 01:46:58 -0000	1.24
  +++ SAXDocumentFactory.java	12 Feb 2005 01:48:23 -0000	1.25
  @@ -91,16 +91,26 @@
       protected Locator locator;
   
       /**
  -     * Whether the parser currently parses a CDATA section.
  +     * Contains collected string data.  May be Text, CDATA or Comment.
        */
  -    protected StringBuffer cdataBuffer;
  +    protected StringBuffer stringBuffer = new StringBuffer();
  +    /**
  +     * Indicates if stringBuffer has content, needed in case of 
  +     * zero sized "text" content.
  +     */
  +    protected boolean      stringContent;
   
       /**
  -     * Whether the parser currently parses a DTD.
  +     * True if the parser is currently parsing a DTD.
        */
       protected boolean inDTD;
   
       /**
  +     * True if the parser is currently parsing a CDATA section.
  +     */
  +    protected boolean inCDATA;
  +
  +    /**
        * Whether the parser is in validating mode.
        */
       protected boolean isValidating;
  @@ -388,9 +398,10 @@
               throw new IOException(e.getMessage());
   	}
   
  -        currentNode = null;
  +        currentNode  = null;
           Document ret = document;
  -        document = null;
  +        document     = null;
  +        locator      = null;
   	return ret;
       }
   
  @@ -437,6 +448,33 @@
           errorHandler = eh;
       }
   
  +    public DOMImplementation getDOMImplementation(String ver) {
  +        return implementation;
  +    }
  +
  +    /**
  +     * <b>SAX</b>: Implements {@link
  +     * org.xml.sax.ErrorHandler#fatalError(SAXParseException)}.
  +     */
  +    public void fatalError(SAXParseException ex) throws SAXException {
  +        throw ex;
  +    }
  +
  +    /**
  +     * <b>SAX</b>: Implements {@link
  +     * org.xml.sax.ErrorHandler#error(SAXParseException)}.
  +     */
  +    public void error(SAXParseException ex) throws SAXException {
  +	throw ex;
  +    }
  +
  +    /**
  +     * <b>SAX</b>: Implements {@link
  +     * org.xml.sax.ErrorHandler#warning(SAXParseException)}.
  +     */
  +    public void warning(SAXParseException ex) throws SAXException {
  +    }
  +
       /**
        * <b>SAX</b>: Implements {@link
        * org.xml.sax.ContentHandler#startDocument()}.
  @@ -448,9 +486,13 @@
   	namespaces.put("xmlns", XMLSupport.XMLNS_NAMESPACE_URI);
   	namespaces.put("", null);
   
  -        cdataBuffer = null;
  -        inDTD = false;
  +        inDTD       = false;
  +        inCDATA     = false;
           currentNode = null;
  +        document    = null;
  +
  +        stringBuffer.setLength(0);
  +        stringContent = false;
   
           if (createDocumentDescriptor) {
               documentDescriptor = new DocumentDescriptor();
  @@ -501,6 +543,9 @@
               }
   	}
   
  +        // Add any collected String Data before element.
  +        appendStringData();
  +
   	// Element creation
   	Element e;
   	int idx = rawName.indexOf(':');
  @@ -547,43 +592,35 @@
   	}
       }
   
  -    public DOMImplementation getDOMImplementation(String ver) {
  -        return implementation;
  -    }
  -
  -    /**
  -     * <b>SAX</b>: Implements {@link
  -     * org.xml.sax.ErrorHandler#fatalError(SAXParseException)}.
  -     */
  -    public void fatalError(SAXParseException ex) throws SAXException {
  -        throw ex;
  -    }
  -
  -    /**
  -     * <b>SAX</b>: Implements {@link
  -     * org.xml.sax.ErrorHandler#error(SAXParseException)}.
  -     */
  -    public void error(SAXParseException ex) throws SAXException {
  -	throw ex;
  -    }
  -
  -    /**
  -     * <b>SAX</b>: Implements {@link
  -     * org.xml.sax.ErrorHandler#warning(SAXParseException)}.
  -     */
  -    public void warning(SAXParseException ex) throws SAXException {
  -    }
  -
       /**
        * <b>SAX</b>: Implements {@link
        * org.xml.sax.ContentHandler#endElement(String,String,String)}.
        */
       public void endElement(String uri, String localName, String rawName)
   	throws SAXException {
  +        appendStringData(); // add string data if any.
  +
           if (currentNode != null)
               currentNode = currentNode.getParentNode();
   	namespaces.pop();
       }
  +
  +    public void appendStringData() {
  +        if (!stringContent) return;
  +
  +        String str = stringBuffer.toString();
  +        stringBuffer.setLength(0); // reuse buffer.
  +        stringContent = false;
  +        if (currentNode == null) {
  +            if (inCDATA) preInfo.add(new CDataInfo(str));
  +            else         preInfo.add(new TextInfo(str));
  +        } else {
  +            Node n;
  +            if (inCDATA) n = document.createCDATASection(str);
  +            else         n = document.createTextNode(str);
  +            currentNode.appendChild(n);
  +        }
  +    }
       
       /**
        * <b>SAX</b>: Implements {@link
  @@ -591,18 +628,23 @@
        */
       public void characters(char ch[], int start, int length)
           throws SAXException {
  -        if (cdataBuffer != null) 
  -            cdataBuffer.append(ch, start, length);
  -        else {
  -            String data = new String(ch, start, length);
  -            if (currentNode == null) {
  -                preInfo.add(new TextInfo(data));
  -            } else {
  -                currentNode.appendChild(document.createTextNode(data));
  -            }
  -        }
  +        stringBuffer.append(ch, start, length);
  +        stringContent = true;
       }
  -    
  +
  +
  +    /**
  +     * <b>SAX</b>: Implements {@link
  +     * org.xml.sax.ContentHandler#ignorableWhitespace(char[],int,int)}.
  +     */
  +    public void ignorableWhitespace(char[] ch,
  +                                    int start,
  +                                    int length)
  +        throws SAXException {
  +        stringBuffer.append(ch, start, length);
  +        stringContent = true;
  +    }
  +
       /**
        * <b>SAX</b>: Implements {@link
        * org.xml.sax.ContentHandler#processingInstruction(String,String)}.
  @@ -611,6 +653,9 @@
           throws SAXException {
   	if (inDTD)
               return;
  +        
  +        appendStringData(); // Add any collected String Data before PI
  +
           if (currentNode == null)
               preInfo.add(new ProcessingInstructionInfo(target, data));
           else
  @@ -626,6 +671,7 @@
        */
       public void startDTD(String name, String publicId, String systemId)
   	throws SAXException {
  +        appendStringData(); // Add collected string data before entering DTD
   	inDTD = true;
       }
   
  @@ -655,7 +701,9 @@
        * org.xml.sax.ext.LexicalHandler#startCDATA()}.
        */
       public void startCDATA() throws SAXException {
  -        cdataBuffer = new StringBuffer();
  +        appendStringData(); // Add any collected String Data before CData
  +        inCDATA       = true;
  +        stringContent = true; // always create CDATA even if empty.
       }
   
       /**
  @@ -663,13 +711,8 @@
        * org.xml.sax.ext.LexicalHandler#endCDATA()}.
        */
       public void endCDATA() throws SAXException {
  -        String data = cdataBuffer.toString();
  -        if (currentNode == null) {
  -            preInfo.add(new CDataInfo(data));
  -        } else {
  -            currentNode.appendChild(document.createCDATASection(data));
  -        }
  -        cdataBuffer = null;
  +        appendStringData(); // Add the CDATA section
  +        inCDATA = false;
       }
   
       /**
  @@ -677,14 +720,13 @@
        * {@link org.xml.sax.ext.LexicalHandler#comment(char[],int,int)}.
        */
       public void comment(char ch[], int start, int length) throws SAXException {
  -	if (inDTD) 
  -            return;
  +	if (inDTD) return;
  +
           String str = new String(ch, start, length);
           if (currentNode == null) {
               preInfo.add(new CommentInfo(str));
           } else {
  -            currentNode.appendChild
  -                (document.createComment(str));
  +            currentNode.appendChild(document.createComment(str));
           }
       }
   }
  
  
  
  1.57      +7 -9      xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java
  
  Index: AbstractGraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/AbstractGraphicsNode.java,v
  retrieving revision 1.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- AbstractGraphicsNode.java	8 Feb 2005 11:11:24 -0000	1.56
  +++ AbstractGraphicsNode.java	12 Feb 2005 01:48:23 -0000	1.57
  @@ -260,8 +260,8 @@
        */
       public void setVisible(boolean isVisible) {
           fireGraphicsNodeChangeStarted();
  -        invalidateGeometryCache();
           this.isVisible = isVisible;
  +        invalidateGeometryCache();
           fireGraphicsNodeChangeCompleted();
       }
   
  @@ -430,6 +430,8 @@
               if (ac.getAlpha() < 0.001)
                   return;         // No point in drawing
           }
  +        Rectangle2D bounds = getBounds();
  +        if (bounds == null) return;
   
           // Set up graphic context. It is important to setup the
           // transform first, because the clip is defined in this node's
  @@ -460,16 +462,12 @@
           // Check if any painting is needed at all. Get the clip (in user space)
           // and see if it intersects with this node's bounds (in user space).
           boolean paintNeeded = true;
  -        Rectangle2D bounds = getBounds();
           Shape g2dClip = curClip; //g2d.getClip();
           if (g2dClip != null) {
  -            Rectangle2D clipBounds = g2dClip.getBounds2D();
  -            if(bounds != null && !bounds.intersects(clipBounds.getX(),
  -                                                    clipBounds.getY(),
  -                                                    clipBounds.getWidth(),
  -                                                    clipBounds.getHeight())){
  +            Rectangle2D cb = g2dClip.getBounds2D();
  +            if(!bounds.intersects(cb.getX(),     cb.getY(),
  +                                  cb.getWidth(), cb.getHeight()))
                   paintNeeded = false;
  -            }
           }
   
           // Only paint if needed.
  
  
  
  1.42      +11 -5     xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java
  
  Index: CompositeGraphicsNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/CompositeGraphicsNode.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- CompositeGraphicsNode.java	6 Feb 2005 00:58:48 -0000	1.41
  +++ CompositeGraphicsNode.java	12 Feb 2005 01:48:23 -0000	1.42
  @@ -42,7 +42,8 @@
   public class CompositeGraphicsNode extends AbstractGraphicsNode 
       implements List {
   
  -    public static final Rectangle2D VIEWPORT = new Rectangle(0, 0, 0, 0);
  +    public static final Rectangle2D VIEWPORT  = new Rectangle();
  +    public static final Rectangle2D NULL_RECT = new Rectangle();
   
       /**
        * The children of this composite graphics node.
  @@ -186,17 +187,22 @@
        * Returns the bounds of the area covered by this node's primitive paint.
        */
       public Rectangle2D getPrimitiveBounds() {
  -        if (primitiveBounds != null) 
  +        if (primitiveBounds != null) {
  +            if (primitiveBounds == NULL_RECT) return null;
               return primitiveBounds;
  +        }
   
           int i=0;
           Rectangle2D bounds = null;
           while ((bounds == null) && i < count) {
               bounds = children[i++].getTransformedBounds(IDENTITY);
           }
  -        if (bounds == null) return null;
  +        if (bounds == null) {
  +            primitiveBounds = NULL_RECT;
  +            return null;
  +        }
  +
           primitiveBounds = bounds;
  -        
           Rectangle2D ctb = null;
           while (i < count) {
               ctb = children[i++].getTransformedBounds(IDENTITY);
  
  
  
  1.19      +7 -1      xml-batik/sources/org/apache/batik/gvt/ImageNode.java
  
  Index: ImageNode.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/ImageNode.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ImageNode.java	18 Aug 2004 07:14:26 -0000	1.18
  +++ ImageNode.java	12 Feb 2005 01:48:24 -0000	1.19
  @@ -19,6 +19,7 @@
   
   import java.awt.Graphics2D;
   import java.awt.geom.Point2D;
  +import java.awt.geom.Rectangle2D;
   
   /**
    * A graphics node that represents an image described as a graphics node.
  @@ -38,9 +39,14 @@
       public void setVisible(boolean isVisible) {
           fireGraphicsNodeChangeStarted();
           this.isVisible = isVisible;
  +        invalidateGeometryCache();
           fireGraphicsNodeChangeCompleted();
       }
   
  +    public Rectangle2D getPrimitiveBounds() {
  +        if (!isVisible)    return null;
  +        return super.getPrimitiveBounds();
  +    }
       /**
        * If hitCheckChildren is true then nodeHitAt will return
        * child nodes of this image. Otherwise it will only
  
  
  
  1.23      +10 -4     xml-batik/sources/org/apache/batik/gvt/UpdateTracker.java
  
  Index: UpdateTracker.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/UpdateTracker.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- UpdateTracker.java	30 Oct 2004 18:38:05 -0000	1.22
  +++ UpdateTracker.java	12 Feb 2005 01:48:24 -0000	1.23
  @@ -19,6 +19,7 @@
   package org.apache.batik.gvt;
   
   import java.awt.Shape;
  +import java.awt.Rectangle;
   import java.awt.geom.AffineTransform;
   import java.awt.geom.Rectangle2D;
   import java.lang.ref.WeakReference;
  @@ -42,6 +43,7 @@
   
       Map dirtyNodes = null;
       Map fromBounds = new HashMap();
  +    protected static Rectangle2D NULL_RECT = new Rectangle();
   
       public UpdateTracker(){
       }
  @@ -142,7 +144,7 @@
                   //       srcORgn + "\n" + srcNRgn + "\n");
                   // <!>
                   Shape oRgn = srcORgn;
  -                if (oRgn != null) {
  +                if ((oRgn != null) && (oRgn != NULL_RECT)) {
                       if (oat != null)
                           oRgn = oat.createTransformedShape(srcORgn);
                       // System.err.println("GN: " + srcGN);
  @@ -188,7 +190,7 @@
                   GraphicsNode childGN = (GraphicsNode)iter.next();
                   Rectangle2D r2d = getNodeDirtyRegion(childGN, at);
                   if (r2d != null) {
  -                    if (ret == null) ret = r2d;
  +                    if ((ret == null) || (ret == NULL_RECT)) ret = r2d;
                       else ret = ret.createUnion(r2d);
                   }
               }
  @@ -196,6 +198,8 @@
               ret = (Rectangle2D)fromBounds.remove(gnWRef);
               if (ret == null) 
                   ret = gn.getBounds();
  +            else if (ret == NULL_RECT) 
  +                ret = null;
               if (ret != null)
                   ret = at.createTransformedShape(ret).getBounds2D();
           }
  @@ -244,7 +248,7 @@
           // Add this dirty region to any existing dirty region.
           Rectangle2D r2d = (Rectangle2D)fromBounds.remove(gnWRef);
           if (rgn != null) {
  -            if (r2d != null) {
  +            if ((r2d != null) && (r2d != NULL_RECT)) {
                   // System.err.println("GN: " + gn);
                   // System.err.println("R2d: " + r2d);
                   // System.err.println("Rgn: " + rgn);
  @@ -260,6 +264,8 @@
           // }
   
           // Store the bounds for the future.
  +        if (r2d == null)
  +            r2d = NULL_RECT;
           fromBounds.put(gnWRef, r2d);
       }
   
  
  
  
  1.16      +14 -2     xml-batik/sources/org/apache/batik/gvt/filter/GraphicsNodeRed8Bit.java
  
  Index: GraphicsNodeRed8Bit.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/filter/GraphicsNodeRed8Bit.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- GraphicsNodeRed8Bit.java	18 Aug 2004 07:14:33 -0000	1.15
  +++ GraphicsNodeRed8Bit.java	12 Feb 2005 01:48:24 -0000	1.16
  @@ -87,7 +87,7 @@
           Rectangle   bounds = at.createTransformedShape(bounds2D).getBounds();
           // System.out.println("Bounds: " + bounds);
   
  -        ColorModel cm = GraphicsUtil.sRGB_Unpre;
  +        ColorModel cm = createColorModel();
   
           int defSz = AbstractTiledRed.getDefaultTileSize();
   
  @@ -144,6 +144,18 @@
   
           g.dispose();
       }
  +
  +    static final boolean onMacOSX;
  +    static {
  +        // This should be OK for applets.
  +        onMacOSX = ("Mac OS X".equals(System.getProperty("os.name")));
  +    }
  +
  +    public ColorModel createColorModel() {
  +        if (onMacOSX)
  +            return GraphicsUtil.sRGB_Pre;
  +        return GraphicsUtil.sRGB_Unpre;
  +    }
   }
   
   
  
  
  
  1.48      +2 -1      xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java
  
  Index: JGVTComponent.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/swing/gvt/JGVTComponent.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- JGVTComponent.java	30 Nov 2004 03:23:58 -0000	1.47
  +++ JGVTComponent.java	12 Feb 2005 01:48:24 -0000	1.48
  @@ -199,6 +199,7 @@
        */
       public JGVTComponent(boolean eventsEnabled, boolean selectableText) {
           setBackground(Color.white);
  +        // setDoubleBuffered(false);
   
           this.eventsEnabled = eventsEnabled;
           this.selectableText = selectableText;
  
  
  
  1.8       +73 -35    xml-batik/sources/org/apache/batik/util/gui/DOMViewer.java
  
  Index: DOMViewer.java
  ===================================================================
  RCS file: /home/cvs/xml-batik/sources/org/apache/batik/util/gui/DOMViewer.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DOMViewer.java	18 Aug 2004 07:15:53 -0000	1.7
  +++ DOMViewer.java	12 Feb 2005 01:48:24 -0000	1.8
  @@ -22,6 +22,9 @@
   import java.awt.FlowLayout;
   import java.awt.GridLayout;
   import java.awt.event.ActionEvent;
  +import java.awt.event.ItemEvent;
  +import java.awt.event.ItemListener;
  +
   import java.util.ArrayList;
   import java.util.Collections;
   import java.util.HashMap;
  @@ -33,6 +36,7 @@
   import javax.swing.Action;
   import javax.swing.BorderFactory;
   import javax.swing.ImageIcon;
  +import javax.swing.JCheckBox;
   import javax.swing.JFrame;
   import javax.swing.JPanel;
   import javax.swing.JScrollPane;
  @@ -98,6 +102,8 @@
        */
       protected Panel panel = new Panel();
   
  +    protected boolean showWhitespace = true;
  +
       /**
        * Creates a new DOMViewer panel.
        */
  @@ -110,12 +116,31 @@
   	
   	getContentPane().add(panel);
   
  -        JPanel p = new JPanel(new FlowLayout(FlowLayout.RIGHT));
  +        JPanel p = new JPanel(new BorderLayout());
  +        
  +        JCheckBox cb = new JCheckBox("Show Whitespace Text Nodes");
  +        cb.setSelected(showWhitespace);
  +        cb.addItemListener(new ItemListener() {
  +                public void itemStateChanged(ItemEvent ie) {
  +                    setShowWhitespace
  +                        (ie.getStateChange() == ItemEvent.SELECTED);
  +                }
  +            });
  +
  +        p.add(cb, BorderLayout.WEST);
  +        
  +
           ButtonFactory bf = new ButtonFactory(bundle, this);
  -        p.add(bf.createJButton("CloseButton"));
  +        p.add(bf.createJButton("CloseButton"), BorderLayout.EAST);
   	getContentPane().add("South", p);
       }
   
  +    public void setShowWhitespace(boolean state) {
  +        showWhitespace = state;
  +        if (panel.document != null)
  +            panel.setDocument(panel.document);
  +    }
  +
       /**
        * Sets the document to display.
        */
  @@ -152,7 +177,7 @@
       /**
        * The panel that contains the viewer.
        */
  -    public static class Panel extends JPanel {
  +    public class Panel extends JPanel {
   	/**
   	 * The DOM document.
   	 */
  @@ -314,7 +339,7 @@
   	public void setDocument(Document doc, ViewCSS view) {
   	    document = doc;
   	    viewCSS  = view;
  -	    TreeNode root = createTree(doc);
  +	    TreeNode root = createTree(doc, showWhitespace);
   	    ((DefaultTreeModel)tree.getModel()).setRoot(root);
   	    if (rightPanel.getComponentCount() != 0) {
   		rightPanel.remove(0);
  @@ -326,13 +351,19 @@
   	/**
   	 * Creates a swing tree from a DOM document.
   	 */
  -	protected static MutableTreeNode createTree(Node node) {
  +	protected MutableTreeNode createTree(Node node, 
  +                                             boolean showWhitespace) {
   	    DefaultMutableTreeNode result;
   	    result = new DefaultMutableTreeNode(new NodeInfo(node));
   	    for (Node n = node.getFirstChild();
                    n != null;
                    n = n.getNextSibling()) {
  -		result.add(createTree(n));
  +                if (!showWhitespace && (n instanceof org.w3c.dom.Text)) {
  +                    String txt = n.getNodeValue();
  +                    if (txt.trim().length() == 0)
  +                        continue;
  +                }
  +                    result.add(createTree(n, showWhitespace));
   	    }
   	    return result;
   	}
  @@ -630,35 +661,42 @@
   	    }
   	}
       
  -	/**
  -	 * To store the nodes informations
  -	 */
  -	protected static class NodeInfo {
  -	    /**
  -	     * The DOM node.
  -	     */
  -	    protected Node node;
  +    } // class Panel
   
  -	    /**
  -	     * Creates a new NodeInfo object.
  -	     */
  -	    public NodeInfo(Node n) {
  -		node = n;
  -	    }
  +    /**
  +     * To store the nodes informations
  +     */
  +    protected static class NodeInfo {
  +        /**
  +         * The DOM node.
  +         */
  +        protected Node node;
  +
  +        /**
  +         * Creates a new NodeInfo object.
  +         */
  +        public NodeInfo(Node n) {
  +            node = n;
  +        }
   
  -	    /**
  -	     * Returns the DOM Node associated with this node info.
  -	     */
  -	    public Node getNode() {
  -		return node;
  -	    }
  +        /**
  +         * Returns the DOM Node associated with this node info.
  +         */
  +        public Node getNode() {
  +            return node;
  +        }
   
  -	    /**
  -	     * Returns a printable representation of the object.
  -	     */
  -	    public String toString() {
  -		return node.getNodeName();
  -	    }
  -	}
  -    } // class Panel
  +        /**
  +         * Returns a printable representation of the object.
  +         */
  +        public String toString() {
  +            if (node instanceof Element) {
  +                String id = ((Element)node).getAttribute("id");
  +                if (id.length() != 0) {
  +                    return node.getNodeName() + " \""+id+"\"";
  +                }
  +            }
  +            return node.getNodeName();
  +        }
  +    }
   }
  
  
  
  1.125     +2 -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.124
  retrieving revision 1.125
  diff -u -r1.124 -r1.125
  --- samplesRendering.xml	3 Jan 2005 10:48:06 -0000	1.124
  +++ samplesRendering.xml	12 Feb 2005 01:48:24 -0000	1.125
  @@ -430,5 +430,6 @@
           <test id="samples/tests/spec/scripting/styling.svg" />
           <test id="samples/tests/spec/scripting/text_content.svg" />
           <test id="samples/tests/spec/scripting/textProperties2.svg" />
  +        <test id="samples/tests/spec/scripting/visibilityOnClick.svg" />
       </testGroup>
   </testSuite>
  
  
  

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