Example usage for com.lowagie.text Section add

List of usage examples for com.lowagie.text Section add

Introduction

In this page you can find the example usage for com.lowagie.text Section add.

Prototype

public boolean add(Object o) 

Source Link

Document

Adds a Paragraph, List, Table or another Section to this Section.

Usage

From source file:it.govpay.web.console.pagamenti.gde.exporter.PdfExporter.java

License:Open Source License

private static void createInfospcoopTable(Section subCatPart, Infospcoop infospcoop)
        throws BadElementException {

    PdfPTable table = new PdfPTable(2);

    PdfPCell c1 = new PdfPCell(new Phrase("Infospcoop"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setColspan(2);/*from   w ww  . j  a  v  a 2 s.c  o  m*/
    table.addCell(c1);
    table.setHeaderRows(1);

    //riga 1
    table.addCell(new Phrase("IdEgov"));
    table.addCell(new Phrase(infospcoop.getIdEgov()));
    // riga 2
    table.addCell(new Phrase("Soggetto Erogatore"));
    table.addCell(new Phrase(infospcoop.getTipoSoggettoErogatore() + "/" + infospcoop.getSoggettoErogatore()));
    // riga 3
    table.addCell(new Phrase("Soggetto Fruitore"));
    table.addCell(new Phrase(infospcoop.getTipoSoggettoFruitore() + "/" + infospcoop.getSoggettoFruitore()));
    // riga 4
    table.addCell(new Phrase("Servizio"));
    table.addCell(new Phrase(infospcoop.getTipoServizio() + "/" + infospcoop.getServizio()));
    // riga 5
    table.addCell(new Phrase("Azione"));
    table.addCell(new Phrase(infospcoop.getAzione()));

    subCatPart.add(table);

}

From source file:it.govpay.web.console.pagamenti.gde.exporter.PdfExporter.java

License:Open Source License

private static void createEventoTable(Section subCatPart, Evento evento) throws BadElementException {

    PdfPTable table = new PdfPTable(2);

    PdfPCell c1 = new PdfPCell(new Phrase("Evento Id[" + evento.getId() + "]"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    c1.setColspan(2);/*from   w w w  .  java2s .c om*/
    table.addCell(c1);
    table.setHeaderRows(1);

    //riga 1
    if (evento.getData() != null) {
        table.addCell(new Phrase("Data registrazione"));
        table.addCell(new Phrase("" + evento.getData()));
    }
    //riga 1
    if (evento.getDominio() != null) {
        table.addCell(new Phrase("Id Dominio"));
        table.addCell(new Phrase(evento.getDominio()));
    }
    //riga 1
    if (evento.getIuv() != null) {
        table.addCell(new Phrase("IUV"));
        table.addCell(new Phrase(evento.getIuv()));
    }
    //riga 1
    if (evento.getCcp() != null) {
        table.addCell(new Phrase("CCP"));
        table.addCell(new Phrase(evento.getCcp()));
    }
    //riga 1
    if (evento.getPsp() != null) {
        table.addCell(new Phrase("Id PSP"));
        table.addCell(new Phrase(evento.getPsp()));
    }
    //riga 1
    if (evento.getTipoVersamento() != null) {
        table.addCell(new Phrase("Tipo Versamento"));
        table.addCell(new Phrase(evento.getTipoVersamento()));
    }
    //riga 1
    if (evento.getComponente() != null) {
        table.addCell(new Phrase("Componente"));
        table.addCell(new Phrase(evento.getComponente().toString()));
    }
    //riga 1
    if (evento.getCategoria() != null) {
        table.addCell(new Phrase("Categoria Evento"));
        table.addCell(new Phrase(evento.getCategoria().toString()));
    }
    //riga 1
    if (evento.getTipo() != null) {
        table.addCell(new Phrase("Tipo Evento"));
        table.addCell(new Phrase(evento.getTipo()));
    }
    //riga 1
    if (evento.getSottoTipo() != null) {
        table.addCell(new Phrase("Sottotipo Evento"));
        table.addCell(new Phrase(evento.getSottoTipo().toString()));
    }
    //riga 1
    if (evento.getFruitore() != null) {
        table.addCell(new Phrase("Id Fruitore"));
        table.addCell(new Phrase(evento.getFruitore()));
    }
    //riga 1
    if (evento.getErogatore() != null) {
        table.addCell(new Phrase("Id Erogatore"));
        table.addCell(new Phrase(evento.getErogatore()));
    }
    //riga 1
    if (evento.getStazioneIntermediarioPA() != null) {
        table.addCell(new Phrase("Id Stazione Intermediario PA"));
        table.addCell(new Phrase(evento.getStazioneIntermediarioPA()));
    }
    //riga 1
    if (evento.getCanalePagamento() != null) {
        table.addCell(new Phrase("Canale Pagamento"));
        table.addCell(new Phrase(evento.getCanalePagamento()));
    }
    //riga 1
    if (evento.getParametri() != null) {
        table.addCell(new Phrase("Parametri Specifici Interfaccia"));
        table.addCell(new Phrase(evento.getParametri()));
    }

    if (evento.getEsito() != null) {
        table.addCell(new Phrase("Esito"));
        table.addCell(new Phrase(evento.getEsito()));
    }

    subCatPart.add(table);

}

From source file:it.govpay.web.console.pagamenti.gde.exporter.PdfExporter.java

License:Open Source License

private static void addEmptyLine(Section section, int number) {
    for (int i = 0; i < number; i++) {
        section.add(new Paragraph(" "));
    }/*w  w  w . java2  s  .  com*/
}

From source file:org.silverpeas.components.almanach.control.AlmanachPdfGenerator.java

License:Open Source License

private static void generateAlmanach(Chapter chapter, AlmanachSessionController almanach,
        List<DisplayableEventOccurrence> occurrences, String mode) {

    boolean monthScope = AlmanachPdfGenerator.PDF_MONTH_EVENTSONLY.equals(mode)
            || AlmanachPdfGenerator.PDF_MONTH_ALLDAYS.equals(mode);
    boolean yearScope = AlmanachPdfGenerator.PDF_YEAR_EVENTSONLY.equals(mode);

    int currentDay = -1;
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(almanach.getCurrentDay());
    calendar.set(Calendar.DAY_OF_MONTH, 1);
    int currentMonth = calendar.get(Calendar.MONTH);
    int currentYear = calendar.get(Calendar.YEAR);

    if (yearScope) {
        // start from begin of current year
        calendar.set(Calendar.MONTH, 0);
    }// w w  w.j a  v a2  s.  c om

    // for each day of the current month
    while ((monthScope && currentMonth == calendar.get(Calendar.MONTH))
            || (yearScope && currentYear == calendar.get(Calendar.YEAR))) {
        Section section = null;
        if (AlmanachPdfGenerator.PDF_MONTH_ALLDAYS.equals(mode)) {
            section = chapter.addSection(generateParagraph(calendar, almanach), 0);
        }

        Font titleTextFont = new Font(Font.BOLD, 12, Font.SYMBOL, new Color(0, 0, 0));

        // get the events of the current day
        for (DisplayableEventOccurrence occurrence : occurrences) {
            EventDetail event = occurrence.getEventDetail();
            String theDay = DateUtil.date2SQLDate(calendar.getTime());
            String startDay = DateUtil.date2SQLDate(occurrence.getStartDate().asDate());
            String startHour = event.getStartHour();
            String endHour = event.getEndHour();

            if (startDay.compareTo(theDay) > 0) {
                continue;
            }

            String endDay = startDay;
            if (event.getEndDate() != null) {
                endDay = DateUtil.date2SQLDate(occurrence.getEndDate().asDate());
            }

            if (endDay.compareTo(theDay) < 0) {
                continue;
            }

            if (calendar.get(Calendar.DAY_OF_MONTH) != currentDay) {
                if (AlmanachPdfGenerator.PDF_MONTH_EVENTSONLY.equals(mode)
                        || AlmanachPdfGenerator.PDF_YEAR_EVENTSONLY.equals(mode)) {
                    section = chapter.addSection(generateParagraph(calendar, almanach), 0);
                }
                currentDay = calendar.get(Calendar.DAY_OF_MONTH);
            }

            Font textFont;
            if (event.getPriority() == 0) {
                textFont = new Font(Font.HELVETICA, 10, Font.NORMAL, new Color(0, 0, 0));
            } else {
                textFont = new Font(Font.HELVETICA, 10, Font.BOLD, new Color(0, 0, 0));
            }

            String eventTitle = event.getTitle();
            if (startDay.compareTo(theDay) == 0 && startHour != null && startHour.length() != 0) {
                eventTitle += " (" + startHour;
                if (endDay.compareTo(theDay) == 0 && endHour != null && endHour.length() != 0) {
                    eventTitle += "-" + endHour;
                }
                eventTitle += ")";
            }

            section.add(new Paragraph(eventTitle, titleTextFont));
            if (StringUtil.isDefined(event.getPlace())) {
                section.add(new Paragraph(event.getPlace(), titleTextFont));
            }
            if (StringUtil.isDefined(event.getDescription(almanach.getLanguage()))) {
                section.add(new Paragraph(event.getDescription(almanach.getLanguage()), textFont));
            }
            section.add(new Paragraph("\n"));

        } // end for
        calendar.add(Calendar.DAY_OF_MONTH, 1);
    }
}

From source file:org.sonar.report.pdf.DefaultPDFReporter.java

License:Open Source License

private void printDashboard(Project project, Section section) throws DocumentException {
    PdfPTable dashboard = new PdfPTable(3);
    dashboard.getDefaultCell().setBorderColor(Color.WHITE);
    Font titleFont = new Font(Font.TIMES_ROMAN, 14, Font.BOLD, Color.BLACK);
    Font dataFont = new Font(Font.TIMES_ROMAN, 14, Font.BOLD, Color.GRAY);
    Font dataFont2 = new Font(Font.TIMES_ROMAN, 10, Font.BOLD, new Color(100, 150, 190));

    PdfPTable linesOfCode = new PdfPTable(1);
    linesOfCode.getDefaultCell().setBorderColor(Color.WHITE);
    linesOfCode.addCell(new Phrase(getTextProperty("general.lines_of_code"), titleFont));
    linesOfCode.addCell(new Phrase(project.getMeasure("ncss").getFormatValue(), dataFont));
    linesOfCode.addCell(/*from  www. java2s.  c  o m*/
            new Phrase(project.getMeasure("packages_count").getFormatValue() + " packages", dataFont2));
    linesOfCode
            .addCell(new Phrase(project.getMeasure("classes_count").getFormatValue() + " classes", dataFont2));
    linesOfCode.addCell(
            new Phrase(project.getMeasure("functions_count").getFormatValue() + " methods", dataFont2));
    linesOfCode.addCell(new Phrase(
            project.getMeasure("duplicated_lines_ratio").getFormatValue() + " duplicated lines", dataFont2));

    PdfPTable comments = new PdfPTable(1);
    comments.getDefaultCell().setBorderColor(Color.WHITE);
    comments.addCell(new Phrase(getTextProperty("general.comments"), titleFont));
    comments.addCell(new Phrase(project.getMeasure("comment_ratio").getFormatValue(), dataFont));
    comments.addCell(
            new Phrase(project.getMeasure("comment_lines").getFormatValue() + " comment lines", dataFont2));

    PdfPTable codeCoverage = new PdfPTable(1);
    codeCoverage.getDefaultCell().setBorderColor(Color.WHITE);
    codeCoverage.addCell(new Phrase(getTextProperty("general.test_count"), titleFont));
    codeCoverage.addCell(new Phrase(project.getMeasure("test_count").getFormatValue(), dataFont));
    codeCoverage.addCell(
            new Phrase(project.getMeasure("test_success_percentage").getFormatValue() + " success", dataFont2));
    codeCoverage
            .addCell(new Phrase(project.getMeasure("code_coverage").getFormatValue() + " coverage", dataFont2));

    PdfPTable complexity = new PdfPTable(1);
    complexity.getDefaultCell().setBorderColor(Color.WHITE);
    complexity.addCell(new Phrase(getTextProperty("general.complexity"), titleFont));
    complexity.addCell(new Phrase(project.getMeasure("ccn_function").getFormatValue(), dataFont));
    complexity.addCell(new Phrase(project.getMeasure("ccn_class").getFormatValue() + " /class", dataFont2));
    complexity.addCell(new Phrase(project.getMeasure("ccn").getFormatValue() + " decision points", dataFont2));

    PdfPTable rulesCompliance = new PdfPTable(1);
    rulesCompliance.getDefaultCell().setBorderColor(Color.WHITE);
    rulesCompliance.addCell(new Phrase(getTextProperty("general.rules_compliance"), titleFont));
    rulesCompliance.addCell(new Phrase(project.getMeasure("rules_compliance").getFormatValue(), dataFont));

    PdfPTable violations = new PdfPTable(1);
    violations.getDefaultCell().setBorderColor(Color.WHITE);
    violations.addCell(new Phrase(getTextProperty("general.violations"), titleFont));
    violations.addCell(new Phrase(project.getMeasure("rules_violations").getFormatValue(), dataFont));

    dashboard.addCell(linesOfCode);
    dashboard.addCell(comments);
    dashboard.addCell(codeCoverage);
    dashboard.addCell(complexity);
    dashboard.addCell(rulesCompliance);
    dashboard.addCell(violations);
    dashboard.setSpacingBefore(8);
    section.add(dashboard);
    Image ccnDistGraph = getCCNDistribution(project);
    if (ccnDistGraph != null) {
        section.add(ccnDistGraph);
        Paragraph imageFoot = new Paragraph(getTextProperty("metrics.ccn_classes_count_distribution"),
                Style.FOOT_FONT);
        imageFoot.setAlignment(Paragraph.ALIGN_CENTER);
        section.add(imageFoot);
    }
}

From source file:org.sonar.report.pdf.DefaultPDFReporter.java

License:Open Source License

private void printMeasures(Measures measures, Section section)
        throws org.dom4j.DocumentException, DocumentException {

    PdfPTable versioningTable = new PdfPTable(2);
    formatTable(versioningTable);//from  ww  w  . j  a v a  2 s . co m
    versioningTable.getDefaultCell().setColspan(2);
    versioningTable
            .addCell(new Phrase(super.getTextProperty("general.versioning_information"), Style.TITLE_FONT));
    versioningTable.addCell(measures.getVersion());
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd - HH:mm:ss");
    versioningTable.addCell(df.format(measures.getDate()));

    PdfPTable measuresTable = new PdfPTable(2);
    formatTable(measuresTable);

    Iterator<String> it = measures.getMeasuresKeys().iterator();
    measuresTable.addCell(new Phrase(super.getTextProperty("general.metric"), Style.TITLE_FONT));
    measuresTable.addCell(new Phrase(super.getTextProperty("general.value"), Style.TITLE_FONT));
    boolean colorEnabled = true;
    while (it.hasNext()) {
        String measureKey = it.next();
        if (colorEnabled) {
            measuresTable.getDefaultCell().setGrayFill(0.9f);
            colorEnabled = false;
        } else {
            measuresTable.getDefaultCell().setGrayFill(1);
            colorEnabled = true;
        }
        if (!measureKey.equals("ccn_classes_count_distribution")
                && !measureKey.equals("ccn_classes_percent_distribution")) {
            measuresTable.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_LEFT);
            measuresTable.addCell(super.getTextProperty("metrics." + measureKey));
            measuresTable.getDefaultCell().setHorizontalAlignment(PdfCell.ALIGN_CENTER);
            measuresTable.addCell(measures.getMeasure(measureKey).getFormatValue());
        }
    }
    measuresTable.setHeaderRows(1);
    section.add(versioningTable);
    section.add(measuresTable);

}

From source file:org.sonar.report.pdf.DefaultPDFReporter.java

License:Open Source License

private void printProjectInfo(Project project, Section section)
        throws DocumentException, org.dom4j.DocumentException {
    List data = new List();
    data.add(new ListItem(super.getTextProperty("general.name") + ": " + project.getName()));
    data.add(new ListItem(super.getTextProperty("general.description") + ": " + project.getDescription()));
    data.add(new ListItem(super.getTextProperty("general.modules") + ": "));

    List sublist = new List();
    if (project.getSubprojects().size() != 0) {
        Iterator<Project> it = project.getSubprojects().iterator();
        while (it.hasNext()) {
            sublist.add(new ListItem(it.next().getName()));
        }/*from ww w.  jav  a2 s .  co  m*/
    } else {
        sublist.add(new ListItem(super.getTextProperty("general.no_modules")));
    }

    sublist.setIndentationLeft(indentation);
    data.add(sublist);
    section.add(data);
    printMeasures(project.getMeasures(), section);
}

From source file:org.sonar.report.pdf.ExecutivePDFReporter.java

License:Open Source License

protected void printDashboard(Project project, Section section) throws DocumentException {

    // Static Analysis
    Paragraph staticAnalysis = new Paragraph(getTextProperty("general.static_analysis"), Style.UNDERLINED_FONT);
    PdfPTable staticAnalysisTable = new PdfPTable(3);
    staticAnalysisTable.getDefaultCell().setBorderColor(Color.WHITE);

    PdfPTable linesOfCode = new PdfPTable(1);
    Style.noBorderTable(linesOfCode);
    linesOfCode.addCell(new Phrase(getTextProperty("general.lines_of_code"), Style.DASHBOARD_TITLE_FONT));
    PdfPTable linesOfCodeTendency = new PdfPTable(2);
    Style.noBorderTable(linesOfCodeTendency);
    linesOfCodeTendency.getDefaultCell().setFixedHeight(Style.TENDENCY_ICONS_HEIGHT);
    linesOfCodeTendency.addCell(/*from  w  ww. j av a  2s. c  om*/
            new Phrase(project.getMeasure(MetricKeys.NCLOC).getFormatValue(), Style.DASHBOARD_DATA_FONT));
    linesOfCodeTendency.addCell(getTendencyImage(project.getMeasure(MetricKeys.NCLOC).getQualitativeTendency(),
            project.getMeasure(MetricKeys.NCLOC).getQuantitativeTendency()));

    linesOfCode.addCell(linesOfCodeTendency);
    linesOfCode.addCell(new Phrase(project.getMeasure(MetricKeys.PACKAGES).getFormatValue() + " packages",
            Style.DASHBOARD_DATA_FONT_2));
    linesOfCode.addCell(new Phrase(project.getMeasure(MetricKeys.CLASSES).getFormatValue() + " classes",
            Style.DASHBOARD_DATA_FONT_2));
    linesOfCode.addCell(new Phrase(project.getMeasure(MetricKeys.FUNCTIONS).getFormatValue() + " methods",
            Style.DASHBOARD_DATA_FONT_2));
    linesOfCode.addCell(new Phrase(
            project.getMeasure(MetricKeys.DUPLICATED_LINES_DENSITY).getFormatValue() + " duplicated lines",
            Style.DASHBOARD_DATA_FONT_2));

    PdfPTable comments = new PdfPTable(1);
    Style.noBorderTable(comments);
    comments.addCell(new Phrase(getTextProperty("general.comments"), Style.DASHBOARD_TITLE_FONT));
    PdfPTable commentsTendency = new PdfPTable(2);
    commentsTendency.getDefaultCell().setFixedHeight(Style.TENDENCY_ICONS_HEIGHT);
    Style.noBorderTable(commentsTendency);
    commentsTendency.addCell(new Phrase(project.getMeasure(MetricKeys.COMMENT_LINES_DENSITY).getFormatValue(),
            Style.DASHBOARD_DATA_FONT));
    commentsTendency.addCell(
            getTendencyImage(project.getMeasure(MetricKeys.COMMENT_LINES_DENSITY).getQualitativeTendency(),
                    project.getMeasure(MetricKeys.COMMENT_LINES_DENSITY).getQuantitativeTendency()));
    comments.addCell(commentsTendency);
    comments.addCell(
            new Phrase(project.getMeasure(MetricKeys.COMMENT_LINES).getFormatValue() + " comment lines",
                    Style.DASHBOARD_DATA_FONT_2));

    PdfPTable complexity = new PdfPTable(1);
    Style.noBorderTable(complexity);
    complexity.addCell(new Phrase(getTextProperty("general.complexity"), Style.DASHBOARD_TITLE_FONT));
    PdfPTable complexityTendency = new PdfPTable(2);
    complexityTendency.getDefaultCell().setFixedHeight(Style.TENDENCY_ICONS_HEIGHT);
    Style.noBorderTable(complexityTendency);
    complexityTendency.addCell(new Phrase(project.getMeasure(MetricKeys.FUNCTION_COMPLEXITY).getFormatValue(),
            Style.DASHBOARD_DATA_FONT));
    complexityTendency.addCell(
            getTendencyImage(project.getMeasure(MetricKeys.FUNCTION_COMPLEXITY).getQualitativeTendency(),
                    project.getMeasure(MetricKeys.FUNCTION_COMPLEXITY).getQuantitativeTendency()));
    complexity.addCell(complexityTendency);
    complexity.addCell(new Phrase(project.getMeasure(MetricKeys.CLASS_COMPLEXITY).getFormatValue() + " /class",
            Style.DASHBOARD_DATA_FONT_2));
    complexity
            .addCell(new Phrase(project.getMeasure(MetricKeys.COMPLEXITY).getFormatValue() + " decision points",
                    Style.DASHBOARD_DATA_FONT_2));

    staticAnalysisTable.setSpacingBefore(10);
    staticAnalysisTable.addCell(linesOfCode);
    staticAnalysisTable.addCell(comments);
    staticAnalysisTable.addCell(complexity);
    staticAnalysisTable.setSpacingAfter(20);

    // Dynamic Analysis
    Paragraph dynamicAnalysis = new Paragraph(getTextProperty("general.dynamic_analysis"),
            Style.UNDERLINED_FONT);
    PdfPTable dynamicAnalysisTable = new PdfPTable(3);
    Style.noBorderTable(dynamicAnalysisTable);

    PdfPTable codeCoverage = new PdfPTable(1);
    Style.noBorderTable(codeCoverage);
    codeCoverage.addCell(new Phrase(getTextProperty("general.code_coverage"), Style.DASHBOARD_TITLE_FONT));
    PdfPTable codeCoverageTendency = new PdfPTable(2);
    Style.noBorderTable(codeCoverageTendency);
    codeCoverageTendency.getDefaultCell().setFixedHeight(Style.TENDENCY_ICONS_HEIGHT);
    codeCoverageTendency.addCell(new Phrase(
            project.getMeasure(MetricKeys.COVERAGE).getFormatValue() + " coverage", Style.DASHBOARD_DATA_FONT));
    codeCoverageTendency
            .addCell(getTendencyImage(project.getMeasure(MetricKeys.COVERAGE).getQualitativeTendency(),
                    project.getMeasure(MetricKeys.COVERAGE).getQuantitativeTendency()));
    codeCoverage.addCell(codeCoverageTendency);
    codeCoverage.addCell(new Phrase(project.getMeasure(MetricKeys.TESTS).getFormatValue() + " tests",
            Style.DASHBOARD_DATA_FONT_2));

    PdfPTable testSuccess = new PdfPTable(1);
    Style.noBorderTable(testSuccess);
    testSuccess.addCell(new Phrase(getTextProperty("general.test_success"), Style.DASHBOARD_TITLE_FONT));
    PdfPTable testSuccessTendency = new PdfPTable(2);
    Style.noBorderTable(testSuccessTendency);
    testSuccessTendency.getDefaultCell().setFixedHeight(Style.TENDENCY_ICONS_HEIGHT);
    testSuccessTendency.addCell(new Phrase(project.getMeasure(MetricKeys.TEST_SUCCESS_DENSITY).getFormatValue(),
            Style.DASHBOARD_DATA_FONT));
    testSuccessTendency.addCell(
            getTendencyImage(project.getMeasure(MetricKeys.TEST_SUCCESS_DENSITY).getQualitativeTendency(),
                    project.getMeasure(MetricKeys.TEST_SUCCESS_DENSITY).getQuantitativeTendency()));
    testSuccess.addCell(testSuccessTendency);
    testSuccess.addCell(new Phrase(project.getMeasure(MetricKeys.TEST_FAILURES).getFormatValue() + " failures",
            Style.DASHBOARD_DATA_FONT_2));
    testSuccess.addCell(new Phrase(project.getMeasure(MetricKeys.TEST_ERRORS).getFormatValue() + " errors",
            Style.DASHBOARD_DATA_FONT_2));

    dynamicAnalysisTable.setSpacingBefore(10);
    dynamicAnalysisTable.addCell(codeCoverage);
    dynamicAnalysisTable.addCell(testSuccess);
    dynamicAnalysisTable.addCell("");
    dynamicAnalysisTable.setSpacingAfter(20);

    Paragraph codingRulesViolations = new Paragraph(getTextProperty("general.coding_rules_violations"),
            Style.UNDERLINED_FONT);
    PdfPTable codingRulesViolationsTable = new PdfPTable(3);
    Style.noBorderTable(codingRulesViolationsTable);

    PdfPTable rulesCompliance = new PdfPTable(1);
    Style.noBorderTable(rulesCompliance);
    rulesCompliance
            .addCell(new Phrase(getTextProperty("general.rules_compliance"), Style.DASHBOARD_TITLE_FONT));
    PdfPTable rulesComplianceTendency = new PdfPTable(2);
    Style.noBorderTable(rulesComplianceTendency);
    rulesComplianceTendency.getDefaultCell().setFixedHeight(Style.TENDENCY_ICONS_HEIGHT);
    rulesComplianceTendency.addCell(new Phrase(
            project.getMeasure(MetricKeys.VIOLATIONS_DENSITY).getFormatValue(), Style.DASHBOARD_DATA_FONT));

    // Workarround for avoid resizing
    Image tendencyRulesResize = getTendencyImage(
            project.getMeasure(MetricKeys.VIOLATIONS_DENSITY).getQualitativeTendency(),
            project.getMeasure(MetricKeys.VIOLATIONS_DENSITY).getQuantitativeTendency());
    tendencyRulesResize.scaleAbsolute(Style.TENDENCY_ICONS_HEIGHT, Style.TENDENCY_ICONS_HEIGHT);
    PdfPCell tendencyRulesCell = new PdfPCell(tendencyRulesResize);
    tendencyRulesCell.setBorder(0);
    rulesComplianceTendency.addCell(tendencyRulesCell);
    rulesCompliance.addCell(rulesComplianceTendency);

    PdfPTable violations = new PdfPTable(1);
    Style.noBorderTable(violations);
    violations.addCell(new Phrase(getTextProperty("general.violations"), Style.DASHBOARD_TITLE_FONT));
    PdfPTable violationsTendency = new PdfPTable(2);
    Style.noBorderTable(violationsTendency);
    violationsTendency.getDefaultCell().setFixedHeight(Style.TENDENCY_ICONS_HEIGHT);
    violationsTendency.addCell(
            new Phrase(project.getMeasure(MetricKeys.VIOLATIONS).getFormatValue(), Style.DASHBOARD_DATA_FONT));

    // Workarround for avoid resizing
    Image tendencyResize = getTendencyImage(project.getMeasure(MetricKeys.VIOLATIONS).getQualitativeTendency(),
            project.getMeasure(MetricKeys.VIOLATIONS).getQuantitativeTendency());
    tendencyResize.scaleAbsolute(Style.TENDENCY_ICONS_HEIGHT, Style.TENDENCY_ICONS_HEIGHT);
    PdfPCell tendencyCell = new PdfPCell(tendencyResize);
    tendencyCell.setBorder(0);
    violationsTendency.addCell(tendencyCell);

    violations.addCell(violationsTendency);

    codingRulesViolationsTable.setSpacingBefore(10);
    codingRulesViolationsTable.addCell(rulesCompliance);
    codingRulesViolationsTable.addCell(violations);
    codingRulesViolationsTable.addCell("");
    codingRulesViolationsTable.setSpacingAfter(20);

    section.add(Chunk.NEWLINE);
    section.add(staticAnalysis);
    section.add(staticAnalysisTable);
    section.add(dynamicAnalysis);
    section.add(dynamicAnalysisTable);
    section.add(codingRulesViolations);
    section.add(codingRulesViolationsTable);
}

From source file:org.sonar.report.pdf.ExecutivePDFReporter.java

License:Open Source License

protected void printMostDuplicatedFiles(Project project, Section section) {
    List<FileInfo> files = project.getMostDuplicatedFiles();
    Iterator<FileInfo> it = files.iterator();
    List<String> left = new LinkedList<String>();
    List<String> right = new LinkedList<String>();

    while (it.hasNext()) {
        FileInfo file = it.next();/*from ww w  .j  a  v  a2 s.c  om*/
        left.add(file.getName());
        right.add(file.getDuplicatedLines());
    }

    PdfPTable mostDuplicatedFilesTable = Style.createSimpleTable(left, right,
            getTextProperty("general.most_duplicated_files"), getTextProperty("general.no_duplicated_files"));
    section.add(mostDuplicatedFilesTable);
}

From source file:org.sonar.report.pdf.ExecutivePDFReporter.java

License:Open Source License

protected void printMostComplexFiles(Project project, Section section) {
    List<FileInfo> files = project.getMostComplexFiles();
    Iterator<FileInfo> it = files.iterator();
    List<String> left = new LinkedList<String>();
    List<String> right = new LinkedList<String>();

    while (it.hasNext()) {
        FileInfo file = it.next();/*from  ww  w. j  a  va 2 s  . c  om*/
        left.add(file.getName());
        right.add(file.getComplexity());
    }

    PdfPTable mostComplexFilesTable = Style.createSimpleTable(left, right,
            getTextProperty("general.most_complex_files"), getTextProperty("general.no_complex_files"));
    section.add(mostComplexFilesTable);
}