com.esri.adf.web.data.geometry
Class WebExtent

java.lang.Object
  extended by com.esri.adf.web.data.geometry.WebGeometry
      extended by com.esri.adf.web.data.geometry.WebExtent
All Implemented Interfaces:
Serializable

public class WebExtent
extends WebGeometry

WebExtent is a class used for representing rectangular extent of a map.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.esri.adf.web.data.geometry.WebGeometry
spatialReference
 
Constructor Summary
WebExtent()
          Creates an empty WebExtent.
WebExtent(double minX, double minY, double maxX, double maxY)
          Constructs a WebExtent instance.
WebExtent(double minX, double minY, double maxX, double maxY, WebSpatialReference spatialReference)
          Constructs a WebExtent instance.
WebExtent(WebExtent copy)
          Constructs a WebExtent that is a copy of a given WebExtent.
WebExtent(WebPoint lowerLeft, WebPoint upperRight)
          Constructs a WebExtent using it's lower left and upper right points.
 
Method Summary
 void centerAt(WebPoint mapPoint)
          Re-centers this WebExtent to the argument point, while maintaining original width & height of WebExtent.
 boolean contains(WebPoint mapPoint)
          Checks whether WebExtent contains the given point.
 boolean equals(Object obj)
           
 boolean equals(WebExtent compareTo, double toleranceRatio)
          Compares two WebExtents for equality.
 void expand(double factor)
          Expands this WebExtent by the factor.
 WebExtent fromMapGeometry(WebExtent extent, int width, int height)
           Converts a geometry in map coordinates to a geometry of the same type in screen coordinates.
 WebExtent fromMapGeometry(WebMap webMap)
           Converts a geometry in map coordinates to a geometry of the same type in screen coordinates.
 String getGeometryType()
           Returns a text representing the type of the geometry.
 double getHeight()
          Returns the height of WebExtent.
 double getMaxX()
          Returns the largest X coordinate of WebExtent.
 double getMaxY()
          Returns the largest Y coordinate of WebExtent.
 double getMinX()
          Returns the smallest X coordinate of WebExtent.
 double getMinY()
          Returns the smallest Y coordinate of WebExtent.
 double getWidth()
          Returns the width of WebExtent.
 int hashCode()
           
 WebExtent project(WebSpatialReference toSpatialReference)
           Converts the WebExtent in map coordinates from it's spatialReference to the desired spatial reference.
 void putCoords(double lMinX, double lMinY, double lMaxX, double lMaxY)
          Sets the coordinates for the lower left and the upper right corners of WebExtent.
 void setMaxX(double maxX)
          Sets the largest X coordinate of WebExtent.
 void setMaxY(double maxY)
          Sets the largest Y coordinate of WebExtent.
 void setMinX(double minX)
          Sets the smallest X coordinate of WebExtent.
 void setMinY(double minY)
          Sets the smallest Y coordinate of WebExtent.
 WebExtent toMapGeometry(WebExtent extent, int width, int height)
           Converts a geometry in screen coordinates to a geometry of the same type in map coordinates.
 WebExtent toMapGeometry(WebMap webMap)
           Converts a geometry in screen coordinates to a geometry of the same type in map coordinates.
 String toString()
           
 
Methods inherited from class com.esri.adf.web.data.geometry.WebGeometry
getSpatialReference, setSpatialReference
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WebExtent

public WebExtent(double minX,
                 double minY,
                 double maxX,
                 double maxY,
                 WebSpatialReference spatialReference)
Constructs a WebExtent instance.

Parameters:
minX - the X coordinate of the WebExtent lower-left corner
minY - the Y coordinate of the WebExtent lower-left corner
maxX - the maximum X coordinate of the WebExtent upper-right corner
maxY - the maximum Y coordinate of WebExtent upper-right corner
spatialReference - spatial reference of WebExtent

WebExtent

public WebExtent(double minX,
                 double minY,
                 double maxX,
                 double maxY)
Constructs a WebExtent instance.

Parameters:
minX - the X coordinate of the WebExtent lower-left corner
minY - the Y coordinate of the WebExtent lower-left corner
maxX - the maximum X coordinate of the WebExtent upper-right corner
maxY - the maximum Y coordinate of WebExtent upper-right corner

WebExtent

public WebExtent(WebExtent copy)
Constructs a WebExtent that is a copy of a given WebExtent.

Parameters:
copy - a WebExtent to be cloned.

WebExtent

public WebExtent(WebPoint lowerLeft,
                 WebPoint upperRight)
Constructs a WebExtent using it's lower left and upper right points.

Parameters:
lowerLeft - a point defining WebExtent's lower left corner
upperRight - a point defining WebExtent's uper right corner

WebExtent

public WebExtent()
Creates an empty WebExtent.

Method Detail

putCoords

public void putCoords(double lMinX,
                      double lMinY,
                      double lMaxX,
                      double lMaxY)
Sets the coordinates for the lower left and the upper right corners of WebExtent.

Parameters:
lMinX - lower left corner X coordinate
lMinY - lower left corner Y coordinate
lMaxX - upper right corner X coordinate
lMaxY - upper right corner Y coordinate

getMaxY

public double getMaxY()
Returns the largest Y coordinate of WebExtent.

Returns:
the largest Y coordinate of WebExtent

