Changeset 32556 in osm for applications/editors/josm/plugins/cadastre-fr
- Timestamp:
- 2016-07-04T14:18:17+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr
- Files:
-
- 1 added
- 44 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/.project
r32165 r32556 17 17 </arguments> 18 18 </buildCommand> 19 <buildCommand> 20 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> 21 <arguments> 22 </arguments> 23 </buildCommand> 19 24 </buildSpec> 20 25 <natures> 21 26 <nature>org.sonarlint.eclipse.core.sonarlintNature</nature> 22 27 <nature>org.eclipse.jdt.core.javanature</nature> 28 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 23 29 </natures> 24 30 </projectDescription> -
applications/editors/josm/plugins/cadastre-fr/.settings/org.eclipse.jdt.ui.prefs
r32211 r32556 37 37 sp_cleanup.remove_private_constructors=true 38 38 sp_cleanup.remove_redundant_type_arguments=true 39 sp_cleanup.remove_trailing_whitespaces= false39 sp_cleanup.remove_trailing_whitespaces=true 40 40 sp_cleanup.remove_trailing_whitespaces_all=true 41 41 sp_cleanup.remove_trailing_whitespaces_ignore_empty=false 42 42 sp_cleanup.remove_unnecessary_casts=true 43 43 sp_cleanup.remove_unnecessary_nls_tags=false 44 sp_cleanup.remove_unused_imports= false44 sp_cleanup.remove_unused_imports=true 45 45 sp_cleanup.remove_unused_local_variables=false 46 46 sp_cleanup.remove_unused_private_fields=true -
applications/editors/josm/plugins/cadastre-fr/build.xml
r32329 r32556 4 4 <property name="commit.message" value="Changed constructor for Plugin"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="10 279"/>6 <property name="plugin.main.version" value="10420"/> 7 7 8 8 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Address.java
r32425 r32556 1 // License: GPL. For details, see LICENSE file. 1 2 package cadastre_fr; 2 3 … … 113 114 // dialog.setVisible(false); 114 115 // kill the window completely to fix an issue on some linux distro and full screen mode. 115 if (dialog != null) {116 if (dialog != null) { 116 117 dialog.dispose(); 117 118 dialog = null; … … 156 157 } 157 158 if (currentMouseNode.get(tagHouseStreet) != null) { 158 if (Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false)) {159 if (Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false)) { 159 160 inputStreet.setText(currentMouseNode.get(tagHouseStreet)); 160 161 if (ctrl) { … … 164 165 applyInputNumberChange(); 165 166 } 166 setSelectedWay((Way) null);167 setSelectedWay((Way) null); 167 168 } 168 169 } else { … … 184 185 } else { 185 186 List<WaySegment> wss = mv.getNearestWaySegments(mousePos, OsmPrimitive.isSelectablePredicate); 186 for (WaySegment ws : wss) {187 for (WaySegment ws : wss) { 187 188 if (ws.way.get(tagHighway) != null && ws.way.get(tagHighwayName) != null) 188 189 mouseOnExistingWays.add(ws.way); … … 220 221 for (OsmPrimitive osm : l) { 221 222 if (osm instanceof Relation && osm.hasKey("type") && osm.get("type").equals(relationAddrType)) { 222 for (RelationMember rm : ((Relation) osm).getMembers()) {223 for (RelationMember rm : ((Relation) osm).getMembers()) { 223 224 if (rm.getRole().equals(relationAddrStreetRole)) { 224 225 OsmPrimitive osp = rm.getMember(); 225 226 if (osp instanceof Way && osp.hasKey(tagHighwayName)) { 226 return (Way) osp;227 return (Way) osp; 227 228 } 228 229 } … … 264 265 for (OsmPrimitive osm : l) { 265 266 if (osm instanceof Relation && osm.hasKey("type") && osm.get("type").equals(relationAddrType)) { 266 return (Relation) osm;267 return (Relation) osm; 267 268 } 268 269 } … … 310 311 is.add(ws.lowerIndex); 311 312 } 312 Set<Pair<Node, Node>> segSet = new HashSet<>();313 Set<Pair<Node, Node>> segSet = new HashSet<>(); 313 314 ArrayList<Way> replacedWays = new ArrayList<>(); 314 315 ArrayList<Way> reuseWays = new ArrayList<>(); … … 333 334 } 334 335 335 private static void adjustNode(Collection<Pair<Node, Node>> segs, Node n) {336 private static void adjustNode(Collection<Pair<Node, Node>> segs, Node n) { 336 337 337 338 switch (segs.size()) { … … 341 342 // This computes the intersection between 342 343 // the two segments and adjusts the node position. 343 Iterator<Pair<Node, Node>> i = segs.iterator();344 Pair<Node, Node> seg = i.next();344 Iterator<Pair<Node, Node>> i = segs.iterator(); 345 Pair<Node, Node> seg = i.next(); 345 346 EastNorth A = seg.a.getEastNorth(); 346 347 EastNorth B = seg.b.getEastNorth(); … … 349 350 EastNorth D = seg.b.getEastNorth(); 350 351 351 double u =det(B.east() - A.east(), B.north() - A.north(), C.east() - D.east(), C.north() - D.north());352 double u = det(B.east() - A.east(), B.north() - A.north(), C.east() - D.east(), C.north() - D.north()); 352 353 353 354 // Check for parallel segments and do nothing if they are … … 366 367 367 368 int snapToIntersectionThreshold 368 = Main.pref.getInteger("edit.snap-intersection-threshold", 10);369 = Main.pref.getInteger("edit.snap-intersection-threshold", 10); 369 370 370 371 // only adjust to intersection if within snapToIntersectionThreshold pixel of mouse click; otherwise … … 462 463 inputNumber.setText(""); 463 464 inputStreet.setText(""); 464 setSelectedWay((Way) null);465 setSelectedWay((Way) null); 465 466 } 466 467 }); … … 495 496 Main.pref.put("cadastrewms.addr.bounds", dialog.getX()+","+dialog.getY()+","+dialog.getWidth()+","+dialog.getHeight()); 496 497 } 498 497 499 @Override public void componentMoved(ComponentEvent e) { 498 500 rememberGeometry(); 499 501 } 502 500 503 @Override public void componentResized(ComponentEvent e) { 501 504 rememberGeometry(); … … 506 509 public void windowClosing(WindowEvent arg) { 507 510 exitMode(); 508 Main.map.selectMapMode((MapMode) Main.map.getDefaultButtonAction());511 Main.map.selectMapMode((MapMode) Main.map.getDefaultButtonAction()); 509 512 } 510 513 }); 511 String bounds = Main.pref.get("cadastrewms.addr.bounds", null);514 String bounds = Main.pref.get("cadastrewms.addr.bounds", null); 512 515 if (bounds != null) { 513 516 String[] b = bounds.split(","); 514 517 dialog.setBounds(new Rectangle( 515 Integer.parseInt(b[0]), Integer.parseInt(b[1]),Integer.parseInt(b[2]),Integer.parseInt(b[3])));518 Integer.parseInt(b[0]), Integer.parseInt(b[1]), Integer.parseInt(b[2]), Integer.parseInt(b[3]))); 516 519 } 517 520 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
r32211 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 42 42 super(out); 43 43 } 44 44 45 @Override 45 46 protected void writeStreamHeader() throws IOException { … … 88 89 for (int i = 0; i < files.length; i++) { 89 90 size += files[i].length(); 90 if (files[i].lastModified() < 91 if (files[i].lastModified() < oldestFileDate) { 91 92 oldestFile = i; 92 93 oldestFileDate = files[i].lastModified(); 93 94 } 94 95 } 95 if (size > (long) cacheSize*1024*1024) {96 if (size > (long) cacheSize*1024*1024) { 96 97 Main.info("Delete oldest file \""+ files[oldestFile].getName() 97 98 + "\" in cache dir to stay under the limit of " + cacheSize + " MB."); … … 120 121 CadastrePlugin.prepareDialog(dialog); 121 122 dialog.setVisible(true); 122 return (Integer) pane.getValue();123 return (Integer) pane.getValue(); 123 124 // till here 124 125 } … … 142 143 if (file.exists()) 143 144 file.delete(); 144 while (file.exists()) // wait until file is really gone (otherwise appends to existing one)145 while (file.exists()) { // wait until file is really gone (otherwise appends to existing one) 145 146 CadastrePlugin.safeSleep(500); 147 } 146 148 } 147 149 … … 158 160 @Override 159 161 public void run() { 160 JOptionPane.showMessageDialog(Main.parent, tr("Error loading file.\nProbably an old version of the cache file."), 162 JOptionPane.showMessageDialog(Main.parent, tr("Error loading file.\nProbably an old version of the cache file."), 161 163 tr("Error"), JOptionPane.ERROR_MESSAGE); 162 164 } … … 193 195 try (ObjectOutputStreamAppend oos = new ObjectOutputStreamAppend( 194 196 new BufferedOutputStream(new FileOutputStream(file, true)))) { 195 for (int i =0; i < size; i++) {197 for (int i = 0; i < size; i++) { 196 198 oos.writeObject(imagesToSave.get(i)); 197 199 } … … 201 203 new BufferedOutputStream(new FileOutputStream(file)))) { 202 204 wmsLayer.write(file, oos); 203 for (int i =0; i < size; i++) {205 for (int i = 0; i < size; i++) { 204 206 oos.writeObject(imagesToSave.get(i)); 205 207 } … … 210 212 } 211 213 imagesLock.lock(); 212 for (int i =0; i < size; i++) {214 for (int i = 0; i < size; i++) { 213 215 imagesToSave.remove(0); 214 216 } 215 217 imagesLock.unlock(); 216 218 } 217 try {wait();} catch (InterruptedException e) { 219 try { 220 wait(); 221 } catch (InterruptedException e) { 218 222 Main.error(e); 219 223 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheFileLambert4ZoneFilter.java
r32211 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 35 35 public boolean acceptName(String filename) { 36 36 String name = filename.toLowerCase(Locale.FRANCE); 37 for (String ext : extension.split(",")) 37 for (String ext : extension.split(",")) { 38 38 if (name.endsWith("." + ext)) 39 39 return true; 40 } 40 41 return false; 41 42 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheFileLambert9ZoneFilter.java
r18773 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 8 8 import javax.swing.filechooser.FileFilter; 9 9 10 public class CacheFileLambert9ZoneFilter extends FileFilter {10 public final class CacheFileLambert9ZoneFilter extends FileFilter { 11 11 12 12 /** … … 17 17 18 18 public static CacheFileLambert9ZoneFilter[] filters = { 19 new CacheFileLambert9ZoneFilter("cc1", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 1)),20 new CacheFileLambert9ZoneFilter("cc2", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 2)),21 new CacheFileLambert9ZoneFilter("cc3", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 3)),22 new CacheFileLambert9ZoneFilter("cc4", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 4)),23 new CacheFileLambert9ZoneFilter("cc5", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 5)),24 new CacheFileLambert9ZoneFilter("cc6", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 6)),25 new CacheFileLambert9ZoneFilter("cc7", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 7)),26 new CacheFileLambert9ZoneFilter("cc8", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 8)),27 new CacheFileLambert9ZoneFilter("cc9", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 9))19 new CacheFileLambert9ZoneFilter("cc1", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 1)), 20 new CacheFileLambert9ZoneFilter("cc2", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 2)), 21 new CacheFileLambert9ZoneFilter("cc3", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 3)), 22 new CacheFileLambert9ZoneFilter("cc4", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 4)), 23 new CacheFileLambert9ZoneFilter("cc5", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 5)), 24 new CacheFileLambert9ZoneFilter("cc6", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 6)), 25 new CacheFileLambert9ZoneFilter("cc7", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 7)), 26 new CacheFileLambert9ZoneFilter("cc8", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 8)), 27 new CacheFileLambert9ZoneFilter("cc9", tr("Lambert CC9 Zone {0} cache file (.CC{0})", 9)) 28 28 }; 29 29 … … 39 39 public boolean acceptName(String filename) { 40 40 String name = filename.toLowerCase(); 41 for (String ext : extension.split(",")) 41 for (String ext : extension.split(",")) { 42 42 if (name.endsWith("." + ext)) 43 43 return true; 44 } 44 45 return false; 45 46 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheFileUTM20NFilter.java
r20824 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 8 8 import javax.swing.filechooser.FileFilter; 9 9 10 public class CacheFileUTM20NFilter extends FileFilter {10 public final class CacheFileUTM20NFilter extends FileFilter { 11 11 12 12 /** … … 34 34 public boolean acceptName(String filename) { 35 35 String name = filename.toLowerCase(); 36 for (String ext : extension.split(",")) 36 for (String ext : extension.split(",")) { 37 37 if (name.endsWith("." + ext)) 38 38 return true; 39 } 39 40 return false; 40 41 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreGrabber.java
r32211 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 54 54 str += wmsLayer.eastNorth2raster(lambertMin, lambertMax); 55 55 str += "&width="+cRasterX+"&height="; // maximum allowed by wms server (576/345, 800/378, 1000/634) 56 str += (int) (cRasterX*(wmsLayer.communeBBox.max.getY() - wmsLayer.communeBBox.min.getY())/(wmsLayer.communeBBox.max.getX() - wmsLayer.communeBBox.min.getX()));56 str += (int) (cRasterX*(wmsLayer.communeBBox.max.getY() - wmsLayer.communeBBox.min.getY())/(wmsLayer.communeBBox.max.getX() - wmsLayer.communeBBox.min.getX())); 57 57 str += "&exception=application/vnd.ogc.se_inimage&styles="; // required for raster images 58 58 Main.info("URL="+str); … … 84 84 85 85 private BufferedImage grab(URL url) throws IOException, OsmTransferException { 86 wmsInterface.urlConn = (HttpURLConnection) url.openConnection();86 wmsInterface.urlConn = (HttpURLConnection) url.openConnection(); 87 87 wmsInterface.urlConn.setRequestProperty("Connection", "close"); 88 88 wmsInterface.urlConn.setRequestMethod("GET"); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
r32425 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 49 49 } 50 50 } 51 51 52 private List<PlanImage> listOfFeuilles = new ArrayList<>(); 52 53 private long cookieTimestamp; … … 109 110 * @return true if a cookie is delivered by WMS and false is WMS is not opening a client session 110 111 * (too many clients or in maintenance) 111 * @throws IOException112 112 */ 113 113 private void getCookie() throws IOException { … … 117 117 searchFormURL = new URL(BASE_URL + "/scpc/accueil.do"); 118 118 while (!success && retries > 0) { 119 urlConn = (HttpURLConnection) searchFormURL.openConnection();119 urlConn = (HttpURLConnection) searchFormURL.openConnection(); 120 120 urlConn.setRequestProperty("Connection", "close"); 121 121 urlConn.setRequestMethod("GET"); … … 124 124 Main.info("GET "+searchFormURL); 125 125 BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8)); 126 while (in.readLine() != null) {126 while (in.readLine() != null) { 127 127 // read the buffer otherwise we sent POST too early 128 128 } … … 132 132 CookieHandler cookieHandler = CookieHandler.getDefault(); 133 133 if (cookieHandler != null) { 134 if (handleCookie(cookieHandler.get(searchFormURL.toURI(), new HashMap<String, List<String>>()).get("Cookie").get(0))) {134 if (handleCookie(cookieHandler.get(searchFormURL.toURI(), new HashMap<String, List<String>>()).get("Cookie").get(0))) { 135 135 break; 136 136 } 137 137 } else { 138 138 String headerName; 139 for (int i =1; (headerName = urlConn.getHeaderFieldKey(i))!=null; i++) {139 for (int i = 1; (headerName = urlConn.getHeaderFieldKey(i)) != null; i++) { 140 140 if ("Set-Cookie".equals(headerName) && handleCookie(urlConn.getHeaderField(i))) { 141 141 break; 142 } 142 } 143 143 } 144 144 } … … 146 146 Main.warn("Request to home page failed. Http error:"+urlConn.getResponseCode()+". Try again "+retries+" times"); 147 147 CadastrePlugin.safeSleep(3000); 148 retries 148 retries--; 149 149 } 150 150 } … … 238 238 } 239 239 240 private void openInterface() throws IOException 240 private void openInterface() throws IOException { 241 241 try { 242 242 // finally, open the interface on server side giving access to the wms server 243 243 URL interfaceURL = new URL(BASE_URL + "/scpc/"+interfaceRef); 244 urlConn = (HttpURLConnection) interfaceURL.openConnection();244 urlConn = (HttpURLConnection) interfaceURL.openConnection(); 245 245 urlConn.setRequestMethod("GET"); 246 246 setCookie(); … … 283 283 * where QP224 is the code commune known by the WMS (or "afficherCarteTa.do?c=..." for raster images). 284 284 * 285 * @param location286 * @param codeCommune287 285 * @return retURL url to available code commune in the cadastre; "" if not found 288 * @throws IOException289 286 */ 290 287 private String postForm(WMSLayer wmsLayer, String codeCommune) throws IOException { … … 308 305 content += "&x=0&y=0"; 309 306 searchFormURL = new URL(BASE_URL + "/scpc/rechercherPlan.do"); 310 urlConn = (HttpURLConnection) searchFormURL.openConnection();307 urlConn = (HttpURLConnection) searchFormURL.openConnection(); 311 308 urlConn.setRequestMethod("POST"); 312 309 urlConn.setDoOutput(true); … … 335 332 if (!wmsLayer.isRaster() && lines.indexOf(C_INTERFACE_VECTOR) != -1) { // "afficherCarteCommune.do" 336 333 // shall be something like: interfaceRef = "afficherCarteCommune.do?c=X2269"; 337 lines = lines.substring(lines.indexOf(C_INTERFACE_VECTOR), lines.length());334 lines = lines.substring(lines.indexOf(C_INTERFACE_VECTOR), lines.length()); 338 335 lines = lines.substring(0, lines.indexOf('\'')); 339 336 lines = Entities.unescape(lines); … … 369 366 } catch (MalformedURLException e) { 370 367 throw (IOException) new IOException("Illegal url.").initCause(e); 371 } catch (DuplicateLayerException e) {368 } catch (DuplicateLayerException e) { 372 369 Main.error(e); 373 370 } … … 401 398 try { 402 399 URL getAllImagesURL = new URL(BASE_URL + "/scpc/listerFeuillesParcommune.do?keepVolatileSession=&offset=2000"); 403 urlConn2 = (HttpURLConnection) getAllImagesURL.openConnection();400 urlConn2 = (HttpURLConnection) getAllImagesURL.openConnection(); 404 401 setCookie(urlConn2); 405 402 urlConn2.connect(); … … 491 488 * and store the result in the wmsLayer as well. 492 489 * @param wmsLayer the WMSLayer where the commune data and images are stored 493 * @throws IOException494 490 */ 495 491 public void retrieveCommuneBBox(WMSLayer wmsLayer) throws IOException { … … 500 496 content += "&dontSaveLastForward&keepVolatileSession="; 501 497 searchFormURL = new URL(content); 502 urlConn = (HttpURLConnection) searchFormURL.openConnection();498 urlConn = (HttpURLConnection) searchFormURL.openConnection(); 503 499 urlConn.setRequestMethod("GET"); 504 500 setCookie(); … … 534 530 int l = input.indexOf(C_BBOX_COMMUN_END, k+1); 535 531 double maxy = Double.parseDouble(input.substring(k+1, l)); 536 wmsLayer.setCommuneBBox( new EastNorthBound(new EastNorth(minx,miny), new EastNorth(maxx,maxy)));532 wmsLayer.setCommuneBBox(new EastNorthBound(new EastNorth(minx, miny), new EastNorth(maxx, maxy))); 537 533 } 538 534 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
r32425 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 46 46 * a city/town/village code. 47 47 * 48 * @author Pieren <pieren3@gmail.com>,49 * <matthieu.lochegnies@gmail.com>for the extension to codeCommune48 * @author Pieren <pieren3@gmail.com>, 49 * <matthieu.lochegnies@gmail.com> for the extension to codeCommune 50 50 * 51 51 * @version 2.6 … … 171 171 public static String grabLayers, grabStyles = null; 172 172 173 static privateboolean menuEnabled = false;173 private static boolean menuEnabled = false; 174 174 175 175 private static String LAYER_BULDINGS = "CDIF:LS2"; … … 204 204 cacheDir = Main.pref.get("cadastrewms.cacheDir"); 205 205 } 206 if (cacheDir.charAt(cacheDir.length()-1) != File.separatorChar 206 if (cacheDir.charAt(cacheDir.length()-1) != File.separatorChar) 207 207 cacheDir += File.separatorChar; 208 208 Main.info("current cache directory: "+cacheDir); … … 212 212 UploadAction.registerUploadHook(new CheckSourceUploadHook()); 213 213 214 registerSessionLayerExporter(WMSLayer.class 214 registerSessionLayerExporter(WMSLayer.class, CadastreSessionExporter.class); 215 215 registerSessionLayerImporter("cadastre-fr", CadastreSessionImporter.class); 216 216 } … … 277 277 if (currentResolution.equals("high")) { 278 278 imageWidth = 1000; imageHeight = 800; 279 } else if (currentResolution.equals("medium")) {279 } else if (currentResolution.equals("medium")) { 280 280 imageWidth = 800; imageHeight = 600; 281 281 } else { … … 339 339 grabStyles = grabStyles.substring(0, grabStyles.length()-1); 340 340 } else { 341 JOptionPane.showMessageDialog(Main.parent, tr("Please enable at least two WMS layers in the cadastre-fr "341 JOptionPane.showMessageDialog(Main.parent, tr("Please enable at least two WMS layers in the cadastre-fr " 342 342 + "plugin configuration.\nLayers ''Building'' and ''Parcel'' added by default.")); 343 343 Main.pref.put("cadastrewms.layerBuilding", true); … … 430 430 try { 431 431 Thread.sleep(milliseconds); 432 } catch (InterruptedException e) {} 432 } catch (InterruptedException e) { 433 Main.debug(e); 434 } 433 435 } 434 436 … … 439 441 try { 440 442 dialog.setAlwaysOnTop(true); 441 } catch (SecurityException e) {443 } catch (SecurityException e) { 442 444 Main.warn(tr("Warning: failed to put option pane dialog always on top. Exception was: {0}", e.toString())); 443 445 } … … 457 459 if (Main.map != null && Main.map.mapView != null) { 458 460 int wmsNewLayerPos = Main.getLayerManager().getLayers().size(); 459 for (Layer l : Main.getLayerManager().getLayersOfType(WMSLayer.class)) {461 for (Layer l : Main.getLayerManager().getLayersOfType(WMSLayer.class)) { 460 462 int wmsPos = Main.getLayerManager().getLayers().indexOf(l); 461 463 if (wmsPos < wmsNewLayerPos) wmsNewLayerPos = wmsPos; … … 477 479 try { 478 480 year = Integer.decode(srcYear); 479 } catch (NumberFormatException e) {} 481 } catch (NumberFormatException e) { 482 Main.debug(e); 483 } 480 484 if (srcYear.equals("AAAA") || (year != null && year < currentYear)) { 481 485 Main.info("Replace source year "+srcYear+" by current year "+currentYear); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java
r30703 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.ActionListener; 9 import javax.swing.*; 9 10 import javax.swing.AbstractButton; 11 import javax.swing.BorderFactory; 12 import javax.swing.Box; 13 import javax.swing.ButtonGroup; 14 import javax.swing.JCheckBox; 15 import javax.swing.JComboBox; 16 import javax.swing.JLabel; 17 import javax.swing.JPanel; 18 import javax.swing.JRadioButton; 19 import javax.swing.JScrollPane; 20 import javax.swing.JSeparator; 21 import javax.swing.JSlider; 22 import javax.swing.JTextField; 23 import javax.swing.SwingConstants; 10 24 11 25 import org.openstreetmap.josm.Main; … … 19 33 * Preference settings for the French Cadastre plugin 20 34 * 21 * @author Pieren <pieren3@gmail.com>35 * @author Pieren <pieren3@gmail.com> 22 36 */ 23 37 public class CadastrePreferenceSetting extends DefaultTabPreferenceSetting { … … 42 56 43 57 private JCheckBox enableTableauAssemblage = new JCheckBox(tr("Use \"Tableau d''assemblage\"")); 44 58 45 59 private JCheckBox simplify2BitsColors = new JCheckBox(tr("Replace grey shades by white color only")); 46 60 … … 92 106 93 107 static final int DEFAULT_CROSSPIECES = 0; 94 108 95 109 static final String DEFAULT_GRAB_MULTIPLIER = Scale.SQUARE_100M.value; 96 110 … … 108 122 } 109 123 124 @Override 110 125 public void addGui(final PreferenceTabbedPane gui) { 111 126 JPanel cadastrewmsMast = gui.createPreferenceTab(this); 112 127 113 128 JPanel cadastrewms = new JPanel(new GridBagLayout()); 114 cadastrewms.setBorder(BorderFactory.createEmptyBorder(0, 0,0,0));129 cadastrewms.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); 115 130 116 131 // option to automatically set the source tag when uploading … … 128 143 // option to reverse the grey colors (to see texts background) 129 144 reversGrey.setSelected(Main.pref.getBoolean("cadastrewms.invertGrey", false)); 130 reversGrey.setToolTipText(tr("Invert the original black and white colors (and all intermediate greys). Useful for texts on dark backgrounds.")); 145 reversGrey.setToolTipText( 146 tr("Invert the original black and white colors (and all intermediate greys). Useful for texts on dark backgrounds.")); 131 147 cadastrewms.add(reversGrey, GBC.eop().insets(0, 0, 0, 0)); 132 148 133 149 // option to enable transparency 134 150 transparency.addActionListener(new ActionListener() { 151 @Override 135 152 public void actionPerformed(ActionEvent e) { 136 153 sliderTrans.setEnabled(transparency.isSelected()); … … 146 163 sliderTrans.setMajorTickSpacing(10); 147 164 sliderTrans.setMinorTickSpacing(1); 148 sliderTrans.setValue((int) (Float.parseFloat(Main.pref.get("cadastrewms.brightness", "1.0f"))*10));165 sliderTrans.setValue((int) (Float.parseFloat(Main.pref.get("cadastrewms.brightness", "1.0f"))*10)); 149 166 sliderTrans.setPaintTicks(true); 150 167 sliderTrans.setPaintLabels(false); … … 201 218 ButtonGroup bgGrabMultiplier = new ButtonGroup(); 202 219 ActionListener multiplierActionListener = new ActionListener() { 220 @Override 203 221 public void actionPerformed(ActionEvent actionEvent) { 204 222 AbstractButton button = (AbstractButton) actionEvent.getSource(); … … 208 226 grabMultiplier1.setIcon(ImageProvider.get("preferences", "unsel_box_1")); 209 227 grabMultiplier1.setSelectedIcon(ImageProvider.get("preferences", "sel_box_1")); 210 grabMultiplier1.addActionListener( 228 grabMultiplier1.addActionListener(multiplierActionListener); 211 229 grabMultiplier1.setToolTipText(tr("Grab one image full screen")); 212 230 grabMultiplier2.setIcon(ImageProvider.get("preferences", "unsel_box_2")); 213 231 grabMultiplier2.setSelectedIcon(ImageProvider.get("preferences", "sel_box_2")); 214 grabMultiplier2.addActionListener( 232 grabMultiplier2.addActionListener(multiplierActionListener); 215 233 grabMultiplier2.setToolTipText(tr("Grab smaller images (higher quality but use more memory)")); 216 234 grabMultiplier3.setIcon(ImageProvider.get("preferences", "unsel_box_3")); 217 235 grabMultiplier3.setSelectedIcon(ImageProvider.get("preferences", "sel_box_3")); 218 grabMultiplier3.addActionListener( 236 grabMultiplier3.addActionListener(multiplierActionListener); 219 237 grabMultiplier3.setToolTipText(tr("Grab smaller images (higher quality but use more memory)")); 220 238 grabMultiplier4.setIcon(ImageProvider.get("preferences", "unsel_box_4")); 221 239 grabMultiplier4.setSelectedIcon(ImageProvider.get("preferences", "sel_box_4")); 222 grabMultiplier4.addActionListener( 240 grabMultiplier4.addActionListener(multiplierActionListener); 223 241 grabMultiplier4.setToolTipText(tr("Fixed size square (default is 100m)")); 224 242 bgGrabMultiplier.add(grabMultiplier1); … … 321 339 // option to enable automatic caching 322 340 enableCache.addActionListener(new ActionListener() { 341 @Override 323 342 public void actionPerformed(ActionEvent e) { 324 343 jLabelCacheSize.setEnabled(enableCache.isSelected()); … … 356 375 cadastrewms.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL)); 357 376 JScrollPane scrollpane = new JScrollPane(cadastrewms); 358 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0));377 scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); 359 378 cadastrewmsMast.add(scrollpane, GBC.eol().fill(GBC.BOTH)); 360 379 } 361 380 381 @Override 362 382 public boolean ok() { 363 383 Main.pref.put("cadastrewms.source", sourcing.getText()); … … 366 386 Main.pref.put("cadastrewms.invertGrey", reversGrey.isSelected()); 367 387 Main.pref.put("cadastrewms.backgroundTransparent", transparency.isSelected()); 368 Main.pref.put("cadastrewms.brightness", Float.toString((float) sliderTrans.getValue()/10));388 Main.pref.put("cadastrewms.brightness", Float.toString((float) sliderTrans.getValue()/10)); 369 389 Main.pref.put("cadastrewms.drawBoundaries", drawBoundaries.isSelected()); 370 390 if (grabRes1.isSelected()) … … 392 412 if (squareSize >= 25 && squareSize <= 1000) 393 413 Main.pref.put("cadastrewms.squareSize", grabMultiplier4Size.getText()); 394 } catch (NumberFormatException e) { // ignore the last input 414 } catch (NumberFormatException e) { 415 Main.debug(e); 395 416 } 396 417 } … … 408 429 if (i > 0 && i < 13) 409 430 Main.pref.put("cadastrewms.rasterDivider", String.valueOf(i)); 410 } catch (NumberFormatException e) { // ignore the last input 431 } catch (NumberFormatException e) { 432 Main.debug(e); 411 433 } 412 434 Main.pref.put("cadastrewms.noImageCropping", disableImageCropping.isSelected()); … … 423 445 CacheControl.cacheSize = Integer.parseInt(cacheSize.getText()); 424 446 Main.pref.put("cadastrewms.cacheSize", String.valueOf(CacheControl.cacheSize)); 425 } catch (NumberFormatException e) { // ignore the last input 447 } catch (NumberFormatException e) { 448 Main.debug(e); 426 449 } 427 450 Main.pref.put("cadastrewms.autoFirstLayer", autoFirstLayer.isSelected()); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionExporter.java
r30738 r32556 1 // License: GPL. For details, see LICENSE file. 1 2 package cadastre_fr; 2 3 … … 44 45 p.add(export, GBC.std()); 45 46 p.add(lbl, GBC.std()); 46 p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL));47 p.add(GBC.glue(1, 0), GBC.std().fill(GBC.HORIZONTAL)); 47 48 return p; 48 49 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionImporter.java
r32211 r32556 1 // License: GPL. For details, see LICENSE file. 1 2 package cadastre_fr; 2 3 … … 20 21 import org.w3c.dom.Element; 21 22 22 public class CadastreSessionImporter implements SessionLayerImporter {23 public class CadastreSessionImporter implements SessionLayerImporter { 23 24 24 25 @Override … … 41 42 fileStr = URLDecoder.decode(fileStr, "UTF-8"); 42 43 fileStr = fileStr.substring(fileStr.indexOf(":/")+2); 43 String filename = fileStr.substring(fileStr.lastIndexOf('/')+1, fileStr.length());44 String ext = (filename.lastIndexOf('.') ==-1)?"":filename.substring(filename.lastIndexOf('.')+1,filename.length());44 String filename = fileStr.substring(fileStr.lastIndexOf('/')+1, fileStr.length()); 45 String ext = (filename.lastIndexOf('.') == -1) ? "" : filename.substring(filename.lastIndexOf('.')+1, filename.length()); 45 46 // create layer and load cache 46 47 if (ext.length() == 3 && ext.substring(0, CacheControl.C_LAMBERT_CC_9Z.length()).equals(CacheControl.C_LAMBERT_CC_9Z)) -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CheckSourceUploadHook.java
r30737 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 30 30 * automatically a tag "source"="Cadastre..." as defined in the plugin preferences. 31 31 */ 32 public class CheckSourceUploadHook implements UploadHook 33 { 32 public class CheckSourceUploadHook implements UploadHook { 34 33 35 34 /** 36 35 * Add the tag "source" if it doesn't exist for all new Nodes and Ways before uploading 37 36 */ 38 public boolean checkUpload(APIDataSet apiDataSet)39 {37 @Override 38 public boolean checkUpload(APIDataSet apiDataSet) { 40 39 if (CadastrePlugin.autoSourcing && CadastrePlugin.pluginUsed && !apiDataSet.getPrimitivesToAdd().isEmpty()) { 41 40 Collection<OsmPrimitive> sel = new HashSet<>(); … … 55 54 /** 56 55 * Check whenever one of the keys of the object is "source" 57 * @param OsmPrimitive58 56 * @return true if one of keys is "source" 59 57 */ 60 58 private boolean tagSourceExist(OsmPrimitive osm) { 61 59 for (String key : osm.keySet()) { 62 if (key.equals("source") 60 if (key.equals("source")) { 63 61 return true; 64 62 } … … 72 70 * @param sel the list of elements added without a key "source" 73 71 */ 74 private void displaySource(Collection<OsmPrimitive> sel) 75 { 72 private void displaySource(Collection<OsmPrimitive> sel) { 76 73 if (!sel.isEmpty()) { 77 74 JPanel p = new JPanel(new GridBagLayout()); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGBuilding.java
r32425 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 106 106 107 107 // convert SVG nodes to eastNorth coordinates 108 for (int i =0; i< SVGpaths.length; i++) {108 for (int i = 0; i < SVGpaths.length; i++) { 109 109 ArrayList<EastNorth> eastNorth = new ArrayList<>(); 110 110 createNodes(SVGpaths[i], eastNorth); … … 147 147 for (Way w : svgDataSet.getWays()) { 148 148 int replaced = 0; 149 for (Node node : w.getNodes()) 149 for (Node node : w.getNodes()) { 150 150 if (node == n) { 151 151 node = nearestNewNode; 152 152 replaced++; 153 153 } 154 } 154 155 if (w.getNodesCount() == replaced) 155 156 w.setDeleted(true); … … 161 162 162 163 Collection<Command> cmds = new LinkedList<>(); 163 for (Node node : svgDataSet.getNodes()) 164 for (Node node : svgDataSet.getNodes()) { 164 165 if (!node.isDeleted()) 165 166 cmds.add(new AddCommand(node)); 166 for (Way way : svgDataSet.getWays()) 167 } 168 for (Way way : svgDataSet.getWays()) { 167 169 if (!way.isDeleted()) 168 170 cmds.add(new AddCommand(way)); 171 } 169 172 Main.main.undoRedo.add(new SequenceCommand(tr("Create buildings"), cmds)); 170 173 Main.map.repaint(); … … 176 179 double dx = Double.parseDouble(coor[1]); 177 180 double dy = Double.parseDouble(coor[2]); 178 for (int i =3; i<coor.length; i+=2){181 for (int i = 3; i < coor.length; i += 2) { 179 182 if (coor[i].isEmpty()) { 180 183 eastNorth.clear(); // some paths are just artifacts 181 184 return; 182 185 } 183 double east = dx +=Double.parseDouble(coor[i]);184 double north = dy +=Double.parseDouble(coor[i+1]);185 eastNorth.add(new EastNorth(east, north));186 double east = dx += Double.parseDouble(coor[i]); 187 double north = dy += Double.parseDouble(coor[i+1]); 188 eastNorth.add(new EastNorth(east, north)); 186 189 } 187 190 // flip the image (svg using a reversed Y coordinate system) … … 240 243 241 244 private String grabSVG(URL url) throws IOException, OsmTransferException { 242 wmsInterface.urlConn = (HttpURLConnection) url.openConnection();245 wmsInterface.urlConn = (HttpURLConnection) url.openConnection(); 243 246 wmsInterface.urlConn.setRequestProperty("Connection", "close"); 244 247 wmsInterface.urlConn.setRequestMethod("GET"); … … 253 256 BufferedReader br = new BufferedReader(isr)) { 254 257 String line; 255 while ( null!=(line=br.readLine())){258 while (null != (line = br.readLine())) { 256 259 line += "\n"; 257 260 bos.write(line.getBytes(StandardCharsets.UTF_8)); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadSVGTask.java
r32211 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 111 111 ArrayList<Double> fitViewBox = new ArrayList<>(); 112 112 ArrayList<ArrayList<EastNorth>> eastNorths = new ArrayList<>(); 113 for (int i =0; i< SVGpaths.length; i++) {113 for (int i = 0; i < SVGpaths.length; i++) { 114 114 ArrayList<EastNorth> eastNorth = new ArrayList<>(); 115 fitViewBox.add( createNodes(SVGpaths[i], eastNorth));115 fitViewBox.add(createNodes(SVGpaths[i], eastNorth)); 116 116 eastNorths.add(eastNorth); 117 117 } … … 149 149 double maxY = Double.MIN_VALUE; 150 150 double maxX = Double.MIN_VALUE; 151 for (int i =3; i<coor.length; i+=2){152 double east = dx +=Double.parseDouble(coor[i]);153 double north = dy +=Double.parseDouble(coor[i+1]);154 eastNorth.add(new EastNorth(east, north));151 for (int i = 3; i < coor.length; i += 2) { 152 double east = dx += Double.parseDouble(coor[i]); 153 double north = dy += Double.parseDouble(coor[i+1]); 154 eastNorth.add(new EastNorth(east, north)); 155 155 minX = minX > east ? east : minX; 156 156 minY = minY > north ? north : minY; … … 193 193 194 194 private String grabSVG(URL url) throws IOException, OsmTransferException { 195 wmsInterface.urlConn = (HttpURLConnection) url.openConnection();195 wmsInterface.urlConn = (HttpURLConnection) url.openConnection(); 196 196 wmsInterface.urlConn.setRequestProperty("Connection", "close"); 197 197 wmsInterface.urlConn.setRequestMethod("GET"); … … 203 203 file.delete(); 204 204 try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file, true)); 205 InputStreamReader isr = new InputStreamReader(is);205 InputStreamReader isr = new InputStreamReader(is); 206 206 BufferedReader br = new BufferedReader(isr)) { 207 207 String line; 208 while ( null!=(line=br.readLine())){208 while (null != (line = br.readLine())) { 209 209 line += "\n"; 210 210 bos.write(line.getBytes(StandardCharsets.UTF_8)); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSPlanImage.java
r32060 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 24 24 25 25 private class Task extends PleaseWaitRunnable { 26 publicTask(WMSLayer wmsLayer, Bounds bounds) {26 Task(WMSLayer wmsLayer, Bounds bounds) { 27 27 super(tr("Downloading {0}", wmsLayer.getName())); 28 28 } … … 35 35 if (wmsLayer.grabber.getWmsInterface().retrieveInterface(wmsLayer)) { 36 36 if (!wmsLayer.getImages().isEmpty()) { 37 //JOptionPane.showMessageDialog(Main.parent,tr("Image already loaded")); 38 JOptionPane pane = new JOptionPane( 39 tr("Image already loaded") 40 , JOptionPane.INFORMATION_MESSAGE); 37 JOptionPane pane = new JOptionPane(tr("Image already loaded"), JOptionPane.INFORMATION_MESSAGE); 41 38 // this below is a temporary workaround to fix the "always on top" issue 42 39 JDialog dialog = pane.createDialog(Main.parent, ""); … … 45 42 // till here 46 43 dontGeoreference = true; 47 } else if (wmsLayer.grabber.getWmsInterface().downloadCanceled) {44 } else if (wmsLayer.grabber.getWmsInterface().downloadCanceled) { 48 45 // do nothing 49 46 } else { … … 73 70 "Use the normal Cadastre Grab menu."));*/ 74 71 JOptionPane pane = new JOptionPane( 75 tr("Municipality vectorized !\nUse the normal Cadastre Grab menu.") 76 ,JOptionPane.INFORMATION_MESSAGE);72 tr("Municipality vectorized !\nUse the normal Cadastre Grab menu."), 73 JOptionPane.INFORMATION_MESSAGE); 77 74 // this below is a temporary workaround to fix the "always on top" issue 78 75 JDialog dialog = pane.createDialog(Main.parent, ""); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSVectorImage.java
r32425 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 42 42 if (wmsLayer.isRaster()) { 43 43 // set raster image commune bounding box based on current view (before adjustment) 44 JOptionPane.showMessageDialog(Main.parent,tr("This commune is not vectorized.\nPlease use the other menu entry to georeference a \"Plan image\"")); 44 JOptionPane.showMessageDialog(Main.parent, 45 tr("This commune is not vectorized.\nPlease use the other menu entry to georeference a \"Plan image\"")); 45 46 Main.getLayerManager().removeLayer(wmsLayer); 46 47 wmsLayer = null; … … 53 54 // grab new images from wms server into active layer 54 55 wmsLayer.grab(bounds); 55 } 56 else if(wmsLayer.getImages().size()==0) 56 } else if (wmsLayer.getImages().size() == 0) 57 57 // failed to contact WMS of find this commune. Remove layer if empty. 58 58 Main.getLayerManager().removeLayer(wmsLayer); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DuplicateLayerException.java
r18544 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 4 4 class DuplicateLayerException extends Exception { 5 private static final long serialVersionUID = 1L;} 5 private static final long serialVersionUID = 1L; 6 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/EastNorthBound.java
r26228 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GeorefImage.java
r26835 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 44 44 private double pixelPerEast; 45 45 private double pixelPerNorth; 46 47 46 48 47 public GeorefImage(BufferedImage img, EastNorth min, EastNorth max, WMSLayer wmsLayer) { 49 48 image = img; 50 49 51 50 this.min = min; 52 51 this.max = max; … … 81 80 */ 82 81 private EastNorthBound computeNewBounding(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4) { 83 EastNorth pt[]= new EastNorth[4];82 EastNorth[] pt = new EastNorth[4]; 84 83 pt[0] = p1; 85 84 pt[1] = p2; … … 90 89 double highestEast = Double.MIN_VALUE; 91 90 double highestNorth = Double.MIN_VALUE; 92 for (int i=0; i<=3; i++) {91 for (int i = 0; i <= 3; i++) { 93 92 smallestEast = Math.min(pt[i].east(), smallestEast); 94 93 smallestNorth = Math.min(pt[i].north(), smallestNorth); … … 111 110 112 111 // apply offsets defined manually when vector images are translated manually (not saved in cache) 113 double dx =0, dy=0;114 if (wmsLayer !=null) {112 double dx = 0, dy = 0; 113 if (wmsLayer != null) { 115 114 dx = wmsLayer.deltaEast; 116 115 dy = wmsLayer.deltaNorth; … … 131 130 } else { 132 131 Point[] croppedPoint = new Point[5]; 133 for (int i =0; i<4; i++)132 for (int i = 0; i < 4; i++) { 134 133 croppedPoint[i] = nc.getPoint( 135 134 new EastNorth(orgCroppedRaster[i].east()+dx, orgCroppedRaster[i].north()+dy)); 135 } 136 136 croppedPoint[4] = croppedPoint[0]; 137 for (int i =0; i<4; i++) {137 for (int i = 0; i < 4; i++) { 138 138 g.setColor(Color.green); 139 139 g.drawLine(croppedPoint[i].x, croppedPoint[i].y, croppedPoint[i+1].x, croppedPoint[i+1].y); … … 173 173 /** 174 174 * Make all pixels masked by the given georefImage transparent in this image 175 *176 * @param georefImage177 175 */ 178 176 public void withdraw(GeorefImage georefImage) { … … 189 187 int heightYMaskPixel = Math.abs((int) ((maxMaskNorth - minMaskNorth) / pxPerNorth)); 190 188 Graphics g = image.getGraphics(); 191 for (int x = minXMaskPixel; x < minXMaskPixel + widthXMaskPixel; x++) 192 for (int y = minYMaskPixel; y < minYMaskPixel + heightYMaskPixel; y++) 189 for (int x = minXMaskPixel; x < minXMaskPixel + widthXMaskPixel; x++) { 190 for (int y = minYMaskPixel; y < minYMaskPixel + heightYMaskPixel; y++) { 193 191 image.setRGB(x, y, VectorImageModifier.cadastreBackgroundTransp); 192 } 193 } 194 194 g.dispose(); 195 195 } … … 222 222 if (WMSLayer.currentFormat >= 4) { 223 223 imageOriginalHeight = in.readInt(); 224 imageOriginalWidth = 225 } 226 image = (BufferedImage)ImageIO.read(ImageIO.createImageInputStream(in));224 imageOriginalWidth = in.readInt(); 225 } 226 image = ImageIO.read(ImageIO.createImageInputStream(in)); 227 227 updatePixelPer(); 228 228 } … … 285 285 min = new EastNorth(min.east() + dx, min.north() + dy); 286 286 max = new EastNorth(max.east() + dx, max.north() + dy); 287 for (int i =0; i<4; i++) {287 for (int i = 0; i < 4; i++) { 288 288 orgRaster[i] = new EastNorth(orgRaster[i].east() + dx, orgRaster[i].north() + dy); 289 289 orgCroppedRaster[i] = new EastNorth(orgCroppedRaster[i].east() + dx, orgCroppedRaster[i].north() + dy); 290 290 } 291 291 } 292 292 293 293 /** 294 294 * Change this image scale by moving the min,max coordinates around an anchor 295 * @param anchor296 * @param proportion297 295 */ 298 296 public void scale(EastNorth anchor, double proportion) { 299 297 min = anchor.interpolate(min, proportion); 300 298 max = anchor.interpolate(max, proportion); 301 for (int i =0; i<4; i++) {299 for (int i = 0; i < 4; i++) { 302 300 orgRaster[i] = anchor.interpolate(orgRaster[i], proportion); 303 301 orgCroppedRaster[i] = anchor.interpolate(orgCroppedRaster[i], proportion); … … 316 314 return; 317 315 // rotate the bounding boxes coordinates first 318 for (int i =0; i<4; i++) {316 for (int i = 0; i < 4; i++) { 319 317 orgRaster[i] = orgRaster[i].rotate(anchor, delta_ang); 320 318 orgCroppedRaster[i] = orgCroppedRaster[i].rotate(anchor, delta_ang); … … 323 321 double sin = Math.abs(Math.sin(angle+delta_ang)), cos = Math.abs(Math.cos(angle+delta_ang)); 324 322 int w = imageOriginalWidth, h = imageOriginalHeight; 325 int neww = (int) Math.floor(w*cos+h*sin);326 int newh = (int) Math.floor(h*cos+w*sin);323 int neww = (int) Math.floor(w*cos+h*sin); 324 int newh = (int) Math.floor(h*cos+w*sin); 327 325 GraphicsConfiguration gc = getDefaultConfiguration(); 328 326 BufferedImage result = gc.createCompatibleImage(neww, newh, image.getTransparency()); … … 336 334 min = enb.min; 337 335 max = enb.max; 338 angle +=delta_ang;336 angle += delta_ang; 339 337 } 340 338 … … 346 344 public void crop(EastNorth adj1, EastNorth adj2) { 347 345 // s1 and s2 have 0,0 at top, left where all EastNorth coord. have 0,0 at bottom, left 348 int sx1 = (int) ((adj1.getX() - min.getX())*getPixelPerEast());349 int sy1 = (int) ((max.getY() - adj2.getY())*getPixelPerNorth());350 int sx2 = (int) ((adj2.getX() - min.getX())*getPixelPerEast());351 int sy2 = (int) ((max.getY() - adj1.getY())*getPixelPerNorth());346 int sx1 = (int) ((adj1.getX() - min.getX())*getPixelPerEast()); 347 int sy1 = (int) ((max.getY() - adj2.getY())*getPixelPerNorth()); 348 int sx2 = (int) ((adj2.getX() - min.getX())*getPixelPerEast()); 349 int sy2 = (int) ((max.getY() - adj1.getY())*getPixelPerNorth()); 352 350 int newWidth = Math.abs(sx2 - sx1); 353 351 int newHeight = Math.abs(sy2 - sy1); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GrabThread.java
r32060 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 35 35 /** 36 36 * Call directly grabber for raster images or prepare thread for vector images 37 * @param moreImages38 37 */ 39 38 public void addImages(ArrayList<EastNorthBound> moreImages) { … … 41 40 imagesToGrab.addAll(moreImages); 42 41 lockImagesToGrag.unlock(); 43 synchronized (this) {42 synchronized (this) { 44 43 this.notify(); 45 44 } … … 139 138 notifyWaiter(); 140 139 } 141 waitNotification(); } 140 waitNotification(); 141 } 142 142 } 143 143 … … 152 152 getCacheControl().deleteCacheFile(); 153 153 wmsLayer.imagesLock.lock(); 154 for (GeorefImage image : wmsLayer.getImages()) 154 for (GeorefImage image : wmsLayer.getImages()) { 155 155 getCacheControl().saveCache(image); 156 } 156 157 wmsLayer.imagesLock.unlock(); 157 158 } … … 199 200 croppedPoint[3] = mv.getPoint(new EastNorth(img.max.east(), img.min.north())); 200 201 croppedPoint[4] = croppedPoint[0]; 201 for (int i =0; i<4; i++) {202 for (int i = 0; i < 4; i++) { 202 203 g.setColor(color); 203 204 g.drawLine(croppedPoint[i].x, croppedPoint[i].y, croppedPoint[i+1].x, croppedPoint[i+1].y); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/ImageModifier.java
r30701 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others 2 // Some of the procedures below are imported from image4j.sourceforge.net, license LGPL. 1 // License: GPL. For details, see LICENSE file. 3 2 package cadastre_fr; 4 3 … … 25 24 protected BufferedImage convert1(BufferedImage src) { 26 25 IndexColorModel icm = new IndexColorModel( 27 1, 2, new byte[] { (byte) 0, (byte) 0xFF }, 28 new byte[] { (byte) 0, (byte) 0xFF }, 29 new byte[] { (byte) 0, (byte) 0xFF } 26 1, 2, 27 new byte[] {(byte) 0, (byte) 0xFF}, 28 new byte[] {(byte) 0, (byte) 0xFF}, 29 new byte[] {(byte) 0, (byte) 0xFF} 30 30 ); 31 31 … … 113 113 114 114 public boolean isBuildingColor(int rgb, boolean ignoreParcelColor) { 115 for (int i = 0; i < cBuilingFootColors.length; i++) 115 for (int i = 0; i < cBuilingFootColors.length; i++) { 116 116 if (rgb == cBuilingFootColors[i]) 117 117 return true; 118 } 118 119 if (ignoreParcelColor && (rgb == parcelColor)) 119 120 return true; … … 122 123 123 124 public boolean isRoofColor(int rgb, boolean ignoreParcelColor) { 124 for (int i = 0; i < cRoofColors.length; i++) 125 for (int i = 0; i < cRoofColors.length; i++) { 125 126 if (rgb == cRoofColors[i]) 126 127 return true; 128 } 127 129 if (ignoreParcelColor && (rgb == parcelColor)) 128 130 return true; … … 153 155 /** 154 156 * Checks if the rgb value is the black background color 155 * @param156 * @return157 157 */ 158 158 public boolean isBackgroundColor(BufferedImage img, int x, int y) { -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionBoundaries.java
r18544 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 22 22 } 23 23 24 @Override 24 25 public void actionPerformed(ActionEvent arg0) { 25 26 wmsLayer = WMSDownloadAction.getLayer(); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionCancelGrab.java
r26382 r32556 1 // License: GPL. For details, see LICENSE file. 1 2 package cadastre_fr; 2 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 3 5 import static org.openstreetmap.josm.tools.I18n.tr; 4 import static org.openstreetmap.josm.tools.I18n.marktr;5 6 6 7 import java.awt.event.ActionEvent; … … 20 21 } 21 22 22 23 23 @Override 24 24 public void actionPerformed(ActionEvent arg0) { … … 27 27 } 28 28 } 29 30 29 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrab.java
r30701 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 25 25 } 26 26 27 @Override 27 28 public void actionPerformed(ActionEvent e) { 28 29 if (Main.map != null) { -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java
r32329 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 25 25 private WMSLayer wmsLayer; 26 26 private RasterImageGeoreferencer rasterImageGeoreferencer; 27 27 28 28 public MenuActionGrabPlanImage() { 29 29 super(tr(name), "cadastre_small", tr("Grab non-georeferenced image"), null, false, "cadastrefr/grabplanimage", true); … … 36 36 if (!rasterImageGeoreferencer.isRunning()) return; 37 37 if (Main.getLayerManager().containsLayer(wmsLayer)) 38 38 return; 39 39 JOptionPane.showMessageDialog(Main.parent, tr("Georeferencing interrupted")); 40 40 rasterImageGeoreferencer.actionInterrupted(); … … 42 42 43 43 @Override 44 44 public void actionPerformed(ActionEvent ae) { 45 45 if (Main.map != null) { 46 46 if (CadastrePlugin.isCadastreProjection()) { … … 58 58 59 59 @Override 60 60 public void run() { 61 61 // wait until plan image is fully loaded and joined into one single image 62 62 boolean loadedFromCache = downloadWMSPlanImage.waitFinished(); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionLoadFromCache.java
r32329 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 39 39 if (file.exists()) { 40 40 String filename = file.getName(); 41 String ext = (filename.lastIndexOf('.') ==-1)?"":filename.substring(filename.lastIndexOf('.')+1,filename.length());41 String ext = (filename.lastIndexOf('.') == -1) ? "" : filename.substring(filename.lastIndexOf('.')+1, filename.length()); 42 42 if ((ext.length() == 3 && ext.substring(0, CacheControl.C_LAMBERT_CC_9Z.length()).equals(CacheControl.C_LAMBERT_CC_9Z) && 43 43 !(CadastrePlugin.isLambert_cc9())) … … 45 45 !(CadastrePlugin.isUtm_france_dom())) 46 46 || (ext.length() == 1) && !(CadastrePlugin.isLambert())) { 47 JOptionPane.showMessageDialog(Main.parent, tr("{0} not allowed with the current projection", filename), tr("Error"), JOptionPane.ERROR_MESSAGE); 47 JOptionPane.showMessageDialog(Main.parent, tr("{0} not allowed with the current projection", filename), 48 tr("Error"), JOptionPane.ERROR_MESSAGE); 48 49 continue; 49 50 } else { … … 56 57 try { 57 58 int cacheZone = Integer.parseInt(ext) - 1; 58 if (cacheZone >= 0 && cacheZone <= 9) {59 if (cacheZone >= 0 && cacheZone <= 9) { 59 60 if (cacheZone != layoutZone) { 60 JOptionPane.showMessageDialog(Main.parent, tr("Cannot load cache {0} which is not compatible with current projection zone", filename), tr("Error"), JOptionPane.ERROR_MESSAGE); 61 JOptionPane.showMessageDialog(Main.parent, 62 tr("Cannot load cache {0} which is not compatible with current projection zone", filename), 63 tr("Error"), JOptionPane.ERROR_MESSAGE); 61 64 continue nextFile; 62 65 } else -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionNewLocation.java
r32329 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 23 23 private static final long serialVersionUID = 1L; 24 24 25 private static final String departements[] = { 25 // CHECKSTYLE.OFF: LineLength 26 // CHECKSTYLE.OFF: SingleSpaceSeparator 27 28 private static final String[] departements = { 26 29 "", tr("(optional)"), 27 30 "001", "01 - Ain", "002", "02 - Aisne", "003", "03 - Allier", "004", "04 - Alpes de Haute-Provence", "005", "05 - Hautes-Alpes", … … 48 51 }; 49 52 53 // CHECKSTYLE.ON: SingleSpaceSeparator 54 // CHECKSTYLE.ON: LineLength 55 50 56 public MenuActionNewLocation() { 51 super(tr("Change location"), "cadastre_small", tr("Set a new location for the next request"), null, false, "cadastrefr/newlocation", true); 57 super(tr("Change location"), "cadastre_small", tr("Set a new location for the next request"), null, false, 58 "cadastrefr/newlocation", true); 52 59 } 53 60 … … 66 73 JPanel p = new JPanel(new GridBagLayout()); 67 74 JLabel labelLocation = new JLabel(tr("Commune")); 68 final JTextField inputTown = new JTextField( Main.pref.get("cadastrewms.location"));75 final JTextField inputTown = new JTextField(Main.pref.get("cadastrewms.location")); 69 76 inputTown.setToolTipText(tr("<html>Enter the town,village or city name.<br>" 70 77 + "Use the syntax and punctuation known by www.cadastre.gouv.fr .</html>")); 71 JLabel labelDepartement = 78 JLabel labelDepartement = new JLabel(tr("Departement")); 72 79 final JComboBox<String> inputDepartement = new JComboBox<>(); 73 for (int i =1; i<departements.length; i+=2) {80 for (int i = 1; i < departements.length; i += 2) { 74 81 inputDepartement.addItem(departements[i]); 75 82 } 76 83 inputDepartement.setToolTipText(tr("<html>Departement number (optional)</html>")); 77 84 if (!Main.pref.get("cadastrewms.codeDepartement").equals("")) { 78 for (int i =0; i < departements.length; i=i+2)85 for (int i = 0; i < departements.length; i += 2) { 79 86 if (departements[i].equals(Main.pref.get("cadastrewms.codeDepartement"))) 80 87 inputDepartement.setSelectedIndex(i/2); 88 } 81 89 } 82 90 p.add(labelSectionNewLocation, GBC.eol()); … … 119 127 Main.info("Add new layer with Location:" + inputTown.getText()); 120 128 } else if (existingLayers != null && existingLayers.size() > 0 && Main.getLayerManager().getActiveLayer() instanceof WMSLayer) { 121 wmsLayer = (WMSLayer) Main.getLayerManager().getActiveLayer();129 wmsLayer = (WMSLayer) Main.getLayerManager().getActiveLayer(); 122 130 } 123 131 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionOpenPreferences.java
r29194 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Vincent Privat <vincent.privat@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 11 11 import org.openstreetmap.josm.gui.preferences.PreferenceDialog; 12 12 13 public class MenuActionOpenPreferences extends JosmAction { 14 private static final long serialVersionUID = 1L; 13 public class MenuActionOpenPreferences extends JosmAction { 14 private static final long serialVersionUID = 1L; 15 15 16 public static String name = marktr("Preferences"); 16 public static String name = marktr("Preferences"); 17 17 18 public MenuActionOpenPreferences() { 19 super(tr(name), "cadastre_small", tr("Open Cadastre Preferences"), null, false, "cadastrefr/openpreferences", true); 20 } 21 22 public void actionPerformed(ActionEvent e) { 23 PreferenceDialog p = new PreferenceDialog(Main.parent); 24 p.selectPreferencesTabByClass(CadastrePreferenceSetting.class); 25 p.setVisible(true); 26 } 18 public MenuActionOpenPreferences() { 19 super(tr(name), "cadastre_small", tr("Open Cadastre Preferences"), null, false, "cadastrefr/openpreferences", true); 20 } 21 22 @Override 23 public void actionPerformed(ActionEvent e) { 24 PreferenceDialog p = new PreferenceDialog(Main.parent); 25 p.selectPreferencesTabByClass(CadastrePreferenceSetting.class); 26 p.setVisible(true); 27 } 27 28 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionRefineGeoRef.java
r30859 r32556 1 // License: GPL. For details, see LICENSE file. 1 2 package cadastre_fr; 2 3 … … 24 25 @Override 25 26 public void actionPerformed(ActionEvent arg0) { 26 if (!wmsLayer.isRaster()) {27 if (!wmsLayer.isRaster()) { 27 28 Main.info("MenuActionRefineGeoRef called for unexpected layer type"); 28 29 return; -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionResetCookie.java
r25045 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 19 19 } 20 20 21 @Override 21 22 public void actionPerformed(ActionEvent e) { 22 23 //CadastrePlugin.cadastreGrabber.getWmsInterface().resetCookie(); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionSaveRasterAs.java
r32060 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 43 43 return file.getName().toLowerCase().endsWith(".png"); 44 44 } 45 45 46 @Override 46 47 public String getDescription() { … … 57 58 return file.getName().toLowerCase().endsWith(".tif"); 58 59 } 60 59 61 @Override 60 62 public String getDescription() { … … 82 84 file = fc.getSelectedFile(); 83 85 BufferedImage bi = wmsLayer.getImage(0).image; 84 if (fc.getFileFilter().equals(filtrePng)) 85 { 86 if (fc.getFileFilter().equals(filtrePng)) { 86 87 if (!file.getName().endsWith(".png")) 87 88 file = new File(file.getParent(), file.getName()+".png"); … … 98 99 e.printStackTrace(); 99 100 } 100 } 101 else if (fc.getFileFilter().equals(filtreTiff)) 102 { 101 } else if (fc.getFileFilter().equals(filtreTiff)) { 103 102 boolean alpha = bi.getColorModel().hasAlpha(); 104 103 Main.info("image with alpha channel : " + alpha); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageGeoreferencer.java
r32425 r32556 1 // License: GPL. For details, see LICENSE file. 1 2 package cadastre_fr; 2 3 … … 39 40 private int initialClickDelay; 40 41 41 public void addListener() {42 public void addListener() { 42 43 Main.map.mapView.addMouseListener(this); 43 44 } … … 51 52 mode = cGetCorners; 52 53 countMouseClicked = 0; 53 initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay", 200);54 initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay", 200); 54 55 mouseClickedTime = System.currentTimeMillis(); 55 Object[] options = { "OK", "Cancel"};56 int ret = JOptionPane.showOptionDialog( 56 Object[] options = {"OK", "Cancel"}; 57 int ret = JOptionPane.showOptionDialog(null, 57 58 tr("Click first corner for image cropping\n(two points required)"), 58 59 tr("Image cropping"), … … 75 76 countMouseClicked = 0; 76 77 mode = cGetLambertCrosspieces; 77 initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay", 200);78 initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay", 200); 78 79 mouseClickedTime = System.currentTimeMillis(); 79 Object[] options = { "OK", "Cancel"};80 int ret = JOptionPane.showOptionDialog( 80 Object[] options = {"OK", "Cancel"}; 81 int ret = JOptionPane.showOptionDialog(null, 81 82 tr("Click first Lambert crosspiece for georeferencing\n(two points required)"), 82 83 tr("Image georeferencing"), … … 91 92 } 92 93 93 public boolean isRunning() 94 { 94 public boolean isRunning() { 95 95 return (countMouseClicked != 0 || mode != 0); 96 96 } … … 101 101 Main.info("mouse click bounce detected"); 102 102 return; // mouse click anti-bounce 103 } 104 else 103 } else 105 104 mouseClickedTime = System.currentTimeMillis(); 106 105 if (e.getButton() != MouseEvent.BUTTON1) … … 115 114 // ignore clicks outside the image 116 115 if (ea.east() < wmsLayer.getImage(0).min.east() || ea.east() > wmsLayer.getImage(0).max.east() 117 || ea.north() < wmsLayer.getImage(0).min.north() || ea.north() > wmsLayer.getImage(0).max.north()) 118 { 116 || ea.north() < wmsLayer.getImage(0).min.north() || ea.north() > wmsLayer.getImage(0).max.north()) { 119 117 Main.info("ignore click outside the image"); 120 118 return; … … 144 142 } 145 143 146 147 144 /** 148 145 * … … 150 147 */ 151 148 private boolean canceledOrRestartCurrAction(String action) { 152 Object[] options = { "Cancel", "Retry"};153 int selectedValue = JOptionPane.showOptionDialog( 149 Object[] options = {"Cancel", "Retry"}; 150 int selectedValue = JOptionPane.showOptionDialog(null, 154 151 tr("Do you want to cancel completely\n"+ 155 152 "or just retry "+action+" ?"), "", … … 177 174 private void affineTransform(EastNorth org1, EastNorth org2, EastNorth dst1, EastNorth dst2) { 178 175 // handle an NPE case I'm not able to reproduce 179 if(org1==null || org2==null || dst1==null || dst2==null) 180 { 176 if (org1 == null || org2 == null || dst1 == null || dst2 == null) { 181 177 JOptionPane.showMessageDialog(Main.parent, 182 178 tr("Ooops. I failed to catch all coordinates\n"+ … … 286 282 */ 287 283 private boolean continueCropping() { 288 Object[] options = { "OK", "Cancel"};289 int ret = JOptionPane.showOptionDialog( 284 Object[] options = {"OK", "Cancel"}; 285 int ret = JOptionPane.showOptionDialog(null, 290 286 tr("Click second corner for image cropping"), 291 287 tr("Image cropping"), … … 316 312 */ 317 313 private boolean continueGeoreferencing() { 318 Object[] options = { "OK", "Cancel"};319 int ret = JOptionPane.showOptionDialog( 314 Object[] options = {"OK", "Cancel"}; 315 int ret = JOptionPane.showOptionDialog(null, 320 316 tr("Click second Lambert crosspiece for georeferencing"), 321 317 tr("Image georeferencing"), -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageModifier.java
r29828 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 12 12 13 13 private int cadastreBackground = -1; // white 14 14 15 15 public static int cadastreBackgroundTransp = 16777215; // original white but transparent 16 16 17 17 private boolean transparencyEnabled = false; 18 18 19 19 public RasterImageModifier(BufferedImage bi) { 20 20 bufferedImage = bi; 21 transparencyEnabled = Main.pref.getBoolean("cadastrewms.backgroundTransparent"); 21 transparencyEnabled = Main.pref.getBoolean("cadastrewms.backgroundTransparent"); 22 22 if (transparencyEnabled) 23 23 makeTransparent(); … … 35 35 for (int y = 0; y < h; y++) { 36 36 int pixel = bufferedImage.getRGB(x, y); 37 if ((!transparencyEnabled && pixel != cadastreBackground) 37 if ((!transparencyEnabled && pixel != cadastreBackground) 38 38 || (transparencyEnabled && pixel != cadastreBackgroundTransp)) { 39 39 bufferedImage.setRGB(x, y, reverseIfGrey(pixel)); … … 46 46 * Reverse the grey value if the pixel is grey (light grey becomes dark grey) 47 47 * Used for texts. 48 * @param pixel49 * @return50 48 */ 51 49 private int reverseIfGrey(int pixel) { … … 77 75 Color maskedColor; 78 76 if (rgb == cadastreBackground) { 79 maskedColor = simplifyColors ? new Color(0xff, 0xff, 0xff, 0x00) : 77 maskedColor = simplifyColors ? new Color(0xff, 0xff, 0xff, 0x00) : 80 78 new Color(r, g, b, 0x00); // transparent 81 79 } else { 82 maskedColor = simplifyColors ? new Color(0, 0, 0, 0xFF) : 80 maskedColor = simplifyColors ? new Color(0, 0, 0, 0xFF) : 83 81 new Color(r, g, b, 0xFF); // opaque 84 82 } … … 90 88 return; 91 89 } 92 90 93 91 /** 94 * Temporary fix for Java6 which doesn't de-serialize correctly cached image on disk. 95 * Recreate a new raster image based on what is loaded/serialized from disk cache. 96 * @param img 92 * Temporary fix for Java6 which doesn't de-serialize correctly cached image on disk. 93 * Recreate a new raster image based on what is loaded/serialized from disk cache. 97 94 * @return new image 98 95 */ … … 101 98 int height = img.getHeight(); 102 99 BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 103 int rgbArray[]= new int[width * height];100 int[] rgbArray = new int[width * height]; 104 101 img.getRGB(0, 0, width, height, rgbArray, 0, width); 105 102 bi.setRGB(0, 0, width, height, rgbArray, 0, width); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/SVGParser.java
r30737 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 7 7 * This class is not intended to be a real SVG parser. It's also not using existing 8 8 * xml parsers. It's just extracting the required strings from an SVG file coming 9 * from the French land registry cadastre.gouv.fr 9 * from the French land registry cadastre.gouv.fr 10 10 * 11 11 */ … … 29 29 try { 30 30 String str = svg.substring(s, e); 31 String 31 String[] viewBox = str.split(" "); 32 32 double[] dbox = new double[4]; 33 for (int i = 0; i<4; i++) 34 dbox[i] = Double.parseDouble(viewBox[i]); 33 for (int i = 0; i < 4; i++) { 34 dbox[i] = Double.parseDouble(viewBox[i]); 35 } 35 36 return dbox; 36 37 } catch (Exception ex) { … … 40 41 return null; 41 42 } 42 43 43 44 /** 44 45 * Closed SVG paths are finishing with a "Z" at the end of the moves list. 45 * @param svg46 * @return47 46 */ 48 public String 47 public String[] getClosedPaths(String svg) { 49 48 ArrayList<String> path = new ArrayList<>(); 50 49 int i = 0; … … 53 52 int e = svg.indexOf(cClosedPathEnd, s); 54 53 if (s != -1 && e != -1) { 55 String onePath = svg.substring(s, e); 54 String onePath = svg.substring(s, e); 56 55 if (onePath.indexOf("Z") != -1) // only closed SVG path 57 56 path.add(onePath); -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/Scale.java
r18544 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 24 24 this.value = value; 25 25 } 26 27 @Override 26 28 public String toString() { 27 29 return value; -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/SimplifyWay.java
r30737 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 10 10 /** 11 11 * Imported from plugin UtilsPlugin 12 * @author 12 * @author 13 13 * 14 14 */ … … 26 26 simplifyWayRange(wnew, from, to, ns, thr); 27 27 List<Node> nodes = wnew.getNodes(); 28 for (int j = to - 1; j > from; j--) 28 for (int j = to - 1; j > from; j--) { 29 29 nodes.remove(j); 30 } 30 31 nodes.addAll(from+1, ns); 31 32 wnew.setNodes(nodes); 32 33 } 33 34 } 34 35 35 36 /* 36 37 * Takes an interval [from,to] and adds nodes from (from,to) to ns. … … 60 61 } 61 62 } 63 62 64 public static double EARTH_RAD = 6378137.0; 65 63 66 /* From Aviaton Formulary v1.3 64 67 * http://williams.best.vwh.net/avform.htm … … 74 77 % (2 * Math.PI); 75 78 } 79 76 80 public static double xtd(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3) { 77 81 double dist_AD = dist(lat1, lon1, lat3, lon3); … … 80 84 return Math.asin(Math.sin(dist_AD) * Math.sin(crs_AD - crs_AB)); 81 85 } 82 83 86 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/VectorImageModifier.java
r20390 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 7 7 import java.awt.image.IndexColorModel; 8 8 import java.awt.image.WritableRaster; 9 9 10 import org.openstreetmap.josm.Main; 10 11 import org.openstreetmap.josm.tools.ColorHelper; … … 13 14 14 15 private int cadastreBackground = -1; // white 15 16 16 17 public static int cadastreBackgroundTransp = 1; // original white but transparent 17 18 18 19 private int backgroundPixel = 0; 19 20 20 public VectorImageModifier() {super();} 21 21 public VectorImageModifier() { 22 super(); 23 } 24 22 25 public VectorImageModifier(BufferedImage bi, boolean monocolor) { 23 26 bufferedImage = bi; … … 70 73 * Reverse the grey value if the pixel is grey (light grey becomes dark grey) 71 74 * Used for texts. 72 * @param pixel73 * @return74 75 */ 75 76 private int reverseIfGrey(int pixel) { -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSAdjustAction.java
r32329 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 16 16 17 17 import org.openstreetmap.josm.Main; 18 import org.openstreetmap.josm.actions.mapmode.MapMode; 19 import org.openstreetmap.josm.data.coor.EastNorth; 18 20 import org.openstreetmap.josm.gui.MapFrame; 19 21 import org.openstreetmap.josm.gui.MapView; 20 import org.openstreetmap.josm.actions.mapmode.MapMode;21 import org.openstreetmap.josm.data.coor.EastNorth;22 22 import org.openstreetmap.josm.tools.ImageProvider; 23 23 24 24 public class WMSAdjustAction extends MapMode implements 25 MouseListener, MouseMotionListener {25 MouseListener, MouseMotionListener { 26 26 27 27 private static final long serialVersionUID = 1L; … … 29 29 private boolean rasterMoved; 30 30 private EastNorth prevEastNorth; 31 enum Mode { moveXY, moveZ, rotate} 31 enum Mode { moveXY, moveZ, rotate } 32 32 33 private static Mode mode = null; 33 34 private static EastNorth[] croppedRaster = new EastNorth[5];; … … 42 43 if (Main.map != null) { 43 44 if (Main.getLayerManager().getActiveLayer() instanceof WMSLayer) { 44 modifiedLayer = (WMSLayer) Main.getLayerManager().getActiveLayer();45 modifiedLayer = (WMSLayer) Main.getLayerManager().getActiveLayer(); 45 46 super.enterMode(); 46 47 Main.map.mapView.addMouseListener(this); … … 52 53 // +"a cadastre layer")); 53 54 exitMode(); 54 Main.map.selectMapMode((MapMode) Main.map.getDefaultButtonAction());55 Main.map.selectMapMode((MapMode) Main.map.getDefaultButtonAction()); 55 56 } 56 57 } … … 97 98 98 99 @Override public void mouseDragged(MouseEvent e) { 99 EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());100 EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY()); 100 101 if (mode == Mode.rotate) { 101 102 rotateFrameOnly(prevEastNorth, newEastNorth); … … 105 106 } else if (mode == Mode.moveZ) { 106 107 resize(newEastNorth); 107 } 108 } 108 109 prevEastNorth = newEastNorth; 109 110 } 110 111 Main.map.mapView.repaint(); 111 112 } 112 113 113 114 public static void paintAdjustFrames(Graphics2D g, final MapView mv) { 114 115 if (mode == Mode.rotate && croppedRaster != null) { 115 116 g.setColor(Color.red); 116 for (int i =0; i<4; i++)117 for (int i = 0; i < 4; i++) { 117 118 g.drawLine(mv.getPoint(croppedRaster[i]).x, 118 119 mv.getPoint(croppedRaster[i]).y, 119 120 mv.getPoint(croppedRaster[i+1]).x, 120 121 mv.getPoint(croppedRaster[i+1]).y); 122 } 121 123 } 122 124 } … … 148 150 double rotationAngle = endAngle - startAngle; 149 151 if (modifiedLayer.getImage(0).orgCroppedRaster != null) { 150 for (int i =0; i<4; i++) {152 for (int i = 0; i < 4; i++) { 151 153 croppedRaster[i] = modifiedLayer.getImage(0).orgCroppedRaster[i].rotate(pivot, rotationAngle); 152 154 } … … 157 159 158 160 @Override public void mouseReleased(MouseEvent e) { 159 //Main.map.mapView.repaint();160 161 if (mode == Mode.rotate) { 161 EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY());162 EastNorth newEastNorth = Main.map.mapView.getEastNorth(e.getX(), e.getY()); 162 163 rotate(prevEastNorth, newEastNorth); 163 164 Main.map.mapView.repaint(); … … 168 169 } 169 170 171 @Override 170 172 public void mouseEntered(MouseEvent e) { 171 173 } 174 175 @Override 172 176 public void mouseExited(MouseEvent e) { 173 177 } 178 179 @Override 174 180 public void mouseMoved(MouseEvent e) { 175 181 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSDownloadAction.java
r32329 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 13 13 import org.openstreetmap.josm.gui.layer.Layer; 14 14 15 public class WMSDownloadAction /*extends JosmAction */ {15 public class WMSDownloadAction /*extends JosmAction */ { 16 16 17 17 // public WMSDownloadAction(String layerName) { … … 32 32 for (Layer l : Main.getLayerManager().getLayers()) { 33 33 if (l instanceof WMSLayer) { 34 existingWMSlayers.add((WMSLayer) l);34 existingWMSlayers.add((WMSLayer) l); 35 35 } 36 36 } … … 50 50 return null; 51 51 } 52 }; 53 52 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSException.java
r20425 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 5 5 private String message; 6 6 private static final long serialVersionUID = 1L; 7 public WMSException(String message) { 7 8 WMSException(String message) { 8 9 super(); 9 10 this.message = message; 10 11 } 12 13 @Override 11 14 public String getMessage() { 12 15 return message; -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
r32329 r32556 1 // License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others1 // License: GPL. For details, see LICENSE file. 2 2 package cadastre_fr; 3 3 … … 77 77 private String codeCommune = ""; 78 78 79 public EastNorthBound communeBBox = new EastNorthBound(new EastNorth(0, 0), new EastNorth(0,0));79 public EastNorthBound communeBBox = new EastNorthBound(new EastNorth(0, 0), new EastNorth(0, 0)); 80 80 81 81 private boolean isRaster; … … 100 100 @SuppressWarnings("serial") 101 101 class ResetOffsetActionMenu extends JosmAction { 102 publicResetOffsetActionMenu() {102 ResetOffsetActionMenu() { 103 103 super(tr("Reset offset"), null, tr("Reset offset (only vector images)"), null, false); 104 104 } 105 105 106 @Override 106 107 public void actionPerformed(ActionEvent arg0) { … … 136 137 public void destroy() { 137 138 // if the layer is currently saving the images in the cache, wait until it's finished 138 if (grabThread != null)139 if (grabThread != null) 139 140 grabThread.cancel(); 140 141 grabThread = null; … … 149 150 if (codeCommune != null && !codeCommune.isEmpty()) 150 151 ret += "(" + codeCommune + ")"; 151 return 152 return ret; 152 153 } 153 154 … … 160 161 grabThread.setGrabber(grabber); 161 162 // if it is the first layer, use the communeBBox as grab bbox (and not divided) 162 if (Main.getLayerManager().getLayers().size() == 1 163 if (Main.getLayerManager().getLayers().size() == 1) { 163 164 final Bounds bounds = this.getCommuneBBox().toBounds(); 164 165 GuiHelper.runInEDTAndWait(new Runnable() { … … 174 175 Integer.parseInt(Main.pref.get("cadastrewms.rasterDivider", CadastrePreferenceSetting.DEFAULT_RASTER_DIVIDER))); 175 176 } else 176 divideBbox(b, 177 divideBbox(b, 177 178 Integer.parseInt(Main.pref.get("cadastrewms.scale", CadastrePreferenceSetting.DEFAULT_GRAB_MULTIPLIER))); 178 179 } … … 199 200 dividedBbox.clear(); 200 201 if (factor < 4 || isRaster) { 201 for (int xEast = 0; xEast < factor; xEast++) 202 for (int xEast = 0; xEast < factor; xEast++) { 202 203 for (int xNorth = 0; xNorth < factor; xNorth++) { 203 204 dividedBbox.add(new EastNorthBound(new EastNorth(minEast + xEast * dEast, minNorth + xNorth * dNorth), 204 205 new EastNorth(minEast + (xEast + 1) * dEast, minNorth + (xNorth + 1) * dNorth))); 206 } 205 207 } 206 208 } else { … … 208 210 // grab all square in a spiral starting from the center (usually the most interesting place) 209 211 int c = Integer.parseInt(Main.pref.get("cadastrewms.squareSize", String.valueOf(CadastrePreferenceSetting.DEFAULT_SQUARE_SIZE))); 210 lambertMin = lambertMin.add(- minEast%c, - minNorth%c);211 lambertMax = lambertMax.add(c - lambertMax.east() %c, c - lambertMax.north()%c);212 lambertMin = lambertMin.add(-minEast % c, -minNorth % c); 213 lambertMax = lambertMax.add(c - lambertMax.east() % c, c - lambertMax.north() % c); 212 214 EastNorth mid = lambertMax.getCenter(lambertMin); 213 215 mid = mid.add(-1, 1); // in case the boxes side is a pair, select the one one top,left to follow the rotation 214 mid = mid.add(- mid.east()%c, - mid.north()%c);215 int x = (int) (lambertMax.east() -lambertMin.east())/c;216 int y = (int) (lambertMax.north() -lambertMin.north())/c;217 int dx[] = {+1, 0,-1, 0};218 int dy[] = {0,-1, 0,+1};216 mid = mid.add(-mid.east() % c, -mid.north() % c); 217 int x = (int) (lambertMax.east() -lambertMin.east())/c; 218 int y = (int) (lambertMax.north() -lambertMin.north())/c; 219 int[] dx = {+1, 0, -1, 0}; 220 int[] dy = {0, -1, 0, +1}; 219 221 int currDir = -1, lDir = 1, i = 1, j = 0, k = -1; 220 222 if (x == 1) … … 231 233 } 232 234 j = 0; 233 currDir = (currDir+1) %4;235 currDir = (currDir+1) % 4; 234 236 } else if (currDir >= 0 && j >= (currDir == 0 || currDir == 2 ? (x-1) : (y-1))) { 235 237 // the overall is a rectangle, not a square. Jump to the other side to grab next square. … … 240 242 } 241 243 j = lDir-1; 242 currDir = (currDir+1) %4;244 currDir = (currDir+1) % 4; 243 245 mid = new EastNorth(mid.east() + dx[currDir]*c*(lDir-1), mid.north() + dy[currDir]*c*(lDir-1)); 244 246 } … … 260 262 str += "\n"+tr("Is not vectorized."); 261 263 str += "\n"+tr("Bounding box: {0}", communeBBox); 262 if (!images.isEmpty())264 if (!images.isEmpty()) 263 265 str += "\n"+tr("Image size (px): {0}/{1}", images.get(0).image.getWidth(), images.get(0).image.getHeight()); 264 266 } else { … … 281 283 @Override 282 284 public void paint(Graphics2D g, final MapView mv, Bounds bounds) { 283 synchronized (this){285 synchronized (this) { 284 286 Object savedInterpolation = g.getRenderingHint(RenderingHints.KEY_INTERPOLATION); 285 287 if (savedInterpolation == null) savedInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR; … … 292 294 g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR); 293 295 imagesLock.lock(); 294 for (GeorefImage img : images) 296 for (GeorefImage img : images) { 295 297 img.paint(g, mv, CadastrePlugin.backgroundTransparent, 296 298 CadastrePlugin.transparency, CadastrePlugin.drawBoundaries); 299 } 297 300 imagesLock.unlock(); 298 301 g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, savedInterpolation); … … 329 332 refineGeoRef.setEnabled(isRaster && grabThread.getImagesToGrabSize() == 0); 330 333 Action resetOffset = new ResetOffsetActionMenu(); 331 resetOffset.setEnabled(!isRaster && !images.isEmpty() && (deltaEast !=0.0 || deltaNorth!=0.0));334 resetOffset.setEnabled(!isRaster && !images.isEmpty() && (deltaEast != 0.0 || deltaNorth != 0.0)); 332 335 return new Action[] { 333 336 LayerListDialog.getInstance().createShowHideLayerAction(), … … 447 450 * Called by CacheControl when a new cache file is created on disk. 448 451 * Save only primitives to keep cache independent of software changes. 449 * @param oos450 * @throws IOException451 452 */ 452 453 public void write(File associatedFile, ObjectOutputStream oos) throws IOException { … … 475 476 * Called by CacheControl when a cache file is read from disk. 476 477 * Cache uses only primitives to stay independent of software changes. 477 * @param ois478 * @throws IOException479 * @throws ClassNotFoundException480 478 */ 481 479 public boolean read(File associatedFile, ObjectInputStream ois, int currentLambertZone) throws IOException, ClassNotFoundException { … … 506 504 double maxX = ois.readDouble(); 507 505 double maxY = ois.readDouble(); 508 this.communeBBox = 506 this.communeBBox = new EastNorthBound(new EastNorth(minX, minY), new EastNorth(maxX, maxY)); 509 507 if (this.lambertZone != currentLambertZone && currentLambertZone != -1) { 510 508 JOptionPane.showMessageDialog(Main.parent, tr("Lambert zone {0} in cache "+ … … 513 511 return false; 514 512 } 515 synchronized (this){513 synchronized (this) { 516 514 boolean EOF = false; 517 515 try { … … 534 532 } catch (EOFException ex) { 535 533 // expected exception when all images are read 534 Main.trace(ex); 536 535 } 537 536 } … … 560 559 Graphics g = newImg.getGraphics(); 561 560 // Coordinate (0,0) is on top,left corner where images are grabbed from bottom left 562 int rasterDivider = (int) Math.sqrt(images.size());561 int rasterDivider = (int) Math.sqrt(images.size()); 563 562 for (int h = 0; h < lx.size(); h++) { 564 563 for (int v = 0; v < ly.size(); v++) { … … 569 568 } 570 569 } 571 synchronized (this) {570 synchronized (this) { 572 571 images.clear(); 573 572 images.add(new GeorefImage(newImg, min, max, this)); … … 581 580 * Works only for raster image layer (only one image in collection). 582 581 * Updates layer georeferences. 583 * @param en1 584 * @param en2 585 */ 586 public void cropImage(EastNorth en1, EastNorth en2){ 582 */ 583 public void cropImage(EastNorth en1, EastNorth en2) { 587 584 // adj1 is corner bottom, left 588 585 EastNorth adj1 = new EastNorth(en1.east() <= en2.east() ? en1.east() : en2.east(), … … 596 593 rasterMax = adj2; 597 594 setCommuneBBox(new EastNorthBound( 598 new EastNorth(0, 0),599 new EastNorth(images.get(0).image.getWidth()-1, images.get(0).image.getHeight()-1)));595 new EastNorth(0, 0), 596 new EastNorth(images.get(0).image.getWidth()-1, images.get(0).image.getHeight()-1))); 600 597 rasterRatio = (rasterMax.getX()-rasterMin.getX())/(communeBBox.max.getX() - communeBBox.min.getX()); 601 598 } … … 613 610 double minY = Double.MAX_VALUE; 614 611 double maxY = Double.MIN_VALUE; 615 for (GeorefImage image:images) {612 for (GeorefImage image:images) { 616 613 minX = image.min.east() < minX ? image.min.east() : minX; 617 614 maxX = image.max.east() > maxX ? image.max.east() : maxX; … … 649 646 images.get(0).shear(dx, dy); 650 647 } else { 651 deltaEast +=dx;652 deltaNorth +=dy;648 deltaEast += dx; 649 deltaNorth += dy; 653 650 } 654 651 } … … 675 672 EastNorthBound currentView = new EastNorthBound(mv.getEastNorth(0, mv.getHeight()), 676 673 mv.getEastNorth(mv.getWidth(), 0)); 677 int minX = ((int) currentView.min.east()/modulo+1)*modulo;678 int minY = ((int) currentView.min.north()/modulo+1)*modulo;679 int maxX = ((int) currentView.max.east()/modulo)*modulo;680 int maxY = ((int) currentView.max.north()/modulo)*modulo;681 int size =(maxX-minX)/modulo;682 if (size <20) {683 int px = size > 10 ? 2 : Math.abs(12-size);674 int minX = ((int) currentView.min.east()/modulo+1)*modulo; 675 int minY = ((int) currentView.min.north()/modulo+1)*modulo; 676 int maxX = ((int) currentView.max.east()/modulo)*modulo; 677 int maxY = ((int) currentView.max.north()/modulo)*modulo; 678 int size = (maxX-minX)/modulo; 679 if (size < 20) { 680 int px = size > 10 ? 2 : Math.abs(12-size); 684 681 g.setColor(Color.green); 685 for (int x =minX; x<=maxX; x+=modulo) {686 for (int y =minY; y<=maxY; y+=modulo) {687 Point p = mv.getPoint(new EastNorth(x, y));682 for (int x = minX; x <= maxX; x += modulo) { 683 for (int y = minY; y <= maxY; y += modulo) { 684 Point p = mv.getPoint(new EastNorth(x, y)); 688 685 g.drawLine(p.x-px, p.y, p.x+px, p.y); 689 686 g.drawLine(p.x, p.y-px, p.x, p.y+px);
Note:
See TracChangeset
for help on using the changeset viewer.