Example usage for java.awt Color LIGHT_GRAY

List of usage examples for java.awt Color LIGHT_GRAY

Introduction

In this page you can find the example usage for java.awt Color LIGHT_GRAY.

Prototype

Color LIGHT_GRAY

To view the source code for java.awt Color LIGHT_GRAY.

Click Source Link

Document

The color light gray.

Usage

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

public void createReport_hostNewDoc(String file) throws DocumentException, IOException {
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    // EventListDao eventListDao = new EventListDao();

    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    if (CPU == null)
        CPU = new Hashtable();
    String cpu = "";
    if (CPU.get("cpu") != null)
        cpu = (String) CPU.get("cpu");
    String cpumax = "0.0%";
    if (CPU.get("cpumax") != null)
        cpumax = (String) CPU.get("cpumax");
    String avgcpu = "";
    if (CPU.get("avgcpu") != null)
        avgcpu = (String) CPU.get("avgcpu");
    String starttime = (String) reportHash.get("starttime");
    String totime = (String) reportHash.get("totime");
    String hostname = (String) reportHash.get("equipname");
    String hostnameDoc = (String) reportHash.get("equipnameDoc");
    String ip = (String) reportHash.get("ip");
    String typename = (String) reportHash.get("typename");
    String startdate = (String) reportHash.get("startdate");
    int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue();

    int memvalue = ((Integer) reportHash.get("memvalue")).intValue();
    int diskvalue = ((Integer) reportHash.get("diskvalue")).intValue();
    int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue();

    /* String type = (String)request.getAttribute("type"); */
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(file));
    document.open();//  w  w w.  ja  v  a  2  s .  c  o  m
    // 
    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);

    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 

    aTable.endHeaders();
    Cell cell = null;
    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell = new Cell(new Phrase("\n" + starttime + "  " + totime + "\n", contextFont));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(hostnameDoc, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(ip, contextFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase("\n" + grade + "\n", contextFont));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(avgcpu, contextFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("CPU", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(cpumax, contextFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    String avgvalue = "0.0%";
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    if (memAvgHash.get("PhysicalMemory") != null) {

        avgvalue = (String) memAvgHash.get("PhysicalMemory");
        cell = new Cell(new Phrase(avgvalue, contextFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    } else {
        cell = new Cell(new Phrase(avgvalue, contextFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    }
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String value = "0.0%";
    if (memMaxHash.get("PhysicalMemory") != null) {

        value = (String) memMaxHash.get("PhysicalMemory");
        cell = new Cell(new Phrase(value, contextFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    } else {
        cell = new Cell(new Phrase(value, contextFont));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    }

    // end 

    // end  }
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(4);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "" + memvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + diskvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String strcpu = "";
    String strmem = "";
    String strping = "";
    String strdisk = "";
    if (cpuvalue > 0) {
        strcpu = "    2   " + cpuvalue + "CPU" + "\n"
                + "\n";
    } else {
        strcpu = "    2   CPU" + " \n" + "\n";
    }
    if (memvalue > 0) {
        strmem = "    3   " + memvalue + "" + "\n" + "\n";
    } else {
        strmem = "    3   " + "\n" + "\n";
    }
    if (pingvalue > 0) {
        strping = "    4   " + pingvalue + "" + "\n"
                + "\n";
    } else {
        strping = "    4   " + "\n" + "\n";
    }
    if (diskvalue > 0) {

        strdisk = "    5   " + diskvalue + "";
    } else {
        strdisk = "    5   ";
    }

    cell = new Cell(new Phrase("    1   " + " \n" + "\n"
            + strcpu + strmem + strping + strdisk + "\n" + "\n" + "\n", contextFont)

    );
    cell.setColspan(8);
    aTable.addCell(cell);
    document.add(aTable);
    document.close();

}

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

public void createReport_hostNewPDF(String file) throws DocumentException, IOException {
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    // EventListDao eventListDao = new EventListDao();

    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    if (CPU == null)
        CPU = new Hashtable();
    String cpu = "";
    if (CPU.get("cpu") != null)
        cpu = (String) CPU.get("cpu");
    String cpumax = "0.0%";
    if (CPU.get("cpumax") != null)
        cpumax = (String) CPU.get("cpumax");
    String avgcpu = "";
    if (CPU.get("avgcpu") != null)
        avgcpu = (String) CPU.get("avgcpu");
    String starttime = (String) reportHash.get("starttime");
    String totime = (String) reportHash.get("totime");
    String hostname = (String) reportHash.get("equipname");
    String hostnameDoc = (String) reportHash.get("equipnameDoc");
    String ip = (String) reportHash.get("ip");
    String typename = (String) reportHash.get("typename");
    String startdate = (String) reportHash.get("startdate");
    int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue();
    int memvalue = ((Integer) reportHash.get("memvalue")).intValue();
    int diskvalue = ((Integer) reportHash.get("diskvalue")).intValue();
    int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue();

    /* String type = (String)request.getAttribute("type"); */
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    PdfWriter.getInstance(document, new FileOutputStream(file));
    document.open();/*  ww w  .  j  a v a  2 s  .c om*/
    // 
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);

    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
    Font contextFont1 = new Font(bfChinese, 10, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 

    aTable.endHeaders();
    Cell cell = null;
    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_CENTER);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell = new Cell(new Phrase("\n" + starttime + "  " + totime + "\n", contextFont1));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(hostnameDoc, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(ip));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase("\n" + grade + "\n", contextFont));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(avgcpu));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("CPU", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(cpumax));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    String avgvalue = "0.0%";
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    if (memAvgHash.get("PhysicalMemory") != null) {

        avgvalue = (String) memAvgHash.get("PhysicalMemory");
        cell = new Cell(new Phrase(avgvalue));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    } else {
        cell = new Cell(new Phrase(avgvalue));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    }
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String value = "0.0%";
    if (memMaxHash.get("PhysicalMemory") != null) {

        value = (String) memMaxHash.get("PhysicalMemory");
        cell = new Cell(new Phrase(value));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    } else {
        cell = new Cell(new Phrase(value));
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
    }

    // end 

    // end  }
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(4);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "" + memvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + diskvalue + "" + "\n", contextFont));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String strcpu = "";
    String strmem = "";
    String strping = "";
    String strdisk = "";
    if (cpuvalue > 0) {
        strcpu = "    2   " + cpuvalue + "CPU" + "\n"
                + "\n";
    } else {
        strcpu = "    2   CPU" + " \n" + "\n";
    }
    if (memvalue > 0) {
        strmem = "    3   " + memvalue + "" + "\n" + "\n";
    } else {
        strmem = "    3   " + "\n" + "\n";
    }
    if (pingvalue > 0) {
        strping = "    4   " + pingvalue + "" + "\n"
                + "\n";
    } else {
        strping = "    4   " + "\n" + "\n";
    }
    if (diskvalue > 0) {

        strdisk = "    5   " + diskvalue + "";
    } else {
        strdisk = "    5   ";
    }

    cell = new Cell(new Phrase("    1   " + " \n" + "\n"
            + strcpu + strmem + strping + strdisk + "\n" + "\n" + "\n", contextFont)

    );
    /*
     * cell = new Cell(new Phrase(" 1 " + " \n" +
     * "\n" + " 2 " + cpuvalue + "CPU" + "\n" +
     * "\n" + " 3 "+memvalue+"" + "\n" +
     * "\n" + " 4 "+pingvalue+"" + "\n" +
     * "\n"+" 5 "+diskvalue+"" + "\n" + "\n"+
     * "\n",contextFont) );
     */
    cell.setColspan(8);
    aTable.addCell(cell);
    document.add(aTable);
    document.close();

}

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

public void createReport_hostDoc(String file) throws DocumentException, IOException {
    String starttime = (String) reportHash.get("starttime");
    String totime = (String) reportHash.get("totime");

    String hostname = (String) reportHash.get("equipname");
    String ip = (String) reportHash.get("ip");
    String newip = doip(ip);// www .  j a v a 2  s  .c o  m
    // WritableSheet sheet = wb.createSheet(hostname + "", 0);
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    if (CPU == null)
        CPU = new Hashtable();
    String Ping = (String) reportHash.get("Ping");
    Calendar colTime = (Calendar) reportHash.get("time");
    Date cc = colTime.getTime();
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    Hashtable Disk = (Hashtable) reportHash.get("Disk");

    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable maxping = (Hashtable) reportHash.get("ping");

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

    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    String[] diskItem = { "AllSize", "UsedSize", "Utilization" };
    String[] diskItemch = { "", "", "" };
    // 
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(file));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 10, Font.NORMAL);
    Paragraph title = new Paragraph(hostname + "", titleFont);
    // 
    title.setAlignment(Element.ALIGN_CENTER);
    // title.setFont(titleFont);
    document.add(title);
    String contextString = ":" + impReport.getTimeStamp() + " \n"// 
            + ":" + starttime + "  " + totime;
    Paragraph context = new Paragraph(contextString, titleFont);
    // 
    context.setAlignment(Element.ALIGN_LEFT);
    // context.setFont(contextFont);
    // 
    context.setSpacingBefore(5);
    // 
    context.setFirstLineIndent(5);
    document.add(context);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(4);
    float[] widths = { 220f, 300f, 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 = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    aTable.addCell(Ping + "%");
    aTable.addCell((String) maxping.get("pingmax"));
    aTable.addCell((String) maxping.get("avgpingcon"));
    Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
            + newip + "ConnectUtilization" + ".png");
    img.setAbsolutePosition(0, 0);
    img.setAlignment(Image.LEFT);// 
    document.add(aTable);
    document.add(img);

    String cpu = "";
    if (CPU.get("cpu") != null)
        cpu = (String) CPU.get("cpu");
    String cpumax = "";
    if (CPU.get("cpumax") != null)
        cpumax = (String) CPU.get("cpumax");
    String avgcpu = "";
    if (CPU.get("avgcpu") != null)
        avgcpu = (String) CPU.get("avgcpu");
    Table aTable1 = new Table(4);
    float[] width = { 220f, 300f, 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);// 
    aTable1.endHeaders();

    cell = new Cell();
    cell.addElement(new Paragraph("CPU", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(cell);

    aTable1.addCell(cpu + "%");
    aTable1.addCell(cpumax);
    aTable1.addCell(avgcpu);

    Image img1 = Image.getInstance(
            ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png");
    img.setAbsolutePosition(0, 0);
    img.setAlignment(Image.MIDDLE);// 
    document.add(aTable1);
    document.add(img1);

    if (Memory != null && Memory.size() > 0) {
        Table aTable2 = new Table(6);
        float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f };
        aTable2.setWidths(widthss);
        aTable2.setWidth(100); //  90%
        aTable2.setAlignment(Element.ALIGN_CENTER);// 
        aTable2.setAutoFillEmptyCells(true); // 
        aTable2.setBorderWidth(1); // 
        aTable2.setBorderColor(new Color(0, 125, 255)); // 
        aTable2.setPadding(2);// 
        aTable2.setSpacing(0);// 
        aTable2.setBorder(2);// 
        aTable2.endHeaders();
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable2.addCell(cell);
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable2.addCell(cell);
        // 

        for (int i = 0; i < memoryItemch.length; i++) {
            cell = new Cell(memoryItemch[i]);
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            // cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            aTable2.addCell(cell);
        }
        // 
        for (int i = 0; i < Memory.size(); i++) {
            aTable2.addCell("");
            Hashtable mhash = (Hashtable) (Memory.get(new Integer(i)));
            String name = (String) mhash.get("name");
            Cell cell1 = new Cell(name);
            aTable2.addCell(cell1);
            for (int j = 0; j < memoryItem.length; j++) {
                String value = "";
                if (mhash.get(memoryItem[j]) != null) {
                    value = (String) mhash.get(memoryItem[j]);
                }
                Cell cell2 = new Cell(value);
                aTable2.addCell(cell2);
            }
            String value = "";
            if (memMaxHash.get(name) != null) {
                value = (String) memMaxHash.get(name);
                Cell cell3 = new Cell(value);
                aTable2.addCell(cell3);
            }
            String avgvalue = "";
            if (memAvgHash.get(name) != null) {
                avgvalue = (String) memAvgHash.get(name);
                aTable2.addCell(avgvalue);
            }

        } // end 
          // 
        Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "memory" + ".png");
        img.setAbsolutePosition(0, 0);
        img.setAlignment(Image.MIDDLE);// 
        document.add(aTable2);
        document.add(img2);
    } else {
        Table aTable2 = new Table(6);
        float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f };
        aTable2.setWidths(widthss);
        aTable2.setWidth(100); //  90%
        aTable2.setAlignment(Element.ALIGN_CENTER);// 
        aTable2.setAutoFillEmptyCells(true); // 
        aTable2.setBorderWidth(1); // 
        aTable2.setBorderColor(new Color(0, 125, 255)); // 
        aTable2.setPadding(2);// 
        aTable2.setSpacing(0);// 
        aTable2.setBorder(2);// 
        aTable2.endHeaders();
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable2.addCell(cell);
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable2.addCell(cell);
        // 

        for (int i = 0; i < memoryItemch.length; i++) {
            cell = new Cell(memoryItemch[i]);
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            aTable2.addCell(cell);
        }
        // 
        String[] names = null;
        HostNodeDao dao = new HostNodeDao();
        HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0);
        // Monitoriplist monitor = monitorManager.getByIpaddress(ip);
        if (node.getSysOid().startsWith("1.3.6.1.4.1.311")) {
            names = new String[] { "PhysicalMemory", "VirtualMemory" };
        } else {
            names = new String[] { "PhysicalMemory", "SwapMemory" };
        }
        for (int i = 0; i < names.length; i++) {
            String name = names[i];
            aTable2.addCell("");
            cell = new Cell(names[i]);
            aTable2.addCell(cell);

            for (int j = 0; j < memoryItem.length; j++) {
                // 
                String value = "";
                Cell cell1 = new Cell(value);
                aTable2.addCell(cell1);
            }
            String value = "";
            if (memMaxHash.get(name) != null) {
                value = (String) memMaxHash.get(name);
                Cell cell2 = new Cell(value);
                aTable2.addCell(cell2);
            } else {
                Cell cell3 = new Cell(value);
                aTable2.addCell(cell3);
            }
            String avgvalue = "";
            if (memAvgHash.get(name) != null) {
                avgvalue = (String) memAvgHash.get(name);
                Cell cell4 = new Cell(avgvalue);
                aTable2.addCell(cell4);
            } else {
                Cell cell5 = new Cell(avgvalue);
                aTable2.addCell(cell5);
            }

        } // end 
          // 
        Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "memory" + ".png");
        img.setAbsolutePosition(0, 0);
        img.setAlignment(Image.MIDDLE);// 
        document.add(aTable2);
        document.add(img2);

    }
    Table aTable3 = new Table(5);
    float[] widthss1 = { 220f, 440f, 150f, 150f, 220f };
    aTable3.setWidths(widthss1);
    aTable3.setWidth(100); //  90%
    aTable3.setAlignment(Element.ALIGN_CENTER);// 
    aTable3.setAutoFillEmptyCells(true); // 
    aTable3.setBorderWidth(1); // 
    aTable3.setBorderColor(new Color(0, 125, 255)); // 
    aTable3.setPadding(2);// 
    aTable3.setSpacing(0);// 
    aTable3.setBorder(2);// 
    aTable3.endHeaders();
    if (Disk != null && Disk.size() > 0) {
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable3.addCell(cell);
        cell = new Cell("");
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable3.addCell(cell);

        for (int i = 0; i < diskItemch.length; i++) {
            cell = new Cell(diskItemch[i]);
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            aTable3.addCell(cell);
        }
        // 

        for (int i = 0; i < Disk.size(); i++) {
            aTable3.addCell("");
            Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i)));
            String name = (String) diskhash.get("name");
            cell = new Cell(name);
            aTable3.addCell(cell);
            for (int j = 0; j < diskItem.length; j++) {
                String value = "";
                if (diskhash.get(diskItem[j]) != null) {
                    value = (String) diskhash.get(diskItem[j]);
                }
                Cell cell1 = new Cell(value);
                // System.out.println(value+"================value===============");
                aTable3.addCell(cell1);
            }
        } // end 
          // 
        Image img3 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "disk" + ".png");
        img.setAbsolutePosition(0, 0);
        img.setAlignment(Image.MIDDLE);// 
        document.add(aTable3);
        document.add(img3);

    }
    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 img3 = Image.getInstance(baos.toByteArray());
        img.setAbsolutePosition(0, 0);
        img.setAlignment(Image.MIDDLE);// 

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

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

