ilog.views.servlet
Class IlvManagerServletSupport

java.lang.Object
  extended by ilog.views.servlet.IlvManagerServletSupport
Direct Known Subclasses:
IlvFacesManagerServletSupport, IlvSDMServletSupport

public abstract class IlvManagerServletSupport
extends Object

A class that can respond to HTTP request to generate an image from a JViews manager. This class can be used inside a Servlet to answer HTTP request.

Capabilities informations are rendered in JSON:

 {'minx'=0.0,'miny'=0.0,'maxx':1024.0,'maxy':512.0,
  'themes':['a layer name', 'antoher one'],
  'overviewthemes':[true, false],
  'maxZoom':6}
 
Once the HTML page is loaded by the client browser, the JavaScript code is executed. You can then query the JavaScript variables. Since JViews 8.0, zoom levels and dynamic capabilities are also provided.

Since:
JViews 3.5

Field Summary
static String ImageMapAreaGeneratorProperty
          The name of the property that is used during the generation of an image map.
 
Constructor Summary
IlvManagerServletSupport(javax.servlet.ServletContext context)
          Creates a manager servlet support.
 
Method Summary
protected  void additionalCapabilities(javax.servlet.http.HttpServletRequest request, javax.servlet.ServletOutputStream out, String mimeFormat)
          Deprecated. beginning with JViews 8.1 use getAdditionalCapabilities(HttpServletRequest) instead.
 void addServerActionListener(ServerActionListener listener)
          Adds the specified listener to receive events when an action is requested from the client.
protected  void beforeDraw(javax.servlet.http.HttpServletRequest request, IlvManagerView view)
          Called before the image is created.
protected  IlvPopupMenuServletSupport createPopupMenuSupport()
          Creates a new instance of popup menu servlet support.
protected  IlvSelectionSupport createSelectionSupport()
          Creates a new instance of selection servlet support.
protected  void encodeImage(BufferedImage image, OutputStream ostream, String formatName)
          This method performs the encoding of the BufferedImage using the given image format.
protected  BufferedImage generateImage(javax.servlet.http.HttpServletRequest request, IlvRect bbox, int width, int height, String[] requestedLayers, Color bgColor, boolean transparent)
          Generates the image.
protected  Map getAdditionalCapabilities(javax.servlet.http.HttpServletRequest request)
          Allows you to add more capabilities to the capability request.
 boolean getAntialiasing()
          Returns true if the manager view is antialiased when the image is generated.
 boolean getContentLengthEnable()
          Returns true if the servlet support is bufferized.
 javax.servlet.ServletContext getContext()
          Returns the servlet context.
protected  String getDefaultImageMapHREF(javax.servlet.http.HttpServletRequest request, IlvManagerView view)
          Returns the HREF that corresponds to the background of the image map.
 IlvManagerLayer[] getDynamicLayers(javax.servlet.http.HttpServletRequest request, IlvManagerView view)
          Returns an array of IlvManagerLayer instances that are known to be dynamic.
protected  long getExpirationDate(javax.servlet.http.HttpServletRequest request)
          Returns the expiration date, in milliseconds, used by the setImageResponseCachePolicy(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) method.
protected  Comparator<IlvGraphic> getGraphicObjectComparator(IlvManagerLayer layer, IlvManagerView view, javax.servlet.http.HttpServletRequest request)
          Returns a Comparator implementation that will be used to sort the IlvGraphic instances in the given layer that need to have their image map generated.
protected  IlvImageMapAreaGenerator getImageMapAreaGenerator(javax.servlet.http.HttpServletRequest request, IlvGraphic obj, IlvManagerView view, IlvTransformer t)
          Returns the area generator for the specified graphic object.
 Object getInternalLock(javax.servlet.http.HttpServletRequest request)
           
 float getJPEGQuality()
          Returns the quality of the produced JPEG file.
protected  Object getKey(javax.servlet.http.HttpServletRequest request)
          Returns the key used to identify a tile managed by the IlvTileManager.
 IlvManagerLayer[] getLayers(javax.servlet.http.HttpServletRequest request, IlvManagerView view)
          Returns the list of layers that are allowed to be rendered.
