org.rhq.enterprise.gui.common.servlet
Class ChartServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.rhq.enterprise.gui.common.servlet.ParameterizedServlet
              extended by org.rhq.enterprise.gui.common.servlet.ImageServlet
                  extended by org.rhq.enterprise.gui.common.servlet.ChartServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
AvailabilityStoplightChartServlet, HighLowChartServlet, PerformanceChartServlet, VerticalChartServlet

public abstract class ChartServlet
extends ImageServlet

This servlet returns a response that contains the binary data of an image (JPEG or PNG) that can be viewed in a web browser.

The chart servlet takes the following parameters (any applicable defaults are in bold and required parameters are in italics):

key value
measurementUnits <MeasurementUnits.NONE>
showPeak (false | true)
showHighRange (false | true)
showValues (false | true)
showAverage (false | true)
showLowRange (false | true)
showLow (false | true)
showBaseline (false | true)
baseline* <double>
highRange* <double>
lowRange* <double>

* only used and required if corresponding showXXX parameter is true

See Also:
Serialized Form

Field Summary
static String BASELINE_PARAM
          Request parameter for baseline.
static String HIGHRANGE_PARAM
          Request parameter for baseline.
static int IMAGE_HEIGHT_DEFAULT
          Default image height.
static int IMAGE_WIDTH_DEFAULT
          Default image width.
static String LOWRANGE_PARAM
          Request parameter for baseline.
static String MEASUREMENT_UNITS_PARAM
           
static String SHOW_AVERAGE_PARAM
          Request parameter for whether or not to show average.
static String SHOW_BASELINE_PARAM
          Request parameter for whether or not to show baseline.
static String SHOW_HIGHRANGE_PARAM
          Request parameter for whether or not to show high range.
static String SHOW_LOW_PARAM
          Request parameter for whether or not to show the low.
static String SHOW_LOWRANGE_PARAM
          Request parameter for whether or not to show low range.
static String SHOW_PEAK_PARAM
          Request parameter for whether or not to show the peak.
static String SHOW_VALUES_PARAM
          Request parameter for whether or not to show the actual values.
protected  org.rhq.core.domain.measurement.MeasurementUnits units
           
 
Fields inherited from class org.rhq.enterprise.gui.common.servlet.ImageServlet
IMAGE_FORMAT_JPEG, IMAGE_FORMAT_PARAM, IMAGE_FORMAT_PNG, IMAGE_HEIGHT_PARAM, IMAGE_WIDTH_PARAM
 
Constructor Summary
ChartServlet()
           
 
Method Summary
protected abstract  Chart createChart()
          Create and return the chart.
protected  Object createImage(javax.servlet.http.HttpServletRequest request)
          Create the image being rendered.
protected  int getDefaultImageHeight()
          Return the default imageHeight.
protected  int getDefaultImageWidth()
          Return the default imageWidth.
protected  boolean getDefaultShowAverage()
          Return the default showAverage.
protected  boolean getDefaultShowBaseline()
          Return the default showBaseline.
protected  boolean getDefaultShowHighRange()
          Return the default showHighRange.
protected  boolean getDefaultShowLow()
          Return the default showLow.
protected  boolean getDefaultShowLowRange()
          Return the default Range.
protected  boolean getDefaultShowPeak()
          Return the default showPeak.
protected  boolean getDefaultShowValues()
          Return the default showValues.
 boolean getShowAvg()
          Return the value of property showAverage.
 boolean getShowLow()
          Return the value of property showLow.
 boolean getShowPeak()
          Return the value of property showPeak.
protected  void initializeChart(Chart chart)
          Initialize the chart.
protected  void parseParameters(javax.servlet.http.HttpServletRequest request)
          This method will be called automatically by the ChartServlet.
protected abstract  void plotData(javax.servlet.http.HttpServletRequest request, Chart chart)
          This method will be called automatically by the ChartServlet.
protected  void renderJpegImage(javax.servlet.ServletOutputStream out, Object imgObj)
          Render a JPEG version of the image into the output stream.
protected  void renderPngImage(javax.servlet.ServletOutputStream out, Object imgObj)
          Render a PNG version of the image into the output stream.
 
Methods inherited from class org.rhq.enterprise.gui.common.servlet.ImageServlet
doGet, getDefaultImageFormat, getImageFormat, getImageHeight, getImageWidth, init
 
Methods inherited from class org.rhq.enterprise.gui.common.servlet.ParameterizedServlet
invalidParamErr, invalidParamErr, invalidParamWarn, invalidParamWarn, invalidParamWarn, invalidParamWarn, invalidParamWarn, parseBooleanParameter, parseDoubleParameter, parseEnumParameter, parseIntParameter, parseLongParameter, parseRequiredBooleanParameter, parseRequiredDoubleParameter, parseRequiredIntParameter, parseRequiredLongParameter, parseRequiredStringParameter, parseRequiredStringParameter, parseStringParameter, parseStringParameter, requiredParamErr
 
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
 

Field Detail

MEASUREMENT_UNITS_PARAM

