Example usage for com.lowagie.text Element ALIGN_CENTER

List of usage examples for com.lowagie.text Element ALIGN_CENTER

Introduction

In this page you can find the example usage for com.lowagie.text Element ALIGN_CENTER.

Prototype

int ALIGN_CENTER

To view the source code for com.lowagie.text Element ALIGN_CENTER.

Click Source Link

Document

A possible value for paragraph alignment.

Usage

From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java

License:Apache License

/**
 * Effectue le rendu des headers./*  w  w w.ja  va  2s. co  m*/
 *
 * @param parameters Paramtres
 * @param datatable Table
 */
private static void renderHeaders(final ExportSheet parameters, final Table datatable)
        throws BadElementException {
    // table header
    final Font font = FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD);
    datatable.getDefaultCell().setBorderWidth(2);
    datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);

    for (final ExportField exportColumn : parameters.getExportFields()) {
        datatable.addCell(new Phrase(exportColumn.getLabel().getDisplay(), font));
    }
    // end of the table header
    datatable.endHeaders();
}

From source file:io.vertigo.quarto.plugins.export.pdfrtf.AbstractExporterIText.java

License:Apache License

/**
 * Effectue le rendu de la liste.//from w ww  .  ja va 2s  .  co m
 *
 * @param parameters Paramtres
 * @param datatable Table
 */
private void renderList(final ExportSheet parameters, final Table datatable) throws BadElementException {
    // data rows
    final Font font = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);
    final Font whiteFont = FontFactory.getFont(FontFactory.HELVETICA, 10, Font.NORMAL);
    whiteFont.setColor(Color.WHITE);
    datatable.getDefaultCell().setBorderWidth(1);
    datatable.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);

    // Parcours des DTO de la DTC
    for (final DtObject dto : parameters.getDtList()) {
        for (final ExportField exportColumn : parameters.getExportFields()) {
            final DtField dtField = exportColumn.getDtField();
            final Object value = dtField.getDataAccessor().getValue(dto);
            final int horizontalAlignement;
            if (value instanceof Number || value instanceof LocalDate || value instanceof Instant) {
                horizontalAlignement = Element.ALIGN_RIGHT;
            } else if (value instanceof Boolean) {
                horizontalAlignement = Element.ALIGN_CENTER;
            } else {
                horizontalAlignement = Element.ALIGN_LEFT;
            }
            datatable.getDefaultCell().setHorizontalAlignment(horizontalAlignement);

            String text = ExportUtil.getText(storeManager, referenceCache, denormCache, dto, exportColumn);
            if (text == null) {
                text = "";
            }
            datatable.addCell(new Phrase(8, text, font));
        }
    }
}

From source file:io.vertigo.quarto.plugins.export.rtf.RTFExporter.java

License:Apache License

/** {@inheritDoc} */
@Override/*from   w  ww  .ja  va2  s  .  co  m*/
protected void createWriter(final Document document, final OutputStream out) {
    RtfWriter2.getInstance(document, out);

    // advanced page numbers : x/y
    final Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL);
    //-----
    final Paragraph footerParagraph = new Paragraph();
    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);
}

From source file:ispyb.client.biosaxs.pdf.DataAcquisitionPDFReport.java

License:Open Source License

private ByteArrayOutputStream exportAsPdf(Experiment3VO experiment, List<Buffer3VO> buffers,
        Proposal3VO proposal) throws Exception {
    Document document = new Document(PageSize.A4.rotate(), 10, 10, 20, 20);

    document.addTitle("exportSamplesView");
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PdfWriter.getInstance(document, baos);
    HeaderFooter header = new HeaderFooter(
            new Phrase(proposal.getTitle() + " " + proposal.getCode() + proposal.getNumber()), false);

    header.setAlignment(Element.ALIGN_CENTER);
    header.getBefore().getFont().setSize(8);
    HeaderFooter footer = new HeaderFooter(new Phrase("Page n."), true);
    footer.setAlignment(Element.ALIGN_RIGHT);
    footer.setBorderWidth(1);/*from ww  w  .  ja  v  a2  s. com*/
    footer.getBefore().getFont().setSize(6);

    document.setHeader(header);
    document.setFooter(footer);

    document.open();

    BaseFont bf = BaseFont.createFont(FONTS[0][0], FONTS[0][1], BaseFont.EMBEDDED);
    Font font = new Font(bf, 6);
    document.add(new Paragraph("Data Acquisition: " + experiment.getName(), font));
    document.add(new Paragraph("Type: " + experiment.getType(), font));
    document.add(new Paragraph("Date: " + experiment.getCreationDate(), font));
    document.add(new Paragraph("Proposal: " + proposal.getCode() + proposal.getNumber(), font));
    document.add(new Paragraph("Title: " + proposal.getTitle(), font));

    document.add(new Paragraph(" "));
    document.add(new Paragraph("Measurements", PdfRtfExporter.FONT_DOC_BOLD));
    document.add(new Paragraph(" "));
    document.add(this.getMeasurementTable(experiment, buffers));
    document.newPage();
    document.add(new Paragraph(" "));
    document.add(new Paragraph("Analysis", PdfRtfExporter.FONT_DOC_BOLD));
    document.add(new Paragraph(" "));
    document.add(this.getAnalysis(experiment, buffers));
    document.newPage();
    document.add(this.getImageTable(experiment, buffers));

    document.close();
    return baos;
}

