org.deegree.enterprise.servlet
Class ChartServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
org.deegree.enterprise.servlet.ChartServlet
- All Implemented Interfaces:
- 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: 29949 $, $Date: 2011-03-09 13:08:56 +0100 (Wed, 09 Mar 2011) $
- Author:
- Moataz Elmasry, last edited by: $Author: apoth $
- See Also:
- Serialized Form
Method Summary |
protected BufferedImage |
buildChart(String chart,
String title,
String legend,
String width,
String height,
String xAxis,
String yAxis,
String tooltips,
String orientation,
String lblType,
String imagetype,
Map<String,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<String,String> |
initAndValidateParams(javax.servlet.http.HttpServletRequest request)
Init and validate params does what its name say. |
protected void |
performAction(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
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 |
ChartServlet
public ChartServlet()
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,
IOException
- Overrides:
doGet
in class javax.servlet.http.HttpServlet
- Throws:
javax.servlet.ServletException
IOException
performAction
protected void performAction(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
- Parameters:
request
- response
-
initAndValidateParams
protected QueuedMap<String,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 BufferedImage buildChart(String chart,
String title,
String legend,
String width,
String height,
String xAxis,
String yAxis,
String tooltips,
String orientation,
String lblType,
String imagetype,
Map<String,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
an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org