Example usage for com.lowagie.text Table endHeaders

List of usage examples for com.lowagie.text Table endHeaders

Introduction

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

Prototype

public int endHeaders() 

Source Link

Document

Marks the last row of the table headers.

Usage

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

public void createReport_faworklistdoc(String filename, User user) throws DocumentException, IOException {
    // //from   w w  w .  j  a  v a 2 s. c  om
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(filename));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 12, Font.NORMAL);

    Paragraph title = new Paragraph("", titleFont);
    // 
    title.setAlignment(Element.ALIGN_CENTER);
    // title.setFont(titleFont);
    document.add(title);
    // document.add(new Paragraph("\n"));
    Table aTable = new Table(13);
    float[] widths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 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;
    NodeMonitorDao nmdao = new NodeMonitorDao();
    List moidlist = new ArrayList();
    try {
        moidlist = nmdao.loadByBID(user.getBusinessids());
    } catch (Exception e) {

    } finally {
        nmdao.close();
    }

    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);
    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);
    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);
    if (moidlist != null) {
        for (int i = 0; i < moidlist.size(); i++) {
            NodeMonitor nm = (NodeMonitor) moidlist.get(i);
            HostNode vo = new HostNode();
            HostNodeDao dao = new HostNodeDao();
            try {
                vo = dao.loadHost(nm.getNodeID());
            } catch (Exception e) {

            } finally {
                dao.close();
            }
            String enable = "";
            if (!nm.isEnabled())
                enable = "";
            if (vo == null)
                continue;

            String sms0 = "";
            if (nm.getSms0() == 0)
                sms0 = "";
            String sms1 = "";
            if (nm.getSms1() == 0)
                sms1 = "";
            String sms2 = "";
            if (nm.getSms2() == 0)
                sms2 = "";
            cell = new Cell(new Phrase(i + 1 + "", titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

            cell = new Cell(new Phrase(vo.getAlias() + "(" + nm.getIp() + ")", titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

            cell = new Cell(new Phrase(nm.getDescr(), titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

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

            cell = new Cell(new Phrase(nm.getLimenvalue0() + nm.getUnit(), titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

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

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

            cell = new Cell(new Phrase(nm.getLimenvalue1() + nm.getUnit(), titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

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

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

            cell = new Cell(new Phrase(nm.getLimenvalue2() + nm.getUnit(), titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

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

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

        }
    }
    document.add(aTable);
    document.close();
}

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

public void createReport_faworklistsearchdoc(String filename) throws DocumentException, IOException {
    // //  w  w  w . j  av  a  2s  .  co  m
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(filename));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 12, Font.NORMAL);

    Paragraph title = new Paragraph("", titleFont);
    // 
    title.setAlignment(Element.ALIGN_CENTER);
    // title.setFont(titleFont);
    document.add(title);
    // document.add(new Paragraph("\n"));
    Table aTable = new Table(13);
    float[] widths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 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;
    List moidlist = (List) reportHash.get("list");
    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);
    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);
    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);
    if (moidlist != null) {
        for (int i = 0; i < moidlist.size(); i++) {
            NodeMonitor nm = (NodeMonitor) moidlist.get(i);
            HostNode vo = new HostNode();
            HostNodeDao dao = new HostNodeDao();
            vo = dao.loadHost(nm.getNodeID());
            String enable = "";
            if (!nm.isEnabled())
                enable = "";
            if (vo == null)
                continue;
            dao.close();
            String sms0 = "";
            if (nm.getSms0() == 0)
                sms0 = "";
            String sms1 = "";
            if (nm.getSms1() == 0)
                sms1 = "";
            String sms2 = "";
            if (nm.getSms2() == 0)
                sms2 = "";
            cell = new Cell(new Phrase(i + 1 + "", titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

            cell = new Cell(new Phrase(vo.getAlias() + "(" + nm.getIp() + ")", titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

            cell = new Cell(new Phrase(nm.getDescr(), titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

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

            cell = new Cell(new Phrase(nm.getLimenvalue0() + nm.getUnit(), titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

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

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

            cell = new Cell(new Phrase(nm.getLimenvalue1() + nm.getUnit(), titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

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

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

            cell = new Cell(new Phrase(nm.getLimenvalue2() + nm.getUnit(), titleFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

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

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

        }
    }
    document.add(aTable);
    document.close();
}

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

/**
 * @author HONGLI DB2 doc/*from  www.  java2s .c  o  m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportDB2SelfDoc(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", 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 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 aTable = new Table(3);
        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));
        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((String) maxping.get("pingnow"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        // 

        document.add(aTable);
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.LEFT);//
        document.add(img);

        document.add(new Paragraph("\n"));
        Table aTable1 = new Table(5);
        float[] width = { 220f, 220f, 220f, 220f, 220f };
        aTable1.setWidths(width);
        aTable1.setWidth(100); //  90%
        aTable1.setAlignment(Element.ALIGN_CENTER);// 
        aTable1.setAutoFillEmptyCells(true); // 
        aTable1.setBorderWidth(1); // 
        aTable1.setBorderColor(new Color(0, 125, 255)); // 
        aTable1.setPadding(2);// 
        aTable1.setSpacing(0);// 
        aTable1.setBorder(2);// 

        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        cell = new Cell(new Phrase("(%)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.addCell(cell);
        // aTable1.endHeaders();

        // 
        Hashtable spaceInfo = (Hashtable) reportHash.get("spaceInfo");
        if (spaceInfo.get("toolsdb") != null) {
            List toolsdb = (ArrayList) spaceInfo.get("toolsdb");// 
            if (toolsdb != null && toolsdb.size() > 0) {
                for (int i = 0; i < toolsdb.size(); i++) {
                    Hashtable tempSpace = (Hashtable) toolsdb.get(i);
                    String SYSCATSPACE = tempSpace.get("tablespace_name") + "";
                    String totalspac = tempSpace.get("totalspac") + "";
                    String usablespac = tempSpace.get("usablespac") + "";
                    String usableper = (String) tempSpace.get("usableper");

                    if (usableper == null || usableper.trim().equals("")) {
                        usableper = "0";
                    }
                    cell = new Cell(new Phrase((i + 1) + "", titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new Cell(new Phrase(SYSCATSPACE, titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new Cell(new Phrase(totalspac, titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new Cell(new Phrase(usablespac, titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new Cell(new Phrase(usableper, titleFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);

                }
            }

            if (impReport.getChart() != null) {
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                try {
                    ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                            impReport.getChart().getWidth(), impReport.getChart().getHeight());
                } catch (IOException ioe) {
                }
                Image img1 = Image.getInstance(baos.toByteArray());
                img1.setAbsolutePosition(0, 0);
                img1.setAlignment(Image.MIDDLE);// 

                document.add(img1);
            }
        }

        document.add(aTable1);
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

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

/**
 * @author HONGLI Sybase doc/*from www  .j a v  a 2  s.com*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportSybaseSelfDoc(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", 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");
        SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO");
        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 aTable = new Table(3);
        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));
        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((String) maxping.get("pingnow"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        // 

        document.add(aTable);
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.LEFT);//
        document.add(img);

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

        //   
        Table spaceTable = new Table(5);
        float[] width = { 220f, 220f, 220f, 220f, 220f };
        spaceTable.setWidths(width);
        spaceTable.setWidth(100); //  90%
        spaceTable.setAlignment(Element.ALIGN_CENTER);// 
        spaceTable.setAutoFillEmptyCells(true); // 
        spaceTable.setBorderWidth(1); // 
        spaceTable.setBorderColor(new Color(0, 125, 255)); // 
        spaceTable.setPadding(2);// 
        spaceTable.setSpacing(0);// 
        spaceTable.setBorder(2);// 
        cell = new Cell(new Phrase("  ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("MB ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("MB", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("(%)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        // spaceTable.endHeaders();

        // 
        List dbInfo = (ArrayList) sysbaseVO.getDbInfo();
        if (dbInfo != null && dbInfo.size() > 0) {

            for (int i = 0; i < dbInfo.size(); i++) {
                TablesVO tempSpace = (TablesVO) dbInfo.get(i);
                String db_name = (String) tempSpace.getDb_name();
                String db_size = (String) tempSpace.getDb_size();
                String db_freesize = (String) tempSpace.getDb_freesize();
                String db_usedperc = (String) tempSpace.getDb_usedperc();
                cell = new Cell(new Phrase((i + 1) + "", titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_name, titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_size, titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_freesize, titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_usedperc, titleFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);

            }
        }

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        document.add(spaceTable);
        document.close();
    } catch (Exception e) {
        SysLogger.error("ExcelReport1.createReportDB2SelfDoc()");
    }
}

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

/**
 * @author HONGLI Sybaseword/*from   w w w .  j  av a 2  s  .com*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_SybaseCldDoc(String filename) throws IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", 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");
        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");
        SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO");
        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);
        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));
        dbCell.setColspan(5);
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("IP", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase("", titleFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(vo.getDbName(), contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(ip, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(typename, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(runstr, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);
        dbCell = new Cell(new Phrase(grade, contextFont));
        dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(dbCell);

        Table aTable = new Table(3);
        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));
        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(pingnow + "%", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingmin + "%", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase(pingconavg + "%", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

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

        //   
        Table spaceTable = new Table(5);
        float[] width = { 220f, 220f, 220f, 220f, 220f };
        spaceTable.setWidths(width);
        spaceTable.setWidth(100); //  90%
        spaceTable.setAlignment(Element.ALIGN_CENTER);// 
        spaceTable.setAutoFillEmptyCells(true); // 
        spaceTable.setBorderWidth(1); // 
        spaceTable.setBorderColor(new Color(0, 125, 255)); // 
        spaceTable.setPadding(2);// 
        spaceTable.setSpacing(0);// 
        spaceTable.setBorder(2);// 
        cell = new Cell(new Phrase("  ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("MB ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("MB", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("(%)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        // spaceTable.endHeaders();

        List dbInfo = (ArrayList) sysbaseVO.getDbInfo();
        if (dbInfo != null && dbInfo.size() > 0) {

            for (int i = 0; i < dbInfo.size(); i++) {
                TablesVO tempSpace = (TablesVO) dbInfo.get(i);
                String db_name = (String) tempSpace.getDb_name();
                String db_size = (String) tempSpace.getDb_size();
                String db_freesize = (String) tempSpace.getDb_freesize();
                String db_usedperc = (String) tempSpace.getDb_usedperc();
                cell = new Cell(new Phrase((i + 1) + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_name, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_size, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_freesize, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);
                cell = new Cell(new Phrase(db_usedperc, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                spaceTable.addCell(cell);

            }
        }
        document.add(spaceTable);

        // 
        Table memTable = new Table(6);
        float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f };
        memTable.setWidths(dbInfoWidths);
        memTable.setWidth(100); //  90%
        memTable.setAlignment(Element.ALIGN_CENTER);// 
        memTable.setAutoFillEmptyCells(true); // 
        memTable.setBorderWidth(1); // 
        memTable.setBorderColor(new Color(0, 125, 255)); // 
        memTable.setPadding(2);// 
        memTable.setSpacing(0);// 
        memTable.setBorder(2);// 
        Hashtable mems = (Hashtable) reportHash.get("mems");// 
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setColspan(6);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);

        cell = new Cell(new Phrase("(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase("(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase("Metadata(MB)", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase("(MB) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase("(MB) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase("(%) ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getTotal_dataCache(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getTotal_physicalMemory(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getMetadata_cache(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getProcedure_cache(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getTotal_logicalMemory(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        cell = new Cell(new Phrase(sysbaseVO.getData_hitrate(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        memTable.addCell(cell);
        document.add(memTable);

        // Sysbase 
        Table remoteServerTable = new Table(5);
        float[] remoteServerWidths = { 220f, 220f, 220f, 220f, 220f };
        remoteServerTable.setWidths(remoteServerWidths);
        remoteServerTable.setWidth(100); //  90%
        remoteServerTable.setAlignment(Element.ALIGN_CENTER);// 
        remoteServerTable.setAutoFillEmptyCells(true); // 
        remoteServerTable.setBorderWidth(1); // 
        remoteServerTable.setBorderColor(new Color(0, 125, 255)); // 
        remoteServerTable.setPadding(2);// 
        remoteServerTable.setSpacing(0);// 
        remoteServerTable.setBorder(2);// 
        Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// 
        cell = new Cell(new Phrase("Sysbase  ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);

        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        cell = new Cell(new Phrase("   ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        remoteServerTable.addCell(cell);
        List serverlist = (List) sysbaseVO.getServersInfo();
        if (serverlist != null && serverlist.size() > 0) {
            for (int k = 0; k < serverlist.size(); k++) {
                TablesVO tVO = (TablesVO) serverlist.get(k);

                cell = new Cell(new Phrase((k + 1) + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getServer_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getServer_network_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getServer_class(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getServer_status(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                remoteServerTable.addCell(cell);
            }
        }
        document.add(remoteServerTable);

        Table userTable = new Table(5);
        float[] uWidth = { 220f, 220f, 220f, 220f, 220f };
        userTable.setWidths(uWidth);
        userTable.setWidth(100); //  90%
        userTable.setAlignment(Element.ALIGN_CENTER);// 
        userTable.setAutoFillEmptyCells(true); // 
        userTable.setBorderWidth(1); // 
        userTable.setBorderColor(new Color(0, 125, 255)); // 
        userTable.setPadding(2);// 
        userTable.setSpacing(0);// 
        userTable.setBorder(2);// 
        cell = new Cell(new Phrase(" Sysbase  ", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new Cell(new Phrase("id ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        userTable.addCell(cell);
        // userTable.endHeaders();

        List userlist = (List) sysbaseVO.getUserInfo();
        if (userlist != null && userlist.size() > 0) {
            for (int k = 0; k < userlist.size(); k++) {
                TablesVO tVO = (TablesVO) userlist.get(k);
                cell = new Cell(new Phrase((k + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getUsers_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getID_in_db(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getGroup_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);
                cell = new Cell(new Phrase(tVO.getLogin_name(), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                userTable.addCell(cell);

            }
        }
        document.add(userTable);

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        //    
        Table evenInfoTable = new Table(2);
        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);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase(downnum, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        evenInfoTable.addCell(cell);
        cell = new Cell(new Phrase(count, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        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

/**
 * @author HONGLI Informix doc/*ww  w. jav a  2s .  co m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportInformixSelfDoc(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", 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 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 dbinfo = new Hashtable();
        dbinfo = (Hashtable) reportHash.get("dbValue");
        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 aTable = new Table(3);
        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));
        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((String) maxping.get("pingnow"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        // 

        document.add(aTable);
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.LEFT);//
        document.add(img);

        document.add(new Paragraph("\n"));
        // Informix
        Table spaceTable = new Table(8);
        float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        spaceTable.setWidths(width);
        spaceTable.setWidth(100); //  90%
        spaceTable.setAlignment(Element.ALIGN_CENTER);// 
        spaceTable.setAutoFillEmptyCells(true); // 
        spaceTable.setBorderWidth(1); // 
        spaceTable.setBorderColor(new Color(0, 125, 255)); // 
        spaceTable.setPadding(2);// 
        spaceTable.setSpacing(0);// 
        spaceTable.setBorder(2);// 
        cell = new Cell(new Phrase("   ", titleFont));
        cell.setColspan(8);
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        spaceTable.addCell(cell);
        // spaceTable.endHeaders();
        ArrayList dbspaces = new ArrayList();
        if (dbinfo != null) {
            dbspaces = (ArrayList) dbinfo.get("informixspaces");// 
        }
        if (dbspaces != null) {
            if (dbspaces.size() > 0) {
                DecimalFormat df = new DecimalFormat("#.###");
                for (int i = 0; i < dbspaces.size(); i++) {
                    Hashtable tablesVO = (Hashtable) dbspaces.get(i);
                    cell = new Cell(new Phrase((i + 1) + ""));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase((String) tablesVO.get("dbspace"), contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase((String) tablesVO.get("owner"), contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase((String) tablesVO.get("fname"), contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);
                    cell = new Cell(new Phrase(
                            df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%",
                            contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    spaceTable.addCell(cell);

                }
            }
        }
        document.add(spaceTable);

        // Informix
        Table hhTable = new Table(8);
        float[] hhWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f };
        hhTable.setWidths(hhWidth);
        hhTable.setWidth(100); //  90%
        hhTable.setAlignment(Element.ALIGN_CENTER);// 
        hhTable.setAutoFillEmptyCells(true); // 
        hhTable.setBorderWidth(1); // 
        hhTable.setBorderColor(new Color(0, 125, 255)); // 
        hhTable.setPadding(2);// 
        hhTable.setSpacing(0);// 
        hhTable.setBorder(2);// 
        cell = new Cell(new Phrase("   ", titleFont));
        cell.setColspan(8);
        hhTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        hhTable.addCell(cell);
        // hhTable.endHeaders();
        List dbsession = (ArrayList) dbinfo.get("sessionList");// 
        if (dbsession != null && dbsession.size() > 0) {
            for (int i = 0; i < dbsession.size(); i++) {
                Hashtable tablesVO = (Hashtable) dbsession.get(i);
                String seqscans = String.valueOf(tablesVO.get("seqscans"));
                if ("null".equals(seqscans)) {
                    seqscans = "";
                }
                String total_sorts = String.valueOf(tablesVO.get("total_sorts"));
                if ("null".equals(total_sorts)) {
                    total_sorts = "";
                }
                String dsksorts = String.valueOf(tablesVO.get("dsksorts"));
                if ("null".equals(dsksorts)) {
                    dsksorts = "";
                }
                cell = new Cell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new Cell(new Phrase(tablesVO.get("access") + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new Cell(new Phrase(tablesVO.get("locksheld") + "", contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new Cell(new Phrase(seqscans, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new Cell(new Phrase(total_sorts, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
                cell = new Cell(new Phrase(dsksorts, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                hhTable.addCell(cell);
            }
        }

        document.add(hhTable);

        // Informix
        Table lockTable = new Table(6);
        float[] lockWidth = { 220f, 220f, 220f, 220f, 220f, 220f };
        lockTable.setWidths(lockWidth);
        lockTable.setWidth(100); //  90%
        lockTable.setAlignment(Element.ALIGN_CENTER);// 
        lockTable.setAutoFillEmptyCells(true); // 
        lockTable.setBorderWidth(1); // 
        lockTable.setBorderColor(new Color(0, 125, 255)); // 
        lockTable.setPadding(2);// 
        lockTable.setSpacing(0);// 
        lockTable.setBorder(2);// 
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setColspan(6);
        lockTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new Cell(new Phrase("  ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        lockTable.addCell(cell);
        // lockTable.endHeaders();
        List dblock = (ArrayList) dbinfo.get("lockList");// 
        if (dblock != null && dblock.size() > 0) {
            for (int i = 0; i < dblock.size(); i++) {
                Hashtable tablesVO = (Hashtable) dblock.get(i);
                String type = (String) tablesVO.get("type");
                String desc = "";
                if ("B".equals(type)) {
                    desc = "";
                } else if ("IS".equals(type)) {
                    desc = "";
                } else if ("S".equals(type)) {
                    desc = "";
                } else if ("XS".equals(type)) {
                    desc = "";
                } else if ("U".equals(type)) {
                    desc = "";
                } else if ("IX".equals(type)) {
                    desc = "";
                } else if ("SIX".equals(type)) {
                    desc = "";
                } else if ("X".equals(type)) {
                    desc = "";
                } else if ("XR".equals(type)) {
                    desc = "";
                }
                cell = new Cell(new Phrase((i + 1) + ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("dbsname"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new Cell(new Phrase((String) tablesVO.get("tabname"), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
                cell = new Cell(new Phrase(desc, contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                lockTable.addCell(cell);
            }
        }

        document.add(lockTable);

        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

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

/**
 * @author HONGLI date 2010-11-11  doc//w w w .  jav a 2s.  co m
 */
public void createReportPingDoc(String filename) {
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
        // 
        Font titleFont = new Font(bfChinese, 12, Font.BOLD);
        // 
        Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
        String dbtype = (String) reportHash.get("dbtype");
        String ip = (String) reportHash.get("ip");
        String newip = doip(ip);
        // System.out.println("newi ========================"+newip);
        Paragraph title = new Paragraph(dbtype + "(" + ip + ")" + "", 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.setSpacingBefore(5);
        // 
        context.setFirstLineIndent(5);
        document.add(context);
        Table aTable = new Table(4);
        float[] widths = { 220f, 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));
        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("");
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // cell = new Cell(new Phrase((String)
        // maxping.get("pingmax"),contextFont));
        cell = new Cell(new Phrase(reportHash.get("pingnow") + "%", contextFont));// HONGLI
        // MODIFY
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // cell = new Cell(new Phrase((String)
        // maxping.get("ping"),contextFont));
        cell = new Cell(new Phrase(reportHash.get("pingmin") + "%", contextFont));// HONGLI
        // MODIFY
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase(reportHash.get("avgpingcon") + "%", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // 
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        document.add(aTable);
        document.add(img);
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

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

/**
 * @author HONGLI word/*from  w w  w.j  a  va 2s .co m*/
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReport_EventDoc(String filename) throws IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", 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");
        DBVo vo = (DBVo) reportHash.get("vo");
        String downnum = (String) reportHash.get("downnum");
        String count = (Integer) reportHash.get("count") + "";

        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);
        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 cell = null;
        cell = new Cell(new Phrase("", titleFont));
        cell.setColspan(5);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase("IP", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(" ", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(vo.getDbName(), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(ip, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(typename, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(downnum, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        cell = new Cell(new Phrase(count, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        dbTable.addCell(cell);
        document.add(dbTable);

        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

/**
 * @author HONGLI MySQL doc//from w w  w  .j  av  a2 s  .  c om
 * @param filename
 * @throws DocumentException
 * @throws IOException
 */
public void createReportMySQLSelfDoc(String filename) throws DocumentException, IOException {
    if (impReport.getTable() == null) {
        fileName = null;
        return;
    }
    try {
        // 
        Document document = new Document(PageSize.A4);
        // (Writer)document(Writer)
        RtfWriter2.getInstance(document, new FileOutputStream(filename));
        document.open();
        // 
        BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", 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 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");
        Vector val = (Vector) reportHash.get("Val");
        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 aTable = new Table(3);
        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));
        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((String) maxping.get("pingnow"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

        // 

        document.add(aTable);
        Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "ConnectUtilization" + ".png");
        img.setAlignment(Image.LEFT);//
        document.add(img);

        document.add(new Paragraph("\n"));
        Table aTable1 = new Table(2);
        float[] width = { 220f, 220f };
        aTable1.setWidths(width);
        aTable1.setWidth(100); //  90%
        aTable1.setAlignment(Element.ALIGN_CENTER);// 
        aTable1.setAutoFillEmptyCells(true); // 
        aTable1.setBorderWidth(1); // 
        aTable1.setBorderColor(new Color(0, 125, 255)); // 
        aTable1.setPadding(2);// 
        aTable1.setSpacing(0);// 
        aTable1.setBorder(2);// 
        cell = new Cell(new Phrase("", titleFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable1.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));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                    cell = new Cell(new Phrase(value, contextFont));
                    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                    aTable1.addCell(cell);
                }
            }
        }
        if (impReport.getChart() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            try {
                ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                        impReport.getChart().getWidth(), impReport.getChart().getHeight());
            } catch (IOException ioe) {
            }
            Image img1 = Image.getInstance(baos.toByteArray());
            img1.setAbsolutePosition(0, 0);
            img1.setAlignment(Image.MIDDLE);// 

            document.add(img1);
        }

        document.add(aTable1);
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

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   w w w . ja  va  2  s.  c  om
    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
    }
}