Example usage for com.itextpdf.text BaseColor WHITE

List of usage examples for com.itextpdf.text BaseColor WHITE

Introduction

In this page you can find the example usage for com.itextpdf.text BaseColor WHITE.

Prototype

BaseColor WHITE

To view the source code for com.itextpdf.text BaseColor WHITE.

Click Source Link

Usage

From source file:Contabilidad.RCuentas.java

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:
    if (t_datos.getRowCount() > 0) {
        javax.swing.JFileChooser jF1 = new javax.swing.JFileChooser();
        jF1.setFileFilter(new ExtensionFileFilter("Excel document (*.pdf)", new String[] { "pdf" }));
        String ruta = null;//from  w  ww  .j av  a2  s  .  c  o m
        if (jF1.showSaveDialog(null) == jF1.APPROVE_OPTION) {
            ruta = jF1.getSelectedFile().getAbsolutePath();
            if (ruta != null) {
                Session session = HibernateUtil.getSessionFactory().openSession();
                try {
                    DecimalFormat formatoPorcentaje = new DecimalFormat("#,##0.00");
                    formatoPorcentaje.setMinimumFractionDigits(2);
                    session.beginTransaction().begin();
                    BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI,
                            BaseFont.NOT_EMBEDDED);
                    //Orden ord=buscaApertura();
                    PDF reporte = new PDF();
                    Date fecha = new Date();
                    DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyyHH-mm-ss");//YYYY-MM-DD HH:MM:SS
                    String valor = dateFormat.format(fecha);

                    reporte.Abrir2(PageSize.LETTER.rotate(), "Reporte Contabilidad", ruta + ".pdf");
                    Font font = new Font(Font.FontFamily.HELVETICA, 7, Font.NORMAL);
                    BaseColor contenido = BaseColor.WHITE;
                    int centro = Element.ALIGN_CENTER;
                    int izquierda = Element.ALIGN_LEFT;
                    int derecha = Element.ALIGN_RIGHT;
                    float[] nuevos = new float[] { 36, 75, 95, 250, 145, 36, 47, 65, 90, 70, 140 };

                    PdfPTable tabla = reporte.crearTabla(nuevos.length, nuevos, 100, Element.ALIGN_LEFT);

                    cabecera(reporte, bf, tabla, "Reporte de Cuentas por Cobrar", 1);
                    for (int ren = 0; ren < t_datos.getRowCount(); ren++) {
                        for (int col = 0; col < t_datos.getColumnCount(); col++) {
                            try {
                                if (col == 1) {
                                    String[] vec = t_datos.getValueAt(ren, col).toString().split("T");
                                    if (vec.length > 0)
                                        tabla.addCell(reporte.celda(vec[0], font, contenido, derecha, 0, 1,
                                                Rectangle.RECTANGLE));
                                    else
                                        tabla.addCell(reporte.celda("", font, contenido, derecha, 0, 1,
                                                Rectangle.RECTANGLE));
                                } else {
                                    if (col == 7)
                                        tabla.addCell(reporte.celda(
                                                formatoPorcentaje.format(t_datos.getValueAt(ren, col)), font,
                                                contenido, derecha, 0, 1, Rectangle.RECTANGLE));
                                    else
                                        tabla.addCell(reporte.celda(t_datos.getValueAt(ren, col).toString(),
                                                font, contenido, izquierda, 0, 1, Rectangle.RECTANGLE));
                                }
                            } catch (Exception e) {
                                tabla.addCell(reporte.celda("", font, contenido, izquierda, 0, 1,
                                        Rectangle.RECTANGLE));
                            }
                        }
                    }
                    tabla.setHeaderRows(1);
                    reporte.agregaObjeto(tabla);
                    reporte.cerrar();
                    reporte.visualizar2(ruta + ".pdf");
                } catch (Exception e) {
                    System.out.println(e);
                    e.printStackTrace();
                    JOptionPane.showMessageDialog(this,
                            "No se pudo realizar el reporte si el archivo esta abierto.");
                }
                if (session != null)
                    if (session.isOpen())
                        session.close();
            }
        }
    }
}

From source file:Contabilidad.RCuentas.java

