org.geotools.map
Class DefaultMapContext

Object
  extended by DefaultMapContext
All Implemented Interfaces:
MapContext
Direct Known Subclasses:
GraphicEnhancedMapContext

public class DefaultMapContext
extends Object
implements MapContext

The default implementation of the MapContext interface

Author:
Andrea Aime
Module:

Field Summary
protected  String abstracts
          Holds value of property abstracts.
protected  String contactInformation
          Holds value of property contactInformation.
protected  String[] keywords
          Holds value of property keywords.
protected  MapLayerListener layerListener
           
protected  EventListenerList listenerList
          Utility field used by event firing mechanism.
static Logger LOGGER
          The logger for the map module.
protected  PropertyChangeSupport propertyChangeSupport
          Utility field used by bound properties.
protected  String title
          Holds value of property title.
 
Constructor Summary
DefaultMapContext()
          Deprecated.  
DefaultMapContext(CoordinateReferenceSystem crs)
          Creates a default empty map context
DefaultMapContext(MapLayer[] layers)
          Deprecated.  
DefaultMapContext(MapLayer[] layers, CoordinateReferenceSystem crs)
          Creates a map context with the provided layers and title
DefaultMapContext(MapLayer[] layers, String title, String contextAbstract, String contactInformation, String[] keywords)
          Deprecated.  
DefaultMapContext(MapLayer[] layers, String title, String contextAbstract, String contactInformation, String[] keywords, CoordinateReferenceSystem crs)
          Creates a map context
 
Method Summary
 void addLayer(AbstractGridCoverage2DReader reader, Style style)
          Add a new layer and trigger a LayerListEvent.
 void addLayer(CollectionSource source, Style style)
           
 void addLayer(Collection collection, Style style)
          Add a new layer and trigger a LayerListEvent.
 void addLayer(FeatureCollection<SimpleFeatureType,SimpleFeature> collection, Style style)
          Add a new layer and trigger a LayerListEvent.
 void addLayer(FeatureSource<SimpleFeatureType,SimpleFeature> featureSource, Style style)
          Add a new layer and trigger a LayerListEvent.
 void addLayer(GridCoverage gc, Style style)
          Add a new layer and trigger a LayerListEvent.
 boolean addLayer(int index, MapLayer layer)
          Add a new layer if not already present and trigger a LayerListEvent.
 boolean addLayer(MapLayer layer)
          Add a new layer and trigger a LayerListEvent.
 int addLayers(MapLayer[] layers)
          Add an array of new layers and trigger a LayerListEvent.
 void addMapBoundsListener(MapBoundsListener listener)
          Registers MapBoundsListener to receive events.
 void addMapLayerListListener(MapLayerListListener listener)
          Registers MapLayerListListener to receive events.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Registers PropertyChangeListener to receive events.
 void clearLayerList()
          DOCUMENT ME!
 String getAbstract()
          Getter for property abstracts.
 ReferencedEnvelope getAreaOfInterest()
          Gets the current area of interest.
 String getContactInformation()
          Getter for property contactInformation.
 CoordinateReferenceSystem getCoordinateReferenceSystem()
          Get the current coordinate system.
 String[] getKeywords()
          Getter for property keywords.
 MapLayer getLayer(int index)
          Return the requested layer.
 ReferencedEnvelope getLayerBounds()
          Get the bounding box of all the layers in this MapContext.
 int getLayerCount()
          Returns the number of layers in this map context
 MapLayer[] getLayers()
          Return this model's list of layers.
 String getTitle()
          Getter for property title.
 int indexOf(MapLayer layer)
          Returns the index of the first occurrence of the specified layer, or -1 if this list does not contain this element.
 Iterator iterator()
          Returns an iterator over the layers in this context in proper sequence.
 void moveLayer(int sourcePosition, int destPosition)
          DOCUMENT ME!
 MapLayer removeLayer(int index)
          DOCUMENT ME!
 boolean removeLayer(MapLayer layer)
          Remove a layer and trigger a LayerListEvent.
 void removeLayers(MapLayer[] layers)
          Remove an array of layers and trigger a LayerListEvent.
 void removeMapBoundsListener(MapBoundsListener listener)
          Removes MapBoundsListener from the list of listeners.
 void removeMapLayerListListener(MapLayerListListener listener)
          Removes MapLayerListListener from the list of listeners.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes PropertyChangeListener from the list of listeners.
 void setAbstract(String abstractValue)
          Setter for property abstracts.
 void setAreaOfInterest(Envelope areaOfInterest)
          Deprecated.  
 void setAreaOfInterest(Envelope areaOfInterest, CoordinateReferenceSystem coordinateReferenceSystem)
          Set a new area of interest and trigger a BoundingBoxEvent.
 void setAreaOfInterest(ReferencedEnvelope areaOfInterest)
          Set a new area of interest and trigger an BoundingBoxEvent.
 void setContactInformation(String contactInformation)
          Setter for property contactInformation.
 void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
          Set the CoordinateReferenceSystem for this map context.
 void setKeywords(String[] keywords)
          Setter for property keywords.
 void setTitle(String title)
          Setter for property title.
 void transform(AffineTransform transform)
          Transform the coordinates according to the provided transform.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

