protected TableBorders applyCellIndents(Rectangle box, float topIndent, float rightIndent, float bottomIndent, float leftIndent, boolean reverse) { box.applyMargins(topIndent / 2, rightIndent / 2, bottomIndent / 2, leftIndent / 2, false); return this; }
@Override protected TableBorders applyLeftAndRightTableBorder(Rectangle layoutBox, boolean reverse) { if (null != layoutBox) { layoutBox.applyMargins(0, rightBorderMaxWidth, 0, leftBorderMaxWidth, reverse); } return this; }
@Override protected TableBorders applyCellIndents(Rectangle box, float topIndent, float rightIndent, float bottomIndent, float leftIndent, boolean reverse) { box.applyMargins(topIndent, rightIndent, bottomIndent, leftIndent, false); return this; }
protected TableBorders applyLeftAndRightTableBorder(Rectangle layoutBox, boolean reverse) { if (null != layoutBox) { layoutBox.applyMargins(0, rightBorderMaxWidth / 2, 0, leftBorderMaxWidth / 2, reverse); } return this; }
protected TableBorders applyLeftAndRightTableBorder(Rectangle layoutBox, boolean reverse) { if (null != layoutBox) { layoutBox.applyMargins(0, rightBorderMaxWidth / 2, 0, leftBorderMaxWidth / 2, reverse); } return this; }
@Override protected TableBorders applyLeftAndRightTableBorder(Rectangle layoutBox, boolean reverse) { if (null != layoutBox) { layoutBox.applyMargins(0, rightBorderMaxWidth, 0, leftBorderMaxWidth, reverse); } return this; }
@Override protected TableBorders applyCellIndents(Rectangle box, float topIndent, float rightIndent, float bottomIndent, float leftIndent, boolean reverse) { box.applyMargins(topIndent, rightIndent, bottomIndent, leftIndent, false); return this; }
protected TableBorders applyCellIndents(Rectangle box, float topIndent, float rightIndent, float bottomIndent, float leftIndent, boolean reverse) { box.applyMargins(topIndent / 2, rightIndent / 2, bottomIndent / 2, leftIndent / 2, false); return this; }
/** * Applies the given spacings on the given rectangle * * @param rect a rectangle spacings will be applied on. * @param horizontalSpacing the horizontal spacing to be applied on the given rectangle * @param verticalSpacing the vertical spacing to be applied on the given rectangle * @param reverse indicates whether the spacings will be applied * inside (in case of false) or outside (in case of false) the rectangle. * @return a {@link Rectangle border box} of the renderer */ private Rectangle applySpacing(Rectangle rect, float horizontalSpacing, float verticalSpacing, boolean reverse) { if (bordersHandler instanceof SeparatedTableBorders) { return rect.applyMargins(verticalSpacing / 2, horizontalSpacing / 2, verticalSpacing / 2, horizontalSpacing / 2, reverse); } else { // Do nothing here. Tables with collapsed borders don't have spacing. } return rect; }
/** * Applies the given spacings on the given rectangle * * @param rect a rectangle spacings will be applied on. * @param horizontalSpacing the horizontal spacing to be applied on the given rectangle * @param verticalSpacing the vertical spacing to be applied on the given rectangle * @param reverse indicates whether the spacings will be applied * inside (in case of false) or outside (in case of false) the rectangle. * @return a {@link Rectangle border box} of the renderer */ private Rectangle applySpacing(Rectangle rect, float horizontalSpacing, float verticalSpacing, boolean reverse) { if (bordersHandler instanceof SeparatedTableBorders) { return rect.applyMargins(verticalSpacing / 2, horizontalSpacing / 2, verticalSpacing / 2, horizontalSpacing / 2, reverse); } else { // Do nothing here. Tables with collapsed borders don't have spacing. } return rect; }
/** * Applies the given horizontal or vertical spacing on the given rectangle * * @param rect a rectangle spacings will be applied on. * @param spacing the horizontal or vertical spacing to be applied on the given rectangle * @param isHorizontal defines whether the provided spacing should be applied as a horizontal or a vertical one * @param reverse indicates whether the spacings will be applied * inside (in case of false) or outside (in case of false) the rectangle. * @return a {@link Rectangle border box} of the renderer */ private Rectangle applySingleSpacing(Rectangle rect, float spacing, boolean isHorizontal, boolean reverse) { if (bordersHandler instanceof SeparatedTableBorders) { if (isHorizontal) { return rect.applyMargins(0, spacing / 2, 0, spacing / 2, reverse); } else { return rect.applyMargins(spacing / 2, 0, spacing / 2, 0, reverse); } } else { // Do nothing here. Tables with collapsed borders don't have spacing. } return rect; }
/** * Applies the given horizontal or vertical spacing on the given rectangle * * @param rect a rectangle spacings will be applied on. * @param spacing the horizontal or vertical spacing to be applied on the given rectangle * @param isHorizontal defines whether the provided spacing should be applied as a horizontal or a vertical one * @param reverse indicates whether the spacings will be applied * inside (in case of false) or outside (in case of false) the rectangle. * @return a {@link Rectangle border box} of the renderer */ private Rectangle applySingleSpacing(Rectangle rect, float spacing, boolean isHorizontal, boolean reverse) { if (bordersHandler instanceof SeparatedTableBorders) { if (isHorizontal) { return rect.applyMargins(0, spacing / 2, 0, spacing / 2, reverse); } else { return rect.applyMargins(spacing / 2, 0, spacing / 2, 0, reverse); } } else { // Do nothing here. Tables with collapsed borders don't have spacing. } return rect; }
protected Rectangle applySpacings(Rectangle rect, float[] spacings, boolean reverse) { if (BorderCollapsePropertyValue.SEPARATE.equals(parent.<BorderCollapsePropertyValue>getProperty(Property.BORDER_COLLAPSE))) { rect.applyMargins(spacings[0] / 2, spacings[1] / 2, spacings[2] / 2, spacings[3] / 2, reverse); } else { // Do nothing here. Spacings are meaningless if borders are collapsed. } return rect; }
protected Rectangle applySpacings(Rectangle rect, float[] spacings, boolean reverse) { if (BorderCollapsePropertyValue.SEPARATE.equals(parent.<BorderCollapsePropertyValue>getProperty(Property.BORDER_COLLAPSE))) { rect.applyMargins(spacings[0] / 2, spacings[1] / 2, spacings[2] / 2, spacings[3] / 2, reverse); } else { // Do nothing here. Spacings are meaningless if borders are collapsed. } return rect; }
/** * Applies the given border box (borders) on the given rectangle * * @param rect a rectangle paddings will be applied on. * @param borders the {@link Border borders} to be applied on the given rectangle * @param reverse indicates whether the border box will be applied * inside (in case of false) or outside (in case of false) the rectangle. * @return a {@link Rectangle border box} of the renderer */ protected Rectangle applyBorderBox(Rectangle rect, Border[] borders, boolean reverse) { float topWidth = borders[0] != null ? borders[0].getWidth() : 0; float rightWidth = borders[1] != null ? borders[1].getWidth() : 0; float bottomWidth = borders[2] != null ? borders[2].getWidth() : 0; float leftWidth = borders[3] != null ? borders[3].getWidth() : 0; return rect.applyMargins(topWidth, rightWidth, bottomWidth, leftWidth, reverse); }
/** * Applies the given border box (borders) on the given rectangle * * @param rect a rectangle paddings will be applied on. * @param borders the {@link Border borders} to be applied on the given rectangle * @param reverse indicates whether the border box will be applied * inside (in case of false) or outside (in case of false) the rectangle. * @return a {@link Rectangle border box} of the renderer */ protected Rectangle applyBorderBox(Rectangle rect, Border[] borders, boolean reverse) { float topWidth = borders[0] != null ? borders[0].getWidth() : 0; float rightWidth = borders[1] != null ? borders[1].getWidth() : 0; float bottomWidth = borders[2] != null ? borders[2].getWidth() : 0; float leftWidth = borders[3] != null ? borders[3].getWidth() : 0; return rect.applyMargins(topWidth, rightWidth, bottomWidth, leftWidth, reverse); }
/** * Applies given margins on the given rectangle * * @param rect a rectangle margins will be applied on. * @param margins the margins to be applied on the given rectangle * @param reverse indicates whether margins will be applied * inside (in case of false) or outside (in case of true) the rectangle. * @return a {@link Rectangle border box} of the renderer */ protected Rectangle applyMargins(Rectangle rect, UnitValue[] margins, boolean reverse) { if (!margins[0].isPointValue()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); logger.error(MessageFormatUtil.format(LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.MARGIN_TOP)); } if (!margins[1].isPointValue()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); logger.error(MessageFormatUtil.format(LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.MARGIN_RIGHT)); } if (!margins[2].isPointValue()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); logger.error(MessageFormatUtil.format(LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.MARGIN_BOTTOM)); } if (!margins[3].isPointValue()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); logger.error(MessageFormatUtil.format(LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.MARGIN_LEFT)); } return rect.applyMargins(margins[0].getValue(), margins[1].getValue(), margins[2].getValue(), margins[3].getValue(), reverse); }
/** * Applies given paddings on the given rectangle * * @param rect a rectangle paddings will be applied on. * @param paddings the paddings to be applied on the given rectangle * @param reverse indicates whether paddings will be applied * inside (in case of false) or outside (in case of false) the rectangle. * @return a {@link Rectangle border box} of the renderer */ protected Rectangle applyPaddings(Rectangle rect, UnitValue[] paddings, boolean reverse) { if (!paddings[0].isPointValue()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); logger.error(MessageFormatUtil.format(LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.PADDING_TOP)); } if (!paddings[1].isPointValue()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); logger.error(MessageFormatUtil.format(LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.PADDING_RIGHT)); } if (!paddings[2].isPointValue()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); logger.error(MessageFormatUtil.format(LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.PADDING_BOTTOM)); } if (!paddings[3].isPointValue()) { Logger logger = LoggerFactory.getLogger(AbstractRenderer.class); logger.error(MessageFormatUtil.format(LogMessageConstant.PROPERTY_IN_PERCENTS_NOT_SUPPORTED, Property.PADDING_LEFT)); } return rect.applyMargins(paddings[0].getValue(), paddings[1].getValue(), paddings[2].getValue(), paddings[3].getValue(), reverse); }
protected void drawBackgrounds(DrawContext drawContext) { boolean shrinkBackgroundArea = bordersHandler instanceof CollapsedTableBorders && (isHeaderRenderer() || isFooterRenderer()); if (shrinkBackgroundArea) { occupiedArea.getBBox().applyMargins(bordersHandler.getMaxTopWidth() / 2, bordersHandler.getRightBorderMaxWidth() / 2, bordersHandler.getMaxBottomWidth() / 2, bordersHandler.getLeftBorderMaxWidth() / 2, false); } super.drawBackground(drawContext); if (shrinkBackgroundArea) { occupiedArea.getBBox().applyMargins(bordersHandler.getMaxTopWidth() / 2, bordersHandler.getRightBorderMaxWidth() / 2, bordersHandler.getMaxBottomWidth() / 2, bordersHandler.getLeftBorderMaxWidth() / 2, true); } if (null != headerRenderer) { headerRenderer.drawBackgrounds(drawContext); } if (null != footerRenderer) { footerRenderer.drawBackgrounds(drawContext); } }
protected void drawBackgrounds(DrawContext drawContext) { boolean shrinkBackgroundArea = bordersHandler instanceof CollapsedTableBorders && (isHeaderRenderer() || isFooterRenderer()); if (shrinkBackgroundArea) { occupiedArea.getBBox().applyMargins(bordersHandler.getMaxTopWidth() / 2, bordersHandler.getRightBorderMaxWidth() / 2, bordersHandler.getMaxBottomWidth() / 2, bordersHandler.getLeftBorderMaxWidth() / 2, false); } super.drawBackground(drawContext); if (shrinkBackgroundArea) { occupiedArea.getBBox().applyMargins(bordersHandler.getMaxTopWidth() / 2, bordersHandler.getRightBorderMaxWidth() / 2, bordersHandler.getMaxBottomWidth() / 2, bordersHandler.getLeftBorderMaxWidth() / 2, true); } if (null != headerRenderer) { headerRenderer.drawBackgrounds(drawContext); } if (null != footerRenderer) { footerRenderer.drawBackgrounds(drawContext); } }