List of usage examples for org.jfree.eastwood Parameters parseQueryString
public static Map parseQueryString(String qs) throws UnsupportedEncodingException
From source file:org.jfree.eastwood.ChartApplet.java
/** * Starts the applet./*www.ja v a2s.com*/ */ public void start() { String chartSpec = getParameter("chart"); try { Map params = Parameters.parseQueryString(chartSpec); JFreeChart chart = ChartEngine.buildChart(params, new Font("Dialog", Font.PLAIN, 12)); this.chartPanel.setChart(chart); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } }
From source file:org.geotools.renderer.chart.ChartGraphicFactory.java
public Icon getIcon(Feature feature, Expression urlExpression, String format, int size) throws Exception { // evaluate the expression as a string, get the query params String url = urlExpression.evaluate(feature, String.class); if (!validRequest(url, format)) return null; Map params = Parameters.parseQueryString(url.substring(HTTP_CHART.length())); // build the chart, guess its optimal size, return the icon representing it JFreeChart chart = ChartEngine.buildChart(params); int[] chartSize = computeChartSize(size, params); return new ImageIcon(drawChart(chart, chartSize[0], chartSize[1])); }
From source file:org.geotools.renderer.chart.ChartGraphicFactory.java
/** * This method has been provided as a test utility only *///w ww.j a v a 2 s. c o m JFreeChart getChart(Feature feature, Expression urlExpression, String format, int size) throws Exception { // evaluate the expression as a string, get the query params String url = urlExpression.evaluate(feature, String.class); if (!validRequest(url, format)) return null; Map params = Parameters.parseQueryString(url.substring(HTTP_CHART.length())); // build the chart, guess its optimal size, return the icon representing it return ChartEngine.buildChart(params); }
From source file:org.jfree.eastwood.ChartServlet.java
/** * Process a GET request.//from ww w . j a v a 2 s . c o m * * @param request the request. * @param response the response. * * @throws ServletException if there is a servlet related problem. * @throws IOException if there is an I/O problem. */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { OutputStream out = response.getOutputStream(); try { Map params = Parameters.parseQueryString(request.getQueryString()); JFreeChart chart = ChartEngine.buildChart(params, this.font); if (chart != null) { response.setContentType("image/png"); // *** CHART SIZE *** String[] size = (String[]) params.get("chs"); int[] dims = new int[2]; if (size != null) { dims = parseChartDimensions(size[0]); } else { dims = new int[] { 200, 125 }; } ChartUtilities.writeChartAsPNG(out, chart, dims[0], dims[1]); } } catch (Exception e) { e.printStackTrace(); } finally { out.close(); } }