com.lowagie.text.Paragraph.add()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(287)

本文整理了Java中com.lowagie.text.Paragraph.add()方法的一些代码示例,展示了Paragraph.add()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Paragraph.add()方法的具体详情如下:
包路径:com.lowagie.text.Paragraph
类名称:Paragraph
方法名:add

Paragraph.add介绍

[英]Adds an Object to the Paragraph.
[中]将Object添加到Paragraph

代码示例

代码示例来源:origin: primefaces/primefaces

protected void addEmptyLine(Paragraph paragraph, int number) {
  for (int i = 0; i < number; i++) {
    paragraph.add(new Paragraph(" "));
  }
}

代码示例来源:origin: javamelody/javamelody

private void writeSqlRequestExplainPlan() throws DocumentException {
  try {
    final String explainPlan;
    if (collectorServer == null) {
      explainPlan = DatabaseInformations.explainPlanFor(request.getName());
    } else {
      explainPlan = collectorServer.collectSqlRequestExplainPlan(
          collector.getApplication(), request.getName());
    }
    if (explainPlan != null) {
      final Paragraph paragraph = new Paragraph("", cellFont);
      paragraph.add(new Phrase('\n' + getString("Plan_d_execution") + '\n', boldFont));
      paragraph.add(new Phrase(explainPlan, courierFont));
      addToDocument(paragraph);
    }
  } catch (final Exception e) {
    final Paragraph paragraph = new Paragraph("", cellFont);
    paragraph.add(new Phrase('\n' + getString("Plan_d_execution") + '\n', boldFont));
    paragraph.add(new Phrase(e.toString(), cellFont));
    addToDocument(paragraph);
  }
}

代码示例来源:origin: javamelody/javamelody

private void writeDurations(List<CounterRequestContext> contexts)
    throws DocumentException, IOException {
  getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
  final Paragraph paragraph = new Paragraph("", cellFont);
  boolean first = true;
  for (final CounterRequestContext context : contexts) {
    if (!first) {
      paragraph.add(new Chunk('\n', cellFont));
    }
    final int duration = context.getDuration(timeOfSnapshot);
    final Counter parentCounter = context.getParentCounter();
    final PdfCounterReport counterReport = counterReportsByCounterName
        .get(parentCounter.getName());
    if (parentCounter.getIconName() != null) {
      paragraph.add(new Chunk(getImage(parentCounter.getIconName()), 0, -1));
    }
    final Font slaFont;
    if (counterReport == null) {
      slaFont = infoCellFont;
    } else {
      slaFont = counterReport.getSlaFont(duration);
    }
    paragraph.add(new Phrase(integerFormat.format(duration), slaFont));
    first = false;
  }
  addCell(paragraph);
}

代码示例来源:origin: javamelody/javamelody

Element createParagraphElement(String paragraphTitle, String iconName)
    throws DocumentException, IOException {
  final Paragraph paragraph = new Paragraph("", paragraphTitleFont);
  paragraph.setSpacingBefore(5);
  paragraph.setSpacingAfter(5);
  if (iconName != null) {
    paragraph.add(new Chunk(getParagraphImage(iconName), 0, -5));
  }
  final Phrase element = new Phrase(' ' + paragraphTitle, paragraphTitleFont);
  element.setLeading(12);
  paragraph.add(element);
  // chapter pour avoir la liste des signets
  final ChapterAutoNumber chapter = new ChapterAutoNumber(paragraph);
  // sans numéro de chapitre
  chapter.setNumberDepth(0);
  chapter.setBookmarkOpen(false);
  chapter.setTriggerNewPage(false);
  return chapter;
}

代码示例来源:origin: javamelody/javamelody

private void writeRequest(CounterRequestContext context, PdfPCell cell, int margin)
    throws DocumentException, IOException {
  final Paragraph paragraph = new Paragraph(
      getDefaultCell().getLeading() + cellFont.getSize());
  paragraph.setIndentationLeft(margin);
  if (context.getParentCounter().getIconName() != null) {
    paragraph.add(new Chunk(getImage(context.getParentCounter().getIconName()), 0, -1));
  }
  paragraph.add(new Phrase(context.getCompleteRequestName(), cellFont));
  cell.addElement(paragraph);
}

代码示例来源:origin: javamelody/javamelody

