HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
使用Jfreechart時,我的X軸數(shù)據(jù)TimeSeries的時間跨度是從0-23點,可是我發(fā)現(xiàn)當(dāng)數(shù)據(jù)中包含12點的時候,TimeSeries會自動將該時間設(shè)置為0點,難道是要將X軸設(shè)置為24小時制?但是貌似除了12點有問題外,它默認(rèn)的是為24小時制的。求解!
代碼如下:
package com.sinocrm.utils; import com.sun.image.codec.jpeg.JPEGImageEncoder; import org.apache.poi.hssf.usermodel.*; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; import org.jfree.chart.StandardChartTheme; import org.jfree.chart.axis.DateAxis; import org.jfree.chart.labels.ItemLabelAnchor; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.labels.StandardXYItemLabelGenerator; import org.jfree.chart.plot.XYPlot; import org.jfree.chart.renderer.xy.XYItemRenderer; import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; import org.jfree.data.time.*; import org.jfree.data.xy.XYDataset; import org.jfree.ui.RectangleInsets; import org.jfree.ui.TextAnchor; import sun.awt.image.codec.JPEGImageEncoderImpl; import sun.tools.jar.resources.jar_fr; import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.List; /** * Created by ds on 14-7-11. * 創(chuàng)建一個橫坐標(biāo)為時間的圖標(biāo) */ public class JfreeChartUtil { /** * 設(shè)置工廠創(chuàng)建的圖表樣式 * 此設(shè)置主要解決中文亂碼問題 */ private static void setCNTheme() { //創(chuàng)建主題樣式 StandardChartTheme standardChartTheme = new StandardChartTheme("CN"); //設(shè)置標(biāo)題字體 standardChartTheme.setExtraLargeFont(new Font("隸書", Font.BOLD, 20)); //設(shè)置圖例的字體 standardChartTheme.setRegularFont(new Font("宋書", Font.PLAIN, 15)); //設(shè)置軸向的字體 standardChartTheme.setLargeFont(new Font("宋書", Font.PLAIN, 15)); //設(shè)置畫布背景為白色 standardChartTheme.setPlotBackgroundPaint(Color.white); //設(shè)置網(wǎng)格豎線顏色為紅色 standardChartTheme.setDomainGridlinePaint(Color.pink); //設(shè)置網(wǎng)格橫線顏色為紅色 standardChartTheme.setRangeGridlinePaint(Color.pink); //設(shè)置曲線圖與XY軸的距離 standardChartTheme.setAxisOffset(new RectangleInsets(0d, 0d, 0d, 0d)); //應(yīng)用主題樣式 ChartFactory.setChartTheme(standardChartTheme); } /** * 創(chuàng)建一個橫坐標(biāo)為時間,只有一個序列的折線圖 * * @param title 圖形的title * @param yLabel Y軸的標(biāo)簽 * @param seriesName 序列的名稱(用于圖例顯示) * @param list 數(shù)據(jù)集合(object[]數(shù)據(jù)中第一個參數(shù)為時間(String或者是date),第二參數(shù)為具體數(shù)據(jù) * @return */ public static JFreeChart createTimeSeriesChart(String title, String yLabel, String seriesName, List list) { //設(shè)置畫布的默認(rèn)主題 setCNTheme(); //創(chuàng)建圖形線 XYDataset dataset = createDataset(seriesName, list); //創(chuàng)建圖形 return createTimeChart(title, yLabel, dataset); } /** * 創(chuàng)建一個橫坐標(biāo)為時間,只有一個序列的折線圖 * * @param title 圖形的title * @param yLabel Y軸的標(biāo)簽 * @param seriesName 序列的名稱集合,與data的長度一致(用于圖例顯示) * @param data 數(shù)據(jù)按照序列集合存放(object[]數(shù)據(jù)中第一個參數(shù)為時間(String或者是date),第二參數(shù)為具體數(shù)據(jù) ) * @return */ public static JFreeChart createTimeSeriesChart(String title, String yLabel, String[] seriesName, List> data) { //設(shè)置畫布的默認(rèn)主題 setCNTheme(); //創(chuàng)建圖形線 XYDataset dataset = createDataset(seriesName, data); //創(chuàng)建圖形 return createTimeChart(title, yLabel, dataset); } /** * 用給定數(shù)據(jù)集創(chuàng)建一個時間折線圖 * * @param title 圖title m * @param yLabel Y軸標(biāo)簽 * @param dataset 數(shù)據(jù)集合 * @return JFreeChart
*/ private static JFreeChart createTimeChart(String title, String yLabel, XYDataset dataset) { //獲取X軸的標(biāo)簽 String xLabel = "時間",format = "yyyy-MM-dd"; Number t1 = dataset.getX(0, 0),t2 = dataset.getX(0, dataset.getItemCount(0) - 1); Date d1 = new Date(t1.longValue()),d2= new Date(t2.longValue()); if(MyUtils.compareDate(d1,d2,format)==0){ xLabel += "("+MyUtils.dateToStr(d1,format)+")"; }else { xLabel += "("+MyUtils.dateToStr(d1,format)+"至"+MyUtils.dateToStr(d2,format)+")"; } JFreeChart freeChart = createTimeChart(title, xLabel, yLabel, dataset); return freeChart; } /** * 用給定數(shù)據(jù)集創(chuàng)建一個時間折線圖 * * @param title 圖title m * @param xLabel x軸標(biāo)簽 * @param yLabel Y軸標(biāo)簽 * @param dataset 數(shù)據(jù)集合 * @return JFreeChart
*/ private static JFreeChart createTimeChart(String title, String xLabel,String yLabel, XYDataset dataset) { JFreeChart freeChart = ChartFactory.createTimeSeriesChart(title, xLabel, yLabel, dataset); //設(shè)置X軸的時間格式 /*XYPlot xyplot = freeChart.getXYPlot(); DateAxis dateaxis = (DateAxis)xyplot.getDomainAxis(); SimpleDateFormat sfd = new SimpleDateFormat("HH:mm"); dateaxis.setRange(MyUtils.strToDate("00:00:00","HH????ss"),MyUtils.strToDate("23:59:59","HH????ss")); dateaxis.setDateFormatOverride(sfd); xyplot.setDomainAxis(dateaxis);*/ /* 設(shè)置是否顯示數(shù)據(jù)點并且顯示具體數(shù)據(jù)信息 //設(shè)置數(shù)據(jù)樣式 XYPlot plot = freeChart.getXYPlot(); XYLineAndShapeRenderer lineRender = (XYLineAndShapeRenderer) plot.getRenderer(); //是否顯示數(shù)據(jù)點 lineRender.setBaseShapesVisible(true); //顯示數(shù)據(jù)點 XYItemRenderer itemRenderer = plot.getRenderer(); itemRenderer.setBaseItemLabelsVisible(true); itemRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); itemRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); plot.setRenderer(itemRenderer);*/ return freeChart; } /** * 創(chuàng)建數(shù)據(jù)集合 * * @param collection 用于裝載多序列的集合 * @param seriesName 序列名稱 * @param dataList 序列數(shù)據(jù)的集合 * @return TimeSeriesCollection
*/ private static TimeSeriesCollection createDataset(TimeSeriesCollection collection, String seriesName, List dataList) { if (collection == null) { collection = new TimeSeriesCollection(); } TimeSeries timeSeries = new TimeSeries(seriesName); Date date; double data; for (Object[] objects : dataList) { if (objects == null || objects.length < 2 || objects[0] == null || objects[1] == null) { continue; } if (objects[0] instanceof Date) { date = (Date) objects[0]; } else { date = MyUtils.strToDateTime(objects[0].toString()); } if (objects[1] instanceof Integer) { data = (Integer) objects[1] - 0.0; } else { data = Double.parseDouble(objects[1].toString()); } timeSeries.add(new Second(date), data); } collection.addSeries(timeSeries); return collection; } /** * 創(chuàng)建只有單個序列的數(shù)據(jù)集合 * * @param seriesName 序列名稱 * @param dataList 序列數(shù)據(jù)的集合 * @return TimeSeriesCollection
*/ private static TimeSeriesCollection createDataset(String seriesName, List dataList) { return createDataset(null, seriesName, dataList); } /** * 創(chuàng)建包含多個序列的數(shù)據(jù)集合 * * @param seriesName 序列名稱 * @param dataList 序列數(shù)據(jù)的集合 * @return TimeSeriesCollection
*/ private static TimeSeriesCollection createDataset(String[] seriesName, List> dataList) { TimeSeriesCollection collection = new TimeSeriesCollection(); int index = 0; List temp; for (String name : seriesName) { temp = dataList.get(index++); createDataset(collection, name, temp); } return collection; } /** * 將生成的圖表信息導(dǎo)出到Excel文件中 * * @param freeChart 圖表 * @param workbook Excel工作簿 g * @param sheetName 創(chuàng)建的工作區(qū)的名稱 * @throws IOException */ public static void exportChartToExcel(JFreeChart freeChart, HSSFWorkbook workbook, String sheetName) throws IOException { HSSFSheet sheet = workbook.createSheet(sheetName); HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); HSSFClientAnchor anchor = new HSSFClientAnchor(0, 0, 100, 50, (short) 1, 1, (short) 15, 25); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ChartUtilities.writeChartAsJPEG(outputStream, freeChart, 1000, 500); patriarch.createPicture(anchor, workbook.addPicture(outputStream.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); } /** * 將生成的圖表信息導(dǎo)出到Excel文件中 * * @param freeCharts 圖表集合 * @param workbook Excel工作簿 g * @param sheetName 創(chuàng)建的工作區(qū)的名稱 * @throws IOException */ public static void exportChartToExcel(JFreeChart[] freeCharts, HSSFWorkbook workbook, String sheetName) throws IOException { int row1 = 1, row2 = 25, index = 0; HSSFSheet sheet = workbook.createSheet(sheetName); HSSFPatriarch patriarch = sheet.createDrawingPatriarch(); HSSFClientAnchor anchor; ByteArrayOutputStream outputStream; for (JFreeChart freeChart : freeCharts) { anchor = new HSSFClientAnchor(0, 0, 100, 50, (short) 1, row1, (short) 15, row2); outputStream = new ByteArrayOutputStream(); ChartUtilities.writeChartAsJPEG(outputStream, freeChart, 1000, 500); patriarch.createPicture(anchor, workbook.addPicture(outputStream.toByteArray(), HSSFWorkbook.PICTURE_TYPE_JPEG)); row2 += 28; row1 += 28; } } public void testExportToExcel() throws IOException { List list = new ArrayList(); Object[] objects; double[] data = {2.1, 3.2, 4.4, 3.8, 5.6, 1.2, 3, 5, 5.2, 2.4, 2.2, 1, 3, 4, 2, 1, 1, 2}; for (int i = 13; i < 23; i++) { objects = new Object[]{"2014-7-11 " + i + ":10:12", data[i - 13]}; list.add(objects); } for (int i = 0; i < 8; i++) { objects = new Object[]{"2014-7-12 " + i + ":30:12", data[i]}; list.add(objects); } JFreeChart[] freeCharts = new JFreeChart[3]; freeCharts[0] = JfreeChartUtil.createTimeSeriesChart("測試圖例1", "Y軸", "序列一", list); freeCharts[1] = JfreeChartUtil.createTimeSeriesChart("測試圖例2", "Y軸", "序列er一", list); freeCharts[2] = JfreeChartUtil.createTimeSeriesChart("測試圖例3", "Y軸", "序列3一", list); String filePath = "H:/test_file/jFreeChart/excels/test.xls"; HSSFWorkbook workbook = new HSSFWorkbook(); JfreeChartUtil.exportChartToExcel(freeCharts, workbook, "圖表"); OutputStream fos = null; try { File file = new File(filePath); if (file.getParent() != null && !file.exists()) { file.mkdirs(); } fos = new FileOutputStream(filePath); HSSFSheet sheet = workbook.createSheet("test"); for (int i = 0; i < 5; i++) { HSSFRow row = sheet.createRow(i); for (int j = 0; j < 6; j++) { HSSFCell cell = row.createCell(j); cell.setCellValue(i + ":" + j); } } workbook.write(fos); } catch (Exception e) { e.printStackTrace(); } finally { if (fos != null) { fos.close(); } } } public static void testExportToImg() throws IOException { List list = new ArrayList(); Object[] objects; double[] data = {2.1, 3.2, 4.4, 3.8, 5.6, 1.2, 3, 5, 5.2, 2.4, 2.2, 1, 3, 4, 2, 1, 1, 2}; for (int i = 12; i < 23; i++) { objects = new Object[]{"2014-7-11 " + i + ":10:12", data[i - 12]}; list.add(objects); } /*for (int i = 0; i < 8; i++) { objects = new Object[]{"2014-7-12 " + i + ":30:12", data[i]}; list.add(objects); }*/ JFreeChart jFreeChart = JfreeChartUtil.createTimeSeriesChart("測試圖例1","Y軸", "序列一", list); BufferedImage bufferedImage = jFreeChart.createBufferedImage(800, 400); OutputStream outputStream = new FileOutputStream("H:\\test_file\\jFreeChart\\images\\test.jpeg"); JPEGImageEncoder encoder = new JPEGImageEncoderImpl(outputStream); encoder.encode(bufferedImage); outputStream.flush(); outputStream.close(); } public static void main(String[] args) throws IOException { testExportToImg(); } }
運行結(jié)果如下:
12點的值默認(rèn)被置為0點了,這樣的話,如果我的時間是從0點到23點的話,那么生成圖形就會因為時間重復(fù)而報錯,請各位幫我分析一下原因,O(∩_∩)O謝謝
來源:開源中國
發(fā)布時間:2014-08-04 16:30:01
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>> package com.code.jtlAnalyzeExcel; import java.awt.Color; import java.awt.Font; import java.io.FileOutputStream; import java.text.SimpleDateFormat; import javax.swing.JPanel; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.ui.ApplicationFrame; public class LineCharts extends ApplicationFrame { private static final long serialVersionUID = 1L; public LineCharts(String s , ExcelObject excel) { super(s); setContentPane(createDemoLine(excel)); } // 生成顯示圖表的面板 public static JPanel createDemoLine(ExcelObject excel) { JFreeChart jfreechart = createChart(createDataset(excel)); return new ChartPanel(jfreechart); } // 生成圖表主對象JFreeChart public static JFreeChart createChart(DefaultCategoryDataset linedataset) { // 定義圖表對象 JFreeChart chart = ChartFactory.createLineChart("Load Test", //折線圖名稱 "Thread", // 橫坐標(biāo)名稱 "Value", // 縱坐標(biāo)名稱 linedataset, // 數(shù)據(jù) PlotOrientation.VERTICAL, // 水平顯示圖像 true, // include legend false, // tooltips false // urls ); // chart.setBackgroundPaint(Color.red); CategoryPlot plot = chart.getCategoryPlot(); // plot.setDomainGridlinePaint(Color.red); plot.setDomainGridlinesVisible(true); // 5,設(shè)置水平網(wǎng)格線顏色 // plot.setRangeGridlinePaint(Color.blue); // 6,設(shè)置是否顯示水平網(wǎng)格線 plot.setRangeGridlinesVisible(true); plot.setRangeGridlinesVisible(true); //是否顯示格子線 //plot.setBackgroundAlpha(f); //設(shè)置背景透明度 NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); rangeAxis.setUpperMargin(0.20); rangeAxis.setLabelAngle(Math.PI / 2.0); rangeAxis.setAutoRange(false); FileOutputStream fos_jpg=null; try{ fos_jpg=new FileOutputStream("D:\\ok_bing.jpg"); /* * 第二個參數(shù)如果為100,會報異常: * java.lang.IllegalArgumentException: The 'quality' must be in the range 0.0f to 1.0f * 限制quality必須小于等于1,把100改成 0.1f。 */ // ChartUtilities.writeChartAsJPEG(fos_jpg, 0.99f, chart, 600, 300, null); ChartUtilities.writeChartAsJPEG(fos_jpg, chart, 900, 400); }catch(Exception e){ System.out.println("[e]"+e); }finally{ try{ fos_jpg.close(); }catch(Exception e){ } } return chart; } // 生成數(shù)據(jù) public static DefaultCategoryDataset createDataset(ExcelObject excel) { DefaultCategoryDataset linedataset = new DefaultCategoryDataset(); for (int i=0; i
來源:開源中國
發(fā)布時間:2015-01-24 19:13:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
@abian 你好,想跟你請教個問題:我現(xiàn)在做了一個柱狀圖,顯示的是當(dāng)前年度按月分組的短信發(fā)送量,1-12月,我現(xiàn)在想法是,當(dāng)我點擊其中某一個月的柱子的時候,就去數(shù)據(jù)庫查詢這個月的每天的短信發(fā)送量,并以折線圖展示這個月每天的情況,我該怎么先實現(xiàn)點擊柱子生成折線圖呢?
來源:開源中國
發(fā)布時間:2015-01-21 10:13:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
這是我myeclipse 運行的圖片
//生成圖片到本地
FileOutputStream fos_jpg=null;
try{
fos_jpg=new FileOutputStream("D:\\loadTest.jpg");
ChartUtilities.writeChartAsJPEG(fos_jpg, chart, 900, 500);
}catch(Exception e){
System.out.println("[e]"+e);
}finally{
try{
fos_jpg.close();
}catch(Exception e){
}
這是我本地生成的圖片:
為什么背景圖片變了!求高手指教
來源:開源中國
發(fā)布時間:2015-01-26 18:33:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
現(xiàn)有兩個圖需要用jfreechart展示在同一個圖片中(一個是階梯圖(數(shù)據(jù)集類型為XYStepDataset),一個是曲線圖(數(shù)據(jù)集類型為DefaultCategoryDataset)).
查詢了一些資料,只有一些同一類型數(shù)據(jù)集的圖片可以一起展示。沒有不同數(shù)據(jù)集類型的圖片一起展示的代碼事例。
請問誰知道或者有關(guān)的事例代碼。謝謝分享。
來源:開源中國
發(fā)布時間:2014-11-11 10:58:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
@abian 你好,想跟你請教個問題:
我想繪制這樣的圖像,用你的JFreeChart程序LineChart類。一共有50 0000 個數(shù)據(jù),都需要繪制出來,但是如上圖所示,橫軸中,以每50000作為一個坐標(biāo),而不是以1為單位畫一個坐標(biāo)?也就是說如何處理能夠使橫坐標(biāo)只顯示0 50000 100000.。。。。。。而把所有數(shù)據(jù)點在圖中都表示出來?
來源:開源中國
發(fā)布時間:2014-10-23 22:21:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>> request.setCharacterEncoding("GBK"); response.setCharacterEncoding("GBK");
我在doPost方法中添加了這兩句話,還是亂碼,用GB2312和UTF-8都不行,就是亂碼,以下是Servlet代碼:
package com.lxl.Servlet; import java.awt.Font; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; import org.jfree.chart.plot.PiePlot; import org.jfree.data.general.DefaultPieDataset; import org.jfree.data.general.PieDataset; import com.lxl.util.DataUtils; /** * @author 劉星鷺 * @Email liuxinglumail@163.com * @version 創(chuàng)建時間: 2014年10月19日 下午3:53:01 */ public class PieChartServlet extends HttpServlet { private static final long serialVersionUID = 5484024445117181514L; public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("GBK"); response.setCharacterEncoding("GBK"); // 設(shè)置返回類型為圖片 response.setContentType("image/png"); // 獲取數(shù)據(jù)集對象 PieDataset dataset = createPieDataset(); // 創(chuàng)建圖形對象 JFreeChart jFreeChart = ChartFactory.createPieChart3D("08年圖書銷量排行榜", dataset, true, true, false); // 獲得圖表區(qū)域?qū)ο?PiePlot piePlot = (PiePlot) jFreeChart.getPlot(); // 設(shè)置圖表區(qū)域的標(biāo)簽文字 piePlot.setLabelFont(new Font("宋體", 0, 12)); // 設(shè)置圖表區(qū)域無數(shù)據(jù)時的默認(rèn)顯示文字 piePlot.setNoDataMessage("沒有銷售數(shù)據(jù)"); // 設(shè)置圖表區(qū)域不是圓形,由于是3D的餅狀圖,建議設(shè)置為false piePlot.setCircular(false); // 設(shè)置圖表區(qū)域文字與圖表區(qū)域的間隔距離,0.02表示2% piePlot.setLabelGap(0.02D); // 將圖表以數(shù)據(jù)流的方式返回給客戶端 ChartUtilities.writeChartAsPNG(response.getOutputStream(), jFreeChart, 500, 270); } private static PieDataset createPieDataset() { // 創(chuàng)建餅狀圖數(shù)據(jù)集對象 DefaultPieDataset defaultPieDataset = new DefaultPieDataset(); // 分別設(shè)置圖形區(qū)域的說明和數(shù)據(jù) defaultPieDataset.setValue("JAVA", DataUtils.getRandomData()); defaultPieDataset.setValue("C/C++", DataUtils.getRandomData()); defaultPieDataset.setValue("PHP", DataUtils.getRandomData()); defaultPieDataset.setValue("JavaScript", DataUtils.getRandomData()); defaultPieDataset.setValue("Ajax", DataUtils.getRandomData()); return defaultPieDataset; } }
亂碼如下圖所示:
來源:開源中國
發(fā)布時間:2014-10-22 14:50:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
最近用jfreechart畫了個蜘蛛圖,發(fā)現(xiàn)數(shù)據(jù)值顯示不出來呀,看了半天API沒有找到顯示數(shù)據(jù)值的地方,有沒有做過的指點告訴一下唄
來源:開源中國
發(fā)布時間:2014-04-28 20:29:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
@鉑金小貓 你好,想跟你請教個問題:
我現(xiàn)在在程序中寫入了
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeImageMap(new PrintWriter(out),filename , info, true);
String str = ChartUtilities.getImageMap( filename,info);
來獲得Map的相應(yīng)信息但是我在后臺打印str
并沒有得到完整的Map信息是什么原因請指教,不勝感激,謝謝!
下面是打印的信息:
area部分的信息丟失了。
我確定CategoryDataset中的數(shù)據(jù)已經(jīng)塞進(jìn)去了。
來源:開源中國
發(fā)布時間:2013-12-24 14:58:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
我在用jfreechart做時序圖時,已經(jīng)實現(xiàn)了將鼠標(biāo)移至具體折點就可以顯示該點的信息(橫縱坐標(biāo)數(shù)據(jù)),但是我現(xiàn)在要實現(xiàn)將熱區(qū)里面的信息替換成我需要的信息。請問大神怎么實現(xiàn)呢??我已經(jīng)嘗試過很多都不行。
來源:開源中國
發(fā)布時間:2014-06-03 17:50:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
grails如果要連接sqlserver2012 配置文件應(yīng)該怎么寫呢???
dataSource {
pooled = true
dbCreate="update"
jmxExport = true
driverClassName = "com.microsoft.jdbc.sqlserver.SQLServerDriver"
username = "sa"
password = ""
}
hibernate {
cache.use_second_level_cache = true
cache.use_query_cache = false
// cache.region.factory_class = 'org.hibernate.cache.SingletonEhCacheRegionFactory' // Hibernate 3
cache.region.factory_class = 'org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory' // Hibernate 4
singleSession = true // configure OSIV singleSession mode
flush.mode = 'manual' // OSIV session flush mode outside of transactional context
}
// environment specific settings
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:microsoft:sqlserver://10.20.24.149:1433;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:microsoft:sqlserver://10.20.24.149:1433;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:microsoft:sqlserver://10.20.24.149:1433;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
properties {
// See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation
jmxEnabled = true
initialSize = 5
maxActive = 50
minIdle = 5
maxIdle = 25
maxWait = 10000
maxAge = 10 * 60000
timeBetweenEvictionRunsMillis = 5000
minEvictableIdleTimeMillis = 60000
validationQuery = "SELECT 1"
validationQueryTimeout = 3
validationInterval = 15000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
jdbcInterceptors = "ConnectionState"
defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED
}
}
}
}
來源:開源中國
發(fā)布時間:2015-09-25 18:37:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>> grails 自帶的分頁樣式實在太難看了,我想問下怎么能更改grails 自帶分頁樣式。
來源:開源中國
發(fā)布時間:2015-01-30 11:50:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>> gsp 中對EL表達(dá)的問題,我在gsp中使用EL表達(dá)式比如用{emprty} 等都不識別. 誰能告訴我為什么?謝謝
來源:開源中國
發(fā)布時間:2014-12-20 09:24:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
在cmd中用命令敲出來的demo拿到idea中無法跑起來
錯誤: 找不到或無法加載主類 org.codehaus.groovy.grails.cli.support.GrailsStarter
來源:開源中國
發(fā)布時間:2015-06-16 17:04:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
我們現(xiàn)在有一個功能在后臺大概執(zhí)行20分鐘左右,然后頁面沒響應(yīng),一直在哪里轉(zhuǎn)圈啊轉(zhuǎn)圈啊。
以前數(shù)據(jù)量小的時候,執(zhí)行7分鐘左右是沒有問題,現(xiàn)在在本地執(zhí)行30分鐘,頁面也是有響應(yīng)的??稍谏a(chǎn)機上就是頁面沒有響應(yīng),頁面上的Ajax超時也設(shè)置過了,服務(wù)器上Tomcat和Nginx的超時時間運維也說設(shè)置過了。
請求哪位大牛幫忙分析下!!!謝謝?。?
來源:開源中國
發(fā)布時間:2015-05-30 23:04:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
itext5 document關(guān)閉時 會報The document has no pages.
來源:開源中國
發(fā)布時間:2019-08-19 16:32:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
遇到一個需求 要求用戶上傳word模板 服務(wù)端做替換占位符 生成表格 表格插入數(shù)據(jù)
poi 插入的表格在文章末尾 替換的字符串太長的話也無法替換 所以不能用
jacob 不支持linux 所以也不能用
網(wǎng)上找openoffice+JODConverter 操作word 以及itext操作word的資料很少 大多是word轉(zhuǎn)pdf的 問一下有沒有 用過這兩種方法操作word的 或者還有別的更好的解決方案
來源:開源中國
發(fā)布時間:2018-04-09 12:01:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
對本來存在的pdf文件,通過PdfReader讀取,獲取PdfStamper和PdfSignatureAppearance,設(shè)置pdf的簽名,這個功能已經(jīng)實現(xiàn)。
但是現(xiàn)在不存在pdf文件,只有PdfWriter對象,PdfWriter對象可以生成pdf文件。如何直接通過PdfWriter對象對pdf進(jìn)行簽名,然后再生成pdf文件?
跪求大神指導(dǎo)!
來源:開源中國
發(fā)布時間:2016-03-02 17:18:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
我找了現(xiàn)有的java操作word的一些類庫,支持windows的排除,因為服務(wù)器在linux環(huán)境。
通用的操作word也就是POI和Itext了吧,當(dāng)然xml做模板的方式不滿足需求。
現(xiàn)在遇到一個問題,需要在word上做背景圖,也就是圖片填充,我實在找不到這方面的實現(xiàn)方法,
OSC有人做過類似的功能嗎?
來源:開源中國
發(fā)布時間:2015-06-11 13:22:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
前臺jsp 頁面 通過js 調(diào)用 Action 里的方法.如下:
public void getPdfFileForDetail(HttpServletRequest request,
HttpServletResponse response) throws RemoteException,Exception{
response.setContentType("contentType=application/pdf");
request.setCharacterEncoding("UTF-8");
String method = HttpUtil.getParameter(request, "method");//PDF文件的操作方式:handLoad--手動下載到本地,ftp--寫到ftp服務(wù)器上
/** 設(shè)置PDF文檔的樣式 **/
// 定義一個A4大小的矩形組件
Rectangle rect = new Rectangle(PageSize.A4);
// 設(shè)置背景顏色為淺灰色
// rect.setBackgroundColor(BaseColor.LIGHT_GRAY);
// 設(shè)置border類型為box
rect.setBorder(rect.BOX);
// 設(shè)置border的顏色為淺灰色
rect.setBorderColor(BaseColor.LIGHT_GRAY);
// 設(shè)置border的寬度
rect.setBorderWidth(5);
// 創(chuàng)建一個PDF文檔,將rect作為文檔的預(yù)設(shè)樣式,后面的10,10,10,10是文檔的邊外距
Document document = new Document(rect, 10, 10, 10, 10);
// 頁邊空白
document.setMargins(20, 20, 30, 40);
ByteArrayOutputStream ba = new ByteArrayOutputStream();
String filename = "";
try {
/****統(tǒng)計信息****/
String ysCount = HttpUtil.getParameter(request, "ysCount");//預(yù)算工時
String ysTotal = HttpUtil.getParameter(request, "ysTotal");//需求預(yù)算數(shù)
String compGsCount = HttpUtil.getParameter(request, "compGsCount")+"人日";//完成工時數(shù)量
String completeCount = HttpUtil.getParameter(request, "completeCount");//完成需求數(shù)量
String modifyCount = HttpUtil.getParameter(request, "modifyCount");//需求變更數(shù)量
String hjGsCount = HttpUtil.getParameter(request, "hjGsCount");//核減工時數(shù)
String compProZb = HttpUtil.getParameter(request, "compProZb")+"%";//工時使用率
String compBl = HttpUtil.getParameter(request, "compBl")+"%";//需求完成率
String modifyB = HttpUtil.getParameter(request, "modifyB")+"%";//需求變更率
String hjGsBl = HttpUtil.getParameter(request, "hjGsBl")+"%";//核減工時率
String jsGsCount = HttpUtil.getParameter(request, "jsGsCount");//結(jié)算工時數(shù)量
String conResXs = HttpUtil.getParameter(request, "conResXs");//合同結(jié)算系數(shù)
filename = contract_name + "結(jié)算明細(xì).pdf";// 文件名
PdfWriter writer = PdfWriter.getInstance(document, ba);
//****設(shè)置頁眉頁腳****/
//** code **/
//設(shè)置PDF字體
BaseFont base = null;
Font fontchinese = null;
Font headFont1 = null;
Font headFont2 = null;
Font headFont3 = null;
try {
base = BaseFont.createFont(PdfTextExtractor.class.getResource("/") + "/simsun.ttc,1", BaseFont.IDENTITY_H,BaseFont.NOT_EMBEDDED);
fontchinese = new Font(base, 8, Font.NORMAL);
headFont1 = new Font(base, 8, Font.BOLD);
headFont2 = new Font(base, 14, Font.BOLD);
headFont3 = new Font(base, 10, Font.BOLD);
} catch (DocumentException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
document.open();
Paragraph title = new Paragraph(contract_name
+ "結(jié)算明細(xì)", headFont2);
title.setSpacingAfter(20f);// 設(shè)置文檔題目下方的空白高度
title.setAlignment(Element.ALIGN_CENTER);// 文檔標(biāo)題居中
title.setLeading(1f);// 設(shè)置行間距,設(shè)置上面空白寬度
document.add(title);// 標(biāo)題
// 寫入合同統(tǒng)計信息
Chunk title2 = new Chunk("合同統(tǒng)計信息", headFont3);
title2.setBackground(new BaseColor(0xEE,0xEE,0xEE),0,0,495,0);
// title2.setLineHeight(5);
Paragraph titleTwo = new Paragraph();
titleTwo.add(title2);
document.add(titleTwo);
float[] tb2_widths = {100f,100f,100f,100f};
PdfPTable table2 = new PdfPTable(tb2_widths);
table2.setSpacingBefore(5f);// 設(shè)置表格上面空白寬度
table2.setSpacingAfter(10f);// 設(shè)置表格下面空白寬度
table2.setTotalWidth(400);// 設(shè)置表格的寬度
table2.setWidthPercentage(100);// 設(shè)置表格寬度為%100
table2.setLockedWidth(false);// 設(shè)置表格的寬度不固定
table2.getDefaultCell().setBorder(0);// 設(shè)置表格默認(rèn)為無邊框
// table2.getDefaultCell().setBorderColor(BaseColor.WHITE);
PdfPCell countCell = null;
for (int n = 1; n <= 12; n++) {
if (n == 1) {
countCell = new PdfPCell(new Paragraph("預(yù)算工時:"
+ ysCount, fontchinese));
} else if (n == 2) {
countCell = new PdfPCell(new Paragraph("需求預(yù)算數(shù):"
+ ysTotal, fontchinese));
} else if (n == 3) {
countCell = new PdfPCell(new Paragraph("完成工時數(shù)量:"
+ compGsCount, fontchinese));
} else if (n == 4) {
countCell = new PdfPCell(new Paragraph("完成需求數(shù)量:"
+ completeCount, fontchinese));
} else if (n == 5) {
countCell = new PdfPCell(new Paragraph("需求變更數(shù)量:"
+ modifyCount, fontchinese));
} else if (n == 6) {
countCell = new PdfPCell(new Paragraph("核減工時數(shù):"
+ hjGsCount, fontchinese));
} else if (n == 7) {
countCell = new PdfPCell(new Paragraph("工時使用率:"
+ compProZb, fontchinese));
} else if (n == 8) {
countCell = new PdfPCell(new Paragraph("需求完成率:"
+ compBl, fontchinese));
} else if (n == 9) {
countCell = new PdfPCell(new Paragraph("需求變更率:"
+ modifyB, fontchinese));
} else if (n == 10) {
countCell = new PdfPCell(new Paragraph("核減工時率:"
+ hjGsBl, fontchinese));
} else if (n == 11) {
countCell = new PdfPCell(new Paragraph("結(jié)算工時數(shù)量:"
+ jsGsCount, fontchinese));
} else if (n == 12) {
countCell = new PdfPCell(new Paragraph("合同結(jié)算系數(shù):"
+ conResXs, fontchinese));
}
countCell.setFixedHeight(20);
if(n==2 || n==12){
countCell.setColspan(3);//合并單元格(列)
}else{
countCell.setColspan(1);//合并單元格(列)
}
countCell.setBorder(Rectangle.NO_BORDER);//設(shè)置表格無邊框
countCell.setHorizontalAlignment(Element.ALIGN_LEFT);// 設(shè)置內(nèi)容水平左對齊顯示
countCell.setVerticalAlignment(Element.ALIGN_MIDDLE); // 設(shè)置垂直居中
table2.addCell(countCell);
}
document.add(table2);
} catch (FileNotFoundException e) {
e.printStackTrace();
log.error("生成PDF出錯 FileNotFoundException: ", e);
} catch (DocumentException e) {
e.printStackTrace();
log.error("生成PDF出錯 DocumentException", e);
} finally {
document.close();
response.setContentType("contentType=application/pdf");
response.setHeader("Content-Disposition", "attachment;filename=\""
+ StringUtil.toUTF8(filename) + "\"");
ba.writeTo(response.getOutputStream());
response.flushBuffer();
System.out.println("PDF文件下載到本地!");
}
}
報的錯:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)
at com.ai.appframe2.web.action.RequestProcessor.exeMethod(RequestProcessor.java:104)
at com.ai.appframe2.web.action.RequestProcessor.process(RequestProcessor.java:58)
at com.ai.appframe2.web.action.CentralControlServlet.doGet(CentralControlServlet.java:60)
at com.ai.appframe2.web.action.CentralControlServlet.doPost(CentralControlServlet.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:966)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:907)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
at com.ai.appframe2.web.filter.expire.ExpireResponseHeaderFilter.doFilter(ExpireResponseHeaderFilter.java:135)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ai.appframe2.web.filter.LoginFilter.doFilter(LoginFilter.java:176)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ai.appframe2.monitor.URLFilter.doFilter(URLFilter.java:62)
at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:696)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:641)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:475)
at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:463)
at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:92)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1425)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:92)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:465)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:394)
at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:102)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:152)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:213)
at com.ibm.io.async.AbstractAsyncFuture.fireCompletionActions(AbstractAsyncFuture.java:195)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:136)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:193)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:725)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:847)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1498)
Caused by:
ExceptionConverter: java.io.IOException: The document has no pages.
用的itext jar包為:itextpdf-5.3.5.jar,itext-asian.jar
急求各位大俠 幫忙解決,感激不盡!!
來源:開源中國
發(fā)布時間:2013-03-18 14:42:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
itext基于AGPL協(xié)議,是不是我們的應(yīng)用就必須開源?求解答,謝謝
來源:開源中國
發(fā)布時間:2019-07-08 10:40:00
HDC調(diào)試需求開發(fā)(15萬預(yù)算),能者速來!>>>
有個pdf文件,我想把里面的內(nèi)容轉(zhuǎn)換為word。用itext轉(zhuǎn)換的時候格式都沒了,具體見下圖。還有什么工具可以轉(zhuǎn)換出保留格式的pdf。
源文件:
轉(zhuǎn)換后:
來源:開源中國
發(fā)布時間:2019-05-29 16:36:00