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:com.afunms.report.abstraction.ExcelReport1.java

/**
 * @author HONGLI MySQLword,pdf//from w w w .java2 s  .co  m
 * @param filename
 * @param type
 * @throws IOException
 */
public void createReport_MySQLCldDoc(String filename, String type) throws IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        if ("pdf".equals(type)) {
            PdfWriter.getInstance(document, new FileOutputStream(filename));
        } else {
            RtfWriter2.getInstance(document, new FileOutputStream(filename));
        }
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String hostname = (String) reportHash.get("dbname");
        String ip = (String) reportHash.get("ip");
        String typename = (String) reportHash.get("typename");
        String runstr = (String) reportHash.get("runstr");
        String grade = (String) reportHash.get("grade");
        String pingnow = (String) reportHash.get("pingnow");
        String pingmin = (String) reportHash.get("pingmin");
        String pingconavg = (String) reportHash.get("pingconavg");
        DBVo vo = (DBVo) reportHash.get("vo");

        Vector val = (Vector) reportHash.get("Val");
        if (val == null) {
            val = new Vector();
        }
        List sessionlist = (ArrayList) reportHash.get("sessionlist");
        if (sessionlist == null) {
            sessionlist = new ArrayList();
        }
        Hashtable tablesHash = (Hashtable) reportHash.get("tablesHash");
        if (tablesHash == null) {
            tablesHash = new Hashtable();
        }
        Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v");
        if (tableinfo_v == null) {
            tableinfo_v = new Vector();
        }
        String newip = doip(ip);
        Paragraph title = new Paragraph(hostname + "", titleFont);
        // 
        title.setAlignment(Element.ALIGN_CENTER);
        // title.setFont(titleFont);
        document.add(title);
        String Ping = (String) reportHash.get("Ping");
        String starttime = (String) reportHash.get("starttime");
        String totime = (String) reportHash.get("totime");

        Hashtable maxping = (Hashtable) reportHash.get("ping");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String contextString = ":" + impReport.getTimeStamp() + " \n"// 
                + ":" + starttime + "  " + totime;

        Paragraph context = new Paragraph(contextString, contextFont);
        // 
        context.setAlignment(Element.ALIGN_LEFT);
        // context.setFont(contextFont);
        // 
        context.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        /*
         * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp());
         * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " +
         * starttime + "  " + totime);
         */
        // 
        Table dbTable = new Table(5);
        this.setTableFormat(dbTable);
        // float[] cellWidths = { 220f, 220f, 220f, 220f, 220f };
        // dbTable.setWidths(cellWidths);
        // dbTable.setWidth(100); //  90%
        // dbTable.setAlignment(Element.ALIGN_CENTER);// 
        // dbTable.setAutoFillEmptyCells(true); // 
        // dbTable.setBorderWidth(1); // 
        // dbTable.setBorderColor(new Color(0, 125, 255)); // 
        // dbTable.setPadding(2);// 
        // dbTable.setSpacing(0);// 
        // dbTable.setBorder(2);// 
        // dbTable.endHeaders();

        Cell dbCell = null;
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbCell.setColspan(5);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("IP", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(dbCell, true);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(vo.getDbName(), contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(ip, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(typename, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(runstr, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(grade, contextFont));
        this.setCellFormat(dbCell, false);
        dbTable.addCell(dbCell);

        Table aTable = new Table(3);
        this.setTableFormat(aTable);
        // float[] widths = { 220f, 220f, 220f };
        // aTable.setWidths(widths);
        // aTable.setWidth(100); //  90%
        // aTable.setAlignment(Element.ALIGN_CENTER);// 
        // aTable.setAutoFillEmptyCells(true); // 
        // aTable.setBorderWidth(1); // 
        // aTable.setBorderColor(new Color(0, 125, 255)); // 
        // aTable.setPadding(2);// 
        // aTable.setSpacing(0);// 
        // aTable.setBorder(2);// 
        // aTable.endHeaders();
        Cell cell = null;
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingnow + "%", contextFont));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingmin + "%", contextFont));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingconavg + "%", contextFont));
        this.setCellFormat(cell, false);
        aTable.addCell(cell);

        // 
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        // img.setAbsolutePosition(0, 0);
        img.scalePercent(76);
        img.setAlignment(Image.LEFT);// 
        document.add(dbTable);
        document.add(aTable);
        document.add(img);
        document.add(new Paragraph("\n"));

        Table xnTable = new Table(2);
        this.setTableFormat(xnTable);
        // float[] width = { 220f, 220f };
        // xnTable.setWidths(width);
        // xnTable.setWidth(100); //  90%
        // xnTable.setAlignment(Element.ALIGN_CENTER);// 
        // xnTable.setAutoFillEmptyCells(true); // 
        // xnTable.setBorderWidth(1); // 
        // xnTable.setBorderColor(new Color(0, 125, 255)); // 
        // xnTable.setPadding(2);// 
        // xnTable.setSpacing(0);// 
        // xnTable.setBorder(2);// 
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        cell.setColspan(2);
        xnTable.addCell(cell);
        // 
        if (val != null && val.size() > 0) {
            for (int i = 0; i < val.size(); i++) {
                Hashtable return_value = (Hashtable) val.get(i);
                if (return_value != null && return_value.size() > 0) {
                    String name = return_value.get("variable_name").toString();
                    String value = return_value.get("value").toString();
                    if (name.equalsIgnoreCase("Max_used_connections")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_first")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_key")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_prev")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd")) {
                        name = "H";
                    }
                    if (name.equalsIgnoreCase("Handler_read_rnd_next")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Open_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Opened_tables")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_cached")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_connected")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_created")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Threads_running")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_immediate")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Table_locks_waited")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_read_requests")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("Key_reads")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("log_slow_queries")) {
                        name = "";
                    }
                    if (name.equalsIgnoreCase("slow_launch_time")) {
                        name = "Slow_launch_threads";
                    }
                    cell = new Cell(new Phrase(name, contextFont));
                    this.setCellFormat(cell, true);
                    xnTable.addCell(cell);
                    cell = new Cell(new Phrase(value, contextFont));
                    this.setCellFormat(cell, false);
                    xnTable.addCell(cell);
                }
            }
        }
        document.add(xnTable);

        // 
        Table dbInfoTable = new Table(6);
        this.setTableFormat(dbInfoTable);
        // float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
        // dbInfoTable.setWidths(dbInfoWidths);
        // dbInfoTable.setWidth(100); //  90%
        // dbInfoTable.setAlignment(Element.ALIGN_CENTER);// 
        // dbInfoTable.setAutoFillEmptyCells(true); // 
        // dbInfoTable.setBorderWidth(1); // 
        // dbInfoTable.setBorderColor(new Color(0, 125, 255)); // 
        // dbInfoTable.setPadding(2);// 
        // dbInfoTable.setSpacing(0);// 
        // dbInfoTable.setBorder(2);// 
        cell = new Cell(new Phrase("   ", titleFont));
        this.setCellFormat(cell, true);
        cell.setColspan(6);
        dbInfoTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        dbInfoTable.addCell(cell);
        if (sessionlist != null && sessionlist.size() > 0) {
            for (int i = 0; i < sessionlist.size(); i++) {
                List ipsessionlist = (List) sessionlist.get(i);
                if (ipsessionlist != null && ipsessionlist.size() > 0) {
                    for (int k = 0; k < ipsessionlist.size(); k++) {
                        String[] sessions = (String[]) ipsessionlist.get(k);
                        if (sessions != null && sessions.length == 5) {
                            cell = new Cell(new Phrase((k + 1) + "", contextFont));
                            this.setCellFormat(cell, false);
                            dbInfoTable.addCell(cell);
                            cell = new Cell(new Phrase(sessions[4], contextFont));
                            this.setCellFormat(cell, false);
                            dbInfoTable.addCell(cell);
                            cell = new Cell(new Phrase(sessions[0], contextFont));
                            this.setCellFormat(cell, false);
                            dbInfoTable.addCell(cell);
                            cell = new Cell(new Phrase(sessions[1], contextFont));
                            this.setCellFormat(cell, false);
                            dbInfoTable.addCell(cell);
                            cell = new Cell(new Phrase(sessions[2], contextFont));
                            this.setCellFormat(cell, false);
                            dbInfoTable.addCell(cell);
                            cell = new Cell(new Phrase(sessions[3], contextFont));
                            this.setCellFormat(cell, false);
                            dbInfoTable.addCell(cell);
                        }
                    }
                }
            }
        }
        document.add(dbInfoTable);

        // 
        Table tabTable = new Table(5);
        this.setTableFormat(tabTable);
        // float[] sysInfoWidths = { 220f, 220f, 220f, 220f, 220f };
        // dbInfoTable.setWidths(dbInfoWidths);
        // tabTable.setWidth(100); //  90%
        // tabTable.setAlignment(Element.ALIGN_CENTER);// 
        // tabTable.setAutoFillEmptyCells(true); // 
        // tabTable.setBorderWidth(1); // 
        // tabTable.setBorderColor(new Color(0, 125, 255)); // 
        // tabTable.setPadding(2);// 
        // tabTable.setSpacing(0);// 
        // tabTable.setBorder(2);// 
        Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// 
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        cell.setColspan(5);
        tabTable.addCell(cell);

        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        tabTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        tabTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        tabTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        tabTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        tabTable.addCell(cell);
        String[] dbs = vo.getDbName().split(",");
        if (dbs != null && dbs.length > 0) {
            for (int i = 0; i < dbs.length; i++) {
                String dbStr = dbs[i];
                // System.out.println(dbStr+"====="+tablesHash.size());
                if (tablesHash.containsKey(dbStr)) {
                    List tableslist = (List) tablesHash.get(dbStr);
                    if (tableslist != null && tableslist.size() > 0) {
                        for (int k = 0; k < tableslist.size(); k++) {
                            String[] tables = (String[]) tableslist.get(k);
                            if (tables != null && tables.length == 4) {
                                cell = new Cell(new Phrase((k + 1) + "", contextFont));
                                this.setCellFormat(cell, false);
                                tabTable.addCell(cell);
                                cell = new Cell(new Phrase(tables[0], contextFont));
                                this.setCellFormat(cell, false);
                                tabTable.addCell(cell);
                                cell = new Cell(new Phrase(tables[1], contextFont));
                                this.setCellFormat(cell, false);
                                tabTable.addCell(cell);
                                cell = new Cell(new Phrase(tables[2], contextFont));
                                this.setCellFormat(cell, false);
                                tabTable.addCell(cell);
                                cell = new Cell(new Phrase(tables[3], contextFont));
                                this.setCellFormat(cell, false);
                                tabTable.addCell(cell);
                            }
                        }
                    }
                }
            }
        }
        document.add(tabTable);

        // 
        Table stateTable = new Table(3);
        this.setTableFormat(stateTable);
        // float[] statewidth = { 220f, 220f, 220f };
        // stateTable.setWidths(statewidth);
        // stateTable.setWidth(100); //  90%
        // stateTable.setAlignment(Element.ALIGN_CENTER);// 
        // stateTable.setAutoFillEmptyCells(true); // 
        // stateTable.setBorderWidth(1); // 
        // stateTable.setBorderColor(new Color(0, 125, 255)); // 
        // stateTable.setPadding(2);// 
        // stateTable.setSpacing(0);// 
        // stateTable.setBorder(2);// 
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        cell.setColspan(3);// HONGLILI
        stateTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        stateTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        this.setCellFormat(cell, true);
        stateTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        this.setCellFormat(cell, true);
        stateTable.addCell(cell);
        if (tableinfo_v != null) {
            for (int i = 0; i < tableinfo_v.size(); i++) {
                Hashtable ht = (Hashtable) tableinfo_v.get(i);
                String size = ht.get("variable_name").toString();
                String free = ht.get("value").toString();
                if (size.equalsIgnoreCase("auto_increment_increment")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("auto_increment_offset")) {
                    size = "AUTO_INCREMENT";
                }
                if (size.equalsIgnoreCase("automatic_sp_privileges")) {
                    size = "automatic_sp_privileges";
                }
                if (size.equalsIgnoreCase("back_log")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("basedir")) {
                    size = "MySQL";
                }
                if (size.equalsIgnoreCase("binlog_cache_size")) {
                    size = "SQL";
                }
                if (size.equalsIgnoreCase("bulk_insert_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_client")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_connection")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_database")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_filesystem")) {
                    size = "character_set_filesystem";
                }
                if (size.equalsIgnoreCase("character_set_results")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_server")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_set_system")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("character_sets_dir")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("collation_connection")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("collation_database")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("collation_server")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("completion_type")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("concurrent_insert")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("connect_timeout")) {
                    size = "Bad handshake";
                }
                if (size.equalsIgnoreCase("datadir")) {
                    size = "MySQL";
                }
                if (size.equalsIgnoreCase("date_format")) {
                    size = "date_format()";
                }
                if (size.equalsIgnoreCase("datetime_format")) {
                    size = "datetime_format()";
                }
                if (size.equalsIgnoreCase("default_week_format")) {
                    size = "WEEK() ";
                }
                if (size.equalsIgnoreCase("delay_key_write")) {
                    size = "DELAY_KEY_WRITE";
                }
                if (size.equalsIgnoreCase("delayed_insert_limit")) {
                    size = "INSERT DELAYEDSELECT";
                }
                if (size.equalsIgnoreCase("delayed_insert_timeout")) {
                    size = "INSERT DELAYEDINSERT";
                }
                if (size.equalsIgnoreCase("delayed_queue_size")) {
                    size = "INSERT DELAYED";
                }
                if (size.equalsIgnoreCase("div_precision_increment")) {
                    size = "/";
                }
                if (size.equalsIgnoreCase("engine_condition_pushdown")) {
                    size = "NDB";
                }
                if (size.equalsIgnoreCase("expire_logs_days")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("flush")) {
                    size = "flushmysqld";
                }
                if (size.equalsIgnoreCase("flush_time")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("ft_boolean_syntax")) {
                    size = "IN BOOLEAN MODE";
                }
                if (size.equalsIgnoreCase("ft_max_word_len")) {
                    size = "FULLTEXT";
                }
                if (size.equalsIgnoreCase("ft_min_word_len")) {
                    size = "FULLTEXT";
                }
                if (size.equalsIgnoreCase("ft_query_expansion_limit")) {
                    size = "WITH QUERY EXPANSION";
                }
                if (size.equalsIgnoreCase("ft_stopword_file")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("group_concat_max_len")) {
                    size = "GROUP_CONCAT()";
                }
                if (size.equalsIgnoreCase("have_archive")) {
                    size = "mysqldARCHIVE";
                }
                if (size.equalsIgnoreCase("have_bdb")) {
                    size = "mysqldBDB";
                }
                if (size.equalsIgnoreCase("have_blackhole_engine")) {
                    size = "mysqldBLACKHOLE";
                }
                if (size.equalsIgnoreCase("have_compress")) {
                    size = "zlib";
                }
                if (size.equalsIgnoreCase("have_crypt")) {
                    size = "crypt()";
                }
                if (size.equalsIgnoreCase("have_csv")) {
                    size = "mysqldARCHIVE";
                }
                if (size.equalsIgnoreCase("have_example_engine")) {
                    size = "mysqldEXAMPLE";
                }
                if (size.equalsIgnoreCase("have_federated_engine")) {
                    size = "mysqldFEDERATED";
                }
                if (size.equalsIgnoreCase("have_geometry")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("have_innodb")) {
                    size = "mysqldInnoDB";
                }
                if (size.equalsIgnoreCase("have_isam")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("have_ndbcluster")) {
                    size = "mysqldNDB CLUSTER";
                }
                if (size.equalsIgnoreCase("have_openssl")) {
                    size = "mysqld/SSL()";
                }
                if (size.equalsIgnoreCase("have_query_cache")) {
                    size = "mysqld";
                }
                if (size.equalsIgnoreCase("have_raid")) {
                    size = "mysqldRAID";
                }
                if (size.equalsIgnoreCase("have_rtree_keys")) {
                    size = "RTREE";
                }
                if (size.equalsIgnoreCase("have_symlink")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("init_connect")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("init_file")) {
                    size = "--init-file";
                }
                if (size.equalsIgnoreCase("init_slave")) {
                    size = "SQL";
                }
                if (size.equalsIgnoreCase("innodb_additional_mem_pool_size")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_autoextend_increment")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_buffer_pool_awe_mem_mb")) {
                    size = "32WindowsAWE";
                }
                if (size.equalsIgnoreCase("innodb_buffer_pool_size")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_checksums")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_commit_concurrency")) {
                    size = "innodb_commit_concurrency";
                }
                if (size.equalsIgnoreCase("innodb_concurrency_tickets")) {
                    size = "innodb_concurrency_tickets";
                }
                if (size.equalsIgnoreCase("innodb_data_file_path")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_data_home_dir")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_doublewrite")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_fast_shutdown")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_file_io_threads")) {
                    size = "InnoDBI/O";
                }
                if (size.equalsIgnoreCase("innodb_file_per_table")) {
                    size = "InnoDB.ibd";
                }
                if (size.equalsIgnoreCase("innodb_flush_log_at_trx_commit")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_flush_method")) {
                    size = "InnoDBfsync()";
                }
                if (size.equalsIgnoreCase("innodb_force_recovery")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_lock_wait_timeout")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_locks_unsafe_for_binlog")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_log_arch_dir")) {
                    size = " ";
                }
                if (size.equalsIgnoreCase("innodb_log_archive")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_log_buffer_size")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_log_file_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_log_files_in_group")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_log_group_home_dir")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_max_dirty_pages_pct")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_max_purge_lag")) {
                    size = "INSERT,UPDATEDELETE";
                }
                if (size.equalsIgnoreCase("innodb_mirrored_log_groups")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("innodb_open_files")) {
                    size = "InnoDB.ibd";
                }
                if (size.equalsIgnoreCase("innodb_support_xa")) {
                    size = "InnoDBXA";
                }
                if (size.equalsIgnoreCase("innodb_sync_spin_loops")) {
                    size = "innodb_sync_spin_loops";
                }
                if (size.equalsIgnoreCase("innodb_table_locks")) {
                    size = "InnoDB";
                }
                if (size.equalsIgnoreCase("innodb_thread_concurrency")) {
                    size = "InnoDBInnoDB";
                }
                if (size.equalsIgnoreCase("innodb_thread_sleep_delay")) {
                    size = "InnoDBSHOW INNODB STATUS<datadir>/innodb_status";
                }
                if (size.equalsIgnoreCase("interactive_timeout")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("join_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("key_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("key_cache_age_threshold")) {
                    size = "(sub-chain)(sub-chain)";
                }
                if (size.equalsIgnoreCase("key_cache_block_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("key_cache_division_limit")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("language")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("large_files_support")) {
                    size = "mysqld";
                }
                if (size.equalsIgnoreCase("large_page_size")) {
                    size = "large_page_size";
                }
                if (size.equalsIgnoreCase("large_pages")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("license")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("local_infile")) {
                    size = "LOCALLOAD DATA INFILE";
                }
                if (size.equalsIgnoreCase("log")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_bin")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_bin_trust_function_creators")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_error")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_slave_updates")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_slow_queries")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("log_warnings")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("long_query_time")) {
                    size = "Slow_queries";
                }
                if (size.equalsIgnoreCase("low_priority_updates")) {
                    size = "sqlSELECTLOCK TABLE READ";
                }
                if (size.equalsIgnoreCase("lower_case_file_system")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("lower_case_table_names")) {
                    size = "1";
                }
                if (size.equalsIgnoreCase("max_allowed_packet")) {
                    size = "/";
                }
                if (size.equalsIgnoreCase("max_binlog_cache_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_binlog_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_connect_errors")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_connections")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_delayed_threads")) {
                    size = "INSERT DELAYED";
                }
                if (size.equalsIgnoreCase("max_error_count")) {
                    size = "SHOW ERRORSSHOW WARNINGS";
                }
                if (size.equalsIgnoreCase("max_heap_table_size")) {
                    size = "MEMORY (HEAP)";
                }
                if (size.equalsIgnoreCase("max_insert_delayed_threads")) {
                    size = "INSERT DELAYED(max_delayed_threads)";
                }
                if (size.equalsIgnoreCase("max_join_size")) {
                    size = "max_join_size";
                }
                if (size.equalsIgnoreCase("max_length_for_sort_data")) {
                    size = "filesort";
                }
                if (size.equalsIgnoreCase("max_prepared_stmt_count")) {
                    size = "max_prepared_stmt_count";
                }
                if (size.equalsIgnoreCase("max_relay_log_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_seeks_for_key")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_sort_length")) {
                    size = "BLOBTEXT";
                }
                if (size.equalsIgnoreCase("max_sp_recursion_depth")) {
                    size = "max_sp_recursion_depth";
                }
                if (size.equalsIgnoreCase("max_tmp_tables")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("max_user_connections")) {
                    size = "MySQL";
                }
                if (size.equalsIgnoreCase("max_write_lock_count")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("multi_range_count")) {
                    size = "multi_range_count";
                }
                if (size.equalsIgnoreCase("myisam_data_pointer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("myisam_max_sort_file_size")) {
                    size = "MyISAMMySQL";
                }
                if (size.equalsIgnoreCase("myisam_recover_options")) {
                    size = "myisam-recover";
                }
                if (size.equalsIgnoreCase("myisam_repair_threads")) {
                    size = "1Repair by sortingMyISAM";
                }
                if (size.equalsIgnoreCase("myisam_sort_buffer_size")) {
                    size = "REPAIR TABLECREATE INDEXALTER TABLEMyISAM";
                }
                if (size.equalsIgnoreCase("myisam_stats_method")) {
                    size = "MyISAMNULL";
                }
                if (size.equalsIgnoreCase("named_pipe")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("net_buffer_length")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("net_read_timeout")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("net_retry_count")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("net_write_timeout")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("new")) {
                    size = "MySQL 4.04.1";
                }
                if (size.equalsIgnoreCase("old_passwords")) {
                    size = "MySQLpre-4.1-style";
                }
                if (size.equalsIgnoreCase("open_files_limit")) {
                    size = "mysqld";
                }
                if (size.equalsIgnoreCase("optimizer_prune_level")) {
                    size = " 0";
                }
                if (size.equalsIgnoreCase("optimizer_search_depth")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("pid_file")) {
                    size = "ID (PID)";
                }
                if (size.equalsIgnoreCase("prepared_stmt_count")) {
                    size = "prepared_stmt_count";
                }
                if (size.equalsIgnoreCase("port")) {
                    size = "TCP/IP";
                }
                if (size.equalsIgnoreCase("preload_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("protocol_version")) {
                    size = "MySQL/";
                }
                if (size.equalsIgnoreCase("query_alloc_block_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("query_cache_limit")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("query_cache_min_res_unit")) {
                    size = "()";
                }
                if (size.equalsIgnoreCase("query_cache_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("query_cache_type")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("query_cache_wlock_invalidate")) {
                    size = "WRITE";
                }
                if (size.equalsIgnoreCase("query_prealloc_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("range_alloc_block_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("read_buffer_size")) {
                    size = "()";
                }
                if (size.equalsIgnoreCase("read_only")) {
                    size = "ON";
                }
                if (size.equalsIgnoreCase("read_only")) {
                    size = "ON";
                }
                if (size.equalsIgnoreCase("relay_log_purge")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("read_rnd_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("secure_auth")) {
                    size = "--secure-authMySQL(4.1)";
                }
                if (size.equalsIgnoreCase("shared_memory")) {
                    size = "(Windows)";
                }
                if (size.equalsIgnoreCase("shared_memory_base_name")) {
                    size = "(Windows)";
                }
                if (size.equalsIgnoreCase("server_id")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("skip_external_locking")) {
                    size = "mysqld";
                }
                if (size.equalsIgnoreCase("skip_networking")) {
                    size = "(TCP/IP)";
                }
                if (size.equalsIgnoreCase("skip_show_database")) {
                    size = "SHOW DATABASESSHOW DATABASES";
                }
                if (size.equalsIgnoreCase("slave_compressed_protocol")) {
                    size = "/";
                }
                if (size.equalsIgnoreCase("slave_load_tmpdir")) {
                    size = "LOAD DATA INFILE";
                }
                if (size.equalsIgnoreCase("slave_net_timeout")) {
                    size = "/";
                }
                if (size.equalsIgnoreCase("slave_skip_errors")) {
                    size = "()";
                }
                if (size.equalsIgnoreCase("slave_transaction_retries")) {
                    size = "SQLslave_transaction_retries";
                }
                if (size.equalsIgnoreCase("slow_launch_time")) {
                    size = "Slow_launch_threads";
                }
                if (size.equalsIgnoreCase("sort_buffer_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("sql_mode")) {
                    size = "SQL";
                }
                if (size.equalsIgnoreCase("storage_engine")) {
                    size = "table_typeisMySQL 5.1,storage_engine";
                }
                if (size.equalsIgnoreCase("sync_binlog")) {
                    size = "sync_binlog'thMySQL";
                }
                if (size.equalsIgnoreCase("sync_frm")) {
                    size = "1,.frm";
                }
                if (size.equalsIgnoreCase("system_time_zone")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("table_cache")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("table_type")) {
                    size = "()";
                }
                if (size.equalsIgnoreCase("thread_cache_size")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("thread_stack")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("time_format")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("time_zone")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("tmp_table_size")) {
                    size = "MySQLMyISAM";
                }
                if (size.equalsIgnoreCase("tmpdir")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("transaction_alloc_block_size")) {
                    size = "()";
                }
                if (size.equalsIgnoreCase("transaction_prealloc_size")) {
                    size = "transaction_alloc_blocks";
                }
                if (size.equalsIgnoreCase("tx_isolation")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("updatable_views_with_limit")) {
                    size = "LIMIT";
                }
                if (size.equalsIgnoreCase("version")) {
                    size = "";
                }
                if (size.equalsIgnoreCase("version_bdb")) {
                    size = "BDB";
                }
                if (size.equalsIgnoreCase("version_comment")) {
                    size = "configure--with-commentMySQL";
                }
                if (size.equalsIgnoreCase("version_compile_machine")) {
                    size = "MySQL";
                }
                if (size.equalsIgnoreCase("version_compile_os")) {
                    size = "MySQL";
                }
                if (size.equalsIgnoreCase("wait_timeout")) {
                    size = "";
                }
                cell = new Cell(new Phrase(String.valueOf(i + 1), contextFont));
                this.setCellFormat(cell, false);
                stateTable.addCell(cell);
                cell = new Cell(new Phrase(size, contextFont));
                this.setCellFormat(cell, false);
                stateTable.addCell(cell);
                cell = new Cell(new Phrase(free, contextFont));
                this.setCellFormat(cell, false);
                stateTable.addCell(cell);
                // stateTable.endHeaders();
            }
        } // HONGLILI
        document.add(stateTable);

        //    
        Table evenInfoTable = new Table(2);
        this.setTableFormat(evenInfoTable);
        // float[] evenInfoWidths = { 220f, 220f };
        // evenInfoTable.setWidths(evenInfoWidths);
        // evenInfoTable.setWidth(100); //  90%
        // evenInfoTable.setAlignment(Element.ALIGN_CENTER);// 
        // evenInfoTable.setAutoFillEmptyCells(true); // 
        // evenInfoTable.setBorderWidth(1); // 
        // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // 
        // evenInfoTable.setPadding(2);// 
        // evenInfoTable.setSpacing(0);// 
        // evenInfoTable.setBorder(2);// 
        String downnum = (String) reportHash.get("downnum");
        String count = (Integer) reportHash.get("count") + "";
        cell = new Cell(new Phrase("", titleFont));
        cell.setColspan(2);
        this.setCellFormat(cell, true);
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        this.setCellFormat(cell, true);
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase(downnum, contextFont));
        this.setCellFormat(cell, false);
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase(count, contextFont));
        this.setCellFormat(cell, false);
        evenInfoTable.addCell(cell);
        document.add(evenInfoTable);
        // 
        addEventListToDoc(document, titleFont, contextFont);
        document.close();
    } catch (Exception e) {
        // SysLogger.error("Error in ExcelReport.createReport()",e);
        SysLogger.error("", e);
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * PDF//  www. j  a va  2s. c om
 * 
 * @param document
 * @throws DocumentException
 * @throws IOException
 */
private void addEventLisToPdf(Document document) throws DocumentException, IOException {
    // 
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 12, Font.NORMAL);

    Cell cell;
    Table eventListTable = new Table(6);
    this.setTableFormat(eventListTable);
    float[] eventListWidths = { 220f, 220f, 440f, 220f, 220f, 220f };
    eventListTable.setWidths(eventListWidths);
    // eventListTable.setWidthPercentage(100);
    cell = new Cell(new Phrase("", titleFont));
    cell.setColspan(6);
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventListTable.addCell(cell);
    int index = 0;
    java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm");
    List list = (ArrayList) reportHash.get("list");
    if (list != null && list.size() > 0) {
        for (int i = 0; i < list.size(); i++) {
            index++;
            EventList eventlist = (EventList) list.get(i);
            Date cc = eventlist.getRecordtime().getTime();
            Integer eventid = eventlist.getId();
            String eventlocation = eventlist.getEventlocation();
            String content = eventlist.getContent();
            String level = String.valueOf(eventlist.getLevel1());
            String status = String.valueOf(eventlist.getManagesign());
            String s = status;
            String showlevel = null;
            String act = "";
            if ("1".equals(level)) {
                showlevel = "";
            } else if ("2".equals(level)) {
                showlevel = "";
            } else {
                showlevel = "";
            }
            if ("0".equals(status)) {
                status = "";
            }
            if ("1".equals(status)) {
                status = "";
            }
            if ("2".equals(status)) {
                status = "";
            }
            String rptman = eventlist.getReportman();
            String rtime1 = _sdf.format(cc);
            cell = new Cell(new Phrase(String.valueOf(index), contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            eventListTable.addCell(cell);
            if ("3".equals(level)) {
                cell = new Cell(new Phrase(showlevel, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                cell.setBackgroundColor(Color.red);
                eventListTable.addCell(cell);
            } else if ("2".equals(level)) {
                cell = new Cell(new Phrase(showlevel, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                cell.setBackgroundColor(Color.orange);
                eventListTable.addCell(cell);
            } else {
                cell = new Cell(new Phrase(showlevel, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                cell.setBackgroundColor(Color.yellow);
                eventListTable.addCell(cell);
            }
            cell = new Cell(new Phrase(content, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            eventListTable.addCell(cell);
            cell = new Cell(new Phrase(rtime1, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            eventListTable.addCell(cell);
            cell = new Cell(new Phrase(rptman, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            eventListTable.addCell(cell);
            cell = new Cell(new Phrase(status, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            eventListTable.addCell(cell);
        }
    }

    document.add(eventListTable);
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

/**
 * DOC//  w w w  .j ava2s .  co m
 * 
 * @param document
 * @param titleFont
 * @param contextFont
 * @throws BadElementException
 * @throws DocumentException
 */
private void addEventListToDoc(Document document, Font titleFont, Font contextFont)
        throws BadElementException, DocumentException {
    Cell cell;
    // 
    Table eventTable = new Table(6);
    this.setTableFormat(eventTable);
    // float[] eventWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
    // eventTable.setWidths(eventWidths);
    // eventTable.setWidth(100); //  90%
    // eventTable.setAlignment(Element.ALIGN_CENTER);// 
    // eventTable.setAutoFillEmptyCells(true); // 
    // eventTable.setBorderWidth(1); // 
    // eventTable.setBorderColor(new Color(0, 125, 255)); // 
    // eventTable.setPadding(2);// 
    // eventTable.setSpacing(0);// 
    // eventTable.setBorder(2);// 
    // eventTable.endHeaders();
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    cell.setColspan(6);
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase(" ", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase("  ", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);
    cell = new Cell(new Phrase("   ", titleFont));
    this.setCellFormat(cell, true);
    eventTable.addCell(cell);

    int index = 0;
    java.text.SimpleDateFormat _sdf = new java.text.SimpleDateFormat("MM-dd HH:mm");
    List list = (ArrayList) reportHash.get("list");
    if (list != null && list.size() > 0) {
        for (int i = 0; i < list.size(); i++) {
            index++;
            EventList eventlist = (EventList) list.get(i);
            Date cc = eventlist.getRecordtime().getTime();
            Integer eventid = eventlist.getId();
            String eventlocation = eventlist.getEventlocation();
            String content = eventlist.getContent();
            String level = String.valueOf(eventlist.getLevel1());
            String status = String.valueOf(eventlist.getManagesign());
            String s = status;
            String showlevel = null;
            String act = "";
            if ("1".equals(level)) {
                showlevel = "";
            } else if ("2".equals(level)) {
                showlevel = "";
            } else {
                showlevel = "";
            }
            if ("0".equals(status)) {
                status = "";
            }
            if ("1".equals(status)) {
                status = "";
            }
            if ("2".equals(status)) {
                status = "";
            }
            String rptman = eventlist.getReportman();
            String rtime1 = _sdf.format(cc);

            cell = new Cell(new Phrase(String.valueOf(index), contextFont));
            this.setCellFormat(cell, false);
            eventTable.addCell(cell);
            cell = new Cell(new Phrase(showlevel, contextFont));
            this.setCellFormat(cell, false);
            if ("3".equals(level)) {
                cell.setBackgroundColor(Color.red);
            } else if ("2".equals(level)) {
                cell.setBackgroundColor(Color.orange);
            } else {
                cell.setBackgroundColor(Color.yellow);
            }
            eventTable.addCell(cell);
            cell = new Cell(new Phrase(content, contextFont));
            this.setCellFormat(cell, false);
            eventTable.addCell(cell);
            cell = new Cell(new Phrase(rtime1, contextFont));
            this.setCellFormat(cell, false);
            eventTable.addCell(cell);
            cell = new Cell(new Phrase(rptman, contextFont));
            this.setCellFormat(cell, false);
            eventTable.addCell(cell);
            cell = new Cell(new Phrase(status, contextFont));
            this.setCellFormat(cell, false);
            eventTable.addCell(cell);
        }
    }
    document.add(eventTable);
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_cabinetWord(String filename, String room) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;/*  ww w  . j  av a 2s  . co m*/
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // new File(filename)
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        // title.setFont(titleFont);
        List cabinetlist = (List) reportHash.get("cabinetlist");

        Paragraph context = new Paragraph();
        // 
        context.setAlignment(Element.ALIGN_CENTER);
        //         context.setFont(contextFont);
        // 
        //         context.setSpacingBefore(0);
        // 
        //         context.setFirstLineIndent(6);
        //         document.add(context);
        //         document.add(new Paragraph("\n"));
        Table aTable = new Table(6);
        //         float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
        //         aTable.setWidths(widths);
        aTable.setWidth(100); //  90%
        aTable.setAlignment(Element.ALIGN_CENTER);// 
        aTable.setAutoFillEmptyCells(true); // 
        //         aTable.setBorderWidth(1); // 
        //         aTable.setBorderColor(new Color(0, 125, 255)); // 
        //         aTable.setPadding(2);// 
        //         aTable.setSpacing(4);// 
        //         aTable.setBorder(2);// 
        Cell cell = null;
        cell = new Cell(new Phrase(room + "", titleFont));
        cell.setRowspan(2);
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("U", titleFont));
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("U", titleFont));
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("U", titleFont));
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("U(%)", titleFont));
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        Cabinet cabinet = null;
        if (cabinetlist != null && cabinetlist.size() > 0) {
            for (int i = 0; i < cabinetlist.size(); i++) {

                cabinet = (Cabinet) cabinetlist.get(i);
                cell = new Cell(new Phrase(1 + i + "", contextFont));
                cell.setRowspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(cabinet.getName(), contextFont));
                cell.setRowspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);

                cell = new Cell(new Phrase(cabinet.getAllu(), contextFont));
                cell.setRowspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(cabinet.getUseu(), contextFont));
                cell.setRowspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(cabinet.getTempu(), contextFont));
                cell.setRowspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(cabinet.getRateu(), contextFont));
                cell.setRowspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);

            }
        }
        document.add(aTable);
        document.close();
    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_equipmentWord(String filename, String roomname, String cabinetname, String uselect,
        String unumber, String rate) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;/*from  www .  jav a2  s  . c o  m*/
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // new File(filename)
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        // title.setFont(titleFont);
        List equipmentlist = (List) reportHash.get("equipmentlist");

        Paragraph context = new Paragraph();
        // 
        context.setAlignment(Element.ALIGN_CENTER);
        //         context.setFont(contextFont);
        // 
        //         context.setSpacingBefore(0);
        // 
        //         context.setFirstLineIndent(6);
        //         document.add(context);
        //         document.add(new Paragraph("\n"));
        Table aTable = new Table(6);
        //         float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
        //         aTable.setWidths(widths);
        aTable.setWidth(100); //  90%
        aTable.setAlignment(Element.ALIGN_CENTER);// 
        aTable.setAutoFillEmptyCells(true); // 
        //         aTable.setBorderWidth(1); // 
        //         aTable.setBorderColor(new Color(0, 125, 255)); // 
        //         aTable.setPadding(2);// 
        //         aTable.setSpacing(4);// 
        //         aTable.setBorder(2);// 
        Cell cell = null;
        cell = new Cell(new Phrase(roomname + cabinetname + "", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase(":" + roomname, titleFont));
        cell.setColspan(3);
        this.setCellFormat(cell, false);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase(":" + cabinetname, titleFont));
        cell.setColspan(3);
        this.setCellFormat(cell, false);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("U:" + uselect, titleFont));
        cell.setColspan(2);
        this.setCellFormat(cell, false);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase(":" + unumber, titleFont));
        cell.setColspan(2);
        this.setCellFormat(cell, false);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase(":" + rate, titleFont));
        cell.setColspan(2);
        this.setCellFormat(cell, false);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        EquipmentReport equipmentReport = null;
        if (equipmentlist != null && equipmentlist.size() > 0) {
            for (int i = 0; i < equipmentlist.size(); i++) {

                equipmentReport = (EquipmentReport) equipmentlist.get(i);
                cell = new Cell(new Phrase(1 + i + "", contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(equipmentReport.getEquipmentname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);

                cell = new Cell(new Phrase(equipmentReport.getEquipmentdesc(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(equipmentReport.getOperation(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(equipmentReport.getContactname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(equipmentReport.getContactphone(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);

            }
        }
        document.add(aTable);
        document.close();
    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:com.afunms.report.abstraction.ExcelReport1.java

public void createReport_OperEquipmentWord(String filename, String opername, String contactname,
        String contactphone) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;//from  w w  w. j a v a 2s.c  o m
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // new File(filename)
        BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        // title.setFont(titleFont);
        List equipmentlist = (List) reportHash.get("equipmentlist");

        Paragraph context = new Paragraph();
        // 
        context.setAlignment(Element.ALIGN_CENTER);
        //         context.setFont(contextFont);
        // 
        //         context.setSpacingBefore(0);
        // 
        //         context.setFirstLineIndent(6);
        //         document.add(context);
        //         document.add(new Paragraph("\n"));
        Table aTable = new Table(7);
        //         float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
        //         aTable.setWidths(widths);
        aTable.setWidth(100); //  90%
        aTable.setAlignment(Element.ALIGN_CENTER);// 
        aTable.setAutoFillEmptyCells(true); // 
        //         aTable.setBorderWidth(1); // 
        //         aTable.setBorderColor(new Color(0, 125, 255)); // 
        //         aTable.setPadding(2);// 
        //         aTable.setSpacing(4);// 
        //         aTable.setBorder(2);// 
        Cell cell = null;
        cell = new Cell(new Phrase(opername + "", titleFont));
        cell.setColspan(7);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase(":" + opername, titleFont));
        cell.setColspan(2);
        this.setCellFormat(cell, false);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase(":" + contactname, titleFont));
        cell.setColspan(2);
        this.setCellFormat(cell, false);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase(":" + contactphone, titleFont));
        cell.setColspan(3);
        this.setCellFormat(cell, false);
        cell.setHorizontalAlignment(Element.ALIGN_LEFT); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("U", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("IP", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        OperCabinet operCabinet = null;
        if (equipmentlist != null && equipmentlist.size() > 0) {
            for (int i = 0; i < equipmentlist.size(); i++) {

                operCabinet = (OperCabinet) equipmentlist.get(i);
                cell = new Cell(new Phrase(operCabinet.getRoomname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(operCabinet.getCabinetname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);

                cell = new Cell(new Phrase(operCabinet.getUseu(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(operCabinet.getEquipmentname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(operCabinet.getIpaddress(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(operCabinet.getCabinetname(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(new Phrase(operCabinet.getContactphone(), contextFont));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);

            }
        }
        document.add(aTable);
        document.close();
    } catch (Exception e) {
        // TODO: handle exception
    }
}

From source file:com.bcpv.webapp.displaytag.decorators.ItextTotalWrapper.java

License:Artistic License

/**
 * Obtain a cell with the given value.//  ww  w .  j  ava2 s .  c  o  m
 * @param value Value to display in the cell.
 * @return A cell with the given value.
 * @throws com.lowagie.text.BadElementException if an error occurs while generating the cell.
 */
private Cell getCell(String value) throws BadElementException {
    Cell cell = new Cell(new Chunk(value, this.font));
    cell.setLeading(8);
    cell.setHorizontalAlignment(Element.ALIGN_LEFT);
    return cell;
}

From source file:com.centurylink.mdw.designer.pages.ExportHelper.java

License:Apache License

private void printElementHtml(Element element, Object parent, int depth, Font font, int parentLevel) {
    String tag = element.getName();
    Object av;//from ww w  .ja  va 2 s  .c o  m
    if (element instanceof HTMLDocument.RunElement) {
        HTMLDocument.RunElement re = (HTMLDocument.RunElement) element;
        int start = re.getStartOffset();
        int end = re.getEndOffset();
        try {
            String content = re.getDocument().getText(start, end - start);
            printAttributesHtml(re);
            av = re.getAttribute(CSS.Attribute.FONT_SIZE);
            String fontsize = av == null ? null : av.toString();
            av = re.getAttribute(CSS.Attribute.FONT_FAMILY);
            String fontfamily = av == null ? null : av.toString();
            av = re.getAttribute(CSS.Attribute.COLOR);
            String fontcolor = av == null ? null : av.toString();
            if (fontcolor != null || fontsize != null || fontfamily != null) {
                if (fontfamily == null)
                    fontfamily = font.getFamilyname();
                float size = fontsize == null ? font.getSize() : (Float.parseFloat(fontsize) + 9);
                int style = font.getStyle();
                Color color;
                if (fontcolor != null) {
                    color = Color.decode(fontcolor);
                } else
                    color = font.getColor();
                font = FontFactory.getFont(fontfamily, size, style, color);
            }
            if (parent instanceof Paragraph) {
                ((Paragraph) parent).add(new Chunk(content, font));
            } else {
                System.err.println("chunk with parent "
                        + (parent == null ? "null" : parent.getClass().getName()) + ": " + content);
            }
        } catch (BadLocationException e) {
            e.printStackTrace();
        }
    } else if (element instanceof HTMLDocument.BlockElement) {
        HTMLDocument.BlockElement be = (HTMLDocument.BlockElement) element;
        printAttributesHtml(be);
        av = be.getAttribute(javax.swing.text.html.HTML.Attribute.ALIGN);
        String align = av == null ? null : av.toString();
        if (tag.equalsIgnoreCase("html")) {
            printElementChildrenHtml(element, parent, depth + 1, font, parentLevel);
        } else if (tag.equalsIgnoreCase("head")) {
            // do nothing
        } else if (tag.equalsIgnoreCase("body")) {
            printElementChildrenHtml(element, parent, depth + 1, font, parentLevel);
        } else if (tag.equalsIgnoreCase("p")) {
            if (parent instanceof Section) {
                Paragraph paragraph = new Paragraph();
                if (align != null) {
                    paragraph.setAlignment(align);
                }
                printElementChildrenHtml(element, paragraph, depth + 1, normalFont, parentLevel);
                ((Section) parent).add(paragraph);
            } else {
                System.err.println("p with parent " + (parent == null ? "null" : parent.getClass().getName()));
            }
        } else if (tag.equalsIgnoreCase("h1") || tag.equalsIgnoreCase("h2") || tag.equalsIgnoreCase("h3")) {
            if (parent instanceof Section) {
                Paragraph title = new Paragraph();
                printElementChildrenHtml(element, title, depth + 1, subSectionFont, parentLevel);
                ((Section) parent).addSection(title, parentLevel == 0 ? 0 : (parentLevel + 1));
            } else {
                System.err
                        .println("list with parent " + (parent == null ? "null" : parent.getClass().getName()));
            }
        } else if (tag.equalsIgnoreCase("ul")) {
            if (parent instanceof Section) {
                com.lowagie.text.List list = new com.lowagie.text.List(false, false, 20.0f);
                printElementChildrenHtml(element, list, depth + 1, normalFont, parentLevel);
                ((Section) parent).add(list);
            } else {
                System.err
                        .println("list with parent " + (parent == null ? "null" : parent.getClass().getName()));
            }
        } else if (tag.equalsIgnoreCase("ol")) {
            if (parent instanceof Section) {
                com.lowagie.text.List list = new com.lowagie.text.List(true, false, 20.0f);
                printElementChildrenHtml(element, list, depth + 1, normalFont, parentLevel);
                ((Section) parent).add(list);
            } else {
                System.err
                        .println("list with parent " + (parent == null ? "null" : parent.getClass().getName()));
            }
        } else if (tag.equalsIgnoreCase("li")) {
            ListItem li = new ListItem();
            li.setSpacingAfter(0.0f);
            printElementChildrenHtml(element, li, depth + 1, normalFont, parentLevel);
            ((com.lowagie.text.List) parent).add(li);
        } else if (tag.equalsIgnoreCase("p-implied")) {
            if (parent instanceof ListItem) {
                Paragraph paragraph = new Paragraph();
                printElementChildrenHtml(element, paragraph, depth + 1, normalFont, parentLevel);
                ((ListItem) parent).add(paragraph);
            } else if (parent instanceof Cell) {
                Paragraph paragraph = new Paragraph();
                printElementChildrenHtml(element, paragraph, depth + 1, normalFont, parentLevel);
                ((Cell) parent).add(paragraph);
            }
        } else if (tag.equalsIgnoreCase("table")) {
            try {
                Table table = new Table(3);
                table.setBorderWidth(1);
                table.setBorderColor(new Color(0, 128, 128));
                table.setPadding(1.0f);
                table.setSpacing(0.5f);
                Cell c = new Cell("header");
                c.setHeader(true);
                c.setColspan(3);
                table.addCell(c);
                table.endHeaders();
                printElementChildrenHtml(element, table, depth + 1, normalFont, parentLevel); // TODO
                ((Section) parent).add(table);
            } catch (BadElementException e) {
                e.printStackTrace();
            }
        } else if (tag.equalsIgnoreCase("tr")) {
            printElementChildrenHtml(element, parent, depth + 1, normalFont, parentLevel); // TODO
        } else if (tag.equalsIgnoreCase("td")) {
            Cell cell = new Cell();
            printElementChildrenHtml(element, cell, depth + 1, normalFont, parentLevel); // TODO
            ((Table) parent).addCell(cell);
        } else {
            System.err.println("Unknown element " + element.getName());
            printElementChildrenHtml(element, parent, depth + 1, normalFont, parentLevel);
        }
    } else {
        return; // could be BidiElement - not sure what it is
    }
}

From source file:com.centurylink.mdw.designer.pages.ExportHelper.java

License:Apache License

private Object generateElementHtml(Element element, int depth, Font font) {
    String tag = element.getName();
    Object myself;/*from   w  ww .  j a v  a2 s  . c  om*/
    Object av;
    if (element instanceof HTMLDocument.RunElement) {
        HTMLDocument.RunElement re = (HTMLDocument.RunElement) element;
        int start = re.getStartOffset();
        int end = re.getEndOffset();
        try {
            String content = re.getDocument().getText(start, end - start);
            HtmlAttr htmlattr = printAttributesHtml(re);
            av = re.getAttribute(CSS.Attribute.FONT_SIZE);
            String fontsize = av == null ? null : av.toString();
            av = re.getAttribute(CSS.Attribute.FONT_FAMILY);
            String fontfamily = av == null ? null : av.toString();
            av = re.getAttribute(CSS.Attribute.COLOR);
            String fontcolor = av == null ? null : av.toString();
            if (fontcolor != null || fontsize != null || fontfamily != null) {
                if (fontfamily == null)
                    fontfamily = font.getFamilyname();
                if (fontsize != null && fontsize.endsWith("pt"))
                    fontsize = fontsize.substring(0, fontsize.indexOf("pt"));
                float size = fontsize == null ? font.getSize() : (Float.parseFloat(fontsize) + 8);
                int style = font.getStyle();
                Color color;
                if (fontcolor != null) {
                    color = Color.decode(fontcolor);
                } else
                    color = font.getColor();
                font = FontFactory.getFont(fontfamily, size, style, color);
            } else if (htmlattr.bold || htmlattr.italic) {
                String family = font.getFamilyname();
                float size = font.getSize();
                Color color = font.getColor();
                if (htmlattr.bold && htmlattr.italic)
                    font = FontFactory.getFont(family, size, Font.BOLDITALIC, color);
                else if (htmlattr.italic)
                    font = FontFactory.getFont(family, size, Font.ITALIC, color);
                else if (htmlattr.bold)
                    font = FontFactory.getFont(family, size, Font.BOLD);
            }
            myself = new Chunk(content, font);
        } catch (BadLocationException e) {
            e.printStackTrace();
            myself = null;
        }
    } else if (element instanceof HTMLDocument.BlockElement) {
        HTMLDocument.BlockElement be = (HTMLDocument.BlockElement) element;
        HtmlAttr htmlattr = printAttributesHtml(be);
        if (htmlattr.bold) {
            System.out.println("+++BOLD!!!");
        }
        av = be.getAttribute(javax.swing.text.html.HTML.Attribute.ALIGN);
        String align = av == null ? null : av.toString();
        if (htmlattr.bold || htmlattr.italic) {
            String family = font.getFamilyname();
            float size = font.getSize();
            Color color = font.getColor();
            if (htmlattr.bold && htmlattr.italic)
                font = FontFactory.getFont(family, size, Font.BOLDITALIC, color);
            else if (htmlattr.italic)
                font = FontFactory.getFont(family, size, Font.ITALIC, color);
            else if (htmlattr.bold)
                font = FontFactory.getFont(family, size, Font.BOLD, Color.blue);
        }
        if (tag.equalsIgnoreCase("html")) {
            myself = generateElementChildrenHtml(element, depth + 1, font);
        } else if (tag.equalsIgnoreCase("head")) {
            myself = null;
        } else if (tag.equalsIgnoreCase("body")) {
            myself = generateElementChildrenHtml(element, depth + 1, font);
        } else if (tag.equalsIgnoreCase("p") || tag.equalsIgnoreCase("p-implied")) {
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            Paragraph paragraph = new Paragraph();
            paragraph.setFirstLineIndent(0F);
            for (Object child : children) {
                if (child instanceof Chunk) {
                    Chunk chunk = (Chunk) child;
                    /*if (!chunk.getContent().equals("\n"))*/ paragraph.add(chunk);
                } else
                    paragraph.add(child);
            }
            if (align != null)
                paragraph.setAlignment(align);
            myself = paragraph;
        } else if (tag.equalsIgnoreCase("h1") || tag.equalsIgnoreCase("h2") || tag.equalsIgnoreCase("h3")) {
            List<Object> children = generateElementChildrenHtml(element, depth + 1, subSectionFont);
            Paragraph title = new Paragraph();
            for (Object child : children) {
                title.add(child);
            }
            myself = new TempSectionPdf(title);
        } else if (tag.equalsIgnoreCase("ul")) {
            com.lowagie.text.List list = new com.lowagie.text.List(false, false, 20.0f);
            list.setIndentationLeft(25.0f);
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            for (Object child : children) {
                list.add(child);
            }
            myself = list;
        } else if (tag.equalsIgnoreCase("ol")) {
            com.lowagie.text.List list = new com.lowagie.text.List(true, false, 20.0f);
            list.setIndentationLeft(25.0f);
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            for (Object child : children) {
                list.add(child);
            }
            myself = list;
        } else if (tag.equalsIgnoreCase("li")) {
            ListItem li = new ListItem();
            li.setSpacingAfter(0.0f);
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            for (Object child : children) {
                li.add(child);
            }
            myself = li;
        } else if (tag.equalsIgnoreCase("table")) {
            List<Object> rows = generateElementChildrenHtml(element, depth + 1, normalFont);
            try {
                int ncols = 0;
                for (Object row : rows) {
                    if (row instanceof List<?>) {
                        int n = ((List<?>) row).size();
                        if (n > ncols)
                            ncols = n;
                    }
                }
                Table table = new Table(2);
                table.setBorderWidth(1);
                table.setBorderColor(new Color(0, 128, 128));
                table.setPadding(1.0f);
                table.setSpacing(0.5f);
                Cell c = new Cell("header");
                c.setHeader(true);
                c.setColspan(ncols);
                table.addCell(c);
                table.endHeaders();
                for (Object row : rows) {
                    if (row instanceof List<?>) {
                        for (Object cell : (List<?>) row) {
                            if (cell instanceof Cell)
                                table.addCell((Cell) cell);
                        }
                    }
                }
                myself = table;
            } catch (BadElementException e) {
                e.printStackTrace();
                myself = null;
            }
        } else if (tag.equalsIgnoreCase("tr")) {
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            myself = children;
        } else if (tag.equalsIgnoreCase("td")) {
            Cell cell = new Cell();
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            for (Object child : children) {
                cell.add(child);
            }
            myself = cell;
        } else if (tag.equalsIgnoreCase("div")) {
            List<Object> children = generateElementChildrenHtml(element, depth + 1, normalFont);
            Paragraph paragraph = new Paragraph();
            paragraph.setFirstLineIndent(0F);
            for (Object child : children) {
                paragraph.add(child);
            }
            if (align != null)
                paragraph.setAlignment(align);
            myself = paragraph;
        } else {
            System.err.println("Unknown element " + element.getName());
            myself = null;
        }
    } else {
        myself = null; // could be BidiElement - not sure what it is
    }
    return myself;
}

From source file:com.ev.export.AnnualPDFExporter.java

License:Apache License

private void addTableHeadCell(String heading) throws Exception {
    Chunk chunk = new Chunk(heading, TABLE_HEAD_FONT);
    Cell cell = new Cell(chunk);
    table.addCell(cell);/*from  www . j a v a  2s .  c  om*/
}