01: /*
02: * JFolder, Copyright 2001-2006 Gary Steinmetz
03: *
04: * Distributable under LGPL license.
05: * See terms of license at gnu.org.
06: */
07:
08: package org.jfolder.console.admin.graphs.v1;
09:
10: //base classes
11: import java.io.IOException;
12: import java.io.OutputStream;
13: import java.io.PrintWriter;
14: import javax.servlet.RequestDispatcher;
15: import javax.servlet.ServletException;
16: import javax.servlet.http.HttpServlet;
17: import javax.servlet.http.HttpServletRequest;
18: import javax.servlet.http.HttpServletResponse;
19: import javax.servlet.http.HttpSession;
20:
21: //project specific classes
22: import org.jfolder.common.UnexpectedSystemException;
23: import org.jfolder.common.tagging.ConceptTagHelper;
24: import org.jfolder.common.tagging.ConceptTagPreferences;
25: import org.jfolder.common.tagging.RootConceptTagHolder;
26: import org.jfolder.common.utils.web.ParameterHelper;
27: import org.jfolder.common.utils.web.ParameterSet;
28:
29: //other classes
30: import org.jfree.chart.ChartFactory;
31: import org.jfree.chart.ChartUtilities;
32: import org.jfree.chart.JFreeChart;
33: import org.jfree.chart.plot.PlotOrientation;
34: import org.jfree.data.general.DefaultPieDataset;
35:
36: public class AdminPieChartServlet extends HttpServlet {
37:
38: public AdminPieChartServlet() {
39: }
40:
41: public void service(HttpServletRequest inRequest,
42: HttpServletResponse inResponse) throws IOException,
43: ServletException {
44:
45: inResponse.setContentType("image/png");
46: //
47: DefaultPieDataset dpd = new DefaultPieDataset();
48: dpd.setValue("S1", 10);
49: JFreeChart chart = ChartFactory.createPieChart("Pie Chart",
50: dpd, true, true, false);
51:
52: //
53: OutputStream os = inResponse.getOutputStream();
54:
55: ChartUtilities.writeChartAsPNG(os, chart, 300, 300);
56: os.flush();
57: os.close();
58:
59: }
60: }
|