[FOray-commit] SF.net SVN: foray: [7152] 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-05-09 01:12:19
|
Revision: 7152 Author: victormote Date: 2006-05-06 15:25:18 -0700 (Sat, 06 May 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7152&view=rev Log Message: ----------- Separate the AreaTree linkage/generated-by concept from the Layout proxy concept. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/AreaNode.java trunk/foray/foray-areatree/src/java/org/foray/area/FOrayFONodeProxy.java trunk/foray/foray-areatree/src/java/org/foray/area/LayoutStrategy.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FObjPL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnotePL.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RowSpanMgr.java trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TablePL.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-05-06 21:28:53 UTC (rev 7151) +++ trunk/foray/foray-areatree/src/java/org/foray/area/AreaNode.java 2006-05-06 22:25:18 UTC (rev 7152) @@ -133,12 +133,12 @@ if (fobj == null) { return null; } - FOrayFONodeProxy proxy = (FOrayFONodeProxy) fobj.getProxy(); - if (proxy == null) { - proxy = this.getLayoutStrategy().makeFObjProxy(fobj); - fobj.setProxy(proxy); + FOrayFONodeProxy linkage = (FOrayFONodeProxy) fobj.getResult(); + if (linkage == null) { + linkage = new FOrayFONodeProxy(fobj); + fobj.setResult(linkage); } - return proxy; + return linkage; } protected org.axsl.areaW.AreaNode getPreviousChildOfGeneratedBy() { Modified: trunk/foray/foray-areatree/src/java/org/foray/area/FOrayFONodeProxy.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/FOrayFONodeProxy.java 2006-05-06 21:28:53 UTC (rev 7151) +++ trunk/foray/foray-areatree/src/java/org/foray/area/FOrayFONodeProxy.java 2006-05-06 22:25:18 UTC (rev 7152) @@ -35,10 +35,9 @@ * <p>An implementation of {@link org.axsl.foR.FONodeProxy} suitable for use * with FOray.</p> */ -public class FOrayFONodeProxy implements org.axsl.foR.FONodeProxy, - FOLinkage { +public class FOrayFONodeProxy implements FOLinkage { - /** The real FONode which this proxy represents. */ + /** The FONode which generated the Areas in {@link #generatedAreas}. */ private FONode realFONode; /** @@ -47,7 +46,7 @@ * This is currently set up to only store the root node of any subtree that * was generated by {@link #realFONode}. */ - private ArrayList generatedAreas; + private ArrayList generatedAreas = new ArrayList(); public FOrayFONodeProxy(FONode realFObj) { this.realFONode = realFObj; Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LayoutStrategy.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/LayoutStrategy.java 2006-05-06 21:28:53 UTC (rev 7151) +++ trunk/foray/foray-areatree/src/java/org/foray/area/LayoutStrategy.java 2006-05-06 22:25:18 UTC (rev 7152) @@ -27,6 +27,7 @@ import org.foray.common.FOrayException; import org.axsl.foR.FONode; +import org.axsl.foR.FONodeProxy; import org.axsl.foR.FOText; import org.axsl.foR.FObj; import org.axsl.foR.FObjMixed; @@ -130,9 +131,7 @@ * @param node * @return A new FObjProxy which proxies node. */ - public FOrayFONodeProxy makeFObjProxy(FONode node) { - return new FOrayFONodeProxy(node); - } + public abstract FONodeProxy makeFObjProxy(FONode node) ; public void handleLineBreakText(LineOutput lineOutput, LineText text, int startOffset, int sizeInChars, int sizeInline, Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java 2006-05-06 21:28:53 UTC (rev 7151) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/ContinuedLabelPL.java 2006-05-06 22:25:18 UTC (rev 7152) @@ -27,6 +27,7 @@ import org.foray.area.Area; import org.foray.common.FOrayException; +import org.axsl.areaW.FOLinkage; import org.axsl.foR.FONode; import org.axsl.foR.extension.ContinuedLabel; import org.axsl.foR.fo.Table; @@ -60,8 +61,8 @@ // See if ancestor table has generated any areas yet. Table table = label.getNearestTable(); - TablePL tablePL = (TablePL) layout.getFObjProxy(table); - if (tablePL != null && tablePL.qtyAreasGenerated() > 0) { + FOLinkage linkage = (FOLinkage) table.getResult(); + if (linkage != null && linkage.qtyAreasGenerated() > 0) { int numChildren = label.getChildren().size(); for (int i = getProgress(); i < numChildren; i++) { FONode fo = (FONode)label.getChildren().get(i); Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java 2006-05-06 21:28:53 UTC (rev 7151) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FONodePL.java 2006-05-06 22:25:18 UTC (rev 7152) @@ -30,6 +30,8 @@ import org.foray.area.NormalBlockArea; import org.foray.common.FOrayException; +import org.axsl.areaW.AreaNode; +import org.axsl.areaW.FOLinkage; import org.axsl.foR.FONode; import org.axsl.foR.FObj; import org.axsl.text.TextException; @@ -44,7 +46,7 @@ /** * */ -public abstract class FONodePL extends FOrayFONodeProxy { +public abstract class FONodePL implements org.axsl.foR.FONodeProxy { /** value of progress before layout begins. */ public static final int START = -1000; @@ -52,6 +54,9 @@ /** value of progress after break-after. */ public static final int BREAK_AFTER = -1001; + /** The real FONode which this proxy represents. */ + private FONode realFONode; + /** * where the layout was up to. * for FObjs it is the child number @@ -62,7 +67,8 @@ protected PioneerLS layout; public FONodePL(FONode realFObj, PioneerLS layout) { - super(realFObj); + this.realFONode = realFObj; + realFObj.setProxy(this); this.layout = layout; } @@ -113,9 +119,20 @@ } protected FONodePL getFObjProxy(FONode node) { - return (FONodePL) layout.getFObjProxy(node); + if (node == null) { + return null; + } + FONodePL proxy = (FONodePL) node.getProxy(); + if (proxy == null) { + proxy = (FONodePL) this.layout.makeFObjProxy(node); + } + return proxy; } + protected FOrayFONodeProxy getFONodeResult(FONode node) { + return (FOrayFONodeProxy) node.getResult(); + } + public abstract int layout(Area area) throws FOrayException; public Log getLogger() { @@ -228,4 +245,28 @@ return blockArea.getCurrentLineArea(); } + public FONode getFONode() { + return this.realFONode; + } + + public FOLinkage getFOLinkage() { + FONode foNode = this.getFONode(); + if (foNode == null) { + return null; + } + FOLinkage linkage = (FOLinkage) foNode.getResult(); + if (linkage == null) { + return null; + } + return linkage; + } + + public AreaNode getLastGeneratedBy() { + FOLinkage linkage = getFOLinkage(); + if (linkage == null) { + return null; + } + return linkage.getLastGeneratedBy(); + } + } Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FObjPL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FObjPL.java 2006-05-06 21:28:53 UTC (rev 7151) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FObjPL.java 2006-05-06 22:25:18 UTC (rev 7152) @@ -67,7 +67,8 @@ return snapshot; } FONode node = ((FONode)children.get(this.progress)); - return getFObjProxy(node).getProgressSnapshot(snapshot); + FONodePL proxy = getFObjProxy(node); + return proxy.getProgressSnapshot(snapshot); } public void rollback(ArrayList snapshot) { @@ -107,7 +108,7 @@ return null; } // Find the last Area generated by that FO - org.axsl.areaW.AreaNode lastGenerated = getFObjProxy(previousSibling) + org.axsl.areaW.AreaNode lastGenerated = getFONodeResult(previousSibling) .getLastGeneratedBy(); if (lastGenerated == null) { return null; Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnotePL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnotePL.java 2006-05-06 21:28:53 UTC (rev 7151) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnotePL.java 2006-05-06 22:25:18 UTC (rev 7152) @@ -59,8 +59,7 @@ FONode fo = (FONode)node.childrenFO().get(i); if (fo instanceof Inline) { inline = (Inline) fo; - FObjMixedPL inlinePL = (FObjMixedPL) layout.getFObjProxy( - inline); + FObjMixedPL inlinePL = (FObjMixedPL) inline.getProxy(); int status = inlinePL.layout(area); if (Status.isIncomplete(status)) { return status; Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java 2006-05-06 21:28:53 UTC (rev 7151) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java 2006-05-06 22:25:18 UTC (rev 7152) @@ -25,7 +25,6 @@ package org.foray.pioneer; import org.foray.area.Area; -import org.foray.area.FOrayFONodeProxy; import org.foray.area.LayoutStrategy; import org.foray.area.LineArea; import org.foray.area.NormalBlockArea; @@ -38,6 +37,7 @@ import org.axsl.common.Constants; import org.axsl.foR.FONode; +import org.axsl.foR.FONodeProxy; import org.axsl.foR.FOText; import org.axsl.foR.FObj; import org.axsl.foR.FObjMixed; @@ -107,8 +107,7 @@ if (area.pendingFootnotes != null) { for (int i = 0; i < area.pendingFootnotes.size(); i++) { FootnoteBody fb = (FootnoteBody)area.pendingFootnotes.get(i); - FootnoteBodyPL fbPL - = ((FootnoteBodyPL) getFObjProxy(fb)); + FootnoteBodyPL fbPL = ((FootnoteBodyPL) fb.getProxy()); PageRA page = area.getPage(); if (! fbPL.layoutFootnote(page, area)) { page.addPendingFootnote(fb); @@ -125,6 +124,7 @@ throws FOrayException { PageSequence pageSeq = pageCollection.getPageSequence(); org.axsl.foR.fo.Flow flow = pageSeq.getFlow(); + flow.setProxy(new FlowPL(flow, this)); pageCollection.padPagesAtBeginning(); // make pages and layout content @@ -158,7 +158,7 @@ * static content. This is likely also justifiable because of spec. */ RegionRABody bodyArea = currentPage.getRegionRABody(); - FlowPL flowPL = (FlowPL) this.getFObjProxy(flow); + FlowPL flowPL = (FlowPL) flow.getProxy(); flowPL.layout(bodyArea); currentPage.formatStaticContent(this); currentPage.layoutComplete(); @@ -172,8 +172,7 @@ if (footnotes != null) { for (int i = 0; i < footnotes.size(); i++) { FootnoteBody fb = (FootnoteBody)footnotes.get(i); - FootnoteBodyPL fbPL - = ((FootnoteBodyPL) getFObjProxy(fb)); + FootnoteBodyPL fbPL = ((FootnoteBodyPL) fb.getProxy()); if (! fbPL.layoutFootnote(pageArea, null)) { // footnotes are too large to fit on empty page } @@ -195,8 +194,7 @@ if (staticContent == null) { return; } - StaticContentPL staticPL - = (StaticContentPL) this.getFObjProxy(staticContent); + StaticContentPL staticPL = (StaticContentPL) staticContent.getProxy(); staticPL.layout(area); } @@ -255,7 +253,7 @@ } } - public FOrayFONodeProxy makeFObjProxy(FONode node) { + public FONodeProxy makeFObjProxy(FONode node) { switch (node.getNodeType()) { case FONode.NODE_ABSTRACT_FLOW: { return null; Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RowSpanMgr.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RowSpanMgr.java 2006-05-06 21:28:53 UTC (rev 7151) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/RowSpanMgr.java 2006-05-06 22:25:18 UTC (rev 7152) @@ -68,7 +68,7 @@ } TableCellPL getTableCellPL() { - return (TableCellPL) layout.getFObjProxy(this.cell); + return (TableCellPL) this.cell.getProxy(); } } Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TablePL.java =================================================================== --- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TablePL.java 2006-05-06 21:28:53 UTC (rev 7151) +++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/TablePL.java 2006-05-06 22:25:18 UTC (rev 7152) @@ -379,8 +379,7 @@ int columnOffset = 0; for (int i = 0; i < node.getTableColumns().size(); i++) { TableColumn column = (TableColumn) node.getTableColumns().get(i); - TableColumnPL columnPL = (TableColumnPL) layout.getFObjProxy( - column); + TableColumnPL columnPL = (TableColumnPL) column.getProxy(); if (columnPL != null) { columnPL.setColumnOffset(columnOffset); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |