Revision: 12301
http://sourceforge.net/p/foray/code/12301
Author: victormote
Date: 2021-12-30 21:30:53 +0000 (Thu, 30 Dec 2021)
Log Message:
-----------
Rename class for clarity.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/PageRa.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/link/BlockLink.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/link/FoTextWordsLink.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/link/GenericLink.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/link/GraftingPointLink.java
trunk/foray/foray-areatree/src/main/java/org/foray/area/link/Linkage.java
Added Paths:
-----------
trunk/foray/foray-areatree/src/main/java/org/foray/area/link/NormalLink.java
Removed Paths:
-------------
trunk/foray/foray-areatree/src/main/java/org/foray/area/link/FoLink.java
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-30 17:55:40 UTC (rev 12300)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaNode4a.java 2021-12-30 21:30:53 UTC (rev 12301)
@@ -28,9 +28,9 @@
package org.foray.area;
-import org.foray.area.link.FoLink;
import org.foray.area.link.GraftingPointLink;
import org.foray.area.link.Linkage;
+import org.foray.area.link.NormalLink;
import org.foray.common.data.AbstractOrderedTreeNode;
import org.axsl.area.AreaNode;
@@ -72,7 +72,7 @@
* @param graftingPoint The ancestor grafting point, if any.
*/
protected void registerWithLinkage(final GraftingPoint graftingPoint) {
- final FoLink normalLinkage = this.getNormalLinkage(
+ final NormalLink normalLinkage = this.getNormalLinkage(
graftingPoint);
normalLinkage.registerGeneratedArea(this);
}
@@ -179,9 +179,9 @@
* Returns the normal linkage associated with this Area.
* @return The normal linkage associated with this Area.
*/
- public FoLink getNormalLinkage() {
- if (this.getLinkage() instanceof FoLink) {
- return (FoLink) this.getLinkage();
+ public NormalLink getNormalLinkage() {
+ if (this.getLinkage() instanceof NormalLink) {
+ return (NormalLink) this.getLinkage();
}
if (this.getLinkage() instanceof GraftingPointLink) {
final GraftingPointLink linkageMarker = (GraftingPointLink)
@@ -200,11 +200,11 @@
* @param graftingPoint The retrieve-marker.
* @return The normal linkage associated with this Area.
*/
- public FoLink getNormalLinkage(
+ public NormalLink getNormalLinkage(
final GraftingPoint graftingPoint) {
final Linkage linkage = this.getLinkage();
- if (linkage instanceof FoLink) {
- return (FoLink) linkage;
+ if (linkage instanceof NormalLink) {
+ return (NormalLink) linkage;
}
if (linkage instanceof GraftingPointLink) {
final GraftingPointLink linkageMarker = (GraftingPointLink) linkage;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java 2021-12-30 17:55:40 UTC (rev 12300)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/AreaTree4a.java 2021-12-30 21:30:53 UTC (rev 12301)
@@ -28,9 +28,9 @@
package org.foray.area;
-import org.foray.area.link.FoLink;
import org.foray.area.link.Linkage;
import org.foray.area.link.LinkageFactory;
+import org.foray.area.link.NormalLink;
import org.axsl.area.AreaTree;
import org.axsl.area.AreaTreeEvent;
@@ -272,8 +272,8 @@
public Area4a firstNormalAreaReturned(final String id) {
final Fo fobj = retrieveId(id);
final Linkage linkage = linkage(fobj, null);
- if (linkage instanceof FoLink) {
- final FoLink normalLinkage = (FoLink) linkage;
+ if (linkage instanceof NormalLink) {
+ final NormalLink normalLinkage = (NormalLink) linkage;
return normalLinkage.firstNormalAreaReturned();
}
/* Hopefully we can't reference ids in static content, right? */
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/PageRa.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/PageRa.java 2021-12-30 17:55:40 UTC (rev 12300)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/PageRa.java 2021-12-30 21:30:53 UTC (rev 12301)
@@ -28,8 +28,8 @@
package org.foray.area;
-import org.foray.area.link.FoLink;
import org.foray.area.link.Linkage;
+import org.foray.area.link.NormalLink;
import org.axsl.area.AreaTreeException;
import org.axsl.area.PageCollection.Force;
@@ -578,7 +578,7 @@
* @return True if the first area returned by marker is on this page.
*/
private boolean startsHere(final Marker marker) {
- final FoLink normalLinkage = this.markerParentLinkage(marker);
+ final NormalLink normalLinkage = this.markerParentLinkage(marker);
if (normalLinkage == null) {
return false;
}
@@ -598,7 +598,7 @@
* @return True if the last area returned by marker is on this page.
*/
private boolean endsHere(final Marker marker) {
- final FoLink normalLinkage = this.markerParentLinkage(marker);
+ final NormalLink normalLinkage = this.markerParentLinkage(marker);
if (normalLinkage == null) {
return false;
}
@@ -617,11 +617,11 @@
* @param marker The marker for which the linkage is needed.
* @return The linkage.
*/
- private FoLink markerParentLinkage(final Marker marker) {
+ private NormalLink markerParentLinkage(final Marker marker) {
final Fo parent = marker.getParent();
final Linkage proxy = linkage(parent, null);
- if (proxy instanceof FoLink) {
- return (FoLink) proxy;
+ if (proxy instanceof NormalLink) {
+ return (NormalLink) proxy;
}
/* This would mean nested markers. Should never happen. */
return null;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/link/BlockLink.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/link/BlockLink.java 2021-12-30 17:55:40 UTC (rev 12300)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/link/BlockLink.java 2021-12-30 21:30:53 UTC (rev 12301)
@@ -33,7 +33,7 @@
/**
* Linkage for {@link Block} formatting objects.
*/
-public class BlockLink extends FoLink {
+public class BlockLink extends NormalLink {
/** The FONode for which this linkage tracks Area generation. */
private Block generatedBy;
Deleted: trunk/foray/foray-areatree/src/main/java/org/foray/area/link/FoLink.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/link/FoLink.java 2021-12-30 17:55:40 UTC (rev 12300)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/link/FoLink.java 2021-12-30 21:30:53 UTC (rev 12301)
@@ -1,249 +0,0 @@
-/*
- * Copyright 2004 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.area.link;
-
-import org.foray.area.Area4a;
-import org.foray.area.AreaNode4a;
-
-import org.axsl.fotree.fo.RetrieveMarker;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * <p>A "normal" linkage manager, that is, one that simply matches an FONode to the Areas that it has created.</p>
- */
-public abstract class FoLink implements Linkage {
-
- /**
- * The ordered list of Area instances generated by {@link Linkage#getGeneratedBy()}.
- * Index 0 "is-first" and Index size() - 1 "is-last".
- * This is currently set up to only store the root node of any subtree that was generated by
- * {@link Linkage#getGeneratedBy()}.
- */
- private List<AreaNode4a> generatedAreas = new ArrayList<AreaNode4a>();
-
- /**
- * Register a given area node as being generated by this linkage.
- * @param areaNode The area node to register.
- */
- public void registerGeneratedArea(final AreaNode4a areaNode) {
- final AreaNode4a parent = areaNode.getParent();
- if (parent != null) {
- /*
- * If the parent was generated by the same FObj, then we shouldn't
- * register this one also.
- */
- if (areaNode.traitGeneratedBy() == parent.traitGeneratedBy()) {
- return;
- }
- }
- if (this.generatedAreas == null) {
- this.generatedAreas = new ArrayList<AreaNode4a>();
- }
- this.generatedAreas.add(areaNode);
- }
-
- /**
- * Unregisters a given area node.
- * @param areaNode The area node to unregister.
- */
- public void unregisterGeneratedArea(final AreaNode4a areaNode) {
- this.generatedAreas.remove(areaNode);
- }
-
- /**
- * Returns the first area generated by this linkage, that is, by the FO node in this linkage.
- * @return The first area generated.
- */
- public AreaNode4a getFirstGeneratedBy() {
- if (this.generatedAreas == null
- || this.generatedAreas.size() < 1) {
- return null;
- }
- return this.generatedAreas.get(0);
- }
-
- /**
- * For a given area, returns the previous area generated by this linkage.
- * @param area The area whose previous area is needed.
- * @return The previous area, or null, if {@code area} is the first area generated by this linkage.
- */
- public AreaNode4a getPreviousGeneratedBy(final AreaNode4a area) {
- if (this.generatedAreas == null) {
- return null;
- }
- final int index = this.generatedAreas.indexOf(area);
- if (index > 0) {
- return this.generatedAreas.get(index - 1);
- }
- return null;
- }
-
- /**
- * For a given area, returns the next area generated by this linkage.
- * @param area The area whose next area is needed.
- * @return The next area, or null, if {@code area} is the last area generated by this linkage.
- */
- public AreaNode4a getNextGeneratedBy(final AreaNode4a area) {
- if (this.generatedAreas == null) {
- return null;
- }
- final int index = this.generatedAreas.indexOf(area);
- if (index > 0 && index < this.generatedAreas.size() - 1) {
- return this.generatedAreas.get(index + 1);
- }
- return null;
- }
-
- /**
- * Indicates whether a given area is the first one generated by this linkage.
- * @param area An Area instance.
- * @return True if and only if area is the first Area generated by this.
- */
- public boolean isFirstGeneratedBy(final AreaNode4a area) {
- if (this.generatedAreas.indexOf(area) == 0) {
- return true;
- }
- return false;
- }
-
- /**
- * Indicates whether a given area is the last one generated by this linkage.
- * @param area An Area instance.
- * @return True if and only if area is the first Area generated by this.
- */
- public boolean isLastGeneratedBy(final AreaNode4a area) {
- if (this.generatedAreas.indexOf(area) == (this.generatedAreas.size() - 1)) {
- return true;
- }
- return false;
- }
-
- /**
- * Returns the number of areas generated by the FO.
- * @return The current count of areas that have been generated by the FObj.
- */
- public int qtyAreasGenerated() {
- return this.generatedAreas.size();
- }
-
- /**
- * Returns the last area node generated by the FO.
- * @return The last AreaNode generated by the parent FObj.
- */
- public AreaNode4a getLastGeneratedBy() {
- if (this.generatedAreas == null
- || this.generatedAreas.size() < 1) {
- return null;
- }
- return this.generatedAreas.get(this.generatedAreas.size() - 1);
- }
-
- /**
- * Returns the last Area generated by the FO.
- * @return The last Area generated by the parent FObj.
- */
- public Area4a getLastAreaGeneratedBy() {
- if (this.generatedAreas == null
- || this.generatedAreas.size() < 1) {
- return null;
- }
- for (int i = this.generatedAreas.size() - 1; i >= 0; i--) {
- final Object object = this.generatedAreas.get(i);
- if (object instanceof Area4a) {
- return (Area4a) object;
- }
- }
- return null;
- }
-
- /**
- * Returns the first normal area returned by this linkage.
- * @return The first normal area returned by this linkage.
- */
- public Area4a firstNormalAreaReturned() {
- /*
- * TODO: This is not right, but will do for now. It is not considering
- * areas that are returned by the FO but not generated by it.
- */
- if (this.generatedAreas == null) {
- return null;
- }
- for (int i = 0; i < this.generatedAreas.size(); i ++) {
- final Object object = this.generatedAreas.get(i);
- if (object instanceof Area4a) {
- return (Area4a) object;
- }
- }
- return null;
- }
-
- /**
- * Returns the last normal area returned by this linkage.
- * @return The last normal area returned by this linkage.
- */
- public Area4a lastNormalAreaReturned() {
- /*
- * TODO: This is not right, but will do for now. It is not considering
- * areas that are returned by the FO but not generated by it.
- */
- if (this.generatedAreas == null) {
- return null;
- }
- for (int i = this.generatedAreas.size() - 1; i >= 0; i --) {
- final Object object = this.generatedAreas.get(i);
- if (object instanceof Area4a) {
- return (Area4a) object;
- }
- }
- return null;
- }
-
- @Override
- public RetrieveMarker getGraftingPoint(final AreaNode4a areaNode) {
- return null;
- }
-
- /**
- * Indicates whether a given area was generated by this linkage.
- * @param areaNode The node to be tested.
- * @return True if and only if this linkage generated {@code areaNode}.
- */
- public boolean contains(final AreaNode4a areaNode) {
- for (int i = 0; i < this.generatedAreas.size(); i++) {
- final Object object = this.generatedAreas.get(i);
- if (object == areaNode) {
- return true;
- }
- }
- return false;
- }
-
-}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/link/FoTextWordsLink.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/link/FoTextWordsLink.java 2021-12-30 17:55:40 UTC (rev 12300)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/link/FoTextWordsLink.java 2021-12-30 21:30:53 UTC (rev 12301)
@@ -33,7 +33,7 @@
/**
* Linkage for {@link FoTextWords} formatting objects.
*/
-public class FoTextWordsLink extends FoLink {
+public class FoTextWordsLink extends NormalLink {
/** The FONode for which this linkage tracks Area generation. */
private FoTextWords generatedBy;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/link/GenericLink.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/link/GenericLink.java 2021-12-30 17:55:40 UTC (rev 12300)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/link/GenericLink.java 2021-12-30 21:30:53 UTC (rev 12301)
@@ -33,7 +33,7 @@
/**
* Linkage for formatting objects that do not need special handling.
*/
-public class GenericLink extends FoLink {
+public class GenericLink extends NormalLink {
/** The FONode for which this linkage tracks Area generation. */
private Fo generatedBy;
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/link/GraftingPointLink.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/link/GraftingPointLink.java 2021-12-30 17:55:40 UTC (rev 12300)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/link/GraftingPointLink.java 2021-12-30 21:30:53 UTC (rev 12301)
@@ -50,7 +50,7 @@
private Fo generatedBy;
/**
- * <p>Map whose key is a {@link GraftingPoint} instance, and whose value is an {@link FoLink} instance.</p>
+ * <p>Map whose key is a {@link GraftingPoint} instance, and whose value is an {@link NormalLink} instance.</p>
*
* <p>An fo:marker can be grafted to multiple fo:retrieve-marker instances, and can therefore be laid out in the
* Area Tree multiple times.
@@ -67,11 +67,11 @@
* Answer: it is unnecessary, because the {@link Marker} instance is implied in this's
* {@link Linkage#getGeneratedBy()}.</p>
*
- * <p>The value of the Map is an {@link FoLink} just as would be used to store the linkage information for
+ * <p>The value of the Map is an {@link NormalLink} just as would be used to store the linkage information for
* non-marker content.
* So the net effect is that we have forced a {@link RetrieveMarker} into the key that tracks this content.</p>
*/
- private Map<GraftingPoint, FoLink> map = new HashMap<GraftingPoint, FoLink>();
+ private Map<GraftingPoint, NormalLink> map = new HashMap<GraftingPoint, NormalLink>();
/* TODO: Since the typical case presumably has the marker being used with
* only one retrieve-marker, a HashMap is probably overkill. We should
* probably use parallel arrays of size 1 for this information, and just
@@ -107,15 +107,15 @@
* @param graftingPoint The RetrieveMarker for which the linkage is needed.
* @return The normal linkage.
*/
- public FoLink getNormalLinkage(final GraftingPoint graftingPoint) {
+ public NormalLink getNormalLinkage(final GraftingPoint graftingPoint) {
if (graftingPoint == null) {
return null;
}
final Linkage object = this.map.get(graftingPoint);
if (object != null) {
- return (FoLink) object;
+ return (NormalLink) object;
}
- final FoLink newLinkage = new GenericLink(this.getGeneratedBy());
+ final NormalLink newLinkage = new GenericLink(this.getGeneratedBy());
this.map.put(graftingPoint, newLinkage);
return newLinkage;
}
@@ -122,9 +122,9 @@
@Override
public GraftingPoint getGraftingPoint(final AreaNode4a areaNode) {
- for (Map.Entry<GraftingPoint, FoLink> entry
+ for (Map.Entry<GraftingPoint, NormalLink> entry
: this.map.entrySet()) {
- final FoLink normalLinkage = entry.getValue();
+ final NormalLink normalLinkage = entry.getValue();
if (normalLinkage.contains(areaNode)) {
return entry.getKey();
}
Modified: trunk/foray/foray-areatree/src/main/java/org/foray/area/link/Linkage.java
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/link/Linkage.java 2021-12-30 17:55:40 UTC (rev 12300)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/link/Linkage.java 2021-12-30 21:30:53 UTC (rev 12301)
@@ -34,7 +34,7 @@
import org.axsl.fotree.fo.GraftingPoint;
/**
- * Abstract superclass for classes that handle the linkage between the FO Tree and the Area Tree.
+ * Interface for classes that handle the linkage between the FO Tree and the Area Tree.
*/
public interface Linkage {
Copied: trunk/foray/foray-areatree/src/main/java/org/foray/area/link/NormalLink.java (from rev 12300, trunk/foray/foray-areatree/src/main/java/org/foray/area/link/FoLink.java)
===================================================================
--- trunk/foray/foray-areatree/src/main/java/org/foray/area/link/NormalLink.java (rev 0)
+++ trunk/foray/foray-areatree/src/main/java/org/foray/area/link/NormalLink.java 2021-12-30 21:30:53 UTC (rev 12301)
@@ -0,0 +1,249 @@
+/*
+ * Copyright 2004 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.area.link;
+
+import org.foray.area.Area4a;
+import org.foray.area.AreaNode4a;
+
+import org.axsl.fotree.fo.RetrieveMarker;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>A "normal" linkage manager, that is, one that simply matches an FONode to the Areas that it has created.</p>
+ */
+public abstract class NormalLink implements Linkage {
+
+ /**
+ * The ordered list of Area instances generated by {@link Linkage#getGeneratedBy()}.
+ * Index 0 "is-first" and Index size() - 1 "is-last".
+ * This is currently set up to only store the root node of any subtree that was generated by
+ * {@link Linkage#getGeneratedBy()}.
+ */
+ private List<AreaNode4a> generatedAreas = new ArrayList<AreaNode4a>();
+
+ /**
+ * Register a given area node as being generated by this linkage.
+ * @param areaNode The area node to register.
+ */
+ public void registerGeneratedArea(final AreaNode4a areaNode) {
+ final AreaNode4a parent = areaNode.getParent();
+ if (parent != null) {
+ /*
+ * If the parent was generated by the same FObj, then we shouldn't
+ * register this one also.
+ */
+ if (areaNode.traitGeneratedBy() == parent.traitGeneratedBy()) {
+ return;
+ }
+ }
+ if (this.generatedAreas == null) {
+ this.generatedAreas = new ArrayList<AreaNode4a>();
+ }
+ this.generatedAreas.add(areaNode);
+ }
+
+ /**
+ * Unregisters a given area node.
+ * @param areaNode The area node to unregister.
+ */
+ public void unregisterGeneratedArea(final AreaNode4a areaNode) {
+ this.generatedAreas.remove(areaNode);
+ }
+
+ /**
+ * Returns the first area generated by this linkage, that is, by the FO node in this linkage.
+ * @return The first area generated.
+ */
+ public AreaNode4a getFirstGeneratedBy() {
+ if (this.generatedAreas == null
+ || this.generatedAreas.size() < 1) {
+ return null;
+ }
+ return this.generatedAreas.get(0);
+ }
+
+ /**
+ * For a given area, returns the previous area generated by this linkage.
+ * @param area The area whose previous area is needed.
+ * @return The previous area, or null, if {@code area} is the first area generated by this linkage.
+ */
+ public AreaNode4a getPreviousGeneratedBy(final AreaNode4a area) {
+ if (this.generatedAreas == null) {
+ return null;
+ }
+ final int index = this.generatedAreas.indexOf(area);
+ if (index > 0) {
+ return this.generatedAreas.get(index - 1);
+ }
+ return null;
+ }
+
+ /**
+ * For a given area, returns the next area generated by this linkage.
+ * @param area The area whose next area is needed.
+ * @return The next area, or null, if {@code area} is the last area generated by this linkage.
+ */
+ public AreaNode4a getNextGeneratedBy(final AreaNode4a area) {
+ if (this.generatedAreas == null) {
+ return null;
+ }
+ final int index = this.generatedAreas.indexOf(area);
+ if (index > 0 && index < this.generatedAreas.size() - 1) {
+ return this.generatedAreas.get(index + 1);
+ }
+ return null;
+ }
+
+ /**
+ * Indicates whether a given area is the first one generated by this linkage.
+ * @param area An Area instance.
+ * @return True if and only if area is the first Area generated by this.
+ */
+ public boolean isFirstGeneratedBy(final AreaNode4a area) {
+ if (this.generatedAreas.indexOf(area) == 0) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Indicates whether a given area is the last one generated by this linkage.
+ * @param area An Area instance.
+ * @return True if and only if area is the first Area generated by this.
+ */
+ public boolean isLastGeneratedBy(final AreaNode4a area) {
+ if (this.generatedAreas.indexOf(area) == (this.generatedAreas.size() - 1)) {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Returns the number of areas generated by the FO.
+ * @return The current count of areas that have been generated by the FObj.
+ */
+ public int qtyAreasGenerated() {
+ return this.generatedAreas.size();
+ }
+
+ /**
+ * Returns the last area node generated by the FO.
+ * @return The last AreaNode generated by the parent FObj.
+ */
+ public AreaNode4a getLastGeneratedBy() {
+ if (this.generatedAreas == null
+ || this.generatedAreas.size() < 1) {
+ return null;
+ }
+ return this.generatedAreas.get(this.generatedAreas.size() - 1);
+ }
+
+ /**
+ * Returns the last Area generated by the FO.
+ * @return The last Area generated by the parent FObj.
+ */
+ public Area4a getLastAreaGeneratedBy() {
+ if (this.generatedAreas == null
+ || this.generatedAreas.size() < 1) {
+ return null;
+ }
+ for (int i = this.generatedAreas.size() - 1; i >= 0; i--) {
+ final Object object = this.generatedAreas.get(i);
+ if (object instanceof Area4a) {
+ return (Area4a) object;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the first normal area returned by this linkage.
+ * @return The first normal area returned by this linkage.
+ */
+ public Area4a firstNormalAreaReturned() {
+ /*
+ * TODO: This is not right, but will do for now. It is not considering
+ * areas that are returned by the FO but not generated by it.
+ */
+ if (this.generatedAreas == null) {
+ return null;
+ }
+ for (int i = 0; i < this.generatedAreas.size(); i ++) {
+ final Object object = this.generatedAreas.get(i);
+ if (object instanceof Area4a) {
+ return (Area4a) object;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the last normal area returned by this linkage.
+ * @return The last normal area returned by this linkage.
+ */
+ public Area4a lastNormalAreaReturned() {
+ /*
+ * TODO: This is not right, but will do for now. It is not considering
+ * areas that are returned by the FO but not generated by it.
+ */
+ if (this.generatedAreas == null) {
+ return null;
+ }
+ for (int i = this.generatedAreas.size() - 1; i >= 0; i --) {
+ final Object object = this.generatedAreas.get(i);
+ if (object instanceof Area4a) {
+ return (Area4a) object;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public RetrieveMarker getGraftingPoint(final AreaNode4a areaNode) {
+ return null;
+ }
+
+ /**
+ * Indicates whether a given area was generated by this linkage.
+ * @param areaNode The node to be tested.
+ * @return True if and only if this linkage generated {@code areaNode}.
+ */
+ public boolean contains(final AreaNode4a areaNode) {
+ for (int i = 0; i < this.generatedAreas.size(); i++) {
+ final Object object = this.generatedAreas.get(i);
+ if (object == areaNode) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|