es.prodevelop.gvsig.mobile.fmap
Class MapContext

java.lang.Object
  extended byes.prodevelop.gvsig.mobile.fmap.MapContext

public class MapContext
extends java.lang.Object

This class keeps and manages geographic data (basically the viewport and the array of layers). Therefore deals with zooms, extents, selection, etc, and gives access to the management of teh viewport and the layer drawing.

Author:
jldominguez
See Also:
ViewPort, FLayer

Field Summary
static double ASSUMED_DPI
           
static double[] CHANGE
           
static double[] CHANGEM
           
static int CONTAINS
           
static int CROSSES
           
static int DISJOINT
           
static int EQUALS
           
static int INTERSECTS
           
static int OVERLAPS
           
static int TOUCHES
           
static int WITHIN
           
static double ZOOMINFACTOR
           
static double ZOOMOUTFACTOR
           
 
Constructor Summary
MapContext(ViewPort vp)
           
 
Method Summary
 void addLayer(FLayer lyr, boolean repaint)
          Add a layer to this mapcontext object
 void addViewPortLisneter(ViewPortListener l)
          Adds a listener to the viewport
 boolean clearSelection()
          Clears selection in all layers
 void closeDataSources()
          Closes the datasources of the layers.
 void draw(java.awt.Graphics2D g, Cancellable cancel)
          Draws visible layers in the provided Graphics object.
 java.awt.geom.Rectangle2D getAllLayersExtent()
          Gets the extent of all the layers
 java.awt.geom.Rectangle2D getFullExtent()
          Computes the full extent adding the extents of the current layers.
 FLayer[] getInfoableLayers(boolean only_vect)
          Gets the layers that the user has selected to be queried for info
 FLayer getLayer(int index)
          Gets i-th layer
 int getLayerCount()
          Gets the number of layers
 java.util.ArrayList getLayers()
           
 IProjection getProjection()
           
 java.awt.geom.Rectangle2D getSelectedLayerExtent()
          Gets the extent of the selected layers
 FLayer[] getSelectedLayers(boolean only_vect)
          Gets the currently selected layers
 ViewPort getViewPort()
          Gets the viewport
 long getViewScale()
          Get current view scale.
 void removeLayer(FLayer lyr)
          Removes one layer from this mapcontext
 void removeViewPortLisneter(ViewPortListener l)
          Removes a listener from the viewport
 void setProjection(IProjection proj)
          Sets a new projection.
 void setViewPort(ViewPort v)
          Sets the viewport
 void setViewPortImageSize(java.awt.Dimension size)
          Set viewport image size
 void swapFromBottom(int _a, int _b)
          Changes the order of the layers in those indices.
 java.lang.StringBuffer toXML(java.lang.String name, java.lang.String projPath)
          Gets the complete XML description of this mapcontext.
 void zoomToSelection()
          Zooms to current selection (in all layers)
 void zoomToSelection(FLyrVect lyr)
          Zooms to current selection in one layer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHANGEM

public static final double[] CHANGEM

CHANGE

public static final double[] CHANGE

EQUALS

public static final int EQUALS
See Also:
Constant Field Values

DISJOINT

public static final int DISJOINT
See Also:
Constant Field Values

INTERSECTS

public static final int INTERSECTS
See Also:
Constant Field Values

TOUCHES

public static final int TOUCHES
See Also:
Constant Field Values

CROSSES

public static final int CROSSES
See Also:
Constant Field Values

WITHIN

public static final int WITHIN
See Also:
Constant Field Values

CONTAINS

public static final int CONTAINS
See Also:
Constant Field Values

OVERLAPS

public static final int OVERLAPS
See Also:
Constant Field Values

ZOOMINFACTOR

public static double ZOOMINFACTOR

ZOOMOUTFACTOR

public static double ZOOMOUTFACTOR

ASSUMED_DPI

public static double ASSUMED_DPI
Constructor Detail

MapContext

