Changeset 24060 in osm for applications/editors
- Timestamp:
- 2010-11-04T14:26:45+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java
r24056 r24060 15 15 import java.io.FileInputStream; 16 16 import java.io.FileNotFoundException; 17 import java.io.FileOutputStream; 17 18 import java.io.IOException; 18 19 import java.util.Collection; … … 46 47 public class LoadPdfDialog extends JFrame { 47 48 48 private StringfileName;49 private File fileName; 49 50 private PathOptimizer data; 50 51 private final FilePlacement placement; … … 275 276 276 277 private void loadFilePressed() { 277 final java.io.File fileName = this.chooseFile();278 279 if ( fileName == null) {278 final File newFileName = this.chooseFile(); 279 280 if (newFileName == null) { 280 281 return; 281 282 } 283 284 this.removeLayer(); 282 285 283 286 this.loadFileButton.setEnabled(false); 284 287 this.loadFileButton.setText(tr("Loading...")); 285 286 288 287 289 this.runAsBackgroundTask( 288 290 new Runnable() { 289 291 public void run() { 290 data = loadPDF( fileName);292 data = loadPDF(newFileName); 291 293 } 292 294 }, … … 295 297 public void actionPerformed(ActionEvent e) { 296 298 if (data!= null) { 299 LoadPdfDialog.this.placement.projection = null; 297 300 OsmBuilder.Mode mode = LoadPdfDialog.this.debugModeCheck.isSelected() ? OsmBuilder.Mode.Debug: OsmBuilder.Mode.Draft; 298 LoadPdfDialog.this.fileName = fileName.getAbsolutePath();301 LoadPdfDialog.this.fileName = newFileName; 299 302 LoadPdfDialog.this.makeLayer(tr("PDF file preview"), mode); 300 303 LoadPdfDialog.this.loadFileButton.setText(tr("Loaded")); 301 304 LoadPdfDialog.this.loadFileButton.setEnabled(true); 305 LoadPdfDialog.this.loadPlacement(); 306 LoadPdfDialog.this.setPlacement(); 302 307 } 303 308 } … … 308 313 private void okPressed() { 309 314 310 boolean ok = this. loadTransformation();315 boolean ok = this.parsePlacement(); 311 316 if (!ok){ 312 317 return; 313 318 } 314 319 320 this.savePlacement(); 321 315 322 //rebuild layer with latest projection 316 323 this.makeLayer(tr("Imported PDF: ") + this.fileName, OsmBuilder.Mode.Final); 324 317 325 this.setVisible(false); 318 326 } 319 327 320 328 private void savePressed() { 321 boolean ok = this. loadTransformation();329 boolean ok = this.parsePlacement(); 322 330 if (!ok){ 323 331 return; … … 329 337 return; 330 338 } 339 340 this.savePlacement(); 331 341 332 342 //rebuild layer with latest projection … … 339 349 private void showPressed() { 340 350 341 boolean ok = this. loadTransformation();351 boolean ok = this.parsePlacement(); 342 352 if (!ok){ 343 353 return; … … 532 542 data.splitLayersByPathKind(); 533 543 data.finish(); 534 535 //load saved transformation536 File propertiesFile = new File(fileName.getAbsoluteFile()+ ".placement");537 try {538 539 if (propertiesFile.exists()){540 Properties p = new Properties();541 p.load(new FileInputStream(propertiesFile));542 this.placement.fromProperties(p);543 this.setTransformation();544 }545 }catch (Exception e){546 e.printStackTrace();547 }548 549 544 return data; 550 545 } … … 552 547 553 548 554 private boolean loadTransformation() {549 private boolean parsePlacement() { 555 550 Object selectedProjection = this.projectionCombo.getSelectedItem(); 556 551 … … 584 579 } 585 580 586 private void set Transformation() {581 private void setPlacement() { 587 582 588 583 this.projectionCombo.setSelectedItem(placement.projection); … … 597 592 } 598 593 594 595 private void loadPlacement() { 596 //load saved transformation 597 File propertiesFile = new File(fileName.getAbsoluteFile()+ ".placement"); 598 try { 599 600 if (propertiesFile.exists()){ 601 Properties p = new Properties(); 602 p.load(new FileInputStream(propertiesFile)); 603 this.placement.fromProperties(p); 604 } 605 }catch (Exception e){ 606 e.printStackTrace(); 607 } 608 } 609 610 private void savePlacement(){ 611 //load saved transformation 612 File propertiesFile = new File(fileName.getAbsoluteFile()+ ".placement"); 613 try { 614 Properties p = this.placement.toProperties(); 615 p.store(new FileOutputStream(propertiesFile), "PDF file placement on OSM"); 616 } catch (Exception e){ 617 e.printStackTrace(); 618 } 619 } 620 621 599 622 private void makeLayer(String name, OsmBuilder.Mode mode) { 600 623 this.removeLayer();
Note:
See TracChangeset
for help on using the changeset viewer.