The servlet provided by Rogue Wave JViews (
IlvManagerServlet)
is able to generate an image map for your Rogue Wave JViews application, but it is likely that
you do not want to generate a clickable area for every graphic object.
On the server side, you must then tell the manager servlet which Rogue Wave JViews layer and which graphic object are
part of the image map generation. For both layer and graphic object,
this is done by setting a property on them.
On a layer, assuming that the variable
manager
is
an
IlvManager, you can set properties as follows:
manager.getManagerLayer(index).setProperty( IlvManagerServlet.
ImageMapAreaGeneratorProperty, Boolean.TRUE);
On a graphic object you can do almost the same thing,
but the value of the property must be an instance of the class
IlvImageMapAreaGenerator. This class is responsible for generating the AREA
part of the image map.
Note that the same instance of IlvImageMapAreaGenerator
can
be used for all graphic objects.
By default, IlvImageMapAreaGenerator
generates
a rectangular area with no HREF in it. You must subclass it to generate
an HREF for your graphic object.
Here is an example that creates a custom IlvImageMapAreaGenerator
and
sets it on some objects:
IlvGraphic object1, object2;
....
IlvImageMapAreaGenerator generator = new IlvImageMapAreaGenerator() {
public String generateHREF(IlvManagerView v, IlvGraphic obj) {
String href;
// place here code the
// computes the URL depending on the graphic object
return href;
}
};
object1.setProperty(IlvManagerServlet.ImageMapAreaGeneratorProperty,
generator);
object2.setProperty(IlvManagerServlet.ImageMapAreaGeneratorProperty,
generator);
The HREF can be a URL to which the browser jumps when
the area is clicked, but it can also be a call to a JavaScript™
method.
For example, in the XML Grapher example, you can define
the generator like this:
IlvImageMapAreaGenerator generator = new IlvImageMapAreaGenerator() {
public String generateALT(IlvManagerView v, IlvGraphic obj) {
return ((GrapherNode)obj).getLabel();
}
public String generateHREF(IlvManagerView v, IlvGraphic obj) {
return "javascript:doSomething(’"+
((GrapherNode)obj).getLabel()+"’)";
}
};
In this example, the HREF generated is a call to the
JavaScript method doSomething
. You must
define this method in the HTML page.
For more information about customizing an area, see the
IlvImageMapAreaGenerator class in the
Java
API Reference Manual.