List of usage examples for com.itextpdf.text Section setTriggerNewPage
public void setTriggerNewPage(final boolean triggerNewPage)
From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java
License:Open Source License
private void buildSectionStakeholders(Section section) { String sectionIntro = "This section describes the stakeholders identified in the " + getProjectName() + " project. Stakeholders are represented by roles and agents."; section.add(createParagraph(sectionIntro)); List<Actor> selActor = getStakeholderActors(); if (selActor.size() != 0) { StringBuilder sb = new StringBuilder(); sb.append("In particular, "); List<Role> roles = new ArrayList<Role>(); for (Actor a : selActor) { if (a instanceof Role) roles.add((Role) a); }/*w ww . j a va 2s. c o m*/ List<String> rolesNames = new ArrayList<String>(); for (Role r : roles) { rolesNames.add("%i" + r.getName() + "%"); } if (roles.size() == 0) { } else if (roles.size() == 1) { sb.append("identified role is: " + rolesNames.get(0) + socialDiagRef()); } else { sb.append("identified roles are: " + separateListOfString(rolesNames) + socialDiagRef()); } List<Agent> agents = new ArrayList<Agent>(); for (Actor a : selActor) { if (a instanceof Agent) agents.add((Agent) a); } List<String> agentsNames = new ArrayList<String>(); for (Agent a : agents) { agentsNames.add("%i" + a.getName() + "%"); } if (roles.size() > 0 && agents.size() > 0) { sb.append(", while "); } else if (agents.size() == 0) { sb.append("."); } if (agents.size() == 0) { } else if (agents.size() == 1) { if (roles.size() > 0) sb.append(" "); sb.append("identified agent is: " + agentsNames.get(0) + socialDiagRef() + "."); } else { if (roles.size() > 0) sb.append(" "); sb.append("identified agents are: " + separateListOfString(agentsNames) + socialDiagRef() + ". "); } // section.add(createParagraph(sb.toString())); // sb = new StringBuilder(); if (roles.size() > 0) { sb.append(" " + ftc.getTable(FigureConstant.ROLE_TABLE)); if (agents.size() > 0) sb.append(" and " + ftc.getTable(FigureConstant.AGENT_TABLE)); } else { sb.append(" " + ftc.getTable(FigureConstant.AGENT_TABLE)); } sb.append(" summarise the stakeholders."); section.add(createParagraph(sb.toString())); if (roles.size() > 0) { List<String[]> headers = new ArrayList<String[]>(); headers.add(new String[] { "Role" }); headers.add(new String[] { "Description" }); headers.add(new String[] { "Mission" }); headers.add(new String[] { "Purpose" }); PdfPTable table = createTable(headers); for (Role r : roles) { table.addCell(getContentCell(r.getName())); table.addCell(getContentCell(r.getDescription())); table.addCell(getContentCell(r.getMission())); table.addCell(getContentCell(r.getPurpose())); } addTableCaption(table, ftc.getTable(FigureConstant.ROLE_TABLE) + " - Roles in the " + getProjectName() + " project."); section.add(table); table.setComplete(true); section.add(getDefaultParagraph()); } if (agents.size() > 0) { List<String[]> headers = new ArrayList<String[]>(); headers.add(new String[] { "Agent" }); headers.add(new String[] { "Description" }); headers.add(new String[] { "Abilities" }); headers.add(new String[] { "Important", "Features" }); headers.add(new String[] { "Certifications", "Accreditations" }); headers.add(new String[] { "Type Of", "Organisation" }); PdfPTable table = createTable(headers); for (Agent a : agents) { table.addCell(getContentCell(a.getName())); table.addCell(getContentCell(a.getDescription())); table.addCell(getContentCell(a.getAbilities())); table.addCell(getContentCell(a.getOtherImportantFeatures())); table.addCell(getContentCell(a.getPossessedCertificationsAndAccreditations())); table.addCell(getContentCell(a.getTypeOfOrganisation())); } addTableCaption(table, ftc.getTable(FigureConstant.AGENT_TABLE) + " - Agents in the " + getProjectName() + " project"); section.add(table); table.setComplete(true); section.add(getDefaultParagraph()); } sb = new StringBuilder(); List<Play> plays = new ArrayList<Play>(); for (Actor a : getStakeholderActors()) { if (a instanceof Agent) { for (Play p : ((Agent) a).getPlayedRoles()) { if (p.getTarget() != null) plays.add(p); } } } if (plays.size() > 0) { section.add(createParagraph( "Agents and roles are related by means of %i play % relations, as reported on " + ftc.getTable(FigureConstant.PLAY_TABLE))); List<String[]> headers = new ArrayList<String[]>(); headers.add(new String[] { "Agent" }); headers.add(new String[] { "Role" }); PdfPTable table = createTable(headers); for (Play p : plays) { table.addCell(getContentCell(p.getSource().getName())); table.addCell(getContentCell(p.getTarget().getName())); } addTableCaption(table, ftc.getTable(FigureConstant.PLAY_TABLE) + " - Agent/Role relations in the " + getProjectName() + " project"); section.add(table); table.setComplete(true); } else { section.add(createParagraph("In the " + getProjectName() + " project there are no plays relationships taking place for the given agents/roles.")); } } section.setComplete(true); section.setTriggerNewPage(true); }