org.gvsig.fmap.geom.primitive.impl
Class AbstractPrimitive

java.lang.Object
  extended by org.gvsig.fmap.geom.primitive.impl.AbstractPrimitive
All Implemented Interfaces:
Shape, Serializable, Comparable, Geometry, FShape, Primitive
Direct Known Subclasses:
BaseMultiPrimitive, DefaultNullGeometry, OrientablePrimitive2D, Point2D, Solid2DZ

public abstract class AbstractPrimitive
extends Object
implements Primitive, FShape, Shape, Serializable

Author:
Jorge Piera LlodrĂ¡ (jorge.piera@iver.es)
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.gvsig.fmap.geom.Geometry
Geometry.DIMENSIONS, Geometry.OPERATIONS, Geometry.SUBTYPES, Geometry.TYPES
 
Field Summary
protected  GeometryType geometryType
           
protected static GeometryManager geomManager
           
protected  String id
           
protected  org.cresques.cts.IProjection projection
           
 
Fields inherited from interface org.gvsig.fmap.geom.Geometry
BEST, E, EXTENDED_GEOMSUBTYPE_OFFSET, EXTENDED_GEOMTYPE_OFFSET, N, NE, NW, S, SE, SELECTHANDLER, STRETCHINGHANDLER, SW, W
 
Constructor Summary
AbstractPrimitive(GeometryType geometryType)
          The constructor with the GeometryType like and argument is used by the GeometryType#create() to create the geometry
AbstractPrimitive(GeometryType geometryType, org.cresques.cts.IProjection projection)
           
AbstractPrimitive(GeometryType geometryType, String id, org.cresques.cts.IProjection projection)
           
 
Method Summary
 double area()
           
 Geometry buffer(double distance)
          Computes a buffer area around this geometry having the given width This is a utility method to wrap the invocation to the operation Geometry.OPERATIONS.BUFFER.
 Point centroid()
           
 Geometry cloneGeometry()
          Creates a clone of this geometry.
 int compareTo(Object arg0)
           
 boolean contains(Geometry geometry)
          Tests whether this geometry contains the specified geometry.
protected  boolean containsPoint(Geometry geom, double x, double y)
          Utility method
protected  boolean containsRectangle(Geometry geom, double x, double y, double w, double h)
           
 byte[] convertToWKB()
          Return a byte array with the equivalent in WKB format of the Geometry.
 String convertToWKT()
          Return a string with the equivalent in WKT format of the Geometry.
 Geometry convexHull()
           
 boolean coveredBy(Geometry geometry)
           
 boolean crosses(Geometry geometry)
           
 Geometry difference(Geometry other)
           
 boolean disjoint(Geometry geometry)
           
 double distance(Geometry geometry)
          Returns the minimum distance between this Geometry and the specified geometry.
 boolean equals(Object obj)
           
 boolean fastIntersects(double x, double y, double w, double h)
          Used by the drawing strategies to quickly test whether this geometry intersects with the visible rectangle.
 GeometryType getGeometryType()
          Instance of the GeometryType associated to this geometry.
 Handler[] getHandlers(int type)
          It returns the handlers of the geometry, these they can be of two types is straightening and of selection.
 String getId()
           
 Shape getInternalShape()
          Deprecated. this Geometry is a Shape.
 Shape getShape()
           
 Shape getShape(AffineTransform affineTransform)
           
 int getShapeType()
          Gets the geometry type of this shape.
 org.cresques.cts.IProjection getSRS()
           
 int getType()
          If this geometry is a predefined interface then this method returns one of Geometry.TYPES contants.
 Geometry intersection(Geometry other)
           
 boolean intersects(Geometry geometry)
           
protected  boolean intersectsRectangle(Geometry geom, double x, double y, double w, double h)
           
 Object invokeOperation(int index, GeometryOperationContext ctx)
          Invokes a geometry operation given its index and context.
 Object invokeOperation(String oppName, GeometryOperationContext ctx)
          Invokes a geometry operation given its name and context.
 boolean isSimple()
          Returns true if this Geometry has no interior point of self-intersection or self-tangency.
