charserviceimpl.java

来自「使用jfreechart制作jsp图形统计」· Java 代码 · 共 571 行 · 第 1/2 页

JAVA
571
字号
					.pie2D(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String pie3DChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.pie3D(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.pie3D(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String pie2DMultipleChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.pie2DMultiple(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.pie2DMultiple(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String pie3DMultipleChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.pie3DMultiple(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.pie3DMultiple(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String ringChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.ring(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.ring(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String scatterChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.scatter(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.scatter(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String histogramChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.histogram(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.histogram(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String bubbleChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.bubble(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.bubble(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String ganttChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.gantt(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.gantt(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String highLowChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.highLow(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.highLow(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String candlestickChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.candlestick(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.candlestick(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String polarChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.polar(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.polar(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String waferMapChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.waferMap(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.waferMap(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String waterFallChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.waterFall(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.waterFall(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String timeSeriesChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.timeSeries(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.timeSeries(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	public String windPlotChar(DatasetObj datasetObj, String reportpath,
			String imgname, String imgtype, int width, int hight)
			throws Exception {
		charname = reportpath + imgname + "." + imgtype;
		image = imgname + "." + imgtype;
		if ("png".equals(imgtype)) {
			isChartAsPNG(new FileOutputStream(charname), this.crimpl
					.windPlot(datasetObj), width, hight);
		} else if ("jpg".equals(imgtype)) {
			isChartAsJPEG(new FileOutputStream(charname), this.crimpl
					.windPlot(datasetObj), width, hight);
		} else {
			image = "";
		}
		return image;
	}

	/**
	 * 生成PNG图
	 * 
	 * @throws IOException
	 */
	private static void isChartAsPNG(FileOutputStream fos_jpg,
			JFreeChart chart, int width, int hight) throws Exception {
		ChartUtilities.writeChartAsPNG(fos_jpg, chart, width, hight);
		fos_jpg.close();
	}

	/**
	 * 生成JPEG图
	 * 
	 * @throws IOException
	 */
	private static void isChartAsJPEG(FileOutputStream fos_jpg,
			JFreeChart chart, int width, int hight) throws Exception {
		ChartUtilities.writeChartAsJPEG(fos_jpg, 0.7f, chart, width, hight);
		fos_jpg.close();
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?