List of usage examples for com.lowagie.text Element ALIGN_LEFT
int ALIGN_LEFT
To view the source code for com.lowagie.text Element ALIGN_LEFT.
Click Source Link
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);//from w ww. ja va2s . c om // 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_pingPDF(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);/*w w w . j a v a 2 s .co 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); PdfPTable aTable = new PdfPTable(4); float[] widths = { 220f, 300f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); aTable.addCell(new Phrase("", contextFont)); // 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.setAlignment(Image.LEFT);// img.scalePercent(75); document.add(aTable); document.add(img); document.close(); }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_capacityPDF(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);/*from w w w . j av a 2s .co 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); 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"); PdfPTable aTable1 = new PdfPTable(4); float[] width = { 220f, 300f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); aTable1.addCell(new Phrase("CPU", contextFont)); aTable1.addCell(new Phrase("", contextFont)); aTable1.addCell(new Phrase("", contextFont)); aTable1.addCell(new Phrase("", contextFont)); // aTable.addCell("3.2",Ping+"%"); aTable1.addCell(""); 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) { PdfPTable aTable2 = new PdfPTable(6); float[] widthss = { 220f, 300f, 220f, 220f, 220f, 220f }; aTable2.setWidths(widthss); aTable2.setWidthPercentage(100); aTable2.addCell(new Phrase("", contextFont)); aTable2.addCell(new Phrase("", contextFont)); // for (int i = 0; i < memoryItemch.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(memoryItemch[i], contextFont)); 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"); PdfPCell cell1 = new PdfPCell(new Phrase(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]); } PdfPCell cell2 = new PdfPCell(new Phrase(value)); aTable2.addCell(cell2); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); PdfPCell cell3 = new PdfPCell(new Phrase(value)); aTable2.addCell(cell3); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); aTable2.addCell(new Phrase(avgvalue)); } } // 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 { PdfPTable aTable2 = new PdfPTable(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(); */ aTable2.addCell(new Phrase("", contextFont)); aTable2.addCell(new Phrase("", contextFont)); // for (int i = 0; i < memoryItemch.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(memoryItemch[i], contextFont)); 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(""); PdfPCell cell = new PdfPCell(new Phrase(names[i])); aTable2.addCell(cell); for (int j = 0; j < memoryItem.length; j++) { // String value = ""; PdfPCell cell1 = new PdfPCell(new Phrase(value)); aTable2.addCell(cell1); } String value = ""; if (memMaxHash.get(name) != null) { value = (String) memMaxHash.get(name); PdfPCell cell2 = new PdfPCell(new Phrase(value)); aTable2.addCell(cell2); } else { PdfPCell cell3 = new PdfPCell(new Phrase(value)); aTable2.addCell(cell3); } String avgvalue = ""; if (memAvgHash.get(name) != null) { avgvalue = (String) memAvgHash.get(name); PdfPCell cell4 = new PdfPCell(new Phrase(avgvalue)); aTable2.addCell(cell4); } else { PdfPCell cell5 = new PdfPCell(new Phrase(avgvalue)); 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); } 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_diskPDF(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);/*from w w w . j a va 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); PdfPTable aTable = new PdfPTable(4); float[] widths = { 220f, 300f, 220f, 220f }; PdfPTable aTable3 = new PdfPTable(5); float[] widthss1 = { 220f, 440f, 150f, 150f, 220f }; aTable3.setWidths(widthss1); aTable3.setWidthPercentage(100); if (Disk != null && Disk.size() > 0) { aTable3.addCell(new Phrase("", contextFont)); aTable3.addCell(new Phrase("", contextFont)); for (int i = 0; i < diskItemch.length; i++) { PdfPCell cell = new PdfPCell(new Phrase(diskItemch[i], contextFont)); 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"); PdfPCell cell = new PdfPCell(new Phrase(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]); } PdfPCell cell1 = new PdfPCell(new Phrase(value)); aTable3.addCell(cell1); } } // 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_oraDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;/*from w w w . j a v a 2 s . c o m*/ return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // 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); document.add(new Paragraph("\n")); // HONGLI MODIFY START1 Table aTable1 = new Table(12); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 aTable1.addCell(""); row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(rowStr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(_filename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(tablespace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(free, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(percent, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new Cell(new Phrase(pyr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pyw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new Cell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI oracleword/*from w w w . jav a 2 s.co m*/ * @param filename * @throws DocumentException * @throws IOException */ public void createReportOracleCldDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidth(100); // 90% dbTable.setAlignment(Element.ALIGN_CENTER);// dbTable.setAutoFillEmptyCells(true); // dbTable.setBorderWidth(1); // dbTable.setBorderColor(new Color(0, 125, 255)); // dbTable.setPadding(2);// dbTable.setSpacing(0);// dbTable.setBorder(2);// dbTable.endHeaders(); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(dbTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Table dbInfoTable = new Table(6); float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; dbInfoTable.setWidths(dbInfoWidths); dbInfoTable.setWidth(100); // 90% dbInfoTable.setAlignment(Element.ALIGN_CENTER);// dbInfoTable.setAutoFillEmptyCells(true); // dbInfoTable.setBorderWidth(1); // dbInfoTable.setBorderColor(new Color(0, 125, 255)); // dbInfoTable.setPadding(2);// dbInfoTable.setSpacing(0);// dbInfoTable.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); String buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase("10", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(buffercache, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(dictionarycache, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(librarycache, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctmemorysorts, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctbufgets, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); cell = new Cell(new Phrase(opencurstr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbInfoTable.addCell(cell); document.add(dbInfoTable); // String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; Table ncTable = new Table(7); float[] ncWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 ncTable.setWidths(ncWidths); ncTable.setWidth(100); // 90% ncTable.setAlignment(Element.ALIGN_CENTER);// ncTable.setAutoFillEmptyCells(true); // ncTable.setBorderWidth(1); // ncTable.setBorderColor(new Color(0, 125, 255)); // ncTable.setPadding(2);// ncTable.setSpacing(0);// ncTable.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(7); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[3], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[3]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); document.add(ncTable); // HONGLI MODIFY START1 Table aTable1 = new Table(11); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(11); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END1 cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(rowStr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(_filename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(tablespace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(free, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(percent, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new Cell(new Phrase(pyr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pyw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new Cell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } document.add(aTable1); // Table evenInfoTable = new Table(2); float[] evenInfoWidths = { 220f, 220f }; evenInfoTable.setWidths(evenInfoWidths); evenInfoTable.setWidth(100); // 90% evenInfoTable.setAlignment(Element.ALIGN_CENTER);// evenInfoTable.setAutoFillEmptyCells(true); // evenInfoTable.setBorderWidth(1); // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // evenInfoTable.setPadding(2);// evenInfoTable.setSpacing(0);// evenInfoTable.setBorder(2);// String downnum = (String) reportHash.get("downnum"); String count = String.valueOf(reportHash.get("count")); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); document.add(evenInfoTable); addEventListToDoc(document, titleFont, contextFont); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI oraclepdf//from ww w .j av a2 s . com * @param filename * @throws DocumentException * @throws IOException */ public void createReportOracleCldPdf(String filename, String type) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) if ("pdf".equals(type)) { PdfWriter.getInstance(document, new FileOutputStream(filename)); } else { RtfWriter2.getInstance(document, new FileOutputStream(filename)); } document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); this.setTableFormat(dbTable); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); this.setCellFormat(dbCell, true); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); this.setCellFormat(dbCell, false); dbTable.addCell(dbCell); Table aTable = new Table(3); this.setTableFormat(aTable); // float[] widths = { 220f, 220f, 220f }; // aTable.setWidths(widths); // aTable.setWidthPercentage(100); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); this.setCellFormat(cell, false); aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); // img.setAbsolutePosition(0, 0); img.scalePercent(76); img.setAlignment(Image.MIDDLE);// document.add(dbTable); document.add(new Paragraph("\n")); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Table dbInfoTable = new Table(6); this.setTableFormat(dbInfoTable); // float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; // dbInfoTable.setWidths(dbInfoWidths); // dbInfoTable.setWidthPercentage(100); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); cell.setColspan(6); dbInfoTable.addCell(cell); String buffercache = "0";// String dictionarycache = "0";// String librarycache = "0";// String pctmemorysorts = "0";// String pctbufgets = "0";// 10 String opencurstr = "0";// Hashtable memPerfValue = (Hashtable) reportHash.get("memPerfValue"); Hashtable memValue = (Hashtable) reportHash.get("memValue"); Hashtable cursors = (Hashtable) reportHash.get("cursors"); if (cursors == null) { cursors = new Hashtable(); } if (memPerfValue == null) memPerfValue = new Hashtable(); if (memPerfValue != null) { if (memPerfValue.containsKey("buffercache") && memPerfValue.get("buffercache") != null) { buffercache = (String) memPerfValue.get("buffercache") + "%"; } if (memPerfValue.containsKey("dictionarycache") && memPerfValue.get("dictionarycache") != null) { dictionarycache = (String) memPerfValue.get("dictionarycache") + "%"; } if (memPerfValue.containsKey("librarycache") && memPerfValue.get("librarycache") != null) { librarycache = (String) memPerfValue.get("librarycache") + "%"; } if (memPerfValue.containsKey("pctmemorysorts") && memPerfValue.get("pctmemorysorts") != null) { pctmemorysorts = (String) memPerfValue.get("pctmemorysorts") + "%"; } if (memPerfValue.containsKey("pctbufgets") && memPerfValue.get("pctbufgets") != null) { pctbufgets = (String) memPerfValue.get("pctbufgets") + "%"; } if (cursors.containsKey("opencur") && cursors.get("opencur") != null) { opencurstr = (String) cursors.get("opencur"); } } cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase("10", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); this.setCellFormat(cell, true); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(buffercache, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(dictionarycache, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(librarycache, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctmemorysorts, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(pctbufgets, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); cell = new Cell(new Phrase(opencurstr, contextFont)); this.setCellFormat(cell, false); dbInfoTable.addCell(cell); document.add(dbInfoTable); document.add(new Paragraph("\n")); // String[] sysItem1 = { "shared_pool", "large_pool", "DEFAULT_buffer_cache", "java_pool" }; String[] sysItemch1 = { "", "", "", "Java" }; String[] sysItem2 = { "aggregate_PGA_target_parameter", "total_PGA_allocated", "maximum_PGA_allocated" }; String[] sysItemch2 = { "PGA", "PGA", "PGA" }; Table ncTable = new Table(7); this.setTableFormat(ncTable); // float[] ncWidths = { 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 // ncTable.setWidths(ncWidths); // ncTable.setWidthPercentage(100); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(7); this.setCellFormat(cell, true); ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch2[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[0], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[1], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[2], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(sysItemch1[3], titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem2[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[0]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[1]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[2]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); cell = new Cell(new Phrase(memValue.get(sysItem1[3]) + "MB", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // ncTable.addCell(cell); document.add(ncTable); document.add(new Paragraph("\n")); // HONGLI MODIFY START1 Table aTable1 = new Table(11); float[] arg0 = { 10f, 20f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f, 10f }; aTable1.setWidths(arg0); this.setTableFormat(aTable1); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(11); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD START1 cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD END1 cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 row = i + 1; String rowStr = "" + row; cell = new Cell(new Phrase(rowStr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(_filename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(tablespace, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(free, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(percent, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new Cell(new Phrase(pyr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbr, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pyw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(pbw, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new Cell(new Phrase(status, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } document.add(aTable1); // document.add(new Paragraph("\n")); Table eventTable = new Table(2); this.setTableFormat(eventTable); cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); this.setCellFormat(cell, true); eventTable.addCell(cell); cell = new Cell(new Phrase((String) reportHash.get("downnum"), contextFont)); this.setCellFormat(cell, false); eventTable.addCell(cell); cell = new Cell(new Phrase(reportHash.get("count") + "", contextFont)); this.setCellFormat(cell, false); eventTable.addCell(cell); document.add(eventTable); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(new Paragraph("\n")); // addEventLisToPdf(document); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * MODIFY HONGLI 2010-10-27/*www .j ava 2 s. c o m*/ */ public void createReport_oraPDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); Font contextFont1 = new Font(bfChinese, 11, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont1); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow"))); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); this.setCellFormat(cell, false); aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); this.setCellFormat(cell, false); aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.MIDDLE);// img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // HONGLI MODIFY START1 PdfPTable aTable1 = new PdfPTable(12); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; // HONGLI MODIFY END1 aTable1.setWidths(width); aTable1.setWidthPercentage(100); aTable1.setHeaderRows(1); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD START1 cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // HONGLI ADD END1 cell = new PdfPCell(new Phrase("", titleFont)); this.setCellFormat(cell, true); aTable1.addCell(cell); // aTable1.endHeaders(); // Vector tableinfo_v = (Vector) reportHash.get("tableinfo_v"); // HONGLI ADD START2 Hashtable dbio = (Hashtable) reportHash.get("dbio"); // HONGLI ADD END2 int row = 0; for (int i = 0; i < tableinfo_v.size(); i++) { Hashtable ht = (Hashtable) tableinfo_v.get(i); String _filename = ht.get("file_name").toString(); String tablespace = ht.get("tablespace").toString(); String size = ht.get("size_mb").toString(); String free = ht.get("free_mb").toString(); String percent = ht.get("percent_free").toString(); String status = ht.get("status").toString(); // HONGLI ADD START3 String pyr = ""; String pbr = ""; String pyw = ""; String pbw = ""; if (dbio.containsKey(_filename)) { Hashtable iodetail = (Hashtable) dbio.get(_filename); if (iodetail != null && iodetail.size() > 0) { pyr = (String) iodetail.get("pyr"); pbr = (String) iodetail.get("pbr"); pyw = (String) iodetail.get("pyw"); pbw = (String) iodetail.get("pbw"); } } // HONGLI ADD END3 aTable1.addCell(new Phrase("")); row = i + 1; String rowStr = "" + row; cell = new PdfPCell(new Phrase(rowStr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(_filename)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(tablespace)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(size)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(free)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(percent)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD START4 cell = new PdfPCell(new Phrase(pyr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(pbr)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(pyw)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(pbw)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // HONGLI ADD END4 cell = new PdfPCell(new Phrase(status)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_sqlDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;/*from w w w. java 2s . co m*/ return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); Table aTable1 = new Table(6); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v"); Hashtable alldatabase = new Hashtable(); if (dbValue.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); int row = 1; for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); cell = new Cell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(row + "", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(dbname, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(size, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(usedsize, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(usedperc, titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // TODO: handle exception } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
public void createReport_sqlPDF(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null;/* w w w .ja v a 2 s . c o m*/ return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) PdfWriter.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); document.add(new Paragraph("\n")); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ PdfPTable aTable = new PdfPTable(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidthPercentage(100); PdfPCell cell = null; cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingnow"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("pingmax"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new PdfPCell(new Phrase((String) maxping.get("avgpingcon"))); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// // document.add(aTable); img.scalePercent(76); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); PdfPTable aTable1 = new PdfPTable(6); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f }; aTable1.setWidths(width); aTable1.setWidthPercentage(100); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // aTable1.endHeaders(); // Hashtable dbValue = (Hashtable) reportHash.get("tableinfo_v"); Hashtable alldatabase = new Hashtable(); if (dbValue.get("database") != null) alldatabase = (Hashtable) dbValue.get("database"); Vector names = new Vector(); if (dbValue.get("names") != null) names = (Vector) dbValue.get("names"); if (alldatabase != null && alldatabase.size() > 0) { if (names == null) names = new Vector(); int row = 1; for (int i = 0; i < names.size(); i++) { String key = (String) names.get(i); if (alldatabase.get(key) == null) continue; Hashtable data = (Hashtable) alldatabase.get(key); String dbname = data.get("dbname").toString(); String size = data.get("size").toString(); String usedsize = ""; if (data.get("usedsize") != null) { usedsize = data.get("usedsize").toString(); } String usedperc = ""; if (data.get("usedperc") != null) usedperc = data.get("usedperc").toString(); cell = new PdfPCell(new Phrase("")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(row + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(dbname)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(size)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(usedsize)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new PdfPCell(new Phrase(usedperc)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); row++; } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { // TODO: handle exception } }