Example usage for com.itextpdf.text List size

List of usage examples for com.itextpdf.text List size

Introduction

In this page you can find the example usage for com.itextpdf.text List size.

Prototype

public int size() 

Source Link

Document

Gets the size of the list.

Usage

From source file:be.zenodotus.creatie.GeneratePDF.java

License:Open Source License

public String vakantieAfdruk(Context context, String name, int jaar) {
    this.context = context;
    PdfWriter w = null;/*from www.j  a v  a  2 s  .  c  om*/
    Document d = new Document(PageSize.A4.rotate(), 5, 5, 10, 10);
    d.setPageCount(3);
    String fileName = name;
    String file = name;
    GregorianCalendar datum = new GregorianCalendar();
    datum.set(GregorianCalendar.YEAR, jaar);

    String[] maanden = { "Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus",
            "September", "Oktober", "November", "December" };
    int[] dagen = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    VerlofDao dao = new VerlofDao(context);
    FeestdagDao feestdagDao = new FeestdagDao(context);
    WerkdagDao werkdagDao = new WerkdagDao(context);
    File folder = new File(context.getFilesDir(), "pdfs");
    folder.mkdirs();
    if (datum.isLeapYear(jaar)) {
        dagen[1] = 29;
    }
    File temp = null;
    temp = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
            "Jacqueline" + jaar + ".pdf");
    fileName = temp.toString();
    try {
        dao.open();
        ArrayList<Verlof> verloflijst = dao.getAlleVerlovenPerJaar(jaar);
        w = PdfWriter.getInstance(d, new FileOutputStream(temp));
        d.open();
        d.addAuthor("Jacqueline Vandenbroecke");
        d.addCreationDate();
        d.addCreator("Verlofplanner");
        d.addTitle("Vakantie " + jaar + " van Jacqueline Vandenbroecke");
        Font standaard = FontFactory.getFont(FontFactory.HELVETICA, 8);
        Font standaardBold = FontFactory.getFont(FontFactory.HELVETICA, 8, Font.BOLD);
        Paragraph gegeven = new Paragraph("Jacqueline Vandenbroecke Verlof " + jaar + "\n", standaardBold);
        gegeven.setAlignment(Paragraph.ALIGN_CENTER);
        d.add(gegeven);

        for (int paginas = 0; paginas < 2; paginas++) {
            int aantal = 0;
            if (paginas == 1) {
                d.newPage();
                aantal = 6;
            }
            PdfPTable table = new PdfPTable(6);
            for (int i = aantal; i < (aantal + 6); i++) {
                PdfPCell cell = new PdfPCell(new Paragraph(maanden[i], standaardBold));
                cell.setBorder(1);
                table.addCell(cell);
            }
            int dag = 1;
            int k = aantal;
            for (int i = aantal; i < (aantal + 6); i++) {
                for (int j = 0; j < 32; j++) {
                    if (k > ((aantal + 6) - 1)) {
                        k = aantal;
                        dag++;
                    }
                    if (dag > dagen[k]) {
                        PdfPCell cell = new PdfPCell(new Paragraph("", standaard));
                        table.addCell(cell);
                        k++;
                    } else {
                        SimpleDateFormat formatterDag = new SimpleDateFormat("dd");
                        SimpleDateFormat formatterWeek = new SimpleDateFormat("EEE");
                        datum.set(jaar, k, dag);
                        PdfPTable dagTabel = new PdfPTable(4);
                        PdfPCell cellDag = new PdfPCell(
                                new Paragraph(formatterDag.format(datum.getTime()), standaard));
                        PdfPCell cellWeek = new PdfPCell(
                                new Paragraph(formatterWeek.format(datum.getTime()), standaard));
                        ArrayList<Verlof> verlof = new ArrayList<Verlof>();
                        for (int z = 0; z < verloflijst.size(); z++) {
                            if (((verloflijst.get(z).getDag() + 1) == dag)
                                    && (verloflijst.get(z).getMaand() == k)) {
                                verlof.add(verloflijst.get(z));

                            }
                        }
                        feestdagDao.open();
                        Feestdag feestdag = feestdagDao.getFeestdag(jaar, datum.get(GregorianCalendar.MONTH),
                                datum.get(GregorianCalendar.DATE));
                        feestdagDao.close();
                        werkdagDao.open();
                        java.util.List<Werkdag> weekend = werkdagDao.getWeekend();
                        werkdagDao.close();
                        String Verlof = "";
                        String uur = "";
                        if (verlof.size() > 0) {
                            if (verlof.size() > 1) {
                                Verlof = verlof.get(0).getVerlofsoort() + "\n" + verlof.get(1).getVerlofsoort();
                                uur = verlof.get(0).getUrental() + "\n" + verlof.get(1).getUrental();
                            } else {
                                Verlof = verlof.get(0).getVerlofsoort();
                                uur = verlof.get(0).getUrental();
                            }

                        }
                        PdfPCell cellVerlof = new PdfPCell(new Paragraph(Verlof, standaard));
                        PdfPCell uren = new PdfPCell(new Paragraph(uur, standaard));
                        if (verlof.size() > 0) {
                            BaseColor kleur = new BaseColor(Color.GRAY);
                            cellVerlof.setBackgroundColor(kleur);
                            uren.setBackgroundColor(kleur);
                            cellDag.setBackgroundColor(kleur);
                            cellWeek.setBackgroundColor(kleur);
                        }
                        for (int z = 0; z < weekend.size(); z++) {
                            if ((formatterWeek.format(datum.getTime())).equals(weekend.get(z).getDag())) {
                                BaseColor kleur = new BaseColor(Color.LTGRAY);
                                cellVerlof.setBackgroundColor(kleur);
                                uren.setBackgroundColor(kleur);
                                cellDag.setBackgroundColor(kleur);
                                cellWeek.setBackgroundColor(kleur);
                            }
                        }
                        if (feestdag != null) {
                            BaseColor kleur = new BaseColor(Color.GREEN);
                            uren.setBackgroundColor(kleur);
                            cellVerlof.setBackgroundColor(kleur);
                            uren.setBackgroundColor(kleur);
                            cellDag.setBackgroundColor(kleur);
                            cellWeek.setBackgroundColor(kleur);
                        }
                        dagTabel.addCell(cellDag);
                        dagTabel.addCell(cellWeek);
                        dagTabel.addCell(cellVerlof);
                        dagTabel.addCell(uren);
                        table.addCell(dagTabel);
                        k++;
                    }
                }

            }
            d.add(table);
            dao.close();
        }
    } catch (Exception ex) {

        ex.printStackTrace();

    } finally {
        d.close();
        w.close();
    }
    return fileName;
}

