org.deegree_impl.graphics
Class MapView_Impl

java.lang.Object
  extended byorg.deegree_impl.graphics.MapView_Impl
All Implemented Interfaces:
MapView

class MapView_Impl
extends java.lang.Object
implements MapView

This interface describes the data modell of the map it self. It is build from themes containing DisplayElements to be rendered. Themes can be added and removed. Existing themes can be re-arragned by changing their order.

------------------------------------------------------------------------

Version:
$Revision: 1.25 $ $Date: 2004/02/27 07:48:09 $
Author:
Andreas Poth, Markus Schneider

Field Summary
private  Theme activatedTh
           
private  GM_Envelope boundingbox
           
private  CS_CoordinateSystem crs
           
private  java.util.HashMap enabled
           
private  java.util.List eventCntr
           
private  java.lang.String name
           
private  java.util.ArrayList optimizers
           
private  GeoTransform projection
           
private  double scale
           
private  java.util.HashMap themes
           
private  java.util.ArrayList themesL
           
 
Constructor Summary
(package private) MapView_Impl(java.lang.String name, GM_Envelope boundingbox)
           
(package private) MapView_Impl(java.lang.String name, GM_Envelope boundingbox, CS_CoordinateSystem crs)
           
 
Method Summary
 void activateTheme(Theme theme)
          activates a theme.
 void addEventController(MapEventController obj)
          adds an eventcontroller to the MapView that's reponsible for handling events that targets the map.
 void addHighlighter(Highlighter highlighter)
          A Highlighter is a class that is responsible for managing the highlight capabilities for one or more Themes.
 void addOptimizer(Optimizer optimizer)
          Adds an Optimizer.
 void addSelector(Selector obj)
          A selector is a class that offers methods for selecting and deselecting single DisplayElements or groups of DisplayElements.
 void addTheme(Theme theme)
          adds a theme to the MapView
private  double calcDistance(double lon1, double lat1, double lon2, double lat2)
          calculates the distance in meters between two points in EPSG:4326 coodinates .
private  double calcScale(int mapWidth, int mapHeight)
          calculates the map scale (denominator) as defined in the OGC SLD 1.0.0 specification
 void clear()
          removes all themes from the MapView.
 void enableTheme(Theme theme, boolean enable)
          enables or disables a theme that is part of the MapView.
 Theme[] getAllThemes()
          returns the Themes in correct order.
 GM_Envelope getBoundingBox()
          returns the BoundingBox (Envelope) of the MapView.
 CS_CoordinateSystem getCoordinatesSystem()
          returns the coordinate reference system of the MapView
 java.lang.String getName()
          returns the name of the map
 Optimizer[] getOptimizers()
          Returns the Optimizers.
 GeoTransform getProjection()
          Returns the GeoTransform that is associated to this MapView.
 double getScale()
          Returns the current scale of the MapView.
 double getScale(java.awt.Graphics g)
          Returns the current scale of the MapView.
 int getSize()
          returns the amount of themes within the MapView.
 Theme getTheme(int index)
          returns the Theme that matches the submitted index
 Theme getTheme(java.lang.String name)
          returns the Theme that matches the submitted name
 boolean isThemeActivated(Theme theme)
          returns true if the passed theme is the one that is set to be activated
 boolean isThemeEnabled(Theme theme)
          returns true if the passed theme is set to be enabled
 void moveDown(Theme theme)
          move a theme down for one index position (index = oldindex - 1)
 void moveUp(Theme theme)
          move a theme up for one index position (index = oldindex + 1)
private  void optimize(java.awt.Graphics g)
          Calls all registered Optimizer subsequently.
 void paint(java.awt.Graphics g)
          renders the map to the passed graphic context
 void paintHighlighted(java.awt.Graphics g)
          renders the features marked as highlighted of all themes contained within the MapView
 void paintSelected(java.awt.Graphics g)
          renders the features marked as selected of all themes contained within the MapView
 void removeEventController(MapEventController obj)
           
 void removeHighlighter(Highlighter highlighter)
           
 void removeSelector(Selector obj)
           
 void removeTheme(int index)
          removes the theme that matches the submitted index from the MapView
 void removeTheme(java.lang.String name)
          removes the theme that matches the submitted name from the MapView
 void removeTheme(Theme theme)
          removes a theme from the MapView
 void setBoundingBox(GM_Envelope boundingbox)
           
 void setCoordinateSystem(CS_CoordinateSystem crs)
          sets the coordinate reference system of the map;
 void setOptimizers(Optimizer[] optimizers)
          Sets the Optimizers.
 void swapThemes(Theme first, Theme second)
          swaps the positions of the submitted themes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private java.lang.String name

