ilog.views.servlet
Class IlvManagerServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by ilog.views.servlet.IlvManagerServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
IlvFacesManagerServlet

public abstract class IlvManagerServlet
extends javax.servlet.http.HttpServlet

An abstract servlet that can respond to HTTP request to generate a JPEG image from a JViews manager. This servlet can be used with the JViews thin client library (see : ilog.views.thinclient) or with the JViews thin client DHTML scripts. The servlet supports two types of request.
The request for the image:

 <servletpath>?request=image
              &bbox=x,y,width,height (manager coordinate system)
              &layer=layer1, layer2
              &width=  resulting image width
              &height= resulting image height
              &format=JPEG
             [&bgcolor=0xffffff]
             [&transparent=false]
This request returns an image corresponding to the (x,y,width,height) area of the manager.
The second type of request is the request for capabilities. This request returns information about the manager. This information are required by the client to handle the image request.
 <servletpath>?request=capabilities
                 &format=[json|octect-stream]
 
This request returns information on the manager. It can be of two different formats:
HTML: In this case the result is an empty HTML page that contains JavaScript code. This format is used when the client is a Web browser.
 <html>
 <head>
 <script language="JavaScript">
 var minx=0.0;
 var miny=0.0;
 var maxx=1024.0;
 var maxy=512.0;
 var themes=new Array();
 var overviewthemes=new Array();
 themes[0]="a layer name";
 overviewthemes[0]=true;
 themes[1]="another layer";
 overviewthemes[1]=true;
 themes[2]="a third layer";
 overviewthemes[2]=true;
 var maxZoom=6;
 </script>
 </head>
 </body>
 </html>
 
Once the HTML page is loaded by the client browser, the JavaScript code is executed. You can then query the JavaScript variables.

OCTET-STREAM: In this case the result in a stream of octets. This format is used when the client is a thin Java applet. The data is produced using java.io.DataOutput and is organized like this:
 Float: Left coordinate of manager's bounding box.
 Float: Top coordinate of manager's bounding box.
 Float: Right coordinate of manager's bounding box.
 Float: Bottom coordinate of manager's bounding box.
 Int: Number of layers.

 For each layer:
 String (UTF format): Name of the layer.
 Boolean: Whether or not the layer is an overview layer.

 Float: Maximum zoom level
 

Since:
JViews 3.5
See Also:
Serialized Form

Field Summary
static String ImageMapAreaGeneratorProperty
          The name of the property that is used during the generation of an image map.
 
Constructor Summary
IlvManagerServlet()
          Creates a IlvManagerServlet.
IlvManagerServlet(IlvManagerServletSupport support)
          Deprecated. Beginning with JViews 8.1 use a subclass and redefine createServletSupport(ServletContext) instead.
 
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  IlvManagerServletSupport createServletSupport(javax.servlet.ServletContext context)
          Returns a new instance of IlvManagerServletSupport.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Responds to the servlet request.
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Responds to the servlet request.
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 put additional 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.
protected  String getDefaultImageMapHREF(javax.servlet.http.HttpServletRequest request, IlvManagerView view)
          Returns the HREF that corresponds to the background of the image map.
protected  IlvImageMapAreaGenerator getImageMapAreaGenerator(javax.servlet.http.HttpServletRequest request, IlvGraphic obj, IlvManagerView view, IlvTransformer t)
          Returns the area generator for the specified graphic object.
 float getJPEGQuality()
          Returns the quality of the produced JPEG file.
protected  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.
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  IlvManagerServletSupport getServletSupport()
          Returns the IlvManagerServletSupport instance.
protected  IlvManagerServletSupport getSupport()
          Deprecated. Beginning with JViews 8.1 use getServletSupport() instead.
protected  boolean handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Responds to the servlet request.
 void init(javax.servlet.ServletConfig config)
          Initializes the manager servlet.
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 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.
protected  void prepareSession(javax.servlet.http.HttpServletRequest request)
          Prepare a session for the client.
 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.
 void setJPEGQuality(float quality)
          Sets the quality of the produced JPEG file.
 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.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, 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

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

IlvManagerServlet

public IlvManagerServlet()
Creates a IlvManagerServlet.


IlvManagerServlet

public IlvManagerServlet(IlvManagerServletSupport support)
Deprecated. Beginning with JViews 8.1 use a subclass and redefine createServletSupport(ServletContext) instead.

Creates a manager servlet.

Parameters:
support - The manager servlet support.
Since:
JViews 7.5
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Initializes the manager servlet.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - The ServletConfig instance.
Throws:
javax.servlet.ServletException
Since:
JViews 5.5

getSupport

protected final IlvManagerServletSupport getSupport()
Deprecated. Beginning with JViews 8.1 use getServletSupport() instead.

Returns the servlet support. The servlet delegates most operations to the servlet support. Derived classes can access the servlet support to implement high level functionality.

Since:
JViews 7.5

getServletSupport

protected final IlvManagerServletSupport getServletSupport()
Returns the IlvManagerServletSupport instance. The servlet delegates most operations to the servlet support. Derived classes can access the servlet support to implement high level functionality.

Since:
JViews 8.1

createServletSupport

protected IlvManagerServletSupport createServletSupport(javax.servlet.ServletContext context)
Returns a new instance of IlvManagerServletSupport.

Since:
JViews 8.1

setVerbose

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

See Also:
isVerbose()

isVerbose

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

See Also:
setVerbose(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 bad 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)

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)

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.

getLayers

protected 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(javax.servlet.http.HttpServletRequest, ilog.views.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 always return a new object that means no locking.

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

getImageMapAreaGenerator

protected IlvImageMapAreaGenerator getImageMapAreaGenerator(javax.servlet.http.HttpServletRequest request,
                                                            IlvGraphic obj,
                                                            IlvManagerView view,
                                                            IlvTransformer t)
Returns the area generator for the specified graphic object. 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.

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.

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[])

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 put additional capabilities to the capability request. The Map should contains 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

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

handleRequest

protected boolean handleRequest(javax.servlet.http.HttpServletRequest request,
                                javax.servlet.http.HttpServletResponse response)
                         throws IOException,
                                javax.servlet.ServletException
Responds to the servlet request. This method responds to image or capabilities requests. It returns false if the request is not a request recognized by this servlet. You may overwrite this method to handle a new type of request, in this case you will have to call the super method.

Parameters:
request - the current Http request.
response - the Http response.
Throws:
IOException
javax.servlet.ServletException

prepareSession

protected void prepareSession(javax.servlet.http.HttpServletRequest request)
Prepare a session for the client. This method is called at every request before any other method to allow the user to prepare a session for its servlet. The actual implementation is empty, but if your servlet needs to create a session you can overwrite the method to do it.

Parameters:
request - the current request.

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws IOException,
                  javax.servlet.ServletException
Responds to the servlet request. This method simply calls prepareSession(javax.servlet.http.HttpServletRequest) then handleRequest(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse). You normally do not need to overwrite this method. To add a new type of request, you can overwrite the method handleRequest.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - The current HTTP request.
response - The HTTP response.
Throws:
IOException
javax.servlet.ServletException

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws IOException,
                   javax.servlet.ServletException
Responds to the servlet request. The default implementation simply calls doGet.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
request - The current HTTP request.
response - The HTTP response.
Throws:
IOException
javax.servlet.ServletException
See Also:
doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)


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