Package org.axsl.fo.fo

Examples of org.axsl.fo.fo.Table


     * definition of the table-cell content-rectangle.
     */
    public int getResolvedGridIPD(final int startingColumn,
            final int inputNumberColumns) {
        int numberColumns = inputNumberColumns;
        final Table table = this.traitGeneratedBy();
        if (startingColumn + numberColumns - 1 > table.numberOfColumns()) {
            numberColumns = table.numberOfColumns() - startingColumn + 1;
        }
        int ipd = 0;
        for (int count = 0; count < numberColumns; count++) {
            final int columnNumber = startingColumn + count;
            ipd += getResolvedColumnWidth(columnNumber);
View Full Code Here


     * @return The new width of the table.
     */
    private int calcAutoColumnWidths() {
        /* For "auto" column width, start by just making all of the columns
         * equal. */
        final Table table = this.traitGeneratedBy();
        final int tableWidth = table.traitIpDimensionOpt(this);
        if (this.resolvedColumnWidth.length < 1) {
            /* TODO: Consider throwing an exception here. */
            return 0;
        }
        final int colWidth = tableWidth / this.resolvedColumnWidth.length;
View Full Code Here

     * @param maxAllocationIPD The maximum width of the area into which the
     * columns can be placed.
     * @return The new width of the table.
     */
    private int calcFixedColumnWidths(final int maxAllocationIPD) {
        final Table table = this.traitGeneratedBy();
        /* Accumulates the total table units used in columns in this table. */
        double totalTableUnits = 0.0;
        /* Accumulates the total width, in millipoints, of the columns that
         * have a fixed width. */
        int totalFixedWidth = 0;
        /* Minimum number of proportional units. */
        double tuMin = Double.MAX_VALUE;
        /* Loop through the columns and total the fixed widths and proportional
         * units for each one. */
        for (int i = 0; i < table.getTableColumns().length; i++) {
            final TableColumn column = table.getTableColumns()[i];
            if (column == null) {
                getLogger().warn("No table-column specification for column " +
                         (i + 1) + ".");
            } else {
                final double tu = column.traitColumnWidthTableUnits();
                /* Keep track of minimum number of proportional units in any
                 * column which has only proportional units. */
                if (tu > 0 && tu < tuMin
                        && column.traitColumnWidth(this) == 0) {
                    tuMin = tu;
                }
                totalTableUnits += tu;
                totalFixedWidth += column.traitColumnWidth(this);
            }
        }

        double dWidthFactor = 0.0;
        double dUnitLength = 0.0;
        int optIPD;
        int minIPD;
        int maxIPD;

        final boolean bHasProportionalUnits = totalTableUnits > 0.0;
        if (table.traitIpDimensionMax(this) >= 0) {
            maxIPD = table.traitIpDimensionMax(this);
        } else {
            maxIPD = maxAllocationIPD;
        }

        if (table.traitIpDimensionOpt(this) < 0) {
            optIPD = -1;
        } else {
            optIPD = table.traitIpDimensionOpt(this);
        }

        if (table.traitIpDimensionMin(this) < 0) {
            minIPD = -1;
        } else {
            minIPD = table.traitIpDimensionMin(this);
        }

        if (bHasProportionalUnits && optIPD < 0) {
            if (minIPD > 0) {
                if (table.traitIpDimensionMax(this) >= 0) {
                    optIPD = (minIPD + maxIPD) / 2;
                } else {
                    optIPD = minIPD;
                }
            } else if (table.traitIpDimensionMax(this) >= 0) {
                optIPD = maxIPD;
            } else {
                getLogger().error("At least one of minimum, optimum, or "
                        + "maximum IPD must be specified on table.");
                optIPD = maxIPD;
            }
        }

        if (totalTableUnits > 0.0) {
            int iProportionalWidth = 0;
            if (optIPD > totalFixedWidth) {
                iProportionalWidth = optIPD - totalFixedWidth;
            } else if (maxIPD > totalFixedWidth) {
                iProportionalWidth = maxIPD - totalFixedWidth;
            } else {
                iProportionalWidth = maxAllocationIPD - totalFixedWidth;
            }
            if (iProportionalWidth > 0) {
                dUnitLength = iProportionalWidth / totalTableUnits;
            } else {
                getLogger().error("Sum of fixed column widths "
                        + totalFixedWidth
                        + " greater than maximum available IPD "
                        + maxAllocationIPD + "; no space for "
                        + totalTableUnits + " proportional units.");
                /* Set remaining proportional units to a number which
                 * will assure the minimum column size for tuMin.
                 */
                dUnitLength = TableRA.MINCOLWIDTH / tuMin;
                // Reduce fixed column widths by this much???
            }
            //log.debug("1 table-unit = " + dUnitLength + " mpt");
        } else {
            /* No proportional units. If minimum IPD is specified, check
             * that sum of column widths > minIPD.
             */
            if (minIPD > totalFixedWidth) {
                // Add extra space to each column
                dWidthFactor = (double) minIPD / (double) totalFixedWidth;
            } else if (maxIPD < totalFixedWidth) {
                // Note: if maxIPD=auto, use maxAllocWidth
                getLogger().warn("Sum of fixed column widths "
                        + totalFixedWidth
                        + " greater than maximum specified IPD " + maxIPD);
            } else if (optIPD != -1 && totalFixedWidth != optIPD) {
                getLogger().warn("Sum of fixed column widths "
                        + totalFixedWidth
                        + " differs from specified optimum IPD " + optIPD);
            }
        }
        // Now distribute the extra units onto each column and set offsets
        int columnOffset = 0;
        for (int i = 0; i < table.getTableColumns().length; i++) {
            final TableColumn column = table.getTableColumns()[i];
            if (column != null) {
                //Compute the width of the column
                int colWidth = -1;
                if (column.traitColumnWidthTableUnits() > 0) {
                    //Proportional width
View Full Code Here

            }
            /* Per the XSL-FO standard 1.0, Section 5.10.4, it is an error for
             * this function to be used within a table unless the table-layout
             * is "fixed".
             */
            Table table = null;
            if (fobj instanceof Table) {
                table = (Table) fobj;
            } else {
                /* TODO: Provide the right context. */
                table = fobj.ancestorTable(null);
            }
            if (table == null) {
                throw new PropertyException("Ancestor 'table' object not found "
                        + "for function \"proportional-column-width\".");
            }
            if (table.traitTableLayout() != TableLayout.FIXED) {
                throw new PropertyException("Table layout must be \"fixed\" "
                        + "for function \"proportional-column-width\".");
            }
            break;
        }
View Full Code Here

        if (tableRA == null) {
            throw new IllegalStateException("Attempted to get the width of "
                    + "the nearest table in a context that is not inside a "
                    + "table.");
        }
        final Table table = tableRA.traitGeneratedBy();
        return table.traitIpDimensionOpt(tableRA);
    }
View Full Code Here

     * relative to the column start edge.
     * @return The adjustment to the start edge.
     */
    public int getStartAdjust() {
        final TableRA tableArea = this.ancestorTableArea();
        final Table table = tableArea.traitGeneratedBy();
        if (table.traitBorderCollapse(this) == BorderModel.SEPARATE) {
            final int iSep = table.traitBorderSeparationIpd(this);
            return iSep / 2 + table.traitBorderStartWidth(this)
                               + table.traitPaddingStart(this);
        }
        return table.traitBorderStartWidth(this) / 2
                + table.traitPaddingStart(this);
    }
View Full Code Here

     */
    public Status layout(final AreaNode areaNode,
            final GraftingPoint graftingPoint) throws AreaTreeException {
        final Fo node = getFONode();
        final TableArea tableArea = (TableArea) areaNode;
        final Table table = tableArea.traitGeneratedBy();
        if (getProgress() == FONodePL.BREAK_AFTER) {
            return Status.OK;
        }

        if (getProgress() == FONodePL.START) {
            if (this.rowSpanMgr == null) {
                this.rowSpanMgr = new RowSpanMgr(table.getTableColumns().length,
                        this.getLayout());
            }

            // if (this.isInListBody) {
            // startIndent += bodyIndent + distanceBetweenStarts;
View Full Code Here

     * issues.
     * @return The allocation height of the cell area.
     */
    public int getHeight(final FoContext context) {
        final TableArea tableArea = this.areaContainer.ancestorTableArea();
        final Table table = tableArea.traitGeneratedBy();
        return this.areaContainer.crBpd()
                + table.traitBorderSeparationBpd(context)
                - (this.node.traitBorderBeforeWidth(context)
                + this.node.traitBorderAfterWidth(context))
                / 2;
    }
View Full Code Here

TOP

Related Classes of org.axsl.fo.fo.Table

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.