public static final Logger LOGGER
The logger for the map module.


listenerList

protected EventListenerList listenerList
Utility field used by event firing mechanism.


layerListener

protected MapLayerListener layerListener

abstracts

protected String abstracts
Holds value of property abstracts.


propertyChangeSupport

protected PropertyChangeSupport propertyChangeSupport
Utility field used by bound properties.


contactInformation

protected String contactInformation
Holds value of property contactInformation.


keywords

protected String[] keywords
Holds value of property keywords.


title

protected String title
Holds value of property title.

Constructor Detail

DefaultMapContext

public DefaultMapContext()
Deprecated. 

Creates a default empty map context


DefaultMapContext

public DefaultMapContext(CoordinateReferenceSystem crs)
Creates a default empty map context


DefaultMapContext

public DefaultMapContext(MapLayer[] layers)
Deprecated. 

Creates a map context with the provided layers and title

Parameters:
layers - DOCUMENT ME!

DefaultMapContext

public DefaultMapContext(MapLayer[] layers,
                         CoordinateReferenceSystem crs)
Creates a map context with the provided layers and title

Parameters:
layers - DOCUMENT ME!

DefaultMapContext

public DefaultMapContext(MapLayer[] layers,
                         String title,
                         String contextAbstract,
                         String contactInformation,
                         String[] keywords)
Deprecated. 

Creates a map context

Parameters:
layers - DOCUMENT ME!
title - DOCUMENT ME!
contextAbstract - DOCUMENT ME!
contactInformation - DOCUMENT ME!
keywords - DOCUMENT ME!

DefaultMapContext

public DefaultMapContext(MapLayer[] layers,
                         String title,
                         String contextAbstract,
                         String contactInformation,
                         String[] keywords,
                         CoordinateReferenceSystem crs)
Creates a map context

Parameters:
layers - DOCUMENT ME!
title - DOCUMENT ME!
contextAbstract - DOCUMENT ME!
contactInformation - DOCUMENT ME!
keywords - DOCUMENT ME!
Method Detail

addLayer

public boolean addLayer(int index,
                        MapLayer layer)
Add a new layer if not already present and trigger a LayerListEvent.

Specified by:
addLayer in interface MapContext
Parameters:
index - DOCUMENT ME!
layer - Then new layer that has been added.
Returns:
DOCUMENT ME!

addLayer

public boolean addLayer(MapLayer layer)
Add a new layer and trigger a LayerListEvent.

Specified by:
addLayer in interface MapContext
Parameters:
layer - Then new layer that has been added.
Returns:
DOCUMENT ME!

addLayer

public void addLayer(FeatureSource<SimpleFeatureType,SimpleFeature> featureSource,
                     Style style)
Add a new layer and trigger a LayerListEvent.

Specified by:
addLayer in interface MapContext
Parameters:
featureSource - Then new layer that has been added.
style - DOCUMENT ME!

addLayer

public void addLayer(CollectionSource source,
                     Style style)

addLayer

public void addLayer(GridCoverage gc,
                     Style style)
Add a new layer and trigger a LayerListEvent.

Specified by:
addLayer in interface MapContext
Parameters:
gc - Then new layer that has been added.
style - DOCUMENT ME!

addLayer

public void addLayer(AbstractGridCoverage2DReader reader,
                     Style style)
Add a new layer and trigger a LayerListEvent.

Specified by:
addLayer in interface MapContext
Parameters:
reader - a reader with the new layer to be added.
style - DOCUMENT ME!

addLayer