FontFactory.getFont(FontFactory.HELVETICA, 9f, Font.NORMAL));
jrobinParagraph.setAlignment(Element.ALIGN_CENTER);
jrobinParagraph.add(new Phrase("\n\n\n\n"));
final Collection<byte[]> graphs;
if (mySmallGraphs != null) {
  if (i % 3 == 0 && i != 0) {
    jrobinParagraph.add(new Phrase("\n\n\n\n\n"));
  jrobinParagraph.add(new Phrase(new Chunk(image, 0, 0)));
  jrobinParagraph.add(new Phrase(" "));
  i++;
jrobinParagraph.add(new Phrase("\n"));
addToDocument(jrobinParagraph);

代码示例来源:origin: javamelody/javamelody

@Override
void toPdf() throws IOException, DocumentException {
  if (sessionsInformations.isEmpty()) {
    addToDocument(new Phrase(getString("Aucune_session"), cellFont));
    return;
  }
  writeHeader();
  writeSessions();
  long totalSerializedSize = 0;
  int nbSerializableSessions = 0;
  for (final SessionInformations sessionInformations : sessionsInformations) {
    final int size = sessionInformations.getSerializedSize();
    if (size >= 0) {
      totalSerializedSize += size;
      nbSerializableSessions++;
    }
  }
  final long meanSerializedSize;
  if (nbSerializableSessions > 0) {
    meanSerializedSize = totalSerializedSize / nbSerializableSessions;
  } else {
    meanSerializedSize = -1;
  }
  final Paragraph paragraph = new Paragraph("", cellFont);
  paragraph.add(getFormattedString("nb_sessions", sessionsInformations.size()) + "\n\n"
      + getFormattedString("taille_moyenne_sessions", meanSerializedSize));
  paragraph.setAlignment(Element.ALIGN_RIGHT);
  addToDocument(paragraph);
}

代码示例来源:origin: javamelody/javamelody

private void addPsCommandReference() throws DocumentException {
  final Anchor psAnchor = new Anchor("ps command reference", PdfFonts.BLUE.getFont());
  psAnchor.setName("ps command reference");
  psAnchor.setReference("http://en.wikipedia.org/wiki/Ps_(Unix)");
  psAnchor.setFont(PdfFonts.BLUE.getFont());
  final Paragraph psParagraph = new Paragraph();
  psParagraph.add(psAnchor);
  psParagraph.setAlignment(Element.ALIGN_RIGHT);
  addToDocument(psParagraph);
}

代码示例来源:origin: javamelody/javamelody

private void addConfigurationReference() throws DocumentException {
  final Anchor quartzAnchor = new Anchor("Configuration reference", PdfFonts.BLUE.getFont());
  quartzAnchor.setName("Quartz configuration reference");
  quartzAnchor.setReference("http://www.quartz-scheduler.org/docs/index.html");
  quartzAnchor.setFont(PdfFonts.BLUE.getFont());
  final Paragraph quartzParagraph = new Paragraph();
  quartzParagraph.add(quartzAnchor);
  quartzParagraph.setAlignment(Element.ALIGN_RIGHT);
  addToDocument(quartzParagraph);
}

代码示例来源:origin: javamelody/javamelody

private void addConfigurationReference() throws DocumentException {
  final Anchor ehcacheAnchor = new Anchor("Configuration reference", PdfFonts.BLUE.getFont());
  ehcacheAnchor.setName("Ehcache configuration reference");
  ehcacheAnchor.setReference(
      "http://ehcache.sourceforge.net/apidocs/net/sf/ehcache/config/CacheConfiguration.html#field_summary");
  ehcacheAnchor.setFont(PdfFonts.BLUE.getFont());
  final Paragraph ehcacheParagraph = new Paragraph();
  ehcacheParagraph.add(ehcacheAnchor);
  ehcacheParagraph.setAlignment(Element.ALIGN_RIGHT);
  addToDocument(ehcacheParagraph);
}

代码示例来源:origin: javamelody/javamelody

@Override
void toPdf() throws DocumentException, IOException {
  if (request != null) {
    if (request.getRumData() != null && request.getRumData().getHits() != 0) {
      writeRequestRumData();
    }
    writeHeader();
    writeRequests();
    addTableToDocument();
    if (JdbcWrapper.SINGLETON.getSqlCounter().isRequestIdFromThisCounter(request.getId())
        && !request.getName().toLowerCase(Locale.ENGLISH).startsWith("alter ")) {
      // inutile d'essayer d'avoir le plan d'exécution des requêtes sql
      // telles que "alter session set ..." (cf issue 152)
      writeSqlRequestExplainPlan();
    }
  }
  if (isGraphDisplayed()) {
    writeGraph();
  }
  if (request != null && request.getStackTrace() != null) {
    final Paragraph paragraph = new Paragraph("\n", cellFont);
    paragraph.setIndentationLeft(20);
    paragraph.setIndentationRight(20);
    paragraph.add(new Phrase("Stack-trace\n", boldFont));
    paragraph.add(new Phrase(request.getStackTrace().replace("\t", "        "), cellFont));
    addToDocument(paragraph);
  }
}

代码示例来源:origin: stackoverflow.com

preface.add(new Paragraph("Title of the document", catFont));
preface.add(new Paragraph(
    "Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    smallBold));
addEmptyLine(preface, 3);
preface.add(new Paragraph(
    "This document describes something which is very important ",
    smallBold));
preface.add(new Paragraph(
    "This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.de ;-).",
    redFont));

代码示例来源:origin: javamelody/javamelody

private void writeAttributes(MBeanNode mbean) throws DocumentException {
  final String description = mbean.getDescription();
  final List<MBeanAttribute> attributes = mbean.getAttributes();
  if (description != null || !attributes.isEmpty()) {
    currentTable = createAttributesTable();
    if (description != null) {
      currentTable.getDefaultCell().setColspan(3);
      addCell('(' + description + ')');
      currentTable.getDefaultCell().setColspan(1);
    }
    for (final MBeanAttribute attribute : attributes) {
      writeAttribute(attribute);
    }
    final Paragraph paragraph = new Paragraph();
    paragraph.setIndentationLeft(margin);
    paragraph.add(currentTable);
    addToDocument(paragraph);
    addText("\n");
  }
}

代码示例来源:origin: javamelody/javamelody

private void writeRequest(CounterRequest childRequest, float executionsByRequest,
    boolean allChildHitsDisplayed) throws IOException, DocumentException {
  final PdfPCell defaultCell = getDefaultCell();
  defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
  final Paragraph paragraph = new Paragraph(defaultCell.getLeading() + cellFont.getSize());
  if (executionsByRequest != -1) {
    paragraph.setIndentationLeft(5);
  }
  final Counter parentCounter = getCounterByRequestId(childRequest);
  if (parentCounter != null && parentCounter.getIconName() != null) {
    paragraph.add(new Chunk(getSmallImage(parentCounter.getIconName()), 0, -1));
  }
  paragraph.add(new Phrase(childRequest.getName(), cellFont));
  final PdfPCell requestCell = new PdfPCell();
  requestCell.addElement(paragraph);
  requestCell.setGrayFill(defaultCell.getGrayFill());
  requestCell.setPaddingTop(defaultCell.getPaddingTop());
  addCell(requestCell);
  defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
  if (executionsByRequest != -1) {
    addCell(nbExecutionsFormat.format(executionsByRequest));
  } else {
    final boolean hasChildren = !request.getChildRequestsExecutionsByRequestId().isEmpty();
    if (hasChildren) {
      addCell("");
    }
  }
  writeRequestValues(childRequest, allChildHitsDisplayed);
}

代码示例来源:origin: javamelody/javamelody

final Paragraph paragraph = new Paragraph(
    getDefaultCell().getLeading() + cellFont.getSize());
paragraph.add(new Chunk(
    getImage(
        "bullets/" + HtmlThreadInformationsReport.getStateIcon(threadInformations)),
    0, -1));
paragraph.add(new Phrase(String.valueOf(threadInformations.getState()), cellFont));
cell.addElement(paragraph);
addCell(cell);

代码示例来源:origin: stackoverflow.com

public class CreatePdf{
  private Font bigFont = FontFactory.getFont(FontFactory.HELVETICA, "Windows-1254", 12, Font.BOLD, new Color(0, 0, 0));
  private Font smallFont = FontFactory.getFont(FontFactory.HELVETICA, "Windows-1254", 8, Font.NORMAL, new Color(0, 0, 0));

  public void create(){
   Paragraph parag1=new Paragraph("Number: ",bigFont);//This gonna be bold font
   Paragraph parag2=new Paragraph("12", smallFont); //This gonna be normal font
   Paragraph comb=new Paragraph(); 
   comb.add(new Chunk(parag1)) 
   comb.add(new Chunk(parag2)); 
  }
}

代码示例来源:origin: org.primefaces/primefaces

protected void addEmptyLine(Paragraph paragraph, int number) {
  for (int i = 0; i < number; i++) {
    paragraph.add(new Paragraph(" "));
  }
}

代码示例来源:origin: stackoverflow.com

Chunk sigUnderline = new Chunk("                                            ");
 sigUnderline.setUnderline(0.1f, -2f);
 Chunk dateUnderline = new Chunk("                       ");
 dateUnderline.setUnderline(0.1f, -2f);
 Paragraph para = new Paragraph("Authorized Signature: ");
 para.add(sigUnderline);
 para.add(new Chunk(" Date: "));
 para.add(dateUnderline);
 document.add(para);

代码示例来源:origin: stackoverflow.com

Chunk reportTitle= new Chunk("Candidate Login Report ",catFont);
Chunk divisiontitle = new Chunk("Division : \t\t"+divisionName);

Phrase phrase = new Phrase();
phrase.add(reportTitle);
phrase.add(divisiontitle);

Paragraph para = new Paragraph();
para.add(phrase);
para.setAlignment(Element.ALIGN_RIGHT);

代码示例来源:origin: net.bull.javamelody/javamelody-core

private void addPsCommandReference() throws DocumentException {
  final Anchor psAnchor = new Anchor("ps command reference", PdfFonts.BLUE.getFont());
  psAnchor.setName("ps command reference");
  psAnchor.setReference("http://en.wikipedia.org/wiki/Ps_(Unix)");
  psAnchor.setFont(PdfFonts.BLUE.getFont());
  final Paragraph psParagraph = new Paragraph();
  psParagraph.add(psAnchor);
  psParagraph.setAlignment(Element.ALIGN_RIGHT);
  addToDocument(psParagraph);
}

相关文章