static void moveGeom(Geometry geometry, double dx, double dy)
           
 boolean overlaps(Geometry geometry)
          Tests whether this geometry overlaps the specified geometry.
 double perimeter()
           
static void rotateGeom(Geometry geometry, double radAngle, double basex, double basey)
           
static void scaleGeom(Geometry geometry, Point2D basePoint, double sx, double sy)
           
 String toString()
           
 boolean touches(Geometry geometry)
           
 AbstractPrimitive transform(org.cresques.cts.IProjection newProjection)
           
 Geometry union(Geometry other)
           
 boolean within(Geometry geometry)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.gvsig.fmap.geom.Geometry
getBounds2D, getDimension, getEnvelope, getGeneralPath, getPathIterator, getPathIterator, intersects, reProject, transform
 
Methods inherited from interface java.awt.Shape
contains, contains, contains, contains, getBounds, intersects
 
Methods inherited from interface org.gvsig.fmap.geom.primitive.FShape
cloneFShape, getSelectHandlers, getStretchingHandlers, reProject, transform
 

Field Detail

id

protected String id

projection

protected org.cresques.cts.IProjection projection

geometryType

protected GeometryType geometryType

geomManager

protected static GeometryManager geomManager
Constructor Detail

AbstractPrimitive

public AbstractPrimitive(GeometryType geometryType)
The constructor with the GeometryType like and argument is used by the GeometryType#create() to create the geometry

Parameters:
type - The geometry type

AbstractPrimitive

public AbstractPrimitive(GeometryType geometryType,
                         String id,
                         org.cresques.cts.IProjection projection)

AbstractPrimitive

public AbstractPrimitive(GeometryType geometryType,
                         org.cresques.cts.IProjection projection)
Method Detail

getGeometryType

public GeometryType getGeometryType()
Description copied from interface: Geometry
Instance of the GeometryType associated to this geometry.

Specified by:
getGeometryType in interface Geometry
Returns:
The geometry type.

getType

public int getType()
Description copied from interface: Geometry
If this geometry is a predefined interface then this method returns one of Geometry.TYPES contants.
If this geometry is an extended type then this method returns a runtime constant that identifies its type. By convention this value is stored in a constant called .CODE within the geometry class, for instance: Point2D.CODE.

Specified by:
getType in interface Geometry
Returns:
If this geometry is a predefined interface then one of Geometry.TYPES or a runtime constant if it is an extended type.

getInternalShape

public Shape getInternalShape()
Deprecated. this Geometry is a Shape.

(non-Javadoc)

Specified by:
getInternalShape in interface Geometry
Returns:
The awt shape
See Also:
com.iver.cit.gvsig.fmap.core.Geometry#getInternalShape()

getId

public String getId()

getSRS

public org.cresques.cts.IProjection getSRS()

transform

public AbstractPrimitive transform(org.cresques.cts.IProjection newProjection)

rotateGeom

public static void rotateGeom(Geometry geometry,
                              double radAngle,
                              double basex,
                              double basey)

moveGeom

public static void moveGeom(Geometry geometry,
                            double dx,
                            double dy)

scaleGeom

public static void scaleGeom(Geometry geometry,
                             Point2D basePoint,
                             double sx,
                             double sy)

fastIntersects

public boolean fastIntersects(double x,
                              double y,
                              double w,
                              double h)
Description copied from interface: Geometry
Used by the drawing strategies to quickly test whether this geometry intersects with the visible rectangle.

Specified by:
fastIntersects in interface Geometry
Parameters:
x - The minimum X coordinate.
y - The minimum Y coordinate.
w - The width of the envelope.
h - The height of the envelope.
Returns:
true if this intersects the rectangle defined by the parameters.

cloneGeometry

public Geometry cloneGeometry()
Description copied from interface: Geometry
Creates a clone of this geometry.

Specified by:
cloneGeometry in interface Geometry
Returns:
A clone of this geometry.

getHandlers

