Changeset 26493 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-08-08T22:20:43+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerAbstract.java
r26489 r26493 29 29 import java.awt.Toolkit; 30 30 import java.awt.event.ActionEvent; 31 import java.io.BufferedReader; 31 32 import java.io.File; 32 33 import java.io.FileInputStream; 34 import java.io.FileReader; 33 35 import java.io.IOException; 34 36 import java.util.List; … … 135 137 // Load image completely 136 138 (new ImageIcon(m_image)).getImage(); 139 140 lookForCalibration(); 137 141 } 138 142 … … 145 149 protected abstract Image createImage() throws IOException; 146 150 151 protected abstract void lookForCalibration() throws IOException; 147 152 /** 148 153 * To be overridden by subclasses. Returns the user readable name of the layer. … … 435 440 Main.map.mapView.repaint(); 436 441 } 442 443 public void loadWorldfile(File file) throws IOException { 444 FileReader reader = new FileReader(file); 445 BufferedReader br = new BufferedReader(reader); 446 double e[] = new double[6]; 447 for (int i=0; i<6; ++i) { 448 String line = br.readLine(); 449 e[i] = Double.parseDouble(line); 450 } 451 double sx=e[0], ry=e[1], rx=e[2], sy=e[3], dx=e[4], dy=e[5]; 452 int w = m_image.getWidth(null); 453 int h = m_image.getHeight(null); 454 m_position.setLocation( 455 dx + w/2*sx + h/2*rx, 456 dy + w/2*ry + h/2*sy 457 ); 458 m_initial_position.setLocation(m_position); 459 m_angle = 0; 460 m_scalex = 100*sx*getMetersPerEasting(m_position); 461 m_scaley = -100*sy*getMetersPerNorthing(m_position); 462 m_shearx = rx / sx; 463 m_sheary = ry / sy; 464 m_initial_scale = 1; 465 Main.map.mapView.repaint(); 466 } 437 467 438 468 private class ResetSubmenuAction extends AbstractAction implements LayerAction { -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromClipboard.java
r23190 r26493 66 66 } 67 67 68 @Override 69 protected void lookForCalibration() throws IOException { 70 } 71 68 72 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerFromFile.java
r24300 r26493 28 28 import java.io.File; 29 29 import java.io.IOException; 30 import java.util.Arrays; 30 31 import javax.imageio.ImageIO; 31 import javax.swing.JDialog;32 32 import javax.swing.JOptionPane; 33 33 /** … … 66 66 Image image = null; 67 67 image = ImageIO.read( m_file ); 68 68 return image; 69 } 70 71 @Override 72 protected void lookForCalibration() throws IOException { 69 73 // Manage a potential existing calibration file 70 74 File calFile = getDefaultCalPath(); … … 104 108 if ( loadcal ) 105 109 loadCalibration(calFile); 110 } else { 111 112 // try to find and load world file 113 int dotIdx = m_file.getName().lastIndexOf("."); 114 if (dotIdx == -1) return; 115 String extension = m_file.getName().substring(dotIdx); 116 String namepart = m_file.getName().substring(0, dotIdx); 117 String[][] imgExtensions = new String[][] { 118 { ".jpg", ".jpeg" }, 119 { ".png" }, 120 { ".tif", ".tiff" }, 121 { ".bmp" }, 122 }; 123 String[][] wldExtensions = new String[][] { 124 { ".wld", ".jgw", ".jpgw" }, 125 { ".wld", ".pgw", ".pngw" }, 126 { ".wld", ".tfw", ".tifw" }, 127 { ".wld", ".bmpw", ".bpw"}, 128 }; 129 for (int i=0; i<imgExtensions.length; ++i) { 130 if (Arrays.asList(imgExtensions[i]).contains(extension.toLowerCase())) { 131 for (String wldExtension : wldExtensions[i]) { 132 File wldFile = new File(m_file.getParentFile(), namepart+wldExtension); 133 if (wldFile.exists()) { 134 System.out.println("Loading world file: "+wldFile); 135 loadWorldfile(wldFile); 136 return; 137 } 138 } 139 } 140 } 106 141 } 107 108 return image;109 142 } 110 143
Note:
See TracChangeset
for help on using the changeset viewer.