⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jfreecharcustomeraction.java

📁 hibernate+spring+ext2.0 的物流网站
💻 JAVA
字号:
/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.struts.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.jfree.chart.*;
import org.jfree.chart.entity.StandardEntityCollection;
import org.jfree.chart.labels.StandardPieToolTipGenerator;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.chart.servlet.ServletUtilities;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.*;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;

import com.bu.mars.*;
import com.service.*;
import com.struts.form.MarsCustomerInfoForm;
import com.struts.form.MarsJfreeCharFormForm;

/**
 * MyEclipse Struts Creation date: 08-26-2008
 * 
 * XDoclet definition:
 * 
 * @struts.action
 */
public class JfreeCharCustomerAction extends Action {
	/*
	 * Generated Methods
	 */
	private MarsBusinessservice bs;

	public MarsBusinessservice getBs() {
		return bs;
	}

	public void setBs(MarsBusinessservice bs) {
		this.bs = bs;
	}

	private static Log log = LogFactory.getLog(JfreeCharCustomerAction.class);

	/**
	 * Method execute
	 * 
	 * @param mapping
	 * @param form
	 * @param request
	 * @param response
	 * @return ActionForward
	 */


	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		// TODO Auto-generated method stub
		
		DefaultPieDataset dataset = new DefaultPieDataset();
		Vector cusvc = bs.getBillinfobusiness().findBySendBranchJF();
		for (int i = 0; i < cusvc.size(); i++) {
			MarsJfreeCharFormForm cusf = (MarsJfreeCharFormForm) cusvc.get(i);
			dataset.setValue(cusf.getSendid(), Double.parseDouble(cusf
					.getCount()));
		}
		JFreeChart chart = ChartFactory.createPieChart3D("按货票的客户信息进行统计分析", dataset, true, true, true); 
		PiePlot3D plot = (PiePlot3D)chart.getPlot(); 
		//plot.setURLGenerator(new StandardPieURLGenerator("barview.jsp")); //生成3维的超级链接
		chart.setBackgroundPaint(java.awt.Color.white); 
		plot.setToolTipGenerator(new StandardPieToolTipGenerator()); //设置生成方式
		
		StandardEntityCollection sec = new StandardEntityCollection(); //设置生成的数据集合
		//创建生成信息对象
		ChartRenderingInfo info = new ChartRenderingInfo(sec); 
		HttpSession session=request.getSession(true);
		
		try {
			//创建存储在内存中的文件名称
			String filename = ServletUtilities.saveChartAsJPEG(chart, 500, 300, info, session);
			//ChartUtilities.writeImageMap(out, "map0", info, false); 
			//获取图片的链接路径
			String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename="+filename; 
			System.out.println(graphURL);
			//request.setAttribute("filename", filename); 
			request.setAttribute("graphURL", graphURL); 
			return mapping.findForward("list");
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 

		return mapping.findForward("list");
	}

	
}

⌨️ 快捷键说明

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