jdk/src/java.desktop/share/classes/java/awt/Point.java
author alexsch
Wed, 24 Aug 2016 00:23:49 +0400
changeset 40719 4ae72a69bd3b
parent 35667 ed476aba94de
permissions -rw-r--r--
8129854: Remove reflection from AWT/Swing classes Reviewed-by: serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 466
diff changeset
     2
 * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 466
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 466
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 466
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 466
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 466
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.geom.Point2D;
466
6acd5ec503a8 4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents: 2
diff changeset
    29
import java.beans.Transient;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * A point representing a location in {@code (x,y)} coordinate space,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * specified in integer precision.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @author      Sami Shaio
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * @since       1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
public class Point extends Point2D implements java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    40
     * The X coordinate of this {@code Point}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
     * If no X coordinate is set it will default to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
     * @see #getLocation()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
     * @see #move(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
     * @since 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    public int x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    /**
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    51
     * The Y coordinate of this {@code Point}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
     * If no Y coordinate is set it will default to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     * @serial
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * @see #getLocation()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     * @see #move(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * @since 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    public int y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * JDK 1.1 serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static final long serialVersionUID = -5276940640259749850L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
     * Constructs and initializes a point at the origin
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * (0, 0) of the coordinate space.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * @since       1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    public Point() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
        this(0, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Constructs and initializes a point with the same location as
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    77
     * the specified {@code Point} object.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * @param       p a point
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @since       1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public Point(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        this(p.x, p.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     * Constructs and initializes a point at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     * {@code (x,y)} location in the coordinate space.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    88
     * @param x the X coordinate of the newly constructed {@code Point}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
    89
     * @param y the Y coordinate of the newly constructed {@code Point}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * @since 1.0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public Point(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        this.x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        this.y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public double getX() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        return x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * {@inheritDoc}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @since 1.2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    public double getY() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        return y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Returns the location of this point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * This method is included for completeness, to parallel the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   116
     * {@code getLocation} method of {@code Component}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @return      a copy of this point, at the same location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @see         java.awt.Component#getLocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * @see         java.awt.Point#setLocation(java.awt.Point)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     * @see         java.awt.Point#setLocation(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @since       1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     */
466
6acd5ec503a8 4935607: RFE: LTP: Should be possible to set the TRANSIENT attribute of propertiies to FALSE
malenkov
parents: 2
diff changeset
   123
    @Transient
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public Point getLocation() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        return new Point(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Sets the location of the point to the specified location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     * This method is included for completeness, to parallel the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   131
     * {@code setLocation} method of {@code Component}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * @param       p  a point, the new location for this point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * @see         java.awt.Component#setLocation(java.awt.Point)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * @see         java.awt.Point#getLocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * @since       1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    public void setLocation(Point p) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        setLocation(p.x, p.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * Changes the point to have the specified location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * This method is included for completeness, to parallel the
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   145
     * {@code setLocation} method of {@code Component}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * Its behavior is identical with <code>move(int,&nbsp;int)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @param       x the X coordinate of the new location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @param       y the Y coordinate of the new location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @see         java.awt.Component#setLocation(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @see         java.awt.Point#getLocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * @see         java.awt.Point#move(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * @since       1.1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public void setLocation(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        move(x, y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * Sets the location of this point to the specified double coordinates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * The double values will be rounded to integer values.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   161
     * Any number smaller than {@code Integer.MIN_VALUE}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   162
     * will be reset to {@code MIN_VALUE}, and any number
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   163
     * larger than {@code Integer.MAX_VALUE} will be
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   164
     * reset to {@code MAX_VALUE}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * @param x the X coordinate of the new location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @param y the Y coordinate of the new location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * @see #getLocation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    public void setLocation(double x, double y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        this.x = (int) Math.floor(x+0.5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        this.y = (int) Math.floor(y+0.5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * Moves this point to the specified location in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * {@code (x,y)} coordinate plane. This method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * is identical with <code>setLocation(int,&nbsp;int)</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @param       x the X coordinate of the new location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @param       y the Y coordinate of the new location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * @see         java.awt.Component#setLocation(int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    public void move(int x, int y) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        this.x = x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        this.y = y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * Translates this point, at location {@code (x,y)},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * by {@code dx} along the {@code x} axis and {@code dy}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * along the {@code y} axis so that it now represents the point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * {@code (x+dx,y+dy)}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @param       dx   the distance to move this point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *                            along the X axis
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @param       dy    the distance to move this point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *                            along the Y axis
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    public void translate(int dx, int dy) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        this.x += dx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        this.y += dy;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Determines whether or not two points are equal. Two instances of
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   206
     * {@code Point2D} are equal if the values of their
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   207
     * {@code x} and {@code y} member fields, representing
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * their position in the coordinate space, are the same.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   209
     * @param obj an object to be compared with this {@code Point2D}
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   210
     * @return {@code true} if the object to be compared is
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   211
     *         an instance of {@code Point2D} and has
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   212
     *         the same values; {@code false} otherwise.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    public boolean equals(Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        if (obj instanceof Point) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            Point pt = (Point)obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            return (x == pt.x) && (y == pt.y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        return super.equals(obj);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * Returns a string representation of this point and its location
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * in the {@code (x,y)} coordinate space. This method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * intended to be used only for debugging purposes, and the content
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * and format of the returned string may vary between implementations.
35667
ed476aba94de 8138838: docs cleanup for java.desktop
avstepan
parents: 25859
diff changeset
   227
     * The returned string may be empty but may not be {@code null}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @return  a string representation of this point
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        return getClass().getName() + "[x=" + x + ",y=" + y + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
}