protected  Object getLock(javax.servlet.http.HttpServletRequest request)
          Returns a locking object that is used to lock the contents of the manager while it is being rendered.
protected  IlvRect getManagerBBox(javax.servlet.http.HttpServletRequest request, IlvManagerView view)
          Computes the bounding box of the manager.
protected  Comparator<IlvManagerLayer> getManagerLayerComparator(IlvManagerView view, javax.servlet.http.HttpServletRequest request)
          Returns a Comparator implementation that will be used to sort the IlvManagerLayer that are used to generate the image map when requested.
abstract  IlvManagerView getManagerView(javax.servlet.http.HttpServletRequest request)
          Returns the manager view used for the specified request.
protected  float getMaxZoomLevel(javax.servlet.http.HttpServletRequest request, IlvManagerView view)
          Returns the maximum zoom level authorized by the servlet.
protected  float getMinZoomLevel(javax.servlet.http.HttpServletRequest request, IlvManagerView view)
          Returns the minimum zoom level authorized by the servlet.
 IlvPopupMenuServletSupport getPopupMenuSupport()
          Returns the popup menu servlet support that handles popup menu requests.
 IlvSelectionSupport getSelectionSupport()
          Returns the servlet support that manages selection requests.
protected  IlvTileManager getTileManager(javax.servlet.http.HttpServletRequest request)
          Retrieves the tile manager.
 double[] getZoomLevels(javax.servlet.http.HttpServletRequest request, IlvManagerView view)
          Returns the zoom levels that a client of this servlet should use to take advantage of the tiling and caching mechanisms.
 boolean handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Responds to HTTP requests.
protected  boolean isOverviewLayer(javax.servlet.http.HttpServletRequest request, IlvManagerLayer layer)
          Returns true if the specified layer returned by getLayers should be displayed in an overview window.
 boolean isPopupEnabled()
          Returns true if the servlet is set to handle popup menu requests.
 boolean isSelectionEnabled()
          Returns true if the servlet is set to handle selection requests.
 boolean isVerbose()
          Returns true if the servlet is on verbose mode.
protected  void prepareManagerView(javax.servlet.http.HttpServletRequest request, IlvManagerView view)
          Allows you to prepare the manager view content before the image is generated or the capabilities are computed.
 void removeServerActionListener(ServerActionListener listener)
          Removes the specified listener so that it no longer receives events generated from the client.
 void setAntialiasing(boolean value)
          Sets the antialiasing of the manager view when the image generated.
 void setContentLengthEnable(boolean value)
          Sets the flag that switches the servlet support in a bufferized mode.
