/** * This is called mainly from the other geometric types, when a point is embedded within their * definition. * * @param value Definition of this point in PostgreSQL's syntax * @throws SQLException if something goes wrong */ public PGpoint(String value) throws SQLException { this(); setValue(value); }
public Object clone() throws CloneNotSupportedException { PGcircle newPGcircle = (PGcircle) super.clone(); if (newPGcircle.center != null) { newPGcircle.center = (PGpoint) newPGcircle.center.clone(); } return newPGcircle; }
/** * @param b Definition of this point in PostgreSQL's binary syntax */ public void setByteValue(byte[] b, int offset) { point[0] = new PGpoint(); point[0].setByteValue(b, offset); point[1] = new PGpoint(); point[1].setByteValue(b, offset + point[0].lengthInBytes()); }
public int hashCode() { // This relies on the behaviour of point's hashcode being an exclusive-OR of // its X and Y components; we end up with an exclusive-OR of the two X and // two Y components, which is equal whenever equals() would return true // since xor is commutative. return point[0].hashCode() ^ point[1].hashCode(); }
/** * @param obj Object to compare with * @return true if the two line segments are identical */ public boolean equals(Object obj) { if (obj instanceof PGlseg) { PGlseg p = (PGlseg) obj; return (p.point[0].equals(point[0]) && p.point[1].equals(point[1])) || (p.point[0].equals(point[1]) && p.point[1].equals(point[0])); } return false; }
PGpoint pgPoint = new PGpoint(); pgPoint.setByteValue((byte[]) paramValues[index], 0); return "'" + pgPoint.toString() + "'::point";
/** * Moves the point to the supplied java.awt.Point refer to java.awt.Point for description of this. * * @param p Point to move to * @see java.awt.Point */ public void setLocation(Point p) { setLocation(p.x, p.y); }
/** * Required by the driver. */ public PGpoint() { setType("point"); }
/** * Translate the point by the supplied amount. * * @param x integer amount to add on the x axis * @param y integer amount to add on the y axis */ public void translate(int x, int y) { translate((double) x, (double) y); }
/** * Moves the point to the supplied coordinates. refer to java.awt.Point for description of this. * * @param x integer coordinate * @param y integer coordinate * @see java.awt.Point */ public void setLocation(int x, int y) { move((double) x, (double) y); }
public int hashCode() { // XXX not very good.. int hash = 0; for (int i = 0; i < points.length && i < 5; ++i) { hash = hash ^ points[i].hashCode(); } return hash; }
/** * @param obj Object to compare with * @return true if the two circles are identical */ public boolean equals(Object obj) { if (obj instanceof PGcircle) { PGcircle p = (PGcircle) obj; return p.center.equals(center) && p.radius == radius; } return false; }
/** * Moves the point to the supplied coordinates. * * @param x integer coordinate * @param y integer coordinate */ public void move(int x, int y) { setLocation(x, y); }
/** * Required by the driver */ public PGpoint() { setType("point"); }
/** * Translate the point by the supplied amount. * @param x integer amount to add on the x axis * @param y integer amount to add on the y axis */ public void translate(int x, int y) { translate((double)x, (double)y); }
/** * Moves the point to the supplied coordinates. * refer to java.awt.Point for description of this * @param x integer coordinate * @param y integer coordinate * @see java.awt.Point */ public void setLocation(int x, int y) { move((double)x, (double)y); }