Changeset 23190 in osm for applications/editors/josm/plugins/lakewalker
- Timestamp:
- 2010-09-15T18:54:18+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker
- Files:
-
- 11 edited
-
BooleanConfigurer.java (modified) (1 diff)
-
Configurer.java (modified) (2 diffs)
-
DoubleConfigurer.java (modified) (3 diffs)
-
IntConfigurer.java (modified) (1 diff)
-
Lakewalker.java (modified) (1 diff)
-
LakewalkerAction.java (modified) (2 diffs)
-
LakewalkerException.java (modified) (1 diff)
-
LakewalkerPlugin.java (modified) (1 diff)
-
LakewalkerWMS.java (modified) (1 diff)
-
StringConfigurer.java (modified) (1 diff)
-
StringEnumConfigurer.java (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/BooleanConfigurer.java
r19624 r23190 23 23 */ 24 24 public class BooleanConfigurer extends Configurer { 25 private javax.swing.JCheckBox box;25 private javax.swing.JCheckBox box; 26 26 27 public BooleanConfigurer() {28 this(false);29 }27 public BooleanConfigurer() { 28 this(false); 29 } 30 30 31 public BooleanConfigurer(boolean val) {32 this(null, "", val);33 }31 public BooleanConfigurer(boolean val) { 32 this(null, "", val); 33 } 34 34 35 public BooleanConfigurer(String key, String name, Boolean val) {36 super(key, name, val);37 }35 public BooleanConfigurer(String key, String name, Boolean val) { 36 super(key, name, val); 37 } 38 38 39 public BooleanConfigurer(String key, String name, boolean val) {40 super(key, name, val ? Boolean.TRUE : Boolean.FALSE);41 }39 public BooleanConfigurer(String key, String name, boolean val) { 40 super(key, name, val ? Boolean.TRUE : Boolean.FALSE); 41 } 42 42 43 public BooleanConfigurer(String key, String name) {44 this(key, name, Boolean.FALSE);45 }43 public BooleanConfigurer(String key, String name) { 44 this(key, name, Boolean.FALSE); 45 } 46 46 47 @Override48 public String getValueString() {49 return booleanValue().toString();50 }47 @Override 48 public String getValueString() { 49 return booleanValue().toString(); 50 } 51 51 52 @Override53 public void setValue(Object o) {54 super.setValue(o);55 if (box != null56 && !o.equals(box.isSelected())) {57 box.setSelected(booleanValue().booleanValue());58 }59 }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 } 60 60 61 @Override62 public void setValue(String s) {63 setValue(Boolean.valueOf(s));64 }61 @Override 62 public void setValue(String s) { 63 setValue(Boolean.valueOf(s)); 64 } 65 65 66 @Override67 public void setName(String s) {68 super.setName(s);69 if (box != null) {70 box.setText(s);71 }72 }66 @Override 67 public void setName(String s) { 68 super.setName(s); 69 if (box != null) { 70 box.setText(s); 71 } 72 } 73 73 74 @Override75 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 }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 87 88 public Boolean booleanValue() {89 return (Boolean) value;90 }88 public Boolean booleanValue() { 89 return (Boolean) value; 90 } 91 91 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Configurer.java
r13497 r23190 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 */ … … 139 139 changeSupport.addPropertyChangeListener(l); 140 140 } 141 141 142 142 public void removePropertyChangeListener(PropertyChangeListener l) { 143 143 changeSupport.removePropertyChangeListener(l); -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/DoubleConfigurer.java
r19624 r23190 37 37 38 38 @Override 39 public void setValue(String s) {39 public void setValue(String s) { 40 40 Double d = null; 41 41 try { … … 50 50 51 51 @Override 52 public void setValue(Object o) {52 public void setValue(Object o) { 53 53 if (!noUpdate && nameField != null && o != null) { 54 54 nameField.setText(o.toString()); … … 58 58 59 59 @Override 60 public String getValueString() {60 public String getValueString() { 61 61 if (value == null || value.equals("")) { 62 62 return null; -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/IntConfigurer.java
r19624 r23190 24 24 public class IntConfigurer extends StringConfigurer { 25 25 26 public IntConfigurer() {27 super();28 }26 public IntConfigurer() { 27 super(); 28 } 29 29 30 public IntConfigurer(String key, String name) {31 this(key, name, 0);32 }30 public IntConfigurer(String key, String name) { 31 this(key, name, 0); 32 } 33 33 34 public IntConfigurer(String key, String name, Integer val) {35 super(key, name);36 if (val != null) {37 setValue(val);38 }39 }34 public IntConfigurer(String key, String name, Integer val) { 35 super(key, name); 36 if (val != null) { 37 setValue(val); 38 } 39 } 40 40 41 @Override42 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 }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 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 }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 63 64 @Override65 public void setValue(Object o) {66 if (!noUpdate && nameField != null && o != null) {67 nameField.setText(o.toString());68 }69 super.setValue(o);70 }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 71 72 @Override73 public String getValueString() {74 return value == null ? null : value.toString();75 }72 @Override 73 public String getValueString() { 74 return value == null ? null : value.toString(); 75 } 76 76 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/Lakewalker.java
r19624 r23190 84 84 public ArrayList<double[]> trace(double lat, double lon, double tl_lon, double br_lon, double tl_lat, double br_lat, ProgressMonitor progressMonitor) throws LakewalkerException { 85 85 86 progressMonitor.beginTask(null);87 88 try {89 90 LakewalkerWMS wms = new LakewalkerWMS(this.resolution, this.tilesize, this.wmslayer, this.workingdir);91 LakewalkerBBox bbox = new LakewalkerBBox(tl_lat,tl_lon,br_lat,br_lon);92 93 Boolean detect_loop = false;94 95 ArrayList<double[]> nodelist = new ArrayList<double[]>();96 97 int[] xy = geo_to_xy(lat,lon,this.resolution);98 99 if(!bbox.contains(lat, lon)){100 throw new LakewalkerException(tr("The starting location was not within the bbox"));101 }102 103 int v;104 105 progressMonitor.indeterminateSubTask(tr("Looking for shoreline..."));106 107 while(true){108 double[] geo = xy_to_geo(xy[0],xy[1],this.resolution);109 if(bbox.contains(geo[0],geo[1])==false){110 break;111 }112 113 v = wms.getPixel(xy[0], xy[1], progressMonitor.createSubTaskMonitor(0, false));114 if(v > this.threshold){115 break;116 }117 118 int delta_lat = this.dirslat[getDirectionIndex(this.startdir)];119 int delta_lon = this.dirslon[getDirectionIndex(this.startdir)];120 121 xy[0] = xy[0]+delta_lon;122 xy[1] = xy[1]+delta_lat;123 124 }125 126 int[] startxy = new int[] {xy[0], xy[1]};127 double[] startgeo = xy_to_geo(xy[0],xy[1],this.resolution);128 129 //System.out.printf("Found shore at lat %.4f lon %.4f\n",lat,lon);130 131 int last_dir = this.getDirectionIndex(this.startdir);132 133 for(int i = 0; i < this.maxnode; i++){134 135 // Print a counter136 if(i % 250 == 0){137 progressMonitor.indeterminateSubTask(tr("{0} nodes so far...",i));138 //System.out.println(i+" nodes so far...");139 }140 141 // Some variables we need142 int d;143 int test_x=0;144 int test_y=0;145 int new_dir = 0;146 147 // Loop through all the directions we can go148 for(d = 1; d <= this.dirslat.length; d++){149 150 // Decide which direction we want to look at from this pixel151 new_dir = (last_dir + d + 4) % 8;152 153 test_x = xy[0] + this.dirslon[new_dir];154 test_y = xy[1] + this.dirslat[new_dir];155 156 double[] geo = xy_to_geo(test_x,test_y,this.resolution);157 158 if(!bbox.contains(geo[0], geo[1])){159 System.out.println("Outside bbox");160 break;161 }162 163 v = wms.getPixel(test_x, test_y, progressMonitor.createSubTaskMonitor(0, false));164 if(v > this.threshold){165 break;166 }167 168 if(d == this.dirslat.length-1){169 System.out.println("Got stuck");170 break;171 }172 }173 174 // Remember this direction175 last_dir = new_dir;176 177 // Set the pixel we found as current178 xy[0] = test_x;179 xy[1] = test_y;180 181 // Break the loop if we managed to get back to our starting point182 if(xy[0] == startxy[0] && xy[1] == startxy[1]){183 break;184 }185 186 // Store this node187 double[] geo = xy_to_geo(xy[0],xy[1],this.resolution);188 nodelist.add(geo);189 //System.out.println("Adding node at "+xy[0]+","+xy[1]+" ("+geo[1]+","+geo[0]+")");190 191 // Check if we got stuck in a loop192 double start_proximity = Math.pow((geo[0] - startgeo[0]),2) + Math.pow((geo[1] - startgeo[1]),2);193 194 if(detect_loop){195 if(start_proximity < Math.pow(start_radius_small,2)){196 System.out.println("Detected loop");197 break;198 }199 }else{200 if(start_proximity > Math.pow(start_radius_big,2)){201 detect_loop = true;202 }203 }204 }205 206 return nodelist;207 } finally {208 progressMonitor.finishTask();209 }86 progressMonitor.beginTask(null); 87 88 try { 89 90 LakewalkerWMS wms = new LakewalkerWMS(this.resolution, this.tilesize, this.wmslayer, this.workingdir); 91 LakewalkerBBox bbox = new LakewalkerBBox(tl_lat,tl_lon,br_lat,br_lon); 92 93 Boolean detect_loop = false; 94 95 ArrayList<double[]> nodelist = new ArrayList<double[]>(); 96 97 int[] xy = geo_to_xy(lat,lon,this.resolution); 98 99 if(!bbox.contains(lat, lon)){ 100 throw new LakewalkerException(tr("The starting location was not within the bbox")); 101 } 102 103 int v; 104 105 progressMonitor.indeterminateSubTask(tr("Looking for shoreline...")); 106 107 while(true){ 108 double[] geo = xy_to_geo(xy[0],xy[1],this.resolution); 109 if(bbox.contains(geo[0],geo[1])==false){ 110 break; 111 } 112 113 v = wms.getPixel(xy[0], xy[1], progressMonitor.createSubTaskMonitor(0, false)); 114 if(v > this.threshold){ 115 break; 116 } 117 118 int delta_lat = this.dirslat[getDirectionIndex(this.startdir)]; 119 int delta_lon = this.dirslon[getDirectionIndex(this.startdir)]; 120 121 xy[0] = xy[0]+delta_lon; 122 xy[1] = xy[1]+delta_lat; 123 124 } 125 126 int[] startxy = new int[] {xy[0], xy[1]}; 127 double[] startgeo = xy_to_geo(xy[0],xy[1],this.resolution); 128 129 //System.out.printf("Found shore at lat %.4f lon %.4f\n",lat,lon); 130 131 int last_dir = this.getDirectionIndex(this.startdir); 132 133 for(int i = 0; i < this.maxnode; i++){ 134 135 // Print a counter 136 if(i % 250 == 0){ 137 progressMonitor.indeterminateSubTask(tr("{0} nodes so far...",i)); 138 //System.out.println(i+" nodes so far..."); 139 } 140 141 // Some variables we need 142 int d; 143 int test_x=0; 144 int test_y=0; 145 int new_dir = 0; 146 147 // Loop through all the directions we can go 148 for(d = 1; d <= this.dirslat.length; d++){ 149 150 // Decide which direction we want to look at from this pixel 151 new_dir = (last_dir + d + 4) % 8; 152 153 test_x = xy[0] + this.dirslon[new_dir]; 154 test_y = xy[1] + this.dirslat[new_dir]; 155 156 double[] geo = xy_to_geo(test_x,test_y,this.resolution); 157 158 if(!bbox.contains(geo[0], geo[1])){ 159 System.out.println("Outside bbox"); 160 break; 161 } 162 163 v = wms.getPixel(test_x, test_y, progressMonitor.createSubTaskMonitor(0, false)); 164 if(v > this.threshold){ 165 break; 166 } 167 168 if(d == this.dirslat.length-1){ 169 System.out.println("Got stuck"); 170 break; 171 } 172 } 173 174 // Remember this direction 175 last_dir = new_dir; 176 177 // Set the pixel we found as current 178 xy[0] = test_x; 179 xy[1] = test_y; 180 181 // Break the loop if we managed to get back to our starting point 182 if(xy[0] == startxy[0] && xy[1] == startxy[1]){ 183 break; 184 } 185 186 // Store this node 187 double[] geo = xy_to_geo(xy[0],xy[1],this.resolution); 188 nodelist.add(geo); 189 //System.out.println("Adding node at "+xy[0]+","+xy[1]+" ("+geo[1]+","+geo[0]+")"); 190 191 // Check if we got stuck in a loop 192 double start_proximity = Math.pow((geo[0] - startgeo[0]),2) + Math.pow((geo[1] - startgeo[1]),2); 193 194 if(detect_loop){ 195 if(start_proximity < Math.pow(start_radius_small,2)){ 196 System.out.println("Detected loop"); 197 break; 198 } 199 }else{ 200 if(start_proximity > Math.pow(start_radius_big,2)){ 201 detect_loop = true; 202 } 203 } 204 } 205 206 return nodelist; 207 } finally { 208 progressMonitor.finishTask(); 209 } 210 210 } 211 211 -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java
r19624 r23190 155 155 } 156 156 157 @Override protected void cancel() {158 LakewalkerAction.this.cancel();159 }157 @Override protected void cancel() { 158 LakewalkerAction.this.cancel(); 159 } 160 160 }; 161 161 Thread executeThread = new Thread(lakewalkerTask); … … 247 247 248 248 } catch (Exception ex) { 249 ex.printStackTrace();249 ex.printStackTrace(); 250 250 } 251 251 -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerException.java
r19624 r23190 5 5 class LakewalkerException extends Exception { 6 6 public LakewalkerException(){ 7 super(tr("An unknown error has occurred"));7 super(tr("An unknown error has occurred")); 8 8 } 9 9 -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPlugin.java
r19624 r23190 15 15 */ 16 16 public class LakewalkerPlugin extends Plugin { 17 public LakewalkerPlugin(PluginInformation info) {18 super(info);19 MainMenu.add(Main.main.menu.toolsMenu, new LakewalkerAction(tr("Lake Walker")));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 @Override23 public PreferenceSetting getPreferenceSetting()24 {25 return new LakewalkerPreferences();26 }22 @Override 23 public PreferenceSetting getPreferenceSetting() 24 { 25 return new LakewalkerPreferences(); 26 } 27 27 28 28 } -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerWMS.java
r19624 r23190 48 48 49 49 public BufferedImage getTile(int x, int y, ProgressMonitor progressMonitor) throws LakewalkerException { 50 progressMonitor.beginTask(tr("Downloading image tile..."));51 try {52 String layer = "global_mosaic_base";53 54 int[] bottom_left_xy = new int[2];55 bottom_left_xy[0] = floor(x,this.tilesize);56 bottom_left_xy[1] = floor(y,this.tilesize);57 58 int[] top_right_xy = new int[2];59 top_right_xy[0] = bottom_left_xy[0] + this.tilesize;60 top_right_xy[1] = bottom_left_xy[1] + this.tilesize;61 62 double[] topright_geo = xy_to_geo(top_right_xy[0],top_right_xy[1],this.resolution);63 double[] bottomleft_geo = xy_to_geo(bottom_left_xy[0],bottom_left_xy[1],this.resolution);64 65 String filename = this.wmslayer+"/landsat_"+this.resolution+"_"+this.tilesize+66 "_xy_"+bottom_left_xy[0]+"_"+bottom_left_xy[1]+".png";67 68 // The WMS server only understands decimal points using periods, so we need69 // to convert to a locale that uses that to build the proper URL70 NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH);71 DecimalFormat df = (DecimalFormat)nf;72 df.applyLocalizedPattern("0.000000");73 74 String urlloc = "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers="+layer+75 "&styles="+wmslayer+"&srs=EPSG:4326&format=image/png"+76 "&bbox="+df.format(bottomleft_geo[1])+","+df.format(bottomleft_geo[0])+77 ","+df.format(topright_geo[1])+","+df.format(topright_geo[0])+78 "&width="+this.tilesize+"&height="+this.tilesize;79 80 File file = new File(this.working_dir,filename);81 82 // Calculate the hashmap key83 String hashkey = Integer.toString(bottom_left_xy[0])+":"+Integer.toString(bottom_left_xy[1]);84 85 // See if this image is already loaded86 if(this.image != null){87 if(this.imagex != bottom_left_xy[0] || this.imagey != bottom_left_xy[1]){88 89 // Check if this image exists in the hashmap90 if(this.imageindex.containsKey(hashkey)){91 // Store which image we have92 this.imagex = bottom_left_xy[0];93 this.imagey = bottom_left_xy[1];94 95 // Retrieve from cache96 this.image = this.images.get(this.imageindex.get(hashkey));97 return this.image;98 } else {99 this.image = null;100 }101 } else {102 return this.image;103 }104 }105 106 try {107 System.out.println("Looking for image in disk cache: "+filename);108 109 // Read from a file110 this.image = ImageIO.read(file);111 112 this.images.add(this.image);113 this.imageindex.put(hashkey,this.images.size()-1);114 115 } catch(FileNotFoundException e){116 System.out.println("Could not find cached image, downloading.");117 } catch(IOException e){118 System.out.println(e.getMessage());119 } catch(Exception e){120 System.out.println(e.getMessage());121 }122 123 if(this.image == null){124 /**125 * Try downloading the image126 */127 try {128 System.out.println("Downloading from "+urlloc);129 130 // Read from a URL131 URL url = new URL(urlloc);132 this.image = ImageIO.read(url); // this can return null!133 } catch(MalformedURLException e){134 System.out.println(e.getMessage());135 } catch(IOException e){136 System.out.println(e.getMessage());137 } catch(Exception e){138 System.out.println(e.getMessage());139 }140 141 if (this.image != null) {142 this.images.add(this.image);143 this.imageindex.put(hashkey,this.images.size()-1);144 145 this.saveimage(file,this.image);146 }147 }148 149 this.imagex = bottom_left_xy[0];150 this.imagey = bottom_left_xy[1];151 152 if(this.image == null){153 throw new LakewalkerException(tr("Could not acquire image"));154 }155 156 return this.image;157 } finally {158 progressMonitor.finishTask();159 }50 progressMonitor.beginTask(tr("Downloading image tile...")); 51 try { 52 String layer = "global_mosaic_base"; 53 54 int[] bottom_left_xy = new int[2]; 55 bottom_left_xy[0] = floor(x,this.tilesize); 56 bottom_left_xy[1] = floor(y,this.tilesize); 57 58 int[] top_right_xy = new int[2]; 59 top_right_xy[0] = bottom_left_xy[0] + this.tilesize; 60 top_right_xy[1] = bottom_left_xy[1] + this.tilesize; 61 62 double[] topright_geo = xy_to_geo(top_right_xy[0],top_right_xy[1],this.resolution); 63 double[] bottomleft_geo = xy_to_geo(bottom_left_xy[0],bottom_left_xy[1],this.resolution); 64 65 String filename = this.wmslayer+"/landsat_"+this.resolution+"_"+this.tilesize+ 66 "_xy_"+bottom_left_xy[0]+"_"+bottom_left_xy[1]+".png"; 67 68 // The WMS server only understands decimal points using periods, so we need 69 // to convert to a locale that uses that to build the proper URL 70 NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH); 71 DecimalFormat df = (DecimalFormat)nf; 72 df.applyLocalizedPattern("0.000000"); 73 74 String urlloc = "http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers="+layer+ 75 "&styles="+wmslayer+"&srs=EPSG:4326&format=image/png"+ 76 "&bbox="+df.format(bottomleft_geo[1])+","+df.format(bottomleft_geo[0])+ 77 ","+df.format(topright_geo[1])+","+df.format(topright_geo[0])+ 78 "&width="+this.tilesize+"&height="+this.tilesize; 79 80 File file = new File(this.working_dir,filename); 81 82 // Calculate the hashmap key 83 String hashkey = Integer.toString(bottom_left_xy[0])+":"+Integer.toString(bottom_left_xy[1]); 84 85 // See if this image is already loaded 86 if(this.image != null){ 87 if(this.imagex != bottom_left_xy[0] || this.imagey != bottom_left_xy[1]){ 88 89 // Check if this image exists in the hashmap 90 if(this.imageindex.containsKey(hashkey)){ 91 // Store which image we have 92 this.imagex = bottom_left_xy[0]; 93 this.imagey = bottom_left_xy[1]; 94 95 // Retrieve from cache 96 this.image = this.images.get(this.imageindex.get(hashkey)); 97 return this.image; 98 } else { 99 this.image = null; 100 } 101 } else { 102 return this.image; 103 } 104 } 105 106 try { 107 System.out.println("Looking for image in disk cache: "+filename); 108 109 // Read from a file 110 this.image = ImageIO.read(file); 111 112 this.images.add(this.image); 113 this.imageindex.put(hashkey,this.images.size()-1); 114 115 } catch(FileNotFoundException e){ 116 System.out.println("Could not find cached image, downloading."); 117 } catch(IOException e){ 118 System.out.println(e.getMessage()); 119 } catch(Exception e){ 120 System.out.println(e.getMessage()); 121 } 122 123 if(this.image == null){ 124 /** 125 * Try downloading the image 126 */ 127 try { 128 System.out.println("Downloading from "+urlloc); 129 130 // Read from a URL 131 URL url = new URL(urlloc); 132 this.image = ImageIO.read(url); // this can return null! 133 } catch(MalformedURLException e){ 134 System.out.println(e.getMessage()); 135 } catch(IOException e){ 136 System.out.println(e.getMessage()); 137 } catch(Exception e){ 138 System.out.println(e.getMessage()); 139 } 140 141 if (this.image != null) { 142 this.images.add(this.image); 143 this.imageindex.put(hashkey,this.images.size()-1); 144 145 this.saveimage(file,this.image); 146 } 147 } 148 149 this.imagex = bottom_left_xy[0]; 150 this.imagey = bottom_left_xy[1]; 151 152 if(this.image == null){ 153 throw new LakewalkerException(tr("Could not acquire image")); 154 } 155 156 return this.image; 157 } finally { 158 progressMonitor.finishTask(); 159 } 160 160 } 161 161 -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/StringConfigurer.java
r19624 r23190 73 73 nameField.addKeyListener(new java.awt.event.KeyAdapter() { 74 74 @Override 75 public void keyReleased(java.awt.event.KeyEvent evt) {75 public void keyReleased(java.awt.event.KeyEvent evt) { 76 76 noUpdate = true; 77 77 setValue(nameField.getText()); -
applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/StringEnumConfigurer.java
r19624 r23190 64 64 } 65 65 @Override 66 public Component getControls() {66 public Component getControls() { 67 67 if (panel == null) { 68 68 panel = Box.createHorizontalBox(); … … 85 85 86 86 @Override 87 public void setValue(Object o) {87 public void setValue(Object o) { 88 88 if(o == null) 89 89 o = 0; … … 94 94 95 95 @Override 96 public void setValue(String s) {96 public void setValue(String s) { 97 97 Integer n = 0; 98 98 for (int i = 0; i < transValues.length; ++i) … … 107 107 108 108 @Override 109 public String getValueString() {109 public String getValueString() { 110 110 return validValues[(Integer)value]; 111 111 }
Note:
See TracChangeset
for help on using the changeset viewer.