From source file:ispyb.client.biosaxs.pdf.DataAcquisitionPDFReport.java

License:Open Source License

/**
 * @param experiment//from w  ww.j  av  a  2  s.co m
 * @return
 */
private Element getMeasurementTable(Experiment3VO experiment, List<Buffer3VO> buffers) {

    PdfPTable table = new PdfPTable(MEASUREMENT_COLUMNS.length);

    table.setWidthPercentage(100f);
    table.getDefaultCell().setPadding(3);
    table.getDefaultCell().setColspan(MEASUREMENT_COLUMNS.length);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    table.getDefaultCell().setColspan(1);
    table.getDefaultCell().setBackgroundColor(PdfRtfExporter.BLUE_COLOR);
    for (int i = 0; i < MEASUREMENT_COLUMNS.length; i++) {
        table.addCell(this.getCell(MEASUREMENT_COLUMNS[i], BaseFont.HELVETICA_BOLD));
    }
    table.getDefaultCell().setBackgroundColor(null);

    List<List<String>> data = this.getExperimentMesurementData(experiment, buffers);

    for (List<String> list : data) {
        for (String string : list) {
            table.addCell(getCell(string));
        }
    }
    return table;
}

From source file:ispyb.client.biosaxs.pdf.DataAcquisitionPDFReport.java

License:Open Source License

