List of usage examples for com.lowagie.text Table setBorder
public void setBorder(int border)
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI Sybaseword//w w w.j a v a 2 s. c o m * @param filename * @throws DocumentException * @throws IOException */ public void createReport_SybaseCldDoc(String filename) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); String runstr = (String) reportHash.get("runstr"); String grade = (String) reportHash.get("grade"); String pingnow = (String) reportHash.get("pingnow"); String pingmin = (String) reportHash.get("pingmin"); String pingconavg = (String) reportHash.get("pingconavg"); DBVo vo = (DBVo) reportHash.get("vo"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); SybaseVO sysbaseVO = (SybaseVO) reportHash.get("sysbaseVO"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidth(100); // 90% dbTable.setAlignment(Element.ALIGN_CENTER);// dbTable.setAutoFillEmptyCells(true); // dbTable.setBorderWidth(1); // dbTable.setBorderColor(new Color(0, 125, 255)); // dbTable.setPadding(2);// dbTable.setSpacing(0);// dbTable.setBorder(2);// dbTable.endHeaders(); Cell dbCell = null; dbCell = new Cell(new Phrase("", titleFont)); dbCell.setColspan(5); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("IP", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase("", titleFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(vo.getDbName(), contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(ip, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(typename, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(runstr, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); dbCell = new Cell(new Phrase(grade, contextFont)); dbCell.setHorizontalAlignment(Element.ALIGN_CENTER); // dbCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(dbCell); Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingnow + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingmin + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(pingconavg + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAbsolutePosition(0, 0); img.setAlignment(Image.LEFT);// document.add(dbTable); document.add(aTable); document.add(img); document.add(new Paragraph("\n")); // Table spaceTable = new Table(5); float[] width = { 220f, 220f, 220f, 220f, 220f }; spaceTable.setWidths(width); spaceTable.setWidth(100); // 90% spaceTable.setAlignment(Element.ALIGN_CENTER);// spaceTable.setAutoFillEmptyCells(true); // spaceTable.setBorderWidth(1); // spaceTable.setBorderColor(new Color(0, 125, 255)); // spaceTable.setPadding(2);// spaceTable.setSpacing(0);// spaceTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("MB ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("MB", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("(%)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); // spaceTable.endHeaders(); List dbInfo = (ArrayList) sysbaseVO.getDbInfo(); if (dbInfo != null && dbInfo.size() > 0) { for (int i = 0; i < dbInfo.size(); i++) { TablesVO tempSpace = (TablesVO) dbInfo.get(i); String db_name = (String) tempSpace.getDb_name(); String db_size = (String) tempSpace.getDb_size(); String db_freesize = (String) tempSpace.getDb_freesize(); String db_usedperc = (String) tempSpace.getDb_usedperc(); cell = new Cell(new Phrase((i + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_name, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_size, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_freesize, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(db_usedperc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); } } document.add(spaceTable); // Table memTable = new Table(6); float[] dbInfoWidths = { 220f, 220f, 220f, 220f, 220f, 220f }; memTable.setWidths(dbInfoWidths); memTable.setWidth(100); // 90% memTable.setAlignment(Element.ALIGN_CENTER);// memTable.setAutoFillEmptyCells(true); // memTable.setBorderWidth(1); // memTable.setBorderColor(new Color(0, 125, 255)); // memTable.setPadding(2);// memTable.setSpacing(0);// memTable.setBorder(2);// Hashtable mems = (Hashtable) reportHash.get("mems");// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(6); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("Metadata(MB)", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(MB) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase("(%) ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_dataCache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_physicalMemory(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getMetadata_cache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getProcedure_cache(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getTotal_logicalMemory(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); cell = new Cell(new Phrase(sysbaseVO.getData_hitrate(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // memTable.addCell(cell); document.add(memTable); // Sysbase Table remoteServerTable = new Table(5); float[] remoteServerWidths = { 220f, 220f, 220f, 220f, 220f }; remoteServerTable.setWidths(remoteServerWidths); remoteServerTable.setWidth(100); // 90% remoteServerTable.setAlignment(Element.ALIGN_CENTER);// remoteServerTable.setAutoFillEmptyCells(true); // remoteServerTable.setBorderWidth(1); // remoteServerTable.setBorderColor(new Color(0, 125, 255)); // remoteServerTable.setPadding(2);// remoteServerTable.setSpacing(0);// remoteServerTable.setBorder(2);// Hashtable sysValue = (Hashtable) reportHash.get("sysValue");// cell = new Cell(new Phrase("Sysbase ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); List serverlist = (List) sysbaseVO.getServersInfo(); if (serverlist != null && serverlist.size() > 0) { for (int k = 0; k < serverlist.size(); k++) { TablesVO tVO = (TablesVO) serverlist.get(k); cell = new Cell(new Phrase((k + 1) + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_network_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_class(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); cell = new Cell(new Phrase(tVO.getServer_status(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // remoteServerTable.addCell(cell); } } document.add(remoteServerTable); Table userTable = new Table(5); float[] uWidth = { 220f, 220f, 220f, 220f, 220f }; userTable.setWidths(uWidth); userTable.setWidth(100); // 90% userTable.setAlignment(Element.ALIGN_CENTER);// userTable.setAutoFillEmptyCells(true); // userTable.setBorderWidth(1); // userTable.setBorderColor(new Color(0, 125, 255)); // userTable.setPadding(2);// userTable.setSpacing(0);// userTable.setBorder(2);// cell = new Cell(new Phrase(" Sysbase ", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase("id ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); // userTable.endHeaders(); List userlist = (List) sysbaseVO.getUserInfo(); if (userlist != null && userlist.size() > 0) { for (int k = 0; k < userlist.size(); k++) { TablesVO tVO = (TablesVO) userlist.get(k); cell = new Cell(new Phrase((k + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getUsers_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getID_in_db(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getGroup_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); cell = new Cell(new Phrase(tVO.getLogin_name(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // userTable.addCell(cell); } } document.add(userTable); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } // Table evenInfoTable = new Table(2); float[] evenInfoWidths = { 220f, 220f }; evenInfoTable.setWidths(evenInfoWidths); evenInfoTable.setWidth(100); // 90% evenInfoTable.setAlignment(Element.ALIGN_CENTER);// evenInfoTable.setAutoFillEmptyCells(true); // evenInfoTable.setBorderWidth(1); // evenInfoTable.setBorderColor(new Color(0, 125, 255)); // evenInfoTable.setPadding(2);// evenInfoTable.setSpacing(0);// evenInfoTable.setBorder(2);// String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // evenInfoTable.addCell(cell); document.add(evenInfoTable); // addEventListToDoc(document, titleFont, contextFont); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI Informix doc//from w w w. j a va2 s . c o m * @param filename * @throws DocumentException * @throws IOException */ public void createReportInformixSelfDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable dbinfo = new Hashtable(); dbinfo = (Hashtable) reportHash.get("dbValue"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); // Informix Table spaceTable = new Table(8); float[] width = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; spaceTable.setWidths(width); spaceTable.setWidth(100); // 90% spaceTable.setAlignment(Element.ALIGN_CENTER);// spaceTable.setAutoFillEmptyCells(true); // spaceTable.setBorderWidth(1); // spaceTable.setBorderColor(new Color(0, 125, 255)); // spaceTable.setPadding(2);// spaceTable.setSpacing(0);// spaceTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(8); spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); // spaceTable.endHeaders(); ArrayList dbspaces = new ArrayList(); if (dbinfo != null) { dbspaces = (ArrayList) dbinfo.get("informixspaces");// } if (dbspaces != null) { if (dbspaces.size() > 0) { DecimalFormat df = new DecimalFormat("#.###"); for (int i = 0; i < dbspaces.size(); i++) { Hashtable tablesVO = (Hashtable) dbspaces.get(i); cell = new Cell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("dbspace"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("owner"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("fname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_size") + "")) + "M", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_used") + "")) + "M", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(Float.parseFloat(tablesVO.get("pages_free") + "")) + "M", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); cell = new Cell(new Phrase( df.format(100 - Float.parseFloat(tablesVO.get("percent_free") + "")) + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // spaceTable.addCell(cell); } } } document.add(spaceTable); // Informix Table hhTable = new Table(8); float[] hhWidth = { 220f, 220f, 220f, 220f, 220f, 220f, 220f, 220f }; hhTable.setWidths(hhWidth); hhTable.setWidth(100); // 90% hhTable.setAlignment(Element.ALIGN_CENTER);// hhTable.setAutoFillEmptyCells(true); // hhTable.setBorderWidth(1); // hhTable.setBorderColor(new Color(0, 125, 255)); // hhTable.setPadding(2);// hhTable.setSpacing(0);// hhTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(8); hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); // hhTable.endHeaders(); List dbsession = (ArrayList) dbinfo.get("sessionList");// if (dbsession != null && dbsession.size() > 0) { for (int i = 0; i < dbsession.size(); i++) { Hashtable tablesVO = (Hashtable) dbsession.get(i); String seqscans = String.valueOf(tablesVO.get("seqscans")); if ("null".equals(seqscans)) { seqscans = ""; } String total_sorts = String.valueOf(tablesVO.get("total_sorts")); if ("null".equals(total_sorts)) { total_sorts = ""; } String dsksorts = String.valueOf(tablesVO.get("dsksorts")); if ("null".equals(dsksorts)) { dsksorts = ""; } cell = new Cell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(tablesVO.get("access") + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(tablesVO.get("locksheld") + "", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(seqscans, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(total_sorts, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); cell = new Cell(new Phrase(dsksorts, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // hhTable.addCell(cell); } } document.add(hhTable); // Informix Table lockTable = new Table(6); float[] lockWidth = { 220f, 220f, 220f, 220f, 220f, 220f }; lockTable.setWidths(lockWidth); lockTable.setWidth(100); // 90% lockTable.setAlignment(Element.ALIGN_CENTER);// lockTable.setAutoFillEmptyCells(true); // lockTable.setBorderWidth(1); // lockTable.setBorderColor(new Color(0, 125, 255)); // lockTable.setPadding(2);// lockTable.setSpacing(0);// lockTable.setBorder(2);// cell = new Cell(new Phrase(" ", titleFont)); cell.setColspan(6); lockTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); // lockTable.endHeaders(); List dblock = (ArrayList) dbinfo.get("lockList");// if (dblock != null && dblock.size() > 0) { for (int i = 0; i < dblock.size(); i++) { Hashtable tablesVO = (Hashtable) dblock.get(i); String type = (String) tablesVO.get("type"); String desc = ""; if ("B".equals(type)) { desc = ""; } else if ("IS".equals(type)) { desc = ""; } else if ("S".equals(type)) { desc = ""; } else if ("XS".equals(type)) { desc = ""; } else if ("U".equals(type)) { desc = ""; } else if ("IX".equals(type)) { desc = ""; } else if ("SIX".equals(type)) { desc = ""; } else if ("X".equals(type)) { desc = ""; } else if ("XR".equals(type)) { desc = ""; } cell = new Cell(new Phrase((i + 1) + "")); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("username"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("hostname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("dbsname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase((String) tablesVO.get("tabname"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); cell = new Cell(new Phrase(desc, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // lockTable.addCell(cell); } } document.add(lockTable); if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.close(); } catch (Exception e) { SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI date 2010-11-11 doc// w w w .j av a 2 s . c o m */ public void createReportPingDoc(String filename) { try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String dbtype = (String) reportHash.get("dbtype"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); // System.out.println("newi ========================"+newip); Paragraph title = new Paragraph(dbtype + "(" + ip + ")" + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n" + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); Table aTable = new Table(4); float[] widths = { 220f, 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(""); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(new Phrase((String) // maxping.get("pingmax"),contextFont)); cell = new Cell(new Phrase(reportHash.get("pingnow") + "%", contextFont));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // cell = new Cell(new Phrase((String) // maxping.get("ping"),contextFont)); cell = new Cell(new Phrase(reportHash.get("pingmin") + "%", contextFont));// HONGLI // MODIFY cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase(reportHash.get("avgpingcon") + "%", contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); document.add(aTable); document.add(img); document.close(); } catch (Exception e) { SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI word/*from w w w . j a v a 2 s . c om*/ * @param filename * @throws DocumentException * @throws IOException */ public void createReport_EventDoc(String filename) throws IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String typename = (String) reportHash.get("typename"); DBVo vo = (DBVo) reportHash.get("vo"); String downnum = (String) reportHash.get("downnum"); String count = (Integer) reportHash.get("count") + ""; String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ // Table dbTable = new Table(5); float[] cellWidths = { 220f, 220f, 220f, 220f, 220f }; dbTable.setWidths(cellWidths); dbTable.setWidth(100); // 90% dbTable.setAlignment(Element.ALIGN_CENTER);// dbTable.setAutoFillEmptyCells(true); // dbTable.setBorderWidth(1); // dbTable.setBorderColor(new Color(0, 125, 255)); // dbTable.setPadding(2);// dbTable.setSpacing(0);// dbTable.setBorder(2);// dbTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setColspan(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("IP", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(" ", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(vo.getDbName(), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(ip, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(typename, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(downnum, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); cell = new Cell(new Phrase(count, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // dbTable.addCell(cell); document.add(dbTable); addEventListToDoc(document, titleFont, contextFont); document.close(); } catch (Exception e) { // SysLogger.error("Error in ExcelReport.createReport()",e); SysLogger.error("", e); } }
From source file:com.afunms.report.abstraction.ExcelReport1.java
/** * @author HONGLI MySQL doc//from www .ja v a2s . c o m * @param filename * @throws DocumentException * @throws IOException */ public void createReportMySQLSelfDoc(String filename) throws DocumentException, IOException { if (impReport.getTable() == null) { fileName = null; return; } try { // Document document = new Document(PageSize.A4); // (Writer)document(Writer) RtfWriter2.getInstance(document, new FileOutputStream(filename)); document.open(); // BaseFont bfChinese = BaseFont.createFont("Times-Roman", "", BaseFont.NOT_EMBEDDED); // Font titleFont = new Font(bfChinese, 12, Font.BOLD); // Font contextFont = new Font(bfChinese, 12, Font.NORMAL); String hostname = (String) reportHash.get("dbname"); String ip = (String) reportHash.get("ip"); String newip = doip(ip); Paragraph title = new Paragraph(hostname + "", titleFont); // title.setAlignment(Element.ALIGN_CENTER); // title.setFont(titleFont); document.add(title); String Ping = (String) reportHash.get("Ping"); String starttime = (String) reportHash.get("starttime"); String totime = (String) reportHash.get("totime"); Vector val = (Vector) reportHash.get("Val"); Hashtable maxping = (Hashtable) reportHash.get("ping"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String contextString = ":" + impReport.getTimeStamp() + " \n"// + ":" + starttime + " " + totime; Paragraph context = new Paragraph(contextString, contextFont); // context.setAlignment(Element.ALIGN_LEFT); // context.setFont(contextFont); // context.setSpacingBefore(5); // context.setFirstLineIndent(5); document.add(context); /* * tmpLabel = new Label(0, 1, ":" + impReport.getTimeStamp()); * sheet.addCell(tmpLabel); tmpLabel = new Label(0, 2, ": " + * starttime + " " + totime); */ Table aTable = new Table(3); float[] widths = { 220f, 220f, 220f }; aTable.setWidths(widths); aTable.setWidth(100); // 90% aTable.setAlignment(Element.ALIGN_CENTER);// aTable.setAutoFillEmptyCells(true); // aTable.setBorderWidth(1); // aTable.setBorderColor(new Color(0, 125, 255)); // aTable.setPadding(2);// aTable.setSpacing(0);// aTable.setBorder(2);// aTable.endHeaders(); Cell cell = null; cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase("", titleFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingnow"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("pingmax"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); cell = new Cell(new Phrase((String) maxping.get("avgpingcon"), contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable.addCell(cell); // document.add(aTable); Image img = Image.getInstance(ResourceCenter.getInstance().getSysPath() + "/resource/image/jfreechart/" + newip + "ConnectUtilization" + ".png"); img.setAlignment(Image.LEFT);// document.add(img); document.add(new Paragraph("\n")); Table aTable1 = new Table(2); float[] width = { 220f, 220f }; aTable1.setWidths(width); aTable1.setWidth(100); // 90% aTable1.setAlignment(Element.ALIGN_CENTER);// aTable1.setAutoFillEmptyCells(true); // aTable1.setBorderWidth(1); // aTable1.setBorderColor(new Color(0, 125, 255)); // aTable1.setPadding(2);// aTable1.setSpacing(0);// aTable1.setBorder(2);// cell = new Cell(new Phrase("", titleFont)); cell.setColspan(2); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); // if (val != null && val.size() > 0) { for (int i = 0; i < val.size(); i++) { Hashtable return_value = (Hashtable) val.get(i); if (return_value != null && return_value.size() > 0) { String name = return_value.get("variable_name").toString(); String value = return_value.get("value").toString(); if (name.equalsIgnoreCase("Max_used_connections")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_first")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_key")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_next")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_prev")) { name = ""; } if (name.equalsIgnoreCase("Handler_read_rnd")) { name = "H"; } if (name.equalsIgnoreCase("Handler_read_rnd_next")) { name = ""; } if (name.equalsIgnoreCase("Open_tables")) { name = ""; } if (name.equalsIgnoreCase("Opened_tables")) { name = ""; } if (name.equalsIgnoreCase("Threads_cached")) { name = ""; } if (name.equalsIgnoreCase("Threads_connected")) { name = ""; } if (name.equalsIgnoreCase("Threads_created")) { name = ""; } if (name.equalsIgnoreCase("Threads_running")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_immediate")) { name = ""; } if (name.equalsIgnoreCase("Table_locks_waited")) { name = ""; } if (name.equalsIgnoreCase("Key_read_requests")) { name = ""; } if (name.equalsIgnoreCase("Key_reads")) { name = ""; } if (name.equalsIgnoreCase("log_slow_queries")) { name = ""; } if (name.equalsIgnoreCase("slow_launch_time")) { name = "Slow_launch_threads"; } cell = new Cell(new Phrase(name, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); cell = new Cell(new Phrase(value, contextFont)); cell.setHorizontalAlignment(Element.ALIGN_CENTER); // cell.setVerticalAlignment(Element.ALIGN_MIDDLE); // aTable1.addCell(cell); } } } if (impReport.getChart() != null) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { ChartUtilities.writeChartAsPNG(baos, impReport.getChart().getChart(), impReport.getChart().getWidth(), impReport.getChart().getHeight()); } catch (IOException ioe) { } Image img1 = Image.getInstance(baos.toByteArray()); img1.setAbsolutePosition(0, 0); img1.setAlignment(Image.MIDDLE);// document.add(img1); } document.add(aTable1); document.close(); } catch (Exception e) { SysLogger.error("", e); } }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private Table createOptionsQuestionStatisticsTableHeader(String optionLabel, String optionFrequencyLabel) throws Exception { Table statsTable; Cell cell;/*w ww . j av a 2 s . co m*/ statsTable = new Table(7); statsTable.setWidth(94); statsTable.setBorder(0); statsTable.setOffset(5); statsTable.setPadding(2); statsTable.setDefaultCellBorder(0); statsTable.setWidths(new int[] { 4, 2, 1, 1, 1, 1, 1 }); cell = new Cell(new Paragraph(optionLabel, boldedFont)); cell.setBorder(Cell.BOTTOM); statsTable.addCell(cell); cell = new Cell(new Paragraph(optionFrequencyLabel, boldedFont)); cell.setBorder(Cell.BOTTOM); statsTable.addCell(cell); cell = new Cell(new Paragraph("20%", boldedFont)); cell.setBorder(Cell.BOTTOM); cell.setHorizontalAlignment(cell.ALIGN_RIGHT); statsTable.addCell(cell); cell = new Cell(new Paragraph("40%", boldedFont)); cell.setBorder(Cell.BOTTOM); cell.setHorizontalAlignment(cell.ALIGN_RIGHT); statsTable.addCell(cell); cell = new Cell(new Paragraph("60%", boldedFont)); cell.setBorder(Cell.BOTTOM); cell.setHorizontalAlignment(cell.ALIGN_RIGHT); statsTable.addCell(cell); cell = new Cell(new Paragraph("80%", boldedFont)); cell.setBorder(Cell.BOTTOM); cell.setHorizontalAlignment(cell.ALIGN_RIGHT); statsTable.addCell(cell); cell = new Cell(new Paragraph("100%", boldedFont)); cell.setBorder(Cell.BOTTOM); cell.setHorizontalAlignment(cell.ALIGN_RIGHT); statsTable.addCell(cell); return statsTable; }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeBooleanMatrixQuestionStatistics(Document document, Question question, List<QuestionStatistic> questionStatistics, String trueLabel, String falseLabel) throws Exception { NumberFormat percentFormat = NumberFormat.getPercentInstance(); percentFormat.setMaximumFractionDigits(1); Table statsTable; Cell cell;// ww w .ja v a2 s . c o m statsTable = new Table(question.getColumnLabels().size() + 1); statsTable.setWidth(94); statsTable.setBorder(0); statsTable.setOffset(5); statsTable.setPadding(2); statsTable.setDefaultCellBorder(0); //header cell = new Cell(); cell.setBorder(Cell.BOTTOM); statsTable.addCell(cell); for (QuestionColumnLabel columnLabel : question.getColumnLabels()) { cell = new Cell(new Paragraph(columnLabel.getLabel(), boldedFont)); cell.setBorder(Cell.BOTTOM); statsTable.addCell(cell); } int rowIndex = 1; for (QuestionRowLabel rowLabel : question.getRowLabels()) { cell = new Cell(new Paragraph(rowLabel.getLabel(), boldedFont)); cell.setBorder(Cell.RIGHT); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(244, 244, 244)); } statsTable.addCell(cell); for (QuestionColumnLabel columnLabel : question.getColumnLabels()) { boolean found = false; cell = new Cell(); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(244, 244, 244)); } for (QuestionStatistic questionStatistic : questionStatistics) { if (questionStatistic.getRowOrder().equals(rowLabel.getOrder()) && questionStatistic.getColumnOrder().equals(columnLabel.getOrder()) && questionStatistic.getEntry().equals("1")) { cell.add(new Paragraph( trueLabel + ": " + percentFormat.format(questionStatistic.getFrequency()), normalFont)); found = true; break; } } if (!found) { cell.add(new Paragraph(trueLabel + ": " + percentFormat.format(0), normalFont)); } found = false; for (QuestionStatistic questionStatistic : questionStatistics) { if (questionStatistic.getRowOrder().equals(rowLabel.getOrder()) && questionStatistic.getColumnOrder().equals(columnLabel.getOrder()) && questionStatistic.getEntry().equals("0")) { cell.add(new Paragraph( falseLabel + ": " + percentFormat.format(questionStatistic.getFrequency()), normalFont)); found = true; break; } } if (!found) { cell.add(new Paragraph(falseLabel + ": " + percentFormat.format(0), normalFont)); } statsTable.addCell(cell); } rowIndex++; } document.add(statsTable); }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeNumericMatrixQuestionStatistics(Document document, Question question, List<QuestionStatistic> questionStatistics, String minimumLabel, String maximumLabel, String averageLabel, String standardDeviationLabel) throws Exception { NumberFormat percentFormat = NumberFormat.getPercentInstance(); percentFormat.setMaximumFractionDigits(1); Table statsTable; Cell cell;/*from w w w. ja va 2 s .c om*/ statsTable = new Table(question.getColumnLabels().size() + 1); statsTable.setWidth(94); statsTable.setBorder(0); statsTable.setOffset(5); statsTable.setPadding(2); statsTable.setDefaultCellBorder(0); //header cell = new Cell(); cell.setBorder(Cell.BOTTOM); statsTable.addCell(cell); for (QuestionColumnLabel columnLabel : question.getColumnLabels()) { cell = new Cell(new Paragraph(columnLabel.getLabel(), boldedFont)); cell.setBorder(Cell.BOTTOM); statsTable.addCell(cell); } int rowIndex = 1; for (QuestionRowLabel rowLabel : question.getRowLabels()) { cell = new Cell(new Paragraph(rowLabel.getLabel(), boldedFont)); cell.setBorder(Cell.RIGHT); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(244, 244, 244)); } statsTable.addCell(cell); for (QuestionColumnLabel columnLabel : question.getColumnLabels()) { boolean found = false; cell = new Cell(); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(244, 244, 244)); } for (QuestionStatistic questionStatistic : questionStatistics) { if (questionStatistic.getRowOrder().equals(rowLabel.getOrder()) && questionStatistic.getColumnOrder().equals(columnLabel.getOrder())) { cell.add(new Paragraph( minimumLabel + ": " + BigDecimalValidator.getInstance() .format(questionStatistic.getMin(), LocaleContextHolder.getLocale()), normalFont)); cell.add(new Paragraph( maximumLabel + ": " + BigDecimalValidator.getInstance() .format(questionStatistic.getMax(), LocaleContextHolder.getLocale()), normalFont)); cell.add(new Paragraph( averageLabel + ": " + BigDecimalValidator.getInstance() .format(questionStatistic.getAverage(), LocaleContextHolder.getLocale()), normalFont)); cell.add(new Paragraph(standardDeviationLabel + ": " + BigDecimalValidator.getInstance().format( questionStatistic.getSampleStandardDeviation(), LocaleContextHolder.getLocale()), normalFont)); break; } } if (!found) { } statsTable.addCell(cell); } rowIndex++; } document.add(statsTable); }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeCurrencyMatrixQuestionStatistics(Document document, Question question, List<QuestionStatistic> questionStatistics, String minimumLabel, String maximumLabel, String averageLabel, String standardDeviationLabel) throws Exception { NumberFormat percentFormat = NumberFormat.getPercentInstance(); percentFormat.setMaximumFractionDigits(1); Table statsTable; Cell cell;// www .j av a 2 s . c o m statsTable = new Table(question.getColumnLabels().size() + 1); statsTable.setWidth(94); statsTable.setBorder(0); statsTable.setOffset(5); statsTable.setPadding(2); statsTable.setDefaultCellBorder(0); //header cell = new Cell(); cell.setBorder(Cell.BOTTOM); statsTable.addCell(cell); for (QuestionColumnLabel columnLabel : question.getColumnLabels()) { cell = new Cell(new Paragraph(columnLabel.getLabel(), boldedFont)); cell.setBorder(Cell.BOTTOM); statsTable.addCell(cell); } int rowIndex = 1; for (QuestionRowLabel rowLabel : question.getRowLabels()) { cell = new Cell(new Paragraph(rowLabel.getLabel(), boldedFont)); cell.setBorder(Cell.RIGHT); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(244, 244, 244)); } statsTable.addCell(cell); for (QuestionColumnLabel columnLabel : question.getColumnLabels()) { boolean found = false; cell = new Cell(); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(244, 244, 244)); } for (QuestionStatistic questionStatistic : questionStatistics) { if (questionStatistic.getRowOrder().equals(rowLabel.getOrder()) && questionStatistic.getColumnOrder().equals(columnLabel.getOrder())) { cell.add(new Paragraph( minimumLabel + ": " + CurrencyValidator.getInstance() .format(questionStatistic.getMin(), LocaleContextHolder.getLocale()), normalFont)); cell.add(new Paragraph( maximumLabel + ": " + CurrencyValidator.getInstance() .format(questionStatistic.getMax(), LocaleContextHolder.getLocale()), normalFont)); cell.add(new Paragraph( averageLabel + ": " + CurrencyValidator.getInstance() .format(questionStatistic.getAverage(), LocaleContextHolder.getLocale()), normalFont)); cell.add(new Paragraph(standardDeviationLabel + ": " + CurrencyValidator.getInstance().format( questionStatistic.getSampleStandardDeviation(), LocaleContextHolder.getLocale()), normalFont)); break; } } if (!found) { } statsTable.addCell(cell); } rowIndex++; } document.add(statsTable); }
From source file:com.jd.survey.web.pdf.StatisticsPdf.java
License:Open Source License
private void writeDateMatrixQuestionStatistics(Document document, Question question, List<QuestionStatistic> questionStatistics, String minimumLabel, String maximumLabel, String dateFormat) throws Exception { NumberFormat percentFormat = NumberFormat.getPercentInstance(); percentFormat.setMaximumFractionDigits(1); Table statsTable; Cell cell;/*from ww w .j a v a 2 s.c o m*/ statsTable = new Table(question.getColumnLabels().size() + 1); statsTable.setWidth(94); statsTable.setBorder(0); statsTable.setOffset(5); statsTable.setPadding(2); statsTable.setDefaultCellBorder(0); //header cell = new Cell(); cell.setBorder(Cell.BOTTOM); statsTable.addCell(cell); for (QuestionColumnLabel columnLabel : question.getColumnLabels()) { cell = new Cell(new Paragraph(columnLabel.getLabel(), boldedFont)); cell.setBorder(Cell.BOTTOM); statsTable.addCell(cell); } int rowIndex = 1; for (QuestionRowLabel rowLabel : question.getRowLabels()) { cell = new Cell(new Paragraph(rowLabel.getLabel(), boldedFont)); cell.setBorder(Cell.RIGHT); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(244, 244, 244)); } statsTable.addCell(cell); for (QuestionColumnLabel columnLabel : question.getColumnLabels()) { boolean found = false; cell = new Cell(); if ((rowIndex % 2) == 1) { cell.setBackgroundColor(new Color(244, 244, 244)); } for (QuestionStatistic questionStatistic : questionStatistics) { if (questionStatistic.getRowOrder().equals(rowLabel.getOrder()) && questionStatistic.getColumnOrder().equals(columnLabel.getOrder())) { cell.add(new Paragraph(minimumLabel + ": " + DateValidator.getInstance().format(questionStatistic.getMinDate(), dateFormat), normalFont)); cell.add(new Paragraph(maximumLabel + ": " + DateValidator.getInstance().format(questionStatistic.getMaxDate(), dateFormat), normalFont)); break; } } if (!found) { } statsTable.addCell(cell); } rowIndex++; } document.add(statsTable); }