org.geotools.renderer.geom
Class GeometryProxy

java.lang.Object
  extended byorg.geotools.renderer.geom.Geometry
      extended byorg.geotools.renderer.geom.GeometryProxy
All Implemented Interfaces:
java.lang.Cloneable, org.opengis.util.Cloneable, java.io.Serializable, java.awt.Shape

public final class GeometryProxy
extends Geometry

A geometry wrapping an existing geometry object with a different style. Every calls except get/setStyle are forwarded to the wrapped geometry. Consequently, changes in this geometry will impact on the wrapped geometry, and conversely.

Version:
$Id: GeometryProxy.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.geotools.renderer.geom.Geometry
DEFAULT_COORDINATE_SYSTEM
 
Constructor Summary
GeometryProxy(Geometry geometry)
          Construct a geographic shape wrapping the given geometry.
 
Method Summary
 Geometry clip(Clipper clipper)
          Returns an geometry approximately equal to this geometry clipped to the specified bounds.
 java.lang.Object clone()
          Return a clone of this geometry.
 float compress(CompressionLevel level)
          Compress the wrapped geometry.
 boolean contains(double x, double y)
          Tests if the specified coordinates are inside the boundary of this geometry.
 boolean contains(double x, double y, double width, double height)
          Test if the interior of this geometry entirely contains the given rectangle.
 boolean contains(java.awt.geom.Point2D point)
          Tests if a specified Point2D is inside the boundary of this geometry.
 boolean contains(java.awt.geom.Rectangle2D rectangle)
          Tests if the interior of this geometry entirely contains the given rectangle.
 boolean contains(java.awt.Shape shape)
          Test if the interior of this geometry entirely contains the given shape.
 boolean equals(java.lang.Object object)
          Compares the specified object with this geometry for equality.
 java.awt.Rectangle getBounds()
          Deprecated. This method is required by the Shape interface, but it doesn't provide enough precision for most cases. Use getBounds2D() instead.
 java.awt.geom.Rectangle2D getBounds2D()
          Returns the bounding box of this geometry.
 CoordinateSystem getCoordinateSystem()
          Returns the geometry's coordinate system, or null if unknow.
 java.lang.String getName(java.util.Locale locale)
          Returns the localized name for this geometry, or null if none.
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform transform)
          Returns an iterator object that iterates along the shape boundary and provides access to the geometry of the shape outline.
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform transform, double flatness)
          Returns a flattened path iterator for this geometry.
 int getPointCount()
          Return the number of points in this geometry.
 float getRenderingResolution()
          Returns the rendering resolution.
 Statistics getResolution()
          Returns the geometry's resolution.
 java.lang.Object getUserObject()
          Returns the user object attached to this geometry, which is the same than the user object for the wrapped geometry.
 int hashCode()
          Returns a hash value for this geometry.
 boolean intersects(double x, double y, double width, double height)
          Tests if the interior of the geometry intersects the interior of a specified rectangle.
 boolean intersects(java.awt.geom.Rectangle2D rectangle)
          Tests if the interior of the geometry intersects the interior of a specified rectangle.
 boolean intersects(java.awt.Shape shape)
          Tests if the interior of the geometry intersects the interior of a specified shape.
 boolean isEmpty()
          Determines whetever this geometry is empty.
 void setCoordinateSystem(CoordinateSystem coordinateSystem)
          Set the geometry's coordinate system.
 void setRenderingResolution(float resolution)
          Hints this geometry that the specified resolution is sufficient for rendering.
 void setResolution(double resolution)
          Set the geometry's resolution.
 void setUserObject(java.lang.Object userObject)
          Set the user object for for the wrapped geometry.
 
Methods inherited from class org.geotools.renderer.geom.Geometry
getID, getStyle, setID, setStyle, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeometryProxy

public GeometryProxy(Geometry geometry)
Construct a geographic shape wrapping the given geometry. The new geometry will initially shares the same style than the given geometry.

Parameters:
geometry - The geometry to wrap.
Method Detail

getName

