Example usage for com.lowagie.text Cell Cell

List of usage examples for com.lowagie.text Cell Cell

Introduction

In this page you can find the example usage for com.lowagie.text Cell Cell.

Prototype

public Cell(Element element) throws BadElementException 

Source Link

Document

Constructs a Cell with a certain Element.

if the element is a ListItem, Row or Cell, an exception will be thrown.

Usage

From source file:s2s.luna.reports.Report_REP_VAL_RSO_DVR.java

License:GNU General Public License

@Override
public void doReport() throws DocumentException, IOException, BadElementException, Exception {
    SecurityWrapper Security = SecurityWrapper.getInstance();
    IAziendaHome home = (IAziendaHome) PseudoContext.lookup("AziendaBean");
    IAzienda bean = home.findByPrimaryKey(new Long(lCOD_AZL));

    initDocument("the doc", null,
            ApplicationConfigurator.LanguageManager.getString("Tabella.valutazione.rischio"),
            bean.getRAG_SCL_AZL(), null);

    writeIndent();/*from w  w w .  j a va2  s .  co  m*/
    {
        ZREPORT_SETTINGS repSetting = new ZREPORT_SETTINGS();
        int tableFontSize = 10;
        int numberOfColumns = 4;
        short sMOD_CLC_RSO = Security.getAziendaModalitaCalcoloRischio();
        numberOfColumns = (sMOD_CLC_RSO == Azienda_MOD_CLC_RSO.MOD_EXTENDED) ? numberOfColumns + 2
                : numberOfColumns;

        // Intestazione generale
        CenterMiddleTable tblTopHeader = new CenterMiddleTable(1);
        tblTopHeader.toCenter();
        tblTopHeader.addHeaderCellB(
                ApplicationConfigurator.LanguageManager.getString("Tabella.valutazione.rischio"));
        m_document.add(tblTopHeader);

        writeLine();

        // Intestazione di dettaglio
        CenterMiddleTable tblData = new CenterMiddleTable(numberOfColumns);
        if (sMOD_CLC_RSO == Azienda_MOD_CLC_RSO.MOD_BASE) {
            int width[] = { 55, 15, 15, 15 };
            tblData.setWidths(width);
        } else if (sMOD_CLC_RSO == Azienda_MOD_CLC_RSO.MOD_EXTENDED) {
            int width[] = { 40, 12, 12, 12, 12, 12 };
            tblData.setWidths(width);
        }
        tblData.toCenter();
        tblData.toMiddle();

        tblData.addHeaderCellB(ApplicationConfigurator.LanguageManager.getString("Rischio"), 1, true, 12);
        tblData.addHeaderCellFirstBold(
                ApplicationConfigurator.LanguageManager.getString("P") + "\n"
                        + StringManager
                                .bracket(ApplicationConfigurator.LanguageManager.getString("Probabilit")),
                1, true, 12, 10);
        tblData.addHeaderCellFirstBold(
                ApplicationConfigurator.LanguageManager.getString("D") + "\n"
                        + StringManager
                                .bracket(ApplicationConfigurator.LanguageManager.getString("Entit.del.danno")),
                1, true, 12, 10);
        if (sMOD_CLC_RSO == Azienda_MOD_CLC_RSO.MOD_EXTENDED) {
            tblData.addHeaderCellFirstBold(ApplicationConfigurator.LanguageManager.getString("F") + "\n"
                    + StringManager.bracket(ApplicationConfigurator.LanguageManager
                            .getString("Frequenza.dell'attivit.a.rischio")),
                    1, true, 12, 10);
            tblData.addHeaderCellFirstBold(
                    ApplicationConfigurator.LanguageManager.getString("N") + "\n"
                            + StringManager.bracket(ApplicationConfigurator.LanguageManager
                                    .getString("Numero.di.incidenti/infortuni.(negli.ultimi.3.anni)")),
                    1, true, 12, 10);
        }
        tblData.addHeaderCellFirstBold(
                ApplicationConfigurator.LanguageManager.getString("R") + "\n" + StringManager.bracket(
                        ApplicationConfigurator.LanguageManager.getString("Stima.numerica.del.rischio")),
                1, true, 12, 10);

        // Dati
        IRischioHome home_rso = (IRischioHome) PseudoContext.lookup("RischioBean");
        Collection<Rischio_Nome_Fattore_View> listaRischi = home_rso.findEx(lCOD_AZL, null, null, null, null,
                null, null, null, null, null, null, null, null, 0);
        for (Rischio_Nome_Fattore_View rischio : listaRischi) {
            Cell rischioCell = new Cell(new Phrase(rischio.strNOM_RSO, repSetting.ftText10));
            rischioCell.setHorizontalAlignment(Element.ALIGN_LEFT);
            tblData.addCell(rischioCell);
            tblData.addCell(Long.toString(rischio.PRB_EVE_LES), tableFontSize);
            tblData.addCell(Long.toString(rischio.ENT_DAN), tableFontSize);
            if (sMOD_CLC_RSO == Azienda_MOD_CLC_RSO.MOD_EXTENDED) {
                tblData.addCell(Long.toString(rischio.FRQ_RIP_ATT_DAN), tableFontSize);
                tblData.addCell(Long.toString(rischio.NUM_INC_INF), tableFontSize);
            }
            tblData.addCellB(Long.toString(rischio.STM_NUM_RSO), tableFontSize, 1);
        }
        m_document.add(tblData);
    }
    closeDocument();
}

