/** * Adds a collection of <CODE>Chunk</CODE>s * to this <CODE>Phrase</CODE>. * * @param collection a collection of <CODE>Chunk</CODE>s, <CODE>Anchor</CODE>s and <CODE>Phrase</CODE>s. * @return <CODE>true</CODE> if the action succeeded, <CODE>false</CODE> if not. * @throws ClassCastException when you try to add something that isn't a <CODE>Chunk</CODE>, <CODE>Anchor</CODE> or <CODE>Phrase</CODE> */ @Override public boolean addAll(final Collection<? extends Element> collection) { for (Element e: collection) { this.add(e); } return true; }
/** * Adds an <CODE>Element</CODE> to the <CODE>Paragraph</CODE>. * * @param o the element to add. * @return true is adding the object succeeded */ @Override public boolean add(Element o) { if (o instanceof List) { List list = (List) o; list.setIndentationLeft(list.getIndentationLeft() + indentationLeft); list.setIndentationRight(indentationRight); return super.add(list); } else if (o instanceof Image) { super.addSpecial(o); return true; } else if (o instanceof Paragraph) { super.addSpecial(o); return true; } return super.add(o); }
success &= this.add(e);
/** * Adds a collection of <CODE>Chunk</CODE>s * to this <CODE>Phrase</CODE>. * * @param collection a collection of <CODE>Chunk</CODE>s, <CODE>Anchor</CODE>s and <CODE>Phrase</CODE>s. * @return <CODE>true</CODE> if the action succeeded, <CODE>false</CODE> if not. * @throws ClassCastException when you try to add something that isn't a <CODE>Chunk</CODE>, <CODE>Anchor</CODE> or <CODE>Phrase</CODE> */ @Override public boolean addAll(final Collection<? extends Element> collection) { for (Element e: collection) { this.add(e); } return true; }
/** * Adds an <CODE>Element</CODE> to the <CODE>Paragraph</CODE>. * * @param o the element to add. * @return true is adding the object succeeded */ @Override public boolean add(Element o) { if (o instanceof List) { List list = (List) o; list.setIndentationLeft(list.getIndentationLeft() + indentationLeft); list.setIndentationRight(indentationRight); return super.add(list); } else if (o instanceof Image) { super.addSpecial(o); return true; } else if (o instanceof Paragraph) { super.addSpecial(o); return true; } return super.add(o); }
success &= this.add(e);
/** * Process the text so that it will render with a combination of fonts * if needed. * @param text the text * @return a <CODE>Phrase</CODE> with one or more chunks */ public Phrase process(String text) { if (fonts.size() == 0) throw new IndexOutOfBoundsException(MessageLocalization.getComposedMessage("no.font.is.defined")); char cc[] = text.toCharArray(); int len = cc.length; StringBuffer sb = new StringBuffer(); Phrase ret = new Phrase(); currentFont = null; for (int k = 0; k < len; ++k) { Chunk newChunk = processChar(cc, k, sb); if (newChunk != null) { ret.add(newChunk); } } if (sb.length() > 0) { Chunk ck = new Chunk(sb.toString(), currentFont != null ? currentFont : fonts.get(0)); ret.add(ck); } return ret; }
/** * Process the text so that it will render with a combination of fonts * if needed. * @param text the text * @return a <CODE>Phrase</CODE> with one or more chunks */ public Phrase process(String text) { if (getSize() == 0) throw new IndexOutOfBoundsException(MessageLocalization.getComposedMessage("no.font.is.defined")); char cc[] = text.toCharArray(); int len = cc.length; StringBuffer sb = new StringBuffer(); Phrase ret = new Phrase(); currentFont = null; for (int k = 0; k < len; ++k) { Chunk newChunk = processChar(cc, k, sb); if (newChunk != null) { ret.add(newChunk); } } if (sb.length() > 0) { Chunk ck = new Chunk(sb.toString(), currentFont != null ? currentFont : getFont(0)); ret.add(ck); } return ret; }
private void addFileStatsRows(final TestRunCoverageStatistics runStats, final PdfPTable table) { final List<ScriptCoverageStatistics> allFileStats = runStats.getFileStats(); for (int i = 0; i < allFileStats.size(); i++) { final ScriptCoverageStatistics scriptCoverageStatistics = allFileStats.get(i); final boolean hasStatements = scriptCoverageStatistics.getHasStatements(); final Phrase fileName = new Phrase(); if (scriptCoverageStatistics.getParentName() != null) { fileName.add(new Chunk(scriptCoverageStatistics.getParentName() + "/", hasStatements ? FONT_TD : FONT_TD_EMPTY_FILE)); fileName.add(new Chunk(scriptCoverageStatistics.getFileName(), hasStatements ? FONT_TD_BOLD : FONT_TD_BOLD_EMPTY_FILE)); } else { fileName.add(new Chunk(scriptCoverageStatistics.getFileName(), hasStatements ? FONT_TD : FONT_TD_EMPTY_FILE)); } final BaseColor bgColor = (i % 2 == 1) ? COLOR_ROW_ODD : COLOR_ROW_EVEN; final Font font = FONT_TD; table.addCell(createCell(fileName, 0, bgColor)); table.addCell(createCell(String.valueOf(scriptCoverageStatistics.getStatements()), font, 1, bgColor)); table.addCell(createCell(String.valueOf(scriptCoverageStatistics.getExecuted()), font, 2, bgColor)); table.addCell(createCell(scriptCoverageStatistics.getCoverage() + "%", FONT_TD, 3, bgColor)); } }
private void printVariables(Chapter chapter, List<Variable> variables, int parentLevel) { Paragraph sTitle = new Paragraph("Process Variables", sectionFont); Section section = chapter.addSection(sTitle, parentLevel == 0 ? 0 : (parentLevel + 1)); com.itextpdf.text.List list = new com.itextpdf.text.List(false, false, 10.0f); for (Variable var : variables) { Phrase phrase = new Phrase(); phrase.add(new Chunk(var.getName(), fixedWidthFont)); String v = var.getType(); if (var.getDescription() != null) v += " (" + var.getDescription() + ")"; phrase.add(new Chunk(": " + v + "\n", normalFont)); list.add(new ListItem(phrase)); } section.add(list); }
private void printAttributes(Section section, List<Attribute> attrs, int parentLevel) { Paragraph sTitle = new Paragraph("Activity Attributes", subSectionFont); Section subsection = section.addSection(sTitle, parentLevel == 0 ? 0 : (parentLevel + 1)); com.itextpdf.text.List list = new com.itextpdf.text.List(false, false, 20.0f); for (Attribute attr : attrs) { if (excludeAttribute(attr.getAttributeName(), attr.getAttributeValue())) continue; Phrase phrase = new com.itextpdf.text.Phrase(); phrase.add(new Chunk(attr.getAttributeName(), fixedWidthFont)); String v = attr.getAttributeValue(); if (v == null) v = ""; phrase.add(new Chunk(": " + v, normalFont)); list.add(new ListItem(phrase)); } subsection.add(list); }