Changeset 28446 in osm for applications/editors/josm/plugins/pdfimport
- Timestamp:
- 2012-06-19T22:18:52+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/pdfimport
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pdfimport/.classpath
r23863 r28446 2 2 <classpath> 3 3 <classpathentry kind="src" path="src"/> 4 <classpathentry kind="src" path="resources"/> 4 5 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 5 6 <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/> -
applications/editors/josm/plugins/pdfimport/build.xml
r27852 r28446 33 33 <property name="commit.message" value="Initial pdfimport version"/> 34 34 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 35 <property name="plugin.main.version" value=" 4980"/>35 <property name="plugin.main.version" value="5236"/> 36 36 <!-- compilation properties --> 37 37 <property name="josm.build.dir" value="../../core"/> … … 113 113 </target> 114 114 <!-- 115 ************************** Publishing the plugin *********************************** 115 ************************** Publishing the plugin *********************************** 116 116 --> 117 117 <!-- 118 ** extracts the JOSM release for the JOSM version in ../core and saves it in the 118 ** extracts the JOSM release for the JOSM version in ../core and saves it in the 119 119 ** property ${coreversion.info.entry.revision} 120 120 ** … … 162 162 </target> 163 163 <!-- 164 ** commits the plugin.jar 164 ** commits the plugin.jar 165 165 --> 166 166 <target name="commit-dist"> 167 167 <echo> 168 168 ***** Properties of published ${plugin.jar} ***** 169 Commit message : '${commit.message}' 169 Commit message : '${commit.message}' 170 170 Plugin-Mainversion: ${plugin.main.version} 171 171 JOSM build version: ${coreversion.info.entry.revision} 172 172 Plugin-Version : ${version.entry.commit.revision} 173 ***** / Properties of published ${plugin.jar} ***** 174 173 ***** / Properties of published ${plugin.jar} ***** 174 175 175 Now commiting ${plugin.jar} ... 176 176 </echo> -
applications/editors/josm/plugins/pdfimport/src/pdfimport/FilePlacement.java
r25546 r28446 5 5 import java.awt.geom.AffineTransform; 6 6 import java.awt.geom.Point2D; 7 import java.util.Arrays;8 import java.util.Collection;9 7 import java.util.Properties; 10 8 … … 13 11 import org.openstreetmap.josm.data.coor.LatLon; 14 12 import org.openstreetmap.josm.data.projection.Projection; 15 import org.openstreetmap.josm.data.projection.ProjectionSubPrefs; 16 import org.openstreetmap.josm.data.projection.Projections; 17 import org.openstreetmap.josm.tools.Utils; 13 import org.openstreetmap.josm.data.projection.ProjectionInfo; 18 14 19 15 public class FilePlacement { … … 46 42 } 47 43 48 private String fromCollection(Collection<String> val) {49 if (val != null && !val.isEmpty())50 return Utils.join("\u001e", val);51 return null;52 }53 54 private Collection<String> toCollection(String s) {55 if (s != null && s.length() != 0) {56 return Arrays.asList(s.split("\u001e", -1));57 }58 return null;59 }60 61 44 public Properties toProperties() { 62 45 Properties p = new Properties(); 63 46 if (projection != null) { 64 p.setProperty("Projection", projection.getClass().getCanonicalName()); 65 66 if (projection instanceof ProjectionSubPrefs) { 67 ProjectionSubPrefs projPrefs = (ProjectionSubPrefs) projection; 68 String code = projection.toCode(); 69 String prefs = fromCollection(projPrefs.getPreferencesFromCode(code)); 70 if (prefs != null) { 71 p.setProperty("ProjectionPrefs", prefs); 72 } 73 } 47 p.setProperty("Projection", projection.toCode()); 74 48 } 75 49 … … 87 61 88 62 public void fromProperties(Properties p){ 89 90 String className = p.getProperty("Projection", null); 91 projection = null; 92 93 if (className != null) { 94 for(Projection proj: Projections.getProjections()){ 95 if (proj.getClass().getCanonicalName().equals(className)){ 96 projection = proj; 97 break; 98 } 99 } 100 if (projection instanceof ProjectionSubPrefs) { 101 ProjectionSubPrefs projPrefs = (ProjectionSubPrefs) projection; 102 103 String s; 104 s = p.getProperty("ProjectionPrefs", null); 105 Collection<String> prefs = toCollection(s); 106 if (prefs != null) { 107 projPrefs.setPreferences(prefs); 108 } 109 } 63 String projectionCode = p.getProperty("Projection", null); 64 if (projectionCode != null) { 65 projection = ProjectionInfo.getProjectionByCode(projectionCode); 66 } else { 67 projection = null; 110 68 } 111 69 -
applications/editors/josm/plugins/pdfimport/src/pdfimport/LoadPdfDialog.java
r25527 r28446 1 1 package pdfimport; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 3 5 import java.awt.BorderLayout; 4 import static org.openstreetmap.josm.tools.I18n.tr;5 6 6 import java.awt.Color; 7 7 import java.awt.Component; … … 24 24 import java.util.Collection; 25 25 import java.util.Properties; 26 26 27 import javax.swing.AbstractAction; 27 28 28 import javax.swing.BorderFactory; 29 29 import javax.swing.BoxLayout; … … 50 50 import org.openstreetmap.josm.data.osm.Node; 51 51 import org.openstreetmap.josm.data.osm.OsmPrimitive; 52 import org.openstreetmap.josm.data.projection.Projection; 53 import org.openstreetmap.josm.data.projection.Projections; 54 import org.openstreetmap.josm.data.projection.ProjectionSubPrefs; 52 import org.openstreetmap.josm.gui.SideButton; 55 53 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 54 import org.openstreetmap.josm.gui.preferences.projection.ProjectionChoice; 55 import org.openstreetmap.josm.gui.preferences.projection.ProjectionPreference; 56 56 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 57 57 import org.openstreetmap.josm.gui.progress.ProgressRenderer; 58 58 import org.openstreetmap.josm.gui.progress.SwingRenderingProgressMonitor; 59 import org.openstreetmap.josm.gui.SideButton;60 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction;61 59 import org.openstreetmap.josm.io.OsmExporter; 62 60 import org.openstreetmap.josm.tools.ImageProvider; … … 82 80 } 83 81 82 @Override 84 83 public void setCustomText(String message) { 85 84 this.pBar.setString(this.title + message); 86 85 } 87 86 87 @Override 88 88 public void setIndeterminate(boolean indeterminate) { 89 89 this.pBar.setIndeterminate(indeterminate); 90 90 } 91 91 92 @Override 92 93 public void setMaximum(int maximum) { 93 94 this.pBar.setMaximum(maximum); 94 95 } 95 96 97 @Override 96 98 public void setTaskTitle(String taskTitle) { 97 99 this.title = taskTitle; … … 99 101 } 100 102 103 @Override 101 104 public void setValue(int value) { 102 105 this.pBar.setValue(value); … … 168 171 169 172 this.projectionCombo.addActionListener(new ActionListener() { 173 @Override 170 174 public void actionPerformed(ActionEvent e) { 171 175 updateProjectionPrefButton(); … … 174 178 }); 175 179 this.projectionPreferencesButton.addActionListener(new ActionListener() { 180 @Override 176 181 public void actionPerformed(ActionEvent e) { 177 182 showProjectionPreferences(); … … 180 185 181 186 this.loadFileButton.addActionListener(new ActionListener() { 187 @Override 182 188 public void actionPerformed(ActionEvent e) { 183 189 loadFilePressed(); … … 186 192 187 193 this.okButton.addActionListener(new ActionListener() { 194 @Override 188 195 public void actionPerformed(ActionEvent e) { 189 196 okPressed(); … … 192 199 193 200 this.saveButton.addActionListener(new ActionListener() { 201 @Override 194 202 public void actionPerformed(ActionEvent e) { 195 203 savePressed(); … … 198 206 199 207 this.showButton.addActionListener(new ActionListener() { 208 @Override 200 209 public void actionPerformed(ActionEvent e) { 201 210 showPressed(); … … 204 213 205 214 this.cancelButton.addActionListener(new ActionListener() { 215 @Override 206 216 public void actionPerformed(ActionEvent e) { 207 217 cancelPressed(); … … 218 228 219 229 this.getMinButton.addActionListener(new ActionListener() { 230 @Override 220 231 public void actionPerformed(ActionEvent e) { 221 232 getMinPressed(); … … 224 235 225 236 this.getMaxButton.addActionListener(new ActionListener() { 237 @Override 226 238 public void actionPerformed(ActionEvent e) { 227 239 getMaxPressed(); … … 236 248 237 249 this.projectionCombo = new JComboBox(); 238 this.projectionCombo.addItem(tr("Select projection...")); 239 for (Projection p: Projections.getProjections()) { 250 for (ProjectionChoice p: ProjectionPreference.getProjectionChoices()) { 240 251 this.projectionCombo.addItem(p); 241 252 } … … 419 430 420 431 private class ProjectionSubPrefsDialog extends JDialog { 421 private Projection SubPrefsprojPref;432 private final ProjectionChoice projPref; 422 433 private OKAction actOK; 423 434 private CancelAction actCancel; 424 435 private JPanel projPrefPanel; 425 436 426 public ProjectionSubPrefsDialog(Component parent, Projection SubPrefspr) {437 public ProjectionSubPrefsDialog(Component parent, ProjectionChoice pr) { 427 438 super(JOptionPane.getFrameForComponent(parent), ModalityType.DOCUMENT_MODAL); 428 439 … … 442 453 443 454 protected JPanel buildInputForm() { 444 JPanel pnl = new JPanel(); 445 projPref.setupPreferencePanel(pnl, null); 446 return pnl; 455 return projPref.getPreferencePanel(null); 447 456 } 448 457 … … 480 489 } 481 490 491 @Override 482 492 public void actionPerformed(ActionEvent e) { 483 493 projPref.setPreferences(projPref.getPreferences(projPrefPanel)); … … 493 503 } 494 504 505 @Override 495 506 public void actionPerformed(ActionEvent e) { 496 507 setVisible(false); … … 512 523 513 524 private void updateProjectionPrefButton() { 514 Object proj = projectionCombo.getSelectedItem(); 515 525 // ProjectionChoice proj = (ProjectionChoice) projectionCombo.getSelectedItem(); 526 527 //TODO 516 528 // Enable/disable pref button 517 if(!(proj instanceof ProjectionSubPrefs)) { 518 projectionPreferencesButton.setEnabled(false); 519 } else { 529 // if(!(proj instanceof ProjectionSubPrefs)) { 530 // projectionPreferencesButton.setEnabled(false); 531 // } else { 520 532 projectionPreferencesButton.setEnabled(true); 521 } 533 // } 522 534 } 523 535 524 536 private void showProjectionPreferences() { 525 Object proj = projectionCombo.getSelectedItem(); 526 527 if(proj instanceof ProjectionSubPrefs) { 528 ProjectionSubPrefsDialog dlg = 529 new ProjectionSubPrefsDialog(this, (ProjectionSubPrefs)proj); 530 dlg.setVisible(true); 531 } 537 ProjectionChoice proj = (ProjectionChoice) projectionCombo.getSelectedItem(); 538 539 ProjectionSubPrefsDialog dlg = new ProjectionSubPrefsDialog(this, proj); 540 dlg.setVisible(true); 541 532 542 } 533 543 … … 546 556 this.runAsBackgroundTask( 547 557 new Runnable() { 558 @Override 548 559 public void run() { 549 560 //async part … … 563 574 new ActionListener() { 564 575 576 @Override 565 577 public void actionPerformed(ActionEvent e) { 566 578 //sync part … … 608 620 this.runAsBackgroundTask( 609 621 new Runnable() { 622 @Override 610 623 public void run() { 611 624 //async part … … 617 630 new ActionListener() { 618 631 632 @Override 619 633 public void actionPerformed(ActionEvent e) { 620 634 //sync part … … 643 657 this.runAsBackgroundTask( 644 658 new Runnable() { 659 @Override 645 660 public void run() { 646 661 //async part … … 652 667 new ActionListener() { 653 668 669 @Override 654 670 public void actionPerformed(ActionEvent e) { 655 671 //sync part … … 769 785 Thread t = new Thread(new Runnable() 770 786 { 787 @Override 771 788 public void run() { 772 789 task.run(); 773 790 774 791 SwingUtilities.invokeLater(new Runnable(){ 792 @Override 775 793 public void run() { 776 794 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); … … 930 948 931 949 private FilePlacement parsePlacement() { 932 ObjectselectedProjection = this.projectionCombo.getSelectedItem();933 934 if ( !(selectedProjectioninstanceof Projection))950 ProjectionChoice selectedProjection = (ProjectionChoice) this.projectionCombo.getSelectedItem(); 951 952 if (selectedProjection == null) 935 953 { 936 954 JOptionPane.showMessageDialog(Main.parent, tr("Please set a projection.")); … … 940 958 FilePlacement placement = new FilePlacement(); 941 959 942 placement.projection = (Projection)this.projectionCombo.getSelectedItem();960 placement.projection = selectedProjection.getProjection(); 943 961 944 962 try … … 970 988 } 971 989 972 this.projectionCombo.setSelectedItem(placement.projection); 990 if (placement.projection != null) { 991 String projectionCode = placement.projection.toCode(); 992 BIG_LOOP: 993 for (ProjectionChoice projectionChoice: ProjectionPreference.getProjectionChoices()) { 994 for (String code: projectionChoice.allCodes()) { 995 if (code.equals(projectionCode)) { 996 projectionChoice.getPreferencesFromCode(projectionCode); 997 this.projectionCombo.setSelectedItem(projectionChoice); 998 break BIG_LOOP; 999 } 1000 } 1001 } 1002 } 1003 973 1004 this.minXField.setText(Double.toString(placement.minX)); 974 1005 this.maxXField.setText(Double.toString(placement.maxX));
Note:
See TracChangeset
for help on using the changeset viewer.