Example usage for com.lowagie.text Cell setVerticalAlignment

List of usage examples for com.lowagie.text Cell setVerticalAlignment

Introduction

In this page you can find the example usage for com.lowagie.text Cell setVerticalAlignment.

Prototype

public void setVerticalAlignment(String alignment) 

Source Link

Document

Sets the alignment of this paragraph.

Usage

From source file:datasoul.servicelist.ServiceListExporterDocument.java

License:Open Source License

private Cell createHeaderCell(String text) throws BadElementException {

    Cell c = new Cell(new Chunk(text, FontFactory.getFont(FontFactory.HELVETICA_BOLD)));
    c.setMaxLines(1);//  w  w w . ja v a  2s  .com
    c.setHeader(true);
    c.setVerticalAlignment(Cell.ALIGN_MIDDLE);
    c.setHorizontalAlignment(Cell.ALIGN_CENTER);
    return c;

}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * returns a cell with a given image inside
 * /*w w  w  .j  av a2s.  com*/
 * @param image
 * @return
 * @throws Exception
 */
private Cell getCellImage(String image) throws Exception {
    if (image != null && !image.equals("")) {
        try {
            Image jpg1 = Image.getInstance(image);
            jpg1.scaleAbsolute(jpg1.getWidth() * IMAGE_HEIGHT / jpg1.getHeight(), IMAGE_HEIGHT);
            Cell cell = new Cell(jpg1);
            cell.setLeading(0);
            cell.setBorderWidth(0);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            return cell;
        } catch (IOException e) {
            return new Cell(new Paragraph(image + " not found", FONT_DOC));
        }
    }
    return new Cell(new Paragraph("", FONT_DOC));
}

From source file:ispyb.common.util.export.ExiPdfRtfExporter.java

License:Open Source License

/**
 * returns a cell with a given image inside
 * //from   w  ww .j  a v a  2  s  . c  o  m
 * @param image
 * @return
 * @throws Exception
 */
private Cell getCellImage(Map<String, Object> dataCollectionMapItem, String imageParam) throws Exception {

    if (dataCollectionMapItem.get(imageParam) != null
            && !(dataCollectionMapItem.get(imageParam).toString()).equals("")) {
        String image = dataCollectionMapItem.get(imageParam).toString();
        image = PathUtils.getPath(image);
        try {
            Image jpg1 = Image.getInstance(image);
            jpg1.scaleAbsolute(jpg1.getWidth() * IMAGE_HEIGHT / jpg1.getHeight(), IMAGE_HEIGHT);
            Cell cell = new Cell(jpg1);
            cell.setLeading(0);
            cell.setBorderWidth(0);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            return cell;
        } catch (IOException e) {
            return new Cell(new Paragraph(image + " not found", FONT_DOC));
        }
    }
    return new Cell(new Paragraph("", FONT_DOC));
}

From source file:ispyb.common.util.export.ExiPdfRtfExporter.java

License:Open Source License

/**
 * returns a cell with a given image inside
 * /*  w  w w . j  a  v  a 2s . c om*/
 * @param image
 * @return
 * @throws Exception
 */
private Cell getCellImage(String imagePath) throws Exception {

    if (imagePath != null) {
        String image = PathUtils.getPath(imagePath);
        try {
            Image jpg1 = Image.getInstance(image);
            jpg1.scaleAbsolute(jpg1.getWidth() * IMAGE_HEIGHT / jpg1.getHeight(), IMAGE_HEIGHT);
            Cell cell = new Cell(jpg1);
            cell.setLeading(0);
            cell.setBorderWidth(0);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_CENTER);
            return cell;
        } catch (IOException e) {
            return new Cell(new Paragraph(image + " not found", FONT_DOC));
        }
    }
    return new Cell(new Paragraph("", FONT_DOC));
}

From source file:org.activityinfo.server.report.renderer.itext.ItextMapRenderer.java

License:Open Source License

private void renderLegend(MapReportElement element, Document doc) throws DocumentException, IOException {

    Table table = new Table(2);
    table.setBorderWidth(1);//from w  w  w  .ja  va 2s .c  o m
    table.setWidth(100f);
    table.setBorderColor(new Color(100, 100, 100));
    table.setPadding(5);
    table.setSpacing(0);
    table.setCellsFitPage(true);
    table.setTableFitsPage(true);
    table.setWidths(new int[] { 1, 3 });

    Cell cell = new Cell(I18N.CONSTANTS.legend());
    cell.setHeader(true);
    cell.setColspan(2);
    table.addCell(cell);
    table.endHeaders();

    for (MapLayerLegend legend : element.getContent().getLegends()) {

        Cell symbolCell = new Cell();
        symbolCell.setHorizontalAlignment(Element.ALIGN_CENTER);
        symbolCell.setVerticalAlignment(Element.ALIGN_MIDDLE);

        Image symbol = createLegendSymbol(legend, imageCreator);
        symbolCell.addElement(symbol);

        Cell descriptionCell = new Cell();
        addLegendDescription(element, legend.getDefinition(), descriptionCell);

        table.addCell(symbolCell);
        table.addCell(descriptionCell);
    }
    doc.add(table);
}

