net.refractions.udig.project
Interface IAbstractContext

All Known Subinterfaces:
ICompositeRenderContext, IRenderContext

public interface IAbstractContext

Provides access to contextual information.

Toolkits are used by extensions to access Map and Project information. A Toolkit should never be instantiated by a developer. The framework provides Toolkits to extensions.

Responsibilities:

Since:
0.5
Author:
Jesse

Method Summary
 IAbstractContext copy()
          Makes a deep copy of this object, if necessary.
 ReferencedEnvelope getBoundingBox(java.awt.Point screenLocation, int scalefactor)
          Returns a world bounding box the scalefactor * (size of a pixel) at the location corresponding to the point on the screen.
 CoordinateReferenceSystem getCRS()
          CoordinateReferenceSystem of the map.
 IEditManager getEditManager()
          The map's edit manager.
 FeatureCollection getFeaturesInBbox(ILayer layer, Envelope bbox)
          Returns all the features that intersect with the bounding box.
 IMap getMap()
          The context's map.
 IMapDisplay getMapDisplay()
          The map's display object.
 java.util.List<ILayer> getMapLayers()
          Returns the list of layers in the current map.
 Envelope getPixelBoundingBox(java.awt.Point screenLocation)
          Returns a world bounding box the size of a pixel at the location corresponding to the point on the screen.
 Coordinate getPixelSize()
          Returns the size of a pixel in world units.
 IProject getProject()
          The map's containing Project.
 IRenderManager getRenderManager()
          The map's render manager
 ILayer getSelectedLayer()
          Returns the currently Selected Layer
 IViewportModel getViewportModel()
          The map's viewport model.
 Coordinate pixelToWorld(int x, int y)
          Converts a coordinate expressed on the device space back to real world coordinates A convenience method.
 java.awt.Shape toShape(Geometry geometry, CoordinateReferenceSystem crs)
          Transform the provided geometry to a java 2d shape (in screen coordiantes).
 java.awt.Shape toShape(ReferencedEnvelope envelope)
          Transform the provided envelope to a java 2d shape (in screen coordiantes).
 java.awt.Point tranformCoordinate(Envelope bbox, java.awt.Dimension displaySize, Coordinate coordinate)
          Transforms the coordinate from the bounding box (bbox) to the area defined by the rectangle it starts at 0,0.
 ReferencedEnvelope worldBounds(java.awt.Rectangle rectangle)
          Creates an Envelope that is close, error to slightly larger, to the Rectangle when it is transformed into world coordinates.
 java.awt.Point worldToPixel(Coordinate coord)
          Returns the pixel on the screen for a given coordinate in world space.
 MathTransform2D worldToScreenMathTransform()
          Creates a MathTransform that will transform from the screen CRS to the world CRS.
 java.awt.geom.AffineTransform worldToScreenTransform()
          Gets up the affine transform that will transform from the world to screen.
 

Method Detail

getViewportModel

IViewportModel getViewportModel()
The map's viewport model.

Convenience for getMap().getViewportModel().

Called to obtain current viewport bounds and crs.

Returns:
The Viewportmodel for the map.
See Also:
IViewportModel

getEditManager

IEditManager getEditManager()
The map's edit manager.

Convenience for getMap().getEditManager().

Called to obtain the currently editable feature.

Returns:
The map's edit manager.
See Also:
IEditManager

getRenderManager

IRenderManager getRenderManager()
The map's render manager

Convenience for getMap().getRenderManager().

Called to refresh the current display.

Returns:
The RenderManager for the map.
See Also:
IRenderManager

getMapDisplay

IMapDisplay getMapDisplay()
The map's display object.

Convenience for getMap().getRenderManager().getMapDisplay().

Called to obtain the height and width of the display.

Returns:
The IMapDisplay for the map.
See Also:
IMapDisplay

getMap

IMap getMap()
The context's map.

The Map data object.

Returns:
The context's map.
See Also:
IMap

getProject

IProject getProject()
The map's containing Project.

