Example usage for com.itextpdf.text Chunk NEWLINE

List of usage examples for com.itextpdf.text Chunk NEWLINE

Introduction

In this page you can find the example usage for com.itextpdf.text Chunk NEWLINE.

Prototype

Chunk NEWLINE

To view the source code for com.itextpdf.text Chunk NEWLINE.

Click Source Link

Document

This is a Chunk containing a newline.

Usage

From source file:dbms.Bills1Controller.java

@FXML
void OnMouseClick(ActionEvent event)
        throws ClassNotFoundException, SQLException, FileNotFoundException, DocumentException {
    int c = check(phone_no.getText());
    int c1 = phone_no.getText().length();
    String s1 = product_id.getText();
    String s3 = cb1.getSelectionModel().getSelectedItem();
    String s7 = cb2.getSelectionModel().getSelectedItem();
    int s8 = cb3.getSelectionModel().getSelectedItem();
    String s2 = cust_name.getText();
    String s4 = address.getText();
    String s6 = date.getValue().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
    String s5 = phone_no.getText();
    String s10 = total.getText();
    String s11 = cb4.getSelectionModel().getSelectedItem();
    String s12 = payment.getText();
    int to = Integer.parseInt(s10);

    if (c == 0 || c1 != 10 || total.getText().equals("") || cust_name.getText().equals("")
            || address.getText().equals("") || payment.getText().equals("")) {
        JOptionPane.showMessageDialog(null, "Something is wrong");
    } else {/*from w w w  .  ja va  2  s .c  o  m*/
        try {
            Class.forName("com.mysql.jdbc.Driver");
            java.sql.Connection con = DriverManager
                    .getConnection("jdbc:mysql://localhost/dbms?user=root&password=india123");
            String str1 = "insert into sold_item values(?,?,?,?,?,?,?,?,?,?)";
            //  System.out.println(str1);
            java.sql.PreparedStatement stmt1 = con.prepareStatement(str1);
            stmt1.setString(1, s1);
            stmt1.setString(2, s3);
            stmt1.setString(3, s7);
            stmt1.setInt(4, s8);
            stmt1.setString(5, s2);
            stmt1.setString(6, s4);
            stmt1.setString(7, s5);
            stmt1.setString(8, s6);
            stmt1.setInt(9, to);
            stmt1.setString(10, s11);
            //   ResultSet rs1 = stmt1.executeQuery();
            stmt1.executeUpdate();
            //   con.close();
            JOptionPane.showMessageDialog(null, "Bill Generated");

            String str6 = "select * from sold_item where billid= '" + s1 + "'";
            PreparedStatement stmt2 = con.prepareStatement(str6);
            ResultSet rs = stmt2.executeQuery(str6);
            Document my_bill = new Document();
            PdfWriter.getInstance(my_bill, new FileOutputStream(s1 + ".pdf"));
            my_bill.open();
            Font f1 = new Font(FontFamily.TIMES_ROMAN, 20.0f, Font.BOLD, BaseColor.BLACK);
            Paragraph p2 = new Paragraph("XYZ Electronics", f1);
            p2.setAlignment(Paragraph.ALIGN_CENTER);
            my_bill.add(p2);
            //my_bill.add(Chunk.NEWLINE);
            Paragraph p3 = new Paragraph("BILL", f1);
            p3.setAlignment(Paragraph.ALIGN_CENTER);
            my_bill.add(p3);
            my_bill.add(Chunk.NEWLINE);
            PdfPTable bill_table = new PdfPTable(2);
            PdfPCell table_cell;
            while (rs.next()) {
                bill_table.addCell("Bill ID");
                String dept_id = rs.getString(1);
                table_cell = new PdfPCell(new Phrase(dept_id));
                bill_table.addCell(table_cell);

                bill_table.addCell("Product Type");
                String dept_name = rs.getString(2);
                table_cell = new PdfPCell(new Phrase(dept_name));
                bill_table.addCell(table_cell);

                bill_table.addCell("Product name");
                String dept_pname = rs.getString(3);
                table_cell = new PdfPCell(new Phrase(dept_pname));
                bill_table.addCell(table_cell);

                bill_table.addCell("Quantity");
                int dept_quan = rs.getInt(4);
                table_cell = new PdfPCell(new Phrase("" + dept_quan));
                bill_table.addCell(table_cell);

                bill_table.addCell("Customer Name");
                String manager_id = rs.getString(5);
                table_cell = new PdfPCell(new Phrase(manager_id));
                bill_table.addCell(table_cell);

                bill_table.addCell("Address");
                String location_id = rs.getString(6);
                table_cell = new PdfPCell(new Phrase(location_id));
                bill_table.addCell(table_cell);

                bill_table.addCell("Phone Number");
                String s = rs.getString(7);
                table_cell = new PdfPCell(new Phrase(s));
                bill_table.addCell(table_cell);

                bill_table.addCell("DATE");
                String ss = rs.getString(8);
                table_cell = new PdfPCell(new Phrase(ss));
                bill_table.addCell(table_cell);

                bill_table.addCell("Total");
                int dept_total = rs.getInt(9);
                table_cell = new PdfPCell(new Phrase("Rs. " + dept_total));
                bill_table.addCell(table_cell);

            }
            my_bill.add(bill_table);
            my_bill.add(Chunk.NEWLINE);
            Font f2 = new Font(FontFamily.TIMES_ROMAN, 20.0f, Font.UNDERLINE, BaseColor.BLACK);
            Paragraph p4 = new Paragraph("Manager Signature", f1);
            p4.setAlignment(Paragraph.ALIGN_RIGHT);
            my_bill.add(p4);

            my_bill.close();
            String spl[] = s7.split("-");
            String strr = "select Quantity from " + s3 + " where Company = '" + spl[0] + "' and ProductName = '"
                    + spl[1] + "'";
            PreparedStatement stmt3 = con.prepareStatement(strr);
            ResultSet rs3 = stmt3.executeQuery();
            rs3.next();
            int f = rs3.getInt(1);
            f = f - s8;
            String strr1 = "Update " + s3 + " set Quantity = " + f + " where Company = '" + spl[0]
                    + "' and ProductName = '" + spl[1] + "' ";
            PreparedStatement stmt4 = con.prepareStatement(strr1);
            stmt4.executeUpdate();

            String strr2 = "insert into payment values(?,?)";
            PreparedStatement stmt5 = con.prepareStatement(strr2);
            stmt5.setString(1, product_id.getText());
            stmt5.setString(2, payment.getText());
            stmt5.executeUpdate();
            rs.close();
            stmt2.close();
            con.close();

            product_id.setText("");
            // prdct_name.setText("");
            cust_name.setText("");
            address.setText("");
            phone_no.setText("");
        } catch (DocumentException | HeadlessException | FileNotFoundException | ClassNotFoundException
                | SQLException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
    }

}

From source file:digilib.pdf.PDFTitlePage.java

License:Open Source License

/**
 * generate iText-PDF-Contents for the title page
 * /*from w w w  .  j  a  va2 s. c  o  m*/
 * @return
 */
public Element getPageContents() {
    Paragraph content = new Paragraph();
    content.setAlignment(Element.ALIGN_CENTER);

    // add vertical whitespace
    for (int i = 0; i < 8; i++) {
        content.add(Chunk.NEWLINE);
    }

    // add logo
    content.add(getLogo());
    content.add(Chunk.NEWLINE);
    content.add(Chunk.NEWLINE);

    // add title
    Anchor title = new Anchor(new Paragraph(getTitle(), FontFactory.getFont(FontFactory.HELVETICA, 16)));
    String burl = job_info.getImageJobInformation().getAsString("base.url");

    title.setReference(burl + "digilib.jsp?fn=" + job_info.getImageJobInformation().getAsString("fn"));
    content.add(title);
    content.add(Chunk.NEWLINE);

    // add author
    if (getDate() != " ")
        content.add(new Paragraph(getAuthor() + " (" + getDate() + ")",
                FontFactory.getFont(FontFactory.HELVETICA, 14)));
    else
        content.add(new Paragraph(getAuthor(), FontFactory.getFont(FontFactory.HELVETICA, 14)));

    content.add(Chunk.NEWLINE);

    // add page numbers
    content.add(new Paragraph(getPages(), FontFactory.getFont(FontFactory.HELVETICA, 12)));

    content.add(Chunk.NEWLINE);
    content.add(Chunk.NEWLINE);
    content.add(Chunk.NEWLINE);

    // add digilib version
    content.add(new Paragraph(getDigilibVersion(), FontFactory.getFont(FontFactory.HELVETICA, 10)));

    for (int i = 0; i < 8; i++) {
        content.add(Chunk.NEWLINE);
    }
    Anchor address = new Anchor(
            new Paragraph(burl + "digilib.jsp?fn=" + job_info.getImageJobInformation().getAsString("fn"),
                    FontFactory.getFont(FontFactory.COURIER, 9)));
    address.setReference(burl + "digilib.jsp?fn=" + job_info.getImageJobInformation().getAsString("fn"));

    content.add(address);

    return content;
}

From source file:direccion.GeneradorFormato.java

public static void main(String[] args) {

    try {/*from w  w w.j  av  a2 s  .  co m*/
        Document document = new Document(PageSize.LETTER, 50, 50, 85, 50);
        document.addAuthor("Direccin");
        document.addTitle("Reporte de algo");

        PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream("Reporte prueba.pdf"));
        writer.setInitialLeading(16);
        Rectangle rct = new Rectangle(80, 104, 500, 688);
        writer.setBoxSize("art", rct);
        GeneradorFormato event = new GeneradorFormato();
        writer.setPageEvent(event);

        document.open();
        Paragraph parrafo2 = new Paragraph(
                "De aqui en adelante el contenido, ya se pone en automatico el encabezado en cada pgina y el nmero",
                FontFactory.getFont(FontFactory.TIMES_ROMAN, 12, Font.NORMAL, BaseColor.RED));
        parrafo2.setAlignment(0);
        document.add(parrafo2);

        document.add(Chunk.NEWLINE);

        document.close();
    } catch (FileNotFoundException | DocumentException ex) {
        System.out.println(ex.getMessage());
    }
}

From source file:domain.Pdfmaker.java

public void makePdf() {
    Document doc = new Document();
    doc.setPageSize(PageSize.A4);//from www  .  j a v a 2  s  .  co m
    try {
        PdfWriter writer = PdfWriter.getInstance(doc, new FileOutputStream(test.getTitle() + ".pdf"));
        writer.setPdfVersion(PdfWriter.VERSION_1_7);
        doc.open();
        Font f = new Font(Font.FontFamily.TIMES_ROMAN, 15, Font.BOLD, new BaseColor(0, 0, 0));
        Paragraph title = new Paragraph("TEST TITLE", f);
        title.setAlignment(Element.ALIGN_CENTER);
        doc.addCreator("Arne De Bremme");
        //make table
        PdfPTable table = new PdfPTable(4);
        table.setTotalWidth(550f);
        table.setLockedWidth(true);
        table.setHeaderRows(1);

        Paragraph p = new Paragraph(test.getTitle());
        p.setAlignment(Element.ALIGN_CENTER);
        PdfPCell cell = new PdfPCell(p);
        cell.setGrayFill(0.7f);
        cell.setColspan(4);
        table.addCell(cell);
        table.addCell(test.getClassGroup().getGroupName());
        PdfPCell cell2 = new PdfPCell(new Paragraph(test.getDescription()));
        cell2.setColspan(2);
        cell2.setRowspan(2);
        table.addCell(cell2);
        PdfPCell cell3 = new PdfPCell(new Paragraph("DD " + test.getStartDate().getDay() + "/"
                + test.getStartDate().getMonth() + "/" + test.getStartDate().getYear()));
        cell3.setRowspan(2);
        table.addCell(cell3);
        table.addCell(new Paragraph("Test " + test.getTestId()));
        doc.add(table);
        doc.add(Chunk.NEWLINE);
        for (Exercise e : ex) {
            Paragraph par = new Paragraph();
            par.add("Vraag " + counter);
            par.add(Chunk.TABBING);
            par.add(Chunk.TABBING);
            par.add(Chunk.TABBING);
            par.add(Chunk.TABBING);
            par.add(e.getPunten() + "/");
            doc.add(par);
            doc.add(new Paragraph("Klimatogram " + e.getClimateChart().getLocation() + " " + e.getPunten()));
            Robot r = new Robot();
            Desktop.getDesktop().browse(new URI(
                    "http://climatechart.azurewebsites.net/ClimateChart/ShowExercises?selectedYear=1&continentId="
                            + e.getClimateChart().getCountry().getContinent().getId() + "&countryId="
                            + e.getClimateChart().getCountry().getContinent().getId() + "&climateId="
                            + e.getClimateChart().getId()));
            TimeUnit.SECONDS.sleep(6);
            BufferedImage bi = r.createScreenCapture(
                    new Rectangle(Toolkit.getDefaultToolkit().getScreenSize().width * 7 / 10,
                            Toolkit.getDefaultToolkit().getScreenSize().width * 8 / 14));
            File file = new File("screenCapture" + counter + ".jpg");
            ImageIO.write(bi, "jpg", file);
            Image img = Image.getInstance("screenCapture.jpg");
            img.scaleAbsolute(400, 300);
            doc.add(img);
            doc.add(Chunk.NEWLINE);
            doc.add(new Paragraph(e.getNaam()));
            doc.add(Chunk.NEXTPAGE);
            counter++;

        }

        doc.close();
        File filz = new File(test.getTitle() + ".pdf");
        Desktop.getDesktop().open(filz);
    } catch (Exception e) {

    }
}