From source file:org.activityinfo.server.report.renderer.itext.ThemeHelper.java

License:Open Source License

public static Cell columnHeaderCell(String label, boolean leaf, int hAlign) throws BadElementException {
    Paragraph para = new Paragraph(label);
    para.setFont(new Font(Font.HELVETICA, BODY_FONT_SIZE, Font.NORMAL, Color.WHITE));

    Cell cell = new Cell();
    cell.addElement(para);/*from w  w  w.  j av a  2  s.  com*/
    cell.setHorizontalAlignment(hAlign);
    cell.setHeader(true);
    cell.setVerticalAlignment(Cell.ALIGN_BOTTOM);
    cell.setBackgroundColor(BLUE3);

    cell.setBorderWidth(0);

    return cell;
}

From source file:org.displaytag.export.PdfView.java

License:Artistic License

/**
 * Returns a formatted cell for the given value.
 * @param value cell value/* w  ww.j  a va2 s .  com*/
 * @return Cell
 * @throws BadElementException errors while generating content
 */
private Cell getCell(String value) throws BadElementException {
    Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(value), smallFont));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setLeading(8);
    return cell;
}

From source file:org.displaytag.render.ItextTableWriter.java

License:Artistic License

/**
 * Returns a formatted cell for the given value.
 * @param value cell value// w ww.ja va  2  s .c  o  m
 * @return Cell
 * @throws BadElementException if errors occurs while generating content.
 */
private Cell getCell(Object value) throws BadElementException {
    Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(ObjectUtils.toString(value)), this.defaultFont));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setLeading(8);
    return cell;
}

From source file:org.egov.infra.web.displaytag.export.EGovPdfView.java

License:Open Source License

/**
 * Returns a formatted cell for the given value.
 * @param value cell value/*from ww  w  . j a  v a2 s  .c  om*/
 * @return Cell
 * @throws BadElementException errors while generating content
 */
private Cell getCell(String value) throws BadElementException {

    value = removeHtmlTagsAndSpaces(value);
    final Cell cell = new Cell(new Chunk(StringUtils.trimToEmpty(value), this.smallFont));
    cell.setVerticalAlignment(Element.ALIGN_TOP);
    cell.setLeading(8);
    return cell;
}

From source file:org.kuali.kfs.module.cam.report.DepreciationReport.java

License:Open Source License

/**
 * This method adds the log lines into the report
 * //from  w  w w .jav a2 s  . c o m
 * @param reportLog
 */
private void generateReportLogBody(List<String[]> reportLog) {
    try {
        Font font = FontFactory.getFont(FontFactory.HELVETICA, 9, Font.NORMAL);
        int columnwidths[];
        columnwidths = new int[] { 40, 15 };

        Table aTable = new Table(2, linesPerPage);
        int rowsWritten = 0;
        for (String[] columns : reportLog) {
            if (pageNumber == 0 || line >= linesPerPage) {
                if (pageNumber > 0) {
                    this.document.add(aTable);
                }
                int elementsLeft = reportLog.size() - rowsWritten;
                int rowsNeeded = (elementsLeft >= linesPerPage ? linesPerPage : elementsLeft);
                this.document.newPage();

                this.generateColumnHeaders();

                aTable = new Table(2, rowsNeeded); // 12 columns, 11 rows.

                aTable.setAutoFillEmptyCells(true);
                aTable.setPadding(3);
                aTable.setWidths(columnwidths);
                aTable.setWidth(100);
                aTable.setBorder(Rectangle.NO_BORDER);

                line = 0;
                pageNumber++;
            }
            rowsWritten++;

            Cell cell;
            cell = new Cell(new Phrase(columns[0], font));
            cell.setHorizontalAlignment(Element.ALIGN_LEFT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable.addCell(cell);

            cell = new Cell(new Phrase(columns[1], font));
            cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable.addCell(cell);
            line++;
        }
        this.document.add(aTable);
    } catch (DocumentException de) {
        throw new RuntimeException(
                "DepreciationReport.generateReportLogBody(List<String[]> reportLog) - error: "
                        + de.getMessage());
    }
}