org.n52.oxf.context
Class ContextBoundingBox

java.lang.Object
  extended by org.n52.oxf.context.ContextBoundingBox
All Implemented Interfaces:
IContextSerializableXML, IEventEmitter

public class ContextBoundingBox
extends Object
implements IEventEmitter, IContextSerializableXML

Author:
Arne Broering

Field Summary
static int FIT_INTERMEDIATE
           
static int FIT_MAXIMUM
           
static int FIT_MINIMUM
          Angefragter Ausschnitt wird an die kleinere Ausdehung angepasst; das führt insbesondere beim initialen Request dazu, dass die angefragte BoundingBox immer innerhalb der Gesamt-BoundingBox eines Layers liegt.
 
Constructor Summary
ContextBoundingBox()
          Constructs a new empty ContextBoundingBox.
ContextBoundingBox(IBoundingBox bBox)
          Constructs a new ContextBoundingBox from a given org.n52.oxf.owsCommon.capabilities.BoundingBox.
ContextBoundingBox(Point2D lowerLeft, Point2D upperRight)
          Constructs a new ContextBoundingBox with the specified lowerLeft and upperRight Points.
ContextBoundingBox(String srs, Point2D lowerLeft, Point2D upperRight)
          ContextBoundingBox with corresponding SRS and Resolution in x resp. y.
 
Method Summary
 void addEventListener(IEventListener listener)
          Add an IEventListener to the OXFEventSupport.
 BoundingBox asCommonCapabilitiesBoundingBox()
           
 boolean contains(Rectangle2D rectangle)
           
 void fitBBox2Screen(int screenWidth, int screenHeight, boolean silently)
          Adjusts the aspect ratio of this BoundingBox to the aspect ratio of the screen.
 void fitBBox2Screen(int screenWidth, int screenHeight, int fitPolicy, boolean silently)
          Adjusts the aspect ratio of this BoundingBox to the aspect ratio of the screen.
 Rectangle2D getActualBBox()
           
 Point2D getLowerLeft()
           
 String getSRS()
           
 Point2D getUpperRight()
           
 void intersect(Rectangle2D rectangle)
           
 boolean isInside(Rectangle2D rectangle)
           
static Point realworld2Screen(Rectangle2D bBox, int screenWidth, int screenHeight, Point2D realWorldPoint)
          Transforms the realworld-coordinates of the specified realWorldPoint to screen-coordinates.
static Point[] realworld2Screen(Rectangle2D bBox, int screenWidth, int screenHeight, Point2D[] realWorldPoints)
           
 void removeEventListener(IEventListener listener)
          Remove an IEventListener from the OXFEventSupport.
static Point2D screen2Realworld(Rectangle2D bBox, int screenWidth, int screenHeight, Point screenPoint)
          Transforms the screen-coordinates of the specified screenPoint to realworld-coordinates.
 void serializeToContext(StringBuffer sb)
          serializes the implementing class (downwardly) compatible to the "Web Map Context Documents" Specification (OGC 05-005) of the OGC in version 1.1.0.
 void setBBox(IBoundingBox bBox, boolean silently)
          Sets the extent and the srs of this ContextBoundingBox.
 void setExtent(Point2D lowerLeft, Point2D upperRight, boolean silently)
          Sets the extent of this ContextBoundingBox.
 void setSRS(String srs)
          Sets the srs of this BoundingBox.
 String toString()
           
 void union(Rectangle2D rectangle)
           
 void zoom(Point2D newCenter, double factor)
          performs a down/up scaling of this ContextBoundingBox.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FIT_MINIMUM

public static final int FIT_MINIMUM
Angefragter Ausschnitt wird an die kleinere Ausdehung angepasst; das führt insbesondere beim initialen Request dazu, dass die angefragte BoundingBox immer innerhalb der Gesamt-BoundingBox eines Layers liegt.

See Also:
Constant Field Values

FIT_INTERMEDIATE

public static final int FIT_INTERMEDIATE
See Also:
Constant Field Values

FIT_MAXIMUM

public static final int FIT_MAXIMUM
See Also:
Constant Field Values
Constructor Detail

ContextBoundingBox

public ContextBoundingBox()
Constructs a new empty ContextBoundingBox. The values for lowerLeft and upperRight must be setted afterwards.


ContextBoundingBox

public ContextBoundingBox(Point2D lowerLeft,
                          Point2D upperRight)
Constructs a new ContextBoundingBox with the specified lowerLeft and upperRight Points.

Parameters:
lowerLeft - Point2D witch includes the x- and y-value of the lowerLeft corner.
upperRight - Point2D witch includes the x- and y-value of the upperRight corner.

ContextBoundingBox

public ContextBoundingBox(String srs,
                          Point2D lowerLeft,
                          Point2D upperRight)
ContextBoundingBox with corresponding SRS and Resolution in x resp. y.

Parameters:
srs - Spatial Reference System of the ContextBoundingBox
lowerLeft - Point2D witch includes the x- and y-value of the lowerLeft corner.
upperRight - Point2D witch includes the x- and y-value of the upperRight corner.

ContextBoundingBox

public ContextBoundingBox(IBoundingBox bBox)
Constructs a new ContextBoundingBox from a given org.n52.oxf.owsCommon.capabilities.BoundingBox.

Parameters:
bBox -
Method Detail

asCommonCapabilitiesBoundingBox

public BoundingBox asCommonCapabilitiesBoundingBox()
Returns:
this ContextBoundingBox as a org.n52.oxf.owsCommon.capabilities.BoundingBox.
Throws:
OXFException

setSRS

public void setSRS(String srs)
            throws OXFEventException
Sets the srs of this BoundingBox.
If the srs changes an SRS_CHANGED event will be fired.

