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:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java

License:Open Source License

/**
 * Entering the project outputs in the summary
 *//*from  w  w  w  .jav a 2s .c  om*/
private void addProjectOutputs(String number) {

    // **********************************************************************************
    // *************************** Overview By Mog *************************************
    // **********************************************************************************
    try {
        Paragraph overview_title = new Paragraph();
        overview_title.setFont(HEADING2_FONT);
        overview_title.add(number + ". " + this.getText("summaries.project.projectOutput"));
        overview_title.add(Chunk.NEWLINE);
        overview_title.add(Chunk.NEWLINE);

        document.newPage();
        document.add(overview_title);

        overview_title = new Paragraph();
        overview_title.setFont(HEADING3_FONT);
        overview_title.add(number + ".1 " + this.getText("summaries.project.overviewbymogs"));
        document.add(overview_title);

    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project title to the project summary pdf", e);
    }

    int[] years = { midOutcomeYear,
            project.isReporting() ? this.currentReportingYear - 1 : this.currentReportingYear - 1,
            project.isReporting() ? this.currentReportingYear : this.currentPlanningYear,
            project.isReporting() ? this.currentReportingYear + 1 : this.currentReportingYear + 1 };

    Paragraph paragraph = new Paragraph();

    List<IPElement> mogs = project.getOutputs();
    try {
        if (mogs.isEmpty()) {
            paragraph.add(this.getText("summaries.project.empty"));
            document.add(paragraph);

        } else {
            // year
            PdfPTable table;
            for (int a = 0; a < years.length; a++) {
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_HEADER_FONT);
                paragraph.add(this.getText("summaries.project.overviewbymogs.text") + "- " + years[a]);
                table = new PdfPTable(1);
                table.setLockedWidth(true);
                table.setTotalWidth(480);
                this.addTableHeaderCell(table, paragraph);
                // Mog
                for (int b = 0; b < mogs.size(); b++) {
                    this.addOverview(table, mogs.get(b), years[a]);
                }
                paragraph = new Paragraph();
                paragraph.add(Chunk.NEWLINE);
                document.add(paragraph);
                document.add(table);
            }

            // Leason regardins
            paragraph = new Paragraph();
            paragraph.add(Chunk.NEWLINE);
            paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
            paragraph.setFont(BODY_TEXT_BOLD_FONT);
            if (!project.isReporting()) {
                paragraph.add(this.getText("summaries.project.output.lessonRegarding"));
            } else {
                paragraph.add(this.getText("summaries.project.overviewbymogs.reporting.lesson"));
            }
            paragraph.setFont(BODY_TEXT_FONT);
            if (project.getComponentLesson("outputs") != null) {
                paragraph.add(this.messageReturn(project.getComponentLesson("outputs").getLessons()));
            } else {
                paragraph.add(this.messageReturn(null));
            }
            paragraph.add(Chunk.NEWLINE);
            paragraph.add(Chunk.NEWLINE);
            document.add(paragraph);
        }

    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project title to the project summary pdf", e);
    }

    // **********************************************************************************
    // *************************** Deliverables.****************************************
    // **********************************************************************************

    int counter = 1;
    try {
        document.newPage();
        paragraph = new Paragraph();
        paragraph.setFont(HEADING3_FONT);
        paragraph.add(number + ".2 " + this.getText("summaries.project.deliverable.title"));
        document.add(paragraph);
        paragraph = new Paragraph();

        List<Deliverable> listDeliverables = project.getDeliverables();
        if (listDeliverables.isEmpty()) {
            paragraph.add(this.getText("summaries.project.empty"));
            document.add(paragraph);
        } else {
            paragraph.add(Chunk.NEWLINE);
            document.add(paragraph);
            for (Deliverable deliverable : listDeliverables) {
                if (!project.isReporting()) {
                    if (deliverable.getYear() == config.getPlanningCurrentYear()) {
                        this.addDelivable(deliverable, counter);
                        counter++;

                    }
                }
            }
        }

        // **********************************************************************************
        // *************************** Next users.****************************************
        // **********************************************************************************

        if (project.isReporting()) {

            counter = 1;
            document.newPage();
            paragraph = new Paragraph();
            paragraph.setFont(HEADING3_FONT);
            paragraph.add(number + ".3 " + this.getText("summaries.project.reporting.nextuser.title"));
            document.add(paragraph);

            PdfPTable table;

            if (project.getNextUsers().isEmpty()) {

                paragraph = new Paragraph();
                paragraph.add(this.messageReturn(null));
                paragraph.add(Chunk.NEWLINE);
                document.add(paragraph);

            } else {
                paragraph = new Paragraph();
                paragraph.add(Chunk.NEWLINE);
                document.add(paragraph);

                for (ProjectNextUser projectNextUser : project.getNextUsers()) {

                    paragraph = new Paragraph();
                    paragraph.setFont(TABLE_HEADER_FONT);
                    paragraph.setAlignment(Element.ALIGN_LEFT);

                    table = new PdfPTable(1);
                    table.setLockedWidth(true);
                    table.setTotalWidth(480);

                    paragraph.add(this.getText("summaries.project.reporting.nextuser",
                            new String[] { String.valueOf(counter) }));
                    this.addTableHeaderCell(table, paragraph);

                    // Next users key
                    paragraph = new Paragraph();
                    paragraph.setFont(TABLE_BODY_BOLD_FONT);
                    paragraph.add(this.getText("summaries.project.reporting.nextuser.currentPeriod"));
                    paragraph.setFont(TABLE_BODY_FONT);

                    if (projectNextUser != null) {
                        paragraph.add(this.messageReturn(projectNextUser.getKeyNextUser()));
                    } else {
                        paragraph.add(this.messageReturn(null));
                    }
                    this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                    // Strategies
                    paragraph = new Paragraph();
                    paragraph.setFont(TABLE_BODY_BOLD_FONT);
                    paragraph.add(this.getText("summaries.project.reporting.nextuser.strategies"));
                    paragraph.setFont(TABLE_BODY_FONT);

                    if (projectNextUser != null) {
                        paragraph.add(this.messageReturn(projectNextUser.getStrategies()));
                    } else {
                        paragraph.add(this.messageReturn(null));
                    }
                    this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                    // reported
                    paragraph = new Paragraph();
                    paragraph.setFont(TABLE_BODY_BOLD_FONT);
                    paragraph.add(this.getText("summaries.project.reporting.nextuser.reported"));
                    paragraph.setFont(TABLE_BODY_FONT);

                    if (projectNextUser != null) {
                        paragraph.add(this.messageReturn(projectNextUser.getReportedDeliverables()));
                    } else {
                        paragraph.add(this.messageReturn(null));
                    }
                    this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                    // lessons
                    paragraph = new Paragraph();
                    paragraph.setFont(TABLE_BODY_BOLD_FONT);
                    paragraph.add(this.getText("summaries.project.reporting.nextuser.lessons"));
                    paragraph.setFont(TABLE_BODY_FONT);

                    if (projectNextUser != null) {
                        paragraph.add(this.messageReturn(projectNextUser.getLessonsImplications()));
                    } else {
                        paragraph.add(this.messageReturn(null));
                    }
                    this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                    counter++;
                    document.add(table);
                    paragraph = new Paragraph();
                    paragraph.add(Chunk.NEWLINE);
                    document.add(paragraph);
                }
            }

            // **********************************************************************************
            // *************************** Project HighLights****************************************
            // **********************************************************************************
            counter = 1;
            document.newPage();
            paragraph = new Paragraph();
            paragraph.setFont(HEADING3_FONT);
            paragraph.add(number + ".4 " + this.getText("summaries.project.reporting.highlight.principal"));
            document.add(paragraph);

            paragraph = new Paragraph();
            paragraph.add(Chunk.NEWLINE);
            document.add(paragraph);

            for (ProjectHighligths projectHighLigth : project.getHighlights()) {
                table = new PdfPTable(2);
                table.setLockedWidth(true);
                table.setTotalWidth(480);

                paragraph = new Paragraph();
                paragraph.setFont(TABLE_HEADER_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight",
                        new String[] { String.valueOf(counter) }));
                this.addTableHeaderCellColspan(table, paragraph, 2);

                // title
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.title"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getTitle()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // author
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.author"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getAuthor()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // subject
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.subject"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getSubject()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // publisher
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.publisher"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getPublisher()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // year
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.year"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(String.valueOf(projectHighLigth.getYear())));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // project highlight types
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.types"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    for (ProjectHighligthsTypes projectHighLigthTypes : projectHighLigth
                            .getProjectHighligthsTypeses()) {
                        paragraph.add(this.messageReturn("\n" + ProjectHighlightsType
                                .getEnum(String.valueOf(projectHighLigthTypes.getIdType())).getDescription()));
                    }
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // project images
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add("Image");

                if (projectHighLigth != null) {
                    Image global;
                    try {
                        if (projectHighLigth.getPhoto() != null) {
                            String urlImage = config.getDownloadURL() + "/" + this.getHighlightsImagesUrlPath()
                                    + projectHighLigth.getPhoto();
                            urlImage = urlImage.replace(" ", "%20");
                            global = Image.getInstance(urlImage);

                        } else {
                            global = null;
                        }

                        if (global != null) {

                            float documentWidth = document.getPageSize().getWidth() - document.leftMargin()
                                    - document.rightMargin();
                            float documentHeight = document.getPageSize().getHeight() - document.topMargin()
                                    - document.bottomMargin();
                            global.scaleToFit((float) (documentWidth * 0.4), global.getHeight());
                            global.setAlignment(Element.ALIGN_CENTER);

                            this.addTableBodyCell(table, global, Element.ALIGN_LEFT, 1);

                        }

                    } catch (MalformedURLException e) {

                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();

                    }

                } else {
                    paragraph.add(this.messageReturn(null));
                }

                // project start date
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.startDate"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(String.valueOf(projectHighLigth.getStartDate())));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // project end date
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.endDate"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(String.valueOf(projectHighLigth.getEndDate())));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);

                // Its Global
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.itsglobal"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    if (projectHighLigth.isIsGlobal()) {
                        paragraph.add("Yes");
                    } else {
                        paragraph.add("No");
                    }
                    ;
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // Country
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.country"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null && projectHighLigth.getProjectHighligthsCountries() != null) {
                    for (ProjectHighligthsCountry country : projectHighLigth.getProjectHighligthsCountries()) {
                        paragraph.add(locationManager.getCountry(country.getIdCountry()).getName() + "\n");
                    }
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableBodyCell(table, paragraph, Element.ALIGN_LEFT, 1);
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.keywords"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getKeywords()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // description
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.description"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getDescription()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // Introduction / Objectives
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.introduction"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getObjectives()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // Results
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.results"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getResults()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // Partners
                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.partners"));
                paragraph.setFont(TABLE_BODY_FONT);
                if (projectHighLigth != null) {
                    paragraph.add(this.messageReturn(projectHighLigth.getPartners()));
                } else {
                    paragraph.add(this.messageReturn(null));
                }
                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                // Links

                paragraph = new Paragraph();
                paragraph.setFont(TABLE_BODY_BOLD_FONT);
                paragraph.add(this.getText("summaries.project.reporting.highlight.links"));
                paragraph.setFont(TABLE_BODY_FONT);
                paragraph.add(this.messageReturn(projectHighLigth.getLinks()));

                this.addTableColSpanCell(table, paragraph, Element.ALIGN_LEFT, 1, 2);

                document.add(table);
                document.newPage();
            }

        }
    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project title to the project summary pdf", e);
    }
}

