List of usage examples for com.lowagie.text Chunk NEWLINE
Chunk NEWLINE
To view the source code for com.lowagie.text Chunk NEWLINE.
Click Source Link
From source file:org.pz.platypus.plugin.pdf.commands.PdfCodeOff.java
License:Open Source License
public int process(final IOutputContext context, final Token tok, final int tokNum) { if (context == null || tok == null) { throw new IllegalArgumentException(); }//from w w w. j av a 2 s. c o m PdfData pdd = (PdfData) context; if (!pdd.inCodeSection()) { return 0; //not currently in a code section } int addlTokensToSkip = 0; TokenList tokens = pdd.getGdd().getInputTokens(); // must output the paragraph manually for listing, because the [-code] command after a // listing implies an end of a paragraph and adds a CR/LF to the listing. if (pdd.isInCodeListing()) { pdd.setInCodeListing(false); PdfOutfile outfile = pdd.getOutfile(); if (outfile != null) { Paragraph para = outfile.getItPara(); if (para != null && para.size() > 0) { if (nextTokenIsEol(tokens, tokNum) && !justBeforeEndOfParagraph(tokens, tokNum)) { para.add(new Chunk(Chunk.NEWLINE)); addlTokensToSkip += 1; } // outfile.addParagraph( para, outfile.getItColumn() ); // outfile.setItPara( new Paragraph( pdd.getLeading() )); } } } PdfRestoreFormat.restore(pdd, tok.getSource()); pdd.setInCodeSection(false, tok.getSource()); return (addlTokensToSkip); }
From source file:org.pz.platypus.plugin.pdf.commands.PdfCodeWithOptions.java
License:Open Source License
/** * Emits a CR or CR/LF to the PDF outfile. * @param outfile to which newLine is written *//*from ww w . j a v a 2s .c o m*/ private void emitNewLine(final PdfOutfile outfile) { Paragraph para = outfile.getItPara(); para.add(new Chunk(Chunk.NEWLINE)); }
From source file:org.pz.platypus.plugin.pdf.commands.PdfEol.java
License:Open Source License
public int process(final IOutputContext context, final Token tok, final int tokNum) { if (context == null) { throw new IllegalArgumentException(); }//from ww w .j av a 2 s . c om PdfData pdf = (PdfData) context; PdfOutfile outfile = pdf.getOutfile(); TokenList tl = pdf.getGdd().getInputTokens(); Token nextTok = tl.getNextToken(tokNum); // if we're at the last input token, then do nothing if (nextTok == null) { return 0; } // if the [cr] occurs at the end of a line that consisted entirely of commands, // then ignore it (so that the following text does not have an unwanted leading character). // so with a line consisting entirely of [fsize:12pt] simply changes font size, but // adds no character to the ouput stream if (!tl.lineSoFarEmitsText(tokNum)) { return 0; } // if EolTreatment = hard, issue CR/LF if (!new EolTreatment().isSoft(pdf.getEolTreatment())) { Paragraph para = outfile.getItPara(); if (para != null) { para.add(new Chunk(Chunk.NEWLINE)); } return 0; } outfile.emitText(" "); return 0; }
From source file:org.pz.platypus.plugin.pdf.commands.PdfEoParagraph.java
License:Open Source License
public int process(final IOutputContext context, final Token tok, final int tokNum) { if (context == null) { throw new IllegalArgumentException(); }//www. j a va 2 s . c o m PdfData pdf = (PdfData) context; // if we're in an paragraph with content, then close it and start a new one. // If we're not, it's likely because someone has inserted multiple blank lines, // so we just skip a line. Paragraph currPar = pdf.getOutfile().getItPara(); // if( currPar == null || ! currPar.isEmpty() ) { if (currPar == null || currPar.size() > 0) { pdf.getOutfile().startNewParagraph(); } else { currPar.add(new Chunk(Chunk.NEWLINE)); } return 0; }
From source file:org.pz.platypus.plugin.pdf.commands.PdfHardCR.java
License:Open Source License
public int process(final IOutputContext context, final Token tok, final int tokNum) { if (context == null || tok == null) { throw new IllegalArgumentException(); }//w w w. j a v a 2 s . c o m PdfData pdd = (PdfData) context; PdfOutfile outfile = pdd.getOutfile(); if (outfile == null) { return (0); //TODO: Error message, though effectively an impossible error. } // a [] marks the end of a bullet entry. If the entry is a paragraph, (almost always the case) // then add it to the current list and return. Paragraph currPar = pdd.getOutfile().getItPara(); if (outfile.inABulletList()) { if (currPar != null && !currPar.isEmpty()) { outfile.addParagraphToList(currPar); return (0); } } currPar.add(new Chunk(Chunk.NEWLINE)); // if it's the first token in line, it = a blank line, so an additional // NEWLINE needs to be emitted, unless it's right after an end of listing command, // which has already emitted the extra CR/LF. if (isFirstTokenInLine(context, tok, tokNum) && !isAfterCodeListing(context, tokNum) && currPar != null) { currPar.add(new Chunk(Chunk.NEWLINE)); } return 0; }
From source file:org.pz.platypus.plugin.pdf.PdfOutfile.java
License:Open Source License
/** * Implement the line spacing before the paragraph, if any. * * Note: We do this manually rather than call Paragraph.setSpacingBefore() in iText * because setSpacingBefore() in iText affects the current paragraph. So is [paraskip=0] * occurs midway in a paragraph, that pargraph will have 0 spacing before it, rather than * the previous paraskip value, which was in effect when the paragraph was started. 2009-01-31 * * @param para the paragraph to align//from ww w . ja va 2 s . c o m * @param pData the PdfData container holding the current settings of the PDF output */ void doParagraphSpaceBefore(final Paragraph para, final PdfData pData) { float skipLines = pData.getParagraphSkip(); // add 1, as you need 2 NEWLINES for the first line's skip. skipLines++; while (skipLines-- > 0) { para.add(new Chunk(Chunk.NEWLINE)); } }
From source file:org.sonar.report.pdf.DefaultPDFReporter.java
License:Open Source License
@Override protected void printTocTitle(Toc tocDocument) throws DocumentException { Paragraph tocTitle = new Paragraph(super.getTextProperty("main.table.of.contents"), Style.TOC_TITLE_FONT); tocTitle.setAlignment(Element.ALIGN_CENTER); tocDocument.getTocDocument().add(tocTitle); tocDocument.getTocDocument().add(Chunk.NEWLINE); }
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(// w w w . ja va 2 s. co m 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
@Override protected void printTocTitle(Toc tocDocument) throws com.lowagie.text.DocumentException { Paragraph tocTitle = new Paragraph(super.getTextProperty("main.table.of.contents"), Style.TOC_TITLE_FONT); tocTitle.setAlignment(Element.ALIGN_CENTER); tocDocument.getTocDocument().add(tocTitle); tocDocument.getTocDocument().add(Chunk.NEWLINE); }
From source file:org.sonarqube.report.extendedpdf.OverviewPDFReporter.java
License:Open Source License
@Override protected void printTocTitle(Toc tocDocument) throws com.lowagie.text.DocumentException { Paragraph tocTitle = new Paragraph(super.getTextProperty("extendedpdf.main.table.of.contents"), Style.TOC_TITLE_FONT); tocTitle.setAlignment(Element.ALIGN_CENTER); tocDocument.getTocDocument().add(tocTitle); tocDocument.getTocDocument().add(Chunk.NEWLINE); }