Parameters:
srs -
Throws:
OXFException
OXFEventException

setBBox

public void setBBox(IBoundingBox bBox,
                    boolean silently)
             throws OXFEventException
Sets the extent and the srs of this ContextBoundingBox.
If 'silently' == true this method will NOT fire an EXTENT_CHANGED event but instead an EXTENT_CHANGED_SILENTLY event.

Throws:
OXFException
OXFEventException

setExtent

public void setExtent(Point2D lowerLeft,
                      Point2D upperRight,
                      boolean silently)
               throws OXFEventException
Sets the extent of this ContextBoundingBox.

If 'silently' == true this method will NOT fire an EXTENT_CHANGED event but instead an EXTENT_CHANGED_SILENTLY event.

Parameters:
lowerLeft - x- and y-value of the lowerleft corner.
upperRight - x- and y-value of the upperright corner.
Throws:
OXFException
OXFEventException

zoom

public void zoom(Point2D newCenter,
                 double factor)
          throws OXFEventException
performs a down/up scaling of this ContextBoundingBox.
Fires an EXTENT_CHANGED event.

Parameters:
newCenter - the new center of the ContextBoundingBox. If center is null, the actual center will be kept.
factor - if z > 1 performs an in-zooming with the factor z.
if z < 1 performs an out-zooming with the factor 1/z
Throws:
OXFException
OXFEventException

fitBBox2Screen

public void fitBBox2Screen(int screenWidth,
                           int screenHeight,
                           int fitPolicy,
                           boolean silently)
                    throws OXFEventException
Adjusts the aspect ratio of this BoundingBox to the aspect ratio of the screen.

If 'silently' == true this method will NOT fire an EXTENT_CHANGED event but instead an EXTENT_CHANGED_SILENTLY event.

Parameters:
screenWidth -
screenHeight -
fitPolicy - - possible values: FIT_MINIMUM (default), FIT_MAXIMUM, FIT_INTERMEDIATE
silently - - if true an EXTENT_CHANGED_SILENTLY event will be fired instead of an EXTENT_CHANGED event.
Throws:
OXFException
OXFEventException

fitBBox2Screen

public void fitBBox2Screen(int screenWidth,
                           int screenHeight,
                           boolean silently)
                    throws OXFEventException
Adjusts the aspect ratio of this BoundingBox to the aspect ratio of the screen.

If 'silently' == true this method will NOT fire an EXTENT_CHANGED event but instead an EXTENT_CHANGED_SILENTLY event.

Parameters:
screenWidth -
screenHeight -
silently - - if true an EXTENT_CHANGED_SILENTLY event will be fired instead of an EXTENT_CHANGED event.
Throws:
OXFException
OXFEventException

screen2Realworld

public static Point2D screen2Realworld(Rectangle2D bBox,
                                       int screenWidth,
                                       int screenHeight,
                                       Point screenPoint)
                                throws NoninvertibleTransformException
Transforms the screen-coordinates of the specified screenPoint to realworld-coordinates.

ATTENTION: The origin of the screen-coordinates is in the upper left corner.

Parameters:
bBox -
screenWidth -
screenHeight -
screenPoint - screen coordinates (origin = upper left corner) !!
Returns:
Throws:
NoninvertibleTransformException
See Also:
org.n52.oxf.context.ContextBoundingBoxTest#testScreen2Realworld()

realworld2Screen

public static Point realworld2Screen(Rectangle2D bBox,
                                     int screenWidth,
                                     int screenHeight,
                                     Point2D realWorldPoint)
Transforms the realworld-coordinates of the specified realWorldPoint to screen-coordinates.

ATTENTION!: the returned Point has got rounded integer coordinates!

ATTENTION: The origin of the returned screen-coordinates is in the upper left corner.

Parameters:
screenWidth -
screenHeight -
realWorldPoint -
Returns:
computed screen coordinates (origin = upper left corner) !!

realworld2Screen

public static Point[] realworld2Screen(Rectangle2D bBox,
                                       int screenWidth,
                                       int screenHeight,
                                       Point2D[] realWorldPoints)

union

public void union(Rectangle2D rectangle)

intersect

public void intersect(Rectangle2D rectangle)

contains

public boolean contains(Rectangle2D rectangle)

isInside

public boolean isInside(Rectangle2D rectangle)

getLowerLeft

public Point2D getLowerLeft()
Returns:
the lowerleft corner.

getUpperRight

public Point2D getUpperRight()
Returns:
the upperright corner.

getActualBBox

public Rectangle2D getActualBBox()
Returns:
a representation of the BoundingBox as a java.awt.geom.Rectangle2D

getSRS

public String getSRS()
Returns:
the Spatial Reference System of this ContextBoundingBox. E.g.: "EPSG:4326".

toString

public String toString()
Overrides:
toString in class Object
Returns:
a String-representation of this ContextBoundingBox. The format is: "minX,minY,maxX,maxY" - comma-separated;

addEventListener

public void addEventListener(IEventListener listener)
Add an IEventListener to the OXFEventSupport.

Specified by:
addEventListener in interface IEventEmitter

removeEventListener

public void removeEventListener(IEventListener listener)
Remove an IEventListener from the OXFEventSupport.

Specified by:
removeEventListener in interface IEventEmitter

serializeToContext

public void serializeToContext(StringBuffer sb)
Description copied from interface: IContextSerializableXML
serializes the implementing class (downwardly) compatible to the "Web Map Context Documents" Specification (OGC 05-005) of the OGC in version 1.1.0.

Specified by:
serializeToContext in interface IContextSerializableXML


Copyright © 2005 - 2010 52°North Initiative for Geospatial Open Source Software GmbH. All rights reserved.