public void cabecera(PDF reporte, BaseFont bf, PdfPTable tabla, String titulo1, int op) {
    Session session = HibernateUtil.getSessionFactory().openSession();
    try {//from   w  w  w. j  av  a2  s . c o m
        reporte.contenido.setLineWidth(0.5f);
        reporte.contenido.setColorStroke(new GrayColor(0.2f));
        reporte.contenido.setColorFill(new GrayColor(0.9f));

        Configuracion con = (Configuracion) session.get(Configuracion.class, 1);
        reporte.inicioTexto();
        reporte.contenido.setFontAndSize(bf, 14);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, con.getEmpresa(), 35, 570, 0);
        reporte.contenido.setFontAndSize(bf, 8);
        reporte.contenido.setColorFill(BaseColor.BLACK);
        String titulo = titulo1;
        if (op == 1) {
            if (t_fecha3.getText().compareTo("AAAA-MM-DD") != 0)
                titulo += " apartir del " + t_fecha3.getText();

            if (t_fecha4.getText().compareTo("AAAA-MM-DD") != 0)
                titulo += " al " + t_fecha4.getText();
        }
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_LEFT, titulo, 35, 560, 0);
        reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT,
                "Fecha:" + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss").format(new Date()), 750, 570, 0);
        if (op == 1) {
            if (valores != null) {
                String val = "Estatus: ";
                if (lista.getSelectedValues().length > 0) {
                    for (int m = 0; m < valores.length; m++) {
                        val += valores[m].toString() + ", ";
                    }
                    reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, val, 750, 560, 0);
                } else {
                    for (int mm = 0; mm < lista.getModel().getSize(); mm++) {
                        val += lista.getModel().getElementAt(mm).toString() + ", ";
                    }
                    reporte.contenido.showTextAligned(PdfContentByte.ALIGN_RIGHT, val, 750, 560, 0);
                }
            }
        }

        reporte.finTexto();
        //agregamos renglones vacios para dejar un espacio
        reporte.agregaObjeto(new Paragraph(" "));

        Font font = new Font(Font.FontFamily.HELVETICA, 6, Font.BOLD);

        BaseColor cabecera = BaseColor.GRAY;
        BaseColor contenido = BaseColor.WHITE;
        int centro = Element.ALIGN_CENTER;
        int izquierda = Element.ALIGN_LEFT;
        int derecha = Element.ALIGN_RIGHT;
        if (op == 1) {
            for (int a = 0; a < tabla.getNumberOfColumns(); a++) {
                tabla.addCell(reporte.celda(t_datos.getColumnName(a), font, cabecera, centro, 0, 1,
                        Rectangle.RECTANGLE));
            }
        }
    } catch (Exception e) {
        System.out.println(e);
    }
    if (session != null)
        if (session.isOpen())
            session.close();
}

From source file:Control.ProcessaArq.java