public void createReport_hostPDF(String file) throws DocumentException, IOException {

    String starttime = (String) reportHash.get("starttime");
    String totime = (String) reportHash.get("totime");

    String hostname = (String) reportHash.get("equipname");
    String ip = (String) reportHash.get("ip");
    String newip = doip(ip);/* www.  j  a v a  2  s. c  o m*/
    // WritableSheet sheet = wb.createSheet(hostname + "", 0);
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    if (CPU == null)
        CPU = new Hashtable();
    String Ping = (String) reportHash.get("Ping");
    Calendar colTime = (Calendar) reportHash.get("time");
    Date cc = colTime.getTime();
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    Hashtable Disk = (Hashtable) reportHash.get("Disk");

    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable maxping = (Hashtable) reportHash.get("ping");

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

    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    String[] diskItem = { "AllSize", "UsedSize", "Utilization" };
    String[] diskItemch = { "", "", "" };
    // 
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    PdfWriter.getInstance(document, new FileOutputStream(file));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 10, Font.NORMAL);
    Paragraph title = new Paragraph(hostname + "", titleFont);
    // 
    title.setAlignment(Element.ALIGN_CENTER);
    // title.setFont(titleFont);
    document.add(title);

    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);
    document.add(new Phrase("\n"));
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(4);
    aTable.setAutoFillEmptyCells(true);
    aTable.setWidth(100);
    // float[] widths = { 220f, 300f, 220f, 220f };
    // aTable.setWidths(widths);
    aTable.setPadding(5);
    // aTable.setWidthPercentage(100);

    Cell cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    aTable.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    aTable.addCell(Ping + "%");
    aTable.addCell((String) maxping.get("pingmax"));
    aTable.addCell((String) maxping.get("avgpingcon"));
    Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
            + newip + "ConnectUtilization" + ".png");

    img.setAlignment(Image.LEFT);// 
    img.scalePercent(75);
    document.add(aTable);
    document.add(img);

    String cpu = "";
    if (CPU.get("cpu") != null)
        cpu = (String) CPU.get("cpu");
    String cpumax = "";
    if (CPU.get("cpumax") != null)
        cpumax = (String) CPU.get("cpumax");
    String avgcpu = "";
    if (CPU.get("avgcpu") != null)
        avgcpu = (String) CPU.get("avgcpu");
    Table aTable1 = new Table(4);
    aTable1.setAutoFillEmptyCells(true);
    aTable1.setWidth(100);
    aTable1.setPadding(5);
    // float[] width = { 220f, 300f, 220f, 220f };
    // aTable1.setWidths(width);
    // aTable1.setWidthPercentage(100);

    cell = new Cell();
    cell.addElement(new Paragraph("CPU", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    aTable1.addCell(cell);
    cell = new Cell();
    cell.addElement(new Paragraph("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    aTable1.addCell(cell);

    aTable1.addCell(cpu + "%");
    aTable1.addCell(cpumax);
    aTable1.addCell(avgcpu);

    Image img1 = Image.getInstance(
            ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png");
    img.setAlignment(Image.MIDDLE);// 
    img1.scalePercent(75);
    document.add(aTable1);
    document.add(img1);

    if (Memory != null && Memory.size() > 0) {
        Table aTable2 = new Table(6);
        aTable2.setPadding(5);
        aTable2.setAutoFillEmptyCells(true);
        aTable2.setWidth(100);
        // float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f };
        // aTable2.setWidths(widthss);
        // aTable2.setWidthPercentage(100);
        cell = new Cell(new Phrase("", contextFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);

        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("", contextFont));

        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable2.addCell(cell);
        // 

        for (int i = 0; i < memoryItemch.length; i++) {
            cell = new Cell(new Phrase(memoryItemch[i], contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            aTable2.addCell(cell);
        }
        // 
        for (int i = 0; i < Memory.size(); i++) {
            aTable2.addCell("");
            Hashtable mhash = (Hashtable) (Memory.get(new Integer(i)));
            String name = (String) mhash.get("name");
            cell = new Cell(new Phrase(name));

            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable2.addCell(cell);
            for (int j = 0; j < memoryItem.length; j++) {
                String value = "";
                if (mhash.get(memoryItem[j]) != null) {
                    value = (String) mhash.get(memoryItem[j]);
                }
                cell = new Cell(new Phrase(value));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                aTable2.addCell(cell);
            }
            String value = "";
            if (memMaxHash.get(name) != null) {
                value = (String) memMaxHash.get(name);
                Cell cell3 = new Cell(new Phrase(value));
                cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                aTable2.addCell(cell3);
            }
            String avgvalue = "";
            if (memAvgHash.get(name) != null) {
                avgvalue = (String) memAvgHash.get(name);
                cell = new Cell(new Phrase(avgvalue));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                aTable2.addCell(cell);
            }

        } // end 
          // 
        Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "memory" + ".png");
        img.setAlignment(Image.MIDDLE);// 
        img2.scalePercent(75);
        document.add(aTable2);
        document.add(img2);
    } else {
        Table aTable2 = new Table(6);

        float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f };
        aTable2.setWidths(widthss);
        // aTable2.setWidthPercentage(100);
        /*
         * aTable2.setWidth(100); //  90%
         * aTable2.setAlignment(Element.ALIGN_CENTER);// 
         * aTable2.setAutoFillEmptyCells(true); // 
         * aTable2.setBorderWidth(1); //  aTable2.setBorderColor(new
         * Color(0, 125, 255)); //  aTable2.setPadding(2);//
         *  aTable2.setSpacing(0);// 
         * aTable2.setBorder(2);//  aTable2.endHeaders();
         */
        cell = new Cell(new Phrase("", contextFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        aTable2.addCell(cell);
        cell = new Cell(new Phrase("", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable2.addCell(cell);
        // 

        for (int i = 0; i < memoryItemch.length; i++) {
            cell = new Cell(new Phrase(memoryItemch[i], contextFont));
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable2.addCell(cell);
        }
        // 
        String[] names = null;
        HostNodeDao dao = new HostNodeDao();
        HostNode node = (HostNode) dao.findByCondition("ip_address", ip).get(0);
        // Monitoriplist monitor = monitorManager.getByIpaddress(ip);
        if (node.getSysOid().startsWith("1.3.6.1.4.1.311")) {
            names = new String[] { "PhysicalMemory", "VirtualMemory" };
        } else {
            names = new String[] { "PhysicalMemory", "SwapMemory" };
        }
        for (int i = 0; i < names.length; i++) {
            String name = names[i];
            aTable2.addCell("");
            cell = new Cell(new Phrase(names[i]));

            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable2.addCell(cell);

            for (int j = 0; j < memoryItem.length; j++) {
                // 
                String value = "";
                cell = new Cell(new Phrase(value));

                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                aTable2.addCell(cell);
            }
            String value = "";
            if (memMaxHash.get(name) != null) {
                value = (String) memMaxHash.get(name);
                Cell cell2 = new Cell(new Phrase(value));
                cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell2.setVerticalAlignment(Element.ALIGN_MIDDLE);
                aTable2.addCell(cell2);
            } else {
                Cell cell3 = new Cell(new Phrase(value));
                cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell3.setVerticalAlignment(Element.ALIGN_MIDDLE);
                aTable2.addCell(cell3);
            }
            String avgvalue = "";
            if (memAvgHash.get(name) != null) {
                avgvalue = (String) memAvgHash.get(name);
                Cell cell4 = new Cell(new Phrase(avgvalue));
                cell4.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell4.setVerticalAlignment(Element.ALIGN_MIDDLE);
                aTable2.addCell(cell4);
            } else {
                Cell cell5 = new Cell(new Phrase(avgvalue));
                cell5.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell5.setVerticalAlignment(Element.ALIGN_MIDDLE);
                aTable2.addCell(cell5);
            }

        } // end 
          // 
        Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "memory" + ".png");
        img.setAlignment(Image.MIDDLE);// 
        img2.scalePercent(75);
        document.add(aTable2);
        document.add(img2);
    }
    Table aTable3 = new Table(5);
    aTable3.setAutoFillEmptyCells(true);
    aTable3.setPadding(5);
    aTable3.setWidth(100);
    // float[] widthss1 = { 220f, 440f, 150f, 150f, 220f };
    // aTable3.setWidths(widthss1);
    // aTable3.setWidthPercentage(100);
    if (Disk != null && Disk.size() > 0) {
        cell = new Cell(new Phrase("", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable3.addCell(cell);
        cell = new Cell(new Phrase("", contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER);
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        aTable3.addCell(cell);
        for (int i = 0; i < diskItemch.length; i++) {
            cell = new Cell(new Phrase(diskItemch[i], contextFont));
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable3.addCell(cell);
        }
        // 

        for (int i = 0; i < Disk.size(); i++) {
            aTable3.addCell("");
            Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i)));
            String name = (String) diskhash.get("name");
            cell = new Cell(new Phrase(name));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER);
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
            aTable3.addCell(cell);
            for (int j = 0; j < diskItem.length; j++) {
                String value = "";
                if (diskhash.get(diskItem[j]) != null) {
                    value = (String) diskhash.get(diskItem[j]);
                }
                cell = new Cell(new Phrase(value));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER);
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                aTable3.addCell(cell);
            }
        } // end 
          // 

        Image img3 = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
                + newip + "disk" + ".png");
        img3.setAlignment(Image.MIDDLE);// 
        img3.scalePercent(78);
        document.add(aTable3);
        // document.add(new Paragraph("\n"));
        document.add(img3);

    }
    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 img3 = Image.getInstance(baos.toByteArray());
        img3.setAlignment(Image.MIDDLE);// 
        img3.scalePercent(76);
        document.add(new Paragraph("\n"));
        // document.add(aTable3);
        document.add(img3);
    }
    document.close();
}

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

public void createReport_networkNewDoc(String file) throws DocumentException, IOException {
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    // EventListDao eventListDao = new EventListDao();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Calendar colTime = (Calendar) reportHash.get("time");
    Date cc = colTime.getTime();/*from ww w  .j a va  2s  .co  m*/
    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    if (CPU == null)
        CPU = new Hashtable();
    String cpu = "";
    if (CPU.get("cpu") != null)
        cpu = (String) CPU.get("cpu");
    String cpumax = "";
    if (CPU.get("cpumax") != null)
        cpumax = (String) CPU.get("cpumax");
    String avgcpu = "";
    if (CPU.get("avgcpu") != null)
        avgcpu = (String) CPU.get("avgcpu");

    String totime = (String) reportHash.get("totime");
    String hostname = (String) reportHash.get("equipname");
    String ip = (String) reportHash.get("ip");
    String typename = (String) reportHash.get("typename");
    String equipnameNetDoc = (String) reportHash.get("equipnameNetDoc");
    String startdate = (String) reportHash.get("startdate");
    String todate = (String) reportHash.get("todate");
    String starttime = (String) reportHash.get("starttime");
    String avginput = (String) reportHash.get("avginput");
    String avgoutput = (String) reportHash.get("avgoutput");
    String maxinput = (String) reportHash.get("maxinput");
    String maxoutput = (String) reportHash.get("maxoutput");

    int updownvalue = ((Integer) reportHash.get("updownvalue")).intValue();

    int utilvalue = ((Integer) reportHash.get("utilvalue")).intValue();
    int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue();
    int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue();

    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(file));
    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.BOLD);
    Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 

    aTable.endHeaders();
    Cell cell = null;
    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    /* cell.setVerticalAlignment(Element.ALIGN_CENTER); */
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell = new Cell(new Phrase("\n" + starttime + "  " + totime + "\n", contextFont1));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(equipnameNetDoc, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(ip, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase("\n" + grade + "\n", contextFont1));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(3);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + "\n", contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell = new Cell(new Phrase(avgcpu, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("CPU", contextFont));
    cell.setColspan(2);
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(cpumax, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "(KB/S)" + "\n", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + avginput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("(KB/S)", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + maxinput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + avgoutput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + maxoutput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(4);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + updownvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + utilvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "" + "\n", contextFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String strcpu = "";
    String strutil = "";
    String strping = "";
    String strupdown = "";
    if (cpuvalue > 0) {
        strcpu = "    2   " + cpuvalue + "CPU" + "\n"
                + "\n";
    } else {
        strcpu = "    2   CPU" + " \n" + "\n";
    }
    if (utilvalue > 0) {
        strutil = "3   " + utilvalue
                + "" + "\n"
                + "\n";
    } else {
        strutil = "    3   " + "\n" + "\n";
    }
    if (updownvalue > 0) {
        strupdown = "    4   " + updownvalue + "" + "\n"
                + "\n";
    } else {
        strupdown = "    4   " + "\n" + "\n";
    }
    if (pingvalue > 0) {

        strping = "    5   " + pingvalue + "";
    } else {
        strping = "    5   ";
    }

    cell = new Cell(new Phrase("    1   " + " \n" + "\n"
            + strcpu + strutil + strupdown + strping + "\n" + "\n" + "\n", contextFont1)

    );

    cell.setColspan(8);
    aTable.addCell(cell);
    document.add(aTable);
    document.close();
}

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

public void createReport_networkNewPdf(String file) throws DocumentException, IOException {
    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    // EventListDao eventListDao = new EventListDao();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    Calendar colTime = (Calendar) reportHash.get("time");
    Date cc = colTime.getTime();/*from   w w  w  .  ja va2s .c o  m*/
    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable memAvgHash = (Hashtable) reportHash.get("memavghash");
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    String[] memoryItemch = { "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    if (CPU == null)
        CPU = new Hashtable();
    String cpu = "";
    if (CPU.get("cpu") != null)
        cpu = (String) CPU.get("cpu");
    String cpumax = "";
    if (CPU.get("cpumax") != null)
        cpumax = (String) CPU.get("cpumax");
    String avgcpu = "";
    if (CPU.get("avgcpu") != null)
        avgcpu = (String) CPU.get("avgcpu");

    String totime = (String) reportHash.get("totime");
    String hostname = (String) reportHash.get("equipname");
    String ip = (String) reportHash.get("ip");
    String typename = (String) reportHash.get("typename");
    String equipnameNetDoc = (String) reportHash.get("equipnameNetDoc");
    String startdate = (String) reportHash.get("startdate");
    String todate = (String) reportHash.get("todate");
    String starttime = (String) reportHash.get("starttime");
    String avginput = (String) reportHash.get("avginput");
    String avgoutput = (String) reportHash.get("avgoutput");
    String maxinput = (String) reportHash.get("maxinput");
    String maxoutput = (String) reportHash.get("maxoutput");

    int updownvalue = ((Integer) reportHash.get("updownvalue")).intValue();

    int utilvalue = ((Integer) reportHash.get("utilvalue")).intValue();
    int pingvalue = ((Integer) reportHash.get("pingvalue")).intValue();
    int cpuvalue = ((Integer) reportHash.get("cpuvalue")).intValue();

    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    PdfWriter.getInstance(document, new FileOutputStream(file));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);

    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
    Font contextFont2 = new Font(bfChinese, 10, Font.NORMAL);
    Font contextFont1 = new Font(bfChinese, 12, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(8);
    float[] widths = { 220f, 220f, 220f, 110f, 110f, 110f, 110f, 220f };
    aTable.setWidths(widths);
    aTable.setWidth(100); //  90%
    aTable.setAlignment(Element.ALIGN_CENTER);// 
    aTable.setAutoFillEmptyCells(true); // 
    aTable.setBorderWidth(1); // 
    aTable.setBorderColor(new Color(0, 125, 255)); // 
    aTable.setPadding(2);// 
    aTable.setSpacing(0);// 
    aTable.setBorder(2);// 

    aTable.endHeaders();
    aTable.setWidths(widths);
    Cell cell = null;
    cell = new Cell(new Phrase("\n" + "" + hostname + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    /* cell.setVerticalAlignment(Element.ALIGN_CENTER); */
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(cell);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell = new Cell(new Phrase("\n" + starttime + "  " + totime + "\n", contextFont2));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(equipnameNetDoc, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);

    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(ip));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(typename, contextFont1));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String grade = (String) reportHash.get("grade");
    cell = new Cell(new Phrase("\n" + grade + "\n", contextFont1));
    cell.setColspan(7);

    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(3);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase(avgcpu, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("CPU", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase(cpumax, contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "(KB/S)" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + avginput.replace(".0", ""), contextFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("(KB/S)", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + maxinput.replace(".0", ""), contextFont));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + avgoutput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + maxoutput.replace(".0", ""), contextFont1));
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(4);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + pingvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "CPU" + cpuvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + updownvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("\n" + "" + utilvalue + "" + "\n", contextFont1));
    cell.setColspan(7);
    aTable.addCell(cell);

    cell = new Cell(new Phrase("\n" + "" + "\n", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(8);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String strcpu = "";
    String strutil = "";
    String strping = "";
    String strupdown = "";
    if (cpuvalue > 0) {
        strcpu = "    2   " + cpuvalue + "CPU" + "\n"
                + "\n";
    } else {
        strcpu = "    2   CPU" + " \n" + "\n";
    }
    if (utilvalue > 0) {
        strutil = "3   " + utilvalue
                + "" + "\n"
                + "\n";
    } else {
        strutil = "    3   " + "\n" + "\n";
    }
    if (updownvalue > 0) {
        strupdown = "    4   " + updownvalue + "" + "\n"
                + "\n";
    } else {
        strupdown = "    4   " + "\n" + "\n";
    }
    if (pingvalue > 0) {

        strping = "    5   " + pingvalue + "";
    } else {
        strping = "    5   ";
    }

    cell = new Cell(new Phrase("    1   " + " \n" + "\n"
            + strcpu + strutil + strupdown + strping + "\n" + "\n" + "\n", contextFont)

    );

    cell.setColspan(8);
    aTable.addCell(cell);
    document.add(aTable);
    document.close();
}

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

public void createReport_networkPDF(String file) throws DocumentException, IOException {
    String runmodel = PollingEngine.getCollectwebflag();
    Hashtable CPU = (Hashtable) reportHash.get("CPU");
    String Ping = (String) reportHash.get("Ping");
    String ip = (String) reportHash.get("ip");
    String newip = doip(ip);//www. j a va 2 s .  c o m
    Calendar colTime = (Calendar) reportHash.get("time");
    Date cc = colTime.getTime();
    Vector netifVector = (Vector) reportHash.get("netifVector");
    Hashtable portconfigHash = (Hashtable) reportHash.get("portconfigHash");
    List reportports = (List) reportHash.get("reportports");
    Vector iprouterVector = (Vector) reportHash.get("iprouterVector");

    Hashtable Memory = (Hashtable) reportHash.get("Memory");
    Hashtable Disk = (Hashtable) reportHash.get("Disk");
    String hostname = (String) reportHash.get("equipname");
    Hashtable memMaxHash = (Hashtable) reportHash.get("memmaxhash");
    Hashtable maxping = (Hashtable) reportHash.get("ping");

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

    String[] netIfItemch = { "", "", "", "(M)(KB/S)", "", "(KB/S)",
            "(KB/S)" };
    String[] ipRouterItemch = { "", "", "", "", "", "" };
    String[] memoryItem = { "Capability", "Utilization" };
    String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize", "INodeUtilization" };
    String[] diskItemch = { "", "", "", "i-node", "i-node" };
    String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" };
    String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)", "ggp(6)",
            "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)", "bbnSpfIgp(12)", "ospf(13)",
            "bgp(14)" };
    // 
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    PdfWriter.getInstance(document, new FileOutputStream(file));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
    BaseFont bfChinese1 = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 10, Font.NORMAL);

    Paragraph title = new Paragraph(hostname + "", titleFont);
    // 
    title.setAlignment(Element.ALIGN_CENTER);
    // title.setFont(titleFont);
    document.add(title);
    String contextString = ":" + impReport.getTimeStamp() + " \n"// 
            + ":" + sdf.format(cc);

    Paragraph context = new Paragraph(new Phrase(contextString, titleFont));
    // 
    context.setAlignment(Element.ALIGN_CENTER);
    // context.setFont(contextFont);
    // 
    context.setSpacingBefore(5);
    // 
    context.setFirstLineIndent(5);
    document.add(context);
    document.add(new Paragraph("\n"));
    //  Table 
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    Table aTable = new Table(4);
    // PdfPTable pdfPTable = new PdfPTable(aTable);
    // float[] widths = { 220f, 300f, 220f, 220f };
    // aTable.setWidths(widths);
    // aTable.setWidthPercentage(100);
    aTable.setWidth(100);
    // 
    aTable.setPadding(5);
    aTable.setAutoFillEmptyCells(true);
    Cell pc1 = new Cell(new Phrase("", contextFont));
    // pc1.setRowspan(2);
    Cell pc2 = new Cell(new Phrase("", contextFont));
    Cell pc3 = new Cell(new Phrase("", contextFont));
    Cell pc4 = new Cell(new Phrase("", contextFont));
    pc1.setBackgroundColor(Color.LIGHT_GRAY);
    pc2.setBackgroundColor(Color.LIGHT_GRAY);
    pc3.setBackgroundColor(Color.LIGHT_GRAY);
    pc4.setBackgroundColor(Color.LIGHT_GRAY);
    aTable.addCell(pc1);
    aTable.addCell(pc2);
    aTable.addCell(pc3);
    aTable.addCell(pc4);
    // aTable.addCell("3.2",Ping+"%");
    aTable.addCell("");
    aTable.addCell(Ping + "%");
    aTable.addCell((String) maxping.get("pingmax"));
    aTable.addCell((String) maxping.get("avgpingcon"));
    Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/"
            + newip + "ConnectUtilization" + ".png");
    // img.setAbsolutePosition(0, 0);
    img.setAlignment(Image.LEFT);// 
    img.scalePercent(76);
    document.add(aTable);
    document.add(img);
    document.add(new Paragraph("\n"));

    // document.add(new Paragraph("\n"));
    // document.close();
    Table aTable1 = new Table(4);
    aTable1.setWidth(100);
    // 
    aTable1.setPadding(5);
    aTable1.setAutoFillEmptyCells(true);
    // float[] width = { 220f, 300f, 220f, 220f };
    // aTable1.setWidths(width);
    // aTable1.setWidthPercentage(100);
    // aTable.addCell("3.2",Ping+"%");
    pc1 = new Cell(new Phrase("CPU", contextFont));
    // pc1.setRowspan(2);
    pc2 = new Cell(new Phrase("", contextFont));
    pc3 = new Cell(new Phrase("", contextFont));
    pc4 = new Cell(new Phrase("", contextFont));
    pc1.setBackgroundColor(Color.LIGHT_GRAY);
    pc2.setBackgroundColor(Color.LIGHT_GRAY);
    pc3.setBackgroundColor(Color.LIGHT_GRAY);
    pc4.setBackgroundColor(Color.LIGHT_GRAY);
    aTable1.addCell(pc1);
    aTable1.addCell(pc2);
    aTable1.addCell(pc3);
    aTable1.addCell(pc4);
    aTable1.addCell("");
    aTable1.addCell((String) CPU.get("cpu") + "%");
    aTable1.addCell((String) CPU.get("cpumax"));
    aTable1.addCell((String) CPU.get("avgcpu"));

    Image img1 = Image.getInstance(
            ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "cpu" + ".png");
    // img.setAbsolutePosition(0, 0);
    img1.setAlignment(Image.MIDDLE);// 
    img1.scalePercent(76);
    document.add(aTable1);
    document.add(img1);
    document.add(new Paragraph("\n"));
    if (netifVector != null && netifVector.size() > 0) {
        Table aTable2 = new Table(8);
        aTable2.setWidth(100);
        // 
        aTable2.setPadding(5);
        aTable2.setAutoFillEmptyCells(true);
        // float[] width2 = { 300f, 220f, 220f, 180f, 300f, 180f, 220f, 220f
        // };
        // aTable2.setWidths(width2);
        // aTable2.setWidthPercentage(100);
        // aTable2.setHeaderRows(1);
        Cell ct = new Cell(new Phrase("", contextFont));
        // ct.setRowspan(netifVector.size() + 1);
        ct.setBackgroundColor(Color.lightGray);
        ct.setHorizontalAlignment(Element.ALIGN_CENTER);
        ct.setVerticalAlignment(Element.ALIGN_MIDDLE);
        aTable2.addCell(ct);
        // 
        // allRow = allRow;
        Color color = new Color(204, 204, 255);
        for (int i = 0; i < netIfItemch.length; i++) {
            Cell cell = new Cell(new Paragraph(netIfItemch[i], contextFont));
            cell.setBackgroundColor(Color.LIGHT_GRAY);
            aTable2.addCell(cell);
        }
        // 
        for (int i = 0; i < netifVector.size(); i++) {
            aTable2.addCell("");
            String[] strs = (String[]) netifVector.get(i);
            String ifname = strs[1];
            String index = strs[0];
            for (int j = 0; j < strs.length; j++) {
                if (j == 1) {
                    String linkuse = "";
                    if (portconfigHash != null && portconfigHash.size() > 0) {
                        if (portconfigHash.get(ip + ":" + index) != null)
                            linkuse = (String) portconfigHash.get(ip + ":" + index);
                    }
                    Cell cell1 = new Cell(new Phrase(strs[j], contextFont));
                    Cell cell2 = new Cell(new Phrase(linkuse, contextFont));
                    cell1.setLeading(6);
                    cell2.setLeading(6);
                    if (i % 2 != 0) {
                        cell1.setBackgroundColor(color);
                        cell2.setBackgroundColor(color);
                    }
                    aTable2.addCell(cell1);
                    aTable2.addCell(cell2);

                } else if (j > 1) {
                    Cell cell3 = new Cell(new Phrase(strs[j].replace("KB/", ""), contextFont));
                    cell3.setLeading(6);
                    if (i % 2 != 0) {
                        cell3.setBackgroundColor(color);
                    }
                    aTable2.addCell(cell3);

                } else {
                    Cell cell4 = new Cell(new Phrase(strs[j].replace("KB/", ""), contextFont));
                    cell4.setLeading(6);
                    if (i % 2 != 0) {
                        cell4.setBackgroundColor(color);
                    }
                    aTable2.addCell(cell4);
                }
            } // end 

        }
        document.add(aTable2);
        document.add(new Paragraph("\n"));
    }
    if ("0".equals(runmodel)) {
        // 
        if (iprouterVector != null && iprouterVector.size() > 0) {
            PdfPTable aTable3 = new PdfPTable(7);
            float[] width2 = { 240f, 170f, 310f, 300f, 220f, 180f, 330f };
            aTable3.setWidths(width2);
            aTable3.setWidthPercentage(100);
            aTable3.setHeaderRows(1);
            aTable3.addCell(new Phrase("", contextFont));
            // 
            // allRow = allRow+1;
            for (int i = 0; i < ipRouterItemch.length; i++) {
                aTable3.addCell(new Phrase(ipRouterItemch[i], contextFont));

            }

            // 

            for (int i = 0; i < iprouterVector.size(); i++) {
                aTable3.addCell("         ");

                IpRouter iprouter = (IpRouter) iprouterVector.get(i);
                aTable3.addCell(iprouter.getIfindex());
                aTable3.addCell(iprouter.getDest());
                aTable3.addCell(iprouter.getNexthop());
                aTable3.addCell(iproutertype[Integer.parseInt(iprouter.getType().longValue() + "")]);
                aTable3.addCell(iprouterproto[Integer.parseInt(iprouter.getProto().longValue() + "")]);
                aTable3.addCell(iprouter.getMask());
            }
            document.add(aTable3);
            document.add(new Paragraph("\n"));
        }
    } else {
        // 
        List routerList = (ArrayList) reportHash.get("routerList");
        if (routerList != null) {
            PdfPTable aTable3 = new PdfPTable(7);
            float[] width2 = { 240f, 170f, 310f, 300f, 220f, 180f, 330f };
            aTable3.setWidths(width2);
            aTable3.setWidthPercentage(100);
            aTable3.setHeaderRows(1);
            aTable3.addCell(new Phrase("", contextFont));
            // 
            // allRow = allRow+1;
            for (int i = 0; i < ipRouterItemch.length; i++) {
                aTable3.addCell(new Phrase(ipRouterItemch[i], contextFont));
            }
            for (int i = 0; i < routerList.size(); i++) {
                RouterNodeTemp iprouter = (RouterNodeTemp) routerList.get(i);
                aTable3.addCell("         ");
                aTable3.addCell(iprouter.getIfindex());
                aTable3.addCell(iprouter.getDest());
                aTable3.addCell(iprouter.getNexthop());
                aTable3.addCell(iprouter.getType());
                aTable3.addCell(iprouter.getProto());
                aTable3.addCell(iprouter.getMask());
            }
            document.add(aTable3);
            document.add(new Paragraph("\n"));
        }
    }
    // doc

    if (reportports != null && reportports.size() > 0) {
        // 

        // aTable4.addCell("");
        for (int i = 0; i < reportports.size(); i++) {
            PdfPTable aTable4 = new PdfPTable(2);
            float[] width2 = { 600f, 300f };
            aTable4.setWidths(width2);
            aTable4.setWidthPercentage(100);
            com.afunms.config.model.Portconfig portconfig = (com.afunms.config.model.Portconfig) reportports
                    .get(i);

            Phrase phrase = new Phrase("", contextFont);
            Phrase phrase1 = new Phrase(portconfig.getPortindex() + "(" + portconfig.getName() + ")");
            Phrase phrase2 = new Phrase("", contextFont);
            aTable4.addCell(new Phrase("" + portconfig.getPortindex() + "(" + portconfig.getName() + ")",
                    contextFont));
            // aTable4.addCell(new Phrase(phrase++ portconfig.getPortindex()
            // + "("+ portconfig.getName() +phrase2));
            if (portconfig.getLinkuse() == null)
                portconfig.setLinkuse("");
            /*
             * Cell cell1 = new Cell(new Phrase(":"+
             * portconfig.getLinkuse(),contextFont));
             */
            aTable4.addCell(new Phrase(":" + portconfig.getLinkuse(), contextFont));
            document.add(aTable4);
            // 
            Image img2 = Image.getInstance(ResourceCenter.getInstance().getSysPath()
                    + "/resource/image/jfreechart/" + newip + portconfig.getPortindex() + "ifspeed_day.png");
            // img2.setAbsolutePosition(0, 0);
            img2.setAlignment(Image.LEFT);// 
            // sheet,0,0,5,1,,,
            img2.scalePercent(67);
            document.add(img2);

        }
    } // 
    if (impReport.getChart() != null) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(),
                    impReport.getChart().getWidth(), impReport.getChart().getHeight());
        } catch (IOException ioe) {
        }
        WritableImage wi = new WritableImage(2, 10000 + 5, 8, 12, baos.toByteArray());
        Image img2 = Image.getInstance(baos.toByteArray());
        // img.setAbsolutePosition(0, 0);
        img2.setAlignment(Image.LEFT);// 
        img2.scalePercent(67);
        document.add(img2);
    }

    document.close();
}

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

