/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * @author Denis M. Kishenko */ package java.awt; import java.awt.geom.Point2D; import java.io.Serializable; public class Point extends Point2D implements Serializable { private static final long serialVersionUID = -5276940640259749850L; public int x; public int y; public Point() { setLocation(0, 0); } public Point(int x, int y) { setLocation(x, y); } public Point(Point p) { setLocation(p.x, p.y); } public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof Point) { Point p = (Point)obj; return x == p.x && y == p.y; } return false; } public String toString() { return getClass().getName() + "[x=" + x + ",y=" + y + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } public double getX() { return x; } public double getY() { return y; } public Point getLocation() { return new Point(x, y); } public void setLocation(Point p) { setLocation(p.x, p.y); } public void setLocation(int x, int y) { this.x = x; this.y = y; } public void setLocation(double x, double y) { x = x < Integer.MIN_VALUE ? Integer.MIN_VALUE : x > Integer.MAX_VALUE ? Integer.MAX_VALUE : x; y = y < Integer.MIN_VALUE ? Integer.MIN_VALUE : y > Integer.MAX_VALUE ? Integer.MAX_VALUE : y; setLocation((int)Math.round(x), (int)Math.round(y)); } public void move(int x, int y) { setLocation(x, y); } public void translate(int dx, int dy) { x += dx; y += dy; } }