public void gravaArquivoConsumoUnidades(ArrayList<Usuario> listaUsuario, String caminho)
        throws IOException, DocumentException {

    Document doc = null;//from  www. j  a v a 2 s  .  c  o  m
    OutputStream os = null;
    PdfWriter pdf = null;
    Paragraph p = new Paragraph();
    Tratamento tempo = new Tratamento();
    PdfPTable table = new PdfPTable(5);
    DecimalFormat df = new DecimalFormat("#####.##");
    ArrayList<String> listaCidade = new ArrayList<String>();
    String local = new String();
    String informacao, tipo = new String();
    Double soma, valorTotal, diferenca = 0.0;
    Usuario unidade = new Usuario();
    ArrayList<Usuario> listaUnidades = new ArrayList<Usuario>();
    /*    
        if(banco.getConta().get(banco.getConta().size()-1).getDiferenca() > 0){
    diferenca = banco.getConta().get(banco.getConta().size()-1).getDiferenca()/9;
        }
        else{ diferenca = 0.0; }
    */
    for (int a = 0; a <= listaUsuario.size() - 1; a++) {
        if ((!listaCidade.contains(listaUsuario.get(a).getCidade()))) {
            listaCidade.add(listaUsuario.get(a).getCidade());
        }
    }

    float[] headerwidths = { 30, 80, 35, 35, 25 }; // define a largura de cada coluna       
    table.setWidths(headerwidths);

    caminho = localizaArquivo(false) + ".pdf";
    try {//configuraes da pgina          
        float fntSize, lineSpacing;
        fntSize = 8f;
        lineSpacing = 8f;

        doc = new Document(PageSize.A4.rotate(), 10, 10, 30, 40);
        os = new FileOutputStream(caminho);
        pdf.getInstance(doc, os);
        doc.open();

        /*
        local = new String();
        local = caminho +" "+ listaCidade.get(a) + ".pdf";
                
        doc = new Document(PageSize.A4.rotate(), 10, 10, 30, 40); 
        os = new FileOutputStream(local);            
        pdf.getInstance(doc, os);   
        doc.open();
        */
        //cabecalho da tabela
        table.getDefaultCell().setBorder(0);

        table.getDefaultCell().setBorder(0);
        table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.getDefaultCell().setColspan(5);

        table.addCell(new Paragraph("CONSUMO POR UNIDADE " + banco.periodoFatura()));

        table.getDefaultCell().setBorder(0);
        table.getDefaultCell().setColspan(0);
        table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        doc.add(table);

        for (int a = 0; a <= listaCidade.size() - 1; a++) {

            table = new PdfPTable(5);
            table.setWidths(headerwidths);
            table.getDefaultCell().setBorder(0);
            table.addCell(new Paragraph(""));
            table.addCell(new Paragraph(""));
            table.addCell(new Paragraph(""));
            table.addCell(new Paragraph(""));
            table.addCell(new Paragraph(""));
            table.getDefaultCell().setBorder(1);

            table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
            table.addCell(new Paragraph("Cidade"));
            table.addCell(new Paragraph("Usurio"));
            table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            table.addCell(new Paragraph("Nmero"));
            table.addCell(new Paragraph("Tipo"));
            table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            table.addCell(new Paragraph("Valor"));
            table.getDefaultCell().setBackgroundColor(BaseColor.WHITE);

            soma = 0.0;
            for (int b = 0; b <= listaUsuario.size() - 1; b++) {

                if (listaCidade.get(a).equals(listaUsuario.get(b).getCidade())) {

                    //cidade
                    informacao = new String();
                    informacao = listaUsuario.get(b).getCidade();
                    table.addCell(new Paragraph(informacao));

                    //Usurio
                    informacao = new String();
                    informacao = listaUsuario.get(b).getNome();
                    table.addCell(new Paragraph(informacao));

                    //Nmero
                    informacao = new String();
                    informacao = String.valueOf(listaUsuario.get(b).getLinha());
                    table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                    table.addCell(new Paragraph(informacao));

                    //Tipo
                    informacao = new String();
                    informacao = listaUsuario.get(b).getTipo();
                    table.addCell(new Paragraph(informacao));

                    //Valor
                    informacao = new String();
                    soma += listaUsuario.get(b).getValor();
                    informacao = "R$" + df.format(listaUsuario.get(b).getValor());
                    table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
                    table.addCell(new Paragraph(informacao));
                }
            }

            // Total
            table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
            informacao = new String();
            informacao = "Total apurado";
            table.addCell(informacao);

            // tempo                        
            table.addCell("");
            table.addCell("");
            table.addCell("");

            // valor
            informacao = new String();
            informacao = "R$" + df.format(soma);
            table.addCell(informacao);
            table.getDefaultCell().setBackgroundColor(BaseColor.WHITE);

            if ((soma - diferenca) > 0) {
                table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
                informacao = new String();
                informacao = "Total a pagar";
                table.addCell(informacao);

                // tempo                        
                table.addCell("");
                table.addCell("");
                table.addCell("");

                // valor
                informacao = new String();
                informacao = "R$" + df.format(soma - diferenca);
                table.addCell(informacao);
                table.getDefaultCell().setBackgroundColor(BaseColor.WHITE);
            }

            table.addCell("");
            table.addCell("");
            table.addCell("");
            table.addCell("");
            table.addCell("");

            unidade = new Usuario();
            unidade.setCidade(listaCidade.get(a));
            unidade.setValor(soma);
            listaUnidades.add(unidade);

            doc.add(table);
        }

        doc.newPage();
        table.getDefaultCell().setBorder(0);
        table.addCell(new Paragraph(""));
        table.addCell(new Paragraph(""));
        table.addCell(new Paragraph(""));
        table.addCell(new Paragraph(""));
        table.addCell(new Paragraph(""));
        table.getDefaultCell().setBorder(1);

        table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(new Paragraph("Cidade"));
        table.addCell(new Paragraph(""));
        table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(new Paragraph(""));
        table.addCell(new Paragraph(""));
        table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        table.addCell(new Paragraph("Valor"));
        table.getDefaultCell().setBackgroundColor(BaseColor.WHITE);

        soma = 0.0;
        for (int a = 0; a <= listaUnidades.size() - 1; a++) {
            //cidade
            informacao = new String();
            informacao = listaUnidades.get(a).getCidade();
            table.addCell(new Paragraph(informacao));

            table.addCell("");
            table.addCell("");
            table.addCell("");

            //Valor
            informacao = new String();
            soma += listaUnidades.get(a).getValor();
            informacao = "R$" + df.format(listaUnidades.get(a).getValor());
            table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            table.addCell(new Paragraph(informacao));
        }

        // Total
        table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
        informacao = new String();
        informacao = "Total apurado";
        table.addCell(informacao);

        // tempo                        
        table.addCell("");
        table.addCell("");
        table.addCell("");

        // valor
        informacao = new String();
        informacao = "R$" + df.format(soma);
        table.addCell(informacao);
        table.getDefaultCell().setBackgroundColor(BaseColor.WHITE);

        table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
        informacao = new String();
        informacao = "Total a pagar";
        table.addCell(informacao);

        // tempo                        
        table.addCell("");
        table.addCell("");
        table.addCell("");

        // valor
        informacao = new String();
        informacao = "R$" + df.format(soma);
        //    informacao = "R$"+ df.format(soma-banco.getConta().get(banco.getConta().size()-1).getDiferenca());
        table.addCell(informacao);
        table.getDefaultCell().setBackgroundColor(BaseColor.WHITE);

        doc.add(table);
        doc.close();
        os.close();

    } finally {
        if (doc != null) {
            //fechamento do documento
            doc.close();
        }
        if (os != null) {
            //fechamento da stream de sada
            os.close();
        }
    }
}