From source file:org.cgiar.ccafs.ap.summaries.projects.pdf.ProjectSummaryPDF.java

License:Open Source License

/**
 * Entering the project title in the summary
 *//*from  www. ja v  a  2 s  . com*/
private void addProjectTitle() {
    LineSeparator line = new LineSeparator(1, 100, null, Element.ALIGN_CENTER, -7);
    Paragraph paragraph = new Paragraph();
    line.setLineColor(titleColor);
    try {
        paragraph.setAlignment(Element.ALIGN_JUSTIFIED);
        paragraph.setFont(BODY_TEXT_BOLD_FONT);
        paragraph.add("Title: ");
        paragraph.setFont(BODY_TEXT_FONT);
        paragraph.add(this.messageReturn(project.getTitle()));
        paragraph.add(line);
        document.add(paragraph);
        document.add(Chunk.NEWLINE);
        ;
    } catch (DocumentException e) {
        LOG.error("There was an error trying to add the project title to the project summary pdf", e);
    }
}

From source file:org.cocktail.superplan.server.gestionimpression.TabularEdtReport.java

License:CeCILL license

public NSData genererPdf(NSArray creneaux, NSTimestamp debutSemaine, String semaine, String libelleFormation)
        throws DocumentException {

    ByteArrayOutputStream os = new ByteArrayOutputStream();
    Document document = new Document();
    PdfWriter.getInstance(document, os);
    document.open();//from w w w  .  ja v  a 2  s. com
    document.setMargins(0, 0, 0, 0);

    Font font = new Font(Font.TIMES_ROMAN, 12, Font.BOLD, Color.DARK_GRAY);

    PdfPTable headerTable = new PdfPTable(1);

    PdfPCell cell = new PdfPCell();
    Phrase ph = new Phrase();
    ph.add(new Chunk(libelleFormation, font));
    cell.setPhrase(ph);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    headerTable.addCell(cell);

    font = new Font(Font.TIMES_ROMAN, 10, Font.NORMAL, Color.DARK_GRAY);
    cell = new PdfPCell();
    ph = new Phrase();
    ph.add(new Chunk(semaine, font));
    cell.setPhrase(ph);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    headerTable.addCell(cell);

    headerTable.setWidthPercentage(100);
    headerTable.setSpacingAfter(5.0f);

    document.add(headerTable);

    PdfPTable pdfTable = creerCreneauxTable(creneaux, debutSemaine);

    pdfTable.setWidthPercentage(100);

    document.add(pdfTable);
    document.close();
    return new NSData(os.toByteArray());
}

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

