Example usage for com.lowagie.text Rectangle RIGHT

List of usage examples for com.lowagie.text Rectangle RIGHT

Introduction

In this page you can find the example usage for com.lowagie.text Rectangle RIGHT.

Prototype

int RIGHT

To view the source code for com.lowagie.text Rectangle RIGHT.

Click Source Link

Document

This represents one side of the border of the Rectangle.

Usage

From source file:corner.orm.tapestry.pdf.PdfTemplateSourceDelegate.java

License:Apache License

private void createTemplateByBlock(PdfBlock block, StringBuffer sb) {
    sb.append("<span jwcid=\"");
    sb.append(block.getName());/*  w  w  w  .  jav  a 2s.co m*/
    sb.append("\" ");

    // rectangle
    sb.append("rectangle=\"literal:");
    Rectangle r = block.getRectangle();
    sb.append(r.left()).append(",").append(r.bottom()).append(",").append(r.right()).append(",")
            .append(r.top());
    sb.append("\" ");

    // other parameter
    if (block.getValue() != null)
        sb.append(block.getValue());

    sb.append("/>\n");
}

From source file:fr.opensagres.odfdom.converter.pdf.internal.stylable.StylableParagraphWrapper.java

License:Open Source License

public void applyStyles(Style style) {
    this.lastStyleApplied = style;

    StyleParagraphProperties paragraphProperties = style.getParagraphProperties();
    if (paragraphProperties != null) {
        // margins
        Float margin = paragraphProperties.getMargin();
        if (margin != null && margin > 0.0f) {
            super.setIndentationLeft(margin);
            super.setIndentationRight(margin);
            super.setSpacingBefore(margin);
            super.setSpacingAfter(margin);
        }/*from w w w .  j  av a 2  s . com*/
        Float marginLeft = paragraphProperties.getMarginLeft();
        if (marginLeft != null && marginLeft > 0.0f) {
            super.setIndentationLeft(marginLeft);
        }
        Float marginRight = paragraphProperties.getMarginRight();
        if (marginRight != null && marginRight > 0.0f) {
            super.setIndentationRight(marginRight);
        }
        Float marginTop = paragraphProperties.getMarginTop();
        if (marginTop != null && marginTop > 0.0f) {
            super.setSpacingBefore(marginTop);
        }
        Float marginBottom = paragraphProperties.getMarginBottom();
        if (marginBottom != null && marginBottom > 0.0f) {
            super.setSpacingAfter(marginBottom);
        }

        // background color
        Color backgroundColor = paragraphProperties.getBackgroundColor();
        if (backgroundColor != null && !TRANSPARENT_COLOR.equals(backgroundColor)) {
            getWrapperCell().setBackgroundColor(backgroundColor);
        }

        // borders
        StyleBorder border = paragraphProperties.getBorder();
        if (border != null && !border.isNoBorder()) {
            StyleUtils.applyStyles(border, getWrapperCell());
        }
        StyleBorder borderLeft = paragraphProperties.getBorderLeft();
        if (borderLeft != null && !borderLeft.isNoBorder()) {
            StyleUtils.applyStyles(borderLeft, getWrapperCell());
        }
        StyleBorder borderRight = paragraphProperties.getBorderRight();
        if (borderRight != null && !borderRight.isNoBorder()) {
            StyleUtils.applyStyles(borderRight, getWrapperCell());
        }
        StyleBorder borderTop = paragraphProperties.getBorderTop();
        if (borderTop != null && !borderTop.isNoBorder()) {
            StyleUtils.applyStyles(borderTop, getWrapperCell());
        }
        StyleBorder borderBottom = paragraphProperties.getBorderBottom();
        if (borderBottom != null && !borderBottom.isNoBorder()) {
            StyleUtils.applyStyles(borderBottom, getWrapperCell());
        }

        // padding
        Float padding = paragraphProperties.getPadding();
        if (padding != null && padding > 0.0f) {
            if (getWrapperCell().hasBorder(Rectangle.LEFT)) {
                getWrapperCell().setPaddingLeft(padding);
            }
            if (getWrapperCell().hasBorder(Rectangle.RIGHT)) {
                getWrapperCell().setPaddingRight(padding);
            }
            if (getWrapperCell().hasBorder(Rectangle.TOP)) {
                getWrapperCell().setPaddingTop(padding);
            }
            if (getWrapperCell().hasBorder(Rectangle.BOTTOM)) {
                getWrapperCell().setPaddingBottom(padding);
            }
        }
        Float paddingLeft = paragraphProperties.getPaddingLeft();
        if (paddingLeft != null && paddingLeft > 0.0f) {
            if (getWrapperCell().hasBorder(Rectangle.LEFT)) {
                getWrapperCell().setPaddingLeft(paddingLeft);
            }
        }
        Float paddingRight = paragraphProperties.getPaddingRight();
        if (paddingRight != null && paddingRight > 0.0f) {
            if (getWrapperCell().hasBorder(Rectangle.RIGHT)) {
                getWrapperCell().setPaddingRight(paddingRight);
            }
        }
        Float paddingTop = paragraphProperties.getPaddingTop();
        if (paddingTop != null && paddingTop > 0.0f) {
            if (getWrapperCell().hasBorder(Rectangle.TOP)) {
                getWrapperCell().setPaddingTop(paddingTop);
            }
        }
        Float paddingBottom = paragraphProperties.getPaddingBottom();
        if (paddingBottom != null && paddingBottom > 0.0f) {
            if (getWrapperCell().hasBorder(Rectangle.BOTTOM)) {
                getWrapperCell().setPaddingBottom(paddingBottom);
            }
        }

        // join border
        Boolean joinBorder = paragraphProperties.getJoinBorder();
        if (joinBorder != null) {
            this.joinBorder = joinBorder;
        }

        // keep together on the same page
        Boolean keepTogether = paragraphProperties.getKeepTogether();
        if (keepTogether != null) {
            super.setKeepTogether(keepTogether);
        }
    }
}

