private void applyPadding(Rectangle r, boolean isLeft) { if (isLeft) { r.setRight(r.getRight() - hPadding); } else { r.setLeft(r.getLeft() + hPadding); } }
public boolean fits() { final boolean simulate = true; // try adding into a single infinite column to calc height ColumnTextBuilder ctb = b.reuseColumnTextBuilder(); b.reuseRectangleBuilder(tempR).copyPositionsFrom(rectangle); tempR.setBottom(-10000f); tempR.setRight(horCenter()); applyPadding(tempR, true); ctb.setSimpleColumn(tempR); float yBefore = ctb.getYLine(); contentAdder.add(ctb, simulate); int status = ctb.go(simulate); if (ColumnText.hasMoreText(status)) { return false; } float yAfter = ctb.getYLine(); final float height = yBefore - yAfter; logger.trace("height: {}", height); // if(height > rectangle.getHeight()) { // return false; // } // now try adding into two actual columns final float columnHeight = height / 2 + additionalSpaceForColumn; if (!addToTwoColumns(simulate, columnHeight)) { return false; } addToTwoColumns(false, columnHeight); return true; }
private void setColumn( float height, float horCenter, boolean left, ColumnTextBuilder ctb, boolean simulate) { b.reuseRectangleBuilder(tempR).copyPositionsFrom(rectangle); tempR.setBottom(tempR.getTop() - height); if (left) { tempR.setRight(horCenter); } else { tempR.setLeft(horCenter); tempR.setBottom(-10000f); } applyPadding(tempR, left); logger.debug("setting column to: {}", tempR); ctb.setSimpleColumn(tempR); }