public abstract class IlvChartServletSupport extends IlvServletSupport
IlvChartServletSupport
class is the core class of the Chart Servlet
framework. It is able to respond to HTTP requests to generate an image
from an IlvChart
chart. The IlvChartServletSupport
class is not a subclass of
HttpServlet
itself. This allows you to add the functionality of
the Chart Servlet framework into your existing servlets. You can do this
by invoking handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
from your servlet doGet()
method. Alternatively, you can use the IlvChartServlet
class as the
basis for developing your servlets. It is a lightweight servlet that
automatically delegates its HTTP requests to an instance of
IlvChartServletSupport
.
Since JViews 6.0, the IlvChartServletSupport
class supports
the DHTML Chart components.
DHTML support is based on exchange of data between the
servlet and the client. This set of data contains information about the
configuration of the chart being displayed. This communication mechanism is
hereafter called capabilities
.
Capabilities are retrieved from the server by the client through the new
"capabilities"
request (CAPABILITIES_REQUEST
). The expected
output format for the capabilities must be specified by means of the
"format"
request parameter (CAP_FORMAT_PARAM
). Beginning
with JViews 8.1 the only possible is "json"
(JSON_CAP_FORMAT
).
Another new feature of this class is the support of two distinct chart components:
a main chart and an overview chart. The main chart instance is returned by
the getChart(ilog.views.chart.servlet.IlvServletRequestParameters)
method. Since this latter method is abstract,
subclasses must override this method to return the expected instance. The
support of an optional overview chart is enabled through the
getOverviewChart(ilog.views.chart.servlet.IlvServletRequestParameters)
method that should return an IlvChart
instance used
as the overview of the main chart (or null
for none). An
overview chart is typically an IlvChart
instance that shares the same data
model than the main chart, but whose visible window always fits its data
window.
Note that synchronizing the data model of the overview and the main
chart is the programmer responsibility.
The parameter value for the "comp"
request parameter (see
IlvChartServletSupport.COMPONENT_PARAM
) corresponding to the overview chart
is "overview"
.
Here is a list of the capabilities generated for the main chart as they appear in the output stream as the properties of a JSON object:
Javascript variable | binary data type | Comments |
---|---|---|
xVisibleMin | Double | The minimum bound of the x-axis visible range. |
xVisibleMax | Double | The maximum bound of the x-axis visible range. |
xDataMin | Double | The minimum bound of the x-axis data range. |
xDataMax | Double | The maximum bound of the x-axis data range. |
yVisibleMin | Double | The minimum bound of the y-axis visible range. |
yVisibleMax | Double | The maximum bound of the y-axis visible range. |
yDataMin | Double | The minimum bound of the y-axis data range. |
yDataMax | Double | The maximum bound of the y-axis data range. |
xHorizontal | Boolean | The x-axis orientation as a Boolean value. |
xPlotRect | Integer | The plot rectangle x-coordinate. |
yPlotRect | Integer | The plot rectangle y-coordinate. |
widthPlotRect | Integer | The plot rectangle width. |
heightPlotRect | Integer | The plot rectangle height. |
dataSets | strings | An array containing the data sets names. |
Here is a list of the capabilities generated for the overview chart as they appear in the output stream:
Javascript variable | binary data type | Comments |
---|---|---|
visLeft | Integer | The visible rectangle x-coordinate. |
visTop | Integer | The visible rectangle y-coordinate. |
visWidth | Integer | The visible rectangle width. |
visHeight | Integer | The visible rectangle height. |
This new class also extends the basic functionalities with several new features:
xmin
,
xmax
, ymin
and ymax
request parameters.IlvChartServerAction
interface and must be
registered on the servlet support via the IlvChartServletSupport.addServerAction
method in order to be called. An action is generated from the client side
when the IlvChartView.performAction()
method is called. This
performAction
method queries the server for a new image with
additional parameters appended to the request so that an action such as
zooming, panning, or data points highlighting can be performed before the
image is generated.
The IlvChartServletSupport
class is abstract. As a minimum, you
will have to provide an implementation of the getChart(ilog.views.chart.servlet.IlvServletRequestParameters)
method in
your concrete subclass.
Modifier and Type | Field and Description |
---|---|
static String |
ACTION_PARAM
The action parameter.
|
static String |
AREA_COMPONENT
The chart area component value for
COMPONENT_PARAM . |
static String |
BG_COLOR_PARAM
The background color parameter value.
|
static String |
CAP_FORMAT_PARAM
The capabilities format parameter for capabilities requests.
|
static String |
CAPABILITIES_REQUEST
The capabilities request value for
REQUEST_PARAM . |
static String |
CHART_COMPONENT
The chart component value for
COMPONENT_PARAM . |
static String |
COMPONENT_PARAM
The component parameter value.
|
static String |
HITMAP_REQUEST
The hitmap request value for
REQUEST_PARAM . |
static String |
HTML_CAP_FORMAT
Deprecated.
Beginning with JViews 8.1 use
JSON_CAP_FORMAT instead. |
static String |
IMAGE_FORMAT_PARAM
The image format parameter value.
|
static String |
IMAGE_REQUEST
The image request value for
REQUEST_PARAM . |
static String |
IMAGEMAP_NAME
The image map name parameter
|
static String |
IMAGEMAP_REQUEST
The image map request value for
REQUEST_PARAM . |
static String |
JPEG_IMAGE_FORMAT
The JPEG image format value.
|
static String |
JSON_CAP_FORMAT
The JSON capabilities format value for
CAP_FORMAT_PARAM . |
static String |
LEGEND_COMPONENT
The legend component value for
COMPONENT_PARAM . |
static String |
OCTET_CAP_FORMAT
Deprecated.
Beginning with JViews 8.1 use
JSON_CAP_FORMAT instead. |
static String |
OVERVIEW_COMPONENT
The overview chart component value for
COMPONENT_PARAM . |
static String |
PNG_IMAGE_FORMAT
The PNG image format value.
|
static String |
REQUEST_PARAM
The request parameter value.
|
static String[] |
VALID_CAP_FORMATS
The array of valid values for
CAP_FORMAT_PARAM . |
static String[] |
VALID_COMPONENTS
All the valid components value.
|
static String |
VERBOSE_PARAM
The verbose parameter value.
|
static String |
X_MAX_PARAM
The maximum visible x-value parameter for image requests.
|
static String |
X_MIN_PARAM
The minimum visible x-value parameter for image requests.
|
static String |
Y_MAX_PARAM
The maximum visible x-value parameter for image requests.
|
static String |
Y_MIN_PARAM
The minimum visible x-value parameter for image requests.
|
Constructor and Description |
---|
IlvChartServletSupport()
Creates a new
IlvChartServletSupport instance. |
Modifier and Type | Method and Description |
---|---|
protected void |
additionalBinaryCapabilities(IlvChart chart,
IlvServletRequestParameters params,
DataOutputStream dataStream)
Deprecated.
since JViews 8.1 you must use
getAdditionalCapabilities(IlvChart, IlvServletRequestParameters)
instead. |
protected void |
additionalOverviewBinaryCapabilities(IlvChart chart,
IlvServletRequestParameters params,
DataOutputStream dout)
Deprecated.
since JViews 8.1 you must use
getAdditionalOverviewCapabilities(IlvChart, IlvServletRequestParameters)
instead. |
protected void |
additionalOverviewTextCapabilities(IlvChart chart,
IlvServletRequestParameters params,
PrintWriter writer)
Deprecated.
since JViews 8.1 you must use
getAdditionalOverviewCapabilities(IlvChart, IlvServletRequestParameters)
instead. |
protected void |
additionalTextCapabilities(IlvChart chart,
IlvServletRequestParameters params,
PrintWriter writer)
Deprecated.
since JViews 8.1 you must use
getAdditionalCapabilities(IlvChart, IlvServletRequestParameters)
instead. |
void |
addServerAction(String name,
IlvChartServerAction action)
Adds the specified
IlvChartServerAction to receive events when the named
action is requested from the client. |
protected IlvImageMapBuilder |
createImageMapBuilder(IlvServletRequestParameters params,
IlvChart chart)
Returns an
IlvImageMapBuilder instance to generate an image
map. |
protected IlvPopupMenuServletSupport |
createPopupMenuSupport()
Creates a new instance of pop-up menu servlet support.
|
protected void |
executeAction(IlvServletRequestParameters params,
IlvChart chart,
int executionThread)
Executes an action requested from the client.
|
protected BufferedImage |
generateImageAWT(IlvServletRequestParameters params,
IlvChart chart,
String compName,
int width,
int height)
Generates the requested image.
|
protected BufferedImage |
generateImageCT(IlvServletRequestParameters params,
IlvChart chart,
String compName,
int width,
int height)
Generates the requested image.
|
protected void |
generateMapAreaTags(PrintWriter output,
IlvServletRequestParameters params,
IlvChart chart)
Writes the image map area tags into the specified writer.
|
protected Map<?,?> |
getAdditionalCapabilities(IlvChart chart,
IlvServletRequestParameters params)
Allows you to put additional capabilities to the capability request.
|
protected Map<?,?> |
getAdditionalOverviewCapabilities(IlvChart chart,
IlvServletRequestParameters params)
Allows you to put additional capabilities to the overview capability request.
|
protected abstract IlvChart |
getChart(IlvServletRequestParameters params)
Returns the chart used for the specified request.
|
IlvServletParameters |
getConfigParameters()
Returns the servlet configuration parameters.
|
protected javax.servlet.ServletContext |
getContext()
Gets the servlet context.
|
IlvChartHitmapSupport |
getHitmapSupport()
Returns the hitmap support that should be an instance of
IlvChartHitmapSupport . |
IlvImageEncoder |
getImageEncoder(String format)
Returns the image encoder registered for the specified format.
|
protected IlvIMapDefinition |
getIMapDefinition(IlvServletRequestParameters params,
IlvChart chart)
Returns the
IlvIMapDefinition used by the
IlvImageMapBuilder to generate the image map tags. |
protected IlvLegend |
getLegend(IlvServletRequestParameters params)
Returns the legend component.
|
protected IlvChart |
getOverviewChart(IlvServletRequestParameters params)
Returns the overview chart used for the specified request.
|
IlvPopupMenuServletSupport |
getPopupMenuSupport()
Returns the pop-up menu servlet support that manage pop-up
menu requests.
|
protected IlvDataWindow |
getRequestedVisibleWindow(IlvServletRequestParameters params,
IlvChart chart)
Returns the requested visible window.
|
javax.servlet.http.HttpServlet |
getServlet()
Returns the servlet associated with this support.
|
boolean |
handleRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
This method is the main entry point for handling HTTP requests.
|
boolean |
isPopupEnabled()
Returns
true if the servlet is set to handle
pop-up menu requests. |
boolean |
isVerbose(IlvServletRequestParameters params)
Returns whether verbose mode is enabled.
|
protected void |
prepareChart(IlvServletRequestParameters params,
IlvChart chart)
Allows you to prepare the chart content before the presentation is
generated.
|
protected void |
prepareOverviewChart(IlvServletRequestParameters params,
IlvChart chart)
Allows you to prepare the overview chart content before the presentation is
generated.
|
protected void |
prepareVisibleWindow(IlvServletRequestParameters params,
IlvChart chart)
Configure the axis visible range of the specified chart according to
the request parameters.
|
void |
removeServerAction(String name,
IlvChartServerAction action)
Removes the specified
IlvChartServerAction , so that it no longer
receives action events generated from the client. |
void |
setConfigParameters(IlvServletParameters configParams)
Sets the servlet configuration parameters.
|
void |
setImageEncoder(String format,
IlvImageEncoder encoder)
Registers the image encoder for the specified format.
|
void |
setPopupEnabled(boolean popupEnabled)
Sets whether this support can handle pop-up menu requests.
|
void |
setServlet(javax.servlet.http.HttpServlet servlet)
Sets the servlet associated with this support.
|
static Point |
toChartArea(Point point,
IlvServletRequestParameters params,
IlvChart chart)
Converts the specified point from the reference component coordinate
system to the chart area coordinate system.
|
static Rectangle |
toChartArea(Rectangle rect,
IlvServletRequestParameters params,
IlvChart chart)
Converts the specified rectangle from the reference component coordinate
system to the chart area coordinate system.
|
static Point |
toRefComp(Point point,
IlvServletRequestParameters params,
IlvChart chart)
Converts the specified point from the chart area coordinate system to the
reference component coordinate system.
|
static Rectangle |
toRefComp(Rectangle rect,
IlvServletRequestParameters params,
IlvChart chart)
Converts the specified rectangle from the chart area coordinate system to
the reference component coordinate system.
|
doGetScriptMessage, getParameterValidationListener, getScriptMessageSupport, setParameterValidationListener
public static final String REQUEST_PARAM
public static final String IMAGE_REQUEST
REQUEST_PARAM
.public static final String IMAGEMAP_REQUEST
REQUEST_PARAM
.public static final String HITMAP_REQUEST
REQUEST_PARAM
.public static final String VERBOSE_PARAM
public static final String IMAGE_FORMAT_PARAM
public static final String JPEG_IMAGE_FORMAT
public static final String PNG_IMAGE_FORMAT
public static final String X_MIN_PARAM
public static final String X_MAX_PARAM
public static final String Y_MIN_PARAM
public static final String Y_MAX_PARAM
public static final String BG_COLOR_PARAM
public static final String ACTION_PARAM
actionName(arg1,arg2,...)
. Use the addServerAction(java.lang.String, ilog.views.chart.servlet.IlvChartServerAction)
method to register an action to handle the specific actionName.public static final String COMPONENT_PARAM
public static final String CHART_COMPONENT
COMPONENT_PARAM
.public static final String AREA_COMPONENT
COMPONENT_PARAM
.public static final String LEGEND_COMPONENT
COMPONENT_PARAM
.public static final String OVERVIEW_COMPONENT
COMPONENT_PARAM
.public static final String IMAGEMAP_NAME
public static final String[] VALID_COMPONENTS
public static final String CAPABILITIES_REQUEST
REQUEST_PARAM
.public static final String CAP_FORMAT_PARAM
HTML_CAP_FORMAT
or OCTET_CAP_FORMAT
.public static final String JSON_CAP_FORMAT
CAP_FORMAT_PARAM
.@Deprecated public static final String HTML_CAP_FORMAT
JSON_CAP_FORMAT
instead.CAP_FORMAT_PARAM
.@Deprecated public static final String OCTET_CAP_FORMAT
JSON_CAP_FORMAT
instead.CAP_FORMAT_PARAM
.public static final String[] VALID_CAP_FORMATS
CAP_FORMAT_PARAM
. The array
consists of a singe value: JSON_CAP_FORMAT
.public IlvChartServletSupport()
IlvChartServletSupport
instance.public void setServlet(javax.servlet.http.HttpServlet servlet)
IlvChartServletSupport
instance
when a new IlvChartServletSupport
is created.public final javax.servlet.http.HttpServlet getServlet()
public IlvServletParameters getConfigParameters()
public void setConfigParameters(IlvServletParameters configParams)
configParams
- The servlet configuration parameters.public boolean isVerbose(IlvServletRequestParameters params)
params
- The servlet request parameters.protected abstract IlvChart getChart(IlvServletRequestParameters params) throws javax.servlet.ServletException
params
- The parameters parsed from the request.javax.servlet.ServletException
protected IlvChart getOverviewChart(IlvServletRequestParameters params) throws javax.servlet.ServletException
null
.javax.servlet.ServletException
protected void prepareOverviewChart(IlvServletRequestParameters params, IlvChart chart)
params
- The parameters parsed from the HTTP request.chart
- The chart returned by getOverviewChart(ilog.views.chart.servlet.IlvServletRequestParameters)
.protected void prepareChart(IlvServletRequestParameters params, IlvChart chart) throws javax.servlet.ServletException
params
- The parameters parsed from the HTTP request.chart
- The chart returned by getChart(ilog.views.chart.servlet.IlvServletRequestParameters)
.javax.servlet.ServletException
protected IlvDataWindow getRequestedVisibleWindow(IlvServletRequestParameters params, IlvChart chart) throws javax.servlet.ServletException
javax.servlet.ServletException
protected void prepareVisibleWindow(IlvServletRequestParameters params, IlvChart chart) throws javax.servlet.ServletException
javax.servlet.ServletException
X_MIN_PARAM
,
X_MAX_PARAM
,
Y_MIN_PARAM
,
Y_MAX_PARAM
protected IlvImageMapBuilder createImageMapBuilder(IlvServletRequestParameters params, IlvChart chart)
IlvImageMapBuilder
instance to generate an image
map.protected IlvIMapDefinition getIMapDefinition(IlvServletRequestParameters params, IlvChart chart)
IlvIMapDefinition
used by the
IlvImageMapBuilder
to generate the image map tags.
The default implementation returns null
, meaning an empty
image map.public boolean handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException, javax.servlet.ServletException
You can override this method to provide a new request type like this:
public boolean handleRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { if (super.handleRequest(request, response)) return true; IlvServletRequestParameters params = new IlvServletRequestParameters(request); String requestType = params.getString(REQUEST_PARAM, null); if ("somethingImportant".equals(requestType)) { doSomethingImportant(request, response, params); return true; } return false; }
handleRequest
in class IlvServletSupport
request
- The current HTTP request.response
- The HTTP response.true
if a recognized request was handled successfully
or false
if the request type was not recognized.
The recognized request types are IMAGE_REQUEST
,
IMAGEMAP_REQUEST
and CAPABILITIES_REQUEST
. An exception
is thrown if a recognized request is not handled successfully.IOException
- If an input or output error is detected when the
servlet handles the request.javax.servlet.ServletException
- If the request could not be handled.protected void generateMapAreaTags(PrintWriter output, IlvServletRequestParameters params, IlvChart chart) throws IOException
createImageMapBuilder
to
create a new IlvImageMapBuilder
object, and generates the
renderer tags according to the IlvIMapDefinition
returned
by the getIMapDefinition
method.output
- The output writer.params
- The parameters parsed from the request.chart
- The IlvChart
for the specified request.IOException
createImageMapBuilder(ilog.views.chart.servlet.IlvServletRequestParameters, ilog.views.chart.IlvChart)
,
getIMapDefinition(ilog.views.chart.servlet.IlvServletRequestParameters, ilog.views.chart.IlvChart)
protected BufferedImage generateImageAWT(IlvServletRequestParameters params, IlvChart chart, String compName, int width, int height) throws javax.servlet.ServletException
params
- The parameters parsed from the request.chart
- The chart to be displayed.compName
- The name of the component of the chart that shall be displayed.width
- The requested width of the image.height
- The requested height of the image.javax.servlet.ServletException
protected BufferedImage generateImageCT(IlvServletRequestParameters params, IlvChart chart, String compName, int width, int height) throws javax.servlet.ServletException
params
- The parameters parsed from the request.chart
- The chart to be displayed.compName
- The name of the component of the chart that shall be displayed.width
- The requested width of the image.height
- The requested height of the image.javax.servlet.ServletException
@Deprecated protected void additionalTextCapabilities(IlvChart chart, IlvServletRequestParameters params, PrintWriter writer) throws IOException, javax.servlet.ServletException
getAdditionalCapabilities(IlvChart, IlvServletRequestParameters)
instead.chart
- The chart returned by getChart
.params
- The parameters parsed from the current HTTP request.writer
- The servlet print writer for writing additional text/HTML
capabilities.IOException
javax.servlet.ServletException
@Deprecated protected void additionalBinaryCapabilities(IlvChart chart, IlvServletRequestParameters params, DataOutputStream dataStream) throws IOException, javax.servlet.ServletException
getAdditionalCapabilities(IlvChart, IlvServletRequestParameters)
instead.chart
- The chart returned by getChart
.params
- The parameters parsed from the current HTTP request.dataStream
- The servlet data output stream for writing additional
binary capabilities.IOException
javax.servlet.ServletException
protected Map<?,?> getAdditionalCapabilities(IlvChart chart, IlvServletRequestParameters params) throws javax.servlet.ServletException
Map
should contain pairs of propertyName
and propertyValue
for each additional capability.chart
- The chart returned by getChart
.params
- The parameters parsed from the current HTTP request.null if none
).javax.servlet.ServletException
@Deprecated protected void additionalOverviewTextCapabilities(IlvChart chart, IlvServletRequestParameters params, PrintWriter writer) throws IOException, javax.servlet.ServletException
getAdditionalOverviewCapabilities(IlvChart, IlvServletRequestParameters)
instead.chart
- The chart returned by getChart
.params
- The parameters parsed from the current HTTP request.writer
- The servlet print writer for writing additional text/HTML
capabilities.IOException
javax.servlet.ServletException
@Deprecated protected void additionalOverviewBinaryCapabilities(IlvChart chart, IlvServletRequestParameters params, DataOutputStream dout) throws IOException, javax.servlet.ServletException
getAdditionalOverviewCapabilities(IlvChart, IlvServletRequestParameters)
instead.chart
- The chart returned by getChart
.params
- The parameters parsed from the current HTTP request.dout
- The servlet data output stream for writing additional
binary capabilities.IOException
javax.servlet.ServletException
protected Map<?,?> getAdditionalOverviewCapabilities(IlvChart chart, IlvServletRequestParameters params) throws javax.servlet.ServletException
Map
should contain pairs of propertyName
and propertyValue
for each additional capability.chart
- The chart returned by getChart
.params
- The parameters parsed from the current HTTP request.null if none
).javax.servlet.ServletException
public final boolean isPopupEnabled()
true
if the servlet is set to handle
pop-up menu requests.setPopupEnabled(boolean)
public void setPopupEnabled(boolean popupEnabled)
This method must be called to support either static or dynamic pop-up menus.
See user manual for further details.
popupEnabled
- The new value for pop-up enabled.getPopupMenuSupport()
public final IlvPopupMenuServletSupport getPopupMenuSupport()
If the pop-up menu is dynamic, you must set the
menu factory through the setMenuFactory(IlvMenuFactory)
of the pop-up menu support returned by this method.
See user manual for further details.
null
if isPopupEnabled()
returns false
.setPopupEnabled(boolean)
protected IlvPopupMenuServletSupport createPopupMenuSupport()
public void setImageEncoder(String format, IlvImageEncoder encoder)
format
- The image format. For example: "JPEG" or "PNG".encoder
- The encoder or null
to unregister the format.getImageEncoder(java.lang.String)
public IlvImageEncoder getImageEncoder(String format)
format
- The image format. For example: "JPEG" or "PNG".null
if the format is not registered.setImageEncoder(java.lang.String, ilog.views.chart.servlet.IlvImageEncoder)
public final void addServerAction(String name, IlvChartServerAction action)
IlvChartServerAction
to receive events when the named
action is requested from the client. To be executed, the action
name and its parameters (as needed) must be specified in the "action"
request parameter (as &action="foo(param1,param2)"
), so that an
action such as adding, removing, or selecting objects can be performed
before the image is generated.
The IlvChartServerAction
will be invoked on the AWT event
dispatch thread.name
- The action name.action
- The server action.removeServerAction(java.lang.String, ilog.views.chart.servlet.IlvChartServerAction)
public final void removeServerAction(String name, IlvChartServerAction action)
IlvChartServerAction
, so that it no longer
receives action events generated from the client.name
- The action name.action
- The server action.addServerAction(java.lang.String, ilog.views.chart.servlet.IlvChartServerAction)
protected void executeAction(IlvServletRequestParameters params, IlvChart chart, int executionThread) throws javax.servlet.ServletException
javax.servlet.ServletException
addServerAction(java.lang.String, ilog.views.chart.servlet.IlvChartServerAction)
public static Rectangle toRefComp(Rectangle rect, IlvServletRequestParameters params, IlvChart chart) throws IlvParameterException
IlvParameterException
public static Point toRefComp(Point point, IlvServletRequestParameters params, IlvChart chart) throws IlvParameterException
IlvParameterException
public static Rectangle toChartArea(Rectangle rect, IlvServletRequestParameters params, IlvChart chart) throws IlvParameterException
IlvParameterException
public static Point toChartArea(Point point, IlvServletRequestParameters params, IlvChart chart) throws IlvParameterException
IlvParameterException
protected IlvLegend getLegend(IlvServletRequestParameters params) throws javax.servlet.ServletException
getChart(params).getLegend()
.javax.servlet.ServletException
public IlvChartHitmapSupport getHitmapSupport()
IlvChartHitmapSupport
.protected javax.servlet.ServletContext getContext()
getContext
in class IlvServletSupport
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.