From source file:ECS.create.java

create() {
    //geting the file path from Page.
    String dpath = Page.dpath;/*from  w ww.j  a v a2 s  . co  m*/
    try {
        //define program "information" as data
        information data = new information();

        //crate a PDF File
        Document cs = new Document();
        //locate where the PDF save.
        FileOutputStream local = new FileOutputStream(dpath);
        //New PDF location
        PdfWriter writer = PdfWriter.getInstance(cs, local);

        //Edit Propety of the PDF
        cs.addTitle("Title@CoverSheet");
        cs.addAuthor("Author@rensanning");
        cs.addSubject("Subject@iText sample");
        cs.addKeywords("Keywords@iText");
        cs.addCreator("Creator@iText");

        //Seting the Font of the text in the PDF
        Font title = new Font(Font.FontFamily.HELVETICA, 25, Font.BOLD);
        //Font stitle = new Font(Font.FontFamily.COURIER, 18,Font.ITALIC | Font.UNDERLINE);
        Font stitle = new Font(Font.FontFamily.TIMES_ROMAN, 18, Font.BOLD);
        Font usual = new Font(Font.FontFamily.TIMES_ROMAN, 18);

        // open the PDF File
        cs.open();

        PdfContentByte canvas = writer.getDirectContent();

        // insert the information in the PDF
        //group the information into paragrph
        Paragraph sinfo = new Paragraph();
        //using the data form the database which geting by program "information"
        sinfo.add(new Chunk("Name: " + data.fn + " " + data.ln, title));
        //cs.add(Chunk.NEWLINE);
        sinfo.add(new Chunk("               "));
        sinfo.add(new Chunk("SID: " + data.sid, title));
        sinfo.setLeading(40);
        //sinfo.add(Chunk.NEWLINE);
        cs.add(sinfo);

        Paragraph cinfo = new Paragraph();
        cinfo.add(new Chunk("Course: " + data.cid + "   " + data.cn, stitle));
        cinfo.setLeading(30);
        cinfo.add(Chunk.NEWLINE);
        cs.add(cinfo);

        Paragraph minfo = new Paragraph();
        minfo.add(new Chunk("Module: ", stitle));
        minfo.add(new Chunk(data.mid + " " + data.mn, usual));
        minfo.setLeading(30);
        minfo.add(Chunk.NEWLINE);
        cs.add(minfo);

        // insert the information in the PDF
        Paragraph cwinfo = new Paragraph();
        cwinfo.add(new Chunk("Coursework ID: ", stitle));
        cwinfo.add(new Chunk(data.cwid, usual));
        cwinfo.add(Chunk.NEWLINE);
        cwinfo.add(new Chunk("Coursework Tile: ", stitle));
        cwinfo.add(new Chunk(data.cwt, usual));
        cwinfo.add(Chunk.NEWLINE);
        cwinfo.add(new Chunk("Coursework Deadline is on ", stitle));
        cwinfo.add(new Chunk(data.cwed, usual));
        cwinfo.setLeading(30);
        cs.add(cwinfo);

        cs.add(new Paragraph("Rule: \n" + " I am the Boss", usual));

        //Phrase phrase1= new Phrase("This is sentence 1. ", title);
        //ColumnText.showTextAligned(canvas, Element.ALIGN_CENTER, phrase1, 30, 600, 0); 
        //cs.add(new Paragraph("Name: " + data.fn + " " + data.ln, title));
        //cs.add(new Chunk("SID: " + data.sid));

        //Close the PDF file
        cs.close();
    } catch (DocumentException | FileNotFoundException ex) {
        System.out.println(ex);
    }
}