public java.lang.String getName(java.util.Locale locale)
Returns the localized name for this geometry, or null if none. This method forwards the call to the wrapped geometry.

Overrides:
getName in class Geometry
Parameters:
locale - The desired locale. If no name is available for this locale, a default locale will be used.
Returns:
The geometry's name, localized if possible.

getCoordinateSystem

public CoordinateSystem getCoordinateSystem()
Returns the geometry's coordinate system, or null if unknow. This method forwards the call to the wrapped geometry.

Specified by:
getCoordinateSystem in class Geometry

setCoordinateSystem

public void setCoordinateSystem(CoordinateSystem coordinateSystem)
                         throws org.opengis.referencing.operation.TransformException
Set the geometry's coordinate system. It will changes the coordinate system of the wrapped geometry.

Specified by:
setCoordinateSystem in class Geometry
Parameters:
coordinateSystem - The new coordinate system. A null value reset the default coordinate system (usually the one that best fits internal data).
Throws:
org.opengis.referencing.operation.TransformException - If a transformation failed. In case of failure, the state of this object will stay unchanged, as if this method has never been invoked.

getUserObject

public java.lang.Object getUserObject()
Returns the user object attached to this geometry, which is the same than the user object for the wrapped geometry.

Overrides:
getUserObject in class Geometry

setUserObject

public void setUserObject(java.lang.Object userObject)
Set the user object for for the wrapped geometry. The user object for this proxy will always stay null (for avoiding memory leak), but the user should never realize that.

Overrides:
setUserObject in class Geometry

isEmpty

public boolean isEmpty()
Determines whetever this geometry is empty. This method forwards the call to the wrapped geometry.

Overrides:
isEmpty in class Geometry

getPointCount

public int getPointCount()
Return the number of points in this geometry. This method forwards the call to the wrapped geometry.

Specified by:
getPointCount in class Geometry

getBounds

public java.awt.Rectangle getBounds()
Deprecated. This method is required by the Shape interface, but it doesn't provide enough precision for most cases. Use getBounds2D() instead.

Returns the smallest bounding box containing getBounds2D(). This method forwards the call to the wrapped geometry.

Specified by:
getBounds in interface java.awt.Shape
Overrides:
getBounds in class Geometry

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Returns the bounding box of this geometry. This method forwards the call to the wrapped geometry.

Specified by:
getBounds2D in interface java.awt.Shape
Specified by:
getBounds2D in class Geometry
Returns:
The bounding box of this geometry.

contains

public boolean contains(double x,
                        double y)
Tests if the specified coordinates are inside the boundary of this geometry. This method forwards the call to the wrapped geometry.

Specified by:
contains in interface java.awt.Shape
Overrides:
contains in class Geometry
Parameters:
x - the specified x coordinates in this geometry coordinate system.
y - the specified y coordinates in this geometry coordinate system.
Returns:
true if the specified coordinates are inside the geometry boundary; false otherwise.

contains

public boolean contains(java.awt.geom.Point2D point)
Tests if a specified Point2D is inside the boundary of this geometry. This method forwards the call to the wrapped geometry.

Specified by:
contains in interface java.awt.Shape
Specified by:
contains in class Geometry
Parameters:
point - the specified point in this geometry coordinate system.
Returns:
true if the specified point is inside the geometry boundary; false otherwise.

contains

public boolean contains(double x,
                        double y,
                        double width,
                        double height)
Test if the interior of this geometry entirely contains the given rectangle. This method forwards the call to the wrapped geometry.

Specified by:
contains in interface java.awt.Shape
Overrides:
contains in class Geometry

contains

public boolean contains(java.awt.geom.Rectangle2D rectangle)
Tests if the interior of this geometry entirely contains the given rectangle. This method forwards the call to the wrapped geometry.

Specified by:
contains in interface java.awt.Shape
Overrides:
contains in class Geometry

contains

public boolean contains(java.awt.Shape shape)
Test if the interior of this geometry entirely contains the given shape. This method forwards the call to the wrapped geometry.