From source file:es.baudlord.pcpartpicker.model.Build.java

License:Open Source License

public static Build generate(boolean allParts, int partsPerCategory, boolean randomParts) {
    Build build = new Build();
    Random random = new Random();
    for (Product.Category category : Product.Category.values())
        if (allParts || Category.isMandatory(category)) {
            List list = Database.getProductByCategory(category);
            if (partsPerCategory < 1)
                partsPerCategory = random.nextInt(list.size()) + 1;
            for (int i = 0; i < partsPerCategory; i++)
                if (!build.add(new Part(Database.getProductByCategory(category)
                        .get(randomParts ? 0 : random.nextInt(list.size())))))
                    i--;/* w  ww. j ava  2  s.c om*/
        }
    return build;
}

From source file:es.jscan.Pantallas.PantallaPrincipal.java

License:Apache License

public void importarDePdf(final File archivo) {
    final PantallaBarra pantbarra = new PantallaBarra(PantallaPrincipal.this, false);

    new Thread() {
        @Override//from ww w  .  j av  a2s . co m
        public void run() {
            org.apache.pdfbox.pdmodel.PDDocument documento = null;
            try {
                documento = org.apache.pdfbox.pdmodel.PDDocument.load(archivo);
            } catch (IOException ex) {
                Utilidades.escribeLog("Error -importarDePdf- al importar del archivo PDF "
                        + archivo.getAbsolutePath() + " - " + ex.getMessage());
                return;
            }
            int startpage = 1;
            int endpage = Integer.MAX_VALUE;
            List pages = documento.getDocumentCatalog().getAllPages();
            String titulo = pantbarra.getTitle();
            pantbarra.barra.setMinimum(startpage);
            pantbarra.barra.setMaximum(pages.size());
            pantbarra.barra.setValue(1);
            for (int i = startpage - 1; i < endpage && i < pages.size(); i++) {
                PDPage page = (PDPage) pages.get(i);
                java.awt.image.BufferedImage imagenpdf = null;
                try {
                    imagenpdf = page.convertToImage(BufferedImage.TYPE_BYTE_GRAY, 200);
                } catch (IOException ex) {
                    Utilidades.escribeLog("Error -importarDePdf- al convertir Imagen de PDF a Escala de Grises "
                            + " - " + ex.getMessage());
                }
                //  Utilidades.escribeLog("Numero bits por pixel :"+imagenpdf.getColorModel().getPixelSize());

                //   imagenpdf = pantutil.convertirAGris((java.awt.image.BufferedImage) imagenpdf);
                guardarImagen(imagenpdf, contimagen);
                cargarMiniaturas(contimagen);
                JScrollBar bar = panelVisorMini.getVerticalScrollBar();
                bar.setValue(bar.getMaximum());
                pantbarra.barra.setValue(i);
                pantbarra.setTitle(titulo + "     " + (i + 1) + " de " + pages.size());
                contimagen++;
                doLayout();
                if (pantbarra.PARAR) {

                    break;
                }
            }

            PDPage page = (PDPage) pages.get(pages.size() - 1);
            java.awt.image.BufferedImage imagenpdf = null;
            try {
                imagenpdf = page.convertToImage();
                imagenpdf = pantutil.convertirAGris((java.awt.image.BufferedImage) imagenpdf);
                documento.close();
            } catch (IOException ex) {
                Utilidades.escribeLog("Error -importarDePdf- al convertir Imagen de PDF a Escala de Grises "
                        + " - " + ex.getMessage());
            }
            JScrollBar bar = panelVisorMini.getVerticalScrollBar();
            if (pantbarra.PARAR) {
                pintarImagenPorIndice(0);
                ponerBordeBoton(0);
                bar.setValue(bar.getMinimum());
            } else {
                pintarImagen(imagenpdf);
                ponerBordeBoton(contimagen - 1);
                bar.setValue(bar.getMaximum());
            }
            pantbarra.dispose();
        }
    }.start();
    pantbarra.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    pantbarra.setVisible(false);
    pantbarra.setVisible(true);
}

From source file:org.tvd.thptty.management.report.Report.java

private PdfPTable createSubjectPointTable() throws BadElementException {
    int countCell = cellTitles.length;
    PdfPTable table = new PdfPTable(countCell);

    table.setWidthPercentage(100);//from   w  ww .  ja va2  s.co  m

    for (int i = 0; i < countCell; i++) {
        Phrase phrase = new Phrase(cellTitles[i], tahomaFont);
        PdfPCell cx = new PdfPCell(phrase);
        cx.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cx);
    }

    table.setHeaderRows(1);
    Phrase phrase = null;
    java.util.List<TYStudent> students = ActionUtil.getStudentsInClass(courses, tyClass.getClassId());
    for (int i = 0; i < students.size(); i++) {
        //index
        phrase = new Phrase(String.valueOf(i + 1), tahomaFont);
        table.addCell(phrase);

        //student full name
        TYStudent student = students.get(i);
        student.setFullName(student.getStudentFirstName() + " " + student.getStudentLastName());

        phrase = new Phrase(student.getFullName(), tahomaFont);
        table.addCell(phrase);

        //speak point
        float points[] = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(),
                tySubject.getSubjectId(), WebKeys.SPEAK_POINT, 1);
        String pointString = TYServiceUtil.floatsToPointString(points);

        phrase = new Phrase(pointString, smallBold);
        table.addCell(phrase);

        //15' point
        points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(),
                tySubject.getSubjectId(), WebKeys.WRITE_POINT, 1);
        pointString = TYServiceUtil.floatsToPointString(points);

        phrase = new Phrase(pointString, smallBold);
        table.addCell(phrase);

        //45' point
        points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(),
                tySubject.getSubjectId(), WebKeys.WRITE_POINT, 2);
        pointString = TYServiceUtil.floatsToPointString(points);

        phrase = new Phrase(pointString, smallBold);
        table.addCell(phrase);

        //90' point
        points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(),
                tySubject.getSubjectId(), WebKeys.WRITE_POINT, 3);
        pointString = TYServiceUtil.floatsToPointString(points);

        phrase = new Phrase(pointString, smallBold);
        table.addCell(phrase);

        //avg point
        TYStudentPoint studentPointSubject = TYServiceUtil.getStudentAVGPointBySubject(courses, semester,
                student.getStudentId(), tySubject.getSubjectId());
        float avgPointSubject = 0;
        if (studentPointSubject != null)
            avgPointSubject = TYServiceUtil.getCutFloat(studentPointSubject.getPoint(), 1);

        pointString = "" + avgPointSubject;

        phrase = new Phrase(pointString, smallBold);
        table.addCell(phrase);

    }

    float totalWidth = PageSize.A4.getWidth();

    float columnWidths[] = { (float) (0.05 * totalWidth), (float) (0.35 * totalWidth),
            (float) (0.1 * totalWidth), (float) (0.2 * totalWidth), (float) (0.1 * totalWidth),
            (float) (0.1 * totalWidth), (float) (0.1 * totalWidth) };
    try {
        table.setWidthPercentage(columnWidths, PageSize.A4);
    } catch (DocumentException e) {
        e.printStackTrace();
    }
    return table;

}

From source file:org.tvd.thptty.management.util.Report.java