public void addLayer(FeatureCollection<SimpleFeatureType,SimpleFeature> collection,
                     Style style)
Add a new layer and trigger a LayerListEvent.

Specified by:
addLayer in interface MapContext
Parameters:
collection - Then new layer that has been added.
style - DOCUMENT ME!

addLayer

public void addLayer(Collection collection,
                     Style style)
Description copied from interface: MapContext
Add a new layer and trigger a LayerListEvent.

Specified by:
addLayer in interface MapContext
Parameters:
collection - Collection with the new layer that will be added.

removeLayer

public boolean removeLayer(MapLayer layer)
Remove a layer and trigger a LayerListEvent.

Specified by:
removeLayer in interface MapContext
Parameters:
layer - Then new layer that has been removed.
Returns:
DOCUMENT ME!

removeLayer

public MapLayer removeLayer(int index)
DOCUMENT ME!

Specified by:
removeLayer in interface MapContext
Parameters:
index - DOCUMENT ME!
Returns:
DOCUMENT ME!

addLayers

public int addLayers(MapLayer[] layers)
Add an array of new layers and trigger a LayerListEvent.

Specified by:
addLayers in interface MapContext
Parameters:
layers - The new layers that are to be added.
Returns:
DOCUMENT ME!

removeLayers

public void removeLayers(MapLayer[] layers)
Remove an array of layers and trigger a LayerListEvent.

Specified by:
removeLayers in interface MapContext
Parameters:
layers - The layers that are to be removed.

getLayers

public MapLayer[] getLayers()
Return this model's list of layers. If no layers are present, then an empty array is returned.

Specified by:
getLayers in interface MapContext
Returns:
This model's list of layers.

getLayer

public MapLayer getLayer(int index)
                  throws IndexOutOfBoundsException
Return the requested layer.

Specified by:
getLayer in interface MapContext
Parameters:
index - index of layer to return.
Returns:
the layer at the specified position
Throws:
IndexOutOfBoundsException - if the index is out of range

indexOf

public int indexOf(MapLayer layer)
Description copied from interface: MapContext
Returns the index of the first occurrence of the specified layer, or -1 if this list does not contain this element.

Specified by:
indexOf in interface MapContext
Parameters:
layer - the MapLayer to search for
Returns:
DOCUMENT ME!
See Also:
MapContext.indexOf(org.geotools.map.MapLayer)

iterator

public Iterator iterator()
Returns an iterator over the layers in this context in proper sequence.

Specified by:
iterator in interface MapContext
Returns:
an iterator over the layers in this context in proper sequence.

getLayerBounds

public ReferencedEnvelope getLayerBounds()
                                  throws IOException
Get the bounding box of all the layers in this MapContext. If all the layers cannot determine the bounding box in the speed required for each layer, then null is returned. The bounds will be expressed in the MapContext coordinate system.

Specified by:
getLayerBounds in interface MapContext
Returns:
The bounding box of the features or null if unknown and too expensive for the method to calculate. TODO: when coordinate system information will be added reproject the bounds according to the current coordinate system
Throws:
IOException - DOCUMENT ME!

setAreaOfInterest

public void setAreaOfInterest(Envelope areaOfInterest,
                              CoordinateReferenceSystem coordinateReferenceSystem)
                       throws IllegalArgumentException
Set a new area of interest and trigger a BoundingBoxEvent.

Specified by:
setAreaOfInterest in interface MapContext
Parameters:
areaOfInterest - The new areaOfInterest.
coordinateReferenceSystem - The coordinate system being using by this model.
Throws:
IllegalArgumentException - if an argument is null.

setAreaOfInterest

public void setAreaOfInterest(Envelope areaOfInterest)
Deprecated. 

Set a new area of interest and trigger an BoundingBoxEvent.

Specified by:
setAreaOfInterest in interface MapContext
Parameters:
areaOfInterest - The new area of interest.
Throws:
IllegalArgumentException - if an argument is null.

getAreaOfInterest

public ReferencedEnvelope getAreaOfInterest()
Gets the current area of interest. If no area of interest is the, the default is to fall back on the layer bounds

Specified by:
getAreaOfInterest in interface MapContext
Returns:
Current area of interest

getCoordinateReferenceSystem

public CoordinateReferenceSystem getCoordinateReferenceSystem()
Get the current coordinate system.

