com.ibm.wbi.protocol.http.beans.imagemap
Class ImageMap

java.lang.Object
  |
  +--com.ibm.wbi.protocol.http.beans.imagemap.ImageMap

public final class ImageMap
extends java.lang.Object

Utility class for processing http imagemap requests. This class is used in conjunction with ImageMapRegion classes to define the regions of an image and the url associated with each region. In addition, ImageMap allows for the definition of a default url if no regions match the location of the imagemap request.


Constructor Summary
ImageMap()
          Creates a new ImageMap object, with no default URL.
ImageMap(java.lang.String defaultURL)
          Creates a new ImageMap object, with defaultURL as the default URL.
 
Method Summary
 void addRegion(ImageMapRegion region)
          Adds the specified region object to the list of regions for this ImageMap.
 void addRegion(ImageMapRegion region, int at)
          Adds region object to list of regions for this ImageMap at specified location.
 ImageMapRegion find(int x, int y)
          Locates the ImageMapRegion that maps to location (x,y).
 ImageMapRegion find(Point point)
          Locates the ImageMapRegion that maps to location point.
 java.lang.String findUrl(int x, int y)
          Locates the url that is represented by the location (x,y).
 java.lang.String findUrl(Point point)
          Locates the url that is represented by the location point.
 java.lang.String findUrl(java.lang.String url)
          Locates the url that is represented by the imagemap information in the url query string url.
 java.lang.String getDefaultUrl()
          Returns the current default url.
 int getNumRegion()
          Returns number of regions this ImageMap object knows about.
 ImageMapRegion getRegion(int at)
          Returns the ImageMapRegion object at the specified index.
static void main(java.lang.String[] args)
          Tests ImageMap.
 void setDefaultUrl(java.lang.String url)
          Sets the default URL for ImageMap to defaultURL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageMap

public ImageMap()
Creates a new ImageMap object, with no default URL.

ImageMap

public ImageMap(java.lang.String defaultURL)
Creates a new ImageMap object, with defaultURL as the default URL.
Parameters:
defaultURL - default URL to be returned if no regions are defined at map location
Method Detail

main

public static void main(java.lang.String[] args)
Tests ImageMap.
Parameters:
args[] - command line parameters

addRegion

public void addRegion(ImageMapRegion region)
Adds the specified region object to the list of regions for this ImageMap.
Parameters:
region - ImageMapRegion to be added to list of Regions

addRegion

public void addRegion(ImageMapRegion region,
                      int at)
Adds region object to list of regions for this ImageMap at specified location.
Parameters:
region - ImageMapRegion to be added to list of Regions
at - index into list to add the region

getRegion

public ImageMapRegion getRegion(int at)
Returns the ImageMapRegion object at the specified index.
Parameters:
at - index of region requested; valid values are 0 to numRegions() - 1
Returns:
Region at specified index; null if index invalid or no region at index.

getNumRegion

public int getNumRegion()
Returns number of regions this ImageMap object knows about.
Returns:
number of regions this ImageMap knows about

setDefaultUrl

public void setDefaultUrl(java.lang.String url)
Sets the default URL for ImageMap to defaultURL.
Parameters:
url - url to be used as the default

getDefaultUrl

public java.lang.String getDefaultUrl()
Returns the current default url.
Returns:
currently defined default url; null if none defined

find

public ImageMapRegion find(int x,
                           int y)
Locates the ImageMapRegion that maps to location (x,y). This is found by sending isInside to each element in the Regions list until a first match is found.
Parameters:
x - x coordinate
y - y coordinate
Returns:
ImageMapRegion at point; null if none found

find

public ImageMapRegion find(Point point)
Locates the ImageMapRegion that maps to location point. This is found by sending isInside to each element in the Regions list, until a first match is found.
Parameters:
point - the location point in question
Returns:
ImageMapRegion at point; null if none found

findUrl

public java.lang.String findUrl(int x,
                                int y)
Locates the url that is represented by the location (x,y). This is found by sending isInside to each element in the Regions list, until a first match is found.
Parameters:
x - x coordinate
y - y coordinate
Returns:
url mapped to x,y; defaultUrl() if no mapping

findUrl

public java.lang.String findUrl(Point point)
Locates the url that is represented by the location point. This is found by sending isInside to each element in the Regions list, until a first match is found.
Parameters:
point - the location point in question
Returns:
url mapped to point; defaultUrl() if no mapping

findUrl

public java.lang.String findUrl(java.lang.String url)
Locates the url that is represented by the imagemap information in the url query string url. This is found by sending isInside to each element in the Regions list, until a first match is found.
Parameters:
url - url that contains the query string w/ imagemap information
Returns:
url mapped to url; defaultUrl() if no mapping