protected TableBorders applyTopTableBorder(Rectangle occupiedBox, Rectangle layoutBox, boolean reverse) { float topIndent = (reverse ? -1 : 1) * getMaxTopWidth(); layoutBox.decreaseHeight(topIndent / 2); occupiedBox.moveDown(topIndent / 2).increaseHeight(topIndent / 2); return this; }
@Override protected TableBorders applyTopTableBorder(Rectangle occupiedBox, Rectangle layoutBox, boolean reverse) { float topIndent = (reverse ? -1 : 1) * getMaxTopWidth(); layoutBox.decreaseHeight(topIndent); occupiedBox.moveDown(topIndent).increaseHeight(topIndent); return this; }
@Override protected TableBorders applyTopTableBorder(Rectangle occupiedBox, Rectangle layoutBox, boolean reverse) { float topIndent = (reverse ? -1 : 1) * getMaxTopWidth(); layoutBox.decreaseHeight(topIndent); occupiedBox.moveDown(topIndent).increaseHeight(topIndent); return this; }
@Override protected TableBorders applyBottomTableBorder(Rectangle occupiedBox, Rectangle layoutBox, boolean reverse) { float bottomTableBorderWidth = (reverse ? -1 : 1) * getMaxBottomWidth(); layoutBox.decreaseHeight(bottomTableBorderWidth); occupiedBox.moveDown(bottomTableBorderWidth).increaseHeight(bottomTableBorderWidth); return this; }
protected TableBorders applyBottomTableBorder(Rectangle occupiedBox, Rectangle layoutBox, boolean reverse) { float bottomTableBorderWidth = (reverse ? -1 : 1) * getMaxBottomWidth(); layoutBox.decreaseHeight(bottomTableBorderWidth / 2); occupiedBox.moveDown(bottomTableBorderWidth / 2).increaseHeight(bottomTableBorderWidth / 2); return this; }
protected TableBorders applyBottomTableBorder(Rectangle occupiedBox, Rectangle layoutBox, boolean reverse) { float bottomTableBorderWidth = (reverse ? -1 : 1) * getMaxBottomWidth(); layoutBox.decreaseHeight(bottomTableBorderWidth / 2); occupiedBox.moveDown(bottomTableBorderWidth / 2).increaseHeight(bottomTableBorderWidth / 2); return this; }
protected TableBorders applyTopTableBorder(Rectangle occupiedBox, Rectangle layoutBox, boolean reverse) { float topIndent = (reverse ? -1 : 1) * getMaxTopWidth(); layoutBox.decreaseHeight(topIndent / 2); occupiedBox.moveDown(topIndent / 2).increaseHeight(topIndent / 2); return this; }
@Override protected TableBorders applyBottomTableBorder(Rectangle occupiedBox, Rectangle layoutBox, boolean reverse) { float bottomTableBorderWidth = (reverse ? -1 : 1) * getMaxBottomWidth(); layoutBox.decreaseHeight(bottomTableBorderWidth); occupiedBox.moveDown(bottomTableBorderWidth).increaseHeight(bottomTableBorderWidth); return this; }
protected void extendLastRow(CellRenderer[] lastRow, Rectangle freeBox) { if (null != lastRow && 0 != heights.size()) { heights.set(heights.size() - 1, heights.get(heights.size() - 1) + freeBox.getHeight()); occupiedArea.getBBox().moveDown(freeBox.getHeight()).increaseHeight(freeBox.getHeight()); for (CellRenderer cell : lastRow) { if (null != cell) { cell.occupiedArea.getBBox().moveDown(freeBox.getHeight()).increaseHeight(freeBox.getHeight()); } } freeBox.moveUp(freeBox.getHeight()).setHeight(0); } }
protected void extendLastRow(CellRenderer[] lastRow, Rectangle freeBox) { if (null != lastRow && 0 != heights.size()) { heights.set(heights.size() - 1, heights.get(heights.size() - 1) + freeBox.getHeight()); occupiedArea.getBBox().moveDown(freeBox.getHeight()).increaseHeight(freeBox.getHeight()); for (CellRenderer cell : lastRow) { if (null != cell) { cell.occupiedArea.getBBox().moveDown(freeBox.getHeight()).increaseHeight(freeBox.getHeight()); } } freeBox.moveUp(freeBox.getHeight()).setHeight(0); } }
private void addNotYetAppliedTopMargin(Rectangle layoutBox) { // normally, space for margins is added when content is met, however if all kids were self-collapsing (i.e. // had no content) or if there were no kids, we need to add it when no more adjoining margins will be met float indentTop = collapseInfo.getCollapseBefore().getCollapsedMarginsSize(); renderer.getOccupiedArea().getBBox().moveDown(indentTop); // Even though all kids have been already drawn, we still need to adjust layout box here // in order to make it represent the available area for element content (e.g. needed for fixed height elements). applyTopMargin(layoutBox, indentTop); }
private void applyTopMargin(Rectangle box, float topIndent) { float bufferLeftoversOnTop = collapseInfo.getBufferSpaceOnTop() - topIndent; float usedTopBuffer = bufferLeftoversOnTop > 0 ? topIndent : collapseInfo.getBufferSpaceOnTop(); collapseInfo.setUsedBufferSpaceOnTop(usedTopBuffer); subtractUsedTopBufferFromBottomBuffer(usedTopBuffer); if (bufferLeftoversOnTop >= 0) { collapseInfo.setBufferSpaceOnTop(bufferLeftoversOnTop); box.moveDown(topIndent); } else { box.moveDown(collapseInfo.getBufferSpaceOnTop()); collapseInfo.setBufferSpaceOnTop(0); box.setHeight(box.getHeight() + bufferLeftoversOnTop); } }
private void applyTopMargin(Rectangle box, float topIndent) { float bufferLeftoversOnTop = collapseInfo.getBufferSpaceOnTop() - topIndent; float usedTopBuffer = bufferLeftoversOnTop > 0 ? topIndent : collapseInfo.getBufferSpaceOnTop(); collapseInfo.setUsedBufferSpaceOnTop(usedTopBuffer); subtractUsedTopBufferFromBottomBuffer(usedTopBuffer); if (bufferLeftoversOnTop >= 0) { collapseInfo.setBufferSpaceOnTop(bufferLeftoversOnTop); box.moveDown(topIndent); } else { box.moveDown(collapseInfo.getBufferSpaceOnTop()); collapseInfo.setBufferSpaceOnTop(0); box.setHeight(box.getHeight() + bufferLeftoversOnTop); } }
private void addNotYetAppliedTopMargin(Rectangle layoutBox) { // normally, space for margins is added when content is met, however if all kids were self-collapsing (i.e. // had no content) or if there were no kids, we need to add it when no more adjoining margins will be met float indentTop = collapseInfo.getCollapseBefore().getCollapsedMarginsSize(); renderer.getOccupiedArea().getBBox().moveDown(indentTop); // Even though all kids have been already drawn, we still need to adjust layout box here // in order to make it represent the available area for element content (e.g. needed for fixed height elements). applyTopMargin(layoutBox, indentTop); }
private void applySelfCollapsedKidMarginWithClearance(Rectangle layoutBox) { // Self-collapsed kid margin with clearance will not be applied to parent top margin // if parent is not self-collapsing. It's self-collapsing kid, thus we just can // add this area to occupied area of parent. float clearedKidMarginWithClearance = prevChildMarginInfo.getOwnCollapseAfter().getCollapsedMarginsSize(); renderer.getOccupiedArea().getBBox(). increaseHeight(clearedKidMarginWithClearance) .moveDown(clearedKidMarginWithClearance); layoutBox.decreaseHeight(clearedKidMarginWithClearance); }
private void applySelfCollapsedKidMarginWithClearance(Rectangle layoutBox) { // Self-collapsed kid margin with clearance will not be applied to parent top margin // if parent is not self-collapsing. It's self-collapsing kid, thus we just can // add this area to occupied area of parent. float clearedKidMarginWithClearance = prevChildMarginInfo.getOwnCollapseAfter().getCollapsedMarginsSize(); renderer.getOccupiedArea().getBBox(). increaseHeight(clearedKidMarginWithClearance) .moveDown(clearedKidMarginWithClearance); layoutBox.decreaseHeight(clearedKidMarginWithClearance); }
private void processUsedChildBufferSpaceOnTop(Rectangle layoutBox) { float childUsedBufferSpaceOnTop = childMarginInfo.getUsedBufferSpaceOnTop(); if (childUsedBufferSpaceOnTop > 0) { if (childUsedBufferSpaceOnTop > collapseInfo.getBufferSpaceOnTop()) { childUsedBufferSpaceOnTop = collapseInfo.getBufferSpaceOnTop(); } collapseInfo.setBufferSpaceOnTop(collapseInfo.getBufferSpaceOnTop() - childUsedBufferSpaceOnTop); collapseInfo.setUsedBufferSpaceOnTop(childUsedBufferSpaceOnTop); // usage of top buffer space on child is expressed by moving layout box down instead of making it smaller, // so in order to process next kids correctly, we need to move parent layout box also layoutBox.moveDown(childUsedBufferSpaceOnTop); subtractUsedTopBufferFromBottomBuffer(childUsedBufferSpaceOnTop); } }
/** * If there is some space left, we will move the footer up, because initially the footer is at the very bottom of the area. * We also will adjust the occupied area by the footer's size if it is present. * * @param layoutBox the layout box which represents the area which is left free. */ private void adjustFooterAndFixOccupiedArea(Rectangle layoutBox, float verticalBorderSpacing) { if (footerRenderer != null) { footerRenderer.move(0, layoutBox.getHeight() + verticalBorderSpacing); float footerHeight = footerRenderer.getOccupiedArea().getBBox().getHeight() - verticalBorderSpacing; occupiedArea.getBBox().moveDown(footerHeight).increaseHeight(footerHeight); } }
/** * If there is some space left, we will move the footer up, because initially the footer is at the very bottom of the area. * We also will adjust the occupied area by the footer's size if it is present. * * @param layoutBox the layout box which represents the area which is left free. */ private void adjustFooterAndFixOccupiedArea(Rectangle layoutBox, float verticalBorderSpacing) { if (footerRenderer != null) { footerRenderer.move(0, layoutBox.getHeight() + verticalBorderSpacing); float footerHeight = footerRenderer.getOccupiedArea().getBBox().getHeight() - verticalBorderSpacing; occupiedArea.getBBox().moveDown(footerHeight).increaseHeight(footerHeight); } }
private void processUsedChildBufferSpaceOnTop(Rectangle layoutBox) { float childUsedBufferSpaceOnTop = childMarginInfo.getUsedBufferSpaceOnTop(); if (childUsedBufferSpaceOnTop > 0) { if (childUsedBufferSpaceOnTop > collapseInfo.getBufferSpaceOnTop()) { childUsedBufferSpaceOnTop = collapseInfo.getBufferSpaceOnTop(); } collapseInfo.setBufferSpaceOnTop(collapseInfo.getBufferSpaceOnTop() - childUsedBufferSpaceOnTop); collapseInfo.setUsedBufferSpaceOnTop(childUsedBufferSpaceOnTop); // usage of top buffer space on child is expressed by moving layout box down instead of making it smaller, // so in order to process next kids correctly, we need to move parent layout box also layoutBox.moveDown(childUsedBufferSpaceOnTop); subtractUsedTopBufferFromBottomBuffer(childUsedBufferSpaceOnTop); } }