Specified by:
contains in class Geometry

intersects

public boolean intersects(double x,
                          double y,
                          double width,
                          double height)
Tests if the interior of the geometry intersects the interior of a specified rectangle. This method forwards the call to the wrapped geometry.

Specified by:
intersects in interface java.awt.Shape
Overrides:
intersects in class Geometry

intersects

public boolean intersects(java.awt.geom.Rectangle2D rectangle)
Tests if the interior of the geometry intersects the interior of a specified rectangle. This method forwards the call to the wrapped geometry.

Specified by:
intersects in interface java.awt.Shape
Overrides:
intersects in class Geometry

intersects

public boolean intersects(java.awt.Shape shape)
Tests if the interior of the geometry intersects the interior of a specified shape. This method forwards the call to the wrapped geometry.

Specified by:
intersects in class Geometry

clip

public Geometry clip(Clipper clipper)
Returns an geometry approximately equal to this geometry clipped to the specified bounds. This method clip the wrapped geometry, and wrap the result in a new GeometryProxy instance with the same style than the current one.

Overrides:
clip in class Geometry
Parameters:
clipper - The clipping area.
Returns:
null if this geometry doesn't intersect the clip, this if no clip has been performed, or a new clipped geometry otherwise.

compress

public float compress(CompressionLevel level)
               throws org.opengis.referencing.operation.TransformException
Compress the wrapped geometry.

Specified by:
compress in class Geometry
Parameters:
level - The compression level (or algorithm) to use.
Returns:
A estimation of the compression rate.
Throws:
org.opengis.referencing.operation.TransformException - If an error has come up during a cartographic projection.

getResolution

public Statistics getResolution()
Returns the geometry's resolution. This method forwards the call to the wrapped geometry.

Specified by:
getResolution in class Geometry
Returns:
Statistics about the resolution, or null if this geometry doesn't contains any point.

setResolution

public void setResolution(double resolution)
                   throws org.opengis.referencing.operation.TransformException
Set the geometry's resolution. It will changes the resolution of the wrapped geometry.

Specified by:
setResolution in class Geometry
Parameters:
resolution - Desired resolution, in the same linear units than getResolution().
Throws:
org.opengis.referencing.operation.TransformException - If some coordinate transformations were needed and failed. There is no guaranteed on geometry's state in case of failure.

getRenderingResolution

public float getRenderingResolution()
Returns the rendering resolution. This method forwards the call to the wrapped geometry.

Overrides:
getRenderingResolution in class Geometry
Returns:
The rendering resolution in units of this geometry's coordinate system (linear or angular units), or 0 if the finest available resolution should be used.

setRenderingResolution

public void setRenderingResolution(float resolution)
Hints this geometry that the specified resolution is sufficient for rendering. It will changes the rendering resolution of the wrapped geometry.

Overrides:
setRenderingResolution in class Geometry
Parameters:
resolution - The resolution to use at rendering time, in units of this geometry's coordinate system (linear or angular units).

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform transform)
Returns an iterator object that iterates along the shape boundary and provides access to the geometry of the shape outline. This method forwards the call to the wrapped geometry.

Specified by:
getPathIterator in interface java.awt.Shape
Specified by:
getPathIterator in class Geometry

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform transform,
                                                  double flatness)
Returns a flattened path iterator for this geometry. This method forwards the call to the wrapped geometry.

Specified by:
getPathIterator in interface java.awt.Shape
Overrides:
getPathIterator in class Geometry

clone

public final java.lang.Object clone()
Return a clone of this geometry. The returned geometry will have a deep copy semantic. This method is final for implementation reason.

Specified by:
clone in interface org.opengis.util.Cloneable
Overrides:
clone in class Geometry

equals

public boolean equals(java.lang.Object object)
Compares the specified object with this geometry for equality.

Overrides:
equals in class Geometry

hashCode

public int hashCode()
Returns a hash value for this geometry.

Overrides:
hashCode in class Geometry


Copyright © GeoTools. All Rights Reserved.