source: osm/applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Coordinate.java@ 30628

Last change on this file since 30628 was 30628, checked in by stoecker, 10 years ago

remove tabs

  • Property svn:mime-type set to text/plain
File size: 1.9 KB
Line 
1// License: GPL. For details, see Readme.txt file.
2package org.openstreetmap.gui.jmapviewer;
3
4import java.awt.geom.Point2D;
5import java.io.IOException;
6import java.io.ObjectInputStream;
7import java.io.ObjectOutputStream;
8import java.io.Serializable;
9import java.util.Objects;
10
11import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
12
13/**
14 * This class encapsulates a Point2D.Double and provide access
15 * via <tt>lat</tt> and <tt>lon</tt>.
16 *
17 * @author Jan Peter Stotz
18 *
19 */
20public class Coordinate implements Serializable, ICoordinate {
21 private transient Point2D.Double data;
22
23 public Coordinate(double lat, double lon) {
24 data = new Point2D.Double(lon, lat);
25 }
26
27 public double getLat() {
28 return data.y;
29 }
30
31 public void setLat(double lat) {
32 data.y = lat;
33 }
34
35 public double getLon() {
36 return data.x;
37 }
38
39 public void setLon(double lon) {
40 data.x = lon;
41 }
42
43 private void writeObject(ObjectOutputStream out) throws IOException {
44 out.writeObject(data.x);
45 out.writeObject(data.y);
46 }
47
48 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
49 data = new Point2D.Double();
50 data.x = (Double) in.readObject();
51 data.y = (Double) in.readObject();
52 }
53
54 public String toString() {
55 return "Coordinate[" + data.y + ", " + data.x + "]";
56 }
57
58 @Override
59 public int hashCode() {
60 int hash = 3;
61 hash = 61 * hash + Objects.hashCode(this.data);
62 return hash;
63 }
64
65 @Override
66 public boolean equals(Object obj) {
67 if (obj == null) {
68 return false;
69 }
70 if (getClass() != obj.getClass()) {
71 return false;
72 }
73 final Coordinate other = (Coordinate) obj;
74 if (!Objects.equals(this.data, other.data)) {
75 return false;
76 }
77 return true;
78 }
79}
Note: See TracBrowser for help on using the repository browser.