Example usage for com.itextpdf.text Section add

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

Introduction

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

Prototype

@Override
public boolean add(final Element element) 

Source Link

Document

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

Usage

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionInformationViewDiagram(Section section, Document document) {

    Image i = rsp.generateScrenshot(ViewsManager.RESOURCE_VIEW);
    float reductionScale = fitImageInArea(i,
            document.getPageSize().getWidth() - document.rightMargin() - document.leftMargin(), 310, false);
    if (reductionScale <= getMaximumReductionScale()) {
        setAppendixAInformationDiagram(true);
    }//w w w . j  a  v a  2  s .co  m

    StringBuilder sectionIntro = new StringBuilder();
    sectionIntro.append(ftc.getFigure(FigureConstant.INFORMATION_DIAGRAM)
            + " presents the graphical representation of the information view");
    if (needInformationDiagramInAppendixA()) {
        sectionIntro.append(" (a larger picture is shown in appendix A)");
    }
    sectionIntro.append(".");
    section.add(createParagraph(sectionIntro.toString()));

    section.add(decorateImage(i, ftc.getFigure(FigureConstant.INFORMATION_DIAGRAM)
            + " - Information View for the " + getProjectName() + " project"));
    section.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionModellingOwnership(Section section) {

    String sectionIntro = "The information view represents also who are the %iowners% of the information that is being manipulated through the documents that represent them in the social view.";
    section.add(createParagraph(sectionIntro));

    List<Actor> selActors = getModellingOwnershipActors();
    List<Actor> validActors = new ArrayList<Actor>();
    for (Actor a : selActors) {
        if (a.getIResources().size() > 0)
            validActors.add(a);//  w  ww . j a  va 2s .  com
    }
    if (validActors.size() > 0) {
        String s = "The owners for the different information in the " + getProjectName()
                + " project are summarised in " + ftc.getTable(FigureConstant.INF_OWN_TABLE) + ".";
        section.add(createParagraph(s));

        List<String[]> headers = new ArrayList<String[]>();//
        headers.add(new String[] { "Agent/Role" });
        headers.add(new String[] { "Information" });
        headers.add(new String[] { "Description" });
        PdfPTable table = createTable(headers);

        for (Actor a : validActors) {
            PdfPCell actorCell = getContentCell(a.getName());
            actorCell.setRowspan(a.getIResources().size());
            table.addCell(actorCell);
            for (Own o : a.getIResources()) {
                table.addCell(getContentCell(o.getTarget().getName()));
                table.addCell(getContentCell(o.getTarget().getDescription()));
            }

        }

        addTableCaption(table, ftc.getTable(FigureConstant.INF_OWN_TABLE) + " - Information owners");
        section.add(table);
        table.setComplete(true);
    } else {
        section.add(createParagraph("In the " + getProjectName()
                + " project there are no relations taking place for the given agents/roles."));
    }
    section.setComplete(true);
    // section.setTriggerNewPage(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionRepresentationInformation(Section section) {

    String sectionIntro = "Information is represented (%imade tangible by%) by documents, which stakeholders have and exchange.";
    section.add(createParagraph(sectionIntro));

    List<Actor> selActor = getRepresentationInformationActors();
    Set<IResource> validResource = new HashSet<IResource>();
    for (Actor a : selActor) {
        for (Own o : a.getIResources()) {
            if (o.getTarget().getTangibleElements().size() > 0)
                validResource.add(o.getTarget());
        }//from   w  ww.  j a va 2s.  com
    }
    if (validResource.size() > 0) {
        String s = "The documents stakeholders in the " + getProjectName() + " project" + infDiagRef()
                + " have and exchange with one another contain the information as summarised in "
                + ftc.getTable(FigureConstant.RAPPRES_INFORMA_TABLE) + ":";
        section.add(createParagraph(s));

        List<String[]> headers = new ArrayList<String[]>();
        headers.add(new String[] { "Information" });
        headers.add(new String[] { "Document" });
        headers.add(new String[] { "Description" });
        PdfPTable table = createTable(headers);

        for (IResource r : validResource) {
            List<TangibleBy> tbList = new ArrayList<TangibleBy>();
            for (TangibleBy tb : r.getTangibleElements()) {
                if (tb.getTarget() != null) {
                    tbList.add(tb);
                }
            }

            if (tbList.size() != 0) {
                PdfPCell infCell = getContentCell(r.getName());

                infCell.setRowspan(tbList.size());
                table.addCell(infCell);
                for (TangibleBy o : tbList) {
                    table.addCell(getContentCell(o.getTarget().getName()));
                    table.addCell(getContentCell(o.getDescription()));
                }
            }

        }

        addTableCaption(table, ftc.getTable(FigureConstant.RAPPRES_INFORMA_TABLE)
                + " - Representation of Information through Documents");
        section.add(table);
        table.setComplete(true);

    } else {
        section.add(createParagraph("In the " + getProjectName()
                + " project there are no \"Tangible By\" relations specified for the documents of the given agents/roles."));
    }
    section.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionComposition(Section section) {

    String sectionIntro = "Documents (information) are composed of other documents (information). Composition of documents (information) is captured through %i part of % relations.";
    section.add(createParagraph(sectionIntro));

    List<Actor> selActor = getCompositionActors();
    Set<Resource> validResource = new HashSet<Resource>();
    for (Actor a : selActor) {
        for (Own o : a.getIResources()) {
            if (o.getTarget().getSubParts().size() > 0)
                validResource.add(o.getTarget());
        }//w ww.ja v  a 2 s  .c  o  m
        for (TResource r : a.getTResources()) {
            if (r.getSubParts().size() > 0)
                validResource.add(r);
        }
    }

    if (validResource.size() > 0) {

        String s = ftc.getTable(FigureConstant.COMPOSITION_TABLE)
                + " summarises the documents and information in the " + getProjectName() + " project"
                + infDiagRef() + ", showing how they are composed and describing the composition.";
        section.add(createParagraph(s));

        List<String[]> headers = new ArrayList<String[]>();
        headers.add(new String[] { "Information", "/ Document" });
        headers.add(new String[] { "Composition" });
        headers.add(new String[] { "Description" });
        PdfPTable table = createTable(headers);

        for (Resource r : validResource) {
            List<PartOf> pofList = new ArrayList<PartOf>();
            for (PartOf p : r.getSubParts()) {
                if (p.getTarget() != null)
                    pofList.add(p);
            }
            if (pofList.size() > 0) {
                PdfPCell infCell = getContentCell(r.getName());
                infCell.setRowspan(pofList.size());
                table.addCell(infCell);
                for (PartOf p : pofList) {
                    table.addCell(getContentCell(p.getSource().getName()));
                    table.addCell(getContentCell(p.getDescription()));
                }
            }
        }

        addTableCaption(table,
                ftc.getTable(FigureConstant.COMPOSITION_TABLE) + " - Information and documents composition");
        section.add(table);
        table.setComplete(true);

    } else {
        section.add(createParagraph(
                "In the " + getProjectName() + " project there are no composite documents or information."));
    }
    section.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionAuthorisationDiagram(Section section, Document document) {

    Image i = rsp.generateScrenshot(ViewsManager.AUTHORIZATION_VIEW);
    float reductionScale = fitImageInArea(i,
            document.getPageSize().getWidth() - document.rightMargin() - document.leftMargin(), 310, false);
    if (reductionScale <= getMaximumReductionScale()) {
        setAppendixASocialDiagram(true);
    }/*from  w ww  .  j  a  va2s . c  o  m*/

    StringBuilder sectionIntro = new StringBuilder();
    sectionIntro.append(ftc.getFigure(FigureConstant.AUTH_DIAGRAM)
            + " presents the graphical representation of the Authorisation view");
    if (needAuthorisationDiagramInAppendixA()) {
        sectionIntro.append(" (a larger picture is rappresented in appendix A)");
    }
    sectionIntro.append(".");
    section.add(createParagraph(sectionIntro.toString()));

    section.add(decorateImage(i, ftc.getFigure(FigureConstant.AUTH_DIAGRAM) + " - Authorisation View for the "
            + getProjectName() + " project"));
    section.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionAuthorisationFlow(Section section) {

    String sectionIntro = "In this section are described for each role/agent, the authorisations it passes to others and what authorisations it receives from other roles/agents.";
    section.add(createParagraph(sectionIntro));

    List<Actor> selActor = getAuthorisationFlowActors();
    List<com.itextpdf.text.List> lists = new ArrayList<com.itextpdf.text.List>();

    for (Actor a : selActor) {
        StringBuilder sbOut = new StringBuilder();
        for (Authorisation au : a.getOutgoingAuthorisations()) {
            if (isValidAuth(au)) {
                if (sbOut.length() > 0)
                    sbOut.append(", and ");
                sbOut.append("authorises %i" + au.getTarget().getName() + "% to " + getOperations(au)
                        + " information ");
                List<String> resList = new ArrayList<String>();
                for (IResource r : au.getResources())
                    resList.add("%i" + r.getName() + "%");
                sbOut.append(separateListOfString(resList) + ", ");

                List<String> goalList = new ArrayList<String>();
                if (au.getGoals().size() > 0) {
                    sbOut.append("in the scope of goal");
                    if (au.getGoals().size() > 1)
                        sbOut.append("s");
                    // sbOut.append(" ");
                    for (Goal g : au.getGoals()) {
                        goalList.add("%i" + g.getName() + "%");
                    }/*from   w  ww.  j  a  va 2s.  co m*/
                    sbOut.append(" " + separateListOfString(goalList) + ", ");
                }
                if (au.getTimesTransferable() == 0) {
                    sbOut.append("%iwithout% passing");
                } else {
                    sbOut.append("%ipassing%");
                }
                sbOut.append(" the right to further authorising other actors");

                String[] res = new String[resList.size()];
                for (int i = 0; i < resList.size(); i++)
                    res[i] = resList.get(i);
                String[] goals = new String[goalList.size()];
                for (int i = 0; i < goalList.size(); i++)
                    goals[i] = goalList.get(i);
            }
        }

        StringBuilder sbInc = new StringBuilder();
        for (Authorisation au : a.getIncomingAuthorisations()) {
            if (isValidAuth(au)) {
                if (sbInc.length() > 0)
                    sbInc.append(", and ");
                sbInc.append("is authorised by %i" + au.getSource().getName() + "% to " + getOperations(au)
                        + " information ");

                List<String> resList = new ArrayList<String>();

                for (IResource r : au.getResources())
                    resList.add("%i" + r.getName() + "%");
                sbInc.append(separateListOfString(resList) + ", ");

                List<String> goalList = new ArrayList<String>();
                if (au.getGoals().size() > 0) {
                    sbInc.append("in the scope of goal");
                    if (au.getGoals().size() > 1)
                        sbOut.append("s");
                    // sbInc.append(" ");
                    for (Goal g : au.getGoals()) {
                        goalList.add("%i" + g.getName() + "%");
                    }
                    sbInc.append(" " + separateListOfString(goalList) + ", ");
                }
                if (au.getTimesTransferable() == 0) {
                    sbInc.append("%iwithout% having");
                } else {
                    sbInc.append("%ihaving%");
                }
                sbInc.append(" the right to further authorising other actors");

                String[] res = new String[resList.size()];
                for (int i = 0; i < resList.size(); i++)
                    res[i] = resList.get(i);
                String[] goals = new String[goalList.size()];
                for (int i = 0; i < goalList.size(); i++)
                    goals[i] = goalList.get(i);
            }
        }
        if (sbOut.length() > 0 || sbInc.length() > 0) {

            String type = "%iAgent% ";
            if (a instanceof Role)
                type = "%iRole% ";

            Paragraph actorName = createParagraph(type + "%b" + a.getName() + "%:");
            actorName.setSpacingAfter(5);

            com.itextpdf.text.List list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
            list.setListSymbol("\u2022" + " ");
            list.setSymbolIndent(10f);
            list.add(new ListItem(actorName));

            if (sbOut.length() > 0) {
                com.itextpdf.text.List sublist = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
                sublist.setListSymbol("- ");
                sublist.setSymbolIndent(30f);
                // Paragraph p=createParagraph("%b" + a.getName() + "% " +
                // sbOut.toString() + ".");
                Paragraph p = createParagraph(sbOut.toString() + ".");

                if (sbInc.length() > 0) {
                    p.setSpacingAfter(10);
                }

                sublist.add(new ListItem(p));
                list.add(sublist);
            }
            if (sbInc.length() > 0) {
                com.itextpdf.text.List sublist = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
                sublist.setListSymbol("- ");
                sublist.setSymbolIndent(30f);
                // Paragraph p=createParagraph("%b" + a.getName() + "% " +
                // sbInc.toString() + ".");
                Paragraph p = createParagraph(sbInc.toString() + ".");
                sublist.add(new ListItem(p));
                list.add(sublist);
            }

            lists.add(list);
        }
    }
    if (lists.size() > 0) {
        String s = "In the " + getProjectName() + " project" + autDiagRef()
                + " the authorisations for each role/agent are:";
        section.add(createParagraph(s));
        for (com.itextpdf.text.List list : lists) {
            section.add(list);
        }
    } else {
        section.add(createParagraph("In the " + getProjectName()
                + " project there are no authorisation taking place for the given agents/roles."));
    }
    section.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionConsistencyAnalysis(final Section section, Document document) {

    String sectionIntro = "The purpose of consistency analysis is to verify whether the diagram for the project "
            + getProjectName()/*from w w w .ja va  2s. c  om*/
            + " is consistent and valid. A diagram is considered to be consistent if its constituent elements (concepts and relationships) are drawn and interconnected following the semantics of the modelling language (STS-ml in our case). Thus, consistency analysis performs post checks to verify compliance with STS-ml semantics for all checks that cannot be performed live over the models.";
    Paragraph pIntro = createParagraph(sectionIntro);
    pIntro.setSpacingAfter(8);
    section.add(pIntro);

    if (generateAppendixBChapter()) {
        String appBref = "More details about the performed checks and their purpose can be found in Appendix B.";
        section.add(createParagraph(appBref));
    }

    ConsistencyAnalysisTasks t = new ConsistencyAnalysisTasks(1);
    DiagramAnalyser analyser = new DiagramAnalyser();

    analyser.addTaskGroup(t);

    AnalysisDescriptor ad = new AnalysisDescriptor("Consistency", FigureConstant.CONSISTENCY_RES_TABLE);
    analyser.addTaskListener(ad);
    analyser.evaluateCurrentDiagram();

    section.add(ad.getFinalParagraph());

    section.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionSecurityAnalysis(Section section) {
    String sectionIntro = "The purpose of security analysis is to verify whether the diagram for the project "
            + getProjectName()/*from   w w  w. j  a v  a  2s  .  c  o m*/
            + " allows the satisfaction of the specified security needs or not. As a result, for all security needs expressed by stakeholders, it checks in the model whether there is any possibility for the security need to be violated. This analysis takes into account the semantics of STS-ml, defining the behaviour of the different elements represented in the models. The elements behaviour is defined by propagation rules that consider what concepts and what relationships the specification of a given security need affects. Datalog is used to define the semantics of STS-ml to express facts (things always hold) and rules.";
    Paragraph pIntro = createParagraph(sectionIntro);
    pIntro.setSpacingAfter(8);
    section.add(pIntro);

    if (generateAppendixCChapter()) {
        String appBref = "You can find more details about the performed checks in Appendix C.";
        section.add(createParagraph(appBref));
    }

    ConsistencyAnalysisTasks t = new ConsistencyAnalysisTasks(1);
    DiagramAnalyser analyser = new DiagramAnalyser();
    analyser.addTaskGroup(t);
    boolean analysisRes = analyser.evaluateCurrentDiagram();
    if (analysisRes) {
        analyser.removeAllTaskGroups();
        analyser.addTaskGroup(new SecurityAnalysisTasks("", 1));
        AnalysisDescriptor ad = new AnalysisDescriptor("Security", FigureConstant.SECURITY_RES_TABLE);
        analyser.addTaskListener(ad);
        analyser.evaluateCurrentDiagram();
        section.add(ad.getFinalParagraph());
    } else {
        Paragraph p = createParagraph("%i" + "The security analysis for " + getProjectName()
                + " couldn't be performed because the consistency analysis has identified some errors that need to be fixed first."
                + "% ");
        p.setIndentationLeft(15);
    }
    section.setComplete(true);
}

From source file:eu.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildSectionRiskAnalysis(Section section) {
    String sectionIntro = "The purpose of the threat analysis is to present the impact of events in the overall model, when they threaten specific elements of the goal model such as goals and documents.";
    Paragraph pIntro = createParagraph(sectionIntro);
    pIntro.setSpacingAfter(8);/*from w  w  w.  ja v a  2s  . c  o  m*/
    section.add(pIntro);

    if (generateAppendixDChapter()) {
        String appBref = "More details for threat analysis are provided in Appendix D.";
        section.add(createParagraph(appBref));
    }

    RiskAnalysisTasks t = new RiskAnalysisTasks(1);
    DiagramAnalyser analyser = new DiagramAnalyser();

    analyser.addTaskGroup(t);

    AnalysisDescriptor ad = new AnalysisDescriptor("Threat", FigureConstant.RISK_RES_TABLE);
    analyser.addTaskListener(ad);
    analyser.evaluateCurrentDiagram();

    section.add(ad.getFinalParagraph());

    section.setComplete(true);
}

From source file:eu.trentorise.smartcampus.citizenportal.service.PdfCreator.java

private static void addContent(Document document) throws DocumentException {
    Anchor anchor = new Anchor("COMUNITA' DELLA VALLAGARINA", catFont);
    anchor.setName("COMUNITA' DELLA VALLAGARINA");
    // Second parameter is the number of the chapter
    Chapter catPart = new Chapter(new Paragraph(anchor), 1);
    catPart.setNumberDepth(0);/*from   www  . j  ava2  s.  c  o  m*/
    Paragraph subPara = new Paragraph("Graduatoria Generale", subFont);
    Section subCatPart = catPart.addSection(subPara);
    subCatPart.setNumberDepth(0);
    Anchor phaseClass = new Anchor("Fase: " + phase, smallBold);
    Anchor state = new Anchor("Stato: Confermata", smallBold);
    Anchor edFinPer = new Anchor("Edizione: " + edFin.getPeriod(), smallBold);
    Anchor edFinCat = new Anchor("Categoria: " + edFin.getCategory(), smallBold);
    Anchor edFinTool = new Anchor("Strumento: " + edFin.getTool(), smallBold);
    // subCatPart.add(new Paragraph("Graduatoria: Generale"));
    subCatPart.add(new Paragraph(phaseClass));
    subCatPart.add(new Paragraph(state));
    subCatPart.add(new Paragraph(edFinPer));
    subCatPart.add(new Paragraph(edFinCat));
    subCatPart.add(new Paragraph(edFinTool));
    // add a list
    // createList(subCatPart);
    Paragraph paragraph = new Paragraph();
    addEmptyLine(paragraph, 1);
    subCatPart.add(paragraph);
    // add a table
    createTable(subCatPart);
    // now add all this to the document
    document.add(catPart);
    // Next section
    // anchor = new Anchor("Second Chapter", catFont);
    // anchor.setName("Second Chapter");
    // Second parameter is the number of the chapter
    // catPart = new Chapter(new Paragraph(anchor), 1);
    // subPara = new Paragraph("Subcategory", subFont);
    // subCatPart = catPart.addSection(subPara);
    // subCatPart.add(new Paragraph("This is a very important message"));
    // now add all this to the document
    // document.add(catPart);
}