License:Artistic License

/**
 * @see org.displaytag.export.BinaryExportView#doExport(OutputStream)
 *///  w  w w .  j  a va 2 s .  co m
public void doExport(OutputStream out) throws JspException {
    try {
        // Initialize the table with the appropriate number of columns
        initTable();

        // Initialize the Document and register it with PdfWriter listener and the OutputStream
        Document document = new Document(PageSize.A4.rotate(), 60, 60, 40, 40);
        document.addCreationDate();
        HeaderFooter footer = new HeaderFooter(new Phrase(TagConstants.EMPTY_STRING, smallFont), true);
        footer.setBorder(Rectangle.NO_BORDER);
        footer.setAlignment(Element.ALIGN_CENTER);

        PdfWriter.getInstance(document, out);

        // Fill the virtual PDF table with the necessary data
        generatePDFTable();
        document.open();
        document.setFooter(footer);
        document.add(this.tablePDF);
        document.close();

    } catch (Exception e) {
        throw new PdfGenerationException(e);
    }
}

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

License:Artistic License

/**
 * Obtain the caption horizontal alignment; Meant to be overriden if a different style is desired.
 * @return The caption horizontal alignment.
 *//*from   w  ww .  j  a  v a  2 s . co  m*/
protected int getCaptionHorizontalAlignment() {
    return Element.ALIGN_CENTER;
}

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

