deegree 2.5 (2011/06/29 09:44 build-8-official)

org.deegree.enterprise.servlet
Class ChartServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.deegree.enterprise.servlet.ChartServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ChartServlet
extends javax.servlet.http.HttpServlet

A Servlet that gets an http GET request, with the de.latlon.charts parameters and it generates and returns a BufferedImage based on these parameters. The request should look as follows: http://www.someserver.com/servletname? chart=ChartType& ( Mandatory ) title=string& legend=boolean& ( default = true ) width=int& ( Mandatory ) height=int& ( Mandatory ) xAxis=string& yAxis=string& tooltips=boolean& ( default = false ) lblType Determines in PieChart what the legend and the tool tip to be. You can either show the data key, value or both. Possible values for this parameter are: Key, Value and KeyValue ( default = Key ) orientation=direction& ( default = vertical ) format=image_format& ( Mandatory ) value=value ( Mandatory ) The keys are the following I) Chart Type: Available chart Types are: 1- Pie 2- Pie3D 3- Bar 4- Bar3D 5- Line 6- Line3D 7- XYBar 8- XYLine II) title: Title of the generated image II) legend: true/false to show/hide the legend of the categories/rows III) width: Width of the generated image IV) height: Height of the generated image V) xAxis Title of the X Axis Title of xAxis VI) yAxis Title of the Y Axis VII) tooltips Show/hide tool tips VIII)orientation vertical/horizontal. the orientation of the chart IX) format format of the output image, ex: image/png and image/jpeg X) type There is actually no parameter called type. It only indicates the more parameters that carry the actual values for the chart. They can have different three different formats. but only one format type shall be used per request. The values can be given as normal key value pairs as follows: Format 1: &CDU=34&SPD=36&Gruene=11 - In this format the key has only one value - This type can only be used together with the chart type: Pie, Pie3D, Bar, Line and Line3D Format 2: &CDU=23,25,21,26&SPD=42,23,33,36 - In this format multiple values per keys can be given - Either comma or white spaces can be used as separators(white spaces are of course encoded in case of a Http Get request) - This type can only be used together with the chart type: Bar, Line and ine3D Format 3: &CDU=1970,23;1974,44;1978,43&SPD=1970,23;1974,44;1978,43 - In this format the key has multiple value, in which each value is a tuple that contains in turn two tokens representing x and y of a cartesian point. This format is used to create cartesian de.latlon.charts - comma and white spacescan be used as separators between tokens, i.e. between x and y, while semi colon shall be used as a separator between tupels. - This type can only be used together with XYLine (and later with XYBar)

Version:
$Revision: 19231 $, $Date: 2009-08-19 10:08:46 +0200 (Mi, 19 Aug 2009) $
Author:
Moataz Elmasry, last edited by: $Author: apoth $
See Also:
Serialized Form

Constructor Summary
ChartServlet()
           
 
Method Summary
protected  java.awt.image.BufferedImage buildChart(java.lang.String chart, java.lang.String title, java.lang.String legend, java.lang.String width, java.lang.String height, java.lang.String xAxis, java.lang.String yAxis, java.lang.String tooltips, java.lang.String orientation, java.lang.String lblType, java.lang.String imagetype, java.util.Map<java.lang.String,java.lang.String> params, ChartConfig chartConfigs)
          Takes in all the needed parameters and a queued map containing the values of the chart and returns a BufferedImage with the chart
protected  void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void goToErrorPage(javax.servlet.http.HttpServletResponse response)
          Creates a buffered image that contains an error label.
 void init()
           
protected  QueuedMap<java.lang.String,java.lang.String> initAndValidateParams(javax.servlet.http.HttpServletRequest request)
          Init and validate params does what its name say.
protected  QueuedMap<java.lang.String,java.lang.String> InitNValidateParams(javax.servlet.http.HttpServletRequest request)
          Deprecated. due to a typo this method is deprecated. Use initAndValidateParams(HttpServletRequest) instead.
protected  void performAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
protected  void PerformAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Deprecated. due to a typo this method is deprecated. Use performAction(HttpServletRequest, HttpServletResponse) instead.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChartServlet

public ChartServlet()
Method Detail

init

public void init()
          throws javax.servlet.ServletException
Overrides:
init in class javax.servlet.GenericServlet
Throws:
javax.servlet.ServletException

doGet

protected void doGet(javax.servlet.http.HttpServletRequest request,
                     javax.servlet.http.HttpServletResponse response)
              throws javax.servlet.ServletException,
                     java.io.IOException
Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
javax.servlet.ServletException
java.io.IOException

PerformAction

@Deprecated
protected void PerformAction(javax.servlet.http.HttpServletRequest request,
                                        javax.servlet.http.HttpServletResponse response)
Deprecated. due to a typo this method is deprecated. Use performAction(HttpServletRequest, HttpServletResponse) instead.

Parameters:
request -
response -

performAction

protected void performAction(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
Parameters:
request -
response -

InitNValidateParams

@Deprecated
protected QueuedMap<java.lang.String,java.lang.String> InitNValidateParams(javax.servlet.http.HttpServletRequest request)
                                                                    throws IncorrectFormatException
Deprecated. due to a typo this method is deprecated. Use initAndValidateParams(HttpServletRequest) instead.

Parameters:
request -
Returns:
instance of the queuedMap
Throws:
IncorrectFormatException

initAndValidateParams

protected QueuedMap<java.lang.String,java.lang.String> initAndValidateParams(javax.servlet.http.HttpServletRequest request)
                                                                      throws IncorrectFormatException
Init and validate params does what its name say. It extracts the mandatory parameters from the HttpServletRequest class and checks their validity. Then it fills a queued map with all parameters, that are not defined, because these are the candidates to be the parameters for the chart

Parameters:
request -
Returns:
instance of the queued map with
Throws:
IncorrectFormatException

goToErrorPage

protected void goToErrorPage(javax.servlet.http.HttpServletResponse response)
Creates a buffered image that contains an error label. It is used to display an error instead of a chart in case an error happened

Parameters:
response -

buildChart

protected java.awt.image.BufferedImage buildChart(java.lang.String chart,
                                                  java.lang.String title,
                                                  java.lang.String legend,
                                                  java.lang.String width,
                                                  java.lang.String height,
                                                  java.lang.String xAxis,
                                                  java.lang.String yAxis,
                                                  java.lang.String tooltips,
                                                  java.lang.String orientation,
                                                  java.lang.String lblType,
                                                  java.lang.String imagetype,
                                                  java.util.Map<java.lang.String,java.lang.String> params,
                                                  ChartConfig chartConfigs)
                                           throws IncorrectFormatException
Takes in all the needed parameters and a queued map containing the values of the chart and returns a BufferedImage with the chart

Parameters:
chart -
title -
legend -
width -
height -
xAxis -
yAxis -
tooltips -
orientation -
lblType -
imagetype -
params -
chartConfigs - to configure the output chart, or null to use the default ChartConfig
Returns:
BufferedImage containing the chart
Throws:
IncorrectFormatException

deegree 2.5 (2011/06/29 09:44 build-8-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org