001 /*
002 * This file is part of the Echo Point Project. This project is a
003 * collection of Components that have extended the Echo Web Application
004 * Framework Version 3.
005 *
006 * Version: MPL 1.1
007 *
008 * The contents of this file are subject to the Mozilla Public License Version
009 * 1.1 (the "License"); you may not use this file except in compliance with
010 * the License. You may obtain a copy of the License at
011 * http://www.mozilla.org/MPL/
012 *
013 * Software distributed under the License is distributed on an "AS IS" basis,
014 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
015 * for the specific language governing rights and limitations under the
016 * License.
017 */
018 package echopoint.model;
019
020 import com.thoughtworks.xstream.annotations.XStreamAlias;
021
022 import java.io.Serializable;
023
024 /**
025 * A model object that represents a point in cartesian co-ordinate system.
026 *
027 * <p><b>Note:</b> Development of this component was sponsored by
028 * <a href='http://tcnbroadcasting.com/index.jsp' target='_top'>TCN
029 * Broadcasting</a>. We are grateful for their support and sponsorship.</p>
030 *
031 * @author Rakesh Vidyadharan 2008-10-20
032 * @version $Id: Point.java 72 2008-10-21 02:51:23Z sptrakesh $
033 */
034 @XStreamAlias( "point" )
035 public class Point implements Serializable
036 {
037 private static final long serialVersionUID = 1l;
038
039 /** The x co-ordinate of the point. */
040 public final int x;
041
042 /** The y co-ordinate of the point. */
043 public final int y;
044
045 public Point( final int x, final int y )
046 {
047 this.x = x;
048 this.y = y;
049 }
050
051 /**
052 * Compare the specified object with this for equality.
053 *
054 * @param o The object that is to be compared.
055 * @return Returns <code>true</code> if the objects are equivalent.
056 */
057 @Override
058 public boolean equals( final Object o )
059 {
060 if ( this == o ) return true;
061 if ( o == null || getClass() != o.getClass() ) return false;
062
063 Point point = (Point) o;
064
065 return x == point.x && y == point.y;
066 }
067
068 /**
069 * Compute a hash code for this object.
070 *
071 * @return The hash code value.
072 */
073 @Override
074 public int hashCode()
075 {
076 int result;
077 result = x;
078 result = 31 * result + y;
079 return result;
080 }
081
082 /**
083 * Accessor for property 'y'.
084 *
085 * @return Value for property 'y'.
086 */
087 public int getY()
088 {
089 return y;
090 }
091
092 /**
093 * Accessor for property 'x'.
094 *
095 * @return Value for property 'x'.
096 */
097 public int getX()
098 {
099 return x;
100 }
101 }