Changeset 19624 in osm
- Timestamp:
- 2010-01-25T20:22:13+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/lakewalker
- Files:
-
- 2 added
- 1 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/BooleanConfigurer.java
r13497 r19624 14 14 * 15 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, copies are available 16 * License along with this library; if not, copies are available 17 17 * at http://www.opensource.org. 18 18 */ … … 23 23 */ 24 24 public class BooleanConfigurer extends Configurer { 25 25 private javax.swing.JCheckBox box; 26 26 27 public BooleanConfigurer() { 28 this(false); 29 } 30 31 public BooleanConfigurer(boolean val) { 32 this(null, "", val); 33 } 34 35 public BooleanConfigurer(String key, String name, Boolean val) { 36 super(key, name, val); 37 } 27 public BooleanConfigurer() { 28 this(false); 29 } 38 30 39 public BooleanConfigurer(String key, String name,boolean val) {40 super(key, name, val ? Boolean.TRUE : Boolean.FALSE);41 31 public BooleanConfigurer(boolean val) { 32 this(null, "", val); 33 } 42 34 43 public BooleanConfigurer(String key, String name) {44 this(key, name, Boolean.FALSE);45 35 public BooleanConfigurer(String key, String name, Boolean val) { 36 super(key, name, val); 37 } 46 38 47 public String getValueString() {48 return booleanValue().toString();49 39 public BooleanConfigurer(String key, String name, boolean val) { 40 super(key, name, val ? Boolean.TRUE : Boolean.FALSE); 41 } 50 42 51 public void setValue(Object o) { 52 super.setValue(o); 53 if (box != null 54 && !o.equals(new Boolean(box.isSelected()))) { 55 box.setSelected(booleanValue().booleanValue()); 56 } 57 } 43 public BooleanConfigurer(String key, String name) { 44 this(key, name, Boolean.FALSE); 45 } 58 46 59 public void setValue(String s) { 60 setValue(Boolean.valueOf(s)); 61 } 47 @Override 48 public String getValueString() { 49 return booleanValue().toString(); 50 } 62 51 63 public void setName(String s) { 64 super.setName(s); 65 if (box != null) { 66 box.setText(s); 67 } 68 } 52 @Override 53 public void setValue(Object o) { 54 super.setValue(o); 55 if (box != null 56 && !o.equals(box.isSelected())) { 57 box.setSelected(booleanValue().booleanValue()); 58 } 59 } 69 60 70 public java.awt.Component getControls() { 71 if (box == null) { 72 box = new javax.swing.JCheckBox(getName()); 73 box.setSelected(booleanValue().booleanValue()); 74 box.addItemListener(new java.awt.event.ItemListener() { 75 public void itemStateChanged(java.awt.event.ItemEvent e) { 76 setValue(new Boolean(box.isSelected())); 77 } 78 }); 79 } 80 return box; 81 } 61 @Override 62 public void setValue(String s) { 63 setValue(Boolean.valueOf(s)); 64 } 82 65 83 public Boolean booleanValue() { 84 return (Boolean) value; 85 } 66 @Override 67 public void setName(String s) { 68 super.setName(s); 69 if (box != null) { 70 box.setText(s); 71 } 72 } 73 74 @Override 75 public java.awt.Component getControls() { 76 if (box == null) { 77 box = new javax.swing.JCheckBox(getName()); 78 box.setSelected(booleanValue().booleanValue()); 79 box.addItemListener(new java.awt.event.ItemListener() { 80 public void itemStateChanged(java.awt.event.ItemEvent e) { 81 setValue(box.isSelected()); 82 } 83 }); 84 } 85 return box; 86 } 87 88 public Boolean booleanValue() { 89 return (Boolean) value; 90 } 86 91 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/DoubleConfigurer.java
r18827 r19624 36 36 } 37 37 38 public void setValue(String s) { 38 @Override 39 public void setValue(String s) { 39 40 Double d = null; 40 41 try { … … 48 49 } 49 50 50 public void setValue(Object o) { 51 @Override 52 public void setValue(Object o) { 51 53 if (!noUpdate && nameField != null && o != null) { 52 54 nameField.setText(o.toString()); … … 55 57 } 56 58 57 public String getValueString() { 59 @Override 60 public String getValueString() { 58 61 if (value == null || value.equals("")) { 59 62 return null; -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/IntConfigurer.java
r18828 r19624 23 23 */ 24 24 public class IntConfigurer extends StringConfigurer { 25 26 public IntConfigurer() {27 super();28 }29 30 public IntConfigurer(String key, String name) {31 this(key, name, new Integer(0));32 }33 25 34 public IntConfigurer(String key, String name, Integer val) { 35 super(key, name); 36 if (val != null) { 37 setValue(val); 38 } 39 } 26 public IntConfigurer() { 27 super(); 28 } 40 29 41 public void setValue(String s) { 42 Integer i = null; 43 try { 44 i = Integer.valueOf(s); 45 } 46 catch (NumberFormatException e) { 47 i = null; 48 } 49 if (i != null) { 50 setValue(i); 51 } 52 } 53 54 public int getIntValue(int defaultValue) { 55 if (getValue() instanceof Integer) { 56 return ((Integer)getValue()).intValue(); 57 } 58 else { 59 return defaultValue; 60 } 61 } 30 public IntConfigurer(String key, String name) { 31 this(key, name, 0); 32 } 62 33 63 public void setValue(Object o) {64 if (!noUpdate && nameField != null && o != null) { 65 nameField.setText(o.toString()); 66 } 67 super.setValue(o); 68 34 public IntConfigurer(String key, String name, Integer val) { 35 super(key, name); 36 if (val != null) { 37 setValue(val); 38 } 39 } 69 40 70 public String getValueString() { 71 return value == null ? null : value.toString(); 72 } 41 @Override 42 public void setValue(String s) { 43 Integer i = null; 44 try { 45 i = Integer.valueOf(s); 46 } 47 catch (NumberFormatException e) { 48 i = null; 49 } 50 if (i != null) { 51 setValue(i); 52 } 53 } 54 55 public int getIntValue(int defaultValue) { 56 if (getValue() instanceof Integer) { 57 return ((Integer)getValue()).intValue(); 58 } 59 else { 60 return defaultValue; 61 } 62 } 63 64 @Override 65 public void setValue(Object o) { 66 if (!noUpdate && nameField != null && o != null) { 67 nameField.setText(o.toString()); 68 } 69 super.setValue(o); 70 } 71 72 @Override 73 public String getValueString() { 74 return value == null ? null : value.toString(); 75 } 73 76 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Lakewalker.java
r16586 r19624 5 5 import java.io.File; 6 6 import java.util.ArrayList; 7 import java.util.Collection; 8 import java.util.LinkedList; 9 10 import org.openstreetmap.josm.command.Command; 11 import org.openstreetmap.josm.data.osm.Way; 7 import java.util.List; 8 12 9 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 13 10 14 11 public class Lakewalker { 15 protected Collection<Command> commands = new LinkedList<Command>();16 protected Collection<Way> ways = new ArrayList<Way>();17 12 protected boolean cancel; 18 13 19 private int waylen;20 14 private int maxnode; 21 15 private int threshold; 22 private double epsilon;23 16 private int resolution; 24 17 private int tilesize; … … 35 28 36 29 public Lakewalker(int waylen, int maxnode, int threshold, double epsilon, int resolution, int tilesize, String startdir, String wmslayer, File workingdir){ 37 this.waylen = waylen;38 30 this.maxnode = maxnode; 39 31 this.threshold = threshold; 40 this.epsilon = epsilon;41 32 this.resolution = resolution; 42 33 this.tilesize = tilesize; … … 383 374 } 384 375 385 ArrayList<double[]> seg_a = new ArrayList<double[]>();386 ArrayList<double[]> seg_b = new ArrayList<double[]>();376 List<double[]> seg_a; 377 List<double[]> seg_b; 387 378 388 379 if(farthest_dist > epsilon){ … … 440 431 * @author Jason Reid 441 432 */ 442 private class LakewalkerBBox {433 private static class LakewalkerBBox { 443 434 444 435 private double top = 90; -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java
r18880 r19624 73 73 private void cleanupCache() { 74 74 final long maxCacheAge = System.currentTimeMillis()-Main.pref.getInteger(LakewalkerPreferences.PREF_MAXCACHEAGE, 100)*24*60*60*1000L; 75 final long maxCacheSize = Main.pref.getInteger(LakewalkerPreferences.PREF_MAXCACHESIZE, 300)*1024*1024 ;75 final long maxCacheSize = Main.pref.getInteger(LakewalkerPreferences.PREF_MAXCACHESIZE, 300)*1024*1024L; 76 76 77 77 for (String wmsFolder : LakewalkerPreferences.WMSLAYERS) { … … 177 177 progressMonitor.createSubTaskMonitor(1, false)); 178 178 } catch(LakewalkerException e){ 179 System.out.println(e.get Error());179 System.out.println(e.getMessage()); 180 180 } 181 181 … … 247 247 248 248 } catch (Exception ex) { 249 ex.printStackTrace(); 249 250 } 250 251 -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerApp.java
r16586 r19624 40 40 try { 41 41 nodelist = lw.trace(lat,lon,leftlon,rightlon,toplat,botlat, NullProgressMonitor.INSTANCE); 42 43 System.out.println(nodelist.size()+" nodes generated"); 44 45 nodelist = lw.vertexReduce(nodelist, dp); 46 47 System.out.println("After vertex reduction, "+nodelist.size()+" nodes remain."); 48 49 nodelist = lw.douglasPeucker(nodelist, dp, 0); 50 System.out.println("After dp approximation, "+nodelist.size()+" nodes remain."); 51 42 52 } catch(LakewalkerException e){ 43 System.out.println(e.getError()); 53 System.out.println(e.getMessage()); 54 e.printStackTrace(); 44 55 } 45 46 System.out.println(nodelist.size()+" nodes generated");47 48 nodelist = lw.vertexReduce(nodelist, dp);49 50 System.out.println("After vertex reduction, "+nodelist.size()+" nodes remain.");51 52 nodelist = lw.douglasPeucker(nodelist, dp, 0);53 54 System.out.println("After dp approximation, "+nodelist.size()+" nodes remain.");55 56 57 56 58 57 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerException.java
r15959 r19624 4 4 5 5 class LakewalkerException extends Exception { 6 String error;7 8 6 public LakewalkerException(){ 9 super(); 10 this.error = tr("An unknown error has occurred"); 7 super(tr("An unknown error has occurred")); 11 8 } 12 9 13 10 public LakewalkerException(String err){ 14 super(); 15 this.error = err; 16 } 17 18 public String getError(){ 19 return this.error; 11 super(err); 20 12 } 21 13 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPlugin.java
r19446 r19624 15 15 */ 16 16 public class LakewalkerPlugin extends Plugin { 17 18 19 20 17 public LakewalkerPlugin(PluginInformation info) { 18 super(info); 19 MainMenu.add(Main.main.menu.toolsMenu, new LakewalkerAction(tr("Lake Walker"))); 20 } 21 21 22 public PreferenceSetting getPreferenceSetting() 23 { 24 return new LakewalkerPreferences(); 25 } 22 @Override 23 public PreferenceSetting getPreferenceSetting() 24 { 25 return new LakewalkerPreferences(); 26 } 26 27 27 28 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java
r19294 r19624 3 3 import static org.openstreetmap.josm.tools.I18n.marktr; 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import java.awt.GridBagConstraints; 5 7 6 8 import javax.swing.Box; … … 9 11 10 12 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.gui.preferences.PreferenceDialog;12 13 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 13 14 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; … … 74 75 landsatResConfig.setToolTipText(tr("Resolution of Landsat tiles, measured in pixels per degree. Default 4000.")); 75 76 landsatSizeConfig.setToolTipText(tr("Size of one landsat tile, measured in pixels. Default 2000.")); 76 eastOffsetConfig.setToolTipText(tr("Offset all points in East direction (degrees). Default 0.")); 77 northOffsetConfig.setToolTipText(tr("Offset all points in North direction (degrees). Default 0.")); 77 eastOffsetConfig.setToolTipText(tr("Offset all points in East direction (degrees). Default 0.")); 78 northOffsetConfig.setToolTipText(tr("Offset all points in North direction (degrees). Default 0.")); 78 79 startDirConfig.setToolTipText(tr("Direction to search for land. Default east.")); 79 80 lakeTypeConfig.setToolTipText(tr("Tag ways as water, coastline, land or nothing. Default is water.")); … … 105 106 public void buildPreferences(JPanel prefPanel) { 106 107 GBC labelConstraints = GBC.std().insets(10,5,5,0); 107 GBC dataConstraints = GBC.eol().insets(0,5,0,0).fill(G BC.HORIZONTAL);108 GBC dataConstraints = GBC.eol().insets(0,5,0,0).fill(GridBagConstraints.HORIZONTAL); 108 109 109 110 prefPanel.add(maxSegsLabel, labelConstraints); … … 118 119 prefPanel.add(landsatResConfig.getControls(), dataConstraints); 119 120 prefPanel.add(landsatSizeLabel, labelConstraints); 120 prefPanel.add(landsatSizeConfig.getControls(), dataConstraints); 121 prefPanel.add(landsatSizeConfig.getControls(), dataConstraints); 121 122 prefPanel.add(eastOffsetLabel, labelConstraints); 122 123 prefPanel.add(eastOffsetConfig.getControls(), dataConstraints); … … 124 125 prefPanel.add(northOffsetConfig.getControls(), dataConstraints); 125 126 prefPanel.add(startDirLabel, labelConstraints); 126 prefPanel.add(startDirConfig.getControls(), dataConstraints); 127 prefPanel.add(startDirConfig.getControls(), dataConstraints); 127 128 prefPanel.add(lakeTypeLabel, labelConstraints); 128 129 prefPanel.add(lakeTypeConfig.getControls(), dataConstraints); … … 136 137 prefPanel.add(sourceConfig.getControls(), dataConstraints); 137 138 138 prefPanel.add(Box.createVerticalGlue(), GBC.eol().fill(G BC.VERTICAL));139 prefPanel.add(Box.createVerticalGlue(), GBC.eol().fill(GridBagConstraints.VERTICAL)); 139 140 } 140 141 -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerWMS.java
r16586 r19624 13 13 import java.text.NumberFormat; 14 14 import java.util.HashMap; 15 import java.util.List; 15 16 import java.util.Locale; 17 import java.util.Map; 16 18 import java.util.Vector; 17 19 … … 27 29 28 30 // Vector to cache images in memory 29 private Vector<BufferedImage> images = new Vector<BufferedImage>();31 private List<BufferedImage> images = new Vector<BufferedImage>(); 30 32 // Hashmap to hold the mapping of cached images 31 private HashMap<String,Integer> imageindex = new HashMap<String,Integer>();33 private Map<String,Integer> imageindex = new HashMap<String,Integer>(); 32 34 33 35 private int resolution; … … 179 181 image = this.getTile(x,y, progressMonitor); 180 182 } catch(LakewalkerException e){ 181 System.out.println(e.get Error());182 throw new LakewalkerException(e.getMessage());183 System.out.println(e.getMessage()); 184 throw e; 183 185 } 184 186 -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/StringConfigurer.java
r13497 r19624 14 14 * 15 15 * You should have received a copy of the GNU Library General Public 16 * License along with this library; if not, copies are available 16 * License along with this library; if not, copies are available 17 17 * at http://www.opensource.org. 18 18 */ … … 34 34 this(null, ""); 35 35 } 36 36 37 37 public StringConfigurer(String key, String name) { 38 38 this(key, name, ""); … … 43 43 } 44 44 45 public String getValueString() { 45 @Override 46 public String getValueString() { 46 47 return (String) value; 47 48 } 48 49 49 public void setValue(String s) { 50 @Override 51 public void setValue(String s) { 50 52 if (!noUpdate && nameField != null) { 51 53 nameField.setText(s); … … 57 59 nameField.setToolTipText(s); 58 60 } 59 60 public java.awt.Component getControls() { 61 62 @Override 63 public java.awt.Component getControls() { 61 64 if (p == null) { 62 65 p = new JPanel(); … … 69 72 p.add(nameField); 70 73 nameField.addKeyListener(new java.awt.event.KeyAdapter() { 71 public void keyReleased(java.awt.event.KeyEvent evt) { 74 @Override 75 public void keyReleased(java.awt.event.KeyEvent evt) { 72 76 noUpdate = true; 73 77 setValue(nameField.getText()); -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/StringEnumConfigurer.java
r13497 r19624 33 33 import java.awt.event.ActionEvent; 34 34 import java.awt.event.ActionListener; 35 35 36 import javax.swing.Box; 36 import javax.swing.DefaultComboBoxModel;37 37 import javax.swing.JComboBox; 38 38 import javax.swing.JLabel; … … 63 63 tooltipText = s; 64 64 } 65 public Component getControls() { 65 @Override 66 public Component getControls() { 66 67 if (panel == null) { 67 68 panel = Box.createHorizontalBox(); … … 82 83 return panel; 83 84 } 84 public void setValue(Object o) { 85 86 @Override 87 public void setValue(Object o) { 85 88 if(o == null) 86 o = new Integer(0);89 o = 0; 87 90 super.setValue(o); 88 91 if(!noUpdate && box != null) … … 90 93 } 91 94 92 public void setValue(String s) { 95 @Override 96 public void setValue(String s) { 93 97 Integer n = 0; 94 98 for (int i = 0; i < transValues.length; ++i) … … 102 106 } 103 107 104 public String getValueString() { 108 @Override 109 public String getValueString() { 105 110 return validValues[(Integer)value]; 106 111 }
Note:
See TracChangeset
for help on using the changeset viewer.