From source file:Control.ProcessaArq.java

public void gravaArquivoConsumoUsuarios(ArrayList<Usuario> lista, String caminho)
        throws IOException, DocumentException {

    Document doc = null;/*from  www.  ja v  a  2s .  c o m*/
    OutputStream os = null;
    Paragraph p = new Paragraph();
    Tratamento tempo = new Tratamento();
    DecimalFormat df = new DecimalFormat("#####.##");
    String informacao, tipo = new String();
    Double soma, valorTotal = 0.0;

    PdfPTable table = new PdfPTable(5); //tabela com 5 colunas
    float[] headerwidths = { 30, 80, 35, 35, 25 }; // define a largura de cada coluna  
    table.setWidths(headerwidths);

    caminho = localizaArquivo(false) + ".pdf";
    try {//configuraes da pgina          
        float fntSize, lineSpacing;
        fntSize = 8f;
        lineSpacing = 8f;
        doc = new Document(PageSize.A4.rotate(), 10, 10, 30, 40);

        os = new FileOutputStream(caminho);
        PdfWriter.getInstance(doc, os);
        doc.open();

        //cabecalho da tabela
        table.getDefaultCell().setBorder(0);
        table.getWidthPercentage();

        table.getDefaultCell().setBorder(0);
        table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.getDefaultCell().setColspan(5);

        table.addCell(new Paragraph("CONSUMO POR USU?RIOS ") + banco.periodoFatura());

        table.getDefaultCell().setBorder(1);
        table.getDefaultCell().setColspan(0);
        table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);

        table.addCell(new Paragraph(""));
        table.addCell(new Paragraph(""));
        table.addCell(new Paragraph(""));
        table.addCell(new Paragraph(""));
        table.addCell(new Paragraph(""));
        table.getDefaultCell().setBorder(1);

        table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(new Paragraph("Cidade"));
        table.addCell(new Paragraph("Usurio"));
        table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.addCell(new Paragraph("Nmero"));
        table.addCell(new Paragraph("Tipo"));
        table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
        table.addCell(new Paragraph("Valor"));
        table.getDefaultCell().setBackgroundColor(BaseColor.WHITE);

        soma = 0.0;
        for (int a = 0; a <= lista.size() - 1; a++) {

            //cidade
            informacao = new String();
            informacao = lista.get(a).getCidade();
            //    table.setTotalWidth(80);
            table.addCell(new Paragraph(informacao));

            //Usurio
            informacao = new String();
            informacao = lista.get(a).getNome();
            //    table.setTotalWidth(200);
            table.addCell(new Paragraph(informacao));

            //Nmero
            informacao = new String();
            informacao = String.valueOf(lista.get(a).getLinha());
            //    table.setTotalWidth(10);
            table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            table.addCell(new Paragraph(informacao));

            //Tipo
            informacao = new String();
            informacao = lista.get(a).getTipo();
            //    table.setTotalWidth(10);
            table.addCell(new Paragraph(informacao));

            //Valor
            informacao = new String();
            soma += lista.get(a).getValor();
            informacao = "R$" + df.format(lista.get(a).getValor());
            //    table.setTotalWidth(10);
            table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
            table.addCell(new Paragraph(informacao));
        }

        // Total
        table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
        informacao = new String();
        informacao = "Total";
        table.addCell(informacao);

        // tempo                               
        table.addCell("");
        table.addCell("");
        table.addCell("");

        // valor
        informacao = new String();
        informacao = "R$" + df.format(soma);
        table.addCell(informacao);
        table.getDefaultCell().setBackgroundColor(BaseColor.WHITE);

        doc.add(table);
        // fim da pgina
    } finally {
        if (doc != null) {
            //fechamento do documento
            doc.close();
        }
        if (os != null) {
            //fechamento da stream de sada
            os.close();
        }
    }
}

From source file:Control.ProcessaArq.java