From source file:s2s.luna.reports.Stampa_documento.java

License:GNU General Public License

public boolean StampaAllegato(long lCOD_DOC, Stampa_documento.TIPO_ALLEGATO tipoAllegato, Document document,
        PdfWriter writer) throws Exception {
    AnagDocumentoFileInfo fileInfo = null;
    IAnagrDocumentoHome doc_home = (IAnagrDocumentoHome) PseudoContext.lookup("AnagrDocumentoBean");
    String Titolo = null;//from   w  ww . ja  v a  2 s .  c  o  m
    // Estraggo le informazioni sull'allegato.
    switch (tipoAllegato) {
    case FILE:
        fileInfo = doc_home.getFileInfoU("", lCOD_DOC);
        Titolo = ApplicationConfigurator.LanguageManager.getString("Allegato.1.File");
        break;
    case FILE_LINK:
        fileInfo = doc_home.getFileInfoULink("", lCOD_DOC);
        Titolo = ApplicationConfigurator.LanguageManager.getString("Allegato.2.File.link");
        break;
    }
    // Se ottengo delle informazioni valide...
    if (fileInfo != null && fileInfo.strContentType != null && fileInfo.strContentType.equals("") == false) {
        // Verifico che l'allegato sia in uno dei formati supportati.
        Stampa_documento.FORMATI_SUPPORTATI formatoFile = checkSupportedFormat(fileInfo.strContentType);
        // Se il formato  supportato...
        if (formatoFile != null) {
            byte[] fileContent = null;
            // Carico l'allegato sotto forma di array di byte.
            switch (tipoAllegato) {
            case FILE:
                fileContent = doc_home.downloadFileU("", lCOD_DOC);
                break;
            case FILE_LINK:
                fileContent = doc_home.downloadFileULink("", lCOD_DOC);
                break;
            }
            // Se il contenuto del file  valido...
            if (fileContent != null && fileContent.length > 0) {
                // Avvio la relativa operazione di import dell'allegato nel Sopralluogo.
                switch (formatoFile) {
                // Formati immagine
                case BMP:
                case GIF:
                case JPEG:
                case JPG:
                case PNG:
                case TIFF:
                case TIF:
                case WMF:
                    Element Allegato = prepareImage(document, fileContent);

                    // Se sono riuscito a costruire correttamente l'allegato...
                    if (Allegato != null) {
                        // lo includo nel Sopralluogo.
                        CenterMiddleTable tbl = new CenterMiddleTable(1);
                        int width[] = { 100 };
                        tbl.setWidths(width);
                        tbl.toLeft();
                        tbl.setDefaultCellBorder(Rectangle.NO_BORDER);
                        tbl.addCell(new Cell(Allegato));
                        document.add(tbl);
                        return true;
                    }
                    break;
                // Altri formati
                case PDF:
                    if (addPDF(Titolo, fileContent, document, writer)) {
                        return true;
                    }
                    break;
                }
            } else {
                CenterMiddleTable tbl = new CenterMiddleTable(1);
                int width[] = { 100 };
                tbl.setWidths(width);
                tbl.toLeft();
                tbl.setDefaultCellBorder(Rectangle.NO_BORDER);
                tbl.addCell(ApplicationConfigurator.LanguageManager.getString("File.not.found") + " \""
                        + fileInfo.strLinkDocument + fileInfo.strName + "\"");
                document.add(tbl);
            }
        }
    }
    return false;
}

From source file:s2s.report.MiddleTable.java

License:GNU General Public License

public void addHeaderCell(String strCaption, int iColspan) throws BadElementException {
    Cell cl = new Cell(new Phrase(strCaption == null ? "" : strCaption, REPORT_SETTINGS.ftTableHeader));
    cl.setBackgroundColor(REPORT_SETTINGS.clTableHeader);
    cl.setColspan(iColspan);// w  w w . j a v a 2s  .  c o m
    this.addCell(cl);
}

From source file:s2s.report.MiddleTable.java

License:GNU General Public License

public void addHeaderCellMagenta(String strCaption, int iColspan) throws BadElementException {
    Cell cl = new Cell(new Phrase(strCaption == null ? "" : strCaption, REPORT_SETTINGS.ftTableHeader));
    cl.setBackgroundColor(REPORT_SETTINGS.magenta);
    cl.setColspan(iColspan);//w  w  w.ja v  a  2 s  .  c o  m
    this.addCell(cl);
}

From source file:s2s.report.MiddleTable.java

License:GNU General Public License

public void addHeaderCellB(String strCaption, int iColspan, boolean bColor, int iSize)
        throws BadElementException {
    Cell cell = null;/*  w ww.  ja  v a  2 s  . c  om*/
    switch (iSize) {
    case 8:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeader8B));
        break;
    case 9:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeader9B));
        break;
    case 10:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeader10B));
        break;
    case 12:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeader12B));
        break;
    case 16:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeader16B));
        break;
    default:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeaderB));
        break;
    }
    if (bColor) {
        cell.setBackgroundColor(REPORT_SETTINGS.clTableHeader);
    }
    cell.setColspan(iColspan);
    this.addCell(cell);
}

From source file:s2s.report.MiddleTable.java

License:GNU General Public License

public void addHeaderCellB2(String strCaption, int iColspan, boolean bColor, int iSize)
        throws BadElementException {
    Cell cell = null;//from www  .  j  ava2s  .c  om
    switch (iSize) {
    case 8:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeader8B));
        break;
    case 9:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeader9B));
        break;
    case 10:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeader10B));
        break;
    case 11:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeader11B));
        break;
    case 12:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeader12B));
        break;
    default:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftTableHeaderB));
        break;
    }

    cell.setColspan(iColspan);
    this.addCell(cell);
}

From source file:s2s.report.MiddleTable.java

License:GNU General Public License

