Ignore:
Timestamp:
2007-08-17T01:30:51+02:00 (17 years ago)
Author:
brent
Message:

Tidied up

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  
    1919package org.openstreetmap.josm.plugins.lakewalker;
    2020
     21import java.text.DecimalFormat;
     22
    2123/**
    2224 * A Configurer for Double values
     
    2426public class DoubleConfigurer extends StringConfigurer {
    2527
     28  final static DecimalFormat df = new DecimalFormat("##0.0000000");
     29 
    2630  public DoubleConfigurer() {
    2731    super();
     
    3337
    3438  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));
    3640  }
    3741
     
    4852    }
    4953    if (!noUpdate && nameField != null) {
    50       nameField.setText(d.toString());
     54      nameField.setText(df.format(d));
    5155    }
    5256  }
    5357
    5458  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);
    5663  }
    5764}
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java

    r4095 r4189  
    4646  protected Cursor oldCursor;
    4747  protected List<Node> selectedNodes;
     48  protected Thread executeThread;
    4849 
    4950  public LakewalkerAction(String name) {
     
    5253    this.name = name;
    5354    setEnabled(true);
    54 
    5555  }
    5656
     
    106106    target += " --maxnodes=" + Main.pref.get(LakewalkerPreferences.PREF_MAX_NODES, "50000");
    107107    target += " --threshold=" + Main.pref.get(LakewalkerPreferences.PREF_THRESHOLD, "35");
     108    target += " --dp-epsilon=" + Main.pref.get(LakewalkerPreferences.PREF_EPSILON, "0.0003");
    108109    target += " --josm";
    109 
    110 
    111    
    112 
    113110
    114111    try {
     
    118115      Runtime rt = Runtime.getRuntime();
    119116      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);
    121118      final BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
    122119     
     
    135132        @Override protected void cancel() {
    136133          reader.cancel();
    137          
     134          executeThread.interrupt();
     135          p.destroy();
    138136        }
    139137      };
    140       Main.worker.execute(lakewalkerTask);
     138      Thread executeThread = new Thread(lakewalkerTask);
     139      executeThread.start();
    141140    }
    142141    catch (Exception ex) {
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java

    r4095 r4189  
    1818  public static final String PREF_MAX_NODES = "lakewalker.max_nodes";
    1919  public static final String PREF_THRESHOLD = "lakewalker.threshold";
     20  public static final String PREF_EPSILON = "lakewalker.epsilon";
    2021 
    2122  protected JTextField python = new JTextField(10);
     
    2324  protected IntConfigurer maxNodes = new IntConfigurer();
    2425  protected IntConfigurer threshold = new IntConfigurer();
     26  protected DoubleConfigurer epsilon = new DoubleConfigurer();
    2527 
    2628  public void addGui(PreferenceDialog gui) {
    2729    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   
    3135    String description = tr("An interlude to the Lakewalker Python module to trace water bodies on Landsat imagery.<br><br>Version: {0}", LakewalkerPlugin.VERSION);
    3236   
    3337    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) {
    3448    prefPanel.add(new JLabel(tr("Python executable")), GBC.std().insets(10,5,5,0));
    3549    prefPanel.add(python, GBC.eol().insets(0,5,0,0).fill(GBC.HORIZONTAL));
     
    4054    prefPanel.add(new JLabel(tr("Maximum gray value to count as water")), GBC.std().insets(10,5,5,0));
    4155    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
    4759  }
    4860
     
    5264    Main.pref.put(PREF_MAX_NODES, maxNodes.getValueString());
    5365    Main.pref.put(PREF_THRESHOLD, threshold.getValueString());
     66    Main.pref.put(PREF_EPSILON, epsilon.getValueString());
    5467  }
    5568 
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java

    r4095 r4189  
    8989          commands.add(new AddCommand(s));
    9090          way.segments.add(s);
     91          way.put("created_by", "Dshpak_landsat_lakes");
    9192          commands.add(new AddCommand(way));
    9293          break;
     
    103104      Main.ds.setSelected(ways);
    104105    }
    105 
    106 
    107106  }
    108107 
Note: See TracChangeset for help on using the changeset viewer.