package com.fusioncharts.exporter.resources;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintWriter;
import javax.imageio.stream.FileImageOutputStream;
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;
/**
*
* @author InfosoftGlobal (P) Ltd.
*
*/
public class FCExporter_IMG extends FCExporter_Format {
private ExportBean exportBean=null;
/* (non-Javadoc)
* @see com.fusioncharts.exporter.resources.FcExporter_Format#exportOutput(java.lang.Object, javax.servlet.http.HttpServletResponse, java.lang.String, int)
*/
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;
String stream = (String)exportBean.getStream();
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")){
noticeMessage = "¬ice=";
// For servlet api before 2.1 use the following
//String requestURL = HttpUtils.getRequestURL(request).toString();
// in servlet api 2.1 use the following
//String requestURL = request.getRequestURL().toString();
String pathToSaveFolder = (String)exportBean.getExportParameterValue("webapproot")+File.separator+FusionChartsExportHelper.SAVEPATH;
File saveFolder = new File(pathToSaveFolder);
String completeFilePath = pathToSaveFolder + File.separator + fileName;
String completeFilePathWithoutExt = pathToSaveFolder + File.separator + fileNameWithoutExt;
File saveFile = new File(completeFilePath);
if(saveFile.exists()) {
noticeMessage+=ErrorHandler.getErrorForCode("W509");
if(!FusionChartsExportHelper.OVERWRITEFILE){
if(FusionChartsExportHelper.INTELLIGENTFILENAMING) {
noticeMessage+=ErrorHandler.getErrorForCode("W514");
completeFilePath= FusionChartsExportHelper.getUniqueFileName(completeFilePathWithoutExt,extension);
File tempFile= new File(completeFilePath);
fileName = tempFile.getName();
noticeMessage+=ErrorHandler.getErrorForCode("W515")+ fileName;
err_warn_Codes.append("W515,");
}
}
}
// In Save mode, send back Successful response back to chart
// In save mode, isHTML is false
String pathToDisplay=FusionChartsExportHelper.HTTP_URI+"/"+fileName;
if (FusionChartsExportHelper.HTTP_URI.endsWith("/")) {
pathToDisplay=FusionChartsExportHelper.HTTP_URI+fileName;
}
meta_values =exportBean.getMetadataAsQueryString(pathToDisplay,false,isHTML);
try{
// Now encode and save to file
FileImageOutputStream fios = new FileImageOutputStream(new File(completeFilePath));
if( exportFormat.toLowerCase().equalsIgnoreCase("jpg") || exportFormat.toLowerCase().equalsIgnoreCase("jpeg")){
JPEGEncoder jpegEncoder = new JPEGEncoder();
try {
jpegEncoder.encode(chartImage,fios);
}catch(Throwable e){
//TODO Unable to encode the buffered image
err_warn_Codes.append("E516,");
}
chartImage=null;
}
else {
BasicEncoder basicEncoder = new BasicEncoder();
try {
basicEncoder.encode(chartImage,fios,1F,exportFormat.toLowerCase());
}catch(Throwable e){
System.out.println(" Unable to encode the buffered image");
err_warn_Codes.append("E516,");
}
chartImage=null;
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(err_warn_Codes.indexOf("E")<0){
// if there are no errors
PrintWriter out;
try {
out = response.getWriter();
out.print(meta_values+noticeMessage+"&statusCode=1&statusMessage=successful");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
else{
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) {
// TODO Auto-generated catch block
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) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return null;
}
public Obje
没有合适的资源?快使用搜索试试~ 我知道了~
FusionCharts结合J2EE服务端生成图片demo
共81个文件
swf:54个
class:4个
java:4个
3星 · 超过75%的资源 需积分: 10 37 下载量 148 浏览量
2014-07-21
16:57:42
上传
评论
收藏 3.29MB RAR 举报
温馨提示
J2EE结合FusionChart服务端生成统计图的demo,将资源下载下来,导入到MyEclipse中即可运行,所有依赖的东西,都已经打到包中了。例子中包括客户端右键统计图下载,服务器端将图片保存到硬盘上的web自定义目录下等常用功能。我这实在是没分了,只能收点儿分了
资源推荐
资源详情
资源评论
收起资源包目录
fusionCharts.rar (81个子文件)
fusionCharts
.project 1KB
.settings
org.eclipse.jdt.core.prefs 330B
.mymetadata 309B
WebRoot
FCExporter.jsp 7KB
jquery-1.4.2.min.js 71KB
FusionChartsExportComponent.js 8KB
WEB-INF
web.xml 724B
lib
fcexport.jar 21KB
classes
com
fusioncharts
exporter
resources
FCExporter_IMG.class 7KB
FCExporter_Format.class 545B
FCExporter_PDF.class 5KB
servlet
FCExporter.class 6KB
fusioncharts_export.properties 1KB
index.jsp 3KB
Resources
FCExporter_PDF.jsp 5KB
FCExporter_IMG.jsp 8KB
FusionCharts.js 113KB
META-INF
MANIFEST.MF 36B
savefiles
chartswf
ScrollArea2D.swf 62KB
MSSpline.swf 67KB
LogMSColumn2D.swf 65KB
Pie2D.swf 52KB
MSCombi3D.swf 90KB
Pareto2D.swf 64KB
SplineArea.swf 63KB
Area2D.swf 54KB
StackedBar2D.swf 57KB
CVS
Entries 3KB
Repository 56B
Root 43B
ZoomLine.swf 80KB
ScrollCombi2D.swf 65KB
Funnel.swf 55KB
MSColumnLine3D.swf 59KB
Bubble.swf 71KB
StackedBar3D.swf 57KB
StackedArea2D.swf 58KB
MSArea.swf 58KB
Bar2D.swf 53KB
LogMSLine.swf 65KB
MSColumn3D.swf 57KB
MSStackedColumn2DLineDY.swf 63KB
MSCombiDY2D.swf 63KB
Column2D.swf 54KB
StackedColumn3DLineDY.swf 62KB
Pyramid.swf 53KB
Doughnut3D.swf 75KB
ScrollLine2D.swf 61KB
ScrollCombiDY2D.swf 67KB
ScrollStackedColumn2D.swf 62KB
InverseMSColumn2D.swf 68KB
FCF_Column3D.swf 21KB
SSGrid.swf 47KB
Doughnut2D.swf 70KB
Line.swf 53KB
FCExporter.swf 21KB
Column3D.swf 53KB
MSLine.swf 57KB
MSColumn3DLineDY.swf 61KB
MSStackedColumn2D.swf 59KB
Pie3D.swf 56KB
StackedColumn2D.swf 58KB
Marimekko.swf 69KB
MSBar3D.swf 56KB
Scatter.swf 70KB
StackedColumn3D.swf 57KB
Pareto3D.swf 64KB
MSBar2D.swf 57KB
MSColumn2D.swf 58KB
MSCombi2D.swf 61KB
InverseMSArea.swf 68KB
InverseMSLine.swf 67KB
Spline.swf 63KB
MSSplineArea.swf 68KB
ScrollColumn2D.swf 62KB
.myeclipse
src
com
fusioncharts
exporter
resources
FCExporter_IMG.java 8KB
FCExporter_PDF.java 6KB
FCExporter_Format.java 423B
servlet
FCExporter.java 5KB
fusioncharts_export.properties 1KB
.classpath 433B
共 81 条
- 1
资源评论
- anywnjdbhh2015-09-10渣渣,完全没用,都不知道图片到哪里去了,后台代码没有一个运行了的。
- angle_yulong2015-12-12参考一下!!!
skycb
- 粉丝: 6
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- rainy-day.jpg
- IMG_20240501_171218.jpg
- Swift-内购封装swift版本
- 经典CNN网络之ResNet 图像分类网络实战项目:7种小麦叶片病害分类(迁移学习)
- Java毕设之ssm010基于ssm的新能源汽车在线租赁管理系统+vue.rar
- Java毕设之ssm009毕业生就业信息统计系统+vue.rar
- Java毕设之ssm008医院门诊挂号系统+jsp.rar
- Java毕设之ssm007亚盛汽车配件销售业绩管理统+jsp.rar
- Java毕设之ssm006基于java的少儿编程网上报名系统+vue.rar
- Java毕设之ssm005基于SSM框架的购物商城系统+jsp.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功