[FOray-commit] SF.net SVN: foray: [7532] trunk/foray/foray-areatree/src/java/org/foray/area
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-06-12 15:15:02
|
Revision: 7532 Author: victormote Date: 2006-06-12 08:14:48 -0700 (Mon, 12 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7532&view=rev Log Message: ----------- Oops. Rename it again. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/AreaNode.java trunk/foray/foray-areatree/src/java/org/foray/area/AreaTree.java trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java Added Paths: ----------- trunk/foray/foray-areatree/src/java/org/foray/area/FOLinkageNormal.java Removed Paths: ------------- trunk/foray/foray-areatree/src/java/org/foray/area/FOLinkage.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/AreaNode.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/AreaNode.java 2006-06-12 15:05:56 UTC (rev 7531) +++ trunk/foray/foray-areatree/src/java/org/foray/area/AreaNode.java 2006-06-12 15:14:48 UTC (rev 7532) @@ -50,7 +50,7 @@ /* * The "generated-by" trait, as defined in Section 6.1.1. */ - protected FOLinkage generatedBy; + protected FOLinkageNormal generatedBy; /** * Constructor. @@ -92,13 +92,13 @@ this.children.remove(areaNode); } - protected FOLinkage linkage(FONode foNode) { + protected FOLinkageNormal linkage(FONode foNode) { if (foNode == null) { return null; } - FOLinkage linkage = (FOLinkage) foNode.getResult(); + FOLinkageNormal linkage = (FOLinkageNormal) foNode.getResult(); if (linkage == null) { - linkage = new FOLinkage(foNode); + linkage = new FOLinkageNormal(foNode); foNode.setResult(linkage); } return linkage; Modified: trunk/foray/foray-areatree/src/java/org/foray/area/AreaTree.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/AreaTree.java 2006-06-12 15:05:56 UTC (rev 7531) +++ trunk/foray/foray-areatree/src/java/org/foray/area/AreaTree.java 2006-06-12 15:14:48 UTC (rev 7532) @@ -115,7 +115,7 @@ } public Root getRoot() { - FOLinkage linkage = this.generatedBy; + FOLinkageNormal linkage = this.generatedBy; /* Cast verified at construction. */ return (Root) linkage.getFONode(); } @@ -178,7 +178,7 @@ */ public Area firstNormalAreaReturned(String id) { FObj fobj = retrieveId(id); - FOLinkage proxy = linkage(fobj); + FOLinkageNormal proxy = linkage(fobj); return proxy.firstNormalAreaReturned(); } Deleted: trunk/foray/foray-areatree/src/java/org/foray/area/FOLinkage.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/FOLinkage.java 2006-06-12 15:05:56 UTC (rev 7531) +++ trunk/foray/foray-areatree/src/java/org/foray/area/FOLinkage.java 2006-06-12 15:14:48 UTC (rev 7532) @@ -1,198 +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 - * - */ - -/* $Id$ */ - -package org.foray.area; - -import org.axsl.areaW.Area; -import org.axsl.areaW.AreaNode; -import org.axsl.foR.FONode; -import org.axsl.foR.FONodeResult; - -import java.util.ArrayList; - -/** - * <p>An implementation of {@link org.axsl.foR.FONodeProxy} suitable for use - * with the FOray AreaTree.</p> - */ -public class FOLinkage implements FONodeResult { - - /** The FONode which generated the Areas in {@link #generatedAreas}. */ - private FONode realFONode; - - /** - * The ordered list of Area instances generated by {@link #realFONode}. - * 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 #realFONode}. - */ - private ArrayList generatedAreas = new ArrayList(); - - public FOLinkage(FONode realFObj) { - this.realFONode = realFObj; - } - - public FONode getFONode() { - return this.realFONode; - } - - public void registerGeneratedArea(AreaNode areaNode) { - AreaNode parent = areaNode.getWritableParent(); - 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 (generatedAreas == null) { - generatedAreas = new ArrayList(); - } - generatedAreas.add(areaNode); - } - - public void unregisterGeneratedArea(AreaNode areaNode) { - generatedAreas.remove(areaNode); - } - - public AreaNode getFirstGeneratedBy() { - if (generatedAreas == null || generatedAreas.size() < 1) { - return null; - } - return (AreaNode) generatedAreas.get(0); - } - - public AreaNode getPreviousGeneratedBy(AreaNode area) { - if (generatedAreas == null) { - return null; - } - int index = generatedAreas.indexOf(area); - if (index > 0) { - return (AreaNode) generatedAreas.get(index - 1); - } - return null; - } - - public AreaNode getNextGeneratedBy(AreaNode area) { - if (generatedAreas == null) { - return null; - } - int index = generatedAreas.indexOf(area); - if (index > 0 && index < generatedAreas.size() - 1) { - return (AreaNode) generatedAreas.get(index + 1); - } - return null; - } - - /** - * @param area An Area instance. - * @return True iff area is the first Area generated by this. - */ - public boolean isFirstGeneratedBy(AreaNode area) { - if (generatedAreas.indexOf(area) == 0) { - return true; - } - return false; - } - - /** - * @param area An Area instance. - * @return True iff area is the first Area generated by this. - */ - public boolean isLastGeneratedBy(AreaNode area) { - if (generatedAreas.indexOf(area) == (generatedAreas.size() - 1)) { - return true; - } - return false; - } - - /** - * @return The current count of areas that have been generated by the FObj. - */ - public int qtyAreasGenerated() { - return this.generatedAreas.size(); - } - - /** - * @return The last AreaNode generated by the parent FObj. - */ - public AreaNode getLastGeneratedBy() { - if (generatedAreas == null || generatedAreas.size() < 1) { - return null; - } - return (AreaNode) generatedAreas.get(generatedAreas.size() - 1); - } - - /** - * @return The last Area generated by the parent FObj. - */ - public Area getLastAreaGeneratedBy() { - if (generatedAreas == null || generatedAreas.size() < 1) { - return null; - } - for (int i = generatedAreas.size() - 1; i >= 0; i--) { - Object object = generatedAreas.get(i); - if (object instanceof Area) { - return (Area) object; - } - } - return null; - } - - public Area 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 (generatedAreas == null) { - return null; - } - for (int i = 0; i < generatedAreas.size(); i ++) { - Object object = generatedAreas.get(i); - if (object instanceof Area) { - return (Area) object; - } - } - return null; - } - - public Area 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 (generatedAreas == null) { - return null; - } - for (int i = generatedAreas.size() - 1; i >= 0; i --) { - Object object = generatedAreas.get(i); - if (object instanceof Area) { - return (Area) object; - } - } - return null; - } - -} Copied: trunk/foray/foray-areatree/src/java/org/foray/area/FOLinkageNormal.java (from rev 7531, trunk/foray/foray-areatree/src/java/org/foray/area/FOLinkage.java) =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/FOLinkageNormal.java (rev 0) +++ trunk/foray/foray-areatree/src/java/org/foray/area/FOLinkageNormal.java 2006-06-12 15:14:48 UTC (rev 7532) @@ -0,0 +1,198 @@ +/* + * 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 + * + */ + +/* $Id$ */ + +package org.foray.area; + +import org.axsl.areaW.Area; +import org.axsl.areaW.AreaNode; +import org.axsl.foR.FONode; +import org.axsl.foR.FONodeResult; + +import java.util.ArrayList; + +/** + * <p>An implementation of {@link org.axsl.foR.FONodeProxy} suitable for use + * with the FOray AreaTree.</p> + */ +public class FOLinkageNormal implements FONodeResult { + + /** The FONode which generated the Areas in {@link #generatedAreas}. */ + private FONode realFONode; + + /** + * The ordered list of Area instances generated by {@link #realFONode}. + * 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 #realFONode}. + */ + private ArrayList generatedAreas = new ArrayList(); + + public FOLinkageNormal(FONode realFObj) { + this.realFONode = realFObj; + } + + public FONode getFONode() { + return this.realFONode; + } + + public void registerGeneratedArea(AreaNode areaNode) { + AreaNode parent = areaNode.getWritableParent(); + 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 (generatedAreas == null) { + generatedAreas = new ArrayList(); + } + generatedAreas.add(areaNode); + } + + public void unregisterGeneratedArea(AreaNode areaNode) { + generatedAreas.remove(areaNode); + } + + public AreaNode getFirstGeneratedBy() { + if (generatedAreas == null || generatedAreas.size() < 1) { + return null; + } + return (AreaNode) generatedAreas.get(0); + } + + public AreaNode getPreviousGeneratedBy(AreaNode area) { + if (generatedAreas == null) { + return null; + } + int index = generatedAreas.indexOf(area); + if (index > 0) { + return (AreaNode) generatedAreas.get(index - 1); + } + return null; + } + + public AreaNode getNextGeneratedBy(AreaNode area) { + if (generatedAreas == null) { + return null; + } + int index = generatedAreas.indexOf(area); + if (index > 0 && index < generatedAreas.size() - 1) { + return (AreaNode) generatedAreas.get(index + 1); + } + return null; + } + + /** + * @param area An Area instance. + * @return True iff area is the first Area generated by this. + */ + public boolean isFirstGeneratedBy(AreaNode area) { + if (generatedAreas.indexOf(area) == 0) { + return true; + } + return false; + } + + /** + * @param area An Area instance. + * @return True iff area is the first Area generated by this. + */ + public boolean isLastGeneratedBy(AreaNode area) { + if (generatedAreas.indexOf(area) == (generatedAreas.size() - 1)) { + return true; + } + return false; + } + + /** + * @return The current count of areas that have been generated by the FObj. + */ + public int qtyAreasGenerated() { + return this.generatedAreas.size(); + } + + /** + * @return The last AreaNode generated by the parent FObj. + */ + public AreaNode getLastGeneratedBy() { + if (generatedAreas == null || generatedAreas.size() < 1) { + return null; + } + return (AreaNode) generatedAreas.get(generatedAreas.size() - 1); + } + + /** + * @return The last Area generated by the parent FObj. + */ + public Area getLastAreaGeneratedBy() { + if (generatedAreas == null || generatedAreas.size() < 1) { + return null; + } + for (int i = generatedAreas.size() - 1; i >= 0; i--) { + Object object = generatedAreas.get(i); + if (object instanceof Area) { + return (Area) object; + } + } + return null; + } + + public Area 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 (generatedAreas == null) { + return null; + } + for (int i = 0; i < generatedAreas.size(); i ++) { + Object object = generatedAreas.get(i); + if (object instanceof Area) { + return (Area) object; + } + } + return null; + } + + public Area 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 (generatedAreas == null) { + return null; + } + for (int i = generatedAreas.size() - 1; i >= 0; i --) { + Object object = generatedAreas.get(i); + if (object instanceof Area) { + return (Area) object; + } + } + return null; + } + +} Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java 2006-06-12 15:05:56 UTC (rev 7531) +++ trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java 2006-06-12 15:14:48 UTC (rev 7532) @@ -531,7 +531,7 @@ */ private boolean startsHere(Marker marker) { FObj parent = marker.parentFO(); - FOLinkage proxy = linkage(parent); + FOLinkageNormal proxy = linkage(parent); Area firstArea = (Area) proxy.firstNormalAreaReturned(); if (firstArea == null) { return false; @@ -548,7 +548,7 @@ */ private boolean endsHere(Marker marker) { FObj parent = marker.parentFO(); - FOLinkage proxy = linkage(parent); + FOLinkageNormal proxy = linkage(parent); Area lastArea = (Area) proxy.lastNormalAreaReturned(); if (lastArea == null) { return false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |