Example usage for com.lowagie.text Rectangle TOP

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

Introduction

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

Prototype

int TOP

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

Click Source Link

Document

This represents one side of the border of the Rectangle.

Usage

From source file:net.bull.javamelody.swing.print.MRtfWriter.java

License:Apache License

/**
 * We create a writer that listens to the document and directs a RTF-stream to out
 *
 * @param table//  w w  w .  j  ava2 s. c  o m
 *           MBasicTable
 * @param document
 *           Document
 * @param out
 *           OutputStream
 * @return DocWriter
 */
@Override
protected DocWriter createWriter(final MBasicTable table, final Document document, final OutputStream out) {
    final RtfWriter2 writer = RtfWriter2.getInstance(document, out);

    // title
    final String title = buildTitle(table);
    if (title != null) {
        final HeaderFooter header = new RtfHeaderFooter(new Paragraph(title));
        header.setAlignment(Element.ALIGN_LEFT);
        header.setBorder(Rectangle.NO_BORDER);
        document.setHeader(header);
        document.addTitle(title);
    }

    // advanced page numbers : x/y
    final Paragraph footerParagraph = new Paragraph();
    final Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL);
    footerParagraph.add(new RtfPageNumber(font));
    footerParagraph.add(new Phrase(" / ", font));
    footerParagraph.add(new RtfTotalPageNumber(font));
    footerParagraph.setAlignment(Element.ALIGN_CENTER);
    final HeaderFooter footer = new RtfHeaderFooter(footerParagraph);
    footer.setBorder(Rectangle.TOP);
    document.setFooter(footer);

    return writer;
}

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;//from  w  ww.  ja  v  a 2 s.  c o 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;/*w w w .  ja  va  2  s  .c o  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  ww  .  ja va  2s .c  om*/
    }
    // 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. ja  v  a 2 s. c om
    }
    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;
        }
    }
}

From source file:org.areasy.common.doclet.document.elements.CellBorderPadding.java

License:Open Source License

/**
 * Creates a PdfPCell with a border and a padding of 6.
 *
 * @param data The cell content./*from w  w w .j  a  v a2 s .co  m*/
 */
public CellBorderPadding(Phrase data) {
    super(data);
    super.setBorder(Rectangle.TOP + Rectangle.LEFT + Rectangle.BOTTOM + Rectangle.RIGHT);
    super.setPadding(6);
    super.setBorderWidth(1);
    super.setBorderColor(Color.gray);
}

From source file:org.areasy.common.doclet.document.elements.CellBorderPadding.java

License:Open Source License

/**
 * Creates a PdfPCell with no bottom border.
 *
 * @param data The cell content./* w w w .jav  a2  s.com*/
 */
public CellBorderPadding(Paragraph data) {
    super(data);
    super.setBorder(Rectangle.TOP + Rectangle.LEFT + Rectangle.RIGHT);
    super.setPadding(6);
    super.setBorderWidth(1);
    super.setBorderColor(Color.gray);
}

From source file:org.areasy.common.doclet.document.elements.CustomPdfPCell.java

License:Open Source License

/**
 * A coloured title bar (for the "Fields", "Methods" and
 * "Constructors" titles).//from   w w  w  . j  a  va 2 s. com
 */
public CustomPdfPCell(String title) {
    super(new Phrase(title, Fonts.getFont(TEXT_FONT, 18)));
    super.setPaddingTop((float) 0.0);
    super.setPaddingBottom((float) 5.0);
    super.setPaddingLeft((float) 3.0);
    super.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    super.setBackgroundColor(COLOR_SUMMARY_HEADER);
    super.setBorder(Rectangle.TOP + Rectangle.LEFT + Rectangle.BOTTOM + Rectangle.RIGHT);
    super.setBorderWidth(1);
    super.setBorderColor(Color.gray);
}

From source file:org.areasy.common.doclet.document.elements.CustomPdfPCell.java

License:Open Source License

/**
 * A coloured title bar (for summary tables etc.)
 *
 * @param paragraph       The text for the title.
 * @param backgroundColor Color of the cell
 *//*from   ww w.j  a  va 2 s . co m*/
public CustomPdfPCell(Paragraph paragraph, Color backgroundColor) {
    super(paragraph);
    super.setPaddingTop((float) 0.0);
    super.setPaddingBottom((float) 5.0);
    super.setPaddingLeft((float) 3.0);
    super.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE);
    super.setBackgroundColor(backgroundColor);
    super.setBorder(Rectangle.TOP + Rectangle.LEFT + Rectangle.BOTTOM + Rectangle.RIGHT);
    super.setBorderWidth(1);
    super.setBorderColor(Color.gray);
}

From source file:org.areasy.common.doclet.document.tags.TagPRE.java

License:Open Source License

/**
 * Creates a PRE tag object.//w w  w.  j  a va  2 s.c  o m
 *
 * @param parent The parent HTML object.
 * @param type   The type for this tag.
 */
public TagPRE(HtmlTag parent, int type) {
    super(parent, type);
    setPre(true);

    cellPara = new Paragraph("", getFont());

    colorTitleCell = new PdfPCell(cellPara);
    colorTitleCell.setBorder(Rectangle.TOP + Rectangle.LEFT + Rectangle.RIGHT + Rectangle.BOTTOM);
    colorTitleCell.setPadding(6);
    colorTitleCell.setPaddingBottom(12);
    colorTitleCell.setPaddingLeft(10);
    colorTitleCell.setPaddingRight(10);
    colorTitleCell.setBorderWidth(1);
    colorTitleCell.setBorderColor(Color.gray);
    colorTitleCell.setBackgroundColor(COLOR_LIGHTER_GRAY);
    colorTitleCell.addElement(cellPara);

    mainTable.addCell(colorTitleCell);
}