Changeset 1747 in josm for trunk/src/org
- Timestamp:
- 2009-07-08T15:26:12+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/CachedLatLon.java
r1728 r1747 16 16 super(coor.lat(), coor.lon()); 17 17 proj = null; 18 } 19 20 public CachedLatLon(EastNorth eastNorth) { 21 super(Main.proj.eastNorth2latlon(eastNorth)); 22 proj = Main.proj; 23 this.eastNorth = eastNorth; 18 24 } 19 25 -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r1731 r1747 37 37 38 38 public final void setEastNorth(EastNorth eastNorth) { 39 coor.setEastNorth(eastNorth); 39 if(eastNorth != null) 40 { 41 if(coor != null) 42 coor.setEastNorth(eastNorth); 43 else 44 coor = new CachedLatLon(eastNorth); 45 } 40 46 } 41 47 42 48 public final EastNorth getEastNorth() { 43 return coor .getEastNorth();49 return coor != null ? coor.getEastNorth() : null; 44 50 } 45 51 -
trunk/src/org/openstreetmap/josm/gui/mappaint/AreaElemStyle.java
r1629 r1747 14 14 this.maxScale = maxScale; 15 15 this.minScale = minScale; 16 this.rules = a.rules; 16 17 } 17 18 … … 23 24 this.maxScale = a.maxScale; 24 25 this.minScale = a.minScale; 26 this.rules = a.rules; 25 27 this.line = l; 26 28 this.code = a.code; -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java
r1743 r1747 19 19 public Boolean equals(ElemStyle s) 20 20 { 21 return s != null && s.code.equals(code); 21 return s != null && s.getCode().equals(getCode()); 22 } 23 public String getCode() 24 { 25 if(code == null && rules != null) 26 { 27 code = ""; 28 for(Rule r: rules) 29 code += r.toCode(); 30 } 31 return code; 22 32 } 23 33 public boolean check(Map<String, String> keys) -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyleHandler.java
r1743 r1747 155 155 if(rule.rules == null) 156 156 rule.rules = new LinkedList<Rule>(); 157 rule.rules.add(new Rule(rule.rule)); 157 158 r = new Rule(); 158 r.init();159 159 rule.rules.add(r); 160 160 } … … 230 230 if(hadLine) 231 231 { 232 rule.line.rules = rule.rules; 233 styles.add(styleName, rule.rule, 232 styles.add(styleName, rule.rule, rule.rules, 234 233 new LineElemStyle(rule.line, rule.scaleMax, rule.scaleMin)); 235 234 } 236 235 if(hadLineMod) 237 236 { 238 rule.linemod.rules = rule.rules; 239 styles.addModifier(styleName, rule.rule, 237 styles.addModifier(styleName, rule.rule, rule.rules, 240 238 new LineElemStyle(rule.linemod, rule.scaleMax, rule.scaleMin)); 241 239 } 242 240 if(hadIcon) 243 241 { 244 rule.icon.rules = rule.rules; 245 styles.add(styleName, rule.rule, 242 styles.add(styleName, rule.rule, rule.rules, 246 243 new IconElemStyle(rule.icon, rule.scaleMax, rule.scaleMin)); 247 244 } 248 245 if(hadArea) 249 246 { 250 rule.area.rules = rule.rules; 251 styles.add(styleName, rule.rule, 247 styles.add(styleName, rule.rule, rule.rules, 252 248 new AreaElemStyle(rule.area, rule.scaleMax, rule.scaleMin)); 253 249 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r1743 r1747 1 1 package org.openstreetmap.josm.gui.mappaint; 2 2 3 import java.util.Collection; 3 4 import java.util.Collections; 4 5 import java.util.HashMap; … … 21 22 private HashMap<String, AreaElemStyle> areas; 22 23 private HashMap<String, LineElemStyle> modifiers; 24 private LinkedList<IconElemStyle> iconsList; 25 private LinkedList<LineElemStyle> linesList; 26 private LinkedList<AreaElemStyle> areasList; 27 private LinkedList<LineElemStyle> modifiersList; 23 28 public StyleSet() 24 29 { … … 27 32 modifiers = new HashMap<String, LineElemStyle>(); 28 33 areas = new HashMap<String, AreaElemStyle>(); 34 iconsList = new LinkedList<IconElemStyle>(); 35 linesList = new LinkedList<LineElemStyle>(); 36 modifiersList = new LinkedList<LineElemStyle>(); 37 areasList = new LinkedList<AreaElemStyle>(); 29 38 } 30 39 private IconElemStyle getNode(Map<String, String> keys) … … 39 48 if((style = icons.get("n" + key + "=" + val)) != null) 40 49 { 41 if( (ret == null || style.priority > ret.priority) && style.check(keys))50 if(ret == null || style.priority > ret.priority) 42 51 ret = style; 43 52 } 44 53 if((style = icons.get("b" + key + "=" + OsmUtils.getNamedOsmBoolean(val))) != null) 45 54 { 46 if( (ret == null || style.priority > ret.priority) && style.check(keys))55 if(ret == null || style.priority > ret.priority) 47 56 ret = style; 48 57 } 49 58 if((style = icons.get("x" + key)) != null) 50 59 { 51 if( (ret == null || style.priority > ret.priority) && style.check(keys))60 if(ret == null || style.priority > ret.priority) 52 61 ret = style; 53 62 } 63 } 64 for(IconElemStyle s : iconsList) 65 { 66 if((ret == null || s.priority > ret.priority) && s.check(keys)) 67 ret = s; 54 68 } 55 69 return ret; … … 71 85 if((styleArea = areas.get(idx)) != null && (retArea == null 72 86 || styleArea.priority > retArea.priority) && (!noclosed 73 || !styleArea.closed) && styleArea.check(keys))87 || !styleArea.closed)) 74 88 retArea = styleArea; 75 89 if((styleLine = lines.get(idx)) != null && (retLine == null 76 || styleLine.priority > retLine.priority) && styleLine.check(keys))90 || styleLine.priority > retLine.priority)) 77 91 { 78 92 retLine = styleLine; 79 93 linestring = idx; 80 94 } 81 if((styleLine = modifiers.get(idx)) != null && styleLine.check(keys))95 if((styleLine = modifiers.get(idx)) != null) 82 96 over.put(idx, styleLine); 83 97 idx = "b" + key + "=" + OsmUtils.getNamedOsmBoolean(val); 84 98 if((styleArea = areas.get(idx)) != null && (retArea == null 85 99 || styleArea.priority > retArea.priority) && (!noclosed 86 || !styleArea.closed) && styleArea.check(keys))100 || !styleArea.closed)) 87 101 retArea = styleArea; 88 102 if((styleLine = lines.get(idx)) != null && (retLine == null 89 || styleLine.priority > retLine.priority) && styleLine.check(keys))103 || styleLine.priority > retLine.priority)) 90 104 { 91 105 retLine = styleLine; 92 106 linestring = idx; 93 107 } 94 if((styleLine = modifiers.get(idx)) != null && styleLine.check(keys))108 if((styleLine = modifiers.get(idx)) != null) 95 109 over.put(idx, styleLine); 96 110 idx = "x" + key; 97 111 if((styleArea = areas.get(idx)) != null && (retArea == null 98 112 || styleArea.priority > retArea.priority) && (!noclosed 99 || !styleArea.closed) && styleArea.check(keys))113 || !styleArea.closed)) 100 114 retArea = styleArea; 101 115 if((styleLine = lines.get(idx)) != null && (retLine == null 102 || styleLine.priority > retLine.priority) && styleLine.check(keys))116 || styleLine.priority > retLine.priority)) 103 117 { 104 118 retLine = styleLine; 105 119 linestring = idx; 106 120 } 107 if((styleLine = modifiers.get(idx)) != null && styleLine.check(keys))121 if((styleLine = modifiers.get(idx)) != null) 108 122 over.put(idx, styleLine); 123 } 124 for(AreaElemStyle s : areasList) 125 { 126 if((retArea == null || s.priority > retArea.priority) 127 && (!noclosed || !s.closed) && s.check(keys)) 128 retArea = s; 129 } 130 for(LineElemStyle s : linesList) 131 { 132 if((retLine == null || s.priority > retLine.priority) 133 && s.check(keys)) 134 retLine = s; 135 } 136 for(LineElemStyle s : modifiersList) 137 { 138 if(s.check(keys)) 139 over.put(s.getCode(), s); 109 140 } 110 141 over.remove(linestring); … … 167 198 return true; 168 199 } 200 for(AreaElemStyle s : areasList) 201 { 202 if(!(s.closed && noclosed) && s.check(o.keys)) 203 return true; 204 } 169 205 } 170 206 return false; … … 183 219 } 184 220 185 public void add(String name, Rule r, LineElemStyle style) 186 { 187 String key = r.getKey(); 188 style.code = key; 189 getStyleSet(name, true).lines.put(key, style); 190 } 191 192 public void addModifier(String name, Rule r, LineElemStyle style) 193 { 194 String key = r.getKey(); 195 style.code = key; 196 getStyleSet(name, true).modifiers.put(key, style); 197 } 198 199 public void add(String name, Rule r, AreaElemStyle style) 200 { 201 String key = r.getKey(); 202 style.code = key; 203 getStyleSet(name, true).areas.put(key, style); 204 } 205 206 public void add(String name, Rule r, IconElemStyle style) 207 { 208 String key = r.getKey(); 209 style.code = key; 210 getStyleSet(name, true).icons.put(key, style); 221 public void add(String name, Rule r, Collection<Rule> rules, LineElemStyle style) 222 { 223 if(rules != null) 224 { 225 style.rules = rules; 226 getStyleSet(name, true).linesList.add(style); 227 } 228 else 229 { 230 String key = r.getKey(); 231 style.code = key; 232 getStyleSet(name, true).lines.put(key, style); 233 } 234 } 235 236 public void addModifier(String name, Rule r, Collection<Rule> rules, LineElemStyle style) 237 { 238 if(rules != null) 239 { 240 style.rules = rules; 241 getStyleSet(name, true).modifiersList.add(style); 242 } 243 else 244 { 245 String key = r.getKey(); 246 style.code = key; 247 getStyleSet(name, true).modifiers.put(key, style); 248 } 249 } 250 251 public void add(String name, Rule r, Collection<Rule> rules, AreaElemStyle style) 252 { 253 if(rules != null) 254 { 255 style.rules = rules; 256 getStyleSet(name, true).areasList.add(style); 257 } 258 else 259 { 260 String key = r.getKey(); 261 style.code = key; 262 getStyleSet(name, true).areas.put(key, style); 263 } 264 } 265 266 public void add(String name, Rule r, Collection<Rule> rules, IconElemStyle style) 267 { 268 if(rules != null) 269 { 270 style.rules = rules; 271 getStyleSet(name, true).iconsList.add(style); 272 } 273 else 274 { 275 String key = r.getKey(); 276 style.code = key; 277 getStyleSet(name, true).icons.put(key, style); 278 } 211 279 } 212 280 -
trunk/src/org/openstreetmap/josm/gui/mappaint/IconElemStyle.java
r1169 r1747 13 13 this.maxScale = maxScale; 14 14 this.minScale = minScale; 15 this.rules = i.rules; 15 16 } 16 17 public IconElemStyle() { init(); } -
trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java
r1635 r1747 30 30 this.maxScale = maxScale; 31 31 this.minScale = minScale; 32 this.rules = s.rules; 32 33 } 33 34 … … 44 45 this.maxScale = s.maxScale; 45 46 this.minScale = s.minScale; 47 this.rules = s.rules; 46 48 47 49 this.overlays = overlays; -
trunk/src/org/openstreetmap/josm/gui/mappaint/Rule.java
r1743 r1747 9 9 String boolValue; 10 10 11 public Rule() 12 { 13 init(); 14 } 15 public Rule(Rule r) 16 { 17 key = r.key; 18 value = r.value; 19 boolValue = r.boolValue; 20 } 11 21 public String getKey() 12 22 { … … 23 33 } 24 34 35 public String toString() 36 { 37 return "Rule["+key+","+(boolValue != null ? "b="+boolValue:"v="+value)+"]"; 38 } 39 public String toCode() 40 { 41 return "[k="+key+(boolValue != null ? ",b="+boolValue:",v="+value)+"]"; 42 } 25 43 } 26 27 28 -
trunk/src/org/openstreetmap/josm/gui/preferences/ProjectionPreference.java
r1743 r1747 54 54 projPanel.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 )); 55 55 projPanel.setLayout(new GridBagLayout()); 56 projPanel.add(new JLabel(tr("Display coordinates as")), GBC.std().insets(5,5,0,5)); 57 projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 58 projPanel.add(coordinatesCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); 56 59 projPanel.add(new JLabel(tr("Projection method")), GBC.std().insets(5,5,0,5)); 57 60 projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 58 61 projPanel.add(projectionCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); 59 projPanel.add(new JLabel(tr("Display coordinates as")), GBC.std().insets(5,5,0,5));60 projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL));61 projPanel.add(coordinatesCombo, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5));62 62 projPanel.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.BOTH)); 63 63 JScrollPane scrollpane = new JScrollPane(projPanel); -
trunk/src/org/openstreetmap/josm/gui/preferences/StyleSources.java
r1743 r1747 95 95 } 96 96 97 public StyleSources(String pref, String iconpref, String url, boolean named, final String name)97 public StyleSources(String pref, String iconpref, final String url, boolean named, final String name) 98 98 { 99 99 sourcesList = new JList(new DefaultListModel()); … … 199 199 ((DefaultListModel)sourcesList.getModel()).addElement( 200 200 ((SourceInfo)sourcesDefaults.getSelectedValue()).url); 201 } 202 } 203 }); 204 205 JButton update = new JButton(tr("Update")); 206 update.addActionListener(new ActionListener(){ 207 public void actionPerformed(ActionEvent e) { 208 MirroredInputStream.cleanup(url); 209 getDefaults(url); 210 int num = sourcesList.getModel().getSize(); 211 if (num > 0) 212 { 213 ArrayList<String> l = new ArrayList<String>(); 214 for (int i = 0; i < num; ++i) 215 MirroredInputStream.cleanup((String)sourcesList.getModel().getElementAt(i)); 201 216 } 202 217 } … … 219 234 buttonPanel.add(edit, GBC.std().insets(5,5,5,0)); 220 235 buttonPanel.add(delete, GBC.std().insets(0,5,5,0)); 221 buttonPanel.add(copy, GBC.std().insets(0,5,0,0)); 236 buttonPanel.add(copy, GBC.std().insets(0,5,5,0)); 237 buttonPanel.add(update, GBC.std().insets(0,5,0,0)); 222 238 if(iconsList != null) 223 239 { … … 265 281 public void getDefaults(String name) 266 282 { 283 ((DefaultListModel)sourcesDefaults.getModel()).removeAllElements(); 267 284 String lang = Main.getLanguageCode()+"_"; 268 285 try -
trunk/src/org/openstreetmap/josm/io/MirroredInputStream.java
r1743 r1747 62 62 { 63 63 return file; 64 } 65 66 static public void cleanup(String name) 67 { 68 cleanup(name, null); 69 } 70 static public void cleanup(String name, String destDir) 71 { 72 URL url; 73 try { 74 url = new URL(name); 75 if (!url.getProtocol().equals("file")) 76 { 77 String localPath = Main.pref.get("mirror." + url); 78 if (localPath != null && localPath.length() > 0) 79 { 80 String[] lp = localPath.split(";"); 81 File lfile = new File(lp[1]); 82 if(lfile.exists()) 83 lfile.delete(); 84 } 85 Main.pref.put("mirror." + url, null); 86 } 87 } catch (java.net.MalformedURLException e) {} 64 88 } 65 89
Note:
See TracChangeset
for help on using the changeset viewer.