博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
fusionchart实现ZoomLine 资源 破解版 出口能力
阅读量:5918 次
发布时间:2019-06-19

本文共 11209 字,大约阅读时间需要 37 分钟。

最近的曲线需要用油画ZoomLine官方网站看了好几天,今天整理出来供大家参考使用

zoomline.html资源

FusionCharts Free Documentation
FusionCharts.
zoomLine.xml源码

以上基本实现了图表的显示工作。假设须要导出还须要下面代码

FCExporterFormat.java源码

package com.fusioncharts.exporter.resources;import javax.servlet.http.HttpServletResponse;import com.fusioncharts.exporter.beans.ExportBean;public abstract class FCExporterFormat {	abstract public Object exportProcessor(ExportBean exportBean);	abstract public String exportOutput(Object exportObj,			HttpServletResponse response);}
FCExporterIMG.java源码

package com.fusioncharts.exporter.resources;import java.awt.image.BufferedImage;import java.io.IOException;import java.io.OutputStream;import java.io.PrintWriter;import javax.servlet.http.HttpServletResponse;import com.fusioncharts.exporter.ErrorHandler;import com.fusioncharts.exporter.FusionChartsExportHelper;import com.fusioncharts.exporter.beans.ChartMetadata;import com.fusioncharts.exporter.beans.ExportBean;import com.fusioncharts.exporter.encoders.BasicEncoder;import com.fusioncharts.exporter.encoders.JPEGEncoder;import com.fusioncharts.exporter.generators.ImageGenerator;public class FCExporterIMG extends FCExporterFormat {		private ExportBean exportBean = null;		public String exportOutput(Object exportObj, HttpServletResponse response) {		String action = (String)exportBean.getExportParameterValue("exportaction");		String exportFormat = (String)exportBean.getExportParameterValue("exportformat");		String exportTargetWindow = (String)exportBean.getExportParameterValue("exporttargetwindow");		String fileNameWithoutExt = (String)exportBean.getExportParameterValue("exportfilename");		String extension = FusionChartsExportHelper.getExtensionFor(exportFormat.toLowerCase());;		String fileName = fileNameWithoutExt+"."+ extension;				StringBuffer err_warn_Codes = new StringBuffer();		BufferedImage chartImage = (BufferedImage)exportObj;		boolean isHTML = false;		if(action.equals("download"))			isHTML=true;		String noticeMessage = "";		String meta_values= exportBean.getMetadataAsQueryString(null,false,isHTML);				if(action.equals("download")){			try { 				response.setContentType(FusionChartsExportHelper.getMimeTypeFor(exportFormat.toLowerCase()));								OutputStream os = response.getOutputStream();								if(exportTargetWindow.equalsIgnoreCase("_self")){					response.addHeader("Content-Disposition", "attachment; filename=\""+fileName+"\"");					//response.addHeader("Content-length",""+ios.length());				} else {					response.addHeader("Content-Disposition", "inline; filename=\""+fileName+"\"");				}				if( exportFormat.toLowerCase().equalsIgnoreCase("jpg") || exportFormat.toLowerCase().equalsIgnoreCase("jpeg")){					JPEGEncoder jpegEncoder = new JPEGEncoder();					try {						jpegEncoder.encode(chartImage,os);						os.flush();					}catch(Throwable e){						//Unable to encode the buffered image						System.out.println("Unable to (JPEG) encode the buffered image");						err_warn_Codes.append("E516,");						//os.flush();						// Note forward will not work in this case, as the output stream has already been opened						// Hence we have to output the error directly.						meta_values =exportBean.getMetadataAsQueryString(null,true,isHTML);						// Reset the response to set new content type and use out instead of outputstream						response.reset();						response.setContentType("text/html");						PrintWriter out = response.getWriter();						out.print(meta_values+noticeMessage+ErrorHandler.buildResponse(err_warn_Codes.toString(),isHTML));						return null;					}					chartImage=null;				} else {										BasicEncoder basicEncoder = new BasicEncoder();					try {						basicEncoder.encode(chartImage,os,1F,exportFormat.toLowerCase());						os.flush();					}catch(Throwable e){						System.out.println("Unable to encode the buffered image");						err_warn_Codes.append("E516,");						//os.flush();						// Note forward will not work in this case, as the output stream has already been opened						// Hence we have to output the error directly.						meta_values =exportBean.getMetadataAsQueryString(null,true,isHTML);						// Reset the response to set new content type and use out instead of outputstream						response.reset();						response.setContentType("text/html");						PrintWriter out = response.getWriter();						out.print(meta_values+noticeMessage+ErrorHandler.buildResponse(err_warn_Codes.toString(),isHTML));						return null;					}					chartImage=null;				}							} catch (IOException e) {				e.printStackTrace();			}		}				if(err_warn_Codes.indexOf("E") != -1) {			meta_values =exportBean.getMetadataAsQueryString(null,true,isHTML);			PrintWriter out;			try {				out = response.getWriter();				out.print(meta_values+noticeMessage+"&statusCode=1&statusMessage=successful");			} catch (IOException e) {				e.printStackTrace();			}		}		return null;	}		public Object exportProcessor(ExportBean pExportBean) {		exportBean = pExportBean;		String stream = (String)exportBean.getStream();		ChartMetadata metadata= exportBean.getMetadata();		BufferedImage chartImage = ImageGenerator.getChartImage(stream,metadata);				return chartImage;	}}
FCExporter.java源码

package com.fusioncharts.exporter.servlet;import java.io.IOException;import java.io.PrintWriter;import javax.servlet.ServletConfig;import javax.servlet.ServletContext;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.fusioncharts.exporter.ErrorHandler;import com.fusioncharts.exporter.FusionChartsExportHelper;import com.fusioncharts.exporter.beans.ExportBean;import com.fusioncharts.exporter.resources.FCExporterFormat;public class FCExporter extends HttpServlet {	    public FCExporter() {        super();    }	public void init(ServletConfig config) throws ServletException {		super.init(config);	}	public void destroy() {		super.destroy();	}	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {		doPost(request,response);	}	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {		ServletContext sc =  getServletContext();		String WEB_ROOT_PATH = sc.getRealPath("/");		ExportBean localExportBean = FusionChartsExportHelper.parseExportRequestStream(request);				String exportFormat = (String)localExportBean.getExportParameterValue("exportformat");		String exportTargetWindow = (String)localExportBean.getExportParameterValue("exporttargetwindow");		StringBuffer err_warn_Codes = new StringBuffer();		if (localExportBean.getMetadata().getWidth() == -1 || 		    localExportBean.getMetadata().getHeight() == -1 || 		    localExportBean.getMetadata().getWidth() == 0 || 		    localExportBean.getMetadata().getHeight() == 0 ) {						//If Width/Height parameter is not sent, the ChartMetadata will have width/height as -1			//Raise Error E101 - Width/Height not found			err_warn_Codes.append("E101,");			}		if (localExportBean.getMetadata().getBgColor() == null) {			//Background color not available			err_warn_Codes.append("W513,");			}		if (localExportBean.getStream() == null  ) {						//If image data not available			//Raise Error E100			err_warn_Codes.append("E100,");			}		String exportAction = (String)localExportBean.getExportParameterValue("exportaction");		boolean isHTML = false;		if(exportAction.equals("download"))			isHTML=true;			if(!exportAction.equals("download")) {			String fileNameWithoutExt = (String)localExportBean.getExportParameterValue("exportfilename");			String extension = FusionChartsExportHelper.getExtensionFor(exportFormat.toLowerCase());;			String fileName = fileNameWithoutExt+"."+ extension;			err_warn_Codes.append(ErrorHandler.checkServerSaveStatus(WEB_ROOT_PATH,fileName));		}		String pathToWebAppRoot = getServletContext().getRealPath("/");		localExportBean.addExportParameter("webapproot", pathToWebAppRoot);		String meta_values= localExportBean.getMetadataAsQueryString(null,true,isHTML);		if(err_warn_Codes.indexOf("E") != -1) {			// There are errors - forward to error page			writeError(response,""+isHTML,err_warn_Codes.toString(),meta_values,exportTargetWindow);					} else {			// get the exporter for this format			//String path = FusionChartsExportHelper.getExporterFilePath(exportFormat).replace(" ","");			// gives with .jsp extension, let us remove the extension - this is a work-around until next release, where Servlets will also be supported			//int indexOfDot = path.lastIndexOf(".");			//String exporterClassName = path.substring(0, indexOfDot);			try {				//Class exporterClass = Class.forName(exporterClassName);				Class exporterClass = Class.forName("com.fusioncharts.exporter.resources.FCExporterIMG");				FCExporterFormat fcExporter = (FCExporterFormat)exporterClass.newInstance(); 				Object exportObject = fcExporter.exportProcessor(localExportBean);				String status= fcExporter.exportOutput(exportObject, response);			} catch (ClassNotFoundException e) {				err_warn_Codes.append("E404");				writeError(response,""+isHTML,err_warn_Codes.toString(),meta_values,exportTargetWindow);			} catch (InstantiationException e) {				err_warn_Codes.append("E404");				writeError(response,""+isHTML,err_warn_Codes.toString(),meta_values,exportTargetWindow);			} catch (IllegalAccessException e) {				err_warn_Codes.append("E404");				writeError(response,""+isHTML,err_warn_Codes.toString(),meta_values,exportTargetWindow);			}		}	}	private void writeError(HttpServletResponse response, String isHTML, String errorCodes, String otherMessages, String exportTargetWindow) {		if(isHTML==null){			isHTML = "true";		}		if(otherMessages==null){			otherMessages="";		}		if(errorCodes==null){			errorCodes="";		}		response.setContentType("text/html");		if(exportTargetWindow.equalsIgnoreCase("_self")){			response.addHeader("Content-Disposition", "attachment;");		} else {			response.addHeader("Content-Disposition", "inline;");		}		PrintWriter out;		try {			out = response.getWriter();			out.print(ErrorHandler.buildResponse(errorCodes,new Boolean(isHTML).booleanValue())) ;			 			out.print(otherMessages);		} catch (IOException e) {					}		}}
web.xml配置

xml version="1.0" encoding="UTF-8"?

> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <servlet> <display-name>FCExporter</display-name> <servlet-name>FCExporter</servlet-name> <servlet-class>com.fusioncharts.exporter.servlet.FCExporter</servlet-class> </servlet> <servlet-mapping> <servlet-name>FCExporter</servlet-name> <url-pattern>/FCExporter</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>zoomline.html</welcome-file> </welcome-file-list> </web-app>

转载地址:http://scfvx.baihongyu.com/

你可能感兴趣的文章
MongoDB数据库 : 管道,用户管理,副本集等
查看>>
【高级编程技术作业】第二周
查看>>
【转】网易内推测试开发岗面试经历
查看>>
webpack系统配置
查看>>
寻找数组中第二大数
查看>>
品牌搜索
查看>>
UVA 10817 十一 Headmaster's Headache
查看>>
PHP左侧菜单栏的管理与实现
查看>>
Docker学习笔记四:Docker镜像、容器管理工具shipyard
查看>>
Knockout.Js学习目录
查看>>
CecOS Virtualization
查看>>
数据库sql 开窗函数
查看>>
算法艺术(二):判断(if)的使用策略
查看>>
[转载] 国王的演讲
查看>>
炒菜模型——各种编程范式
查看>>
前端神器avalonJS入门(一)
查看>>
jQuery函数attr()和prop()的区别
查看>>
简单BGP实例
查看>>
从实例出发,了解单例模式和静态块
查看>>
LeetCode 146. LRU Cache
查看>>