Changeset 5634 in josm
- Timestamp:
- 2012-12-26T15:47:43+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/projection/Projections.java
r5554 r5634 7 7 import java.io.InputStreamReader; 8 8 import java.util.Collection; 9 import java.util.Collections; 9 10 import java.util.HashMap; 11 import java.util.HashSet; 10 12 import java.util.Map; 13 import java.util.Set; 11 14 import java.util.regex.Matcher; 12 15 import java.util.regex.Pattern; … … 113 116 114 117 public static String getInit(String id) { 115 return inits.get(id.to LowerCase()).b;118 return inits.get(id.toUpperCase()).b; 116 119 } 117 120 … … 132 135 Matcher m = epsgPattern.matcher(line); 133 136 if (m.matches()) { 134 inits.put(" epsg:" + m.group(1), Pair.create(name, m.group(2).trim()));137 inits.put("EPSG:" + m.group(1), Pair.create(name, m.group(2).trim())); 135 138 } else { 136 139 System.err.println("Warning: failed to parse line from the epsg projection definition: "+line); … … 144 147 } 145 148 146 private final static Map<String, ProjectionChoice> allCodesPC = new HashMap<String, ProjectionChoice>(); 147 private final static Map<String, Projection> allCodes = new HashMap<String, Projection>(); 149 private final static Set<String> allCodes = new HashSet<String>(); 150 private final static Map<String, ProjectionChoice> allProjectionChoicesByCode = new HashMap<String, ProjectionChoice>(); 151 private final static Map<String, Projection> projectionsByCode_cache = new HashMap<String, Projection>(); 148 152 149 153 static { 150 // FIXME: use {@link #inits}, because it may contain more codes in future151 // than exposed by the ProjectionChoices152 154 for (ProjectionChoice pc : ProjectionPreference.getProjectionChoices()) { 153 155 for (String code : pc.allCodes()) { 154 all CodesPC.put(code, pc);156 allProjectionChoicesByCode.put(code, pc); 155 157 } 156 158 } 159 allCodes.addAll(inits.keySet()); 160 allCodes.addAll(allProjectionChoicesByCode.keySet()); 157 161 } 158 162 159 163 public static Projection getProjectionByCode(String code) { 160 Projection p = allCodes.get(code); 161 if (p != null) return p; 162 ProjectionChoice pc = allCodesPC.get(code); 163 if (pc == null) return null; 164 Collection<String> pref = pc.getPreferencesFromCode(code); 165 pc.setPreferences(pref); 166 p = pc.getProjection(); 167 allCodes.put(code, p); 168 return p; 164 Projection proj = projectionsByCode_cache.get(code); 165 if (proj != null) return proj; 166 ProjectionChoice pc = allProjectionChoicesByCode.get(code); 167 if (pc != null) { 168 Pair<String, String> pair = inits.get(code); 169 if (pair == null) return null; 170 String name = pair.a; 171 String init = pair.b; 172 proj = new CustomProjection(name, code, init, null); 173 } else { 174 Collection<String> pref = pc.getPreferencesFromCode(code); 175 pc.setPreferences(pref); 176 proj = pc.getProjection(); 177 } 178 projectionsByCode_cache.put(code, proj); 179 return proj; 180 } 181 182 public static Collection<String> getAllProjectionCodes() { 183 return Collections.unmodifiableCollection(allCodes); 169 184 } 170 185 -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/CustomProjectionChoice.java
r5548 r5634 245 245 return false; 246 246 } 247 248 @Override 249 public boolean showProjectionName() { 250 return false; 251 } 247 252 } -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreference.java
r5631 r5634 204 204 205 205 /************************ 206 * Projection by Code. 207 */ 208 registerProjectionChoice(new CodeProjectionChoice()); 209 210 /************************ 206 211 * Custom projection. 207 212 */ … … 265 270 private Component projectionCodeGlue; 266 271 private JLabel projectionCode = new JLabel(); 272 private JLabel projectionNameLabel; 273 private Component projectionNameGlue; 274 private JLabel projectionName = new JLabel(); 267 275 private JLabel bounds = new JLabel(); 268 276 … … 304 312 projPanel.add(projectionCodeGlue = GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 305 313 projPanel.add(projectionCode, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); 314 projPanel.add(projectionNameLabel = new JLabel(tr("Projection name")), GBC.std().insets(25,5,0,5)); 315 projPanel.add(projectionNameGlue = GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); 316 projPanel.add(projectionName, GBC.eop().fill(GBC.HORIZONTAL).insets(0,5,5,5)); 306 317 projPanel.add(new JLabel(tr("Bounds")), GBC.std().insets(25,5,0,5)); 307 318 projPanel.add(GBC.glue(5,0), GBC.std().fill(GBC.HORIZONTAL)); … … 328 339 Projection proj = pc.getProjection(); 329 340 projectionCode.setText(proj.toCode()); 341 projectionName.setText(proj.toString()); 330 342 Bounds b = proj.getWorldBoundsLatLon(); 331 343 CoordinateFormat cf = CoordinateFormat.getDefaultFormat(); 332 344 bounds.setText(b.getMin().lonToString(cf)+", "+b.getMin().latToString(cf)+" : "+b.getMax().lonToString(cf)+", "+b.getMax().latToString(cf)); 333 345 boolean showCode = true; 346 boolean showName = false; 334 347 if (pc instanceof SubPrefsOptions) { 335 348 showCode = ((SubPrefsOptions) pc).showProjectionCode(); 349 showName = ((SubPrefsOptions) pc).showProjectionName(); 336 350 } 337 351 projectionCodeLabel.setVisible(showCode); 338 352 projectionCodeGlue.setVisible(showCode); 339 353 projectionCode.setVisible(showCode); 354 projectionNameLabel.setVisible(showName); 355 projectionNameGlue.setVisible(showName); 356 projectionName.setVisible(showName); 340 357 } 341 358 -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/SubPrefsOptions.java
r5234 r5634 11 11 */ 12 12 boolean showProjectionCode(); 13 14 /** 15 * @return true, if the projection name should be displayed in the top panel 16 */ 17 boolean showProjectionName(); 13 18 }
Note:
See TracChangeset
for help on using the changeset viewer.