Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
- Timestamp:
- 2015-06-20T23:42:21+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
r8444 r8510 57 57 protected void buildDownloadAreaInputFields() { 58 58 latlon = new JosmTextField[4]; 59 for (int i=0; i< 4; i++) {59 for (int i = 0; i < 4; i++) { 60 60 latlon[i] = new JosmTextField(11); 61 latlon[i].setMinimumSize(new Dimension(100, new JosmTextField().getMinimumSize().height));61 latlon[i].setMinimumSize(new Dimension(100, new JosmTextField().getMinimumSize().height)); 62 62 latlon[i].addFocusListener(new SelectAllOnFocusHandler(latlon[i])); 63 63 } … … 95 95 tfOsmUrl.setBorder(latlon[0].getBorder()); 96 96 97 dlg.add(new JLabel(tr("min lat")), GBC.std().insets(10, 20,5,0));98 dlg.add(latlon[0], GBC.std().insets(0, 20,0,0));99 dlg.add(new JLabel(tr("min lon")), GBC.std().insets(10, 20,5,0));100 dlg.add(latlon[1], GBC.eol().insets(0, 20,0,0));101 dlg.add(new JLabel(tr("max lat")), GBC.std().insets(10, 0,5,0));97 dlg.add(new JLabel(tr("min lat")), GBC.std().insets(10, 20, 5, 0)); 98 dlg.add(latlon[0], GBC.std().insets(0, 20, 0, 0)); 99 dlg.add(new JLabel(tr("min lon")), GBC.std().insets(10, 20, 5, 0)); 100 dlg.add(latlon[1], GBC.eol().insets(0, 20, 0, 0)); 101 dlg.add(new JLabel(tr("max lat")), GBC.std().insets(10, 0, 5, 0)); 102 102 dlg.add(latlon[2], GBC.std()); 103 dlg.add(new JLabel(tr("max lon")), GBC.std().insets(10, 0,5,0));103 dlg.add(new JLabel(tr("max lon")), GBC.std().insets(10, 0, 5, 0)); 104 104 dlg.add(latlon[3], GBC.eol()); 105 105 … … 111 111 } 112 112 }); 113 dlg.add(btnClear, GBC.eol().insets(10,20,0,0)); 114 115 dlg.add(new JLabel(tr("URL from www.openstreetmap.org (you can paste an URL here to download the area)")), GBC.eol().insets(10,5,5,0)); 116 dlg.add(tfOsmUrl, GBC.eop().insets(10,0,5,0).fill()); 117 dlg.add(showUrl, GBC.eop().insets(10,0,5,5)); 113 dlg.add(btnClear, GBC.eol().insets(10, 20, 0, 0)); 114 115 dlg.add(new JLabel(tr("URL from www.openstreetmap.org (you can paste an URL here to download the area)")), 116 GBC.eol().insets(10, 5, 5, 0)); 117 dlg.add(tfOsmUrl, GBC.eop().insets(10, 0, 5, 0).fill()); 118 dlg.add(showUrl, GBC.eop().insets(10, 0, 5, 5)); 118 119 showUrl.setEditable(false); 119 120 showUrl.setBackground(dlg.getBackground()); … … 136 137 public Bounds getDownloadArea() { 137 138 double[] values = new double[4]; 138 for (int i =0; i < 4; i++) {139 for (int i = 0; i < 4; i++) { 139 140 try { 140 141 values[i] = Double.parseDouble(latlon[i].getText()); 141 } catch (NumberFormatException x) {142 } catch (NumberFormatException x) { 142 143 return null; 143 144 } … … 152 153 private boolean parseURL(DownloadDialog gui) { 153 154 Bounds b = OsmUrlToBounds.parse(tfOsmUrl.getText()); 154 if (b == null) return false;155 gui.boundingBoxChanged(b, BoundingBoxSelection.this);155 if (b == null) return false; 156 gui.boundingBoxChanged(b, BoundingBoxSelection.this); 156 157 updateBboxFields(b); 157 158 updateUrl(b); … … 198 199 try { 199 200 value = Double.parseDouble(tfLatValue.getText()); 200 } catch (NumberFormatException ex) {201 setErrorMessage(tfLatValue, tr("The string ''{0}'' is not a valid double value.", tfLatValue.getText()));201 } catch (NumberFormatException ex) { 202 setErrorMessage(tfLatValue, tr("The string ''{0}'' is not a valid double value.", tfLatValue.getText())); 202 203 return; 203 204 } 204 205 if (!LatLon.isValidLat(value)) { 205 setErrorMessage(tfLatValue, tr("Value for latitude in range [-90,90] required.", tfLatValue.getText()));206 setErrorMessage(tfLatValue, tr("Value for latitude in range [-90,90] required.", tfLatValue.getText())); 206 207 return; 207 208 } … … 231 232 try { 232 233 value = Double.parseDouble(tfLonValue.getText()); 233 } catch (NumberFormatException ex) {234 setErrorMessage(tfLonValue, tr("The string ''{0}'' is not a valid double value.", tfLonValue.getText()));234 } catch (NumberFormatException ex) { 235 setErrorMessage(tfLonValue, tr("The string ''{0}'' is not a valid double value.", tfLonValue.getText())); 235 236 return; 236 237 } 237 238 if (!LatLon.isValidLon(value)) { 238 setErrorMessage(tfLonValue, tr("Value for longitude in range [-180,180] required.", tfLonValue.getText()));239 setErrorMessage(tfLonValue, tr("Value for longitude in range [-180,180] required.", tfLonValue.getText())); 239 240 return; 240 241 } … … 255 256 static class SelectAllOnFocusHandler extends FocusAdapter { 256 257 private JTextComponent tfTarget; 258 257 259 public SelectAllOnFocusHandler(JTextComponent tfTarget) { 258 260 this.tfTarget = tfTarget; … … 267 269 class OsmUrlRefresher implements DocumentListener { 268 270 @Override 269 public void changedUpdate(DocumentEvent e) { parseURL(parent); } 270 @Override 271 public void insertUpdate(DocumentEvent e) { parseURL(parent); } 272 @Override 273 public void removeUpdate(DocumentEvent e) { parseURL(parent); } 271 public void changedUpdate(DocumentEvent e) { 272 parseURL(parent); 273 } 274 275 @Override 276 public void insertUpdate(DocumentEvent e) { 277 parseURL(parent); 278 } 279 280 @Override 281 public void removeUpdate(DocumentEvent e) { 282 parseURL(parent); 283 } 274 284 } 275 285 276 286 class BoundingBoxBuilder extends FocusAdapter implements ActionListener { 277 287 protected Bounds build() { 278 double minlon, minlat, maxlon, maxlat;288 double minlon, minlat, maxlon, maxlat; 279 289 try { 280 290 minlat = Double.parseDouble(latlon[0].getText().trim()); … … 282 292 maxlat = Double.parseDouble(latlon[2].getText().trim()); 283 293 maxlon = Double.parseDouble(latlon[3].getText().trim()); 284 } catch (NumberFormatException e) {294 } catch (NumberFormatException e) { 285 295 return null; 286 296 } … … 292 302 if (minlat > maxlat) 293 303 return null; 294 return new Bounds(minlat, minlon,maxlat,maxlon);304 return new Bounds(minlat, minlon, maxlat, maxlon); 295 305 } 296 306
Note:
See TracChangeset
for help on using the changeset viewer.