Mercurial > projects > dwt-linux
annotate dwt/graphics/Point.d @ 238:380bad9f6852
reverted char[] to String
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:42:55 +0200 |
parents | df23b11d0b70 |
children | c0d810de7093 |
rev | line source |
---|---|
72 | 1 /******************************************************************************* |
4 | 2 * Copyright (c) 2000, 2005 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
72 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
4 | 12 *******************************************************************************/ |
10
63c023465156
moved from org.eclipse.swt to dwt
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
13 module dwt.graphics.Point; |
4 | 14 |
238 | 15 import dwt.dwthelper.utils; |
16 | |
4 | 17 |
10
63c023465156
moved from org.eclipse.swt to dwt
Frank Benoit <benoit@tionex.de>
parents:
9
diff
changeset
|
18 public import dwt.internal.SerializableCompatibility; |
4 | 19 |
20 import tango.text.convert.Format; | |
21 | |
22 /** | |
23 * Instances of this class represent places on the (x, y) | |
24 * coordinate plane. | |
25 * <p> | |
26 * The coordinate space for rectangles and points is considered | |
27 * to have increasing values downward and to the right from its | |
28 * origin making this the normal, computer graphics oriented notion | |
29 * of (x, y) coordinates rather than the strict mathematical one. | |
30 * </p> | |
31 * <p> | |
32 * The hashCode() method in this class uses the values of the public | |
33 * fields to compute the hash value. When storing instances of the | |
34 * class in hashed collections, do not modify these fields after the | |
35 * object has been inserted. | |
36 * </p> | |
37 * <p> | |
38 * Application code does <em>not</em> need to explicitly release the | |
39 * resources managed by each instance when those instances are no longer | |
40 * required, and thus no <code>dispose()</code> method is provided. | |
41 * </p> | |
42 * | |
43 * @see Rectangle | |
44 */ | |
45 | |
46 public final class Point : SerializableCompatibility { | |
47 | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
48 /** |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
49 * the x coordinate of the point |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
50 */ |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
51 public int x; |
4 | 52 |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
53 /** |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
54 * the y coordinate of the point |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
55 */ |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
56 public int y; |
4 | 57 |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
58 //static final long serialVersionUID = 3257002163938146354L; |
4 | 59 |
60 /** | |
61 * Constructs a new point with the given x and y coordinates. | |
62 * | |
63 * @param x the x coordinate of the new point | |
64 * @param y the y coordinate of the new point | |
65 */ | |
66 public this (int x, int y) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
67 this.x = x; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
68 this.y = y; |
4 | 69 } |
70 | |
71 /** | |
72 * Compares the argument to the receiver, and returns true | |
73 * if they represent the <em>same</em> object using a class | |
74 * specific comparison. | |
75 * | |
76 * @param object the object to compare with this object | |
77 * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise | |
78 * | |
79 * @see #hashCode() | |
80 */ | |
81 public override int opEquals (Object object) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
82 if (object is this) return true; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
83 if ( auto p = cast(Point)object ){ |
148
ee9953d47114
some ==/is replacements, thanks torhu for bug report
Frank Benoit <benoit@tionex.de>
parents:
72
diff
changeset
|
84 return (p.x is this.x) && (p.y is this.y); |
4 | 85 } |
86 return false; | |
87 } | |
88 | |
89 /** | |
90 * Returns an integer hash code for the receiver. Any two | |
91 * objects that return <code>true</code> when passed to | |
92 * <code>equals</code> must return the same value for this | |
93 * method. | |
94 * | |
95 * @return the receiver's hash | |
96 * | |
97 * @see #equals(Object) | |
98 */ | |
188
df23b11d0b70
minor changes to be more compatible to dwt-win, fixed potetial ==/is bugs.
Frank Benoit <benoit@tionex.de>
parents:
177
diff
changeset
|
99 override public hash_t toHash () { |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
10
diff
changeset
|
100 return x ^ y; |
4 | 101 } |
102 | |
103 /** | |
104 * Returns a string containing a concise, human-readable | |
105 * description of the receiver. | |
106 * | |
107 * @return a string representation of the point | |
108 */ | |
238 | 109 override public String toString () { |
177 | 110 return Format( "Point {{{}, {}}", x, y );; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
4 | 111 } |
112 | |
113 } | |
114 |