private Element getImageTable(Experiment3VO experiment, List<Buffer3VO> buffers) {

    PdfPTable table = new PdfPTable(ImageColumns.length);

    table.setWidthPercentage(100f);/* www .  j  a v a  2  s .c  om*/
    table.getDefaultCell().setPadding(3);
    table.getDefaultCell().setColspan(ImageColumns.length);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    table.getDefaultCell().setColspan(1);
    table.getDefaultCell().setBackgroundColor(PdfRtfExporter.BLUE_COLOR);
    for (int i = 0; i < ImageColumns.length; i++) {
        table.addCell(this.getCell(ImageColumns[i], BaseFont.HELVETICA_BOLD));
    }
    table.getDefaultCell().setBackgroundColor(null);

    List<Measurement3VO> measurements = experiment.getMeasurements();
    Collections.sort(measurements, MeasurementComparator
            .compare(MeasurementComparator.getComparator(MeasurementComparator.PRIOTIRY_SORT_ASC)));
    for (int x = 0; x < measurements.size(); x++) {
        Measurement3VO measurement = measurements.get(x);
        Specimen3VO specimen = experiment.getSampleById(measurement.getSpecimenId());
        if (specimen.getMacromolecule3VO() != null) {
            SaxsDataCollection3VO dataCollection = experiment
                    .getDataCollectionByMeasurementId(measurement.getMeasurementId());

            ArrayList<String> list = this.addAnalysisRow(measurement, experiment, buffers);
            if (list.size() > 0) {
                int sizeTable = list.get(0).length();
                PdfPTable nested1 = new PdfPTable(sizeTable);
                nested1.getDefaultCell().setBorder(0);
                for (int i = 0; i < list.size(); i++) {
                    if (i == 0) {
                        nested1.getDefaultCell().setBackgroundColor(PdfRtfExporter.LIGHT_GREY_COLOR);
                        nested1.getDefaultCell().setBorder(0);
                        Paragraph cell = this.getCell(this.COLUMNS[i] + ": " + list.get(i));
                        nested1.addCell(cell);
                    } else {
                        nested1.getDefaultCell().setBackgroundColor(null);
                        nested1.getDefaultCell().setBorder(0);
                        PdfPCell cell = new PdfPCell(this.getCell(this.COLUMNS[i] + ": " + list.get(i)));
                        cell.setBorder(0);
                        nested1.addCell(cell);
                    }
                }
                table.addCell(new PdfPCell(nested1));

                if (dataCollection.getSubstraction3VOs() != null) {
                    if (dataCollection.getSubstraction3VOs().size() > 0) {
                        Subtraction3VO substraction = ((Subtraction3VO) (dataCollection.getSubstraction3VOs()
                                .toArray()[0]));

                        String scatteringImage = BiosaxsActions
                                .checkFilePathForDevelopment(substraction.getScatteringFilePath());
                        if (scatteringImage != null) {
                            if (new File(scatteringImage).exists()) {
                                try {
                                    PdfPCell cell = new PdfPCell(Image.getInstance(scatteringImage), true);
                                    cell.setBorder(0);
                                    table.addCell(cell);
                                } catch (Exception e) {
                                    PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                                    cell.setBorder(0);
                                    table.addCell(cell);
                                    e.printStackTrace();
                                }
                            } else {
                                PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                                cell.setBorder(0);
                                table.addCell(cell);
                            }
                        } else {
                            PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                            cell.setBorder(0);
                            table.addCell(cell);
                        }

                        String guinierImage = BiosaxsActions
                                .checkFilePathForDevelopment(substraction.getGuinierFilePath());
                        if (guinierImage != null) {
                            if (new File(guinierImage).exists()) {
                                try {
                                    PdfPCell cell = new PdfPCell(Image.getInstance(guinierImage), true);
                                    cell.setBorder(0);
                                    table.addCell(cell);
                                } catch (Exception e) {
                                    PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                                    cell.setBorder(0);
                                    table.addCell(cell);
                                    e.printStackTrace();
                                }
                            } else {
                                PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                                cell.setBorder(0);
                                table.addCell(cell);
                            }
                        } else {
                            PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                            cell.setBorder(0);
                            table.addCell(cell);
                        }

                        String kraktyImage = BiosaxsActions
                                .checkFilePathForDevelopment(substraction.getKratkyFilePath());
                        if (kraktyImage != null) {
                            if (new File(kraktyImage).exists()) {
                                try {
                                    PdfPCell cell = new PdfPCell(Image.getInstance(kraktyImage), true);
                                    cell.setBorder(0);
                                    table.addCell(cell);
                                } catch (Exception e) {
                                    PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                                    cell.setBorder(0);
                                    table.addCell(cell);
                                    e.printStackTrace();
                                }
                            } else {
                                PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                                cell.setBorder(0);
                                table.addCell(cell);
                            }
                        } else {
                            PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                            cell.setBorder(0);
                            table.addCell(cell);
                        }

                        String gnomImage = BiosaxsActions
                                .checkFilePathForDevelopment(substraction.getGnomFilePath());
                        if (gnomImage != null) {
                            if (new File(gnomImage).exists()) {
                                try {
                                    PdfPCell cell = new PdfPCell(Image.getInstance(gnomImage), true);
                                    cell.setBorder(0);
                                    table.addCell(cell);
                                } catch (Exception e) {
                                    PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                                    cell.setBorder(0);
                                    table.addCell(cell);
                                    e.printStackTrace();
                                }
                            } else {
                                PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                                cell.setBorder(0);
                                table.addCell(cell);
                            }
                        } else {
                            PdfPCell cell = new PdfPCell(this.getCell("Image not found"));
                            cell.setBorder(0);
                            table.addCell(cell);
                        }
                    }
                }
            }
        }
    }
    return table;
}

From source file:ispyb.client.biosaxs.pdf.DataAcquisitionPDFReport.java

License:Open Source License