public void addHeaderCellFirstBold(String strCaption, int iColspan, boolean bColor, int iSize, int iSecondSize)
        throws BadElementException {
    Font firstFont = null;//  w  w w.ja  v  a  2  s. c  o m
    Font secondFont = null;
    switch (iSize) {
    case 8:
        firstFont = REPORT_SETTINGS.ftTableHeader8B;
        break;
    case 9:
        firstFont = REPORT_SETTINGS.ftTableHeader9B;
        break;
    case 12:
        firstFont = REPORT_SETTINGS.ftTableHeader12B;
        break;
    default:
        firstFont = REPORT_SETTINGS.ftTableHeaderB;
        break;
    }
    switch (iSecondSize) {
    case 8:
        secondFont = REPORT_SETTINGS.ftTableHeader8;
        break;
    case 9:
        secondFont = REPORT_SETTINGS.ftTableHeader9;
        break;
    case 12:
        secondFont = REPORT_SETTINGS.ftTableHeader12;
        break;
    default:
        secondFont = REPORT_SETTINGS.ftTableHeader;
        break;
    }
    String firstChar = (StringManager.isNotEmpty(strCaption) ? String.valueOf(strCaption.charAt(0)) : "");
    String otherPart = (StringManager.isNotEmpty(strCaption) ? strCaption.substring(1, strCaption.length())
            : "");

    Chunk firstCharChunk = new Chunk(firstChar, firstFont);
    Phrase str = new Phrase(otherPart, secondFont);
    str.add(0, firstCharChunk);
    Cell cl = new Cell(str);
    if (bColor) {
        cl.setBackgroundColor(REPORT_SETTINGS.clTableHeader);
    }
    cl.setColspan(iColspan);
    this.addCell(cl);
}

From source file:s2s.report.MiddleTable.java

License:GNU General Public License

public void addCellFirstLineBold(String strCaption, int iColspan, int iSize, int iSecondSize)
        throws BadElementException {
    Font firstFont = null;/*  ww w .  j  a v a 2 s. c  o m*/
    Font secondFont = null;
    switch (iSize) {
    case 8:
        firstFont = REPORT_SETTINGS.ftText8B;
        break;
    case 9:
        firstFont = REPORT_SETTINGS.ftText9B;
        break;
    default:
        firstFont = REPORT_SETTINGS.ftText12B;
        break;
    }
    switch (iSecondSize) {
    case 8:
        secondFont = REPORT_SETTINGS.ftText8;
        break;
    case 9:
        secondFont = REPORT_SETTINGS.ftText9;
        break;
    default:
        secondFont = REPORT_SETTINGS.ftText12;
        break;
    }
    String newLineChar = "\n";
    String firstPart = StringManager.isNotEmpty(strCaption)
            ? strCaption.substring(0, strCaption.indexOf(newLineChar) + newLineChar.length())
            : "";
    String otherPart = StringManager.isNotEmpty(strCaption) ? strCaption.substring(firstPart.length()) : "";

    Chunk firstCharChunk = new Chunk(firstPart, firstFont);
    Phrase str = new Phrase(otherPart, secondFont);
    str.add(0, firstCharChunk);
    Cell cl = new Cell(str);
    cl.setColspan(iColspan);
    this.addCell(cl);
}

From source file:s2s.report.MiddleTable.java

License:GNU General Public License

public void addCellUrl(String strCaption) throws Exception {
    Chunk ph = new Chunk(strCaption);
    ph.setAnchor(strCaption);//ww  w .j  a  va 2  s.c  om
    super.addCell(new Cell(ph));
}

From source file:s2s.report.MiddleTable.java

License:GNU General Public License

public void addCellBU(String strCaption, int iSize, int iColspan) throws BadElementException {
    strCaption = strCaption == null ? "" : strCaption;
    Cell cell = null;//from  w  w  w. j av  a2s . c o m
    switch (iSize) {
    case 8:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText8BU));
        break;
    case 9:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText9BU));
        break;
    case 10:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText10BU));
        break;
    case 11:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText11BU));
        break;
    case 12:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText12BU));
        break;
    case 13:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText13BU));
        break;
    case 14:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText14BU));
        break;
    case 15:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText15BU));
        break;
    case 16:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText16BU));
        break;
    case 17:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText17BU));
        break;
    case 18:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText18BU));
        break;
    case 19:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText19BU));
        break;
    default:
        cell = new Cell(new Phrase(strCaption, REPORT_SETTINGS.ftText12BU));
        break;
    }
    cell.setColspan(iColspan);
    this.addCell(cell);
}