[FOray-commit] SF.net SVN: foray: [9703] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-06-06 16:30:46
|
Revision: 9703
http://svn.sourceforge.net/foray/?rev=9703&view=rev
Author: victormote
Date: 2007-06-06 09:27:11 -0700 (Wed, 06 Jun 2007)
Log Message:
-----------
Conform to axsl changes in the inheritance structure of the tree structures, including moving the OrderedTreeNode interface from axsl to foray.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBorder.java
trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java
trunk/foray/foray-common/src/java/org/foray/common/AbstractOrderedTreeNode.java
trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java
trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java
trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java
Added Paths:
-----------
trunk/foray/foray-common/src/java/org/foray/common/OrderedTreeNode.java
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java 2007-06-06 15:29:53 UTC (rev 9702)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java 2007-06-06 16:27:11 UTC (rev 9703)
@@ -37,9 +37,8 @@
import org.foray.area.RegionRABody;
import org.foray.area.SpanRA;
import org.foray.area.TextArea;
+import org.foray.common.OrderedTreeNode;
-import org.axsl.common.OrderedTreeNode;
-
import java.util.Iterator;
import junit.framework.TestCase;
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-06-06 15:29:53 UTC (rev 9702)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBlock.java 2007-06-06 16:27:11 UTC (rev 9703)
@@ -33,10 +33,9 @@
import org.foray.area.NormalBlockArea;
import org.foray.area.NormalFlowRA;
import org.foray.area.PageCollection;
+import org.foray.common.OrderedTreeNode;
import org.foray.core.FOrayException;
-import org.axsl.common.OrderedTreeNode;
-
/**
* Tests of various block-related concepts at the Area Tree level.
*/
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBorder.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBorder.java 2007-06-06 15:29:53 UTC (rev 9702)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/TestBorder.java 2007-06-06 16:27:11 UTC (rev 9703)
@@ -31,10 +31,9 @@
import org.foray.area.AreaTree;
import org.foray.area.NormalBlockArea;
import org.foray.area.NormalFlowRA;
+import org.foray.common.OrderedTreeNode;
import org.foray.core.FOrayException;
-import org.axsl.common.OrderedTreeNode;
-
/**
* Tests of various border-related concepts at the Area Tree level.
*/
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java 2007-06-06 15:29:53 UTC (rev 9702)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/NormalBlockArea.java 2007-06-06 16:27:11 UTC (rev 9703)
@@ -268,7 +268,7 @@
* actually have children. If the FONode has no children, then an empty
* area is needed in the area tree. */
if (! this.hasChildren()
- && this.traitGeneratedBy().hasChildren()) {
+ && this.traitGeneratedBy().getChildCount() != 0) {
return true;
}
return false;
Modified: trunk/foray/foray-common/src/java/org/foray/common/AbstractOrderedTreeNode.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/AbstractOrderedTreeNode.java 2007-06-06 15:29:53 UTC (rev 9702)
+++ trunk/foray/foray-common/src/java/org/foray/common/AbstractOrderedTreeNode.java 2007-06-06 16:27:11 UTC (rev 9703)
@@ -46,7 +46,7 @@
* However, the data portion of that class was not deemed suitable.</p>
*/
public abstract class AbstractOrderedTreeNode
- implements org.axsl.common.OrderedTreeNode {
+ implements OrderedTreeNode {
/**
* Constructor.
Added: trunk/foray/foray-common/src/java/org/foray/common/OrderedTreeNode.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/OrderedTreeNode.java (rev 0)
+++ trunk/foray/foray-common/src/java/org/foray/common/OrderedTreeNode.java 2007-06-06 16:27:11 UTC (rev 9703)
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * 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.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.common;
+
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
+
+/**
+ * A {@link TreeNode} that is aware of its relationships not only to its parents
+ * and children, but also to its siblings.
+ * The order and placement of children is significant.
+ */
+public interface OrderedTreeNode extends TreeNode {
+
+ /**
+ * Returns this node's position within the siblings.
+ * @return The index to "this" in the parent's children.
+ */
+ int siblingIndex();
+
+ /**
+ * Returns the previous sibling node.
+ * @return Return the sibling immediately preceding "this" in the parent's
+ * children, or null if this is the first child.
+ */
+ OrderedTreeNode getPreviousSibling();
+
+ /**
+ * Returns the next sibling node.
+ * @return Return the sibling immediately following "this" in the parent's
+ * children, or null if this is the last child.
+ */
+ OrderedTreeNode getNextSibling();
+
+ /**
+ * Reports whether this node has any children.
+ * @return True if this node has any children, false if it has none.
+ */
+ boolean hasChildren();
+
+ /**
+ * Returns the first child of this node.
+ * @return The first child of this node, or null if this node has no
+ * children.
+ */
+ OrderedTreeNode getFirstChild();
+
+ /**
+ * Returns the last child of this node.
+ * @return The last child of this node, or null if this node has no
+ * children.
+ */
+ OrderedTreeNode getLastChild();
+
+ /**
+ * Returns the next node in the tree relative to the current node, in
+ * pre-order traversal order. This is also known as breadth-first order.
+ * @return The next pre-order node, or null if there is none.
+ */
+ OrderedTreeNode nextPreOrderNode();
+
+ /**
+ * Returns the next node in the tree relative to the current node, in
+ * post-order traversal order. This is also known as depth-first order.
+ * @return The next post-order node, or null if there is none.
+ */
+ OrderedTreeNode nextPostOrderNode();
+
+ /**
+ * Finds and returns the first leaf that is a descendant of this node --
+ * either this node or its first child's first leaf.
+ * Returns this node if it is a leaf.
+ * (Liberated from {@link DefaultMutableTreeNode}).
+ *
+ * @see TreeNode#isLeaf
+ * @see DefaultMutableTreeNode#isNodeDescendant
+ * @return the first leaf in the subtree rooted at this node
+ */
+ OrderedTreeNode getFirstLeaf();
+
+
+ /**
+ * Finds and returns the last leaf that is a descendant of this node --
+ * either this node or its last child's last leaf.
+ * Returns this node if it is a leaf.
+ * (Liberated from {@link DefaultMutableTreeNode}).
+ *
+ * @see TreeNode#isLeaf
+ * @see DefaultMutableTreeNode#isNodeDescendant
+ * @return the last leaf in the subtree rooted at this node
+ */
+ OrderedTreeNode getLastLeaf();
+
+ /**
+ * Returns the leaf after this node or null if this node is the
+ * last leaf in the tree.
+ * <p>
+ * In this implementation of the <code>MutableNode</code> interface,
+ * this operation is very inefficient. In order to determine the
+ * next node, this method first performs a linear search in the
+ * parent's child-list in order to find the current node.
+ * <p>
+ * That implementation makes the operation suitable for short
+ * traversals from a known position. But to traverse all of the
+ * leaves in the tree, you should use <code>depthFirstEnumeration</code>
+ * to enumerate the nodes in the tree and use <code>isLeaf</code>
+ * on each node to determine which are leaves.
+ * (Liberated from {@link DefaultMutableTreeNode}).
+ *
+ * @see DefaultMutableTreeNode#depthFirstEnumeration
+ * @see TreeNode#isLeaf
+ * @return returns the next leaf past this node
+ */
+ OrderedTreeNode getNextLeaf();
+
+
+ /**
+ * Returns the leaf before this node or null if this node is the
+ * first leaf in the tree.
+ * <p>
+ * In this implementation of the <code>MutableNode</code> interface,
+ * this operation is very inefficient. In order to determine the
+ * previous node, this method first performs a linear search in the
+ * parent's child-list in order to find the current node.
+ * <p>
+ * That implementation makes the operation suitable for short
+ * traversals from a known position. But to traverse all of the
+ * leaves in the tree, you should use <code>depthFirstEnumeration</code>
+ * to enumerate the nodes in the tree and use <code>isLeaf</code>
+ * on each node to determine which are leaves.
+ * (Liberated from {@link DefaultMutableTreeNode}).
+ *
+ * @see DefaultMutableTreeNode#depthFirstEnumeration
+ * @see TreeNode#isLeaf
+ * @return returns the leaf before this node
+ */
+ OrderedTreeNode getPreviousLeaf();
+
+}
Property changes on: trunk/foray/foray-common/src/java/org/foray/common/OrderedTreeNode.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java
===================================================================
--- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java 2007-06-06 15:29:53 UTC (rev 9702)
+++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java 2007-06-06 16:27:11 UTC (rev 9703)
@@ -71,7 +71,7 @@
// See if ancestor table has generated any areas yet.
final TableArea tableArea = areaNode.ancestorTableArea();
- if (tableArea != null && tableArea.getPreviousSibling() != null) {
+ if (tableArea != null && tableArea.siblingIndex() != 0) {
final int numChildren = this.label.getChildren().size();
for (int i = getProgress(); i < numChildren; i++) {
final FoNode fo = this.label.getChildren().get(i);
Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java
===================================================================
--- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java 2007-06-06 15:29:53 UTC (rev 9702)
+++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java 2007-06-06 16:27:11 UTC (rev 9703)
@@ -118,7 +118,7 @@
final FootnoteRA footArea) throws AreaWException {
/* TODO: It seems like this logic should be done once when the
* PageCollection is first started, and cached there for reuse. */
- if (footArea.hasChildren()) {
+ if (footArea.getChildCount() != 0) {
return;
}
final PageSequence pageSeq = bac.getPage()
Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java
===================================================================
--- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java 2007-06-06 15:29:53 UTC (rev 9702)
+++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java 2007-06-06 16:27:11 UTC (rev 9703)
@@ -274,7 +274,8 @@
switch (node.traitBreakBefore(area)) {
case PAGE: {
// if first ColumnArea, and empty, return OK
- if (!colArea.hasChildren() && (colArea.siblingIndex() == 0)) {
+ if (colArea.getChildCount() == 0
+ && (colArea.siblingIndex() == 0)) {
return Status.OK;
}
return Status.FORCE_PAGE_BREAK;
@@ -282,7 +283,8 @@
case ODD_PAGE: {
// if first ColumnArea, empty, _and_ in odd page,
// return OK
- if (!colArea.hasChildren() && (colArea.siblingIndex() == 0)
+ if (colArea.getChildCount() == 0
+ && (colArea.siblingIndex() == 0)
&& (colArea.getPage().getNumber() % 2 != 0)) {
return Status.OK;
}
@@ -291,7 +293,8 @@
case EVEN_PAGE: {
// if first ColumnArea, empty, _and_ in even page,
// return OK
- if (!colArea.hasChildren() && (colArea.siblingIndex() == 0)
+ if (colArea.getChildCount() == 0
+ && (colArea.siblingIndex() == 0)
&& (colArea.getPage().getNumber() % 2 == 0)) {
return Status.OK;
}
@@ -299,7 +302,7 @@
}
case COLUMN: {
// if ColumnArea is empty return OK
- if (!area.hasChildren()) {
+ if (colArea.getChildCount() == 0) {
return Status.OK;
}
return Status.FORCE_COLUMN_BREAK;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|