private Element getAnalysis(Experiment3VO experiment, List<Buffer3VO> buffers) {
    PdfPTable table = new PdfPTable(COLUMNS.length);

    /** SUBTITLE **/
    table.getDefaultCell().setColspan(5);
    table.getDefaultCell().setBackgroundColor(PdfRtfExporter.BLUE_COLOR);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(this.getCell("Sample", BaseFont.HELVETICA_BOLD));

    table.getDefaultCell().setColspan(5);
    table.getDefaultCell().setBackgroundColor(PdfRtfExporter.BLUE_COLOR);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(this.getCell("Guinier", BaseFont.HELVETICA_BOLD));

    table.getDefaultCell().setColspan(3);
    table.getDefaultCell().setBackgroundColor(PdfRtfExporter.BLUE_COLOR);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(this.getCell("Gnom", BaseFont.HELVETICA_BOLD));

    table.getDefaultCell().setColspan(2);
    table.getDefaultCell().setBackgroundColor(PdfRtfExporter.BLUE_COLOR);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(this.getCell("Porod", BaseFont.HELVETICA_BOLD));
    table.setWidthPercentage(100f);//from w ww.j  a va2  s.  c  o m
    table.getDefaultCell().setPadding(3);
    table.getDefaultCell().setColspan(COLUMNS.length);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT);
    table.getDefaultCell().setColspan(1);
    table.getDefaultCell().setBackgroundColor(PdfRtfExporter.BLUE_COLOR);
    for (int i = 0; i < COLUMNS.length; i++) {
        table.addCell(this.getCell(COLUMNS[i], BaseFont.HELVETICA_BOLD));
    }
    table.getDefaultCell().setBackgroundColor(null);

    List<List<String>> data = this.getExperimentAnalysisData(experiment, buffers);

    for (List<String> list : data) {
        for (String string : list) {
            table.addCell(getCell(string));
        }
    }
    return table;
}

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

License:Open Source License

/**
 * sets the header in the specified document
 * /*from   w  ww  .j a v a2 s  . co m*/
 * @param document
 * @throws Exception
 */
private void setHeader(Document document) throws Exception {
    HeaderFooter header;
    String h = "Data Collections for Proposal: " + proposalCode + proposalNumber;
    if (name != null) {
        h += "  ---  Sample: " + name;
    } else if (slv != null) {
        h += " on Beamline: " + (slv.getBeamlineName() == null ? "" : slv.getBeamlineName())
                + "  ---  Session start date: "
                + (slv.getStartDate() == null ? "" : Formatter.formatDate(slv.getStartDate()));
    }
    header = new HeaderFooter(new Phrase(h, FONT_HELVETICA_10), false);
    header.setAlignment(Element.ALIGN_CENTER);
    header.setBorderWidth(1);
    header.getBefore().getFont().setSize(SIZE_FONT);
    document.setHeader(header);
}

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

License:Open Source License

/**
 * sets the header in the specified document
 * /*from w ww . j  a va 2 s  .c o  m*/
 * @param document
 * @throws Exception
 */
private void setHeaderForDetails(Document document) throws Exception {
    HeaderFooter header;
    String h = "Screening report for Proposal: " + proposalCode + proposalNumber;
    if (name != null) {
        h += "  ---  Sample: " + name;
    } else if (slv != null) {
        h += " on Beamline: " + (slv.getBeamlineName() == null ? "" : slv.getBeamlineName())
                + "  ---  Session start date: "
                + (slv.getStartDate() == null ? "" : Formatter.formatDate(slv.getStartDate()));
    }
    header = new HeaderFooter(new Phrase(h, FONT_HELVETICA_10), false);
    header.setAlignment(Element.ALIGN_CENTER);
    header.setBorderWidth(1);
    header.getBefore().getFont().setSize(SIZE_FONT);
    document.setHeader(header);
}

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

License:Open Source License

/**
 * sets the header in the specified document
 * /*from ww  w . jav  a2s .  c om*/
 * @param document
 * @throws Exception
 */
private void setHeaderMXPressO(Document document) throws Exception {
    HeaderFooter header;
    String h = "MXPressO/MXPressE for Proposal: " + proposalCode + proposalNumber;
    if (name != null) {
        h += "  ---  Sample: " + name;
    } else if (slv != null) {
        h += " on Beamline: " + (slv.getBeamlineName() == null ? "" : slv.getBeamlineName())
                + "  ---  Session start date: "
                + (slv.getStartDate() == null ? "" : Formatter.formatDate(slv.getStartDate()));
    }
    header = new HeaderFooter(new Phrase(h, FONT_HELVETICA_10), false);
    header.setAlignment(Element.ALIGN_CENTER);
    header.setBorderWidth(1);
    header.getBefore().getFont().setSize(SIZE_FONT);
    document.setHeader(header);
}