/** * {@inheritDoc} */ @Override public LayoutArea clone() { LayoutArea area = new LayoutArea(pageNumber, bBox.clone()); return area; }
/** * Gets the bounding box that contains all content written to the * {@link DrawContext} by this {@link IRenderer}. * * @return the smallest {@link Rectangle} that surrounds the content */ public Rectangle getOccupiedAreaBBox() { return occupiedArea.getBBox().clone(); }
/** * Gets the bounding box that contains all content written to the * {@link DrawContext} by this {@link IRenderer}. * * @return the smallest {@link Rectangle} that surrounds the content */ public Rectangle getOccupiedAreaBBox() { return occupiedArea.getBBox().clone(); }
/** * {@inheritDoc} */ @Override public LayoutArea clone() { LayoutArea area = new LayoutArea(pageNumber, bBox.clone()); return area; }
/** * {@inheritDoc} */ @Override public LayoutArea clone() { RootLayoutArea area = new RootLayoutArea(pageNumber, bBox.clone()); area.setEmptyArea(emptyArea); return area; } }
/** * {@inheritDoc} */ @Override public LayoutArea clone() { RootLayoutArea area = new RootLayoutArea(pageNumber, bBox.clone()); area.setEmptyArea(emptyArea); return area; } }
@Override public Rectangle getOccupiedAreaBBox() { Rectangle bBox = occupiedArea.getBBox().clone(); Float rotationAngle = this.<Float>getProperty(Property.ROTATION_ANGLE); if (rotationAngle != null) { if (!hasOwnProperty(Property.ROTATION_INITIAL_WIDTH) || !hasOwnProperty(Property.ROTATION_INITIAL_HEIGHT)) { Logger logger = LoggerFactory.getLogger(BlockRenderer.class); logger.error(MessageFormatUtil.format(LogMessageConstant.ROTATION_WAS_NOT_CORRECTLY_PROCESSED_FOR_RENDERER, getClass().getSimpleName())); } else { bBox.setWidth((float) this.getPropertyAsFloat(Property.ROTATION_INITIAL_WIDTH)); bBox.setHeight((float) this.getPropertyAsFloat(Property.ROTATION_INITIAL_HEIGHT)); } } return bBox; }
@Override public Rectangle getOccupiedAreaBBox() { Rectangle bBox = occupiedArea.getBBox().clone(); Float rotationAngle = this.<Float>getProperty(Property.ROTATION_ANGLE); if (rotationAngle != null) { if (!hasOwnProperty(Property.ROTATION_INITIAL_WIDTH) || !hasOwnProperty(Property.ROTATION_INITIAL_HEIGHT)) { Logger logger = LoggerFactory.getLogger(BlockRenderer.class); logger.error(MessageFormatUtil.format(LogMessageConstant.ROTATION_WAS_NOT_CORRECTLY_PROCESSED_FOR_RENDERER, getClass().getSimpleName())); } else { bBox.setWidth((float) this.getPropertyAsFloat(Property.ROTATION_INITIAL_WIDTH)); bBox.setHeight((float) this.getPropertyAsFloat(Property.ROTATION_INITIAL_HEIGHT)); } } return bBox; }
@Override protected LayoutArea updateCurrentArea(LayoutResult overflowResult) { if (overflowResult != null && overflowResult.getAreaBreak() != null && overflowResult.getAreaBreak().getType() != AreaBreakType.NEXT_AREA) { nextAreaNumber = 0; } if (nextAreaNumber % columns.length == 0) { super.updateCurrentArea(overflowResult); } return (currentArea = new RootLayoutArea(currentPageNumber, columns[nextAreaNumber++ % columns.length].clone())); } }
@Override protected LayoutArea updateCurrentArea(LayoutResult overflowResult) { if (overflowResult != null && overflowResult.getAreaBreak() != null && overflowResult.getAreaBreak().getType() != AreaBreakType.NEXT_AREA) { nextAreaNumber = 0; } if (nextAreaNumber % columns.length == 0) { super.updateCurrentArea(overflowResult); } return (currentArea = new RootLayoutArea(currentPageNumber, columns[nextAreaNumber++ % columns.length].clone())); } }
/** * {@inheritDoc} */ @Override protected LayoutArea updateCurrentArea(LayoutResult overflowResult) { if (currentArea == null) { int pageNumber = canvas.isCanvasOfPage() ? canvas.getPdfDocument().getPageNumber(canvas.getPage()) : 0; currentArea = new RootLayoutArea(pageNumber, canvas.getRootArea().clone()); } else { setProperty(Property.FULL, true); currentArea = null; } return currentArea; }
public MarginsCollapseInfo startChildMarginsHandling(IRenderer child, Rectangle layoutBox) { if (backupLayoutBox != null) { // this should happen only if previous kid was floated restoreLayoutBoxAfterFailedLayoutAttempt(layoutBox); removeRendererChild(--processedChildrenNum); childMarginInfo = null; } rendererChildren.add(child); int childIndex = processedChildrenNum++; // If renderer is floated, prepare layout box as if it was inline, // however it will be restored from backup when next kid processing will start. boolean childIsBlockElement = !rendererIsFloated(child) && isBlockElement(child); backupLayoutBox = layoutBox.clone(); backupCollapseInfo = new MarginsCollapseInfo(); collapseInfo.copyTo(backupCollapseInfo); prepareBoxForLayoutAttempt(layoutBox, childIndex, childIsBlockElement); if (childIsBlockElement) { childMarginInfo = createMarginsInfoForBlockChild(childIndex); } return this.childMarginInfo; }
public MarginsCollapseInfo startChildMarginsHandling(IRenderer child, Rectangle layoutBox) { if (backupLayoutBox != null) { // this should happen only if previous kid was floated restoreLayoutBoxAfterFailedLayoutAttempt(layoutBox); removeRendererChild(--processedChildrenNum); childMarginInfo = null; } rendererChildren.add(child); int childIndex = processedChildrenNum++; // If renderer is floated, prepare layout box as if it was inline, // however it will be restored from backup when next kid processing will start. boolean childIsBlockElement = !rendererIsFloated(child) && isBlockElement(child); backupLayoutBox = layoutBox.clone(); backupCollapseInfo = new MarginsCollapseInfo(); collapseInfo.copyTo(backupCollapseInfo); prepareBoxForLayoutAttempt(layoutBox, childIndex, childIsBlockElement); if (childIsBlockElement) { childMarginInfo = createMarginsInfoForBlockChild(childIndex); } return this.childMarginInfo; }
/** * {@inheritDoc} */ @Override protected LayoutArea updateCurrentArea(LayoutResult overflowResult) { if (currentArea == null) { int pageNumber = canvas.isCanvasOfPage() ? canvas.getPdfDocument().getPageNumber(canvas.getPage()) : 0; currentArea = new RootLayoutArea(pageNumber, canvas.getRootArea().clone()); } else { setProperty(Property.FULL, true); currentArea = null; } return currentArea; }
protected ImageRenderer autoScale(LayoutArea layoutArea) { Rectangle area = layoutArea.getBBox().clone(); applyMargins(area, false); applyBorderBox(area, false); // if rotation was applied, width would be equal to the width of rectangle bounding the rotated image float angleScaleCoef = imageWidth / (float) width; if (width > angleScaleCoef * area.getWidth()) { updateHeight(UnitValue.createPointValue(area.getWidth() / (float)width * imageHeight)); updateWidth(UnitValue.createPointValue(angleScaleCoef * area.getWidth())); } return this; }
protected ImageRenderer autoScale(LayoutArea layoutArea) { Rectangle area = layoutArea.getBBox().clone(); applyMargins(area, false); applyBorderBox(area, false); // if rotation was applied, width would be equal to the width of rectangle bounding the rotated image float angleScaleCoef = imageWidth / (float) width; if (width > angleScaleCoef * area.getWidth()) { updateHeight(UnitValue.createPointValue(area.getWidth() / (float)width * imageHeight)); updateWidth(UnitValue.createPointValue(angleScaleCoef * area.getWidth())); } return this; }
/** * Calculates the common rectangle which includes all the input rectangles. * * @param rectangles list of input rectangles. * @return common rectangle. */ public static Rectangle getCommonRectangle(Rectangle... rectangles) { float ury = -Float.MAX_VALUE; float llx = Float.MAX_VALUE; float lly = Float.MAX_VALUE; float urx = -Float.MAX_VALUE; for (Rectangle rectangle : rectangles) { if (rectangle == null) continue; Rectangle rec = rectangle.clone(); if (rec.getY() < lly) lly = rec.getY(); if (rec.getX() < llx) llx = rec.getX(); if (rec.getY() + rec.getHeight() > ury) ury = rec.getY() + rec.getHeight(); if (rec.getX() + rec.getWidth() > urx) urx = rec.getX() + rec.getWidth(); } return new Rectangle(llx, lly, urx - llx, ury - lly); }
Rectangle parentBBox = layoutContext.getArea().getBBox().clone(); if (this.<Float>getProperty(Property.ROTATION_ANGLE) != null) { parentBBox.moveDown(AbstractRenderer.INF - parentBBox.getHeight()).setHeight(AbstractRenderer.INF); float height = lineDrawer != null ? lineDrawer.getLineWidth() : 0; occupiedArea = new LayoutArea(layoutContext.getArea().getPageNumber(), parentBBox.clone()); applyMargins(occupiedArea.getBBox(), false); applyRotationLayout(layoutContext.getArea().getBBox().clone()); if (isNotFittingLayoutArea(layoutContext.getArea())) { if (!Boolean.TRUE.equals(getPropertyAsBoolean(Property.FORCED_PLACEMENT))) {
Rectangle parentBBox = layoutContext.getArea().getBBox().clone(); if (this.<Float>getProperty(Property.ROTATION_ANGLE) != null) { parentBBox.moveDown(AbstractRenderer.INF - parentBBox.getHeight()).setHeight(AbstractRenderer.INF); float height = lineDrawer != null ? lineDrawer.getLineWidth() : 0; occupiedArea = new LayoutArea(layoutContext.getArea().getPageNumber(), parentBBox.clone()); applyMargins(occupiedArea.getBBox(), false); applyRotationLayout(layoutContext.getArea().getBBox().clone()); if (isNotFittingLayoutArea(layoutContext.getArea())) { if (!Boolean.TRUE.equals(getPropertyAsBoolean(Property.FORCED_PLACEMENT))) {
Rectangle borderRect = applyMargins(occupiedArea.getBBox().clone(), getMargins(), false); boolean isAreaClipped = clipBorderArea(drawContext, borderRect); BorderRadius[] borderRadii = getBorderRadii();