Specified by:
getCoordinateReferenceSystem in interface MapContext
Returns:
the coordinate system of this box.

transform

public void transform(AffineTransform transform)
Transform the coordinates according to the provided transform. Useful for zooming and panning processes.

Specified by:
transform in interface MapContext
Parameters:
transform - The transform to change area of interest.

moveLayer

public void moveLayer(int sourcePosition,
                      int destPosition)
DOCUMENT ME!

Specified by:
moveLayer in interface MapContext
Parameters:
sourcePosition - DOCUMENT ME!
destPosition - DOCUMENT ME!
Throws:
IndexOutOfBoundsException - DOCUMENT ME!

clearLayerList

public void clearLayerList()
DOCUMENT ME!

Specified by:
clearLayerList in interface MapContext

getLayerCount

public int getLayerCount()
Returns the number of layers in this map context

Specified by:
getLayerCount in interface MapContext
Returns:
the number of layers in this map context

getAbstract

public String getAbstract()
Getter for property abstracts.

Specified by:
getAbstract in interface MapContext
Returns:
Value of property abstracts.

setAbstract

public void setAbstract(String abstractValue)
Setter for property abstracts.

Specified by:
setAbstract in interface MapContext
Parameters:
abstractValue - New value of property abstracts.
Throws:
NullPointerException - DOCUMENT ME!

getContactInformation

public String getContactInformation()
Getter for property contactInformation.

Specified by:
getContactInformation in interface MapContext
Returns:
Value of property contactInformation.

setContactInformation

public void setContactInformation(String contactInformation)
Setter for property contactInformation.

Specified by:
setContactInformation in interface MapContext
Parameters:
contactInformation - New value of property contactInformation.
Throws:
NullPointerException - DOCUMENT ME!

getKeywords

public String[] getKeywords()
Getter for property keywords.

Specified by:
getKeywords in interface MapContext
Returns:
Value of property keywords.

setKeywords

public void setKeywords(String[] keywords)
Setter for property keywords.

Specified by:
setKeywords in interface MapContext
Parameters:
keywords - New value of property keywords.
Throws:
NullPointerException - DOCUMENT ME!

getTitle

public String getTitle()
Getter for property title.

Specified by:
getTitle in interface MapContext
Returns:
Value of property title.

setTitle

public void setTitle(String title)
Setter for property title.

Specified by:
setTitle in interface MapContext
Parameters:
title - New value of property title.
Throws:
NullPointerException - DOCUMENT ME!

addMapLayerListListener

public void addMapLayerListListener(MapLayerListListener listener)
Registers MapLayerListListener to receive events.

Specified by:
addMapLayerListListener in interface MapContext
Parameters:
listener - The listener to register.

removeMapLayerListListener

public void removeMapLayerListListener(MapLayerListListener listener)
Removes MapLayerListListener from the list of listeners.

Specified by:
removeMapLayerListListener in interface MapContext
Parameters:
listener - The listener to remove.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Registers PropertyChangeListener to receive events.

Specified by:
addPropertyChangeListener in interface MapContext
Parameters:
listener - The listener to register.

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes PropertyChangeListener from the list of listeners.

Specified by:
removePropertyChangeListener in interface MapContext
Parameters:
listener - The listener to remove.

addMapBoundsListener

public void addMapBoundsListener(MapBoundsListener listener)
Registers MapBoundsListener to receive events.

Specified by:
addMapBoundsListener in interface MapContext
Parameters:
listener - The listener to register.

removeMapBoundsListener

public void removeMapBoundsListener(MapBoundsListener listener)
Removes MapBoundsListener from the list of listeners.

Specified by:
removeMapBoundsListener in interface MapContext
Parameters:
listener - The listener to remove.

setAreaOfInterest

public void setAreaOfInterest(ReferencedEnvelope areaOfInterest)
Set a new area of interest and trigger an BoundingBoxEvent.

Specified by:
setAreaOfInterest in interface MapContext
Parameters:
areaOfInterest - The new area of interest.
Throws:
NullPointerException - DOCUMENT ME!

setCoordinateReferenceSystem

public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
                                  throws TransformException,
                                         FactoryException
Description copied from interface: MapContext
Set the CoordinateReferenceSystem for this map context.

Specified by:
setCoordinateReferenceSystem in interface MapContext
Throws:
FactoryException
TransformException


Copyright © 1996-2009 Geotools. All Rights Reserved.