lt.monarch.chart.engine
Class SimpleHotSpotMap

java.lang.Object
  extended by lt.monarch.chart.engine.HotSpotMap
      extended by lt.monarch.chart.engine.SimpleHotSpotMap
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
ImageMap

public class SimpleHotSpotMap
extends HotSpotMap

A simple hot spot map, which accepts all hot spot mappings and stores them. It can then find a mapped chart entity at a desired point (x,y)

See Also:
Serialized Form

Nested Class Summary
Modifier and Type Class and Description
static class SimpleHotSpotMap.HotSpot
          A simple hot spot, which maps some chart entity to some rectangle or polygon.
 
Field Summary
Modifier and Type Field and Description
protected  java.util.ArrayList<SimpleHotSpotMap.HotSpot> map
          array of chart entities mappings to polygons or rectangles.
 
Constructor Summary
Constructor and Description
SimpleHotSpotMap()
           
 
Method Summary
Modifier and Type Method and Description
 void clear()
          Removes all chart objects
 void clearEntity(ChartEntity entity)
          Removes the specified chart entity and all it's child entities from the hot spot map.
 java.util.List<ChartEntity> findAllEntitiesAt(Point2D pt)
          Finds all mapped entities at the specified point.
 java.lang.Object[] findEntitiesInside(java.awt.Rectangle r)
          Finds a chart entities that are inside of the given area.
 java.lang.Object[] findEntitiesIntersecting(java.awt.Rectangle r)
          Finds a chart entities that intersect with the given area.
 ChartEntity findEntityAt(Point2D pt)
          Finds a chart entity at the specified point.
 Point2D getEntityPosition(ChartEntity entity)
          Returns a position of the specified chart entity.
 java.awt.Shape getEntityShape(ChartEntity chartEntity)
          Returns the entity shape according to the entity.
 java.awt.Shape getEntityShape(Point2D pt)
          Returns the entity shape according to the point.
 ChartEntity getObjectById(int id)
          Finds a chart object with specified id.
 void mapEntity(ChartEntity entity, Point2D pt)
          Maps the specified chart entity to the specified point.
 void mapEntity(ChartEntity entity, Rectangle2D rectangle)
          Maps the specified chart entity to the specified rectangle.
 void mapEntity(ChartEntity entity, java.awt.Shape shape)
          Maps the specified chart entity to the specified polygon.
 void mapEntity(ChartEntity entity, java.awt.Shape shape, int id)
          Maps the polygon to the entity.
protected  void mapEntity(SimpleHotSpotMap.HotSpot spot)
          Puts the specified HotSpot to the mappings array.
 
Methods inherited from class lt.monarch.chart.engine.HotSpotMap
contains
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected final java.util.ArrayList<SimpleHotSpotMap.HotSpot> map
array of chart entities mappings to polygons or rectangles.

Constructor Detail

SimpleHotSpotMap

public SimpleHotSpotMap()
Method Detail

clearEntity

public void clearEntity(ChartEntity entity)
Removes the specified chart entity and all it's child entities from the hot spot map.

Specified by:
clearEntity in class HotSpotMap
Parameters:
entity - the entity to remove

clear

public void clear()
Removes all chart objects

Specified by:
clear in class HotSpotMap

mapEntity

protected void mapEntity(SimpleHotSpotMap.HotSpot spot)
Puts the specified HotSpot to the mappings array.

Parameters:
spot - the HotSpot

mapEntity

public void mapEntity(ChartEntity entity,
                      java.awt.Shape shape)
Maps the specified chart entity to the specified polygon.

Specified by:
mapEntity in class HotSpotMap
Parameters:
entity - the chart entity
shape - the shape

mapEntity

public void mapEntity(ChartEntity entity,
                      Rectangle2D rectangle)
Maps the specified chart entity to the specified rectangle.

Specified by:
mapEntity in class HotSpotMap
Parameters:
entity - the entity
rectangle - the rectangle

mapEntity

public void mapEntity(ChartEntity entity,
                      Point2D pt)
Maps the specified chart entity to the specified point.

Specified by:
mapEntity in class HotSpotMap
Parameters:
entity - the entity
pt - the point

getEntityPosition

public Point2D getEntityPosition(ChartEntity entity)
Returns a position of the specified chart entity.

Overrides:
getEntityPosition in class HotSpotMap
Parameters:
entity - the chart entity
Returns:
the entity position if it was mapped to point, null otherwise

findEntityAt

public ChartEntity findEntityAt(Point2D pt)
Finds a chart entity at the specified point. If no entity was found, returns null.

Overrides:
findEntityAt in class HotSpotMap
Parameters:
pt - the point
Returns:
an entity at the specified point if search was successful, null otherwise

findAllEntitiesAt

public java.util.List<ChartEntity> findAllEntitiesAt(Point2D pt)
Finds all mapped entities at the specified point.

Overrides:
findAllEntitiesAt in class HotSpotMap
Parameters:
pt - search point
Returns:
a list of entities found at the specified point. If noting found then empty list is returned;

findEntitiesIntersecting

public java.lang.Object[] findEntitiesIntersecting(java.awt.Rectangle r)
Finds a chart entities that intersect with the given area.

Parameters:
r - Rectangle where to look for chart entities.
Returns:
An array of entities.

getEntityShape

public java.awt.Shape getEntityShape(Point2D pt)
Description copied from class: HotSpotMap
Returns the entity shape according to the point.

Specified by:
getEntityShape in class HotSpotMap
Parameters:
pt - point of shape
Returns:
selected entity shape

findEntitiesInside

public java.lang.Object[] findEntitiesInside(java.awt.Rectangle r)
Finds a chart entities that are inside of the given area.

Parameters:
r - Rectangle where to look for chart entities.
Returns:
An array of entities.

getEntityShape

public java.awt.Shape getEntityShape(ChartEntity chartEntity)
Description copied from class: HotSpotMap
Returns the entity shape according to the entity.

Specified by:
getEntityShape in class HotSpotMap
Parameters:
chartEntity - entity
Returns:
selected entity shape

getObjectById

public ChartEntity getObjectById(int id)
Description copied from class: HotSpotMap
Finds a chart object with specified id. If no entity was found, returns null.

Specified by:
getObjectById in class HotSpotMap
Parameters:
id - id to search for
Returns:
an object with specified if the search was successful, null otherwise

mapEntity

public void mapEntity(ChartEntity entity,
                      java.awt.Shape shape,
                      int id)
Description copied from class: HotSpotMap
Maps the polygon to the entity. Entities may have several associated polygons.
Warning: The polygon is not copied internally. All changes made to the polygon after the method completes will affect the map.

Specified by:
mapEntity in class HotSpotMap
Parameters:
entity - entity to be mapped
shape - shape
id - id