License:Artistic License

/**
 * Obtain the horizontal alignment used to render header text; Meant to be overridden if a different alignment is
 * desired.// w w  w .  j a  v  a  2s  .c  o  m
 * @return The horizontal alignment used to render header text;
 */
protected int getHeaderHorizontalAlignment() {
    return Element.ALIGN_CENTER;
}

From source file:org.drools.verifier.doc.DroolsDocsComponentFactory.java

License:Apache License

public static void createFirstPage(Document document, String currentDate, DrlPackageParser packageData)
        throws DocumentException {
    Paragraph title = new Paragraph("\n\n\n\n\n" + packageData.getName().toUpperCase(), RULE_PACKAGE_TITLE);
    title.setAlignment(Element.ALIGN_CENTER);
    document.add(title);//from  w  ww .  j  av  a  2  s  .  c o  m

    Paragraph date = new Paragraph("Documentation created: " + currentDate, BODY_TEXT);
    date.setAlignment(Element.ALIGN_CENTER);
    document.add(date);

    document.add(new Paragraph("\n\n\n\n\n" + packageData.getDescription(), BODY_TEXT));
    document.add(newTable("Metadata ", packageData.getMetadata()));
    document.add(newTable("Globals ", packageData.getGlobals()));
    createOtherItems(document, packageData.getOtherInformation());
}

