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.xy.XYSeries;
35: import org.jfree.data.xy.XYSeriesCollection;
36: import org.jfree.data.category.DefaultCategoryDataset;
37:
38: public class AdminXYPlotServlet extends HttpServlet {
39:
40: public AdminXYPlotServlet() {
41: }
42:
43: public void service(HttpServletRequest inRequest,
44: HttpServletResponse inResponse) throws IOException,
45: ServletException {
46:
47: inResponse.setContentType("image/png");
48: //
49: XYSeries xys = new XYSeries("Series 1");
50: xys.add(10, 10);
51: xys.add(20, 10);
52: xys.add(30, 30);
53:
54: XYSeriesCollection xysc = new XYSeriesCollection();
55: xysc.addSeries(xys);
56:
57: JFreeChart chart = ChartFactory.createXYLineChart("XY Plot",
58: "Category", "Value", xysc, PlotOrientation.VERTICAL,
59: true, true, false);
60:
61: //
62: OutputStream os = inResponse.getOutputStream();
63:
64: ChartUtilities.writeChartAsPNG(os, chart, 300, 300);
65: os.flush();
66: os.close();
67:
68: }
69: }
|