org.postgresql.geometric

## Class PGpoint

- java.lang.Object
- - org.postgresql.util.PGobject
  - - org.postgresql.geometric.PGpoint

All Implemented Interfaces:
  java.io.Serializable, java.lang.Cloneable, org.postgresql.util.PGBinaryObject

    public class PGpoint
    extends PGobject
    implements org.postgresql.util.PGBinaryObject, java.io.Serializable, java.lang.Cloneable

It maps to the point datatype in org.postgresql. This implements a version of java.awt.Point, except it uses double to represent the coordinates.

See Also:
  Serialized Form

### Field Summary

Fields
`double` `x` The X coordinate of the point
`double` `y` The Y coordinate of the point

### Fields inherited from class org.postgresql.util.PGobject

`type, value`

### Constructor Summary

Constructors
Constructor and Description
`PGpoint()` Required by the driver
`PGpoint(double x, double y)`
`PGpoint(java.lang.String value)` This is called mainly from the other geometric types, when a point is embedded within their definition.

### Method Summary

Methods
`boolean` `equals(java.lang.Object obj)` This must be overidden to allow comparisons of objects
`java.lang.String` `getValue()` This must be overidden, to return the value of the object, in the form required by org.postgresql.
`int` `hashCode()`
`int` `lengthInBytes()`
`void` `move(double x, double y)` Moves the point to the supplied coordinates.
`void` `move(int x, int y)` Moves the point to the supplied coordinates.
`void` `setByteValue(byte[] b, int offset)`
`void` `setLocation(int x, int y)` Moves the point to the supplied coordinates.
`void` `setLocation(java.awt.Point p)` Moves the point to the supplied java.awt.Point refer to java.awt.Point for description of this
`void` `setValue(java.lang.String s)` This method sets the value of this object.
`void` `toBytes(byte[] b, int offset)`
`void` `translate(double x, double y)` Translate the point by the supplied amount.
`void` `translate(int x, int y)` Translate the point by the supplied amount.

### Methods inherited from class org.postgresql.util.PGobject

`clone, getType, setType, toString`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### x

    public double x

The X coordinate of the point

#### y

    public double y

The Y coordinate of the point

### Constructor Detail

#### PGpoint

    public PGpoint(double x,
           double y)

Parameters:
  `x` - coordinate
  `y` - coordinate

#### PGpoint

    public PGpoint(java.lang.String value)
            throws java.sql.SQLException

This is called mainly from the other geometric types, when a point is embedded within their definition.

Parameters:
  `value` - Definition of this point in PostgreSQL's syntax
Throws:
  `java.sql.SQLException`

#### PGpoint

    public PGpoint()

Required by the driver

### Method Detail

#### setValue

    public void setValue(java.lang.String s)
                  throws java.sql.SQLException

Description copied from class: `PGobject`
This method sets the value of this object. It must be overidden.

Overrides:
  `setValue` in class `PGobject`
Parameters:
  `s` - Definition of this point in PostgreSQL's syntax
Throws:
  `java.sql.SQLException` - on conversion failure

#### setByteValue

    public void setByteValue(byte[] b,
                    int offset)

Specified by:
  `setByteValue` in interface `org.postgresql.util.PGBinaryObject`
Parameters:
  `b` - Definition of this point in PostgreSQL's binary syntax

#### equals

    public boolean equals(java.lang.Object obj)

Description copied from class: `PGobject`
This must be overidden to allow comparisons of objects

Overrides:
  `equals` in class `PGobject`
Parameters:
  `obj` - Object to compare with
Returns:
  true if the two points are identical

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `java.lang.Object`

#### getValue

    public java.lang.String getValue()

Description copied from class: `PGobject`
This must be overidden, to return the value of the object, in the form required by org.postgresql.

Overrides:
  `getValue` in class `PGobject`
Returns:
  the PGpoint in the syntax expected by org.postgresql

#### lengthInBytes

    public int lengthInBytes()

Specified by:
  `lengthInBytes` in interface `org.postgresql.util.PGBinaryObject`

#### toBytes

    public void toBytes(byte[] b,
               int offset)

Specified by:
  `toBytes` in interface `org.postgresql.util.PGBinaryObject`

#### translate

    public void translate(int x,
                 int y)

Translate the point by the supplied amount.

Parameters:
  `x` - integer amount to add on the x axis
  `y` - integer amount to add on the y axis

#### translate

    public void translate(double x,
                 double y)

Translate the point by the supplied amount.

Parameters:
  `x` - double amount to add on the x axis
  `y` - double amount to add on the y axis

#### move

    public void move(int x,
            int y)

Moves the point to the supplied coordinates.

Parameters:
  `x` - integer coordinate
  `y` - integer coordinate

#### move

    public void move(double x,
            double y)

Moves the point to the supplied coordinates.

Parameters:
  `x` - double coordinate
  `y` - double coordinate

#### setLocation

    public void setLocation(int x,
                   int y)

Moves the point to the supplied coordinates. refer to java.awt.Point for description of this

Parameters:
  `x` - integer coordinate
  `y` - integer coordinate
See Also:
  `Point`

#### setLocation

    public void setLocation(java.awt.Point p)

Moves the point to the supplied java.awt.Point refer to java.awt.Point for description of this

Parameters:
  `p` - Point to move to
See Also:
  `Point`