Changeset 34445 in osm for applications/editors/josm/plugins/ImportImagePlugin/src
- Timestamp:
- 2018-08-10T00:01:05+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayer.java
r34219 r34445 223 223 } catch (ArrayIndexOutOfBoundsException e) { 224 224 // TODO: prevents this to happen when displaying GeoTIFF images (see #7902) 225 e.printStackTrace();225 Logging.error(e); 226 226 } 227 227 -
applications/editors/josm/plugins/ImportImagePlugin/src/org/openstreetmap/josm/plugins/ImportImagePlugin/LayerPropertiesDialog.java
r34219 r34445 8 8 import java.awt.GridBagLayout; 9 9 import java.awt.Rectangle; 10 import java.awt.event.KeyAdapter; 10 11 import java.awt.event.KeyEvent; 11 12 import java.io.File; … … 31 32 import org.geotools.referencing.CRS; 32 33 import org.opengis.referencing.FactoryException; 33 import org.opengis.referencing.NoSuchAuthorityCodeException;34 34 import org.opengis.referencing.crs.CoordinateReferenceSystem; 35 35 import org.openstreetmap.josm.tools.Logging; … … 109 109 } 110 110 111 112 111 /** 113 112 * This method initializes this … … 118 117 this.setContentPane(getMainPanel()); 119 118 this.setPreferredSize(new Dimension(404, 485)); 120 121 119 } 122 120 … … 353 351 okButton.setBounds(new Rectangle(134, 5, 136, 31)); 354 352 okButton.setText("OK"); 355 okButton.addActionListener(new java.awt.event.ActionListener() { 356 @Override 357 public void actionPerformed(java.awt.event.ActionEvent e) { 358 setVisible(false); 359 dispose(); 360 } 361 }); 353 okButton.addActionListener(e -> { 354 setVisible(false); 355 dispose(); 356 }); 362 357 } 363 358 return okButton; … … 374 369 searchField.setBounds(new Rectangle(13, 111, 282, 20)); 375 370 searchField.setToolTipText("Enter keywords or EPSG codes"); 376 searchField.addKeyListener(new java.awt.event.KeyAdapter() {371 searchField.addKeyListener(new KeyAdapter() { 377 372 @Override 378 public void keyTyped( java.awt.event.KeyEvent e) {373 public void keyTyped(KeyEvent e) { 379 374 380 375 for (Iterator<String> iterator = supportedCRS.iterator(); iterator.hasNext();) { … … 430 425 useDefaultCRSButton.setBounds(new Rectangle(253, 54, 118, 28)); 431 426 useDefaultCRSButton.setText("Apply Default"); 432 useDefaultCRSButton.addActionListener(new java.awt.event.ActionListener() { 433 @Override 434 public void actionPerformed(java.awt.event.ActionEvent e) { 435 try { 436 437 setCursor(new Cursor(Cursor.WAIT_CURSOR)); 438 if (PluginOperations.defaultSourceCRS != null) { 439 imageLayer.resample(PluginOperations.defaultSourceCRS); 440 } else { 441 JOptionPane.showMessageDialog(getContentPane(), 442 "<html>No default reference system available.<br>Please select one from the list</html>"); 427 useDefaultCRSButton.addActionListener(e -> { 428 try { 429 setCursor(new Cursor(Cursor.WAIT_CURSOR)); 430 if (PluginOperations.defaultSourceCRS != null) { 431 imageLayer.resample(PluginOperations.defaultSourceCRS); 432 } else { 433 JOptionPane.showMessageDialog(getContentPane(), 434 "<html>No default reference system available.<br>Please select one from the list</html>"); 435 } 436 } catch (FactoryException | IOException e1) { 437 Logging.error(e1); 438 } finally { 439 setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); 443 440 } 444 445 } catch (NoSuchAuthorityCodeException e1) { 446 // TODO Auto-generated catch block 447 e1.printStackTrace(); 448 } catch (FactoryException e1) { 449 // TODO Auto-generated catch block 450 e1.printStackTrace(); 451 } catch (IOException e2) { 452 // TODO Auto-generated catch block 453 e2.printStackTrace(); 454 } finally { 455 setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); 456 } 457 } 458 }); 441 }); 459 442 } 460 443 return useDefaultCRSButton; … … 473 456 applySelectedCRSButton.setHorizontalTextPosition(SwingConstants.TRAILING); 474 457 applySelectedCRSButton.setText("<html>Apply<br>Selection</html>"); 475 applySelectedCRSButton.addActionListener(new java.awt.event.ActionListener() { 476 @Override 477 public void actionPerformed(java.awt.event.ActionEvent e) { 478 479 String selection = crsJList.getSelectedValue(); 480 String code = selection.substring(selection.indexOf("[-") + 2, selection.indexOf("-]")); 481 482 CoordinateReferenceSystem newRefSys = null; 483 try { 484 newRefSys = CRS.decode(code, eastingFirstCheckBox.isSelected()); 485 486 setCursor(new Cursor(Cursor.WAIT_CURSOR)); 487 488 imageLayer.resample(newRefSys); 489 490 } catch (NoSuchAuthorityCodeException e1) { 491 // TODO Auto-generated catch block 492 e1.printStackTrace(); 493 } catch (FactoryException e1) { 494 // TODO Auto-generated catch block 495 e1.printStackTrace(); 496 } catch (IOException e2) { 497 // TODO Auto-generated catch block 498 e2.printStackTrace(); 499 } finally { 500 setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); 501 } 502 } 503 }); 458 applySelectedCRSButton.addActionListener(e -> { 459 460 String selection = crsJList.getSelectedValue(); 461 String code = selection.substring(selection.indexOf("[-") + 2, selection.indexOf("-]")); 462 463 try { 464 CoordinateReferenceSystem newRefSys = CRS.decode(code, eastingFirstCheckBox.isSelected()); 465 setCursor(new Cursor(Cursor.WAIT_CURSOR)); 466 imageLayer.resample(newRefSys); 467 } catch (FactoryException | IOException e1) { 468 Logging.error(e1); 469 } finally { 470 setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); 471 } 472 }); 504 473 } 505 474 return applySelectedCRSButton; … … 516 485 setSelectedCRSAsDefaultButton.setBounds(new Rectangle(315, 300, 69, 61)); 517 486 setSelectedCRSAsDefaultButton.setText("<html>Set as<br>Default</html>"); 518 setSelectedCRSAsDefaultButton 519 .addActionListener(new java.awt.event.ActionListener() { 520 @Override 521 public void actionPerformed(java.awt.event.ActionEvent e) { 522 523 if (crsJList.getSelectedValue() != null) { 524 String selection = crsJList.getSelectedValue(); 525 String code = selection.substring(selection.indexOf("[-") + 2, selection.indexOf("-]")); 526 527 try { 528 PluginOperations.defaultSourceCRS = CRS.decode(code, eastingFirstCheckBox.isSelected()); 529 PluginOperations.defaultSourceCRSDescription = selection; 530 531 ImportImagePlugin.pluginProps.setProperty("default_crs_eastingfirst", 532 "" + eastingFirstCheckBox.isSelected()); 533 ImportImagePlugin.pluginProps.setProperty("default_crs_srid", code); 534 try (FileWriter fileWriter = new FileWriter(new File(ImportImagePlugin.PLUGINPROPERTIES_PATH))) { 535 ImportImagePlugin.pluginProps.store(fileWriter, null); 536 } 537 538 defaultCRSLabel.setText(selection); 539 540 } catch (IOException | FactoryException e2) { 541 Logging.error(e2); 487 setSelectedCRSAsDefaultButton.addActionListener(e -> { 488 if (crsJList.getSelectedValue() != null) { 489 String selection = crsJList.getSelectedValue(); 490 String code = selection.substring(selection.indexOf("[-") + 2, selection.indexOf("-]")); 491 492 try { 493 PluginOperations.defaultSourceCRS = CRS.decode(code, eastingFirstCheckBox.isSelected()); 494 PluginOperations.defaultSourceCRSDescription = selection; 495 496 ImportImagePlugin.pluginProps.setProperty("default_crs_eastingfirst", 497 "" + eastingFirstCheckBox.isSelected()); 498 ImportImagePlugin.pluginProps.setProperty("default_crs_srid", code); 499 try (FileWriter fileWriter = new FileWriter(new File(ImportImagePlugin.PLUGINPROPERTIES_PATH))) { 500 ImportImagePlugin.pluginProps.store(fileWriter, null); 542 501 } 543 } else { 544 JOptionPane.showMessageDialog(getContentPane(), "Please make a selection from the list."); 502 503 defaultCRSLabel.setText(selection); 504 505 } catch (IOException | FactoryException e2) { 506 Logging.error(e2); 545 507 } 508 } else { 509 JOptionPane.showMessageDialog(getContentPane(), "Please make a selection from the list."); 546 510 } 547 511 });
Note:
See TracChangeset
for help on using the changeset viewer.