public static final String MEASUREMENT_UNITS_PARAM
See Also:
Constant Field Values

IMAGE_WIDTH_DEFAULT

public static final int IMAGE_WIDTH_DEFAULT
Default image width.

See Also:
Constant Field Values

IMAGE_HEIGHT_DEFAULT

public static final int IMAGE_HEIGHT_DEFAULT
Default image height.

See Also:
Constant Field Values

SHOW_PEAK_PARAM

public static final String SHOW_PEAK_PARAM
Request parameter for whether or not to show the peak.

See Also:
Constant Field Values

SHOW_HIGHRANGE_PARAM

public static final String SHOW_HIGHRANGE_PARAM
Request parameter for whether or not to show high range.

See Also:
Constant Field Values

SHOW_VALUES_PARAM

public static final String SHOW_VALUES_PARAM
Request parameter for whether or not to show the actual values.

See Also:
Constant Field Values

SHOW_AVERAGE_PARAM

public static final String SHOW_AVERAGE_PARAM
Request parameter for whether or not to show average.

See Also:
Constant Field Values

SHOW_LOWRANGE_PARAM

public static final String SHOW_LOWRANGE_PARAM
Request parameter for whether or not to show low range.

See Also:
Constant Field Values

SHOW_LOW_PARAM

public static final String SHOW_LOW_PARAM
Request parameter for whether or not to show the low.

See Also:
Constant Field Values

SHOW_BASELINE_PARAM

public static final String SHOW_BASELINE_PARAM
Request parameter for whether or not to show baseline.

See Also:
Constant Field Values

BASELINE_PARAM

public static final String BASELINE_PARAM
Request parameter for baseline.

See Also:
Constant Field Values

HIGHRANGE_PARAM

public static final String HIGHRANGE_PARAM
Request parameter for baseline.

See Also:
Constant Field Values

LOWRANGE_PARAM

public static final String LOWRANGE_PARAM
Request parameter for baseline.

See Also:
Constant Field Values

units

protected org.rhq.core.domain.measurement.MeasurementUnits units
Constructor Detail

ChartServlet

public ChartServlet()
Method Detail

createImage

protected Object createImage(javax.servlet.http.HttpServletRequest request)
                      throws javax.servlet.ServletException
Create the image being rendered.

Specified by:
createImage in class ImageServlet
Parameters:
request - the servlet request
Throws:
javax.servlet.ServletException

renderPngImage

protected void renderPngImage(javax.servlet.ServletOutputStream out,
                              Object imgObj)
                       throws IOException
Render a PNG version of the image into the output stream.

Specified by:
renderPngImage in class ImageServlet
Parameters:
out - the output stream
Throws:
IOException

renderJpegImage

protected void renderJpegImage(javax.servlet.ServletOutputStream out,
                               Object imgObj)
                        throws IOException
Render a JPEG version of the image into the output stream.

Specified by:
renderJpegImage in class ImageServlet
Parameters:
out - the output stream
Throws:
IOException

parseParameters

protected void parseParameters(javax.servlet.http.HttpServletRequest request)
This method will be called automatically by the ChartServlet. It should handle the parsing and error-checking of any specific parameters for the chart being rendered.

Overrides:
parseParameters in class ImageServlet
Parameters:
request - the HTTP request object

createChart

protected abstract Chart createChart()
Create and return the chart. This method will be called after the parameters have been parsed.

Returns:
the newly created chart

initializeChart

protected void initializeChart(Chart chart)
Initialize the chart. This method will be called after the parameters have been parsed and the chart has been created.

Parameters:
chart - the chart

plotData

protected abstract void plotData(javax.servlet.http.HttpServletRequest request,
                                 Chart chart)
                          throws javax.servlet.ServletException
This method will be called automatically by the ChartServlet. It should handle adding data to the chart, setting up the X and Y axis labels, etc.

Parameters:
request - the HTTP request
Throws:
javax.servlet.ServletException

getShowLow

public boolean getShowLow()
Return the value of property showLow.


getShowPeak

public boolean getShowPeak()
Return the value of property showPeak.


getShowAvg

public boolean getShowAvg()
Return the value of property showAverage.


getDefaultImageWidth

protected int getDefaultImageWidth()
Return the default imageWidth.

Overrides:
getDefaultImageWidth in class ImageServlet

getDefaultImageHeight

protected int getDefaultImageHeight()
Return the default imageHeight.

Overrides:
getDefaultImageHeight in class ImageServlet

getDefaultShowPeak

protected boolean getDefaultShowPeak()
Return the default showPeak.


getDefaultShowHighRange

protected boolean getDefaultShowHighRange()
Return the default showHighRange.


getDefaultShowValues

protected boolean getDefaultShowValues()
Return the default showValues.


getDefaultShowAverage

protected boolean getDefaultShowAverage()
Return the default showAverage.


getDefaultShowLowRange

protected boolean getDefaultShowLowRange()
Return the default Range.


getDefaultShowLow

protected boolean getDefaultShowLow()
Return the default showLow.


getDefaultShowBaseline

protected boolean getDefaultShowBaseline()
Return the default showBaseline.



Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.