public Handler[] getHandlers(int type)
Description copied from interface: Geometry
It returns the handlers of the geometry, these they can be of two types is straightening and of selection.

Specified by:
getHandlers in interface Geometry
Parameters:
type - Type of handlers.
Returns:
The handlers.

isSimple

public boolean isSimple()
Description copied from interface: Geometry
Returns true if this Geometry has no interior point of self-intersection or self-tangency. In mathematical formalisms, this means that every point in the interior of the object must have a metric neighborhood whose intersection with the object is isomorphic to an n-sphere, where n is the dimension of this Geometry.

Specified by:
isSimple in interface Geometry
Returns:
If the geometry is simple.

invokeOperation

public Object invokeOperation(int index,
                              GeometryOperationContext ctx)
                       throws GeometryOperationNotSupportedException,
                              GeometryOperationException
Description copied from interface: Geometry
Invokes a geometry operation given its index and context.

Specified by:
invokeOperation in interface Geometry
Parameters:
index - Unique index of the operation. Operation code.
ctx - The context of the geometry operation.
Returns:
Object returned by the operation.
Throws:
GeometryOperationNotSupportedException - It is thrown when the operation has been not registered for this geometry.
GeometryOperationException - It is thrown when there is an error executing the operation.

invokeOperation

public Object invokeOperation(String oppName,
                              GeometryOperationContext ctx)
                       throws GeometryOperationNotSupportedException,
                              GeometryOperationException
Description copied from interface: Geometry
Invokes a geometry operation given its name and context.

Specified by:
invokeOperation in interface Geometry
Parameters:
oppName - Operation name.
ctx - The context of the geometry operation.
Returns:
Object returned by the operation.
Throws:
GeometryOperationNotSupportedException - It is thrown when the operation has been not registered for this geometry.
GeometryOperationException - It is thrown when there is an error executing the operation.

compareTo

public int compareTo(Object arg0)
Specified by:
compareTo in interface Comparable

toString

public String toString()
Overrides:
toString in class Object

equals

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

getShapeType

public int getShapeType()
Description copied from interface: FShape
Gets the geometry type of this shape.

Specified by:
getShapeType in interface FShape
Returns:
int the geometry type of this shape.

containsPoint

protected boolean containsPoint(Geometry geom,
                                double x,
                                double y)
                         throws GeometryOperationException
Utility method

Parameters:
geometry -
x -
y -
Returns:
Throws:
GeometryOperationException

containsRectangle

protected boolean containsRectangle(Geometry geom,
                                    double x,
                                    double y,
                                    double w,
                                    double h)
                             throws GeometryOperationException
Parameters:
geometry -
x -
y -
w -
h -
Returns:
Throws:
GeometryOperationException

intersectsRectangle

protected boolean intersectsRectangle(Geometry geom,
                                      double x,
                                      double y,
                                      double w,
                                      double h)
                               throws GeometryOperationException
Parameters:
geom -
x -
y -
w -
h -
Returns:
Throws:
GeometryOperationException

convertToWKB

public byte[] convertToWKB()
                    throws GeometryOperationNotSupportedException,
                           GeometryOperationException
Description copied from interface: Geometry
Return a byte array with the equivalent in WKB format of the Geometry. Utility method to wrap the invocation to the operation Geometry.OPERATIONS.CONVERTTOWKB.

Specified by:
convertToWKB in interface Geometry
Returns:
the WKB version of the geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

convertToWKT

public String convertToWKT()
                    throws GeometryOperationNotSupportedException,
                           GeometryOperationException
Description copied from interface: Geometry
Return a string with the equivalent in WKT format of the Geometry. This is a utility method to wrap the invocation to the operation Geometry.OPERATIONS.CONVERTTOWKT.

Specified by:
convertToWKT in interface Geometry
Returns:
the WKT version of the geometry.
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

buffer

public Geometry buffer(double distance)
                throws GeometryOperationNotSupportedException,
                       GeometryOperationException
Description copied from interface: Geometry
Computes a buffer area around this geometry having the given width This is a utility method to wrap the invocation to the operation Geometry.OPERATIONS.BUFFER.

