Changeset 17 in josm for src/org/openstreetmap/josm/data
- Timestamp:
- 2005-10-09T04:14:40+02:00 (19 years ago)
- Location:
- src/org/openstreetmap/josm/data
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/data/GeoPoint.java
r9 r17 59 59 } 60 60 61 61 /** 62 * @return <code>true</code>, if the other GeoPoint has the same lat/lon values. 63 */ 64 public boolean equalsLatLon(GeoPoint other) { 65 return lat == other.lat && lon == other.lon; 66 } 62 67 } -
src/org/openstreetmap/josm/data/Preferences.java
r16 r17 1 1 package org.openstreetmap.josm.data; 2 2 3 import java.beans.PropertyChangeEvent; 4 import java.beans.PropertyChangeListener; 3 5 import java.io.File; 4 6 import java.io.FileReader; … … 38 40 39 41 42 /** 43 * Whether lines should be drawn between track points of raw gps data. 44 */ 45 private boolean drawRawGpsLines = false; 40 46 /** 41 47 * Whether nodes on the same place should be considered identical. … … 100 106 101 107 mergeNodes = root.getChild("mergeNodes") != null; 108 drawRawGpsLines = root.getChild("drawRawGpsLines") != null; 102 109 } catch (Exception e) { 103 110 if (e instanceof PreferencesException) … … 120 127 if (mergeNodes) 121 128 children.add(new Element("mergeNodes")); 129 if (drawRawGpsLines) 130 children.add(new Element("drawRawGpsLines")); 122 131 123 132 try { … … 134 143 135 144 /** 136 * This interface notifies any interested about changes in the projection137 * @author imi138 */139 public interface ProjectionChangeListener {140 void projectionChanged(Projection oldProjection, Projection newProjection);141 }142 /**143 145 * The list of all listeners to projection changes. 144 146 */ 145 private Collection<Pro jectionChangeListener> listener = new LinkedList<ProjectionChangeListener>();147 private Collection<PropertyChangeListener> listener = new LinkedList<PropertyChangeListener>(); 146 148 /** 147 149 * Add a listener of projection changes to the list of listeners. 148 150 * @param listener The listerner to add. 149 151 */ 150 public void addPro jectionChangeListener(ProjectionChangeListener listener) {152 public void addPropertyChangeListener(PropertyChangeListener listener) { 151 153 if (listener != null) 152 154 this.listener.add(listener); … … 155 157 * Remove the listener from the list. 156 158 */ 157 public void removePro jectionChangeListener(ProjectionChangeListener listener) {159 public void removePropertyChangeListener(PropertyChangeListener listener) { 158 160 this.listener.remove(listener); 159 161 } 162 /** 163 * Fires a PropertyChangeEvent if the old value differs from the new value. 164 */ 165 private <T> void firePropertyChanged(String name, T oldValue, T newValue) { 166 if (oldValue == newValue) 167 return; 168 PropertyChangeEvent evt = null; 169 for (PropertyChangeListener l : listener) { 170 if (evt == null) 171 evt = new PropertyChangeEvent(this, name, oldValue, newValue); 172 l.propertyChange(evt); 173 } 174 } 175 176 // getter / setter 177 160 178 /** 161 179 * Set the projection and fire an event to all ProjectionChangeListener … … 165 183 Projection old = this.projection; 166 184 this.projection = projection; 167 if (old != projection) 168 for (ProjectionChangeListener l : listener) 169 l.projectionChanged(old, projection); 185 firePropertyChanged("projection", old, projection); 170 186 } 171 187 /** … … 176 192 return projection; 177 193 } 194 public void setDrawRawGpsLines(boolean drawRawGpsLines) { 195 boolean old = this.drawRawGpsLines; 196 this.drawRawGpsLines = drawRawGpsLines; 197 firePropertyChanged("drawRawGpsLines", old, drawRawGpsLines); 198 } 199 public boolean isDrawRawGpsLines() { 200 return drawRawGpsLines; 201 } 178 202 } -
src/org/openstreetmap/josm/data/osm/DataSet.java
r16 r17 186 186 187 187 /** 188 * Import the given dataset by merging all data with this dataset. 189 * The objects imported are not cloned, so from now on, these data belong 190 * to both datasets. So use mergeFrom only if you are about to abandon the 191 * other dataset or this dataset. 192 * 193 * @param ds The DataSet to merge into this one. 194 * @param mergeEqualNodes If <code>true</code>, nodes with the same lat/lon 195 * are merged together. 196 */ 197 public void mergeFrom(DataSet ds, boolean mergeEqualNodes) { 198 if (mergeEqualNodes) { 199 LinkedList<Node> nodesToAdd = new LinkedList<Node>(); 200 for (Node n : ds.nodes) 201 for (Node mynode : nodes) { 202 if (mynode.coor.equalsLatLon(n.coor)) 203 mynode.mergeFrom(n); 204 else 205 nodesToAdd.add(n); 206 } 207 } else 208 nodes.addAll(ds.nodes); 209 tracks.addAll(ds.tracks); 210 pendingLineSegments.addAll(ds.pendingLineSegments); 211 } 212 213 /** 188 214 * Remove the selection from every value in the collection. 189 215 * @param list The collection to remove the selection from. -
src/org/openstreetmap/josm/data/osm/Node.java
r9 r17 33 33 return Collections.unmodifiableCollection(parentSegment); 34 34 } 35 36 /** 37 * Merge the node given at parameter with this node. 38 * All parents of the parameter-node become parents of this node. 39 * 40 * The argument node is not changed. 41 * 42 * @param node Merge the node to this. 43 */ 44 public void mergeFrom(Node node) { 45 parentSegment.addAll(node.parentSegment); 46 if (keys == null) 47 keys = node.keys; 48 else if (node.keys != null) 49 keys.putAll(node.keys); 50 } 35 51 36 52 /** -
src/org/openstreetmap/josm/data/osm/visitor/SelectionComponentVisitor.java
r11 r17 7 7 8 8 import javax.swing.Icon; 9 import javax.swing.ImageIcon;10 9 11 10 import org.openstreetmap.josm.data.osm.Key; … … 13 12 import org.openstreetmap.josm.data.osm.Node; 14 13 import org.openstreetmap.josm.data.osm.Track; 15 import org.openstreetmap.josm.gui. Main;14 import org.openstreetmap.josm.gui.ImageProvider; 16 15 17 16 /** … … 38 37 public void visit(Key k) { 39 38 name = k.name; 40 icon = new ImageIcon(Main.class.getResource("/images/data/key.png"));39 icon = ImageProvider.get("data", "key"); 41 40 } 42 41 … … 53 52 54 53 this.name = name; 55 icon = new ImageIcon("images/data/linesegment.png");54 icon = ImageProvider.get("data", "linesegment"); 56 55 } 57 56 … … 67 66 68 67 this.name = name; 69 icon = new ImageIcon("images/data/node.png");68 icon = ImageProvider.get("data", "node"); 70 69 } 71 70 … … 87 86 88 87 this.name = name; 89 icon = new ImageIcon("images/data/track.png");88 icon = ImageProvider.get("data", "track"); 90 89 } 91 90 -
src/org/openstreetmap/josm/data/projection/UTM.java
r16 r17 98 98 * Combobox with all ellipsoids for the configuration panel 99 99 */ 100 private JComboBox ellipsoidCombo = new JComboBox(allEllipsoids);100 private JComboBox ellipsoidCombo; 101 101 /** 102 102 * Spinner with all possible zones for the configuration panel 103 103 */ 104 private JSpinner zoneSpinner = new JSpinner(new SpinnerNumberModel(1,1,60,1));104 private JSpinner zoneSpinner; 105 105 /** 106 106 * Hemisphere combo for the configuration panel 107 107 */ 108 private JComboBox hemisphereCombo = new JComboBox(Hemisphere.values());108 private JComboBox hemisphereCombo; 109 109 110 110 … … 248 248 249 249 // ellipsoid 250 if (ellipsoidCombo == null) 251 ellipsoidCombo = new JComboBox(allEllipsoids); 250 252 panel.add(new JLabel("Ellipsoid"), gbc); 251 253 panel.add(ellipsoidCombo, GBC.eol()); … … 253 255 254 256 // zone 257 if (zoneSpinner == null) 258 zoneSpinner = new JSpinner(new SpinnerNumberModel(1,1,60,1)); 255 259 panel.add(new JLabel("Zone"), gbc); 256 260 panel.add(zoneSpinner, GBC.eol().insets(0,5,0,5)); … … 259 263 260 264 // hemisphere 265 if (hemisphereCombo == null) 266 hemisphereCombo = new JComboBox(Hemisphere.values()); 261 267 panel.add(new JLabel("Hemisphere"), gbc); 262 268 panel.add(hemisphereCombo, GBC.eop()); … … 268 274 public void actionPerformed(ActionEvent e) { 269 275 if (Main.main.getMapFrame() != null) { 270 DataSet ds = Main.main.getMapFrame().mapView. dataSet;276 DataSet ds = Main.main.getMapFrame().mapView.getActiveDataSet(); 271 277 ZoneData zd = autoDetect(ds); 272 278 if (zd.zone == 0) … … 291 297 @Override 292 298 public void commitConfigurationPanel() { 293 ellipsoid = (Ellipsoid)ellipsoidCombo.getSelectedItem(); 294 zone = (Integer)zoneSpinner.getValue(); 295 hemisphere = (Hemisphere)hemisphereCombo.getSelectedItem(); 296 fireStateChanged(); 299 if (ellipsoidCombo != null && zoneSpinner != null && hemisphereCombo != null) { 300 ellipsoid = (Ellipsoid)ellipsoidCombo.getSelectedItem(); 301 zone = (Integer)zoneSpinner.getValue(); 302 hemisphere = (Hemisphere)hemisphereCombo.getSelectedItem(); 303 fireStateChanged(); 304 } 297 305 } 298 306 }
Note:
See TracChangeset
for help on using the changeset viewer.