themes

private java.util.HashMap themes

enabled

private java.util.HashMap enabled

themesL

private java.util.ArrayList themesL

activatedTh

private Theme activatedTh

boundingbox

private GM_Envelope boundingbox

crs

private CS_CoordinateSystem crs

eventCntr

private java.util.List eventCntr

scale

private double scale

projection

private GeoTransform projection

optimizers

private java.util.ArrayList optimizers
Constructor Detail

MapView_Impl

MapView_Impl(java.lang.String name,
             GM_Envelope boundingbox)

MapView_Impl

MapView_Impl(java.lang.String name,
             GM_Envelope boundingbox,
             CS_CoordinateSystem crs)
Method Detail

getName

public java.lang.String getName()
returns the name of the map

Specified by:
getName in interface MapView

getTheme

public Theme getTheme(java.lang.String name)
returns the Theme that matches the submitted name

Specified by:
getTheme in interface MapView

getTheme

public Theme getTheme(int index)
returns the Theme that matches the submitted index

Specified by:
getTheme in interface MapView

getAllThemes

public Theme[] getAllThemes()
returns the Themes in correct order. The first Theme (index == 0) shall be rendered at first (bottom most).

Specified by:
getAllThemes in interface MapView

getScale

public double getScale()
Returns the current scale of the MapView.

Specified by:
getScale in interface MapView

getScale

public double getScale(java.awt.Graphics g)
Returns the current scale of the MapView.

Specified by:
getScale in interface MapView

addTheme

public void addTheme(Theme theme)
              throws java.lang.Exception
adds a theme to the MapView

Specified by:
addTheme in interface MapView
Throws:
java.lang.Exception

removeTheme

public void removeTheme(Theme theme)
removes a theme from the MapView

Specified by:
removeTheme in interface MapView

removeTheme

public void removeTheme(java.lang.String name)
removes the theme that matches the submitted name from the MapView

Specified by:
removeTheme in interface MapView

removeTheme

public void removeTheme(int index)
removes the theme that matches the submitted index from the MapView

Specified by:
removeTheme in interface MapView

clear

public void clear()
removes all themes from the MapView.

Specified by:
clear in interface MapView

swapThemes

public void swapThemes(Theme first,
                       Theme second)
swaps the positions of the submitted themes

Specified by:
swapThemes in interface MapView

moveUp

public void moveUp(Theme theme)
move a theme up for one index position (index = oldindex + 1)

Specified by:
moveUp in interface MapView

moveDown

public void moveDown(Theme theme)
move a theme down for one index position (index = oldindex - 1)

Specified by:
moveDown in interface MapView

enableTheme

public void enableTheme(Theme theme,
                        boolean enable)
enables or disables a theme that is part of the MapView. A theme that has been disabled won't be rendered and usually doesn't react to events targeted to the MapView, but still is part of the MapView.

Specified by:
enableTheme in interface MapView

isThemeEnabled

public boolean isThemeEnabled(Theme theme)
returns true if the passed theme is set to be enabled

Specified by:
isThemeEnabled in interface MapView

activateTheme