protected  void setImageResponseCachePolicy(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Sets the response cache policy when generating an image.
 void setJPEGQuality(float quality)
          Sets the quality of the produced JPEG file.
 void setPopupEnabled(boolean popupEnabled)
          Enables or disables the support of popup menu requests.
 void setSelectionEnabled(boolean selectionEnabled)
          Enables or disables the support of selection requests.
 void setVerbose(boolean value)
          Turns the verbose mode on and off.
protected  boolean shouldGenerateImageMap(javax.servlet.http.HttpServletRequest request, IlvManagerLayer layer, IlvManagerView view, IlvTransformer t)
          Returns true if image map information should be generated for the specified layer.
protected  boolean useTileManager(javax.servlet.http.HttpServletRequest request)
          Indicates whether a tile manager should be used by this servlet support.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ImageMapAreaGeneratorProperty

public static final String ImageMapAreaGeneratorProperty
The name of the property that is used during the generation of an image map. When this property is set on a layer with any type of value, then this layer is taken into account for the generation of an image map. In a layer, for every graphic object with such a property an area of the image map will be generated.

See Also:
IlvImageMapAreaGenerator, Constant Field Values
Constructor Detail

IlvManagerServletSupport

public IlvManagerServletSupport(javax.servlet.ServletContext context)
Creates a manager servlet support.

Parameters:
context - The Servlet Context.
Since:
JViews 5.5
Method Detail

getContext

public javax.servlet.ServletContext getContext()
Returns the servlet context.

Returns:
The servlet context of null when there is no servlet context.
Since:
JViews 7.5

setVerbose

public final void setVerbose(boolean value)
Turns the verbose mode on and off.

Parameters:
value - The new value for verbose.
See Also:
isVerbose()

isVerbose

public final boolean isVerbose()
Returns true if the servlet is on verbose mode.

See Also:
setVerbose(boolean)

setPopupEnabled

public void setPopupEnabled(boolean popupEnabled)
Enables or disables the support of popup menu requests.

This method must be called to support either static or dynamic popup menus.

See the user documentation for more details.

Parameters:
popupEnabled - The new value for popup enabled.
Since:
JViews 7.5
See Also:
getPopupMenuSupport()

isPopupEnabled

public final boolean isPopupEnabled()
Returns true if the servlet is set to handle popup menu requests.

Since:
JViews 7.5
See Also:
setPopupEnabled(boolean)

getPopupMenuSupport

public final IlvPopupMenuServletSupport getPopupMenuSupport()
Returns the popup menu servlet support that handles popup menu requests.

If the popup menu is dynamic, you must set a menu factory through the setMenuFactory(IlvMenuFactory) on the popup menu support returned by this method.

See the user documentation for more details.

Returns:
The popup menu servlet support or null if the support for popup menu is disabled.
Since:
JViews 7.5
See Also:
setPopupEnabled(boolean)

createPopupMenuSupport

protected IlvPopupMenuServletSupport createPopupMenuSupport()
Creates a new instance of popup menu servlet support.

Returns:
A new popup menu servlet support.
Since:
JViews 7.5

isSelectionEnabled

public final boolean isSelectionEnabled()
Returns true if the servlet is set to handle selection requests.

Since:
JViews 7.5
See Also:
setSelectionEnabled(boolean)

setSelectionEnabled

public void setSelectionEnabled(boolean selectionEnabled)
Enables or disables the support of selection requests.

See the user documentation for more details.

Since:
JViews 7.5
See Also:
isSelectionEnabled()

getSelectionSupport

public final IlvSelectionSupport getSelectionSupport()
Returns the servlet support that manages selection requests.

Returns:
The selection servlet support or null if the support for selection is disabled.
Since:
JViews 7.5
See Also:
setSelectionEnabled(boolean)

createSelectionSupport

protected IlvSelectionSupport createSelectionSupport()
Creates a new instance of selection servlet support.

This implementation returns null. Subclasses must override this method to support selection requests.

Returns:
A selection servlet support.
Since:
JViews 7.5

setAntialiasing

public final void setAntialiasing(boolean value)
Sets the antialiasing of the manager view when the image generated.

Parameters:
value - The new antialising state of the manager view.
See Also:
getAntialiasing()

getAntialiasing

public final boolean getAntialiasing()
Returns true if the manager view is antialiased when the image is generated. The default value is true.

See Also:
setAntialiasing(boolean)

setContentLengthEnable

public final void setContentLengthEnable(boolean value)
Sets the flag that switches the servlet support in a bufferized mode. When the servlet support bufferized the images the contents length of the response is set.

Parameters:
value - The bufferized flag.
See Also:
getContentLengthEnable()

getContentLengthEnable

public final boolean getContentLengthEnable()
Returns true if the servlet support is bufferized. The default value is false.

See Also:
setContentLengthEnable(boolean)

setJPEGQuality

public final void setJPEGQuality(float quality)
Sets the quality of the produced JPEG file.

Parameters:
quality - can be in the [0,1] range, 0 for poor quality and high compression, 1 for high quality and poor compression. The default value is 0.75.
See Also:
getJPEGQuality()

getJPEGQuality

public final float getJPEGQuality()
Returns the quality of the produced JPEG file. The default value is 0.75.

See Also:
setJPEGQuality(float)

getManagerView

public abstract IlvManagerView getManagerView(javax.servlet.http.HttpServletRequest request)
                                       throws javax.servlet.ServletException
Returns the manager view used for the specified request. You can return always the same manager view, or return a manager view for each request session if the content of the manager depends on the session.

Parameters:
request - The current HTTP request.
Throws:
javax.servlet.ServletException

getManagerBBox

protected IlvRect getManagerBBox(javax.servlet.http.HttpServletRequest request,
                                 IlvManagerView view)
                          throws javax.servlet.ServletException
Computes the bounding box of the manager. This area of the manager is used to give the area of interest for the servlet.

Parameters:
request - The current HTTP request.
view - The manager view returned by getManagerView.
Throws:
javax.servlet.ServletException

getMaxZoomLevel

protected float getMaxZoomLevel(javax.servlet.http.HttpServletRequest request,
                                IlvManagerView view)
Returns the maximum zoom level authorized by the servlet. The default value is 10.

Parameters:
request - The current HTTP request.
view - The manager view returned by getManagerView.

getMinZoomLevel

protected float getMinZoomLevel(javax.servlet.http.HttpServletRequest request,
                                IlvManagerView view)
Returns the minimum zoom level authorized by the servlet. The default value is 1 (fit to content).

Parameters:
request - The current HTTP request.
view - The manager view returned by getManagerView.
Since:
JViews 8.1

getLayers

public IlvManagerLayer[] getLayers(javax.servlet.http.HttpServletRequest request,
                                   IlvManagerView view)
                            throws javax.servlet.ServletException
Returns the list of layers that are allowed to be rendered. The default implementation returns an array containing all the layers of the manager.

Parameters:
request - The current HTTP request.
view - The manager view (returned by getManagerView).
Throws:
javax.servlet.ServletException

isOverviewLayer

protected boolean isOverviewLayer(javax.servlet.http.HttpServletRequest request,
                                  IlvManagerLayer layer)
Returns true if the specified layer returned by getLayers should be displayed in an overview window. The default implementation always return true.

Parameters:
request - The current HTTP request.
layer - A manager layer.
See Also:
getLayers(HttpServletRequest, IlvManagerView)

getLock

protected Object getLock(javax.servlet.http.HttpServletRequest request)
Returns a locking object that is used to lock the contents of the manager while it is being rendered.

The default implementation returns an object that identifies the manager view. This allows the getManagerView method to always return the same IlvManagerView without leading to multithreading problems.

This lock must never be taken on the AWT/Swing thread, otherwise deadlocks may occur.

Parameters:
request - The current HTTP request.
See Also:
getManagerView(javax.servlet.http.HttpServletRequest)

getInternalLock

public Object getInternalLock(javax.servlet.http.HttpServletRequest request)
Parameters:
request -
Internal method or field: do not use!

addServerActionListener

public final void addServerActionListener(ServerActionListener listener)
Adds the specified listener to receive events when an action is requested from the client. An action is generated from the client side, when the IlvView.performAction method is called. This method queries the server for a new image but additional parameters are sent in the image request so that an action such as adding, removing or selecting objects can be performed before the image is generated. An action is defined by a name and a list of parameters. To implement the action on the client side, you will implement the ServerActionListener interface and check the action name and parameters in the event.

Parameters:
listener - The listener.
See Also:
removeServerActionListener(ilog.views.servlet.ServerActionListener), IlvView.performAction(java.lang.String, java.lang.String[])

removeServerActionListener

public final void removeServerActionListener(ServerActionListener listener)
Removes the specified listener so that it no longer receives events generated from the client.

Parameters:
listener - The listener.
See Also:
addServerActionListener(ilog.views.servlet.ServerActionListener), IlvView.performAction(java.lang.String, java.lang.String[])

generateImage

protected BufferedImage generateImage(javax.servlet.http.HttpServletRequest request,
                                      IlvRect bbox,
                                      int width,
                                      int height,
                                      String[] requestedLayers,
                                      Color bgColor,
                                      boolean transparent)
                               throws javax.servlet.ServletException
Generates the image. You may override this method to add additional information on the generated image.

Parameters:
request - The current HTTP request.
bbox - The area of the manager to draw.
width - The width of the image.
height - The height of the image.
requestedLayers - An array of layer names to draw.
bgColor - The background color of the image
transparent - Indicates if the image should be transparent.
Throws:
javax.servlet.ServletException

getKey

protected Object getKey(javax.servlet.http.HttpServletRequest request)
Returns the key used to identify a tile managed by the IlvTileManager. This implementation returns an IlvRect that identifies the tile.

Parameters:
request - The current HttpServletRequest.
Returns:
The key.
Since:
JViews 8.0

useTileManager

protected boolean useTileManager(javax.servlet.http.HttpServletRequest request)
Indicates whether a tile manager should be used by this servlet support.

Parameters:
request - The current HTTP request.
Returns:
Returns true if the request contains a parameter with a 'tile' parameter set to true, otherwise returns false.
Since:
JViews 8.0

getTileManager

protected IlvTileManager getTileManager(javax.servlet.http.HttpServletRequest request)
                                 throws javax.servlet.ServletException
Retrieves the tile manager. This implementation returns null. Subclasses must override this method to provide a tile manager.

Parameters:
request - The current HTTP request.
Returns:
The IlvTileManager or null if no tile manager was found.
Throws:
javax.servlet.ServletException
Since:
JViews 8.0

getDefaultImageMapHREF

protected String getDefaultImageMapHREF(javax.servlet.http.HttpServletRequest request,
                                        IlvManagerView view)
Returns the HREF that corresponds to the background of the image map. The default returned value is null meaning no HREF.

Parameters:
request - The current HTTP request.
view - The manager view for the specified request.

getGraphicObjectComparator

protected Comparator<IlvGraphic> getGraphicObjectComparator(IlvManagerLayer layer,
                                                            IlvManagerView view,
                                                            javax.servlet.http.HttpServletRequest request)
Returns a Comparator implementation that will be used to sort the IlvGraphic instances in the given layer that need to have their image map generated.

When used, the Comparator should yield an ordered collection in descending order with the IlvGraphic instances of higher priority being listed first.

A null value can be returned to indicate that no sorting needs to take place.

Parameters:
layer - The layer that contains IlvGraphic instances to be potentially sorted.
request - The current HTTP request.
view - The manager view for the specified request.
Returns:
The Comparator that will be used to sort the IlvGraphic instances that need to have their image map generated. Or null if no sorting is needed.
Since:
JViews 8.1
Internal method or field: do not use!

getManagerLayerComparator

protected Comparator<IlvManagerLayer> getManagerLayerComparator(IlvManagerView view,
                                                                javax.servlet.http.HttpServletRequest request)
Returns a Comparator implementation that will be used to sort the IlvManagerLayer that are used to generate the image map when requested.

When used, the Comparator should yield an ordered collection in descending order with the IlvManagerLayer instances of higher priority being listed first.

A null value can be returned to indicate that no sorting needs to take place.

Parameters:
request - The current HTTP request.
view - The manager view for the specified request.
Returns:
The Comparator that will be used to sort the IlvManagerLayer that are used to generate the image map when requested. Or null if no sorting is needed.
Since:
JViews 8.1
Internal method or field: do not use!

getImageMapAreaGenerator

protected IlvImageMapAreaGenerator getImageMapAreaGenerator(javax.servlet.http.HttpServletRequest request,
                                                            IlvGraphic obj,
                                                            IlvManagerView view,
                                                            IlvTransformer t)
Returns the area generator for the specified graphic object.

Parameters:
request - The current HTTP request.
obj - The graphic object for which the area will be generated.
view - The manager view for the specified request.
t - The transformer used to draw the view.

shouldGenerateImageMap

protected boolean shouldGenerateImageMap(javax.servlet.http.HttpServletRequest request,
                                         IlvManagerLayer layer,
                                         IlvManagerView view,
                                         IlvTransformer t)
Returns true if image map information should be generated for the specified layer.

Parameters:
request - The current HTTP request.
layer - The layer.
view - The manager view for the specified request.
t - The transformer used to draw the view.

encodeImage

protected void encodeImage(BufferedImage image,
                           OutputStream ostream,
                           String formatName)
                    throws IOException
This method performs the encoding of the BufferedImage using the given image format. It supports all encoding formats supported by the javax.imageio API. It can be redefined to change the way the encoding is performed.

Parameters:
image - The image to encode.
ostream - The OutputStream to which the encoded image must be output.
formatName - a String containing the informal name of the image format.
Throws:
IOException - If encoding failed.
Since:
JViews 8.1
See Also:
ImageIO

setImageResponseCachePolicy

protected void setImageResponseCachePolicy(javax.servlet.http.HttpServletRequest request,
                                           javax.servlet.http.HttpServletResponse response)
Sets the response cache policy when generating an image. This default implementation does the following:
 response.setHeader("pragma", "no-cache");
 response.setHeader("Cache-Control", "no-cache");
 
If the request is a tile request (containing an attribute named 'tile') whose value is true, an expiration date is set.

Parameters:
request - The http request.
response - The http response to configure.
Since:
JViews 8.0

getExpirationDate

protected long getExpirationDate(javax.servlet.http.HttpServletRequest request)
Returns the expiration date, in milliseconds, used by the setImageResponseCachePolicy(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) method.

Parameters:
request - The current HttpServletRequest.
Returns:
An expiration date, in milliseconds.
Since:
JViews 8.0

getZoomLevels

public double[] getZoomLevels(javax.servlet.http.HttpServletRequest request,
                              IlvManagerView view)
Returns the zoom levels that a client of this servlet should use to take advantage of the tiling and caching mechanisms. This default implementation returns null.

Parameters:
request - The current HTTP request.
view - The view returned by getManagerView().
Returns:
An array of double values or null if no zoom level is provided.
Since:
JViews 8.0

getDynamicLayers

public IlvManagerLayer[] getDynamicLayers(javax.servlet.http.HttpServletRequest request,
                                          IlvManagerView view)
Returns an array of IlvManagerLayer instances that are known to be dynamic.

This implementation returns the layers that have an index greater or equal to the value returned by IlvManagerView.getTripleBufferedLayerCount().

Parameters:
request - The current HttpServletRequest.
view - The IlvManagerView returned by getManagerView().
Returns:
An array containing all the dynamic layers or an empty array if no layer is dynamic.
Since:
JViews 8.0
See Also:
IlvManagerView.getTripleBufferedLayerCount()

additionalCapabilities

protected void additionalCapabilities(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.ServletOutputStream out,
                                      String mimeFormat)
Deprecated. beginning with JViews 8.1 use getAdditionalCapabilities(HttpServletRequest) instead.

Allows you to add additional capabilities to the capability request. They must be put in the stream as a JSON fragment. Example:
   , 'myprop1' : 'myvalue1', 'myprop2' : 'myvalue2'
 

Parameters:
request - The current HTTP request.
out - The servlet output stream for writing additional capabilities.
mimeFormat - since JViews 8.1 always set to "json"

getAdditionalCapabilities

protected Map getAdditionalCapabilities(javax.servlet.http.HttpServletRequest request)
Allows you to add more capabilities to the capability request. The Map should contain pairs of propertyName and propertyValue for each additional capability.

Parameters:
request - The current HTTP request.
Returns:
The additional properties (null if none).
Since:
JViews 8.1

beforeDraw

protected void beforeDraw(javax.servlet.http.HttpServletRequest request,
                          IlvManagerView view)
                   throws javax.servlet.ServletException
Called before the image is created. This method is called just before the image is created in an "image" request. The default implementation decodes action parameters to execute potential actions.

Parameters:
request - The current HTTP request.
view - The manager view returned by getManagerView.
Throws:
javax.servlet.ServletException

prepareManagerView

protected void prepareManagerView(javax.servlet.http.HttpServletRequest request,
                                  IlvManagerView view)
                           throws javax.servlet.ServletException
Allows you to prepare the manager view content before the image is generated or the capabilities are computed. The current implementation does nothing.

Parameters:
request - The current HTTP request.
view - The manager view returned by getManagerView.
Throws:
javax.servlet.ServletException

handleRequest

public boolean handleRequest(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response)
                      throws IOException,
                             javax.servlet.ServletException
Responds to HTTP requests. This method responds to image or capabilities requests . It returns false if the request is not a request recognized by this servlet.

Parameters:
request - The current HTTP request.
response - The HTTP response.
Returns:
false when the request is not recognized by this servlet.
Throws:
IOException
javax.servlet.ServletException


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.