[FOray-commit] SF.net SVN: foray:[12185] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2021-12-07 17:35:08
|
Revision: 12185
http://sourceforge.net/p/foray/code/12185
Author: victormote
Date: 2021-12-07 17:35:05 +0000 (Tue, 07 Dec 2021)
Log Message:
-----------
Push more tree-related logic back into the tree classes.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaFlexible.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java
trunk/foray/foray-common/src/main/java/org/foray/common/data/AbstractOrderedTreeNode.java
trunk/foray/foray-common/src/main/java/org/foray/common/data/OrderedTreeNode.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Marker4a.java
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaFlexible.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaFlexible.java 2021-12-07 17:09:43 UTC (rev 12184)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaFlexible.java 2021-12-07 17:35:05 UTC (rev 12185)
@@ -28,6 +28,8 @@
package org.foray.area;
+import org.foray.common.data.OrderedTreeNode;
+
import org.axsl.common.value.RelativeAxis;
import java.util.List;
@@ -203,11 +205,11 @@
if (previous == null) {
/* It is possible that the child area has not yet been registered
* with the parent Area yet. Use the last child of the parent. */
- final List<? extends AreaNode4a> siblings = this.getSiblings();
+ final List<? extends OrderedTreeNode<AreaNode4a>> siblings = this.getSiblings();
if (siblings != null
&& siblings.size() > 0) {
final int lastIndex = siblings.size() - 1;
- final AreaNode4a previousNode = siblings.get(lastIndex);
+ final AreaNode4a previousNode = siblings.get(lastIndex).asNativeType();
if (previousNode instanceof Area4a) {
previous = (Area4a) previousNode;
}
@@ -272,7 +274,7 @@
public int pdUsedBySiblings() {
int pdUsedBySiblings = 0;
final int siblingIndex = siblingIndex();
- final List<? extends AreaNode4a> siblings = getSiblings();
+ final List<? extends OrderedTreeNode<AreaNode4a>> siblings = getSiblings();
for (int i = 0; i < siblingIndex; i++) {
if (siblings.get(i) instanceof AreaFlexible) {
final AreaFlexible af = (AreaFlexible) siblings.get(i);
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java 2021-12-07 17:09:43 UTC (rev 12184)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java 2021-12-07 17:35:05 UTC (rev 12185)
@@ -108,14 +108,6 @@
return getChildren().get(childIndex);
}
- @Override
- public List<? extends AreaNode4a> getSiblings() {
- if (this.getParent() == null) {
- return null;
- }
- return this.getParent().getChildren();
- }
-
/**
* Removes this from the parent's list of children.
*/
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/data/AbstractOrderedTreeNode.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/data/AbstractOrderedTreeNode.java 2021-12-07 17:09:43 UTC (rev 12184)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/data/AbstractOrderedTreeNode.java 2021-12-07 17:35:05 UTC (rev 12185)
@@ -61,12 +61,6 @@
return new PostOrderDescendantIterator(this);
}
- /**
- * Return the List of this node's children.
- * @return The List of this node's children.
- */
- public abstract List<? extends OrderedTreeNode<T>> getChildren();
-
@Override
public int getChildCount() {
if (getChildren() == null) {
@@ -91,6 +85,19 @@
return false;
}
+ /**
+ * Returns the List of this node's parent's children, which includes this node.
+ * @return The List of this node's parent's children.
+ */
+ public List<? extends OrderedTreeNode<T>> getSiblings() {
+ final OrderedTreeNode<T> parent = getParentAsOrderedNode();
+ if (this.getParent() == null) {
+ return null;
+ }
+ return parent.getChildren();
+ }
+
+
@Override
public int siblingIndex() {
final List<? extends OrderedTreeNode<T>> siblings = getSiblings();
Modified: trunk/foray/foray-common/src/main/java/org/foray/common/data/OrderedTreeNode.java
===================================================================
--- trunk/foray/foray-common/src/main/java/org/foray/common/data/OrderedTreeNode.java 2021-12-07 17:09:43 UTC (rev 12184)
+++ trunk/foray/foray-common/src/main/java/org/foray/common/data/OrderedTreeNode.java 2021-12-07 17:35:05 UTC (rev 12185)
@@ -41,15 +41,10 @@
public interface OrderedTreeNode<T> {
/**
- * Interface for types that are able to convert back and forth between a native type and a node in the ordered tree.
+ * Interface for types that are can convert a native type to an ordered tree node.
* @param <T> The type of node.
*/
public interface Convertible<T> {
- /**
- * Casts the node as its native type.
- * @return This, cast as its native type.
- */
- T asNativeType();
/**
* Casts a native type item as an ordered tree node.
@@ -60,6 +55,12 @@
}
/**
+ * Casts the node as its native type.
+ * @return This, cast as its native type.
+ */
+ T asNativeType();
+
+ /**
* Returns the parent of this.
* @return The parent node.
*/
@@ -72,6 +73,12 @@
OrderedTreeNode<T> getParentAsOrderedNode();
/**
+ * Return the List of this node's children.
+ * @return The List of this node's children.
+ */
+ List<? extends OrderedTreeNode<T>> getChildren();
+
+ /**
* Returns the number of children this contains.
* @return The number of children.
*/
@@ -98,12 +105,6 @@
boolean isLeaf();
/**
- * Returns the List of this node's parent's children, which includes this node.
- * @return The List of this node's parent's children.
- */
- List<? extends OrderedTreeNode<T>> getSiblings();
-
- /**
* Returns this node's position within the siblings.
* @return The index to "this" in the parent's children.
*/
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2021-12-07 17:09:43 UTC (rev 12184)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2021-12-07 17:35:05 UTC (rev 12185)
@@ -286,14 +286,6 @@
return forayGraftingPoint.getParent();
}
- @Override
- public List<? extends FoObj> getSiblings() {
- if (this.getParent() == null) {
- return null;
- }
- return this.getParent().getChildren();
- }
-
/**
* Adds the context information to a given message.
* @param message The message to which context information should be added.
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Marker4a.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Marker4a.java 2021-12-07 17:09:43 UTC (rev 12184)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/obj/Marker4a.java 2021-12-07 17:35:05 UTC (rev 12185)
@@ -28,6 +28,7 @@
package org.foray.fotree.fo.obj;
+import org.foray.common.data.OrderedTreeNode;
import org.foray.fotree.FoObj;
import org.foray.fotree.FoObjMixed;
import org.foray.fotree.Namespace;
@@ -73,9 +74,9 @@
throwException(getFullName() + " must be descendant of fo:flow.");
}
// Validate that there is not content before this and other markers.
- final List<? extends FoObj> siblings = this.getSiblings();
+ final List<? extends OrderedTreeNode<FoObj>> siblings = this.getSiblings();
for (int i = 0; i < siblings.size(); i++) {
- final FoObj sibling = siblings.get(i);
+ final FoObj sibling = siblings.get(i).asNativeType();
if (sibling instanceof Marker4a) {
/* This is valid. */
} else if (sibling instanceof FoWordSequence) {
@@ -94,7 +95,7 @@
@Override
protected void validateProperties() throws FoTreeException {
// Make sure that no sibling marker has the same 'marker-class-name'.
- final List<? extends FoObj> siblings = this.getSiblings();
+ final List<? extends OrderedTreeNode<FoObj>> siblings = this.getSiblings();
for (int i = 0; i < siblings.size(); i++) {
if (! (siblings.get(i) instanceof Marker4a)) {
continue;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|