public MapContext(ViewPort vp)
Method Detail

getLayers

public java.util.ArrayList getLayers()
Returns:
All layers in the current view

getLayer

public FLayer getLayer(int index)
Gets i-th layer

Parameters:
index -
Returns:
the i-th layer

getViewScale

public long getViewScale()
Get current view scale.

Returns:
Returns d when current scale is 1:d (assumes dpi = ASSUMED_DPI)

getProjection

public IProjection getProjection()
Returns:
Get current projection

setProjection

public void setProjection(IProjection proj)
Sets a new projection.

Parameters:
proj - the new projection

draw

public void draw(java.awt.Graphics2D g,
                 Cancellable cancel)
Draws visible layers in the provided Graphics object.

Parameters:
g - the object where layers will be drawn.
cancel - cancel object (follow this parameter to see if it is used.

getViewPort

public ViewPort getViewPort()
Gets the viewport

Returns:
the viewport

setViewPort

public void setViewPort(ViewPort v)
Sets the viewport

Parameters:
v - the new viewport

getFullExtent

public java.awt.geom.Rectangle2D getFullExtent()
                                        throws FMapDriverException
Computes the full extent adding the extents of the current layers.

Returns:
The current full extent
Throws:
FMapDriverException

removeLayer

public void removeLayer(FLayer lyr)
Removes one layer from this mapcontext

Parameters:
lyr - the layer to be removed

addLayer

public void addLayer(FLayer lyr,
                     boolean repaint)
Add a layer to this mapcontext object

Parameters:
lyr - the layer to be added
repaint - whether or not the view has to be repainted

swapFromBottom

public void swapFromBottom(int _a,
                           int _b)
Changes the order of the layers in those indices.

Parameters:
_a - one of the indices
_b - the other index

closeDataSources

public void closeDataSources()
Closes the datasources of the layers. This is called when the application is closed.


setViewPortImageSize

public void setViewPortImageSize(java.awt.Dimension size)
Set viewport image size

Parameters:
size - the new image size of the viewport

addViewPortLisneter

public void addViewPortLisneter(ViewPortListener l)
Adds a listener to the viewport

Parameters:
l - listener to be added

removeViewPortLisneter

public void removeViewPortLisneter(ViewPortListener l)
Removes a listener from the viewport

Parameters:
l - listener to be removed

getLayerCount

public int getLayerCount()
Gets the number of layers

Returns:
layer count

getSelectedLayers

public FLayer[] getSelectedLayers(boolean only_vect)
Gets the currently selected layers

Parameters:
only_vect - whether or not only vector layers have to be included
Returns:
array of layers currently selected (so far, only one layer can be selected)

getSelectedLayerExtent

public java.awt.geom.Rectangle2D getSelectedLayerExtent()
Gets the extent of the selected layers

Returns:
the extent of the selected layers

getAllLayersExtent

public java.awt.geom.Rectangle2D getAllLayersExtent()
Gets the extent of all the layers

Returns:
the extent of all the layers

zoomToSelection

public void zoomToSelection()
Zooms to current selection (in all layers)


zoomToSelection

public void zoomToSelection(FLyrVect lyr)
Zooms to current selection in one layer

Parameters:
lyr - the layer of interest

getInfoableLayers

public FLayer[] getInfoableLayers(boolean only_vect)
Gets the layers that the user has selected to be queried for info

Parameters:
only_vect - whether or not only vector layers have to be included
Returns:
the layers that the user has selected to be queried for info

toXML

public java.lang.StringBuffer toXML(java.lang.String name,
                                    java.lang.String projPath)
Gets the complete XML description of this mapcontext. It will include the XML description of the viewport and all the layers

Parameters:
name - the name of the mapcontext XML element.
projPath - the project path
Returns:
the complete XML description of this mapcontext

clearSelection

public boolean clearSelection()
Clears selection in all layers

Returns:
return true if at least one feature was selected. It used to decide whether or not the view has to be repainted