net.refractions.udig.project.render
Interface IViewportModel
public interface IViewportModel
Models the Viewport on the map.
- Since:
- 0.5
- Author:
- Jesse
Field Summary |
static CoordinateReferenceSystem |
DEFAULT_CRS
A Default setting to use for the viewport CRS. |
Method Summary |
void |
addViewportModelListener(IViewportModelListener listener)
Adds a IViewportModelListener to this map. |
double |
getAspectRatio()
Returns the aspect ratio of the viewport. |
Envelope |
getBounds()
Returns the bounding box of the Viewport in world coordinates. |
Coordinate |
getCenter()
Returns the center of the viewport in world coordinates. |
CoordinateReferenceSystem |
getCRS()
Returns the local coordinate system. |
double |
getHeight()
Returns the Viewport's height in world coordinates. |
IMap |
getMap()
Gets the Map that contains the current ViewportModel |
Coordinate |
getPixelSize()
Returns the size of a pixel in world units. |
double |
getScaleDenominator()
Find the scale denominator of the map. |
double |
getWidth()
Returns the Viewport's width in world coordinates. |
Coordinate |
pixelToWorld(int x,
int y)
Converts a coordinate expressed on the device space back to real world coordinates |
void |
removeViewportModelListener(IViewportModelListener listener)
Removes a IViewportModelListener from this map. |
java.awt.Point |
worldToPixel(Coordinate coord)
Returns the pixel on the screen for a given coordinate in world space. |
java.awt.geom.AffineTransform |
worldToScreenTransform()
Gets up the affine transform that will transform from the world to screen. |
java.awt.geom.AffineTransform |
worldToScreenTransform(Envelope mapExtent,
java.awt.Dimension destination)
Gets up the affine transform that will transform from the world to the display of size
destination. |
DEFAULT_CRS
static final CoordinateReferenceSystem DEFAULT_CRS
- A Default setting to use for the viewport CRS.
getCRS
CoordinateReferenceSystem getCRS()
- Returns the local coordinate system. The local coordinate system is the CRS that all the
layer data will be transformed into. Once the layer data is transformed into the local CRS
then it is transformed for display onto the screen
- Returns:
- the local coordinate system
- See Also:
CoordinateReferenceSystem
getBounds
Envelope getBounds()
- Returns the bounding box of the Viewport in world coordinates.
Note: Since Envelope is not a UDIG element changes to the bounds envelope object will not
raise events. Therefore the bounds should only be modified via the ViewportModel interface
The bounds are in the same CRS as returned by getCRS()
- Returns:
- the bounding box of the Viewport in world coordinates.
- See Also:
Envelope
getCenter
Coordinate getCenter()
- Returns the center of the viewport in world coordinates. The bounds are in the same CRS as
returned by getCRS()
- Returns:
- the center of the viewport in world coordinates
- See Also:
Coordinate
getHeight
double getHeight()
- Returns the Viewport's height in world coordinates. The bounds are in the same CRS as
returned by getCRS()
- Returns:
- the Viewport's height in world coordinates.
getWidth
double getWidth()
- Returns the Viewport's width in world coordinates. The bounds are in the same CRS as returned
by getCRS()
- Returns:
- the Viewport's width in world coordinates.
getAspectRatio
double getAspectRatio()
- Returns the aspect ratio of the viewport. (width/height)
- Returns:
- The aspect ratio of the viewport.
getMap
IMap getMap()
- Gets the Map that contains the current ViewportModel
- Returns:
- the Map that contains the current ViewportModel
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
- See Also:
AffineTransform
worldToPixel
java.awt.Point worldToPixel(Coordinate coord)
- Returns the pixel on the screen for a given coordinate in world space.
- Parameters:
coord
- A coordinate in world space.
- Returns:
- The pixel on the screen that the world coordinate is drawn on.
- See Also:
Point
,
Coordinate
worldToScreenTransform
java.awt.geom.AffineTransform worldToScreenTransform(Envelope mapExtent,
java.awt.Dimension destination)
- Gets up the affine transform that will transform from the world to the display of size
destination. A convenience method. This method is independent of the CRS.
- Returns:
- a transform that maps from real world coordinates to the screen
pixelToWorld
Coordinate pixelToWorld(int x,
int y)
- Converts a coordinate expressed on the device space back to real world coordinates
- Parameters:
x
- horizontal coordinate on device spacey
- vertical coordinate on device space
- Returns:
- The correspondent real world coordinate
- See Also:
Coordinate
getPixelSize
Coordinate getPixelSize()
- Returns the size of a pixel in world units.
- Returns:
- the size of a pixel in world units.
- See Also:
Coordinate
getScaleDenominator
double getScaleDenominator()
- Find the scale denominator of the map.
Method:
1. find the diagonal distance (meters)
2. find the diagonal distance (pixels)
3. find the diagonal distance (meters) -- use DPI
4. calculate scale (#1/#2)
NOTE: return the scale denominator not the actual scale (1/scale = denominator)
TODO: (SLD spec page 28):
Since it is common to integrate the output of multiple servers into a single displayed result in the
web-mapping environment, it is important that different map servers have consistent behaviour with respect to
processing scales, so that all of the independent servers will select or deselect rules at the same scales.
To insure consistent behaviour, scales relative to coordinate spaces must be handled consistently between map
servers. For geographic coordinate systems, which use angular units, the angular coverage of a map should be
converted to linear units for computation of scale by using the circumference of the Earth at the equator and
by assuming perfectly square linear units. For linear coordinate systems, the size of the coordinate space
should be used directly without compensating for distortions in it with respect to the shape of the real Earth.
NOTE: we are actually doing a a much more exact calculation, and accounting for non-square pixels
- Returns:
- the scale denominator of the map on the current display. Return -1 if something is wrong. For example the display has not
yet been created.
addViewportModelListener
void addViewportModelListener(IViewportModelListener listener)
- Adds a IViewportModelListener to this map. A given listener will only be added once.
- Parameters:
listener
- Listener to be added- See Also:
net.refractions.udig.project.ViewportModelEvent.ViewportModelEventType
removeViewportModelListener
void removeViewportModelListener(IViewportModelListener listener)
- Removes a IViewportModelListener from this map.
- Parameters:
listener
- Listener to be removed