Changeset 4189 in osm for applications/editors/josm/plugins/lakewalker
- Timestamp:
- 2007-08-17T01:30:51+02:00 (17 years ago)
- Location:
- applications/editors/josm/plugins/lakewalker
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/DoubleConfigurer.java
r4095 r4189 19 19 package org.openstreetmap.josm.plugins.lakewalker; 20 20 21 import java.text.DecimalFormat; 22 21 23 /** 22 24 * A Configurer for Double values … … 24 26 public class DoubleConfigurer extends StringConfigurer { 25 27 28 final static DecimalFormat df = new DecimalFormat("##0.0000000"); 29 26 30 public DoubleConfigurer() { 27 31 super(); … … 33 37 34 38 public DoubleConfigurer(String key, String name, Double val) { 35 super(key, name, val == null ? null : val.toString());39 super(key, name, val == null ? null : df.format(val)); 36 40 } 37 41 … … 48 52 } 49 53 if (!noUpdate && nameField != null) { 50 nameField.setText(d .toString());54 nameField.setText(df.format(d)); 51 55 } 52 56 } 53 57 54 58 public String getValueString() { 55 return value == null ? null : value.toString(); 59 if (value == null || value.equals("")) { 60 return (String) value; 61 } 62 return df.format(value); 56 63 } 57 64 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java
r4095 r4189 46 46 protected Cursor oldCursor; 47 47 protected List<Node> selectedNodes; 48 protected Thread executeThread; 48 49 49 50 public LakewalkerAction(String name) { … … 52 53 this.name = name; 53 54 setEnabled(true); 54 55 55 } 56 56 … … 106 106 target += " --maxnodes=" + Main.pref.get(LakewalkerPreferences.PREF_MAX_NODES, "50000"); 107 107 target += " --threshold=" + Main.pref.get(LakewalkerPreferences.PREF_THRESHOLD, "35"); 108 target += " --dp-epsilon=" + Main.pref.get(LakewalkerPreferences.PREF_EPSILON, "0.0003"); 108 109 target += " --josm"; 109 110 111 112 113 110 114 111 try { … … 118 115 Runtime rt = Runtime.getRuntime(); 119 116 System.out.println("dir: " + working_dir + ", target: " + target); 120 Process p = rt.exec(target, null, working_dir);117 final Process p = rt.exec(target, null, working_dir); 121 118 final BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); 122 119 … … 135 132 @Override protected void cancel() { 136 133 reader.cancel(); 137 134 executeThread.interrupt(); 135 p.destroy(); 138 136 } 139 137 }; 140 Main.worker.execute(lakewalkerTask); 138 Thread executeThread = new Thread(lakewalkerTask); 139 executeThread.start(); 141 140 } 142 141 catch (Exception ex) { -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java
r4095 r4189 18 18 public static final String PREF_MAX_NODES = "lakewalker.max_nodes"; 19 19 public static final String PREF_THRESHOLD = "lakewalker.threshold"; 20 public static final String PREF_EPSILON = "lakewalker.epsilon"; 20 21 21 22 protected JTextField python = new JTextField(10); … … 23 24 protected IntConfigurer maxNodes = new IntConfigurer(); 24 25 protected IntConfigurer threshold = new IntConfigurer(); 26 protected DoubleConfigurer epsilon = new DoubleConfigurer(); 25 27 26 28 public void addGui(PreferenceDialog gui) { 27 29 python.setToolTipText(tr("Path to python executable.")); 28 maxSegs.setToolTipText(tr("Maximum number of segments per way.")); 29 maxNodes.setToolTipText(tr("Maximum number of nodes to trace.")); 30 maxNodes.setToolTipText(tr("Gray threshold.")); 30 maxSegs.setToolTipText(tr("Maximum nuber of nodes allowed in one way.")); 31 maxNodes.setToolTipText(tr("Maximum number of nodes to generate before bailing out (before simplifying lines).")); 32 maxNodes.setToolTipText(tr("Maximum gray value to accept as water (based on Landsat IR-1 data). Can be in the range 0-255.")); 33 epsilon.setToolTipText(tr("Accuracy of Douglas-Peucker line simplification, measured in degrees. Lower values give more nodes, and more accurate lines. Defaults to 0.0003.")); 34 31 35 String description = tr("An interlude to the Lakewalker Python module to trace water bodies on Landsat imagery.<br><br>Version: {0}", LakewalkerPlugin.VERSION); 32 36 33 37 JPanel prefPanel = gui.createPreferenceTab("lakewalker.png", I18n.tr("Lakewalker Plugin Preferences"), description); 38 buildPreferences(prefPanel); 39 40 python.setText(Main.pref.get(PREF_PYTHON, "python.exe")); 41 maxSegs.setValue(Main.pref.get(PREF_MAX_SEG, "250")); 42 maxNodes.setValue(Main.pref.get(PREF_MAX_NODES, "50000")); 43 threshold.setValue(Main.pref.get(PREF_THRESHOLD, "35")); 44 epsilon.setValue(Main.pref.get(PREF_EPSILON, "0.0003")); 45 } 46 47 public void buildPreferences(JPanel prefPanel) { 34 48 prefPanel.add(new JLabel(tr("Python executable")), GBC.std().insets(10,5,5,0)); 35 49 prefPanel.add(python, GBC.eol().insets(0,5,0,0).fill(GBC.HORIZONTAL)); … … 40 54 prefPanel.add(new JLabel(tr("Maximum gray value to count as water")), GBC.std().insets(10,5,5,0)); 41 55 prefPanel.add(threshold.getControls(), GBC.eol().insets(0,5,0,0).fill(GBC.HORIZONTAL)); 42 43 python.setText(Main.pref.get(PREF_PYTHON, "python.exe")); 44 maxSegs.setValue(Main.pref.get(PREF_MAX_SEG, "250")); 45 maxNodes.setValue(Main.pref.get(PREF_MAX_NODES, "50000")); 46 threshold.setValue(Main.pref.get(PREF_THRESHOLD, "35")); 56 prefPanel.add(new JLabel(tr("Line simplification accuracy, measured in degrees.")), GBC.std().insets(10,5,5,0)); 57 prefPanel.add(epsilon.getControls(), GBC.eol().insets(0,5,0,0).fill(GBC.HORIZONTAL)); 58 47 59 } 48 60 … … 52 64 Main.pref.put(PREF_MAX_NODES, maxNodes.getValueString()); 53 65 Main.pref.put(PREF_THRESHOLD, threshold.getValueString()); 66 Main.pref.put(PREF_EPSILON, epsilon.getValueString()); 54 67 } 55 68 -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java
r4095 r4189 89 89 commands.add(new AddCommand(s)); 90 90 way.segments.add(s); 91 way.put("created_by", "Dshpak_landsat_lakes"); 91 92 commands.add(new AddCommand(way)); 92 93 break; … … 103 104 Main.ds.setSelected(ways); 104 105 } 105 106 107 106 } 108 107
Note:
See TracChangeset
for help on using the changeset viewer.