public void createReport_networkchoce(String starttime, String totime, String file, String username,
        String positionname) throws DocumentException, IOException {

    Hashtable allreporthash = new Hashtable();
    allreporthash = reportHash;//  w  w  w.ja  va  2  s.  c om
    /*
     * String starttime = (String) reportHash.get("starttime"); String
     * totime = (String) reportHash.get("totime");
     */

    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(file));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont1 = new Font(bfChinese, 14, Font.BOLD);
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 10, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);
    String runAppraise = "";
    if (dataHash.containsKey("runAppraise")) {
        runAppraise = (String) dataHash.get("runAppraise");
    }
    try {
        fileName = ResourceCenter.getInstance().getSysPath() + file;
        Table aTable = new Table(15);
        float[] widths = { 60f, 60f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f, 50f };
        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("", titleFont1));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(15);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        // cell = new Cell("");
        cell = new Cell("" + starttime + "" + totime);
        cell.setColspan(14);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase(username, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setColspan(3);

        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase(positionname, contextFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setColspan(3);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        aTable.addCell(cell);
        cell = new Cell(runAppraise);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setColspan(4);
        aTable.addCell(cell);
        cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "" + "\n" + "", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(3 + allreporthash.size());
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("IP", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("CPU(%)", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("(KB/S)", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(4);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("()", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(3);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("" + "\n" + "", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("" + "\n" + "", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("" + "\n" + "", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("" + "\n" + "", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setColspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);
        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setRowspan(2);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        aTable.addCell(cell);

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

        fileName = ResourceCenter.getInstance().getSysPath() + file;

        if (allreporthash != null && allreporthash.size() > 0) {
            Iterator keys = allreporthash.keySet().iterator();
            String ip = "";
            while (keys.hasNext()) {
                ip = keys.next().toString();
                Hashtable report_has = (Hashtable) allreporthash.get(ip);
                String hostname = (String) report_has.get("equipname");
                // WritableSheet sheet = wb.createSheet(hostname+"",
                // sheetNum);

                Hashtable CPU = (Hashtable) report_has.get("CPU");
                String Ping = (String) report_has.get("Ping");
                // Hashtable maxping = (Hashtable)
                // report_has.get("maxping");
                String newip = doip(ip);
                Calendar colTime = Calendar.getInstance();
                Date cc = colTime.getTime();
                Vector netifVector = (Vector) report_has.get("netifVector");
                Hashtable portconfigHash = (Hashtable) report_has.get("portconfigHash");
                List reportports = (List) report_has.get("reportports");
                Vector iprouterVector = (Vector) report_has.get("iprouterVector");

                Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash");
                Hashtable maxping = (Hashtable) report_has.get("ping");

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

                String[] netIfItemch = { "", "", "", "(M)", "", "",
                        "" };
                String[] ipRouterItemch = { "", "", "", "", "",
                        "" };
                String[] memoryItem = { "Capability", "Utilization" };
                String[] diskItem = { "AllSize", "UsedSize", "Utilization", "INodeUsedSize",
                        "INodeUtilization" };
                String[] diskItemch = { "", "", "", "i-node", "i-node" };
                String[] iproutertype = { "", "", "", "direct(3)", "indirect(4)" };
                String[] iprouterproto = { "", "other(1)", "local(2)", "netmgmt(3)", "icmp(4)", "egp(5)",
                        "ggp(6)", "hello(7)", "rip(8)", "is-is(9)", "es-is(10)", "ciscoIgrp(11)",
                        "bbnSpfIgp(12)", "ospf(13)", "bgp(14)" };
                String avginput = (String) report_has.get("avginput");
                String avgoutput = (String) report_has.get("avgoutput");
                String maxinput = (String) report_has.get("maxinput");
                String maxoutput = (String) report_has.get("maxoutput");

                String levelone = (String) report_has.get("levelone");
                String levletwo = (String) report_has.get("levletwo");
                String levelthree = (String) report_has.get("levelthree");
                /*
                 * String starttime = (String)report_has.get("starttime");
                 * String totime = (String)report_has.get("totime");
                 */
                cell = new Cell(ip);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(hostname);
                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((String) CPU.get("avgcpu"));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell((String) CPU.get("cpumax"));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell("");
                aTable.addCell(cell);
                cell = new Cell("");
                aTable.addCell(cell);
                cell = new Cell(avgoutput.replace(".0", ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(maxoutput.replace(".0", ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(avginput.replace(".0", ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(maxinput.replace(".0", ""));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(levelone);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(levletwo);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                cell = new Cell(levelthree);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
                /*
                 * cell = (Cell)aTable.getElement(1, 1); cell.add(new
                 * Phrase(""+starttime+""+totime,contextFont));
                 */
            }
        }

        cell = new Cell(new Phrase("", titleFont));
        cell.setBackgroundColor(Color.LIGHT_GRAY);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setColspan(15);
        aTable.addCell(cell);
        String businessAnalytics = "";
        if (dataHash.containsKey("businessAnalytics")) {
            businessAnalytics = (String) dataHash.get("businessAnalytics");
        }
        cell = new Cell(businessAnalytics);
        cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
        cell.setColspan(15);
        cell.setRowspan(6);
        aTable.addCell(cell);
        document.add(aTable);
        document.close();
    } catch (Exception e) {
        SysLogger.error("", e);
    }
}

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

public void createReport_hostchoce(String starttime, String totime, String file, String username,
        String positionname) throws DocumentException, IOException {
    Hashtable allreporthash = new Hashtable();
    allreporthash = reportHash;/*from  w ww. jav a 2 s .  c  om*/
    Document document = new Document(PageSize.A4);
    // (Writer)document(Writer)
    RtfWriter2.getInstance(document, new FileOutputStream(file));
    document.open();
    // 
    BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED);
    // 
    Font titleFont1 = new Font(bfChinese, 14, Font.BOLD);
    Font titleFont = new Font(bfChinese, 12, Font.BOLD);
    // 
    Font contextFont = new Font(bfChinese, 12, Font.NORMAL);
    Font contextFont1 = new Font(bfChinese, 14, Font.NORMAL);
    Font fontChinese = new Font(bfChinese, 12, Font.NORMAL, Color.black);

    fileName = ResourceCenter.getInstance().getSysPath() + file;
    Table aTable = new Table(13);
    float[] widths = { 60f, 100f, 30f, 30f, 30f, 30f, 30f, 30f, 50f, 50f, 30f, 30f, 30f };
    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("", titleFont1));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(13);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // cell = new Cell("");
    cell = new Cell(new Phrase("" + starttime + "" + totime, contextFont));
    cell.setColspan(12);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // cell = new Cell(new Phrase(username,contextFont));
    cell = new Cell(new Phrase(username, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell.setColspan(4);
    aTable.addCell(cell);
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    // cell = new Cell(new Phrase(positionname,contextFont));
    cell = new Cell(new Phrase(positionname, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    cell.setColspan(4);
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String runAppraise = "";
    if (dataHash.containsKey("runAppraise")) {
        runAppraise = (String) dataHash.get("runAppraise");
    }
    // cell = new Cell(new Phrase(positionname,contextFont));
    cell = new Cell(new Phrase(runAppraise, contextFont));
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + "\n" + "" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2 + allreporthash.size());
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("IP", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("(%)", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("CPU(%)", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("TOP", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(2);
    cell.setRowspan(2);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("()", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(3);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);

    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    cell = new Cell(new Phrase("" + "\n" + "", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    java.text.NumberFormat formate = java.text.NumberFormat.getNumberInstance();
    formate.setMaximumFractionDigits(0);//
    fileName = ResourceCenter.getInstance().getSysPath() + file;
    if (allreporthash != null && allreporthash.size() > 0) {
        Iterator keys = allreporthash.keySet().iterator();
        String ip = "";
        int sheetNum = 0;
        while (keys.hasNext()) {
            ip = keys.next().toString();
            String newip = doip(ip);
            Hashtable report_has = (Hashtable) allreporthash.get(ip);
            String hostname = (String) report_has.get("equipname");
            Hashtable CPU = (Hashtable) report_has.get("CPU");
            String Ping = (String) report_has.get("Ping");
            Calendar colTime = (Calendar) report_has.get("time");
            Date cc = colTime.getTime();
            Hashtable Memory = (Hashtable) report_has.get("Memory");
            Hashtable Disk = (Hashtable) report_has.get("Disk");

            Hashtable memMaxHash = (Hashtable) report_has.get("memmaxhash");
            Hashtable memAvgHash = (Hashtable) report_has.get("memavghash");
            Hashtable maxping = (Hashtable) report_has.get("ping");

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

            String[] memoryItemch = { "", "", "", "" };
            String[] memoryItem = { "Capability", "c" };
            String[] diskItem = { "AllSize", "UsedSize", "Utilization", "Utilizationvalue" };
            String[] diskItemch = { "", "", "" };

            String levelone = (String) report_has.get("levelone");
            String levletwo = (String) report_has.get("levletwo");
            String levelthree = (String) report_has.get("levelthree");
            cell = new Cell(new Phrase(ip, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            // =======
            String string1 = ((String) maxping.get("pingmax")).replace("%", "");
            String string2 = ((String) maxping.get("avgpingcon")).replace("%", "");
            // formate.format(Double.valueOf(string1));
            // System.out.println(formate.format(Double.valueOf(string))+"@@@@@@@0000000000");
            cell = new Cell(new Phrase(formate.format(Double.valueOf(string1)), contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            cell = new Cell(new Phrase(formate.format(Double.valueOf(string2)), contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);

            String cpu = "";
            if (CPU.get("cpu") != null)
                cpu = (String) CPU.get("cpu");
            String cpumax = "";
            if (CPU.get("cpumax") != null)
                cpumax = (String) CPU.get("cpumax");
            String avgcpu = "";
            if (CPU.get("avgcpu") != null)
                avgcpu = (String) CPU.get("avgcpu");
            String string3 = avgcpu.replace("%", "");
            String string4 = cpumax.replace("%", "");

            cell = new Cell(new Phrase(formate.format(Double.valueOf(string3)), contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            cell = new Cell(new Phrase(formate.format(Double.valueOf(string4)), contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            String avgvalue = "0.0%";
            if (memAvgHash.get("PhysicalMemory") != null) {

                avgvalue = (String) memAvgHash.get("PhysicalMemory");
                String string5 = avgvalue.replace("%", "");
                cell = new Cell(new Phrase(formate.format(Double.valueOf(string5)), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
            } else {
                String string5 = avgvalue.replace("%", "");
                cell = new Cell(new Phrase(formate.format(Double.valueOf(string5)), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
            }
            String value = "0.0%";
            if (memMaxHash.get("PhysicalMemory") != null) {

                value = (String) memMaxHash.get("PhysicalMemory");
                String string6 = value.replace("%", "");
                cell = new Cell(new Phrase(formate.format(Double.valueOf(string6)), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
            } else {
                String string6 = value.replace("%", "");
                cell = new Cell(new Phrase(formate.format(Double.valueOf(string6)), contextFont));
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
            }
            String value1 = "0";
            String name = "";
            String Utilization = "";
            if (Disk != null && Disk.size() > 0) {
                for (int i = 0; i < Disk.size(); i++) {
                    Hashtable diskhash = (Hashtable) (Disk.get(new Integer(i)));
                    if (diskhash.get(diskItem[3]) != null) {
                        if (value1.compareTo((String) diskhash.get(diskItem[3])) < 0) {
                            value1 = (String) diskhash.get(diskItem[3]);
                            name = (String) diskhash.get("name");
                            Utilization = (String) diskhash.get(diskItem[2]);
                        }
                    }
                }
                cell = new Cell(name + "  " + Utilization);
                cell.setColspan(2);
                aTable.addCell(cell);

            } else {
                cell = new Cell("---");
                cell.setColspan(2);
                cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
                aTable.addCell(cell);
            }
            cell = new Cell(new Phrase(levelone, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            cell = new Cell(new Phrase(levletwo, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
            cell = new Cell(new Phrase(levelthree, contextFont));
            cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
            cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
            aTable.addCell(cell);
        }
    }
    cell = new Cell(new Phrase("", titleFont));
    cell.setBackgroundColor(Color.LIGHT_GRAY);
    cell.setColspan(13);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    String businessAnalytics = "";
    if (dataHash.containsKey("businessAnalytics")) {
        businessAnalytics = (String) dataHash.get("businessAnalytics");
    }
    cell = new Cell(businessAnalytics);
    cell.setColspan(13);
    cell.setRowspan(6);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER); // 
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 
    aTable.addCell(cell);
    document.add(aTable);
    document.close();
}