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.category.DefaultCategoryDataset;
35:
36: public class AdminBarChartServlet extends HttpServlet {
37:
38: public AdminBarChartServlet() {
39: }
40:
41: public void service(HttpServletRequest inRequest,
42: HttpServletResponse inResponse) throws IOException,
43: ServletException {
44:
45: inResponse.setContentType("image/png");
46: //
47: DefaultCategoryDataset dcd = new DefaultCategoryDataset();
48: dcd.addValue(10, "S1", "C1");
49: JFreeChart chart = ChartFactory.createBarChart("Bar Chart",
50: "Category", "Value", dcd, PlotOrientation.VERTICAL,
51: true, true, false);
52:
53: //
54: OutputStream os = inResponse.getOutputStream();
55:
56: ChartUtilities.writeChartAsPNG(os, chart, 300, 300);
57: os.flush();
58: os.close();
59:
60: }
61: }
|