org.postgis.java2d
Class PGShapeGeometry

java.lang.Object
  extended by org.postgresql.util.PGobject
      extended by org.postgis.java2d.PGShapeGeometry
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable

public class PGShapeGeometry
extends org.postgresql.util.PGobject
implements java.awt.Shape

PostGIS Java2D geometry implementation (read-only). Supports PostGIS 1.x (lwgeom hexwkb). As the java.awt.Shape methods currently are implemented by using a java.awt.geom.GeneralPath object, they have the same semantics. BUG/TODO: MultiPoints or Points in a Geometry Collection currently don't work as expected, as some GeneralPath implementations throw away adjacent MoveTo commands as an optimization (e. G. sun 1.5 and ibm 1.5). Points thus are translated into MoveTo() followed by a closePath. This may change when we implement our own path logics. We have to evaluate whether Graphics2D renders a single MoveTo command as a single "brush tip", or we need the closePath() command nevertheless to get any drawing. Maybe we need a LineTo() to the same coordinages instead. (Multi)LineStrings are translated into a sequence of a single MoveTo and multiple LineTo vertices, and Polygon rings into a sequence of a single MoveTo, multiple LineTo and a closePath command. To allow correct Polygon filling, our PathIterators have GeneralPath.WIND_EVEN_ODD as winding rule.

Author:
Markus Schaber
See Also:
GeneralPath, Shape, PGobject, Serialized Form

Field Summary
 
Fields inherited from class org.postgresql.util.PGobject
type, value
 
Constructor Summary
PGShapeGeometry()
          Constructor called by JDBC drivers.
PGShapeGeometry(java.awt.geom.GeneralPath path, int srid)
          Construct directly from a General Path
PGShapeGeometry(java.lang.String value)
          Reads the HexWKB representation
 
Method Summary
 boolean contains(double x, double y)
           
 boolean contains(double x, double y, double w, double h)
           
 boolean contains(java.awt.geom.Point2D p)
           
 boolean contains(java.awt.geom.Rectangle2D r)
           
 boolean equals(java.lang.Object obj)
           
 java.awt.Rectangle getBounds()
           
 java.awt.geom.Rectangle2D getBounds2D()
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
           
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at, double flatness)
           
 int getSRID()
          Return the SRID or Geometry.UNKNOWN_SRID if none was available
 java.lang.String getValue()
          We currently have read-only support, so this method returns null
 boolean intersects(double x, double y, double w, double h)
           
 boolean intersects(java.awt.geom.Rectangle2D r)
           
 void setValue(java.lang.String value)
          Reads the HexWKB representation - to be called by the jdbc drivers.
 java.lang.String toString()
           
 
Methods inherited from class org.postgresql.util.PGobject
clone, getType, setType
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PGShapeGeometry

public PGShapeGeometry()
Constructor called by JDBC drivers. call setValue afterwards to fill with Geometry data.


PGShapeGeometry

public PGShapeGeometry(java.awt.geom.GeneralPath path,
                       int srid)
Construct directly from a General Path


PGShapeGeometry

public PGShapeGeometry(java.lang.String value)
                throws java.sql.SQLException
Reads the HexWKB representation

Throws:
java.sql.SQLException
Method Detail

setValue

public void setValue(java.lang.String value)
              throws java.sql.SQLException
Reads the HexWKB representation - to be called by the jdbc drivers. Be shure to call this only once and if you used the PGShapeGeometry() constructor without parameters. In all other cases, behaviour is undefined.

Overrides:
setValue in class org.postgresql.util.PGobject
Throws:
java.sql.SQLException

toString

public java.lang.String toString()
Overrides:
toString in class org.postgresql.util.PGobject

getValue

public java.lang.String getValue()
We currently have read-only support, so this method returns null

Overrides:
getValue in class org.postgresql.util.PGobject

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class org.postgresql.util.PGobject

getSRID

public int getSRID()
Return the SRID or Geometry.UNKNOWN_SRID if none was available


contains

public boolean contains(double x,
                        double y)
Specified by:
contains in interface java.awt.Shape

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Specified by:
contains in interface java.awt.Shape

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Specified by:
intersects in interface java.awt.Shape

getBounds

public java.awt.Rectangle getBounds()
Specified by:
getBounds in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Point2D p)
Specified by:
contains in interface java.awt.Shape

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Specified by:
getBounds2D in interface java.awt.Shape

contains

public boolean contains(java.awt.geom.Rectangle2D r)
Specified by:
contains in interface java.awt.Shape

intersects

public boolean intersects(java.awt.geom.Rectangle2D r)
Specified by:
intersects in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at)
Specified by:
getPathIterator in interface java.awt.Shape

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform at,
                                                  double flatness)
Specified by:
getPathIterator in interface java.awt.Shape