Crossfire JXClient, Trunk  R20561
Location.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.map;
23 
24 import org.jetbrains.annotations.NotNull;
25 import org.jetbrains.annotations.Nullable;
26 
31 public class Location {
32 
36  private final int x;
37 
41  private final int y;
42 
46  private final int layer;
47 
54  public Location(final int x, final int y, final int layer) {
55  this.x = x;
56  this.y = y;
57  this.layer = layer;
58  }
59 
64  public int getX() {
65  return x;
66  }
67 
72  public int getY() {
73  return y;
74  }
75 
80  public int getLayer() {
81  return layer;
82  }
83 
87  @Override
88  public boolean equals(@Nullable final Object obj) {
89  if (obj == null) {
90  return false;
91  }
92  if (obj.getClass() != Location.class) {
93  return false;
94  }
95  final Location loc = (Location)obj;
96  return loc.x == x && loc.y == y && loc.layer == layer;
97  }
98 
102  @Override
103  public int hashCode() {
104  return x^y*0x1000^layer*0x1000000;
105  }
106 
110  @NotNull
111  @Override
112  public String toString() {
113  return x+"/"+y+"/"+layer;
114  }
115 
116 }
int getY()
Returns the y-coordinate.
Definition: Location.java:72
Location(final int x, final int y, final int layer)
Creates a new location.
Definition: Location.java:54
boolean equals(@Nullable final Object obj)
Definition: Location.java:88
int getX()
Returns the x-coordinate.
Definition: Location.java:64