javax.swing.text.html
Class Map

java.lang.Object
  extended byjavax.swing.text.html.Map

class Map
extends Object

Map is used to represent a map element that is part of an HTML document. Once a Map has been created, and any number of areas have been added, you can test if a point falls inside the map via the contains method.

Author:
Scott Violet

Nested Class Summary
(package private) static class Map.CircleRegionContainment
          Used to test for containment in a circular region.
(package private) static class Map.DefaultRegionContainment
          An implementation that will return true if the x, y location is inside a rectangle defined by origin 0, 0, and width equal to width passed in, and height equal to height passed in.
(package private) static class Map.PolygonRegionContainment
          Used to test for containment in a polygon region.
(package private) static class Map.RectangleRegionContainment
          Used to test for containment in a rectangular region.
(package private) static interface Map.RegionContainment
          Defines the interface used for to check if a point is inside a region.
 
Field Summary
private  Vector areaAttributes
          An array of AttributeSets.
private  Vector areas
          An array of RegionContainments, will slowly grow to match the length of areaAttributes as needed.
private  String name
          Name of the Map.
 
Constructor Summary
Map()
           
Map(String name)
           
 
Method Summary
 void addArea(AttributeSet as)
          Defines a region of the Map, based on the passed in AttributeSet.
protected  Map.RegionContainment createRegionContainment(AttributeSet attributes)
          Creates and returns an instance of RegionContainment that can be used to test if a particular point lies inside a region.
protected static int[] extractCoords(Object stringCoords)
          Creates and returns an array of integers from the String stringCoords.
 AttributeSet getArea(int x, int y, int width, int height)
          Returns the AttributeSet that contains the passed in location, x, y.
 AttributeSet[] getAreas()
          Returns the AttributeSets representing the differet areas of the Map.
 String getName()
          Returns the name of the Map.
 void removeArea(AttributeSet as)
          Removes the previously created area.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private String name
Name of the Map.


areaAttributes

private Vector areaAttributes
An array of AttributeSets.


areas

private Vector areas
An array of RegionContainments, will slowly grow to match the length of areaAttributes as needed.

Constructor Detail

Map

public Map()

Map

public Map(String name)
Method Detail

getName

public String getName()
Returns the name of the Map.


addArea

public void addArea(AttributeSet as)
Defines a region of the Map, based on the passed in AttributeSet.


removeArea

public void removeArea(AttributeSet as)
Removes the previously created area.


getAreas

public AttributeSet[] getAreas()
Returns the AttributeSets representing the differet areas of the Map.


getArea

public AttributeSet getArea(int x,
                            int y,
                            int width,
                            int height)
Returns the AttributeSet that contains the passed in location, x, y. width, height gives the size of the region the map is defined over. If a matching area is found, the AttribueSet for it is returned.


createRegionContainment

protected Map.RegionContainment createRegionContainment(AttributeSet attributes)
Creates and returns an instance of RegionContainment that can be used to test if a particular point lies inside a region.


extractCoords

protected static int[] extractCoords(Object stringCoords)
Creates and returns an array of integers from the String stringCoords. If one of the values represents a % the returned value with be negative. If a parse error results from trying to parse one of the numbers null is returned.