public void gravaArquivoServicos(ArrayList<Conta> lista, String caminho) throws IOException, DocumentException {
    ArrayList<String> listaTipos;
    String local[];/* ww  w .j a v a 2s  . c om*/
    Document doc = null;
    OutputStream os = null;
    Paragraph p = new Paragraph();
    Tratamento tempo = new Tratamento();
    DecimalFormat df = new DecimalFormat("#####.##");
    String informacao, tempoServico, tempoSubTotal, tempoTotal, tipo = new String();
    Double soma, valorTotal = 0.0;

    PdfPTable table = new PdfPTable(3); //tabela com 3 colunas
    float[] headerwidths = { 85, 35, 25 }; // define a largura de cada coluna
    table.setWidths(headerwidths);

    caminho = localizaArquivo(false) + ".pdf";
    try {//configuraes da pgina          
        float fntSize, lineSpacing;
        fntSize = 10f;
        lineSpacing = 10f;
        doc = new Document(PageSize.A4.rotate(), 10, 10, 20, 10);

        os = new FileOutputStream(caminho);
        PdfWriter.getInstance(doc, os);
        doc.open();

        tempoTotal = "00:00:00";
        tempoServico = "00:00:00";
        tempoSubTotal = "00:00:00";
        listaTipos = new ArrayList<String>();

        //cabecalho da tabela
        table.getDefaultCell().setBorder(0);
        table.getWidthPercentage();

        table.getDefaultCell().setBorder(0);
        table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        table.getDefaultCell().setColspan(3);

        table.addCell(new Paragraph(tempo.verificaNomeServico(lista) + " " + banco.periodoFatura()));

        table.getDefaultCell().setBorder(1);
        table.getDefaultCell().setColspan(0);
        table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);

        for (int a = 0; a < lista.size() - 1; a++) {
            System.out.println(a + " - " + lista.get(a).getTipo());

            if (!listaTipos.contains(lista.get(a).getTipo())) {

                listaTipos.add(lista.get(a).getTipo());
                soma = 0.0;
                tipo = new String();
                informacao = new String();

                informacao = "" + listaTipos.get(listaTipos.size() - 1) + "";
                table.getDefaultCell().setBorder(1);
                table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                table.getDefaultCell().setColspan(3);
                table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);

                table.addCell(new Paragraph(informacao));

                table.getDefaultCell().setBorder(1);
                table.getDefaultCell().setColspan(0);
                table.getDefaultCell().setBackgroundColor(BaseColor.WHITE);
                table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);

                // contedo da tabela
                for (int b = 0; b <= lista.size() - 1; b++) {
                    if (lista.get(b).getTipo().equals(listaTipos.get(listaTipos.size() - 1))) {

                        soma += lista.get(b).getValor();
                        tempoServico = tempo.somaTempo(lista.get(b).getDuracao(), tempoServico);
                        tempoSubTotal = tempo.somaTempo(tempoServico, tempoSubTotal);
                        tempoTotal = tempo.somaTempo(tempoServico, tempoTotal);
                        tipo = listaTipos.get(listaTipos.size() - 1);

                        informacao = new String();
                        informacao = lista.get(b).getDescricaoServico();
                        table.setTotalWidth(80);
                        table.addCell(new Paragraph(informacao));

                        informacao = new String();
                        informacao = tempoServico + " (" + tempo.conversaoHoraMinuto(tempoServico) + ")";
                        table.setTotalWidth(30);
                        table.addCell(new Paragraph(informacao));

                        informacao = new String();
                        informacao = "R$" + df.format(lista.get(b).getValor());
                        table.setTotalWidth(20);
                        table.addCell(new Paragraph(informacao));

                        tempoServico = "00:00:00";
                        //    System.out.println(informacao);                                 
                    }
                }
                //rodap da tabela
                listaTipos.add(tipo);
                valorTotal += soma;

                // subtotal
                table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
                informacao = new String();
                informacao = "Sub Total:";
                table.addCell(informacao);

                // tempo
                informacao = new String();
                informacao = tempoSubTotal + " (" + tempo.conversaoHoraMinuto(tempoSubTotal) + ")";
                table.addCell(informacao);

                // valor
                informacao = new String();
                informacao = "R$" + df.format(soma);
                table.addCell(informacao);
                table.getDefaultCell().setBackgroundColor(BaseColor.WHITE);

                // espao entre tabelas

                table.getDefaultCell().setBorder(1);
                table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
                table.getDefaultCell().setColspan(3);
                table.addCell(new Paragraph("* * * * *"));
                table.getDefaultCell().setColspan(0);
                table.getDefaultCell().setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
                table.getDefaultCell().setBorder(0);

                tempoSubTotal = "00:00:00";
                //    System.out.println(informacao);   
            }
        }
        // fim da pgina

        // valor total
        informacao = new String();
        informacao = "Total Geral:  ";
        table.getDefaultCell().setBorder(1);
        table.getDefaultCell().setBackgroundColor(BaseColor.LIGHT_GRAY);
        table.addCell(informacao);
        table.getDefaultCell().setBorder(1);

        // tempo
        informacao = new String();
        informacao = tempoTotal + " (" + tempo.conversaoHoraMinuto(tempoTotal) + ")";
        table.addCell(informacao);

        //valor
        informacao = new String();
        informacao = "R$" + df.format(valorTotal);
        table.addCell(informacao);

        doc.add(table);
        //    System.out.println(informacao);

    } finally {
        if (doc != null) {
            //fechamento do documento
            doc.close();
        }
        if (os != null) {
            //fechamento da stream de sada
            os.close();
        }
    }
}

