Changeset 30859 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GrabThread.java
- Timestamp:
- 2014-12-19T17:12:01+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GrabThread.java
r30737 r30859 28 28 29 29 private CacheControl cacheControl = null; 30 30 31 31 private EastNorthBound currentGrabImage; 32 32 … … 34 34 35 35 /** 36 * Call directly grabber for raster images or prepare thread for vector images 36 * Call directly grabber for raster images or prepare thread for vector images 37 37 * @param moreImages 38 38 */ … … 44 44 this.notify(); 45 45 } 46 System.out.println("Added " + moreImages.size() + " to the grab thread");46 Main.info("Added " + moreImages.size() + " to the grab thread"); 47 47 if (wmsLayer.isRaster()) { 48 48 waitNotification(); … … 56 56 return size; 57 57 } 58 58 59 59 public ArrayList<EastNorthBound> getImagesToGrabCopy() { 60 ArrayList<EastNorthBound> copyList = new ArrayList<>(); 60 ArrayList<EastNorthBound> copyList = new ArrayList<>(); 61 61 lockImagesToGrag.lock(); 62 62 for (EastNorthBound img : imagesToGrab) { … … 67 67 return copyList; 68 68 } 69 70 public void clearImagesToGrab() { 69 70 public void clearImagesToGrab() { 71 71 lockImagesToGrag.lock(); 72 72 imagesToGrab.clear(); 73 73 lockImagesToGrag.unlock(); 74 74 } 75 75 76 76 @Override 77 77 public void run() { … … 92 92 newImage = grabber.grab(wmsLayer, currentGrabImage.min, currentGrabImage.max); 93 93 } catch (IOException e) { 94 System.out 95 .println("Download action canceled by user or server did not respond"); 94 Main.warn("Download action canceled by user or server did not respond"); 96 95 setCanceled(true); 97 96 break; 98 97 } catch (OsmTransferException e) { 99 System.out.println("OSM transfer failed");98 Main.error("OSM transfer failed"); 100 99 setCanceled(true); 101 100 break; 102 101 } 103 102 if (grabber.getWmsInterface().downloadCanceled) { 104 System.out.println("Download action canceled by user");103 Main.info("Download action canceled by user"); 105 104 setCanceled(true); 106 105 break; 107 106 } 108 107 try { 109 if (CadastrePlugin.backgroundTransparent) {110 wmsLayer.imagesLock.lock();111 for (GeorefImage img : wmsLayer.getImages()) {112 if (img.overlap(newImage))113 // mask overlapping zone in already grabbed image114 img.withdraw(newImage);115 else116 // mask overlapping zone in new image only when new image covers completely the 117 // existing image118 newImage.withdraw(img);119 }120 wmsLayer.imagesLock.unlock();121 }122 wmsLayer.addImage(newImage);123 Main.map.mapView.repaint();124 saveToCache(newImage);108 if (CadastrePlugin.backgroundTransparent) { 109 wmsLayer.imagesLock.lock(); 110 for (GeorefImage img : wmsLayer.getImages()) { 111 if (img.overlap(newImage)) 112 // mask overlapping zone in already grabbed image 113 img.withdraw(newImage); 114 else 115 // mask overlapping zone in new image only when new image covers completely the 116 // existing image 117 newImage.withdraw(img); 118 } 119 wmsLayer.imagesLock.unlock(); 120 } 121 wmsLayer.addImage(newImage); 122 Main.map.mapView.repaint(); 123 saveToCache(newImage); 125 124 } catch (NullPointerException e) { 126 System.out.println("Layer destroyed. Cancel grab thread");125 Main.info("Layer destroyed. Cancel grab thread"); 127 126 setCanceled(true); 128 127 } 129 128 } 130 129 } 131 System.out.println("grab thread list empty");130 Main.info("grab thread list empty"); 132 131 lockCurrentGrabImage.lock(); 133 132 currentGrabImage = null; … … 163 162 if (cacheControl != null) { 164 163 while (!cacheControl.isCachePipeEmpty()) { 165 System.out 166 .println("Try to close a WMSLayer which is currently saving in cache : wait 1 sec."); 164 Main.info("Try to close a WMSLayer which is currently saving in cache : wait 1 sec."); 167 165 CadastrePlugin.safeSleep(1000); 168 166 } … … 193 191 lockCurrentGrabImage.unlock(); 194 192 } 195 193 196 194 private void paintBox(Graphics g, MapView mv, EastNorthBound img, Color color) { 197 195 Point[] croppedPoint = new Point[5]; … … 206 204 } 207 205 } 208 206 209 207 public boolean isCanceled() { 210 208 return canceled; … … 231 229 wait(); 232 230 } catch (InterruptedException e) { 233 e.printStackTrace(System.out); 234 } 235 } 236 231 Main.error(e); 232 } 233 } 237 234 }
Note:
See TracChangeset
for help on using the changeset viewer.