Specified by:
buffer in interface Geometry
Parameters:
distance - the width of the buffer
Returns:
a new Geometry with the computed buffer.
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

contains

public boolean contains(Geometry geometry)
                 throws GeometryOperationNotSupportedException,
                        GeometryOperationException
Description copied from interface: Geometry
Tests whether this geometry contains the specified geometry. This is a utility method to wrap the invocation to the operation Geometry.OPERATIONS.CONTAINS.

Specified by:
contains in interface Geometry
Parameters:
geometry - the Geometry with which to compare this Geometry
Returns:
if this Geometry contains the specified geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

distance

public double distance(Geometry geometry)
                throws GeometryOperationNotSupportedException,
                       GeometryOperationException
Description copied from interface: Geometry
Returns the minimum distance between this Geometry and the specified geometry. This is a utility method to wrap the invocation to the operation Geometry.OPERATIONS.DISTANCE.

Specified by:
distance in interface Geometry
Parameters:
geometry - the Geometry from which to compute the distance
Returns:
the distance between the geometries
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

overlaps

public boolean overlaps(Geometry geometry)
                 throws GeometryOperationNotSupportedException,
                        GeometryOperationException
Description copied from interface: Geometry
Tests whether this geometry overlaps the specified geometry. This is a utility method to wrap the invocation to the operation Geometry.OPERATIONS.OVERLAPS.

Specified by:
overlaps in interface Geometry
Parameters:
geometry - the Geometry with which to compare this Geometry
Returns:
true if the two geometries overlap.
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

convexHull

public Geometry convexHull()
                    throws GeometryOperationNotSupportedException,
                           GeometryOperationException
Specified by:
convexHull in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

coveredBy

public boolean coveredBy(Geometry geometry)
                  throws GeometryOperationNotSupportedException,
                         GeometryOperationException
Specified by:
coveredBy in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

crosses

public boolean crosses(Geometry geometry)
                throws GeometryOperationNotSupportedException,
                       GeometryOperationException
Specified by:
crosses in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

difference

public Geometry difference(Geometry other)
                    throws GeometryOperationNotSupportedException,
                           GeometryOperationException
Specified by:
difference in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

intersection

public Geometry intersection(Geometry other)
                      throws GeometryOperationNotSupportedException,
                             GeometryOperationException
Specified by:
intersection in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

intersects

public boolean intersects(Geometry geometry)
                   throws GeometryOperationNotSupportedException,
                          GeometryOperationException
Specified by:
intersects in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

touches

public boolean touches(Geometry geometry)
                throws GeometryOperationNotSupportedException,
                       GeometryOperationException
Specified by:
touches in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

union

public Geometry union(Geometry other)
               throws GeometryOperationNotSupportedException,
                      GeometryOperationException
Specified by:
union in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

disjoint

public boolean disjoint(Geometry geometry)
                 throws GeometryOperationNotSupportedException,
                        GeometryOperationException
Specified by:
disjoint in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

within

public boolean within(Geometry geometry)
               throws GeometryOperationNotSupportedException,
                      GeometryOperationException
Specified by:
within in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

centroid

public Point centroid()
               throws GeometryOperationNotSupportedException,
                      GeometryOperationException
Specified by:
centroid in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

area

public double area()
            throws GeometryOperationNotSupportedException,
                   GeometryOperationException
Specified by:
area in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

perimeter

public double perimeter()
                 throws GeometryOperationNotSupportedException,
                        GeometryOperationException
Specified by:
perimeter in interface Geometry
Throws:
GeometryOperationNotSupportedException
GeometryOperationException

getShape

public Shape getShape()
Specified by:
getShape in interface Geometry
Returns:
the awt shape used to display the geometry.

getShape

public Shape getShape(AffineTransform affineTransform)
Specified by:
getShape in interface Geometry
Returns:
the awt shape used to display the geometry. It applies a tranformation before to return the coordinates of the shape


Copyright © 2004-2012 gvSIG. All Rights Reserved.