From source file:control.ReportHandler.java

public ReportHandler(EnrollmentRegister enR, PersonRegister peR, QuarantineRegister quR, UserRegister usR) {
    this.enR = enR;
    this.peR = peR;
    this.quR = quR;
    this.usR = usR;

    columnFont = FontFactory.getFont(FontFactory.HELVETICA, 12);
    columnFont.setColor(BaseColor.WHITE);
}

From source file:controller.PlanController.java

public Document PrintPressed(String Path) throws DocumentException, IOException {
    // step 1/* w  w w . j  ava2s .  c o m*/
    Document document = new Document();
    // step 2
    PdfWriter.getInstance(document, new FileOutputStream(Path));
    // step 3
    document.open();
    // step 4
    PdfPTable tablaDatosPlan = new PdfPTable(2);

    tablaDatosPlan.setWidthPercentage(100);

    if (!Team.getText().isEmpty()) {
        PdfPCell cell1 = new PdfPCell(new Phrase(messages.getString("Team") + ":" + Team.getText()));
        cell1.setBorderColor(BaseColor.WHITE);
        tablaDatosPlan.addCell(cell1);
    }
    if (!Season.getText().isEmpty()) {
        PdfPCell cell1 = new PdfPCell(new Phrase(messages.getString("Season") + ":" + Season.getText()));
        cell1.setBorderColor(BaseColor.WHITE);
        tablaDatosPlan.addCell(cell1);
    }
    if (!Date.getText().isEmpty()) {
        PdfPCell cell1 = new PdfPCell(new Phrase(messages.getString("Date") + ":" + Date.getText()));
        cell1.setBorderColor(BaseColor.WHITE);
        tablaDatosPlan.addCell(cell1);
    }
    if (!Players.getText().isEmpty()) {
        PdfPCell cell1 = new PdfPCell(new Phrase(messages.getString("Players") + ":" + Players.getText()));
        cell1.setBorderColor(BaseColor.WHITE);
        tablaDatosPlan.addCell(cell1);
    }
    if (!Start.getText().isEmpty()) {
        PdfPCell cell1 = new PdfPCell(new Phrase(messages.getString("Start") + ":" + Start.getText()));
        cell1.setBorderColor(BaseColor.WHITE);
        tablaDatosPlan.addCell(cell1);
    }
    if (!End.getText().isEmpty()) {
        PdfPCell cell1 = new PdfPCell(new Phrase(messages.getString("End") + ":" + End.getText()));
        cell1.setBorderColor(BaseColor.WHITE);
        tablaDatosPlan.addCell(cell1);
    }
    if (!Place.getText().isEmpty()) {
        PdfPCell cell1 = new PdfPCell(new Phrase(messages.getString("Place") + ":" + Place.getText()));
        cell1.setBorderColor(BaseColor.WHITE);
        tablaDatosPlan.addCell(cell1);
    }
    if (!Equipment.getText().isEmpty()) {
        PdfPCell cell1 = new PdfPCell(new Phrase(messages.getString("Equipment") + ":" + Equipment.getText()));
        cell1.setBorderColor(BaseColor.WHITE);
        tablaDatosPlan.addCell(cell1);
    }

    document.add(tablaDatosPlan);

    document.add(new Phrase("\n"));
    document.add(new Phrase("\n"));

    PdfPTable tablaEjercicios = new PdfPTable(4);
    tablaEjercicios.setHeaderRows(contadorlineas);
    tablaEjercicios.addCell(messages.getString("Start"));
    tablaEjercicios.addCell(messages.getString("End"));
    tablaEjercicios.addCell(messages.getString("Drill"));
    tablaEjercicios.addCell(messages.getString("Notes"));
    int cont = 0;
    for (int aw = 4; aw < contadorlineas + 4; aw++) {

        tablaEjercicios.addCell(starColumn.getCellData(cont));
        tablaEjercicios.addCell(endColumn.getCellData(cont));
        tablaEjercicios.addCell(drillColumn.getCellData(cont));
        tablaEjercicios.addCell(notesColumn.getCellData(cont));
        cont++;
    }

    document.add(tablaEjercicios);
    int contadorListado = 0, contadorRecorrer = 0;

    if (checkboxDrills.isSelected()) {

        while (contadorListado < planData.size()) {
            contadorRecorrer = 0;

            while (contadorRecorrer < playData.size()) {
                System.out.println("Busco el ejercicio " + drillColumn.getCellData(contadorListado));
                if (drillColumn.getCellData(contadorListado)
                        .contains(playData.get(contadorRecorrer).getNombreJugada())) {
                    int contador = 1;
                    System.out.println("Ejercicio encontrado");
                    document.add(new Paragraph(
                            messages.getString("Drill") + " " + drillColumn.getCellData(contadorListado)));
                    while (contador < playData.get(contadorRecorrer).getContadorJugada() + 1) {

                        document.add(new Paragraph(messages.getString("Diagram") + " " + contador));
                        document.add(new Paragraph(" "));

                        Image image2 = Image.getInstance(playData.get(contadorRecorrer).getNombreJugada() + "-"
                                + playData.get(contadorRecorrer).getTipoJugada() + "-"
                                + playData.get(contadorRecorrer).getSubtipoJugada() + "_" + contador);
                        image2.scalePercent(50);

                        PdfPTable table1 = new PdfPTable(2);

                        table1.addCell(image2);
                        table1.addCell(
                                textPdf.textPdf(contador, playData.get(contadorRecorrer).getDescripcionJugada(),
                                        playData.get(contadorRecorrer).getContadorJugada()));
                        document.add(table1);

                        contador++;

                    }

                }
                contadorRecorrer++;

            }
            contadorListado++;
        }

    }
    // step 5
    document.close();
    return document;

}