From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.elements.StylableParagraph.java

License:Open Source License

public void setBorder(CTBorder border, int borderSide) {
    if (border == null) {
        return;/*  w ww .jav a 2  s.  c  o  m*/
    }
    boolean noBorder = (STBorder.NONE == border.getVal() || STBorder.NIL == border.getVal());

    // No border
    if (noBorder) {
        return;
    } else {
        // border size
        float size = -1;
        BigInteger borderSize = border.getSz();
        if (borderSize != null) {
            // http://officeopenxml.com/WPtableBorders.php
            // if w:sz="4" => 1/4 points
            size = borderSize.floatValue() / 8f;
        }
        // border color
        fr.opensagres.poi.xwpf.converter.core.Color bdColor = ColorHelper.getBorderColor(border);

        Color borderColor = Converter.toAwtColor(bdColor);
        // border padding
        Float space = null;
        BigInteger borderSpace = border.getSpace();
        if (borderSpace != null) {
            // Specifies the spacing offset. Values are specified in points (1/72nd of an inch).
            space = borderSpace.floatValue();
        }

        switch (borderSide) {
        case Rectangle.TOP:
            if (size != -1) {
                this.setBorderWidthTop(size);
            }
            if (borderColor != null) {

                super.setBorderColorTop(borderColor);
            }
            if (space != null) {
                super.setBorderPaddingTop(space);
            }
            break;
        case Rectangle.BOTTOM:
            if (size != -1) {
                this.setBorderWidthBottom(size);
            }
            if (borderColor != null) {
                super.setBorderColorBottom(borderColor);
            }
            if (space != null) {
                super.setBorderPaddingBottom(space);
            }
            break;
        case Rectangle.LEFT:
            if (size != -1) {
                this.setBorderWidthLeft(size);
            }
            if (borderColor != null) {
                super.setBorderColorLeft(borderColor);
            }
            if (space != null) {
                super.setBorderPaddingLeft(space);
            }
            break;
        case Rectangle.RIGHT:
            if (size != -1) {
                this.setBorderWidthRight(size);
            }
            if (borderColor != null) {
                super.setBorderColorRight(borderColor);
            }
            if (space != null) {
                super.setBorderPaddingRight(space);
            }
            break;
        }
    }
}

From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.elements.StylableTableCell.java

License:Open Source License

public void setBorderRight(TableCellBorder borderRight, boolean inside) {
    setBorder(borderRight, inside, Rectangle.RIGHT);
}

From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.elements.StylableTableCell.java

License:Open Source License

public void setBorder(TableCellBorder border, boolean inside, int borderSide) {
    if (border == null || !border.hasBorder()) {
        this.disableBorderSide(borderSide);
        return;/*from  ww w.  j av a 2s  . c om*/
    }
    Float borderSize = border.getBorderSize();

    if (inside) {
        // manage conflict border

        // divide the border side by 2 to avoid multiply with 2 the border
        // this code simplify the "Conflicts between adjacent cells"
        // http://officeopenxml.com/WPtableCellBorderConflicts.php
        //borderSize = borderSize / 2;                    
    }

    Color borderColor = Converter.toAwtColor(border.getBorderColor());
    switch (borderSide) {
    case Rectangle.TOP:
        if (borderSize != null) {
            this.setBorderWidthTop(borderSize);
        }
        if (borderColor != null) {

            this.setBorderColorTop(borderColor);
        }
        break;
    case Rectangle.BOTTOM:
        if (borderSize != null) {
            this.setBorderWidthBottom(borderSize);
        }
        if (borderColor != null) {
            this.setBorderColorBottom(borderColor);
        }
        break;
    case Rectangle.LEFT:
        if (borderSize != null) {
            this.setBorderWidthLeft(borderSize);
        }
        if (borderColor != null) {
            this.setBorderColorLeft(borderColor);
        }
        break;
    case Rectangle.RIGHT:
        if (borderSize != null) {
            this.setBorderWidthRight(borderSize);
        }
        if (borderColor != null) {
            this.setBorderColorRight(borderColor);
        }
        break;
    }
}

From source file:fr.opensagres.poi.xwpf.converter.pdf.internal.PdfMapper.java

License:Open Source License

@Override
protected IITextContainer startVisitParagraph(XWPFParagraph docxParagraph, ListItemContext itemContext,
        IITextContainer pdfParentContainer) throws Exception {
    this.currentRunX = null;

    // create PDF paragraph
    StylableParagraph pdfParagraph = pdfDocument.createParagraph(pdfParentContainer);

    // indentation left
    Float indentationLeft = stylesDocument.getIndentationLeft(docxParagraph);
    if (indentationLeft != null) {
        pdfParagraph.setIndentationLeft(indentationLeft);
    }/*from w  ww .  j a  v a  2s  .  c o  m*/
    // indentation right
    Float indentationRight = stylesDocument.getIndentationRight(docxParagraph);
    if (indentationRight != null) {
        pdfParagraph.setIndentationRight(indentationRight);
    }
    // indentation first line
    Float indentationFirstLine = stylesDocument.getIndentationFirstLine(docxParagraph);
    if (indentationFirstLine != null) {
        pdfParagraph.setFirstLineIndent(indentationFirstLine);
    }
    // indentation hanging (remove first line)
    Float indentationHanging = stylesDocument.getIndentationHanging(docxParagraph);
    if (indentationHanging != null) {
        pdfParagraph.setFirstLineIndent(-indentationHanging);
    }

    // // spacing before
    Float spacingBefore = stylesDocument.getSpacingBefore(docxParagraph);
    if (spacingBefore != null) {
        pdfParagraph.setSpacingBefore(spacingBefore);
    }

    // spacing after
    Float spacingAfter = stylesDocument.getSpacingAfter(docxParagraph);
    if (spacingAfter != null) {
        pdfParagraph.setSpacingAfter(spacingAfter);
    }

    ParagraphLineSpacing lineSpacing = stylesDocument.getParagraphSpacing(docxParagraph);
    if (lineSpacing != null) {
        if (lineSpacing.getLeading() != null && lineSpacing.getMultipleLeading() != null) {
            pdfParagraph.setLeading(lineSpacing.getLeading(), lineSpacing.getMultipleLeading());
        } else {
            if (lineSpacing.getLeading() != null) {
                pdfParagraph.setLeading(lineSpacing.getLeading());
            }
            if (lineSpacing.getMultipleLeading() != null) {
                pdfParagraph.setMultipliedLeading(lineSpacing.getMultipleLeading());
            }
        }

    }

    // text-align
    ParagraphAlignment alignment = stylesDocument.getParagraphAlignment(docxParagraph);
    if (alignment != null) {
        switch (alignment) {
        case LEFT:
            pdfParagraph.setAlignment(Element.ALIGN_LEFT);
            break;
        case RIGHT:
            pdfParagraph.setAlignment(Element.ALIGN_RIGHT);
            break;
        case CENTER:
            pdfParagraph.setAlignment(Element.ALIGN_CENTER);
            break;
        case BOTH:
            pdfParagraph.setAlignment(Element.ALIGN_JUSTIFIED);
            break;
        default:
            break;
        }
    }

    // background-color
    Color backgroundColor = stylesDocument.getBackgroundColor(docxParagraph);
    if (backgroundColor != null) {
        pdfParagraph.setBackgroundColor(Converter.toAwtColor(backgroundColor));
    }

    // border
    CTBorder borderTop = stylesDocument.getBorderTop(docxParagraph);
    pdfParagraph.setBorder(borderTop, Rectangle.TOP);

    CTBorder borderBottom = stylesDocument.getBorderBottom(docxParagraph);
    pdfParagraph.setBorder(borderBottom, Rectangle.BOTTOM);

    CTBorder borderLeft = stylesDocument.getBorderLeft(docxParagraph);
    pdfParagraph.setBorder(borderLeft, Rectangle.LEFT);

    CTBorder borderRight = stylesDocument.getBorderRight(docxParagraph);
    pdfParagraph.setBorder(borderRight, Rectangle.RIGHT);

    if (itemContext != null) {
        CTLvl lvl = itemContext.getLvl();
        CTPPr lvlPPr = lvl.getPPr();
        if (lvlPPr != null) {
            if (ParagraphIndentationLeftValueProvider.INSTANCE
                    .getValue(docxParagraph.getCTP().getPPr()) == null) {

                // search the indentation from the level properties only if
                // paragraph has not override it
                // see
                // https://code.google.com/p/xdocreport/issues/detail?id=239
                Float indLeft = ParagraphIndentationLeftValueProvider.INSTANCE.getValue(lvlPPr);
                if (indLeft != null) {
                    pdfParagraph.setIndentationLeft(indLeft);
                }
            }
            if (ParagraphIndentationHangingValueProvider.INSTANCE
                    .getValue(docxParagraph.getCTP().getPPr()) == null) {
                // search the hanging from the level properties only if
                // paragraph has not override it
                // see
                // https://code.google.com/p/xdocreport/issues/detail?id=239
                Float hanging = stylesDocument.getIndentationHanging(lvlPPr);
                if (hanging != null) {
                    pdfParagraph.setFirstLineIndent(-hanging);
                }
            }
        }
        CTRPr lvlRPr = lvl.getRPr();
        if (lvlRPr != null) {
            // Font family
            String listItemFontFamily = stylesDocument.getFontFamilyAscii(lvlRPr);

            // Get font size
            Float listItemFontSize = stylesDocument.getFontSize(lvlRPr);

            // Get font style
            int listItemFontStyle = Font.NORMAL;
            Boolean bold = stylesDocument.getFontStyleBold(lvlRPr);
            if (bold != null && bold) {
                listItemFontStyle |= Font.BOLD;
            }
            Boolean italic = stylesDocument.getFontStyleItalic(lvlRPr);
            if (italic != null && italic) {
                listItemFontStyle |= Font.ITALIC;
            }
            Boolean strike = stylesDocument.getFontStyleStrike(lvlRPr);
            if (strike != null && strike) {
                listItemFontStyle |= Font.STRIKETHRU;
            }

            // Font color
            Color listItemFontColor = stylesDocument.getFontColor(lvlRPr);

            pdfParagraph.setListItemFontFamily(listItemFontFamily);
            pdfParagraph.setListItemFontSize(listItemFontSize);
            pdfParagraph.setListItemFontStyle(listItemFontStyle);
            pdfParagraph.setListItemFontColor(Converter.toAwtColor(listItemFontColor));

        }
        pdfParagraph.setListItemText(itemContext.getText());
    }
    return pdfParagraph;
}

From source file:org.apache.poi.xwpf.converter.internal.itext.PDFMapper.java

License:Open Source License

@Override
protected IITextContainer startVisitTableCell(XWPFTableCell cell, IITextContainer tableContainer) {
    StylableTable pdfPTable = (StylableTable) tableContainer;

    XWPFTableRow row = cell.getTableRow();
    ExtendedPdfPCell pdfPCell = new ExtendedPdfPCell();
    pdfPCell.setITextContainer(pdfPTable);

    CTTcPr tcPr = cell.getCTTc().getTcPr();

    if (tcPr != null) {

        // Colspan
        Integer colspan = null;//  w ww.jav a 2 s. co  m
        CTDecimalNumber gridSpan = tcPr.getGridSpan();
        if (gridSpan != null) {
            colspan = gridSpan.getVal().intValue();
        }
        if (colspan != null) {
            pdfPCell.setColspan(colspan);
        }

        // Backround Color
        CTShd shd = tcPr.getShd();
        String hexColor = null;
        if (shd != null) {
            hexColor = shd.xgetFill().getStringValue();
        }
        if (hexColor != null && !"auto".equals(hexColor)) {
            pdfPCell.setBackgroundColor(ColorRegistry.getInstance().getColor("0x" + hexColor));
        }

        // Borders
        // Table Properties on cells

        // overridden locally
        CTTcBorders borders = tcPr.getTcBorders();
        if (borders != null) {
            // border-left
            setBorder(borders.getLeft(), pdfPCell, Rectangle.LEFT);
            // border-right
            setBorder(borders.getRight(), pdfPCell, Rectangle.RIGHT);
            // border-top
            setBorder(borders.getTop(), pdfPCell, Rectangle.TOP);
            // border-bottom
            setBorder(borders.getBottom(), pdfPCell, Rectangle.BOTTOM);
        }
    }
    int height = row.getHeight();
    pdfPCell.setMinimumHeight(dxa2points(height));

    return pdfPCell;
}

From source file:org.apache.poi.xwpf.converter.internal.itext.XWPFTableUtil.java

License:Open Source License

public static void setBorder(CTBorder border, PdfPCell pdfPCell, int borderSide) {
    if (border == null) {
        return;/*from w w  w.j a v a2 s .  co  m*/
    }
    boolean noBorder = (STBorder.NONE == border.getVal());

    // No border
    if (noBorder) {
        pdfPCell.disableBorderSide(borderSide);
    } else {
        float size = -1;
        BigInteger borderSize = border.getSz();
        if (borderSize != null) {
            size = dxa2points(borderSize);
        }

        Color borderColor = null;
        String hexColor = getBorderColor(border);
        if (hexColor != null) {
            borderColor = ColorRegistry.getInstance().getColor("0x" + hexColor);
        }

        switch (borderSide) {
        case Rectangle.TOP:
            if (size != -1) {
                pdfPCell.setBorderWidthTop(size);
            }
            if (borderColor != null) {

                pdfPCell.setBorderColorTop(borderColor);
            }
            break;
        case Rectangle.BOTTOM:
            if (size != -1) {
                pdfPCell.setBorderWidthBottom(size);
            }
            if (borderColor != null) {
                pdfPCell.setBorderColorBottom(borderColor);
            }
            break;
        case Rectangle.LEFT:
            if (size != -1) {
                pdfPCell.setBorderWidthLeft(size);
            }
            if (borderColor != null) {
                pdfPCell.setBorderColorLeft(borderColor);
            }
            break;
        case Rectangle.RIGHT:
            if (size != -1) {
                pdfPCell.setBorderWidthRight(size);
            }
            if (borderColor != null) {
                pdfPCell.setBorderColorRight(borderColor);
            }
            break;
        }
    }
}

