xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vhenneb...@apache.org
Subject svn commit: r614920 - in /xmlgraphics/fop/trunk/src/java/org/apache/fop: fo/flow/table/ layoutmgr/table/
Date Thu, 24 Jan 2008 16:41:03 GMT
Author: vhennebert
Date: Thu Jan 24 08:40:46 2008
New Revision: 614920

URL: http://svn.apache.org/viewvc?rev=614920&view=rev
Log:
Cleanup:
- renamed startRow/startCol into rowIndex/colIndex
- improved javadoc of PrimaryGridUnit.getRowIndex()
- moved colIndex from GridUnit into PrimaryGridUnit since it's only needed there
- simplified EmptyGridUnit constructor

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EffRow.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/GridUnit.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EffRow.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EffRow.java?rev=614920&r1=614919&r2=614920&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EffRow.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EffRow.java Thu Jan 24 08:40:46
2008
@@ -57,7 +57,7 @@
         for (Iterator guIter = gridUnits.iterator(); guIter.hasNext();) {
             Object gu = guIter.next();
             if (gu instanceof PrimaryGridUnit) {
-                ((PrimaryGridUnit) gu).setStartRow(index);
+                ((PrimaryGridUnit) gu).setRowIndex(index);
             }
         }
     }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java?rev=614920&r1=614919&r2=614920&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/EmptyGridUnit.java Thu Jan
24 08:40:46 2008
@@ -30,11 +30,10 @@
     /**
      * @param table the containing table
      * @param row the table-row element this grid unit belongs to (if any)
-     * @param startRow index of the row this grid unit belongs to, 0-based
-     * @param startCol column index, 0-based
+     * @param colIndex column index, 0-based
      */
-    EmptyGridUnit(Table table, TableRow row, int startRow, int startCol) {
-        super(table, row, table.getColumn(startCol), startCol, 0, 0);
+    EmptyGridUnit(Table table, TableRow row, int colIndex) {
+        super(table, row, table.getColumn(colIndex), 0, 0);
     }
 
     /** {@inheritDoc} */

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java?rev=614920&r1=614919&r2=614920&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/FixedColRowGroupBuilder.java
Thu Jan 24 08:40:46 2008
@@ -87,8 +87,7 @@
         GridUnit[] cellRow = new GridUnit[cell.getNumberColumnsSpanned()];
         cellRow[0] = pgu;
         for (int j = 1; j < cell.getNumberColumnsSpanned(); j++) {
-            GridUnit gu = new GridUnit(pgu, currentTableRow, table.getColumn(columnIndex
+ j),
-                    columnIndex + j, j, 0);
+            GridUnit gu = new GridUnit(pgu, currentTableRow, table.getColumn(columnIndex
+ j), j, 0);
             row.set(columnIndex + j, gu);
             cellRow[j] = gu;
         }
@@ -98,7 +97,7 @@
             cellRow = new GridUnit[cell.getNumberColumnsSpanned()];
             for (int j = 0; j < cell.getNumberColumnsSpanned(); j++) {
                 GridUnit gu = new GridUnit(pgu, currentTableRow, table.getColumn(columnIndex
+ j),
-                        columnIndex + j, j, i);
+                        j, i);
                 row.set(columnIndex + j, gu);
                 cellRow[j] = gu;
             }
@@ -124,7 +123,7 @@
         // Fill gaps with empty grid units
         for (int i = 0; i < numberOfColumns; i++) {
             if (currentRow.get(i) == null) {
-                currentRow.set(i, new EmptyGridUnit(table, currentTableRow, currentRowIndex,
i));
+                currentRow.set(i, new EmptyGridUnit(table, currentTableRow, i));
             }
         }
         borderResolver.endRow(currentRow, container);

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/GridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/GridUnit.java?rev=614920&r1=614919&r2=614920&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/GridUnit.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/GridUnit.java Thu Jan 24 08:40:46
2008
@@ -59,9 +59,6 @@
     /** Table column that this grid unit belongs to */
     private TableColumn column;
 
-    /** start index of grid unit within row in column direction */
-    private int startCol;
-
     /** index of grid unit within cell in column direction */
     private int colSpanIndex;
 
@@ -84,13 +81,12 @@
      * @param table the containing table
      * @param row the table-row element this grid unit belongs to (if any)
      * @param column table column this grid unit belongs to
