deweese 2004/09/24 03:56:37 Modified: sources/org/apache/batik Version.java sources/org/apache/batik/gvt GVTTreeWalker.java Log: 1) GVT Tree walker can now be given any node in the GVT tree and it walk just that subtree. 2) Fixed header on Version.java Revision Changes Path 1.3 +15 -47 xml-batik/sources/org/apache/batik/Version.java Index: Version.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/Version.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- Version.java 8 Aug 2003 11:38:49 -0000 1.2 +++ Version.java 24 Sep 2004 10:56:36 -0000 1.3 @@ -1,52 +1,20 @@ /* - ============================================================================ - The Apache Software License, Version 1.1 - ============================================================================ + Copyright 2003 The Apache Software Foundation - Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. + 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 - Redistribution and use in source and binary forms, with or without modifica- - tion, are permitted provided that the following conditions are met: + http://www.apache.org/licenses/LICENSE-2.0 - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + 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. - 2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - 3. The end-user documentation included with the redistribution, if any, must - include the following acknowledgment: "This product includes software - developed by the Apache Software Foundation (http://www.apache.org/)." - Alternately, this acknowledgment may appear in the software itself, if - and wherever such third-party acknowledgments normally appear. - - 4. The names "Batik" and "Apache Software Foundation" must not be - used to endorse or promote products derived from this software without - prior written permission. For written permission, please contact - [EMAIL PROTECTED] - - 5. Products derived from this software may not be called "Apache", nor may - "Apache" appear in their name, without prior written permission of the - Apache Software Foundation. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND - FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- - DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - This software consists of voluntary contributions made by many individuals - on behalf of the Apache Software Foundation. For more information on the - Apache Software Foundation, please see <http://www.apache.org/>. - -*/ + */ package org.apache.batik; 1.4 +53 -35 xml-batik/sources/org/apache/batik/gvt/GVTTreeWalker.java Index: GVTTreeWalker.java =================================================================== RCS file: /home/cvs/xml-batik/sources/org/apache/batik/gvt/GVTTreeWalker.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- GVTTreeWalker.java 18 Aug 2004 07:14:26 -0000 1.3 +++ GVTTreeWalker.java 24 Sep 2004 10:56:37 -0000 1.4 @@ -30,23 +30,34 @@ /** The GVT root into which text is searched. */ protected GraphicsNode gvtRoot; + /** The root of the subtree of the GVT which is traversed. */ + protected GraphicsNode treeRoot; + /** The current GraphicsNode. */ protected GraphicsNode currentNode; /** * Constructs a new <tt>GVTTreeWalker</tt>. * - * @param gvtRoot the graphics node root + * @param treeRoot the top of the graphics node tree to search */ - public GVTTreeWalker(GraphicsNode gvtRoot) { - this.gvtRoot = gvtRoot; - currentNode = gvtRoot; + public GVTTreeWalker(GraphicsNode treeRoot) { + this.gvtRoot = treeRoot.getRoot(); + this.treeRoot = treeRoot; + this.currentNode = treeRoot; } /** * Returns the root graphics node. */ public GraphicsNode getRoot() { + return treeRoot; + } + + /** + * Returns the GVT root graphics node. + */ + public GraphicsNode getGVTRoot() { return gvtRoot; } @@ -54,8 +65,8 @@ * Sets the current GraphicsNode to the specified node. * * @param node the new current graphics node - * @exception IllegalArgumentException if the node is not part of the GVT Tree - * this walker is dedicated to + * @exception IllegalArgumentException if the node is not part of + * the GVT Tree this walker is dedicated to */ public void setCurrentGraphicsNode(GraphicsNode node) { if (node.getRoot() != gvtRoot) { @@ -73,8 +84,9 @@ } /** - * Returns the previous <tt>GraphicsNode</tt>. If the current graphics node - * does not have a previous node, returns null and retains the current node. + * Returns the previous <tt>GraphicsNode</tt>. If the current + * graphics node does not have a previous node, returns null and + * retains the current node. */ public GraphicsNode previousGraphicsNode() { GraphicsNode result = getPreviousGraphicsNode(currentNode); @@ -85,8 +97,9 @@ } /** - * Returns the next <tt>GraphicsNode</tt>. If the current graphics node does - * not have a next node, returns null and retains the current node. + * Returns the next <tt>GraphicsNode</tt>. If the current graphics + * node does not have a next node, returns null and retains the + * current node. */ public GraphicsNode nextGraphicsNode() { GraphicsNode result = getNextGraphicsNode(currentNode); @@ -97,10 +110,14 @@ } /** - * Returns the parent of the current <tt>GraphicsNode</tt>. If the current - * graphics node has no parent, returns null and retains the current node. + * Returns the parent of the current <tt>GraphicsNode</tt>. If the + * current graphics node has no parent, returns null and retains + * the current node. */ public GraphicsNode parentGraphicsNode() { + // Don't ascend above treeRoot. + if (currentNode == treeRoot) return null; + GraphicsNode result = currentNode.getParent(); if (result != null) { currentNode = result; @@ -109,9 +126,9 @@ } /** - * Returns the next sibling of the current <tt>GraphicsNode</tt>. If the - * current graphics node does not have a next sibling, returns null and - * retains the current node. + * Returns the next sibling of the current + * <tt>GraphicsNode</tt>. If the current graphics node does not + * have a next sibling, returns null and retains the current node. */ public GraphicsNode getNextSibling() { GraphicsNode result = getNextSibling(currentNode); @@ -122,9 +139,10 @@ } /** - * Returns the next previous of the current <tt>GraphicsNode</tt>. If the - * current graphics node does not have a previous sibling, returns null and - * retains the current node. + * Returns the next previous of the current + * <tt>GraphicsNode</tt>. If the current graphics node does not + * have a previous sibling, returns null and retains the current + * node. */ public GraphicsNode getPreviousSibling() { GraphicsNode result = getPreviousSibling(currentNode); @@ -135,9 +153,9 @@ } /** - * Returns the first child of the current <tt>GraphicsNode</tt>. If the - * current graphics node does not have a first child, returns null and - * retains the current node. + * Returns the first child of the current + * <tt>GraphicsNode</tt>. If the current graphics node does not + * have a first child, returns null and retains the current node. */ public GraphicsNode firstChild() { GraphicsNode result = getFirstChild(currentNode); @@ -148,9 +166,9 @@ } /** - * Returns the last child of the current <tt>GraphicsNode</tt>. If the - * current graphics node does not have a last child, returns null and - * retains the current node. + * Returns the last child of the current <tt>GraphicsNode</tt>. If + * the current graphics node does not have a last child, returns + * null and retains the current node. */ public GraphicsNode lastChild() { GraphicsNode result = getLastChild(currentNode); @@ -160,10 +178,10 @@ return result; } - //////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// - private GraphicsNode getNextGraphicsNode(GraphicsNode node) { + protected GraphicsNode getNextGraphicsNode(GraphicsNode node) { if (node == null) { return null; } @@ -181,7 +199,7 @@ // Go to the first sibling of one of the ancestors n = node; - while ((n = n.getParent()) != null && n != gvtRoot) { + while ((n = n.getParent()) != null && n != treeRoot) { GraphicsNode t = getNextSibling(n); if (t != null) { return t; @@ -190,13 +208,13 @@ return null; } - private GraphicsNode getPreviousGraphicsNode(GraphicsNode node) { + protected GraphicsNode getPreviousGraphicsNode(GraphicsNode node) { if (node == null) { return null; } // The previous of root is null - if (node == gvtRoot) { + if (node == treeRoot) { return null; } @@ -215,7 +233,7 @@ return n; } - private static GraphicsNode getLastChild(GraphicsNode node) { + protected static GraphicsNode getLastChild(GraphicsNode node) { if (!(node instanceof CompositeGraphicsNode)) { return null; } @@ -231,7 +249,7 @@ } } - private static GraphicsNode getPreviousSibling(GraphicsNode node) { + protected static GraphicsNode getPreviousSibling(GraphicsNode node) { CompositeGraphicsNode parent = node.getParent(); if (parent == null) { return null; @@ -248,7 +266,7 @@ } } - private static GraphicsNode getFirstChild(GraphicsNode node) { + protected static GraphicsNode getFirstChild(GraphicsNode node) { if (!(node instanceof CompositeGraphicsNode)) { return null; } @@ -264,7 +282,7 @@ } } - private static GraphicsNode getNextSibling(GraphicsNode node) { + protected static GraphicsNode getNextSibling(GraphicsNode node) { CompositeGraphicsNode parent = node.getParent(); if (parent == null) { return null;
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]