|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.servlet.GenericServlet | +--javax.servlet.http.HttpServlet | +--com.jrefinery.chart.demo.servlet.BaseImageServlet
A Base image servlet generator. Used to provide common base and methods to servlets which need to generate a chart from sql data sources To extend overwrite method : generateSQL. Will attempt to get configuration constants from the firstly the servlet container configuration and then secondly the servlet's initialization parameters. The servlets initialization parameters taking precedence. Available configuration options are a. DBuser - The database user to connect as b. DBpwd - The password for the database user c. DBschema - The schema to utilise d. DBurl - The connection URL to the database e. DBdriver - The JDBC driver to utilise to connect to the database f. CacheType- Specifies the type of chart cache to utilise when generating HTML. (Optional, default of Dynamic) g. TemporaryDir - Specifies the directory to locate chart cache (Optional for Dynamic CacheTypes, mandatory for other types) h. TemporaryUrl - Specifies the url to the temporaryDir (Mandatory for Temp_Url CacheType, Optional for other types) i. HeaderUrl - The url for the header included in html page. may be file:// (Optional) j. FooterUrl - The url for the footer included in html page. may be file:// (Optional) The servlet will check to see if a connection is shared amongst the servlets context already. If not it will create a connection and share via the servlet container. Supports the following url options NAME TYPE NOTES type integer the type of chart to generate. eg moving average, linear fit etc under development. width integer The width of output in pixels. Clipped into the range 10-2000 height integer The height of the output in pixels. Clipped into the range 10-1000 initColor integer Between 0-11, used to indicate the initial shading of the background finalColor integer Between 0-11, used to indicate the final shading of the background title String The chart title xaxistitle String The x axis title yaxistitle String The y axis title zero String if passed a value of 'true' then the chart will include zero showLegend String if passed a value of 'false' then the chart will not include legend output String Selection of the type of output requested. jpeg, gif, svg CAUTION : THE FOLLOWING ARE UNTESTED / UNDER DEVELOPMENT 1. SVG support using apache batik. 2. PDF support 3. Charting options such as moving average, linear fit.
JFreeChart
,
JFreeChartServletDemo
, Serialized FormField Summary | |
protected java.lang.String |
chartTitle
Title of the chart |
java.lang.String |
dbSchema
|
protected boolean |
debug
Whether or not to enable debug information output |
protected int |
defaultChartType
|
protected static java.text.SimpleDateFormat |
df
|
static int |
IMAGE_CACHE_DELETE
Cache Types : 0 : include through a servlet request to cache, do delete file after initial retrival 1 : include through a servlet request to cache, do not delete file after initial retrival 2 : include image through url reference, , do not delete file after initial retrival 3 : Dynamic (No ImageMap Support) 4 : Dynamic with imagemap support (Note requires chart to be generated twice) |
static int |
IMAGE_CACHE_NO_DELETE
|
static int |
IMAGE_DYNAMIC_IMAGEMAP
|
static int |
IMAGE_DYNAMIC_NO_IMAGEMAP
|
static int |
IMAGE_TEMP_URL
|
protected java.lang.String |
servletName
The servlets name |
protected int |
sqlServerType
|
protected java.lang.String |
xAxisTitle
Title of the x axis |
protected java.lang.String |
yAxisTitle
Title of the y axis |
Fields inherited from interface com.jrefinery.chart.demo.servlet.Constants |
CAUTION_FILE, CONTENT_TYPE, DB_CONNECTION, DB_DRIVER, DB_PASSWORD, DB_SCHEMA, DB_SERVER, DB_URL, DB_USER, DEBUG, FOOTER, FOOTER_FILE, FOOTER_URL, HEADER, HEADER_FILE, HEADER_URL, IMAGE_URL, MYSQL, ORACLE, ORGANISATION, REPLACE_SCHEMA, RESPONSE_HTML, RESPONSE_JPEG, RESPONSE_PDF, RESPONSE_PNG, RESPONSE_PS, RESPONSE_SVG, SHARED_DB, SHARED_DB_OPENER, SHARED_VOYAGES, SHARED_VOYAGES_TIME, TEMP_DIR, TEMP_URL |
Constructor Summary | |
BaseImageServlet()
|
Method Summary | |
protected JFreeChart |
createCategoryChart(int type,
java.lang.String sql)
Create a chart |
protected JFreeChart |
createChart(javax.servlet.http.HttpServletRequest request)
|
protected JFreeChart |
createPieChart(int type,
java.lang.String sql)
Create a chart |
protected JFreeChart |
createXYChart(int type,
java.lang.String sql)
Create an XY chart |
void |
destroy()
Shutdown the servlet |
protected void |
doCache(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
static void |
doErrorPage(javax.servlet.http.HttpServletResponse response,
java.lang.String message)
Write an error page as the reponse. |
void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Basic servlet method, answers requests from the browser. |
protected void |
doHtml(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
protected void |
doImage(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Processes the HTTP request. |
static boolean |
existsURL(java.lang.String URLName)
This function will return true if a given URL exists by using the HTTP status code. |
protected java.lang.String |
generateSQL(javax.servlet.http.HttpServletRequest request)
Generate the SQL required from the http request Override this method to generate the appropriate sql for a request. |
static java.awt.Color |
getColor(int color)
Gets the color attribute of the passed integer |
protected static int |
getImageOutputType(javax.servlet.http.HttpServletRequest request)
|
protected static java.awt.Dimension |
getImageSize(javax.servlet.http.HttpServletRequest request)
|
static void |
includeFile(java.io.OutputStream out,
java.io.File file)
write the contents of a file to an output stream. |
static void |
includeUrl(java.io.PrintWriter out,
java.lang.String url)
Include contents of a given url in output |
void |
init(javax.servlet.ServletConfig config)
Override init() to set up data used by invocations of this servlet. |
protected void |
modifyChart(JFreeChart chart,
javax.servlet.http.HttpServletRequest request)
Modify a chart based on request parameters Override this method if you would like to modify the generated chart, Generally for chart look and feel. |
protected void |
openConnection()
Open the database connection |
protected void |
statusMessage(java.lang.String message)
Write a status message to the server console (stdout) if debug enabled |
protected boolean |
testConnection()
Test the database connection is available |
protected ChartRenderingInfo |
writeChart(JFreeChart chart,
java.io.OutputStream out,
int outputType,
java.awt.Dimension size)
|
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
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 |
Field Detail |
protected static final java.text.SimpleDateFormat df
protected int sqlServerType
protected java.lang.String servletName
protected boolean debug
protected java.lang.String chartTitle
protected java.lang.String xAxisTitle
protected java.lang.String yAxisTitle
protected int defaultChartType
public java.lang.String dbSchema
public static final int IMAGE_CACHE_DELETE
public static final int IMAGE_CACHE_NO_DELETE
public static final int IMAGE_TEMP_URL
public static final int IMAGE_DYNAMIC_IMAGEMAP
public static final int IMAGE_DYNAMIC_NO_IMAGEMAP
Constructor Detail |
public BaseImageServlet()
Method Detail |
public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
doGet
in class javax.servlet.http.HttpServlet
request
- HTTPServletRequestresponse
- HTTPServletResponsejavax.servlet.ServletException
- Description of the Exceptionjava.io.IOException
- Description of the Exceptionpublic void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
doPost
in class javax.servlet.http.HttpServlet
request
- Description of the Parameterresponse
- Description of the Parameterjavax.servlet.ServletException
- Description of the Exceptionjava.io.IOException
- Description of the Exceptionprotected void modifyChart(JFreeChart chart, javax.servlet.http.HttpServletRequest request)
chart
- The Chartprotected java.lang.String generateSQL(javax.servlet.http.HttpServletRequest request)
request
- The servlets request parametersprotected JFreeChart createXYChart(int type, java.lang.String sql)
type
- Type of chart to create. Currently not supported.sql
- SQL to execute. 1st column is x values, following columns are y valuesprotected JFreeChart createPieChart(int type, java.lang.String sql)
type
- Type of chart to create. Currently not supported.sql
- SQL to execute. 1st column is category, followed by valueprotected JFreeChart createCategoryChart(int type, java.lang.String sql)
type
- Type of chart to create. Currently not supported.sql
- SQL to execute. 1st column is category, followed by valuepublic void init(javax.servlet.ServletConfig config) throws javax.servlet.ServletException
init
in class javax.servlet.GenericServlet
config
- Description of the Parameterjavax.servlet.ServletException
- Description of the Exceptionprotected void doHtml(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
request
- response
- javax.servlet.ServletException
- java.io.IOException
- protected void doCache(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
protected void doImage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
request
- response
- javax.servlet.ServletException
- java.io.IOException
- protected ChartRenderingInfo writeChart(JFreeChart chart, java.io.OutputStream out, int outputType, java.awt.Dimension size)
protected JFreeChart createChart(javax.servlet.http.HttpServletRequest request)
public void destroy()
destroy
in class javax.servlet.GenericServlet
protected void openConnection()
protected boolean testConnection()
protected void statusMessage(java.lang.String message)
message
- the message to be writtenpublic static void doErrorPage(javax.servlet.http.HttpServletResponse response, java.lang.String message)
response
- The servlet responsemessage
- The error message to be displayedpublic static void includeUrl(java.io.PrintWriter out, java.lang.String url)
out
- the stream to be written tourl
- the url to be includedpublic static void includeFile(java.io.OutputStream out, java.io.File file)
out
- the stream to be written tofile
- the file to be included in the outputpublic static boolean existsURL(java.lang.String URLName)
public static java.awt.Color getColor(int color)
color
- The colour indexprotected static int getImageOutputType(javax.servlet.http.HttpServletRequest request)
protected static java.awt.Dimension getImageSize(javax.servlet.http.HttpServletRequest request)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |