Changeset 35353 in osm for applications/viewer/jmapviewer
- Timestamp:
- 2020-03-08T22:08:39+01:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Coordinate.java
r35341 r35353 2 2 package org.openstreetmap.gui.jmapviewer; 3 3 4 import java.awt.geom.Point2D;5 4 import java.io.IOException; 6 5 import java.io.ObjectInputStream; … … 20 19 public class Coordinate implements ICoordinate, Serializable { 21 20 private static final long serialVersionUID = 1L; 22 private transient Point2D.Double data; 21 private double x; 22 private double y; 23 23 24 24 /** … … 28 28 */ 29 29 public Coordinate(double lat, double lon) { 30 data = new Point2D.Double(lon, lat); 30 setLat(lat); 31 setLon(lon); 31 32 } 32 33 33 34 @Override 34 35 public double getLat() { 35 return data.y;36 return y; 36 37 } 37 38 38 39 @Override 39 40 public void setLat(double lat) { 40 data.y = lat;41 y = lat; 41 42 } 42 43 43 44 @Override 44 45 public double getLon() { 45 return data.x;46 return x; 46 47 } 47 48 48 49 @Override 49 50 public void setLon(double lon) { 50 data.x = lon;51 x = lon; 51 52 } 52 53 53 54 private void writeObject(ObjectOutputStream out) throws IOException { 54 out.writeObject( data.x);55 out.writeObject( data.y);55 out.writeObject(x); 56 out.writeObject(y); 56 57 } 57 58 58 59 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 59 data = new Point2D.Double(); 60 data.x = (Double) in.readObject(); 61 data.y = (Double) in.readObject(); 60 x = (Double) in.readObject(); 61 y = (Double) in.readObject(); 62 62 } 63 63 64 64 @Override 65 65 public String toString() { 66 return "Coordinate[" + data.y + ", " + data.x + ']';66 return "Coordinate[" + y + ", " + x + ']'; 67 67 } 68 68 69 69 @Override 70 70 public int hashCode() { 71 return Objects.hash Code(data);71 return Objects.hash(x, y); 72 72 } 73 73 74 74 @Override 75 public boolean equals(Object obj) { 76 if (this == obj) 77 return true; 78 if (!(obj instanceof Coordinate)) 79 return false; 80 final Coordinate other = (Coordinate) obj; 81 return Objects.equals(data, other.data); 75 public boolean equals(Object o) { 76 if (this == o) return true; 77 if (o == null || getClass() != o.getClass()) return false; 78 Coordinate that = (Coordinate) o; 79 return Double.compare(that.x, x) == 0 && Double.compare(that.y, y) == 0; 82 80 } 83 81 }
Note:
See TracChangeset
for help on using the changeset viewer.