From source file:org.eclipse.osee.ats.rest.internal.build.report.table.BuildTraceTable.java

License:Open Source License

public void initializeTraceReportTable(String program, String build) throws OseeCoreException {
    String header = String.format("%s: [%s - %s]", AtsElementData.BUILD_TRACE_REPORT, program, build);
    document = new Document();
    document.addTitle(header);/*w  w  w.ja v  a2  s  .c o  m*/
    HtmlWriter.getInstance(document, output);
    document.open();
    createTables();
    Cell headerCell = new RtfCell(header);
    headerCell.setColspan(1);
    headerCell.setHeader(true);
    headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    reportTable.addCell(headerCell);
    reportTable.endHeaders();
    reportTable.setTableFitsPage(true);

    Cell rpcrCell = new RtfCell(AtsElementData.RPCR);
    rpcrCell.setHeader(true);
    rpcrCell.setHorizontalAlignment(Element.ALIGN_CENTER);
    traceReportTable.addCell(rpcrCell);

    Cell req = new Cell(AtsElementData.REQUIREMENT);
    req.setHeader(true);
    req.setHorizontalAlignment(Element.ALIGN_CENTER);
    nestedHeaderTable.addCell(req);
    Cell script = new Cell(AtsElementData.TEST_SCRIPT);
    script.setHeader(true);
    script.setHorizontalAlignment(Element.ALIGN_CENTER);
    nestedHeaderTable.addCell(script);

    traceReportTable.insertTable(nestedHeaderTable);
    sortedRpcr = new TreeSet<Pair<String, Table>>(PairCompare);

}

From source file:org.eclipse.osee.ats.rest.internal.build.report.table.UrlListTable.java

License:Open Source License

public void initializeTable(String title, String lastRun, String... headers) throws OseeCoreException {
    document = new Document();
    lastRunDate = lastRun;//from  ww w  . j av  a  2 s  .c  om
    sortedList = new TreeSet<List<Anchor>>(new Comparator<List<Anchor>>() {

        @Override
        public int compare(List<Anchor> anchor1, List<Anchor> anchor2) {
            String name1 = anchor1.get(0).toString();
            String name2 = anchor2.get(0).toString();
            return name1.compareTo(name2);
        }
    });
    HtmlWriter.getInstance(document, output);
    document.addTitle(title);
    document.open();

    try {
        table = new Table(headers.length);
    } catch (BadElementException ex) {
        OseeExceptions.wrapAndThrow(ex);
    }

    for (String header : headers) {
        Cell headerCell = new Cell(header);
        headerCell.setHeader(true);
        headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(headerCell);
    }
    table.setWidth(10f * headers.length);
    table.setAlignment(Element.ALIGN_BOTTOM);
}

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

License:Open Source License

@Override
public void doExport(final OutputStream out) throws JspException {

    try {//from www .  j  av  a  2 s  .c o  m
        // Initialize the table with the appropriate number of columns
        initTable();

        // Initialize the Document and register it with PdfWriter listener and the OutputStream
        final Document document = new Document(PageSize.A4.rotate(), 60, 60, 40, 40);
        document.addCreationDate();
        final HeaderFooter footer = new HeaderFooter(new Phrase(TagConstants.TAGNAME_CAPTION, this.smallFont),
                true);
        footer.setBorder(Rectangle.NO_BORDER);
        footer.setAlignment(Element.ALIGN_CENTER);

        // PdfWriter.getInstance(document, out);
        PdfWriter.getInstance(document, out).setPageEvent(new PageNumber());
        // Fill the virtual PDF table with the necessary data
        generatePDFTable();
        document.open();

        // Table table = new Table(this.model.getNumberOfColumns());
        // ItextTableWriter writer = new ItextTableWriter(tablePDF, document);
        // writer.writeTable(this.model, "-1");
        // document.setFooter(footer);
        // document.setHeader(footer);
        document.add(this.tableCaption);
        document.add(this.tablePDF);
        document.close();

    } catch (final Exception e) {

        throw new PdfGenerationException(e);
    }

}