getMaxX

public double getMaxX()
Returns the largest X coordinate of WebExtent.

Returns:
the largest X coordinate of WebExtent

getMinY

public double getMinY()
Returns the smallest Y coordinate of WebExtent.

Returns:
the smallest Y coordinate of WebExtent

setMinX

public void setMinX(double minX)
Sets the smallest X coordinate of WebExtent.

Parameters:
minX - the smallest X coordinate of WebExtent

setMaxY

public void setMaxY(double maxY)
Sets the largest Y coordinate of WebExtent.

Parameters:
maxY - the largest Y coordinate of WebExtent

setMaxX

public void setMaxX(double maxX)
Sets the largest X coordinate of WebExtent.

Parameters:
maxX - the largest X coordinate of WebExtent

setMinY

public void setMinY(double minY)
Sets the smallest Y coordinate of WebExtent.

Parameters:
minY - the smallest Y coordinate of WebExtent

getMinX

public double getMinX()
Returns the smallest X coordinate of WebExtent.

Returns:
the smallest X coordinate of WebExtent

getWidth

public double getWidth()
Returns the width of WebExtent.

Returns:
the width of WebExtent

getHeight

public double getHeight()
Returns the height of WebExtent.

Returns:
the height of WebExtent.

equals

public boolean equals(WebExtent compareTo,
                      double toleranceRatio)
Compares two WebExtents for equality.

Parameters:
compareTo - a WebExtent to compare this one to
toleranceRatio - a tolerance ratio. If the difference between coordinates is less than tolerance ratio, coordinates are considered to be equal.
Returns:
true if the given WebExtent is equals to this one, false otherwise

contains

public boolean contains(WebPoint mapPoint)
Checks whether WebExtent contains the given point.

Parameters:
mapPoint - point to use in the check
Returns:
true if WebExtent contains the given point, false otherwise

expand

public void expand(double factor)
Expands this WebExtent by the factor. Factor must be greater than zero. WebExtent is enlarged horizontally and vertically by deltaw and deltah respectively, where deltaw = this.getWidth() * (1 - factor) / 2; deltah = this.getHeight() * (1 - factor) / 2;

Parameters:
factor - a value used to expand the WebExtent

centerAt

public void centerAt(WebPoint mapPoint)
Re-centers this WebExtent to the argument point, while maintaining original width & height of WebExtent.

Parameters:
mapPoint - new center point of extent

fromMapGeometry

public WebExtent fromMapGeometry(WebMap webMap)
Description copied from class: WebGeometry

Converts a geometry in map coordinates to a geometry of the same type in screen coordinates. Since the converted geometry is a screen geometry, the coordinate system of the converted geometry will be null.

Specified by:
fromMapGeometry in class WebGeometry
Parameters:
webMap - The WebMap based on which the coordinates need to be converted
Returns:
the WebGeometry in screen coordinates

fromMapGeometry

public WebExtent fromMapGeometry(WebExtent extent,
                                 int width,
                                 int height)
Description copied from class: WebGeometry

Converts a geometry in map coordinates to a geometry of the same type in screen coordinates. Since the converted geometry is a screen geometry, the coordinate system of the converted geometry will be null.

Overrides:
fromMapGeometry in class WebGeometry
Parameters:
extent - the WebExtent of the map image
width - the width of the map image
height - the height of the map image
Returns:
the WebGeometry in screen coordinates

toMapGeometry

public WebExtent toMapGeometry(WebMap webMap)
Description copied from class: WebGeometry

Converts a geometry in screen coordinates to a geometry of the same type in map coordinates. The coordinate system of the converted geometry is the same as the coordinate system of the WebMap.

Specified by:
toMapGeometry in class WebGeometry
Parameters:
webMap - The WebMap based on which the coordinates need to be converted
Returns:
the WebGeometry in map coordinates

toMapGeometry

public WebExtent toMapGeometry(WebExtent extent,
                               int width,
                               int height)
Description copied from class: WebGeometry

Converts a geometry in screen coordinates to a geometry of the same type in map coordinates. The coordinate system of the converted geometry is the same as the coordinate system of the specified extent.

Overrides:
toMapGeometry in class WebGeometry
Parameters:
extent - the WebExtent of the map image
width - the width of the map image
height - the height of the map image
Returns:
the WebGeometry in map coordinates

getGeometryType

public String getGeometryType()
Description copied from class: WebGeometry

Returns a text representing the type of the geometry. WebGeometry objects of the same type must return the same text.

Specified by:
getGeometryType in class WebGeometry
Returns:
a text representing the type of the geometry

toString

public String toString()
Overrides:
toString in class Object

project

public WebExtent project(WebSpatialReference toSpatialReference)

Converts the WebExtent in map coordinates from it's spatialReference to the desired spatial reference. If the desired spatial reference is same as the current one, this same object is returned. Otherwise, a new WebExtent object is created and populated with the converted coordinates. The coordinates are computed such that the extent falls within the horizon of the desired spatial reference.

Specified by:
project in class WebGeometry
Parameters:
toSpatialReference - the desired spatial reference of the projected geometry
Returns:
the projected WebExtent

hashCode

public int hashCode()
Overrides:
hashCode in class WebGeometry

equals

public boolean equals(Object obj)
Overrides:
equals in class WebGeometry