From source file:de.beimax.talenttree.PageGeneratorSignature.java

License:Open Source License

/**
 * draw a diamond shape/* www  .  jav  a 2 s .  c  om*/
 * @param x
 * @param y
 */
protected void drawDiamond(float x, float y) {
    float offset = -15.766f / 2 - PDFGenerator.talentPathStroke / 2;
    canvas.setColorFill(BaseColor.WHITE);

    // rhombus/diamond
    canvas.moveTo(x + 9.883f + offset, y - offset / 2);
    canvas.lineTo(x + 15.766f + offset, y - 5.883f - offset / 2);
    canvas.lineTo(x + 9.883f + offset, y - 11.765f - offset / 2);
    canvas.lineTo(x + 4 + offset, y - 5.883f - offset / 2);
    canvas.closePathFillStroke();
}

From source file:de.beimax.talenttree.PageGeneratorSimple.java

License:Open Source License

/**
 * Add single talent in box/*from   www. ja  v a2s . co m*/
 * @param row row to print talent in
 * @param col column to print talent in
 * @param key key for talent information
 * @param multiCols span multiple columns or 1
 * @param customCost custom cost of talent (instead of default) - 0 means box will not be printed
 */
protected void addTalent(int row, int col, String key, int multiCols, int customCost) throws Exception {
    // get data
    HeaderProperties headerProperties = parseHeaderProperty(key);

    // define color
    BaseColor bgColor = headerProperties.active ? PDFGenerator.activeColor : PDFGenerator.passiveColor;
    boolean headerTwoLine = headerProperties.title.contains("\n");

    // calculate offsets
    float x = calculateColOffset(col);
    float y = calculateRowOffset(row);

    // sanity check for multiple columns
    if (multiCols < 1)
        multiCols = 1;
    else if (multiCols > 4)
        multiCols = 4;

    // box width and height
    float talentBoxWidth = PDFGenerator.talentBoxWidth * multiCols
            + calculateHorizontalSpacing() * (multiCols - 1);
    float talentBoxHeight = PDFGenerator.talentBoxHeight;

    // draw shapes
    canvas.saveState();
    // draw outer rectangle
    drawTalentRectangle(bgColor, x, y, talentBoxWidth, talentBoxHeight);
    // draw left footer shape
    float yFooterBoxOffset = y - talentBoxHeight + PDFGenerator.talentBoxStroke;
    if (customCost != 0) {
        drawFooterShape(bgColor, x + PDFGenerator.wedgeOffset + PDFGenerator.talentBoxStroke,
                y - talentBoxHeight + PDFGenerator.talentBoxStroke, 25);
    }
    // draw right footer shape
    drawFooterShape(bgColor, x + talentBoxWidth - PDFGenerator.wedgeOffset - PDFGenerator.talentBoxStroke - 50,
            y - talentBoxHeight + PDFGenerator.talentBoxStroke, 50);
    // draw header shape
    drawHeaderShape(bgColor, x + PDFGenerator.talentBoxStroke * 2.5f, y - PDFGenerator.talentBoxStroke * 2.5f,
            talentBoxWidth - PDFGenerator.talentBoxStroke * 5, headerTwoLine, headerProperties.status);
    canvas.restoreState();

    // draw text
    canvas.beginText();
    canvas.setColorFill(BaseColor.WHITE);
    // title
    canvas.setFontAndSize(generator.getFontHeader(), 13);
    float offSetYTalentText;
    if (headerTwoLine) {
        String[] parts = headerProperties.title.split("\\n");
        canvas.showTextAligned(Element.ALIGN_LEFT, parts[0], x + PDFGenerator.talentBoxStroke * 3.5f,
                y - PDFGenerator.talentBoxStroke * 2 - 14f, 0);
        canvas.showTextAligned(Element.ALIGN_LEFT, parts[1], x + PDFGenerator.talentBoxStroke * 3.5f,
                y - PDFGenerator.talentBoxStroke * 2 - 27f, 0);
        offSetYTalentText = y - PDFGenerator.talentBoxStroke * 2 - 28f;
    } else {
        canvas.showTextAligned(Element.ALIGN_LEFT, headerProperties.title,
                x + PDFGenerator.talentBoxStroke * 3.5f, y - PDFGenerator.talentBoxStroke * 2 - 14f, 0);
        offSetYTalentText = y - PDFGenerator.talentBoxStroke * 2 - 15f;
    }
    // mini text
    canvas.setFontAndSize(generator.getFontBold(), 6.25f);
    float textOffsetY = yFooterBoxOffset + 8 - 6.25f / 2 + 0.5f;
    // draw page
    canvas.showTextAligned(Element.ALIGN_CENTER, headerProperties.page,
            x + PDFGenerator.wedgeOffset + PDFGenerator.talentBoxStroke + 25f / 2, textOffsetY, 0);
    // draw costs
    if (customCost != 0) {
        if (customCost == -1)
            customCost = (row + 1) * 5;
        canvas.showTextAligned(Element.ALIGN_LEFT, getLocalizedString("Cost") + " " + customCost,
                x + talentBoxWidth - PDFGenerator.talentBoxStroke - 50, textOffsetY, 0);
    }
    canvas.endText();

    // draw talent text
    canvas.setColorFill(BaseColor.BLACK);
    PdfPTable table = getTalentCell(key, talentBoxWidth, 9f);
    // too large?
    float max = y - talentBoxHeight;
    if (table.getRowHeight(0) > offSetYTalentText - max - 2 * PDFGenerator.wedgeOffset)
        table = getTalentCell(key, talentBoxWidth, 8.5f); // create smaller cell
    if (table.getRowHeight(0) > offSetYTalentText - max - 2 * PDFGenerator.wedgeOffset)
        table = getTalentCell(key, talentBoxWidth, 7.5f); // create tiny cell
    table.writeSelectedRows(0, -1, x + PDFGenerator.talentBoxStroke * 1.5f, offSetYTalentText, canvas);
}

