@Override
 public int getBaselineOffset() {
   int baselineOffset = super.getBaselineOffset();
   if (effSpaceBefore != null) {
     baselineOffset += effSpaceBefore.getOpt();
   }
   if (!discardBorderBefore) {
     baselineOffset += getCommonBorderPaddingBackground().getBorderBeforeWidth(false);
   }
   if (!discardPaddingBefore) {
     baselineOffset += getCommonBorderPaddingBackground().getPaddingBefore(false, this);
   }
   return baselineOffset;
 }
Пример #2
0
  /**
   * The table area is a reference area that contains areas for columns, bodies, rows and the
   * contents are in cells.
   *
   * @param parentIter the position iterator
   * @param layoutContext the layout context for adding areas
   */
  @Override
  public void addAreas(final PositionIterator parentIter, final LayoutContext layoutContext) {
    getParentArea(null);
    addId();

    // add space before, in order to implement display-align = "center" or
    // "after"
    if (layoutContext.getSpaceBefore() != 0) {
      addBlockSpacing(0.0, MinOptMax.getInstance(layoutContext.getSpaceBefore()));
    }

    final int startXOffset = getTable().getCommonMarginBlock().startIndent.getValue(this);

    // add column, body then row areas

    // BPD of the table, i.e., height of its content; table's borders and
    // paddings not counted
    int tableHeight = 0;
    // Body childLM;
    final LayoutContext lc = new LayoutContext(0);

    lc.setRefIPD(getContentAreaIPD());
    this.contentLM.setStartXOffset(startXOffset);
    this.contentLM.addAreas(parentIter, lc);
    tableHeight += this.contentLM.getUsedBPD();

    this.curBlockArea.setBPD(tableHeight);

    if (this.columnBackgroundAreas != null) {
      for (final Iterator iter = this.columnBackgroundAreas.iterator(); iter.hasNext(); ) {
        final ColumnBackgroundInfo b = (ColumnBackgroundInfo) iter.next();
        TraitSetter.addBackground(
            b.backgroundArea,
            b.column.getCommonBorderPaddingBackground(),
            this,
            b.xShift,
            -b.backgroundArea.getYOffset(),
            b.column.getColumnWidth().getValue(this),
            tableHeight);
      }
      this.columnBackgroundAreas.clear();
    }

    if (getTable().isSeparateBorderModel()) {
      TraitSetter.addBorders(
          this.curBlockArea,
          getTable().getCommonBorderPaddingBackground(),
          this.discardBorderBefore,
          this.discardBorderAfter,
          false,
          false,
          this);
      TraitSetter.addPadding(
          this.curBlockArea,
          getTable().getCommonBorderPaddingBackground(),
          this.discardPaddingBefore,
          this.discardPaddingAfter,
          false,
          false,
          this);
    }
    TraitSetter.addBackground(
        this.curBlockArea, getTable().getCommonBorderPaddingBackground(), this);
    TraitSetter.addMargins(
        this.curBlockArea,
        getTable().getCommonBorderPaddingBackground(),
        this.startIndent,
        this.endIndent,
        this);
    TraitSetter.addBreaks(
        this.curBlockArea, getTable().getBreakBefore(), getTable().getBreakAfter());
    TraitSetter.addSpaceBeforeAfter(
        this.curBlockArea, layoutContext.getSpaceAdjust(), this.effSpaceBefore, this.effSpaceAfter);

    flush();

    resetSpaces();
    this.curBlockArea = null;

    notifyEndOfLayout();
  }