From source file:org.apache.poi.xwpf.converter.internal.itext.XWPFTableUtil.java

License:Open Source License

public static void setBorder(StyleBorder border, PdfPCell pdfPCell, int borderSide) {
    if (border == null) {
        return;/*from w  w w.j a  v  a 2s .  c o m*/
    }
    // boolean noBorder = (STBorder.NONE == border.getVal());

    // No border

    float size = -1;
    BigInteger borderSize = border.getWidth();
    if (borderSize != null) {
        size = dxa2points(borderSize);
    }

    Color borderColor = border.getColor();

    switch (borderSide) {
    case Rectangle.TOP:
        if (size != -1) {
            pdfPCell.setBorderWidthTop(size);
        }
        if (borderColor != null) {

            pdfPCell.setBorderColorTop(borderColor);
        }
        break;
    case Rectangle.BOTTOM:
        if (size != -1) {
            pdfPCell.setBorderWidthBottom(size);
        }
        if (borderColor != null) {
            pdfPCell.setBorderColorBottom(borderColor);
        }
        break;
    case Rectangle.LEFT:
        if (size != -1) {
            pdfPCell.setBorderWidthLeft(size);
        }
        if (borderColor != null) {
            pdfPCell.setBorderColorLeft(borderColor);
        }
        break;
    case Rectangle.RIGHT:
        if (size != -1) {
            pdfPCell.setBorderWidthRight(size);
        }
        if (borderColor != null) {
            pdfPCell.setBorderColorRight(borderColor);
        }
        break;
    }

}

From source file:org.apache.poi.xwpf.converter.pdf.internal.elements.StylableParagraph.java

License:Open Source License

public void setBorder(CTBorder border, int borderSide) {
    if (border == null) {
        return;/*from   w w w .j  a  v a  2 s  .  c o  m*/
    }
    boolean noBorder = (STBorder.NONE == border.getVal() || STBorder.NIL == border.getVal());

    // No border
    if (noBorder) {
        return;
    } else {
        // border size
        float size = -1;
        BigInteger borderSize = border.getSz();
        if (borderSize != null) {
            // http://officeopenxml.com/WPtableBorders.php
            // if w:sz="4" => 1/4 points
            size = borderSize.floatValue() / 8f;
        }
        // border color
        org.apache.poi.xwpf.converter.core.Color bdColor = ColorHelper.getBorderColor(border);

        Color borderColor = Converter.toAwtColor(bdColor);
        // border padding
        Float space = null;
        BigInteger borderSpace = border.getSpace();
        if (borderSpace != null) {
            // Specifies the spacing offset. Values are specified in points (1/72nd of an inch).
            space = borderSpace.floatValue();
        }

        switch (borderSide) {
        case Rectangle.TOP:
            if (size != -1) {
                this.setBorderWidthTop(size);
            }
            if (borderColor != null) {

                super.setBorderColorTop(borderColor);
            }
            if (space != null) {
                super.setBorderPaddingTop(space);
            }
            break;
        case Rectangle.BOTTOM:
            if (size != -1) {
                this.setBorderWidthBottom(size);
            }
            if (borderColor != null) {
                super.setBorderColorBottom(borderColor);
            }
            if (space != null) {
                super.setBorderPaddingBottom(space);
            }
            break;
        case Rectangle.LEFT:
            if (size != -1) {
                this.setBorderWidthLeft(size);
            }
            if (borderColor != null) {
                super.setBorderColorLeft(borderColor);
            }
            if (space != null) {
                super.setBorderPaddingLeft(space);
            }
            break;
        case Rectangle.RIGHT:
            if (size != -1) {
                this.setBorderWidthRight(size);
            }
            if (borderColor != null) {
                super.setBorderColorRight(borderColor);
            }
            if (space != null) {
                super.setBorderPaddingRight(space);
            }
            break;
        }
    }
}