private PdfPTable createTable(Section subCatPart) throws BadElementException {
    int countCell = cellTitles.length;
    PdfPTable table = new PdfPTable(countCell);

    for (int i = 0; i < countCell; i++) {
        PdfPCell cx = new PdfPCell(new Phrase(cellTitles[i]));
        cx.setHorizontalAlignment(Element.ALIGN_CENTER);
        table.addCell(cx);/*ww  w.jav a2 s .  c o m*/
    }

    table.setHeaderRows(1);

    java.util.List<TYStudent> students = ActionUtil.getStudentsInClass(courses, tyClass.getClassId());
    for (int i = 0; i < students.size(); i++) {
        TYStudent student = students.get(i);
        student.setFullName(student.getStudentFirstName() + " " + student.getStudentLastName());
        table.addCell(student.getFullName());

        System.out.println("\n" + student.getFullName() + "\n");

        float points[] = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(),
                tySubject.getSubjectId(), WebKeys.SPEAK_POINT, 1);
        String pointString = TYServiceUtil.floatsToPointString(points);
        table.addCell(pointString);

        points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(),
                tySubject.getSubjectId(), WebKeys.WRITE_POINT, 1);
        pointString = TYServiceUtil.floatsToPointString(points);
        table.addCell(pointString);

        points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(),
                tySubject.getSubjectId(), WebKeys.WRITE_POINT, 2);
        pointString = TYServiceUtil.floatsToPointString(points);
        table.addCell(pointString);

        points = TYServiceUtil.getPointStudentByPTPF(courses, semester, student.getStudentId(),
                tySubject.getSubjectId(), WebKeys.WRITE_POINT, 3);
        pointString = TYServiceUtil.floatsToPointString(points);
        table.addCell(pointString);

        java.util.List<TYStudentPoint> studentPointSubjects = TYServiceUtil.getStudentAVGPointBySubject(courses,
                semester, student.getStudentId(), tySubject.getSubjectId());
        float avgPointSubject = 0;
        if (studentPointSubjects.size() > 0)
            avgPointSubject = TYServiceUtil.getCutFloat(studentPointSubjects.get(0).getPoint(), 2);

        pointString = "" + avgPointSubject;
        table.addCell(pointString);

    }

    subCatPart.add(table);
    return table;

}

From source file:others.pdfWriter.java

public static void createTableExercicios(Document document, java.util.List<Exercicios> exercicios)
        throws BadElementException, DocumentException {
    PdfPTable table = new PdfPTable(3);

    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);

    PdfPCell c1 = new PdfPCell(new Phrase("Exercicio"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);/*  w  ww.j  a v a  2 s .co  m*/

    c1 = new PdfPCell(new Phrase("Descrio"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Musculo"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    table.setHeaderRows(1);
    if (exercicios.size() < 1) {
        table.addCell("Adicione Exercicios");
        table.addCell("Adicione Exercicios");
        table.addCell("Adicione Exercicios");
    }
    for (Exercicios exercicio : exercicios) {
        table.addCell(exercicio.getNome());
        table.addCell(exercicio.getDescricao());
        table.addCell(exercicio.getMusculo());
    }

    document.add(table);

}

From source file:others.pdfWriter.java

public static void createTableGeral(Document document, java.util.List<Aluno> alunos)
        throws BadElementException, DocumentException {
    PdfPTable table = new PdfPTable(3);

    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);

    PdfPCell c1 = new PdfPCell(new Phrase("Aluno"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);//from   w  ww  . j a v  a2 s  . c o m

    c1 = new PdfPCell(new Phrase("Email Aluno"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    c1 = new PdfPCell(new Phrase("Professor"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);
    table.setHeaderRows(1);
    if (alunos.size() < 1) {
        table.addCell("Nada consta");
        table.addCell("Nada consta");
        table.addCell("Nada consta");
    }
    for (Aluno aluno : alunos) {
        table.addCell(aluno.getNome());
        table.addCell(aluno.getEmail());
        if (aluno.getInstrutor() != null) {
            table.addCell(aluno.getInstrutor().getNome());
        } else {
            table.addCell("Aguarda aceitao");
        }
    }

    document.add(table);

}

From source file:others.pdfWriter.java

public static void createTableAlunos(Document document, java.util.List<Aluno> alunos)
        throws BadElementException, DocumentException {
    PdfPTable table = new PdfPTable(2);

    // t.setBorderColor(BaseColor.GRAY);
    // t.setPadding(4);
    // t.setSpacing(4);
    // t.setBorderWidth(1);

    PdfPCell c1 = new PdfPCell(new Phrase("Aluno"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);/* w ww.j  a  v a  2s.c om*/

    c1 = new PdfPCell(new Phrase("Email"));
    c1.setHorizontalAlignment(Element.ALIGN_CENTER);
    table.addCell(c1);

    table.setHeaderRows(1);
    if (alunos.size() < 1) {
        table.addCell("Adicione Alunos");
        table.addCell("Adicione Alunos");
    }
    for (Aluno aluno : alunos) {
        table.addCell(aluno.getNome());
        table.addCell(aluno.getEmail());
    }

    document.add(table);

}