Changeset 43 in josm for src/org/openstreetmap/josm/data/projection
- Timestamp:
- 2006-01-22T16:10:57+01:00 (18 years ago)
- Location:
- src/org/openstreetmap/josm/data/projection
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/data/projection/Epsg4263.java
r42 r43 1 1 package org.openstreetmap.josm.data.projection; 2 3 import javax.swing.JComponent;4 2 5 3 import org.openstreetmap.josm.data.GeoPoint; … … 10 8 * @author imi 11 9 */ 12 public class Epsg4263 extends Projection {10 public class Epsg4263 implements Projection { 13 11 14 @Override15 12 public void latlon2xy(GeoPoint p) { 16 13 p.x = p.lon; … … 18 15 } 19 16 20 @Override21 17 public void xy2latlon(GeoPoint p) { 22 18 p.lat = p.y; … … 28 24 return "EPSG:4263"; 29 25 } 30 31 @Override32 public JComponent getConfigurationPanel() {33 return null;34 }35 36 @Override37 public void commitConfigurationPanel() {38 }39 26 } -
src/org/openstreetmap/josm/data/projection/Mercator.java
r39 r43 1 1 package org.openstreetmap.josm.data.projection; 2 3 import javax.swing.JComponent;4 2 5 3 import org.openstreetmap.josm.data.GeoPoint; … … 14 12 * @author imi 15 13 */ 16 public class Mercator extends Projection {14 public class Mercator implements Projection { 17 15 18 @Override19 16 public void latlon2xy(GeoPoint p) { 20 17 p.x = p.lon*Math.PI/180; … … 22 19 } 23 20 24 @Override25 21 public void xy2latlon(GeoPoint p) { 26 22 p.lon = p.x*180/Math.PI; … … 32 28 return "Mercator"; 33 29 } 34 35 @Override36 public JComponent getConfigurationPanel() {37 return null;38 }39 40 @Override41 public void commitConfigurationPanel() {42 }43 30 } -
src/org/openstreetmap/josm/data/projection/Projection.java
r41 r43 1 1 package org.openstreetmap.josm.data.projection; 2 2 3 import java.util.LinkedList;4 import java.util.List;5 6 import javax.swing.JComponent;7 import javax.swing.event.ChangeEvent;8 import javax.swing.event.ChangeListener;9 10 import org.openstreetmap.josm.data.Bounds;11 3 import org.openstreetmap.josm.data.GeoPoint; 12 4 … … 17 9 * @author imi 18 10 */ 19 abstract public class Projection implements Cloneable{11 public interface Projection { 20 12 21 13 public static double MAX_LAT = 85; 22 14 public static double MAX_LON = 180; 23 24 /**25 * The event list with all state chaned listener26 */27 List<ChangeListener> listener = new LinkedList<ChangeListener>();28 15 29 16 /** … … 32 19 * @param p The geo point to convert. x/y members of the point are filled. 33 20 */ 34 abstract publicvoid latlon2xy(GeoPoint p);21 void latlon2xy(GeoPoint p); 35 22 36 23 /** … … 39 26 * @param p The geo point to convert. lat/lon members of the point are filled. 40 27 */ 41 abstract publicvoid xy2latlon(GeoPoint p);28 void xy2latlon(GeoPoint p); 42 29 43 30 … … 47 34 * Describe the projection converter in one or two words. 48 35 */ 49 @Override 50 abstract public String toString(); 51 52 // miscellous functions 53 54 /** 55 * If the projection supports any configuration, this function return 56 * the configuration panel. If no configuration needed, 57 * return <code>null</code>. 58 * 59 * The items on the configuration panel should not update the configuration 60 * directly, but remember changed settings so a call to commitConfigurationPanel 61 * can set them. 62 * 63 * This function also rolls back all changes to the configuration panel interna 64 * components. 65 */ 66 abstract public JComponent getConfigurationPanel(); 67 /** 68 * Commits any changes from components created by addToConfigurationPanel. 69 * The projection should now obtain the new settings. If any setting has 70 * changed, the implementation have to call to fireStateChanged to inform 71 * the listeners. 72 */ 73 abstract public void commitConfigurationPanel(); 74 75 /** 76 * Initialize itself with the given bounding rectangle (regarding lat/lon). 77 * 78 * This function should initialize own parameters needed to do the 79 * projection at best effort. 80 * 81 * Init must not fire an state changed event, since it is usually called 82 * during the initialization of the mapFrame. 83 * 84 * This implementation does nothing. It is provided only for subclasses 85 * to initialize their data members. 86 */ 87 public void init(Bounds b) {} 88 89 /** 90 * Add an event listener to the state changed event queue. If passed 91 * <code>null</code>, nothing happens. 92 */ 93 public final void addChangeListener(ChangeListener l) { 94 if (l != null) 95 listener.add(l); 96 } 97 /** 98 * Remove an event listener from the event queue. If passed 99 * <code>null</code>, nothing happens. 100 */ 101 public final void removeChangeListener(ChangeListener l) { 102 listener.remove(l); 103 } 104 /** 105 * Fire an ChangeEvent to every listener on the queue. 106 */ 107 public final void fireStateChanged() { 108 ChangeEvent e = null; 109 for(ChangeListener l : listener) { 110 if (e == null) 111 e = new ChangeEvent(this); 112 l.stateChanged(e); 113 } 114 } 36 String toString(); 115 37 }
Note:
See TracChangeset
for help on using the changeset viewer.