org.geotools.map
Class DefaultMapContext

java.lang.Object
  extended byorg.geotools.map.DefaultMapContext
All Implemented Interfaces:
MapContext

public class DefaultMapContext
extends java.lang.Object
implements MapContext

The default implementation of the interface

Author:
Andrea Aime

Field Summary
protected  java.lang.String abstracts
          Holds value of property abstracts.
protected  java.lang.String contactInformation
          Holds value of property contactInformation.
protected  java.lang.String[] keywords
          Holds value of property keywords.
protected  MapLayerListener layerListener
           
protected  javax.swing.event.EventListenerList listenerList
          Utility field used by event firing mechanism.
protected  java.beans.PropertyChangeSupport propertyChangeSupport
          Utility field used by bound properties.
protected  java.lang.String title
          Holds value of property title.
 
Constructor Summary
DefaultMapContext()
          Creates a default empty map context
DefaultMapContext(MapLayer[] layers)
          Creates a map context with the provided layers and title
DefaultMapContext(MapLayer[] layers, java.lang.String title, java.lang.String contextAbstract, java.lang.String contactInformation, java.lang.String[] keywords)
          Creates a map context
 
Method Summary
 void addLayer(FeatureCollection collection, Style style)
          Add a new layer and trigger a LayerListEvent.
 void addLayer(FeatureSource featureSource, Style style)
          Add a new layer and trigger a LayerListEvent.
 void addLayer(org.opengis.coverage.grid.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(java.beans.PropertyChangeListener listener)
          Registers PropertyChangeListener to receive events.
 void clearLayerList()
          DOCUMENT ME!
 java.lang.String getAbstract()
          Getter for property abstracts.
 com.vividsolutions.jts.geom.Envelope getAreaOfInterest()
          Gets the current area of interest.
 java.lang.String getContactInformation()
          Getter for property contactInformation.
 org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
          Get the current coordinate system.
 java.lang.String[] getKeywords()
          Getter for property keywords.
 MapLayer getLayer(int index)
          Return the requested layer.
 com.vividsolutions.jts.geom.Envelope 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.
 java.lang.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.
 java.util.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(java.beans.PropertyChangeListener listener)
          Removes PropertyChangeListener from the list of listeners.
 void setAbstract(java.lang.String abstractValue)
          Setter for property abstracts.
 void setAreaOfInterest(com.vividsolutions.jts.geom.Envelope areaOfInterest)
          Set a new area of interest and trigger an BoundingBoxEvent.
 void setAreaOfInterest(com.vividsolutions.jts.geom.Envelope areaOfInterest, org.opengis.referencing.crs.CoordinateReferenceSystem coordinateReferenceSystem)
          Set a new area of interest and trigger a BoundingBoxEvent.
 void setContactInformation(java.lang.String contactInformation)
          Setter for property contactInformation.
 void setKeywords(java.lang.String[] keywords)
          Setter for property keywords.
 void setTitle(java.lang.String title)
          Setter for property title.
 void transform(java.awt.geom.AffineTransform transform)
          Transform the coordinates according to the provided transform.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listenerList

protected javax.swing.event.EventListenerList listenerList
Utility field used by event firing mechanism.


layerListener

protected MapLayerListener layerListener

abstracts

protected java.lang.String abstracts
Holds value of property abstracts.


propertyChangeSupport

protected java.beans.PropertyChangeSupport propertyChangeSupport
Utility field used by bound properties.


contactInformation

protected java.lang.String contactInformation
Holds value of property contactInformation.


keywords

protected java.lang.String[] keywords
Holds value of property keywords.


title

protected java.lang.String title
Holds value of property title.

Constructor Detail

DefaultMapContext

public DefaultMapContext()
Creates a default empty map context


DefaultMapContext

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

Parameters:
layers - DOCUMENT ME!

DefaultMapContext

public DefaultMapContext(MapLayer[] layers,
                         java.lang.String title,
                         java.lang.String contextAbstract,
                         java.lang.String contactInformation,
                         java.lang.String[] keywords)
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 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(org.opengis.coverage.grid.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!
Returns:

addLayer

public void addLayer(FeatureCollection 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!

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 java.lang.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:
java.lang.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
Returns:
DOCUMENT ME!
See Also:
MapContext.indexOf(org.geotools.map.MapLayer)

iterator

public java.util.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 com.vividsolutions.jts.geom.Envelope getLayerBounds()
                                                    throws java.io.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:
java.io.IOException - DOCUMENT ME!

setAreaOfInterest

public void setAreaOfInterest(com.vividsolutions.jts.geom.Envelope areaOfInterest,
                              org.opengis.referencing.crs.CoordinateReferenceSystem coordinateReferenceSystem)
                       throws java.lang.IllegalArgumentException
Set a new area of interest and trigger a BoundingBoxEvent. Note that this is the only method to change coordinate system. A setCoordinateReferenceSystem method is not provided to ensure this class is not dependant on transform classes.

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

setAreaOfInterest

public void setAreaOfInterest(com.vividsolutions.jts.geom.Envelope 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:
java.lang.NullPointerException - DOCUMENT ME!

getAreaOfInterest

public com.vividsolutions.jts.geom.Envelope 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 org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
Get the current coordinate system.

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

transform

public void transform(java.awt.geom.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:
java.lang.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 java.lang.String getAbstract()
Getter for property abstracts.

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

setAbstract

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

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

getContactInformation

public java.lang.String getContactInformation()
Getter for property contactInformation.

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

setContactInformation

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

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

getKeywords

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

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

setKeywords

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

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

getTitle

public java.lang.String getTitle()
Getter for property title.

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

setTitle

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

Specified by:
setTitle in interface MapContext
Parameters:
title - New value of property title.
Throws:
java.lang.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(java.beans.PropertyChangeListener listener)
Registers PropertyChangeListener to receive events.

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

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.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.


Copyright © GeoTools. All Rights Reserved.