public void activateTheme(Theme theme)
activates a theme. Usually the activated theme is perferred to react to events (this doesn't mean that other themes are not allowed to react to events).

Specified by:
activateTheme in interface MapView

isThemeActivated

public boolean isThemeActivated(Theme theme)
returns true if the passed theme is the one that is set to be activated

Specified by:
isThemeActivated in interface MapView

getSize

public int getSize()
returns the amount of themes within the MapView.

Specified by:
getSize in interface MapView

addEventController

public void addEventController(MapEventController obj)
adds an eventcontroller to the MapView that's reponsible for handling events that targets the map. E.g.: zooming, panning, selecting a feature etc.

Specified by:
addEventController in interface MapView

removeEventController

public void removeEventController(MapEventController obj)
Specified by:
removeEventController in interface MapView
See Also:
addEventController(MapEventController)

addSelector

public void addSelector(Selector obj)
A selector is a class that offers methods for selecting and deselecting single DisplayElements or groups of DisplayElements. A selector may offers methods like 'select all DisplayElements within a specified bounding box' or 'select all DisplayElements thats area is larger than 120 kmē' etc.

Specified by:
addSelector in interface MapView

removeSelector

public void removeSelector(Selector obj)
Specified by:
removeSelector in interface MapView
See Also:
addSelector(Selector)

getBoundingBox

public GM_Envelope getBoundingBox()
returns the BoundingBox (Envelope) of the MapView. This isn't nessecary the BoundingBox of the data that will be rendered. It's the boundingBox of the the visible area of the map measured in its coordinate reference system.

Specified by:
getBoundingBox in interface MapView

setBoundingBox

public void setBoundingBox(GM_Envelope boundingbox)
Specified by:
setBoundingBox in interface MapView
See Also:
this method may be used for zooming and panning the map

getCoordinatesSystem

public CS_CoordinateSystem getCoordinatesSystem()
returns the coordinate reference system of the MapView

Specified by:
getCoordinatesSystem in interface MapView

setCoordinateSystem

public void setCoordinateSystem(CS_CoordinateSystem crs)
                         throws java.lang.Exception
sets the coordinate reference system of the map;

Specified by:
setCoordinateSystem in interface MapView
Throws:
java.lang.Exception

paint

public void paint(java.awt.Graphics g)
           throws RenderException
renders the map to the passed graphic context

Specified by:
paint in interface MapView
Parameters:
g -
Throws:
RenderException - thrown if the passed Graphic haven't clipbounds. use g.setClip( .. );

paintSelected

public void paintSelected(java.awt.Graphics g)
                   throws RenderException
renders the features marked as selected of all themes contained within the MapView

Specified by:
paintSelected in interface MapView
Parameters:
g - graphic context to render the map too
Throws:
RenderException - thrown if the passed Graphic haven't clipbounds. use g.setClip( .. );

paintHighlighted

public void paintHighlighted(java.awt.Graphics g)
                      throws RenderException
renders the features marked as highlighted of all themes contained within the MapView

Specified by:
paintHighlighted in interface MapView
Parameters:
g - graphic context to render the map too
Throws:
RenderException - thrown if the passed Graphic haven't clipbounds. use g.setClip( .. );

addHighlighter

public void addHighlighter(Highlighter highlighter)
A Highlighter is a class that is responsible for managing the highlight capabilities for one or more Themes.

Specified by:
addHighlighter in interface MapView

removeHighlighter

public void removeHighlighter(Highlighter highlighter)
Specified by:
removeHighlighter in interface MapView
See Also:
addHighlighter(Highlighter)

calcScale

private double calcScale(int mapWidth,
                         int mapHeight)
calculates the map scale (denominator) as defined in the OGC SLD 1.0.0 specification

Returns:
scale of the map

calcDistance

private double calcDistance(double lon1,
                            double lat1,
                            double lon2,
                            double lat2)
calculates the distance in meters between two points in EPSG:4326 coodinates .


getProjection

public GeoTransform getProjection()
Returns the GeoTransform that is associated to this MapView.

Specified by:
getProjection in interface MapView
Returns:
the associated GeoTransform-instance

optimize

private void optimize(java.awt.Graphics g)
Calls all registered Optimizer subsequently.

Parameters:
g -

addOptimizer

public void addOptimizer(Optimizer optimizer)
Adds an Optimizer.

Specified by:
addOptimizer in interface MapView
Parameters:
optimizer -

getOptimizers

public Optimizer[] getOptimizers()
Returns the Optimizers.

Specified by:
getOptimizers in interface MapView
Returns:

setOptimizers

public void setOptimizers(Optimizer[] optimizers)
Sets the Optimizers.

Specified by:
setOptimizers in interface MapView
Parameters:
optimizers -