Example usage for com.itextpdf.text Paragraph setSpacingAfter

List of usage examples for com.itextpdf.text Paragraph setSpacingAfter

Introduction

In this page you can find the example usage for com.itextpdf.text Paragraph setSpacingAfter.

Prototype

public void setSpacingAfter(float spacing) 

Source Link

Usage

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

License:Open Source License

protected Paragraph getSectionTitleParagraph(String title) {

    Paragraph result = new Paragraph(title, SECTION);
    result.setSpacingAfter(15);
    result.setSpacingBefore(10);/*from w ww . j  a  v a  2  s  .c  om*/
    return result;
}

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

License:Open Source License

protected Paragraph listParagraphs(List<Paragraph> paragraphs) {

    Paragraph pList = getDefaultParagraph();
    com.itextpdf.text.List list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    list.setListSymbol("\u2022" + " ");
    list.setSymbolIndent(30f);//from w w w.ja va  2s .c o m
    pList.add(list);
    pList.setSpacingBefore(0f);
    pList.setSpacingAfter(0f);

    for (Paragraph p : paragraphs) {
        list.add(new ListItem(p));
    }
    return pList;
}

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

License:Open Source License

public Paragraph getIndexTitle() {

    Paragraph p = new Paragraph("Table of Contents", INDEX_TITLE);
    p.setSpacingAfter(10f);
    return p;/*from   ww  w .  j av a 2 s  .  c o m*/
}

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

License:Open Source License