-     * @param startCol index of the column this grid unit belongs to
      * @param colSpanIndex index of this grid unit in the span, in column direction
      * @param rowSpanIndex index of this grid unit in the span, in row direction
      */
-    protected GridUnit(Table table, TableRow row, TableColumn column, int startCol,
-            int colSpanIndex, int rowSpanIndex) {
-        this(row, column, startCol, colSpanIndex, rowSpanIndex);
+    protected GridUnit(Table table, TableRow row, TableColumn column, int colSpanIndex,
+            int rowSpanIndex) {
+        this(row, column, colSpanIndex, rowSpanIndex);
         setBorders(table);
     }
 
@@ -100,13 +96,12 @@
      * @param cell table cell which occupies this grid unit
      * @param row the table-row element this grid unit belongs to (if any)
      * @param column table column this grid unit belongs to
-     * @param startCol index of the column this grid unit belongs to
      * @param colSpanIndex index of this grid unit in the span, in column direction
      * @param rowSpanIndex index of this grid unit in the span, in row direction
      */
-    protected GridUnit(TableCell cell, TableRow row, TableColumn column, int startCol,
-            int colSpanIndex, int rowSpanIndex) {
-        this(row, column, startCol, colSpanIndex, rowSpanIndex);
+    protected GridUnit(TableCell cell, TableRow row, TableColumn column, int colSpanIndex,
+            int rowSpanIndex) {
+        this(row, column, colSpanIndex, rowSpanIndex);
         this.cell = cell;
         setBorders(cell.getTable());
     }
@@ -117,21 +112,18 @@
      * @param primary the before-start grid unit of the cell containing this grid unit
      * @param row the table-row element this grid unit belongs to (if any)
      * @param column table column this grid unit belongs to
-     * @param startCol index of the column this grid unit belongs to
      * @param colSpanIndex index of this grid unit in the span, in column direction
      * @param rowSpanIndex index of this grid unit in the span, in row direction
      */
-    GridUnit(PrimaryGridUnit primary, TableRow row, TableColumn column, int startCol,
-            int colSpanIndex, int rowSpanIndex) {
-        this(primary.getCell(), row, column, startCol, colSpanIndex, rowSpanIndex);
+    GridUnit(PrimaryGridUnit primary, TableRow row, TableColumn column, int colSpanIndex,
+            int rowSpanIndex) {
+        this(primary.getCell(), row, column, colSpanIndex, rowSpanIndex);
         this.primary = primary;
     }
 
-    private GridUnit(TableRow row, TableColumn column, int startCol, int colSpanIndex,
-            int rowSpanIndex) {
+    private GridUnit(TableRow row, TableColumn column, int colSpanIndex, int rowSpanIndex)
{
         this.row = row;
         this.column = column;
-        this.startCol = startCol;
         this.colSpanIndex = colSpanIndex;
         this.rowSpanIndex = rowSpanIndex;
     }
@@ -222,15 +214,6 @@
         return cell == null;
     }
 
-    /**
-     * Returns the index of the column this grid unit belongs to.
-     * 
-     * @return the column index, 0-based
-     */
-    public int getStartCol() {
-        return startCol;
-    }
-
     /** @return true if the grid unit is the last in column spanning direction */
     public boolean isLastGridUnitColSpan() {
         return (colSpanIndex == cell.getNumberColumnsSpanned() - 1);
@@ -474,10 +457,9 @@
                 buffer.append("(last)");
             }
         }
-        buffer.append(" startCol=").append(startCol);
         if (!isPrimary() && getPrimary() != null) {
-            buffer.append(" primary=").append(getPrimary().getStartRow());
-            buffer.append("/").append(getPrimary().getStartCol());
+            buffer.append(" primary=").append(getPrimary().getRowIndex());
+            buffer.append("/").append(getPrimary().getColIndex());
             if (getPrimary().getCell() != null) {
                 buffer.append(" id=" + getPrimary().getCell().getId());
             }

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java?rev=614920&r1=614919&r2=614920&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/table/PrimaryGridUnit.java Thu Jan
24 08:40:46 2008
@@ -22,8 +22,6 @@
 import java.util.LinkedList;
 import java.util.List;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.table.TableCellLayoutManager;
@@ -34,14 +32,17 @@
  */
 public class PrimaryGridUnit extends GridUnit {
 
-    private static Log log = LogFactory.getLog(PrimaryGridUnit.class);
-
     /** Cell layout manager. */
     private TableCellLayoutManager cellLM;
     /** List of Knuth elements representing the contents of the cell. */
     private LinkedList elements;
-    /** Index of row where this cell starts */
-    private int startRow;
+
+    /** Index of the row where this cell starts. */
+    private int rowIndex;
+
+    /** Index of the column where this cell starts. */
+    private int colIndex;
+
     /** Links to the spanned grid units. (List of GridUnit arrays, one array represents a
row) */
     private List rows;
     /** The calculated size of the cell's content. (cached value) */
@@ -56,15 +57,14 @@
      * @param cell table cell which occupies this grid unit
      * @param row the table-row element this grid unit belongs to (if any)
      * @param column table column this grid unit belongs to
-     * @param startCol index of the column this grid unit belongs to, zero-based
-     * @param startRow index of the row this grid unit belongs to, zero-based
+     * @param colIndex index of the column this grid unit belongs to, zero-based
      */
-    PrimaryGridUnit(TableCell cell, TableRow row, TableColumn column, int startCol) {
-        super(cell, row, column, startCol, 0, 0);
+    PrimaryGridUnit(TableCell cell, TableRow row, TableColumn column, int colIndex) {
+        super(cell, row, column, 0, 0);
+        this.colIndex = colIndex;
         this.isSeparateBorderModel = column.getTable().isSeparateBorderModel(); // TODO
         this.halfBorderSeparationBPD = column.getTable().getBorderSeparation().getBPD().getLength()
                 .getValue() / 2;  // TODO
-        log.trace("PrimaryGridUnit created, row " + startRow + " col " + startCol);
     }
 
     public TableCellLayoutManager getCellLM() {
@@ -248,17 +248,29 @@
         rows.add(row);
     }
 
-    void setStartRow(int startRow) {
-        this.startRow = startRow;
+    void setRowIndex(int rowIndex) {
+        this.rowIndex = rowIndex;
     }
 
     /**
-     * Returns the index of the row this grid unit belongs to.
-     *
-     * @return the index of the row this grid unit belongs to.
+     * Returns the index of the row this grid unit belongs to. This is the index, in the
+     * enclosing table part, of the first row spanned by the cell. Note that if the table
+     * has several table-body children, then the index grows continuously across them;
+     * they are considered to form one single part, the "body of the table".
+     * 
+     * @return the index of the row this grid unit belongs to, 0-based.
+     */
+    public int getRowIndex() {
+        return rowIndex;
+    }
+
+    /**
+     * Returns the index of the column this grid unit belongs to.
+     * 
+     * @return the column index, 0-based
      */
-    public int getStartRow() {
-        return this.startRow;
+    public int getColIndex() {
+        return colIndex;
     }
 
     /**
@@ -290,7 +302,7 @@
     /** {@inheritDoc} */
     public String toString() {
         StringBuffer sb = new StringBuffer(super.toString());
-        sb.append(" startRow=").append(startRow);
+        sb.append(" rowIndex=").append(rowIndex);
         return sb.toString();
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?rev=614920&r1=614919&r2=614920&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
Thu Jan 24 08:40:46 2008
@@ -175,8 +175,8 @@
 
                         //Calculate width of cell
                         int spanWidth = 0;
-                        for (int i = primary.getStartCol(); 
-                                i < primary.getStartCol() 
+                        for (int i = primary.getColIndex(); 
+                                i < primary.getColIndex() 
                                         + primary.getCell().getNumberColumnsSpanned();
                                 i++) {
                             if (tableLM.getColumns().getColumn(i + 1) != null) {

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowPainter.java?rev=614920&r1=614919&r2=614920&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowPainter.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/RowPainter.java Thu Jan
24 08:40:46 2008
@@ -117,7 +117,7 @@
             if (log.isDebugEnabled()) {
                 log.debug(">" + cellPart);
             }
-            int colIndex = cellPart.pgu.getStartCol();
+            int colIndex = cellPart.pgu.getColIndex();
             if (firstCellParts[colIndex] == null) {
                 firstCellParts[colIndex] = cellPart;
                 cellHeights[colIndex] = cellPart.getBorderPaddingBefore(firstCellOnPage[colIndex]);
@@ -159,7 +159,7 @@
                 int cellHeight = cellHeights[i];
                 cellHeight += lastCellParts[i].getConditionalAfterContentLength();
                 cellHeight += lastCellParts[i].getBorderPaddingAfter(lastInPart);
-                int cellOffset = getRowOffset(Math.max(firstCellParts[i].pgu.getStartRow(),
+                int cellOffset = getRowOffset(Math.max(firstCellParts[i].pgu.getRowIndex(),
                         firstRowIndex));
                 actualRowHeight = Math.max(actualRowHeight, cellOffset + cellHeight
                         - currentRowOffset);
@@ -256,7 +256,7 @@
          * Determine the index of the first row of this cell that will be displayed on the
          * current page.
          */
-        int startRowIndex = Math.max(pgu.getStartRow(), firstRowIndex);
+        int startRowIndex = Math.max(pgu.getRowIndex(), firstRowIndex);
         int currentRowIndex = currentRow.getIndex();
 
         /*
@@ -280,7 +280,7 @@
         int cellTotalHeight = rowHeight + currentRowOffset - cellOffset;
         if (log.isDebugEnabled()) {
             log.debug("Creating area for cell:");
-            log.debug("  start row: " + pgu.getStartRow() + " " + currentRowOffset + " "
+            log.debug("  start row: " + pgu.getRowIndex() + " " + currentRowOffset + " "
                     + cellOffset);
             log.debug(" rowHeight=" + rowHeight + " cellTotalHeight=" + cellTotalHeight);
         }
@@ -295,8 +295,8 @@
                     startPos, endPos, prevBreak);
         }
         cellLM.addAreas(new KnuthPossPosIter(pgu.getElements(), startPos, endPos + 1),
-                layoutContext, spannedGridRowHeights, startRowIndex - pgu.getStartRow(),
-                currentRowIndex - pgu.getStartRow(), borderBeforeWhich, borderAfterWhich,
+                layoutContext, spannedGridRowHeights, startRowIndex - pgu.getRowIndex(),
+                currentRowIndex - pgu.getRowIndex(), borderBeforeWhich, borderAfterWhich,
                 startRowIndex == firstRowOnPageIndex, lastOnPage);
     }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java?rev=614920&r1=614919&r2=614920&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java
Thu Jan 24 08:40:46 2008
@@ -346,8 +346,8 @@
                         false, false, this);
             }
         } else {
-            boolean inFirstColumn = (primaryGridUnit.getStartCol() == 0);
-            boolean inLastColumn = (primaryGridUnit.getStartCol()
+            boolean inFirstColumn = (primaryGridUnit.getColIndex() == 0);
+            boolean inLastColumn = (primaryGridUnit.getColIndex()
                     + getTableCell().getNumberColumnsSpanned() == getTable()
                     .getNumberOfColumns());
             if (!primaryGridUnit.hasSpanning()) {
@@ -407,7 +407,7 @@
                     int bpd = spannedGridRowHeights[y - startRow];
                     int dx = xoffset;
                     for (int x = 0; x < gridUnits.length; x++) {
-                        int ipd = getTable().getColumn(primaryGridUnit.getStartCol() + x)
+                        int ipd = getTable().getColumn(primaryGridUnit.getColIndex() + x)
                                 .getColumnWidth().getValue((PercentBaseContext) getParent());
                         if (blocks[y][x] != null) {
                             Block block = blocks[y][x];

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java?rev=614920&r1=614919&r2=614920&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
Thu Jan 24 08:40:46 2008
@@ -33,7 +33,7 @@
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.flow.table.EffRow;
-import org.apache.fop.fo.flow.table.GridUnit;
+import org.apache.fop.fo.flow.table.PrimaryGridUnit;
 import org.apache.fop.fo.flow.table.Table;
 import org.apache.fop.fo.flow.table.TableBody;
 import org.apache.fop.fo.flow.table.TableRow;
@@ -273,8 +273,8 @@
      * @param gu the grid unit
      * @return the requested X offset
      */
-    protected int getXOffsetOfGridUnit(GridUnit gu) {
-        int col = gu.getStartCol();
+    protected int getXOffsetOfGridUnit(PrimaryGridUnit gu) {
+        int col = gu.getColIndex();
         return startXOffset + getTableLM().getColumns().getXOffset(col + 1, getTableLM());
     }
     



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message