From source file:de.beimax.talenttree.PageGeneratorSimple.java

License:Open Source License

/**
 * draw header shape for talent box/*from ww w .jav a  2 s  . c o m*/
 * @param color
 * @param x
 * @param y
 * @param width
 * @param headerTwoLine
 * @param status
 */
protected void drawHeaderShape(BaseColor color, float x, float y, float width, boolean headerTwoLine,
        char status) {
    // settings
    canvas.setColorFill(color);

    // draw shape
    canvas.moveTo(x, y);
    canvas.lineTo(x + width - PDFGenerator.wedgeOffset, y);
    canvas.lineTo(x + width, y - PDFGenerator.wedgeOffset);
    if (headerTwoLine) {
        canvas.lineTo(x + width - PDFGenerator.wedgeOffset * 2.5f, y - PDFGenerator.wedgeOffset * 3.5f);
        canvas.lineTo(x, y - PDFGenerator.wedgeOffset * 3.5f);
    } else {
        canvas.lineTo(x + width - PDFGenerator.wedgeOffset, y - PDFGenerator.wedgeOffset * 2);
        canvas.lineTo(x, y - PDFGenerator.wedgeOffset * 2);
    }
    canvas.fill();

    // draw shape to cross off when learned
    float shapeX = x + width - 2.2f;
    float shapeY = y - 2.2f;
    switch (status) {
    case 'R': // ranked
        drawRanked(BaseColor.WHITE, shapeX, shapeY);
        break;
    default:
        drawNormal(BaseColor.WHITE, shapeX, shapeY);
    }
}