From adf3c2b7cafde18623125d0a7d205dc562cec14a Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Thu, 8 Feb 2007 16:55:11 +0000 Subject: [PATCH] Javadoc for the table layout code git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@504958 13f79535-47bb-0310-9956-ffa450edef68 --- .../table/TableContentLayoutManager.java | 5 ++- .../layoutmgr/table/TableLayoutManager.java | 18 ++++++--- .../fop/layoutmgr/table/TableRowIterator.java | 2 +- .../fop/layoutmgr/table/TableStepper.java | 39 ++++++++++++++++--- 4 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index 2ab9a1cde..64f1ac605 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -217,7 +217,7 @@ public class TableContentLayoutManager implements PercentBaseContext { KnuthPenalty pen = (KnuthPenalty)last; pen.setP(-KnuthPenalty.INFINITE); pen.setBreakClass(rowFO.getBreakBefore()); - } else if (last instanceof BreakElement) { + } else {//if (last instanceof BreakElement) { // TODO vh: seems the only possibility BreakElement breakPoss = (BreakElement) last; breakPoss.setPenaltyValue(-KnuthPenalty.INFINITE); breakPoss.setBreakClass(rowFO.getBreakBefore()); @@ -432,10 +432,11 @@ public class TableContentLayoutManager implements PercentBaseContext { pgus.clear(); TableRow tableRow = null; - int minContentHeight = 0; + int minContentHeight = 0; // Minimum content height for the row int maxCellHeight = 0; int effRowContentHeight = 0; for (int j = 0; j < row.getGridUnits().size(); j++) { +// assert maxColumnCount == 0 || maxColumnCount == row.getGridUnits().size(); // TODO vh maxColumnCount = Math.max(maxColumnCount, row.getGridUnits().size()); GridUnit gu = row.getGridUnit(j); if ((gu.isPrimary() || (gu.getColSpanIndex() == 0 && gu.isLastGridUnitRowSpan())) diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index 2e653e23d..13b606618 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -144,7 +144,14 @@ public class TableLayoutManager extends BlockStackingLayoutManager return halfBorderSeparationIPD; } - /** @see org.apache.fop.layoutmgr.LayoutManager */ + /** + * Handles the Knuth elements at the table level: mainly breaks, spaces and borders + * before and after the table. The Knuth elements for the table cells are handled by + * TableContentLayoutManager. + * + * @see org.apache.fop.layoutmgr.LayoutManager + * @see TableContentLayoutManager#getNextKnuthElements(LayoutContext, int) + */ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { LinkedList returnList = new LinkedList(); @@ -159,8 +166,10 @@ public class TableLayoutManager extends BlockStackingLayoutManager } } + /* + * Compute the IPD and adjust it if necessary (overconstrained) + */ referenceIPD = context.getRefIPD(); - if (getTable().getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) { int contentIPD = getTable().getInlineProgressionDimension().getOptimum(this) .getLength().getValue(this); @@ -173,7 +182,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager } updateContentAreaIPDwithOverconstrainedAdjust(); } - int sumOfColumns = columns.getSumOfColumnWidths(this); if (!autoLayout && sumOfColumns > getContentAreaIPD()) { log.debug(FONode.decorateWithContextInfo( @@ -181,7 +189,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager getTable())); updateContentAreaIPDwithOverconstrainedAdjust(sumOfColumns); } - int availableIPD = referenceIPD - getIPIndents(); if (getContentAreaIPD() > availableIPD) { log.warn(FONode.decorateWithContextInfo( @@ -210,6 +217,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager //Spaces, border and padding to be repeated at each break addPendingMarks(context); + // Elements for the table-header/footer/body LinkedList contentKnuthElements = null; LinkedList contentList = new LinkedList(); //Position returnPosition = new NonLeafPosition(this, null); @@ -537,4 +545,4 @@ public class TableLayoutManager extends BlockStackingLayoutManager } } -} \ No newline at end of file +} diff --git a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java index 2fc91cb4b..6cd7f0f8f 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableRowIterator.java @@ -77,7 +77,7 @@ public class TableRowIterator { //TODO rows should later be a Jakarta Commons LinkedList so concurrent modifications while //using a ListIterator are possible - /** List of cached rows. This a list of EffRow elements. */ + /** List of cached rows. This is a list of EffRow elements. */ private List fetchedRows = new java.util.ArrayList(); /** diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index 6763f8b08..b8e34ba63 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -51,10 +51,25 @@ public class TableStepper { private EffRow[] rowGroup; private int totalHeight; private int activeRow; + /** + * Knuth elements for active cells, per column. Active cells are cells spanning over + * the currently active row. + */ private List[] elementLists; private int[] startRow; + /** + * For each column, index, in the cell's list of Knuth elements, of the element + * starting the current row. + */ private int[] start; + /** + * For each column, index, in the cell's list of Knuth elements, of the element + * ending the current row. + */ private int[] end; + /** + * For each column, widths of the Knuth elements which will be on the current row. + */ private int[] widths; private int[] baseWidth; private int[] borderBefore; @@ -105,10 +120,22 @@ public class TableStepper { return false; } + /** + * Returns the row currently being processed. + * + * @return the row currently being processed + */ private EffRow getActiveRow() { return rowGroup[activeRow]; } + /** + * Returns the grid unit at the given column number on the active row. + * + * @param column column number of the grid unit to get + * @return the corresponding grid unit (may be null) + * @see TableStepper#getActiveRow + */ private GridUnit getActiveGridUnit(int column) { return getActiveRow().safelyGetGridUnit(column); } @@ -200,7 +227,7 @@ public class TableStepper { if (height == 0) { height = row.getHeight().opt; } - list.add(new KnuthBoxCellWithBPD(height, pgu)); + list.add(new KnuthBoxCellWithBPD(height)); elementLists[column] = list; } else { //Copy elements (LinkedList) to array lists to improve @@ -234,7 +261,7 @@ public class TableStepper { * @param context Active LayoutContext * @param rowGroup the row group * @param maxColumnCount the maximum number of columns to expect - * @param bodyType Indicates what type of body is processed (boder, header or footer) + * @param bodyType Indicates what type of body is processed (body, header or footer) * @return the combined element list */ public LinkedList getCombinedKnuthElementsForRowGroup( @@ -599,13 +626,13 @@ public class TableStepper { return this.tclm.getTableLM(); } + /** + * Marker class denoting table cells fitting in just one box (no legal break inside). + */ private class KnuthBoxCellWithBPD extends KnuthBox { - private PrimaryGridUnit pgu; - - public KnuthBoxCellWithBPD(int w, PrimaryGridUnit pgu) { + public KnuthBoxCellWithBPD(int w) { super(w, null, true); - this.pgu = pgu; } } -- 2.39.5