Convenience for getMap().getProject().

Contains all the IProjectElements in the project.

Returns:
The containing Project of the map.
See Also:
IProject

worldToScreenTransform

java.awt.geom.AffineTransform worldToScreenTransform()
Gets up the affine transform that will transform from the world to screen. A convenience method.

Returns:
a transform that maps from real world coordinates to the screen

worldToPixel

java.awt.Point worldToPixel(Coordinate coord)
Returns the pixel on the screen for a given coordinate in world space. A convenience method.

Parameters:
coord - A coordinate in world space.
Returns:
The pixel on the screen that the world coordinate is drawn on.

pixelToWorld

Coordinate pixelToWorld(int x,
                        int y)
Converts a coordinate expressed on the device space back to real world coordinates A convenience method.

Parameters:
x - horizontal coordinate on device space
y - vertical coordinate on device space
Returns:
The correspondent real world coordinate

worldBounds

ReferencedEnvelope worldBounds(java.awt.Rectangle rectangle)
Creates an Envelope that is close, error to slightly larger, to the Rectangle when it is transformed into world coordinates.

Parameters:
rectangle -
Returns:

worldToScreenMathTransform

MathTransform2D worldToScreenMathTransform()
Creates a MathTransform that will transform from the screen CRS to the world CRS.

Returns:

getPixelSize

Coordinate getPixelSize()
Returns the size of a pixel in world units. A convenience method.

Returns:
the size of a pixel in world units.

getPixelBoundingBox

Envelope getPixelBoundingBox(java.awt.Point screenLocation)
Returns a world bounding box the size of a pixel at the location corresponding to the point on the screen. A convenience method.

Returns:
the size of a pixel in world units.

getBoundingBox

ReferencedEnvelope getBoundingBox(java.awt.Point screenLocation,
                                  int scalefactor)
Returns a world bounding box the scalefactor * (size of a pixel) at the location corresponding to the point on the screen. A convenience method.

XXX: Can we make this a ReferencedEnvelope?

Returns:
the size of a pixel in world units.

getCRS

CoordinateReferenceSystem getCRS()
CoordinateReferenceSystem of the map.

Returns:
getViewportModel().getCRS();

toShape

java.awt.Shape toShape(ReferencedEnvelope envelope)
Transform the provided envelope to a java 2d shape (in screen coordiantes).

Parameters:
box -
Returns:

getSelectedLayer

ILayer getSelectedLayer()
Returns the currently Selected Layer

Returns:
the currently Selected Layer

toShape

java.awt.Shape toShape(Geometry geometry,
                       CoordinateReferenceSystem crs)
Transform the provided geometry to a java 2d shape (in screen coordiantes).

Parameters:
box -
Returns:

getFeaturesInBbox

FeatureCollection getFeaturesInBbox(ILayer layer,
                                    Envelope bbox)
                                    throws java.io.IOException
Returns all the features that intersect with the bounding box.

Parameters:
source - The featuresource to get features from.
bbox - The bounding box that acts as a filter. Must be in map coordinates.
Returns:
all the features that intersect with the bounding box.
Throws:
java.io.IOException

getMapLayers

java.util.List<ILayer> getMapLayers()
Returns the list of layers in the current map.

Returns:
The list of layers in the current map.

copy

IAbstractContext copy()
Makes a deep copy of this object, if necessary. This is an alternative to clone since I hate clone, it is too hard to implement.

Returns:
a new copy of this object.

tranformCoordinate

java.awt.Point tranformCoordinate(Envelope bbox,
                                  java.awt.Dimension displaySize,
                                  Coordinate coordinate)
Transforms the coordinate from the bounding box (bbox) to the area defined by the rectangle it starts at 0,0. A simple Affine transform is used and the y-axis is flipped since it is assumed the bbox is a world bbox and the Rectangle is a cartesian like on the screen.

Parameters:
bbox - The from area
displaySize - the to area
coordinate - the coordinate to transform.
Returns:
the point that the coordiante transforms to.