Mercurial > projects > dwt-mac
diff dwt/graphics/Point.d @ 33:965ac0a77267
Ported a couple of modules in dwt.graphics
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Fri, 12 Sep 2008 13:53:21 +0200 |
parents | a9ab4c738ed8 |
children | 7d135fe0caf2 |
line wrap: on
line diff
--- a/dwt/graphics/Point.d Fri Sep 12 13:44:30 2008 +0200 +++ b/dwt/graphics/Point.d Fri Sep 12 13:53:21 2008 +0200 @@ -7,12 +7,17 @@ * * Contributors: * IBM Corporation - initial API and implementation + * + * Port to the D programming language: + * Jacob Carlborg <jacob.carlborg@gmail.com> *******************************************************************************/ module dwt.graphics.Point; -import dwt.dwthelper.utils; +import dwt.internal.SerializableCompatibility; -import dwt.internal.SerializableCompatibility; +import tango.text.convert.Format; + +import dwt.dwthelper.utils; /** * Instances of this class represent places on the (x, y) @@ -50,7 +55,7 @@ */ public int y; - static final long serialVersionUID = 3257002163938146354L; + static const long serialVersionUID = 3257002163938146354L; /** * Constructs a new point with the given x and y coordinates. @@ -73,13 +78,15 @@ * * @see #hashCode() */ -public bool equals (Object object) { +public bool opEquals (Object object) { if (object is this) return true; if (!( null !is cast(Point)object )) return false; Point p = cast(Point)object; return (p.x is this.x) && (p.y is this.y); } +alias opEquals equals; + /** * Returns an integer hash code for the receiver. Any two * objects that return <code>true</code> when passed to @@ -90,10 +97,12 @@ * * @see #equals(Object) */ -public int hashCode () { +public hash_t toHash () { return x ^ y; } +alias toHash hashCode; + /** * Returns a string containing a concise, human-readable * description of the receiver. @@ -101,7 +110,7 @@ * @return a string representation of the point */ public String toString () { - return "Point {" + x + ", " + y + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + return Format("Point {{}{}{}{}" , x , ", " , y , "}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } }