Changeset 795 in josm for trunk/src/org
- Timestamp:
- 2008-08-16T18:27:50+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r758 r795 89 89 if (v.min != null && v.max != null) // && v.min.north() == v.max.north() && v.min.east() == v.max.east()) { 90 90 { 91 EastNorth en = Main.proj.latlon2eastNorth(new LatLon(0.001, 0.001));91 EastNorth en = new EastNorth(0,0); 92 92 v.min = new EastNorth(v.min.east()-en.east(), v.min.north()-en.north()); 93 93 v.max = new EastNorth(v.max.east()+en.east(), v.max.north()+en.north()); -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r768 r795 54 54 */ 55 55 protected final SortedMap<String, String> properties = new TreeMap<String, String>(); 56 protected final SortedMap<String, String> defaults = new TreeMap<String, String>(); 56 57 57 58 /** … … 118 119 } 119 120 synchronized public String get(final String key, final String def) { 121 if(!defaults.containsKey(key)) 122 defaults.put(key, def); 123 else if(!defaults.get(key).equals(def)) 124 System.out.println("Defaults for " + key + " differ: " + def + " != " + defaults.get(key)); 120 125 if (override.containsKey(key)) 121 126 return override.get(key); … … 139 144 } 140 145 146 synchronized public Map<String, String> getDefaults() 147 { 148 return defaults; 149 } 150 141 151 synchronized public boolean getBoolean(final String key) { 142 return getBoolean(key, false); 152 if (override.containsKey(key)) 153 return override.get(key) == null ? false : Boolean.parseBoolean(override.get(key)); 154 return properties.containsKey(key) ? Boolean.parseBoolean(properties.get(key)) : false; 143 155 } 144 156 synchronized public boolean getBoolean(final String key, final boolean def) { 157 if(!defaults.containsKey(key)) 158 defaults.put(key, Boolean.toString(def)); 159 else if(!defaults.get(key).equals(Boolean.toString(def))) 160 System.out.println("Defaults for " + key + " differ: " + def + " != " + defaults.get(key)); 145 161 if (override.containsKey(key)) 146 162 return override.get(key) == null ? def : Boolean.parseBoolean(override.get(key)); -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r791 r795 15 15 import org.openstreetmap.josm.data.osm.visitor.Visitor; 16 16 import org.openstreetmap.josm.tools.DateParser; 17 import org.openstreetmap.josm.Main; 17 18 18 19 … … 23 24 * Although OsmPrimitive is designed as a base class, it is not to be meant to subclass 24 25 * it by any other than from the package {@link org.openstreetmap.josm.data.osm}. The available primitives are a fixed set that are given 25 * by the server environment and not an extendible data stuff. 26 * by the server environment and not an extendible data stuff. 26 27 * 27 28 * @author imi … … 36 37 /** 37 38 * Unique identifier in OSM. This is used to identify objects on the server. 38 * An id of 0 means an unknown id. The object has not been uploaded yet to 39 * An id of 0 means an unknown id. The object has not been uploaded yet to 39 40 * know what id it will get. 40 * 41 * 41 42 * Do not write to this attribute except you know exactly what you are doing. 42 43 * More specific, it is not good to set this to 0 and think the object is now … … 50 51 * the server. In this case, on next upload, this object will be updated. 51 52 * Deleted objects are deleted from the server. If the objects are added (id=0), 52 * the modified is ignored and the object is added to the server. 53 * the modified is ignored and the object is added to the server. 53 54 */ 54 55 public boolean modified = false; … … 66 67 */ 67 68 public boolean visible = true; 68 69 /** 69 70 /** 70 71 * User that last modified this primitive, as specified by the server. 71 72 * Never changed by JOSM. 72 73 */ 73 74 public User user = null; 74 75 75 76 /** 76 77 * true if this object is considered "tagged". To be "tagged", an object 77 78 * must have one or more "non-standard" tags. "created_by" and "source" 78 * are typically considered "standard" tags and do not make an object 79 * are typically considered "standard" tags and do not make an object 79 80 * "tagged". 80 81 */ 81 82 public boolean tagged = false; 82 83 83 84 /** 84 85 * true if this object has direction dependent tags (e.g. oneway) 85 86 */ 86 87 public boolean hasDirectionKeys = false; 87 88 88 89 /** 89 90 * If set to true, this object is currently selected. … … 97 98 */ 98 99 public String timestamp = null; 99 100 /** 101 * The timestamp is only parsed when this is really necessary, and this 100 101 /** 102 * The timestamp is only parsed when this is really necessary, and this 102 103 * is the cache for the result. 103 104 */ 104 105 public Date parsedTimestamp = null; 105 106 106 107 /** 107 108 * If set to true, this object is incomplete, which means only the id 108 109 * and type is known (type is the objects instance class) 109 110 */ 110 public boolean incomplete = false; 111 112 /** 111 public boolean incomplete = false; 112 113 /** 113 114 * Contains the version number as returned by the API. Needed to 114 115 * ensure update consistency 115 116 */ 116 117 public int version = -1; 117 118 118 119 /** 119 120 * Contains a list of "uninteresting" keys that do not make an object 120 121 * "tagged". 121 * /122 public static Collection<String> uninteresting =123 new HashSet<String>(Arrays.asList(new String[] {"source", "note", "converted_by", "created_by"}));124 122 * Initialized by checkTagged() 123 */ 124 private static Collection<String> uninteresting = null; 125 125 126 /** 126 127 * Contains a list of direction-dependent keys that make an object 127 128 * direction dependent. 128 * /129 public static Collection<String> directionKeys =130 new HashSet<String>(Arrays.asList(new String[] {"oneway", "incline", "incline_steep", "aerialway"}));131 129 * Initialized by checkDirectionTagged() 130 */ 131 private static Collection<String> directionKeys = null; 132 132 133 /** 133 134 * Implementation of the visitor scheme. Subclasses have to call the correct … … 142 143 modified = true; 143 144 } 144 145 145 146 /** 146 147 * Returns the timestamp for this object, or the current time if none is set. … … 157 158 } 158 159 return parsedTimestamp; 159 160 161 /** 162 * Equal, if the id (and class) is equal. 163 * 160 } 161 162 /** 163 * Equal, if the id (and class) is equal. 164 * 164 165 * An primitive is equal to its incomplete counter part. 165 166 */ 166 167 168 169 170 171 172 167 @Override public boolean equals(Object obj) { 168 if (id == 0) return obj == this; 169 if (obj instanceof OsmPrimitive) { // not null too 170 return ((OsmPrimitive)obj).id == id && obj.getClass() == getClass(); 171 } 172 return false; 173 } 173 174 174 175 /** 175 176 * Return the id plus the class type encoded as hashcode or super's hashcode if id is 0. 176 * 177 * 177 178 * An primitive has the same hashcode as its incomplete counterpart. 178 179 */ … … 204 205 } 205 206 checkTagged(); 206 207 checkDirectionTagged(); 207 208 } 208 209 /** … … 216 217 } 217 218 checkTagged(); 218 219 checkDirectionTagged(); 219 220 } 220 221 … … 256 257 257 258 /** 258 * Perform an equality compare for all non-volatile fields not only for the id 259 * Perform an equality compare for all non-volatile fields not only for the id 259 260 * but for the whole object (for conflict resolving) 260 261 * @param semanticOnly if <code>true</code>, modified flag and timestamp are not compared … … 264 265 id == osm.id && 265 266 incomplete == osm.incomplete && 266 (semanticOnly || (modified == osm.modified)) && 267 (semanticOnly || (modified == osm.modified)) && 267 268 deleted == osm.deleted && 268 269 (semanticOnly || (timestamp == null ? osm.timestamp==null : timestamp.equals(osm.timestamp))) && … … 272 273 (keys == null ? osm.keys==null : keys.equals(osm.keys)); 273 274 } 274 275 275 276 public String getTimeStr() { 276 277 return timestamp == null ? null : new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(timestamp); 277 278 } 278 279 279 280 /** 280 281 * Updates the "tagged" flag. "keys" property should probably be made private … … 283 284 public void checkTagged() { 284 285 tagged = false; 286 if(uninteresting == null) 287 uninteresting = new HashSet<String>(Arrays.asList(Main.pref.get("tags.uninteresting", 288 "source;note;converted_by;created_by").split(";"))); 285 289 if (keys != null) { 286 290 for (Entry<String,String> e : keys.entrySet()) { … … 292 296 } 293 297 } 294 /** 295 * Updates the "hasDirectionKeys" flag. "keys" property should probably be made private 296 * to make sure this gets called when keys are set. 297 */ 298 public void checkDirectionTagged() { 299 hasDirectionKeys = false; 300 if (keys != null) { 301 for (Entry<String,String> e : keys.entrySet()) { 302 if (directionKeys.contains(e.getKey())) { 303 hasDirectionKeys = true; 304 break; 305 } 306 } 307 } 308 309 } 310 298 /** 299 * Updates the "hasDirectionKeys" flag. "keys" property should probably be made private 300 * to make sure this gets called when keys are set. 301 */ 302 public void checkDirectionTagged() { 303 hasDirectionKeys = false; 304 if(directionKeys == null) 305 directionKeys = new HashSet<String>(Arrays.asList(Main.pref.get("tags.direction", 306 "oneway;incline;incline_step;aerialway").split(";"))); 307 if (keys != null) { 308 for (Entry<String,String> e : keys.entrySet()) { 309 if (directionKeys.contains(e.getKey())) { 310 hasDirectionKeys = true; 311 break; 312 } 313 } 314 } 315 } 311 316 } -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r655 r795 110 110 } else { 111 111 Main.pref.load(); 112 113 // this is temporary code to ease the transition to built-in mappaint114 List<String> plugins = new LinkedList<String>();115 if (Main.pref.hasKey("plugins"))116 plugins.addAll(Arrays.asList(Main.pref.get("plugins").split(",")));117 118 if (plugins.contains("mappaint")) {119 plugins.remove("mappaint");120 // XXX is there really no "public static String.join" or something?121 StringBuilder tmp = new StringBuilder();122 for (String p : plugins) { if (tmp.length()>0) tmp.append(","); tmp.append(p); }123 Main.pref.put("plugins", tmp.toString());124 Main.pref.put("draw.wireframe", false);125 } else if (!Main.pref.hasKey("draw.wireframe")) {126 Main.pref.put("draw.wireframe", true);127 }128 112 } 129 113 } catch (final IOException e1) { -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r768 r795 195 195 // TODO move code to an "action" like the others? 196 196 final JCheckBoxMenuItem wireframe = new JCheckBoxMenuItem(tr("Wireframe view")); 197 wireframe.setSelected(Main.pref.getBoolean("draw.wireframe", true)); 197 wireframe.setSelected(Main.pref.getBoolean("draw.wireframe", false)); 198 198 wireframe.setAccelerator(KeyStroke.getKeyStroke("ctrl W")); 199 199 wireframe.addActionListener(new ActionListener() { -
trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r774 r795 422 422 // menu. 423 423 if (TaggingPresetPreference.taggingPresets.size() > 0 && 424 Main.pref.getBoolean("taggingpreset s.in-properties-dialog", false)) {424 Main.pref.getBoolean("taggingpreset.in-properties-dialog", false)) { 425 425 Vector<ActionListener> allPresets = new Vector<ActionListener>(); 426 426 for (final TaggingPreset p : TaggingPresetPreference.taggingPresets) -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r786 r795 148 148 @Override public void paint(final Graphics g, final MapView mv) { 149 149 boolean inactive = Main.map.mapView.getActiveLayer() != this && Main.pref.getBoolean("draw.data.inactive_color", true); 150 if (Main.pref.getBoolean("draw.data.downloaded_area", false)) {150 if (Main.pref.getBoolean("draw.data.downloaded_area", true)) { 151 151 // FIXME this is inefficient; instead a proper polygon has to be built, and instead 152 152 // of drawing the outline, the outlying areas should perhaps be shaded. -
trunk/src/org/openstreetmap/josm/gui/preferences/AdvancedPreference.java
r627 r795 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Component; 6 7 import java.awt.Dimension; 7 8 import java.awt.GridBagLayout; … … 22 23 import javax.swing.JTable; 23 24 import javax.swing.JTextField; 25 import javax.swing.table.DefaultTableCellRenderer; 24 26 import javax.swing.table.DefaultTableModel; 25 27 … … 30 32 31 33 private Map<String,String> orig; 34 private Map<String,String> defaults; 32 35 private DefaultTableModel model; 33 36 … … 35 38 JPanel p = gui.createPreferenceTab("advanced", tr("Advanced Preferences"), tr("Setting Preference entries directly. Use with caution!")); 36 39 37 model = new DefaultTableModel(new String[]{ "Key", "Value"},0) {40 model = new DefaultTableModel(new String[]{tr("Key"), tr("Value")},0) { 38 41 @Override public boolean isCellEditable(int row, int column) { 39 42 return column != 0; 40 43 } 41 44 }; 45 DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(){ 46 public Component getTableCellRendererComponent(JTable table, Object value, 47 boolean isSelected, boolean hasFocus, int row, int column) 48 { 49 JLabel label=new JLabel(); 50 String s = defaults.get((String)value); 51 if(s != null) 52 { 53 if(s.equals(model.getValueAt(row, 1))) 54 label.setToolTipText(tr("Current value is default.")); 55 else 56 label.setToolTipText(tr("Default value is ''{0}''.", s)); 57 } 58 else 59 label.setToolTipText(tr("Default value currently unknown (setting has not been used yet).")); 60 label.setText((String)value); 61 return label; 62 }; 63 }; 42 64 final JTable list = new JTable(model); 65 list.getColumn(tr("Key")).setCellRenderer(renderer); 43 66 JScrollPane scroll = new JScrollPane(list); 44 67 p.add(scroll, GBC.eol().fill(GBC.BOTH)); … … 46 69 47 70 orig = Main.pref.getAllPrefix(""); 71 defaults = Main.pref.getDefaults(); 48 72 orig.remove("osm-server.password"); 73 TreeSet<String> ts = new TreeSet<String>(orig.keySet()); 74 for (String s : defaults.keySet()) 75 { 76 if(!ts.contains(s)) 77 ts.add(s); 78 } 49 79 50 for (String s : new TreeSet<String>(orig.keySet())) 51 model.addRow(new String[]{s, Main.pref.get(s)}); 80 for (String s : ts) 81 { 82 String val = Main.pref.get(s); 83 if(val == null) val = ""; 84 model.addRow(new String[]{s, val}); 85 } 52 86 53 87 JButton add = new JButton(tr("Add")); … … 85 119 return; 86 120 } 87 while (list.getSelectedRow() != -1)88 model. removeRow(list.getSelectedRow());121 for(int row: list.getSelectedRows()) 122 model.setValueAt("", row, 1); 89 123 } 90 124 }); … … 100 134 public void ok() { 101 135 for (int i = 0; i < model.getRowCount(); ++i) { 102 String key = model.getValueAt(i,0).toString();103 136 String value = model.getValueAt(i,1).toString(); 104 String origValue = orig.get(key); 105 if (origValue == null || !origValue.equals(value)) 106 Main.pref.put(key, value); 107 orig.remove(key); // processed. 137 if(value.length() != 0) 138 { 139 String key = model.getValueAt(i,0).toString(); 140 String origValue = orig.get(key); 141 if (origValue == null || !origValue.equals(value)) 142 Main.pref.put(key, value); 143 orig.remove(key); // processed. 144 } 108 145 } 109 146 for (Entry<String, String> e : orig.entrySet()) -
trunk/src/org/openstreetmap/josm/gui/preferences/AudioPreference.java
r627 r795 135 135 gui.audio.add(audioMarkersFromStart, GBC.eol().insets(10,0,0,0)); 136 136 137 audioForwardBackAmount.setText(Main.pref.get("audio.forwardbackamount", "10 "));137 audioForwardBackAmount.setText(Main.pref.get("audio.forwardbackamount", "10.0")); 138 138 audioForwardBackAmount.setToolTipText(tr("The number of seconds to jump forward or back when the relevant button is pressed")); 139 139 gui.audio.add(new JLabel(tr("Forward/back time (seconds)")), GBC.std());
Note:
See TracChangeset
for help on using the changeset viewer.