Class Map<T extends Map<T>>


public class Map<T extends Map<T>> extends StyledContainerElement<T>
Represents an HTML <map> element for defining image maps.

The <map> element is used to define a client-side image map, which allows different regions of an image to be clickable links. The map contains one or more <area> elements that define the clickable regions and their associated links. Image maps are useful for creating interactive graphics like navigation diagrams or geographic maps.

Features:

  • Defines clickable regions within an image
  • Contains one or more area elements
  • Associated with images via the name attribute
  • Supports various shapes (rectangle, circle, polygon)

Usage:


 // Create an image map
 Map imageMap = new Map();
 imageMap.setName("navigation-map");

 // Add clickable areas
 Area homeArea = new Area();
 homeArea.setShape("rect");
 homeArea.setCoords("0,0,50,50");
 homeArea.setHref("/home");
 imageMap.addArea(homeArea);

 Area aboutArea = new Area();
 aboutArea.setShape("rect");
 aboutArea.setCoords("50,0,100,50");
 aboutArea.setHref("/about");
 imageMap.addArea(aboutArea);

 // Associate with an image
 Image img = new Image("navigation.png");
 img.setUseMap("#navigation-map");
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • Map

      public Map()
      Constructs an empty <map> element.

      Creates an image map without a name or areas. The name and area elements should be added using the setter methods.

  • Method Details

    • setName

      public final T setName(String name)
      Sets the name attribute for this image map.

      The name is used to associate this map with an image element via the image's usemap attribute. The usemap value should be "#" followed by this name.

      Parameters:
      name - the unique name for this image map
    • addArea

      public void addArea(Area area)
      Adds an area element to this image map.

      Area elements define the clickable regions within the image map, including their shape, coordinates, and destination URLs.

      Parameters:
      area - the Area element defining a clickable region