private void buildFirstPage(PdfWriter writer, Document document) throws DocumentException {

    Paragraph firstPageTitleParagraph = new Paragraph(getDocumentTitle(), FIRST_PAGE_TITLE);
    firstPageTitleParagraph.setAlignment(Element.ALIGN_CENTER);
    firstPageTitleParagraph.setSpacingAfter(Utilities.millimetersToPoints(50));
    document.add(firstPageTitleParagraph);

    Paragraph firstPageProjectNameParagraph = new Paragraph(getProjectName(), FIRST_PAGE_PRJ_NAME);
    firstPageProjectNameParagraph.setAlignment(Element.ALIGN_CENTER);
    firstPageProjectNameParagraph.setSpacingAfter(Utilities.millimetersToPoints(20));
    document.add(firstPageProjectNameParagraph);

    Paragraph firstPageAuthorNameParagraph = new Paragraph(getReportAuthor(), FIRST_PAGE_AUTHOR);
    firstPageAuthorNameParagraph.setAlignment(Element.ALIGN_CENTER);
    firstPageAuthorNameParagraph.setSpacingAfter(Utilities.millimetersToPoints(20));
    document.add(firstPageAuthorNameParagraph);

    Paragraph firstPageOrganizationParagraph = new Paragraph(getReportIstitution(), FIRST_PAGE_ORGANIZ);
    firstPageOrganizationParagraph.setAlignment(Element.ALIGN_CENTER);
    firstPageOrganizationParagraph.setSpacingAfter(Utilities.millimetersToPoints(20));
    document.add(firstPageOrganizationParagraph);

    Paragraph firstPageDateParagraph = new Paragraph(getDate(), FIRST_PAGE_DATE);
    firstPageDateParagraph.setAlignment(Element.ALIGN_CENTER);
    firstPageDateParagraph.setSpacingAfter(Utilities.millimetersToPoints(40));
    document.add(firstPageDateParagraph);

    String[] phrases = { "This document has been generated by STS-Tool", "http://www.sts-tool.eu" };
    Paragraph firstPageLastLineParagraph = new Paragraph(phrases[0], FIRST_PAGE_LAST_LINE);
    for (int i = 1; i < phrases.length; i++) {
        firstPageLastLineParagraph.add(Chunk.NEWLINE);
        firstPageLastLineParagraph.add(new Phrase(phrases[i], FIRST_PAGE_LAST_LINE));
    }/*from   ww  w.j a va2s . co  m*/
    firstPageLastLineParagraph.setAlignment(Element.ALIGN_CENTER);
    document.add(firstPageLastLineParagraph);

    if (footerImage != null) {
        footerImage.setAbsolutePosition((PageSize.A4.getWidth() / 2) - (footerImage.getPlainWidth() / 2), 50);
        document.add(footerImage);
    }
}

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() + "%");
                    }// w  w  w.j  ava2  s  .  c om
                    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. j a  va  2  s .  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()/* w w w  . j  a v  a  2  s . 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);
    section.add(pIntro);// ww w . j  av a 2s .  c  om

    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.aniketos.wp1.ststool.report.pdfgenerator.ReportContentFactory.java

License:Open Source License

private void buildAppendixCChapter(Chapter c, Document d) {

    c.setTitle(getChapterTitleParagraph("Appendix C"));
    c.setNumberDepth(0);/*from  ww  w . j ava2  s.  c om*/
    c.setTriggerNewPage(true);

    String sectionIntro = "STS-ml allows for the specification of security needs over actors interactions. It currently supports a non-exhaustive set of security needs and organisational constraints, namely non-repudiation, redundancy, no-delegation, non-usage, non-modification, non-production, non-disclosure and need-to-know. The purpose of security analysis is to verify whether there are any violations of security needs. As such, it includes defining the rules necessary to detect violations. In the following are provided the details for all the checks performed during security analysis.";
    c.add(createParagraph(sectionIntro));

    List<Paragraph> plist = new ArrayList<Paragraph>();

    int kk = 0;

    for (kk = kk; kk < 4; kk++) {
        plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]));
    }
    c.add(listParagraphs(plist));
    plist.clear();

    Paragraph parList = getDefaultParagraph();
    com.itextpdf.text.List list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    list.setListSymbol("\u2022" + " ");
    list.setSymbolIndent(30f);
    parList.add(list);
    parList.setSpacingBefore(0f);
    parList.setSpacingAfter(0f);

    list.add(new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk++])));

    com.itextpdf.text.List subList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    subList.setListSymbol("\u2022" + " ");
    subList.setSymbolIndent(15f);

    for (kk = kk; kk < 10; kk++) {
        subList.add(
                new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])));
        // plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]));
    }

    list.add(subList);
    c.add(parList);

    /*
     * 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);
     */

    String text = "Apart from the verification of violations of security needs, security analysis performs checks to verify that actors comply with their authorities. For this, it searches for eventual unauthorised passages of rights. For the time being, the following violations are detected:";
    c.add(createParagraph(text));

    parList = getDefaultParagraph();
    list = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    list.setListSymbol("\u2022" + " ");
    list.setSymbolIndent(30f);
    parList.add(list);
    parList.setSpacingBefore(0f);
    parList.setSpacingAfter(0f);

    list.add(new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk++])));

    subList = new com.itextpdf.text.List(com.itextpdf.text.List.UNORDERED);
    subList.setListSymbol("\u2022" + " ");
    subList.setSymbolIndent(15f);

    for (kk = kk; kk < 16; kk++) {
        subList.add(
                new ListItem(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk])));
        // plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]));
    }

    list.add(subList);
    c.add(parList);

    text = "As far as organisational constraints are concerned, security analysis verifies that the specification of SoD and BoD constraints can be satisfied in the given model. The satisfaction of role-based SoD and BoD are already covered by the consistency analysis, security analysis deals with goal-based SoD and BoD instead.";
    c.add(createParagraph(text));

    for (kk = kk; kk < SecurityAnalysisTasksNames.ALL_TASKS_NAMES.length; kk++) {
        plist.add(getSecurityAnalysisDescription(SecurityAnalysisTasksNames.ALL_TASKS_NAMES[kk]));
    }
    c.add(listParagraphs(plist));

    c.setComplete(true);
}

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

License:Open Source License

private Paragraph createP(String s) {
    Paragraph p = createParagraph(s);
    p.setSpacingAfter(0);
    p.setSpacingBefore(0);
    return p;
}