From source file:eeebees.PDFGen.java

public static void main(String[] args) {

    try {//from w  ww.  j  a  va  2  s .c  o m

        OutputStream file = new FileOutputStream(new File("D:\\PDF_Java4s.pdf"));
        Document document = new Document();
        PdfWriter.getInstance(document, file);

        //Inserting Image in PDF
        //Image image = Image.getInstance ("src/pdf/java4s.png");
        //image.scaleAbsolute(120f, 60f);//image width,height    

        //Inserting Table in PDF
        PdfPTable table = new PdfPTable(3);

        PdfPCell cell = new PdfPCell(new Paragraph("Java4s.com"));

        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setPadding(10.0f);
        cell.setBackgroundColor(new BaseColor(140, 221, 8));

        table.addCell(cell);

        table.addCell("Name");
        table.addCell("Address");
        table.addCell("Country");
        table.addCell("Java4s");
        table.addCell("NC");
        table.addCell("United States");
        table.setSpacingBefore(30.0f); // Space Before table starts, like margin-top in CSS
        table.setSpacingAfter(30.0f); // Space After table starts, like margin-Bottom in CSS                                          

        //Inserting List in PDF
        List list = new List(true, 30);
        list.add(new ListItem("Java4s"));
        list.add(new ListItem("Php4s"));
        list.add(new ListItem("Some Thing..."));

        //Text formating in PDF
        Chunk chunk = new Chunk("Welecome To Java4s Programming Blog...");
        chunk.setUnderline(+1f, -2f);//1st co-ordinate is for line width,2nd is space between
        Chunk chunk1 = new Chunk("Php4s.com");
        chunk1.setUnderline(+4f, -8f);
        chunk1.setBackground(new BaseColor(17, 46, 193));

        //Now Insert Every Thing Into PDF Document
        document.open();//PDF document opened........                   

        //document.add(image);

        document.add(Chunk.NEWLINE); //Something like in HTML :-)

        document.add(new Paragraph("Dear Java4s.com"));
        document.add(new Paragraph("Document Generated On - " + new Date().toString()));

        document.add(table);

        document.add(chunk);
        document.add(chunk1);

        document.add(Chunk.NEWLINE); //Something like in HTML :-)                                

        document.newPage(); //Opened new page
        document.add(list); //In the new page we are going to add list

        document.close();

        file.close();

        System.out.println("Pdf created successfully..");

    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

License:Open Source License

protected PdfPCell getHeaderCell(String[] header) {

    Phrase p = new Phrase();
    p.setFont(TABLE_HEADER);/*from   w ww.ja v a 2  s .  c o  m*/
    for (String s : header) {
        p.add(new Chunk(s));
        p.add(Chunk.NEWLINE);
    }
    PdfPCell cell = new PdfPCell(p);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setBorder(Rectangle.BOTTOM | Rectangle.TOP);
    cell.setBorderWidthTop(1.5f);
    cell.setBorderWidthBottom(1.5f);
    cell.setPaddingBottom(7);
    cell.setPaddingTop(2);
    return cell;
}

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

License:Open Source License

protected PdfPCell getContentCell(String[] phrases, Font font) {

    PdfPCell cell = getContentCell();//ww w. j a v  a 2s .  c  om
    Phrase p = new Phrase(phrases[0], font);
    for (int i = 1; i < phrases.length; i++) {
        p.add(Chunk.NEWLINE);
        p.add(new Phrase(phrases[i], font));
    }
    cell.setPhrase(p);
    return cell;
}

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 av a 2s .  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 buildSectionGoalDelegations(Section section) {

    String sectionIntro = "Stakeholders interact with others to achieve some of their goals by means of goal delegations. Goal delegations are graphically represented as a relation that starts from a delegator actor to a delegatee actor (following the direction of the arrow), having a rounded corner rectangle representing the goal being delegated. Security needs are graphically specified as labels that appear below the delegated goal "
            + socialDiagRef() + ".";
    section.add(createParagraph(sectionIntro));

    List<Actor> selActor = getGoalDelegationsActors();
    List<Paragraph> phrases = new ArrayList<Paragraph>();

    for (Actor a : selActor) {

        for (Delegation d : a.getOutgoingDelegations()) {
            Paragraph par = createParagraph("%b" + a.getName() + "% delegates goal %i"
                    + d.getSourceGoal().getName() + "% to %b" + d.getTarget().getName() + "%.");
            List<String> secNeeds = buildDelegationSecNeedList(d);
            if (secNeeds.size() > 0) {
                par.add(new Phrase(" The following security needs apply to this delegation:"));
                par.add(Chunk.NEWLINE);
                par.add(new Phrase(separateListOfString(secNeeds) + "."));
            }/*from  ww w.j  a va2 s. co  m*/
            phrases.add(par);
        }

        /*
         * StringBuilder sbInc = new StringBuilder(); sbInc.append("%b" +
         * a.getName() + "% is delegated by ");
         * 
         * int incCount = 0; for (Delegation d : a.getIncomingDelegations())
         * { if (incCount > 0) sbInc.append(", and is delegated by ");
         * sbInc.append("%i" + d.getSource().getName() + "% goal %i" +
         * d.getSourceGoal().getName() + "%"); List<String> secNeed1 =
         * buildSecNeedString(d, false, 'i'); List<String> secNeed2 =
         * buildSecNeedString(d, true, 'i');
         * 
         * if (secNeed2.size() > 0) { switch (secNeed2.size()) { case 1:
         * sbInc.append(" and is required to comply with the " +
         * separateListOfString(secNeed2) + " security need"); break;
         * default: sbInc.append(" and is required to comply with the " +
         * separateListOfString(secNeed2) + " security needs"); break; } }
         * if (secNeed1.size() > 0) { switch (secNeed1.size()) { case 1:
         * sbInc.append(" and requires it to comply with the " +
         * separateListOfString(secNeed1) + " security need"); break;
         * default: sbInc.append(" and requires it to comply with the " +
         * separateListOfString(secNeed1) + " security needs"); break; }
         * 
         * } List<String> parmSecNeed = buildParamterizedSecNeedString(d,
         * 'i'); if (parmSecNeed.size() > 0) {
         * sbInc.append(" and is required for a level of " +
         * separateListOfString(parmSecNeed)); } if (secNeed1.size() == 0 &&
         * secNeed2.size() == 0 && parmSecNeed.size() == 0) {
         * sbInc.append(": no security need is speccified"); } incCount++; }
         * 
         * 
         * StringBuilder sbOut = new StringBuilder(); int outCount = 0; for
         * (Delegation d : a.getOutgoingDelegations()) { if (outCount > 0)
         * sbOut.append(", and delegates to "); sbOut.append("%i" +
         * d.getTarget().getName() + "% goal %i" +
         * d.getSourceGoal().getName() + "%"); List<String> secNeed1 =
         * buildSecNeedString(d, true, 'i'); List<String> secNeed2 =
         * buildSecNeedString(d, false, 'i');
         * 
         * if (secNeed1.size() > 0) { switch (secNeed1.size()) { case 1:
         * sbOut.append(" and requires it to comply with the " +
         * separateListOfString(secNeed1) + " security need"); break;
         * default: sbOut.append(" and requires it to comply with the " +
         * separateListOfString(secNeed1) + " security needs"); break; } }
         * if (secNeed2.size() > 0) { switch (secNeed2.size()) { case 1:
         * sbOut.append(" and is required to comply with the " +
         * separateListOfString(secNeed2) + " security need"); break;
         * default: sbOut.append(" and is required to comply with the " +
         * separateListOfString(secNeed2) + " security needs"); break; } }
         * List<String> parmSecNeed = buildParamterizedSecNeedString(d,
         * 'i'); if (parmSecNeed.size() > 0) {
         * sbOut.append(" and requires a level of " +
         * separateListOfString(parmSecNeed)); } if (secNeed1.size() == 0 &&
         * secNeed2.size() == 0 && parmSecNeed.size() == 0) {
         * sbOut.append(": no security need is speccified"); }
         * 
         * outCount++; }
         * 
         * StringBuilder sb = new StringBuilder(); if (incCount > 0) { if
         * (outCount > 0) { sb.append(sbInc.toString() +
         * " while it delegates to " + sbOut.toString() + "."); } else {
         * sb.append(sbInc.toString() + "."); } } else { if (outCount > 0) {
         * sb.append("%b" + a.getName() + "% delegates to " +
         * sbOut.toString() + "."); } } if (sb.length() > 0) {
         * phrases.add(createParagraph(sb.toString())); }
         */
    }

    if (phrases.size() != 0) {
        sectionIntro = "The following description enlists all the delegations from one role/agent to the others. When applicable, security needs expressed over the delegations are enumerated.";
        section.add(createParagraph(sectionIntro));

        String t = "In the " + getProjectName() + " project" + socialDiagRef()
                + ", we have the following goal delegations:";
        section.add(createParagraph(t));
        section.add(listParagraphs(phrases));

        section.add(createParagraph(ftc.getTable(FigureConstant.DELEGATION_TABLE)
                + " summarises %igoal delegations%, together with the eventual %isecurity needs%, and the possible %ipreconditions% and %ipostconditions%, which determine when the delegation can take place, and the expected outcome of the delegation, respectively."));

        List<String[]> headers = new ArrayList<String[]>();
        headers.add(new String[] { "Delegator" });
        headers.add(new String[] { "Goal" });
        headers.add(new String[] { "Delegatee" });
        headers.add(new String[] { "Security", "Needs" });
        headers.add(new String[] { "Delegation", "Description" });
        headers.add(new String[] { "Pre-", "conditions" });
        headers.add(new String[] { "Post-", "conditions" });

        PdfPTable table = createTable(headers);

        for (Actor a : selActor) {

            if (a.getOutgoingDelegations().size() > 0) {

                PdfPCell cell = getContentCell();
                cell.setPhrase(new Phrase(a.getName(), TABLE_CONTENT));
                cell.setRowspan(a.getOutgoingDelegations().size());
                table.addCell(cell);

                for (Delegation d : a.getOutgoingDelegations()) {
                    table.addCell(getContentCell(d.getSourceGoal().getName()));
                    table.addCell(getContentCell(d.getTarget().getName()));

                    List<String> sn = buildDelegationSecNeedList(d);

                    Phrase p = null;
                    for (int i = 0; i < sn.size(); i++) {
                        if (i == 0)
                            p = new Phrase(sn.get(i), TABLE_CONTENT_SMALL);
                        else {
                            p.add(Chunk.NEWLINE);
                            p.add(new Phrase(sn.get(i), TABLE_CONTENT_SMALL));
                        }
                    }

                    PdfPCell c = getContentCell();
                    c.addElement(p);
                    table.addCell(c);

                    table.addCell(getContentCell(d.getDescription()));
                    table.addCell(getContentCell(d.getPreConditions()));
                    table.addCell(getContentCell(d.getPostConditions()));
                }
            }
        }
        addTableCaption(table,
                ftc.getTable(FigureConstant.DELEGATION_TABLE) + " - Goal Delegations and Security Needs");
        section.add(table);
        table.setComplete(true);

    } else {
        section.add(createParagraph("In the " + getProjectName()
                + " project there are no goal delegations taking place for the given agents/roles."));
    }
    section.setComplete(true);
}