package examples.htmlkona;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import weblogic.html.*;
/**
* This servlet demonstrates how to create image maps with htmlKona.
*
* @author Copyright (c) 1996-98 by WebLogic, Inc. All Rights Reserved.
* @author Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
*/
public class ImageMap extends HttpServlet {
public synchronized void service(HttpServletRequest req, HttpServletResponse res)
throws IOException
{
try {
res.setStatus(HttpServletResponse.SC_OK);
res.setContentType("text/html");
ServletPage hp = new ServletPage();
hp.getHead()
.addElement(new TitleElement("Image Map"));
hp.getBodyElement()
.setAttribute(BodyElement.bgColor, HtmlColor.white);
int[] xcoords = {353, 474, 353};
int[] ycoords = {116, 163, 163};
int ncoords = 3;
hp.getBody()
.addElement(MarkupElement.HorizontalRule)
.addElement(new HeadingElement("Client-side image map", 2))
.addElement(new StringElement("This demo is designed to illustrate how you might "
+ "use a screenshot and an image map to provide "
+ "online help. You can demonstrate the client-"
+ "side image map by clicking on "
+ "several areas. The areas are: the OK button, "
+ "the Cancel "
+ "button, the DNS button, a triangle shape that "
+ "stretches from the upper left corner of the "
+ "Advanced button to the lower right corner of "
+ "the Help button to the lower left corner of "
+ "the Help button. The last area is a circle "
+ "with a 40-pixel radius that originates over "
+ "the first dot in the Default Gateway box. "
+ "Clicking on any of these areas will take you "
+ "to a demo help-page on WebLogic's website."))
.addElement(MarkupElement.HorizontalRule)
.addElement(new ImageElement(defaults.imageloc() + "ipscreen.gif")
.setAlign(AlignType.center)
.setUseMap("#MyMap", true))
.addElement(new MapElement("MyMap")
.addElement(new AreaElement(AreaElement.rectangle,
"353, 33, 475, 53",
"http://www.weblogic.com/docs/classdocs/htmlimgmap.html#ok"))
.addElement(new AreaElement(AreaElement.rectangle,
"353, 60, 475, 82",
"http://www.weblogic.com/docs/classdocs/htmlimgmap.html#cancel"))
.addElement(new AreaElement(new java.awt.Rectangle(353,88,475,100),
"http://www.weblogic.com/docs/classdocs/htmlimgmap.html#dns"))
.addElement(new AreaElement(new java.awt.Polygon(xcoords, ycoords, ncoords),
"http://www.weblogic.com/docs/classdocs/htmlimgmap.html#advanced"))
.addElement(new AreaElement(AreaElement.circle,
"220,193, 40",
"http://www.weblogic.com/docs/classdocs/htmlimgmap.html#circle")))
.addElement(MarkupElement.HorizontalRule);
hp.output(res.getOutputStream());
}
catch (Exception e) {
defaults.showException(e, res.getOutputStream());
}
}
}