Ignore:
Timestamp:
2016-07-04T14:18:17+02:00 (8 years ago)
Author:
donvip
Message:

checkstyle

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  
    1717                        </arguments>
    1818                </buildCommand>
     19                <buildCommand>
     20                        <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
     21                        <arguments>
     22                        </arguments>
     23                </buildCommand>
    1924        </buildSpec>
    2025        <natures>
    2126                <nature>org.sonarlint.eclipse.core.sonarlintNature</nature>
    2227                <nature>org.eclipse.jdt.core.javanature</nature>
     28                <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
    2329        </natures>
    2430</projectDescription>
  • applications/editors/josm/plugins/cadastre-fr/.settings/org.eclipse.jdt.ui.prefs

    r32211 r32556  
    3737sp_cleanup.remove_private_constructors=true
    3838sp_cleanup.remove_redundant_type_arguments=true
    39 sp_cleanup.remove_trailing_whitespaces=false
     39sp_cleanup.remove_trailing_whitespaces=true
    4040sp_cleanup.remove_trailing_whitespaces_all=true
    4141sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
    4242sp_cleanup.remove_unnecessary_casts=true
    4343sp_cleanup.remove_unnecessary_nls_tags=false
    44 sp_cleanup.remove_unused_imports=false
     44sp_cleanup.remove_unused_imports=true
    4545sp_cleanup.remove_unused_local_variables=false
    4646sp_cleanup.remove_unused_private_fields=true
  • applications/editors/josm/plugins/cadastre-fr/build.xml

    r32329 r32556  
    44    <property name="commit.message" value="Changed constructor for Plugin"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="10279"/>
     6    <property name="plugin.main.version" value="10420"/>
    77   
    88    <!-- 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.
    12package cadastre_fr;
    23
     
    113114//        dialog.setVisible(false);
    114115        // kill the window completely to fix an issue on some linux distro and full screen mode.
    115         if(dialog != null) {
     116        if (dialog != null) {
    116117            dialog.dispose();
    117118            dialog = null;
     
    156157                }
    157158                if (currentMouseNode.get(tagHouseStreet) != null) {
    158                     if(Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false)) {
     159                    if (Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false)) {
    159160                        inputStreet.setText(currentMouseNode.get(tagHouseStreet));
    160161                        if (ctrl) {
     
    164165                                applyInputNumberChange();
    165166                        }
    166                         setSelectedWay((Way)null);
     167                        setSelectedWay((Way) null);
    167168                    }
    168169                } else {
     
    184185        } else {
    185186            List<WaySegment> wss = mv.getNearestWaySegments(mousePos, OsmPrimitive.isSelectablePredicate);
    186             for(WaySegment ws : wss) {
     187            for (WaySegment ws : wss) {
    187188                if (ws.way.get(tagHighway) != null && ws.way.get(tagHighwayName) != null)
    188189                    mouseOnExistingWays.add(ws.way);
     
    220221        for (OsmPrimitive osm : l) {
    221222            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()) {
    223224                    if (rm.getRole().equals(relationAddrStreetRole)) {
    224225                        OsmPrimitive osp = rm.getMember();
    225226                        if (osp instanceof Way && osp.hasKey(tagHighwayName)) {
    226                             return (Way)osp;
     227                            return (Way) osp;
    227228                        }
    228229                    }
     
    264265        for (OsmPrimitive osm : l) {
    265266            if (osm instanceof Relation && osm.hasKey("type") && osm.get("type").equals(relationAddrType)) {
    266                 return (Relation)osm;
     267                return (Relation) osm;
    267268            }
    268269        }
     
    310311            is.add(ws.lowerIndex);
    311312        }
    312         Set<Pair<Node,Node>> segSet = new HashSet<>();
     313        Set<Pair<Node, Node>> segSet = new HashSet<>();
    313314        ArrayList<Way> replacedWays = new ArrayList<>();
    314315        ArrayList<Way> reuseWays = new ArrayList<>();
     
    333334    }
    334335
    335     private static void adjustNode(Collection<Pair<Node,Node>> segs, Node n) {
     336    private static void adjustNode(Collection<Pair<Node, Node>> segs, Node n) {
    336337
    337338        switch (segs.size()) {
     
    341342            // This computes the intersection between
    342343            // 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();
    345346            EastNorth A = seg.a.getEastNorth();
    346347            EastNorth B = seg.b.getEastNorth();
     
    349350            EastNorth D = seg.b.getEastNorth();
    350351
    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());
    352353
    353354            // Check for parallel segments and do nothing if they are
     
    366367
    367368            int snapToIntersectionThreshold
    368             = Main.pref.getInteger("edit.snap-intersection-threshold",10);
     369            = Main.pref.getInteger("edit.snap-intersection-threshold", 10);
    369370
    370371            // only adjust to intersection if within snapToIntersectionThreshold pixel of mouse click; otherwise
     
    462463                inputNumber.setText("");
    463464                inputStreet.setText("");
    464                 setSelectedWay((Way)null);
     465                setSelectedWay((Way) null);
    465466            }
    466467        });
     
    495496                Main.pref.put("cadastrewms.addr.bounds", dialog.getX()+","+dialog.getY()+","+dialog.getWidth()+","+dialog.getHeight());
    496497            }
     498
    497499            @Override public void componentMoved(ComponentEvent e) {
    498500                rememberGeometry();
    499501            }
     502
    500503            @Override public void componentResized(ComponentEvent e) {
    501504                rememberGeometry();
     
    506509            public void windowClosing(WindowEvent arg) {
    507510                exitMode();
    508                 Main.map.selectMapMode((MapMode)Main.map.getDefaultButtonAction());
     511                Main.map.selectMapMode((MapMode) Main.map.getDefaultButtonAction());
    509512            }
    510513        });
    511         String bounds = Main.pref.get("cadastrewms.addr.bounds",null);
     514        String bounds = Main.pref.get("cadastrewms.addr.bounds", null);
    512515        if (bounds != null) {
    513516            String[] b = bounds.split(",");
    514517            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])));
    516519        }
    517520    }
  • 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    4242            super(out);
    4343        }
     44
    4445        @Override
    4546        protected void writeStreamHeader() throws IOException {
     
    8889            for (int i = 0; i < files.length; i++) {
    8990                size += files[i].length();
    90                 if (files[i].lastModified() <  oldestFileDate) {
     91                if (files[i].lastModified() < oldestFileDate) {
    9192                    oldestFile = i;
    9293                    oldestFileDate = files[i].lastModified();
    9394                }
    9495            }
    95             if (size > (long)cacheSize*1024*1024) {
     96            if (size > (long) cacheSize*1024*1024) {
    9697                Main.info("Delete oldest file  \""+ files[oldestFile].getName()
    9798                        + "\" in cache dir to stay under the limit of " + cacheSize + " MB.");
     
    120121                    CadastrePlugin.prepareDialog(dialog);
    121122                    dialog.setVisible(true);
    122                     return (Integer)pane.getValue();
     123                    return (Integer) pane.getValue();
    123124                    // till here
    124125                }
     
    142143        if (file.exists())
    143144            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)
    145146            CadastrePlugin.safeSleep(500);
     147        }
    146148    }
    147149
     
    158160                @Override
    159161                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."),
    161163                            tr("Error"), JOptionPane.ERROR_MESSAGE);
    162164                }
     
    193195                        try (ObjectOutputStreamAppend oos = new ObjectOutputStreamAppend(
    194196                                new BufferedOutputStream(new FileOutputStream(file, true)))) {
    195                             for (int i=0; i < size; i++) {
     197                            for (int i = 0; i < size; i++) {
    196198                                oos.writeObject(imagesToSave.get(i));
    197199                            }
     
    201203                                new BufferedOutputStream(new FileOutputStream(file)))) {
    202204                            wmsLayer.write(file, oos);
    203                             for (int i=0; i < size; i++) {
     205                            for (int i = 0; i < size; i++) {
    204206                                oos.writeObject(imagesToSave.get(i));
    205207                            }
     
    210212                }
    211213                imagesLock.lock();
    212                 for (int i=0; i < size; i++) {
     214                for (int i = 0; i < size; i++) {
    213215                    imagesToSave.remove(0);
    214216                }
    215217                imagesLock.unlock();
    216218            }
    217             try {wait();} catch (InterruptedException e) {
     219            try {
     220                wait();
     221            } catch (InterruptedException e) {
    218222                Main.error(e);
    219223            }
  • 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    3535    public boolean acceptName(String filename) {
    3636        String name = filename.toLowerCase(Locale.FRANCE);
    37         for (String ext : extension.split(","))
     37        for (String ext : extension.split(",")) {
    3838            if (name.endsWith("." + ext))
    3939                return true;
     40        }
    4041        return false;
    4142    }
  • 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    88import javax.swing.filechooser.FileFilter;
    99
    10 public class CacheFileLambert9ZoneFilter extends FileFilter {
     10public final class CacheFileLambert9ZoneFilter extends FileFilter {
    1111
    1212    /**
     
    1717
    1818    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))
    2828        };
    2929
     
    3939    public boolean acceptName(String filename) {
    4040        String name = filename.toLowerCase();
    41         for (String ext : extension.split(","))
     41        for (String ext : extension.split(",")) {
    4242            if (name.endsWith("." + ext))
    4343                return true;
     44        }
    4445        return false;
    4546    }
  • 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    88import javax.swing.filechooser.FileFilter;
    99
    10 public class CacheFileUTM20NFilter extends FileFilter {
     10public final class CacheFileUTM20NFilter extends FileFilter {
    1111
    1212    /**
     
    3434    public boolean acceptName(String filename) {
    3535        String name = filename.toLowerCase();
    36         for (String ext : extension.split(","))
     36        for (String ext : extension.split(",")) {
    3737            if (name.endsWith("." + ext))
    3838                return true;
     39        }
    3940        return false;
    4041    }
  • 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    5454        str += wmsLayer.eastNorth2raster(lambertMin, lambertMax);
    5555        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()));
    5757        str += "&exception=application/vnd.ogc.se_inimage&styles="; // required for raster images
    5858        Main.info("URL="+str);
     
    8484
    8585    private BufferedImage grab(URL url) throws IOException, OsmTransferException {
    86         wmsInterface.urlConn = (HttpURLConnection)url.openConnection();
     86        wmsInterface.urlConn = (HttpURLConnection) url.openConnection();
    8787        wmsInterface.urlConn.setRequestProperty("Connection", "close");
    8888        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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    4949        }
    5050    }
     51
    5152    private List<PlanImage> listOfFeuilles = new ArrayList<>();
    5253    private long cookieTimestamp;
     
    109110     * @return true if a cookie is delivered by WMS and false is WMS is not opening a client session
    110111     *         (too many clients or in maintenance)
    111      * @throws IOException
    112112     */
    113113    private void getCookie() throws IOException {
     
    117117            searchFormURL = new URL(BASE_URL + "/scpc/accueil.do");
    118118            while (!success && retries > 0) {
    119                 urlConn = (HttpURLConnection)searchFormURL.openConnection();
     119                urlConn = (HttpURLConnection) searchFormURL.openConnection();
    120120                urlConn.setRequestProperty("Connection", "close");
    121121                urlConn.setRequestMethod("GET");
     
    124124                    Main.info("GET "+searchFormURL);
    125125                    BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream(), StandardCharsets.UTF_8));
    126                     while(in.readLine() != null) {
     126                    while (in.readLine() != null) {
    127127                        // read the buffer otherwise we sent POST too early
    128128                    }
     
    132132                    CookieHandler cookieHandler = CookieHandler.getDefault();
    133133                    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))) {
    135135                            break;
    136136                        }
    137137                    } else {
    138138                        String headerName;
    139                         for (int i=1; (headerName = urlConn.getHeaderFieldKey(i))!=null; i++) {
     139                        for (int i = 1; (headerName = urlConn.getHeaderFieldKey(i)) != null; i++) {
    140140                            if ("Set-Cookie".equals(headerName) && handleCookie(urlConn.getHeaderField(i))) {
    141141                                break;
    142                             } 
     142                            }
    143143                        }
    144144                    }
     
    146146                    Main.warn("Request to home page failed. Http error:"+urlConn.getResponseCode()+". Try again "+retries+" times");
    147147                    CadastrePlugin.safeSleep(3000);
    148                     retries --;
     148                    retries--;
    149149                }
    150150            }
     
    238238    }
    239239
    240     private void openInterface() throws IOException  {
     240    private void openInterface() throws IOException {
    241241        try {
    242242            // finally, open the interface on server side giving access to the wms server
    243243            URL interfaceURL = new URL(BASE_URL + "/scpc/"+interfaceRef);
    244             urlConn = (HttpURLConnection)interfaceURL.openConnection();
     244            urlConn = (HttpURLConnection) interfaceURL.openConnection();
    245245            urlConn.setRequestMethod("GET");
    246246            setCookie();
     
    283283     * where QP224 is the code commune known by the WMS (or "afficherCarteTa.do?c=..." for raster images).
    284284     *
    285      * @param location
    286      * @param codeCommune
    287285     * @return retURL url to available code commune in the cadastre; "" if not found
    288      * @throws IOException
    289286     */
    290287    private String postForm(WMSLayer wmsLayer, String codeCommune) throws IOException {
     
    308305            content += "&x=0&y=0";
    309306            searchFormURL = new URL(BASE_URL + "/scpc/rechercherPlan.do");
    310             urlConn = (HttpURLConnection)searchFormURL.openConnection();
     307            urlConn = (HttpURLConnection) searchFormURL.openConnection();
    311308            urlConn.setRequestMethod("POST");
    312309            urlConn.setDoOutput(true);
     
    335332                if (!wmsLayer.isRaster() && lines.indexOf(C_INTERFACE_VECTOR) != -1) {  // "afficherCarteCommune.do"
    336333                    // 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());
    338335                    lines = lines.substring(0, lines.indexOf('\''));
    339336                    lines = Entities.unescape(lines);
     
    369366        } catch (MalformedURLException e) {
    370367            throw (IOException) new IOException("Illegal url.").initCause(e);
    371         } catch (DuplicateLayerException e){
     368        } catch (DuplicateLayerException e) {
    372369            Main.error(e);
    373370        }
     
    401398        try {
    402399            URL getAllImagesURL = new URL(BASE_URL + "/scpc/listerFeuillesParcommune.do?keepVolatileSession=&offset=2000");
    403             urlConn2 = (HttpURLConnection)getAllImagesURL.openConnection();
     400            urlConn2 = (HttpURLConnection) getAllImagesURL.openConnection();
    404401            setCookie(urlConn2);
    405402            urlConn2.connect();
     
    491488     * and store the result in the wmsLayer as well.
    492489     * @param wmsLayer the WMSLayer where the commune data and images are stored
    493      * @throws IOException
    494490     */
    495491    public void retrieveCommuneBBox(WMSLayer wmsLayer) throws IOException {
     
    500496        content += "&dontSaveLastForward&keepVolatileSession=";
    501497        searchFormURL = new URL(content);
    502         urlConn = (HttpURLConnection)searchFormURL.openConnection();
     498        urlConn = (HttpURLConnection) searchFormURL.openConnection();
    503499        urlConn.setRequestMethod("GET");
    504500        setCookie();
     
    534530            int l = input.indexOf(C_BBOX_COMMUN_END, k+1);
    535531            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)));
    537533        }
    538534    }
  • 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    4646 * a city/town/village code.
    4747 *
    48  * @author Pieren <pieren3@gmail.com>,
    49  *         <matthieu.lochegnies@gmail.com> for the extension to codeCommune
     48 * @author Pieren &lt;pieren3@gmail.com&gt;,
     49 *         &lt;matthieu.lochegnies@gmail.com&gt; for the extension to codeCommune
    5050 *
    5151 * @version 2.6
     
    171171    public static String grabLayers, grabStyles = null;
    172172
    173     static private boolean menuEnabled = false;
     173    private static boolean menuEnabled = false;
    174174
    175175    private static String LAYER_BULDINGS = "CDIF:LS2";
     
    204204            cacheDir = Main.pref.get("cadastrewms.cacheDir");
    205205        }
    206         if (cacheDir.charAt(cacheDir.length()-1) != File.separatorChar )
     206        if (cacheDir.charAt(cacheDir.length()-1) != File.separatorChar)
    207207            cacheDir += File.separatorChar;
    208208        Main.info("current cache directory: "+cacheDir);
     
    212212        UploadAction.registerUploadHook(new CheckSourceUploadHook());
    213213
    214         registerSessionLayerExporter(WMSLayer.class , CadastreSessionExporter.class);
     214        registerSessionLayerExporter(WMSLayer.class, CadastreSessionExporter.class);
    215215        registerSessionLayerImporter("cadastre-fr", CadastreSessionImporter.class);
    216216    }
     
    277277        if (currentResolution.equals("high")) {
    278278            imageWidth = 1000; imageHeight = 800;
    279         } else if (currentResolution.equals("medium")){
     279        } else if (currentResolution.equals("medium")) {
    280280            imageWidth = 800; imageHeight = 600;
    281281        } else {
     
    339339            grabStyles = grabStyles.substring(0, grabStyles.length()-1);
    340340        } 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 "
    342342                    + "plugin configuration.\nLayers ''Building'' and ''Parcel'' added by default."));
    343343            Main.pref.put("cadastrewms.layerBuilding", true);
     
    430430        try {
    431431            Thread.sleep(milliseconds);
    432         } catch (InterruptedException e) {}
     432        } catch (InterruptedException e) {
     433            Main.debug(e);
     434        }
    433435    }
    434436
     
    439441            try {
    440442                dialog.setAlwaysOnTop(true);
    441             } catch(SecurityException e) {
     443            } catch (SecurityException e) {
    442444                Main.warn(tr("Warning: failed to put option pane dialog always on top. Exception was: {0}", e.toString()));
    443445            }
     
    457459        if (Main.map != null && Main.map.mapView != null) {
    458460            int wmsNewLayerPos = Main.getLayerManager().getLayers().size();
    459             for(Layer l : Main.getLayerManager().getLayersOfType(WMSLayer.class)) {
     461            for (Layer l : Main.getLayerManager().getLayersOfType(WMSLayer.class)) {
    460462                int wmsPos = Main.getLayerManager().getLayers().indexOf(l);
    461463                if (wmsPos < wmsNewLayerPos) wmsNewLayerPos = wmsPos;
     
    477479        try {
    478480            year = Integer.decode(srcYear);
    479         } catch (NumberFormatException e) {}
     481        } catch (NumberFormatException e) {
     482            Main.debug(e);
     483        }
    480484        if (srcYear.equals("AAAA") || (year != null && year < currentYear)) {
    481485            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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    77import java.awt.event.ActionEvent;
    88import java.awt.event.ActionListener;
    9 import javax.swing.*;
     9
     10import javax.swing.AbstractButton;
     11import javax.swing.BorderFactory;
     12import javax.swing.Box;
     13import javax.swing.ButtonGroup;
     14import javax.swing.JCheckBox;
     15import javax.swing.JComboBox;
     16import javax.swing.JLabel;
     17import javax.swing.JPanel;
     18import javax.swing.JRadioButton;
     19import javax.swing.JScrollPane;
     20import javax.swing.JSeparator;
     21import javax.swing.JSlider;
     22import javax.swing.JTextField;
     23import javax.swing.SwingConstants;
    1024
    1125import org.openstreetmap.josm.Main;
     
    1933 * Preference settings for the French Cadastre plugin
    2034 *
    21  * @author Pieren <pieren3@gmail.com>
     35 * @author Pieren &lt;pieren3@gmail.com&gt;
    2236 */
    2337public class CadastrePreferenceSetting extends DefaultTabPreferenceSetting {
     
    4256
    4357    private JCheckBox enableTableauAssemblage = new JCheckBox(tr("Use \"Tableau d''assemblage\""));
    44    
     58
    4559    private JCheckBox simplify2BitsColors = new JCheckBox(tr("Replace grey shades by white color only"));
    4660
     
    92106
    93107    static final int DEFAULT_CROSSPIECES = 0;
    94    
     108
    95109    static final String DEFAULT_GRAB_MULTIPLIER = Scale.SQUARE_100M.value;
    96110
     
    108122    }
    109123
     124    @Override
    110125    public void addGui(final PreferenceTabbedPane gui) {
    111126        JPanel cadastrewmsMast = gui.createPreferenceTab(this);
    112127
    113128        JPanel cadastrewms = new JPanel(new GridBagLayout());
    114         cadastrewms.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
     129        cadastrewms.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    115130
    116131        // option to automatically set the source tag when uploading
     
    128143        // option to reverse the grey colors (to see texts background)
    129144        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."));
    131147        cadastrewms.add(reversGrey, GBC.eop().insets(0, 0, 0, 0));
    132148
    133149        // option to enable transparency
    134150        transparency.addActionListener(new ActionListener() {
     151            @Override
    135152            public void actionPerformed(ActionEvent e) {
    136153                sliderTrans.setEnabled(transparency.isSelected());
     
    146163        sliderTrans.setMajorTickSpacing(10);
    147164        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));
    149166        sliderTrans.setPaintTicks(true);
    150167        sliderTrans.setPaintLabels(false);
     
    201218        ButtonGroup bgGrabMultiplier = new ButtonGroup();
    202219        ActionListener multiplierActionListener = new ActionListener() {
     220            @Override
    203221            public void actionPerformed(ActionEvent actionEvent) {
    204222              AbstractButton button = (AbstractButton) actionEvent.getSource();
     
    208226        grabMultiplier1.setIcon(ImageProvider.get("preferences", "unsel_box_1"));
    209227        grabMultiplier1.setSelectedIcon(ImageProvider.get("preferences", "sel_box_1"));
    210         grabMultiplier1.addActionListener( multiplierActionListener);
     228        grabMultiplier1.addActionListener(multiplierActionListener);
    211229        grabMultiplier1.setToolTipText(tr("Grab one image full screen"));
    212230        grabMultiplier2.setIcon(ImageProvider.get("preferences", "unsel_box_2"));
    213231        grabMultiplier2.setSelectedIcon(ImageProvider.get("preferences", "sel_box_2"));
    214         grabMultiplier2.addActionListener( multiplierActionListener);
     232        grabMultiplier2.addActionListener(multiplierActionListener);
    215233        grabMultiplier2.setToolTipText(tr("Grab smaller images (higher quality but use more memory)"));
    216234        grabMultiplier3.setIcon(ImageProvider.get("preferences", "unsel_box_3"));
    217235        grabMultiplier3.setSelectedIcon(ImageProvider.get("preferences", "sel_box_3"));
    218         grabMultiplier3.addActionListener( multiplierActionListener);
     236        grabMultiplier3.addActionListener(multiplierActionListener);
    219237        grabMultiplier3.setToolTipText(tr("Grab smaller images (higher quality but use more memory)"));
    220238        grabMultiplier4.setIcon(ImageProvider.get("preferences", "unsel_box_4"));
    221239        grabMultiplier4.setSelectedIcon(ImageProvider.get("preferences", "sel_box_4"));
    222         grabMultiplier4.addActionListener( multiplierActionListener);
     240        grabMultiplier4.addActionListener(multiplierActionListener);
    223241        grabMultiplier4.setToolTipText(tr("Fixed size square (default is 100m)"));
    224242        bgGrabMultiplier.add(grabMultiplier1);
     
    321339        // option to enable automatic caching
    322340        enableCache.addActionListener(new ActionListener() {
     341            @Override
    323342            public void actionPerformed(ActionEvent e) {
    324343                jLabelCacheSize.setEnabled(enableCache.isSelected());
     
    356375        cadastrewms.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
    357376        JScrollPane scrollpane = new JScrollPane(cadastrewms);
    358         scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
     377        scrollpane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    359378        cadastrewmsMast.add(scrollpane, GBC.eol().fill(GBC.BOTH));
    360379    }
    361380
     381    @Override
    362382    public boolean ok() {
    363383        Main.pref.put("cadastrewms.source", sourcing.getText());
     
    366386        Main.pref.put("cadastrewms.invertGrey", reversGrey.isSelected());
    367387        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));
    369389        Main.pref.put("cadastrewms.drawBoundaries", drawBoundaries.isSelected());
    370390        if (grabRes1.isSelected())
     
    392412                if (squareSize >= 25 && squareSize <= 1000)
    393413                    Main.pref.put("cadastrewms.squareSize", grabMultiplier4Size.getText());
    394             } catch (NumberFormatException e) { // ignore the last input
     414            } catch (NumberFormatException e) {
     415                Main.debug(e);
    395416            }
    396417        }
     
    408429            if (i > 0 && i < 13)
    409430                Main.pref.put("cadastrewms.rasterDivider", String.valueOf(i));
    410         } catch (NumberFormatException e) { // ignore the last input
     431        } catch (NumberFormatException e) {
     432            Main.debug(e);
    411433        }
    412434        Main.pref.put("cadastrewms.noImageCropping", disableImageCropping.isSelected());
     
    423445            CacheControl.cacheSize = Integer.parseInt(cacheSize.getText());
    424446            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);
    426449        }
    427450        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.
    12package cadastre_fr;
    23
     
    4445        p.add(export, GBC.std());
    4546        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));
    4748        return p;
    4849    }
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreSessionImporter.java

    r32211 r32556  
     1// License: GPL. For details, see LICENSE file.
    12package cadastre_fr;
    23
     
    2021import org.w3c.dom.Element;
    2122
    22 public class CadastreSessionImporter implements SessionLayerImporter{
     23public class CadastreSessionImporter implements SessionLayerImporter {
    2324
    2425    @Override
     
    4142            fileStr = URLDecoder.decode(fileStr, "UTF-8");
    4243            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());
    4546            // create layer and load cache
    4647            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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    3030 * automatically a tag "source"="Cadastre..." as defined in the plugin preferences.
    3131 */
    32 public class CheckSourceUploadHook implements UploadHook
    33 {
     32public class CheckSourceUploadHook implements UploadHook {
    3433
    3534    /**
    3635     * Add the tag "source" if it doesn't exist for all new Nodes and Ways before uploading
    3736     */
    38     public boolean checkUpload(APIDataSet apiDataSet)
    39     {
     37    @Override
     38    public boolean checkUpload(APIDataSet apiDataSet) {
    4039        if (CadastrePlugin.autoSourcing && CadastrePlugin.pluginUsed && !apiDataSet.getPrimitivesToAdd().isEmpty()) {
    4140            Collection<OsmPrimitive> sel = new HashSet<>();
     
    5554    /**
    5655     * Check whenever one of the keys of the object is "source"
    57      * @param OsmPrimitive
    5856     * @return true if one of keys is "source"
    5957     */
    6058    private boolean tagSourceExist(OsmPrimitive osm) {
    6159        for (String key : osm.keySet()) {
    62             if (key.equals("source") ) {
     60            if (key.equals("source")) {
    6361                return true;
    6462            }
     
    7270     * @param sel the list of elements added without a key "source"
    7371     */
    74     private void displaySource(Collection<OsmPrimitive> sel)
    75     {
     72    private void displaySource(Collection<OsmPrimitive> sel) {
    7673        if (!sel.isEmpty()) {
    7774            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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    106106
    107107        // convert SVG nodes to eastNorth coordinates
    108         for (int i=0; i< SVGpaths.length; i++) {
     108        for (int i = 0; i < SVGpaths.length; i++) {
    109109            ArrayList<EastNorth> eastNorth = new ArrayList<>();
    110110            createNodes(SVGpaths[i], eastNorth);
     
    147147                for (Way w : svgDataSet.getWays()) {
    148148                    int replaced = 0;
    149                     for (Node node : w.getNodes())
     149                    for (Node node : w.getNodes()) {
    150150                        if (node == n) {
    151151                            node = nearestNewNode;
    152152                            replaced++;
    153153                        }
     154                    }
    154155                    if (w.getNodesCount() == replaced)
    155156                        w.setDeleted(true);
     
    161162
    162163        Collection<Command> cmds = new LinkedList<>();
    163         for (Node node : svgDataSet.getNodes())
     164        for (Node node : svgDataSet.getNodes()) {
    164165            if (!node.isDeleted())
    165166                cmds.add(new AddCommand(node));
    166         for (Way way : svgDataSet.getWays())
     167        }
     168        for (Way way : svgDataSet.getWays()) {
    167169            if (!way.isDeleted())
    168170                cmds.add(new AddCommand(way));
     171        }
    169172        Main.main.undoRedo.add(new SequenceCommand(tr("Create buildings"), cmds));
    170173        Main.map.repaint();
     
    176179        double dx = Double.parseDouble(coor[1]);
    177180        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) {
    179182            if (coor[i].isEmpty()) {
    180183                eastNorth.clear(); // some paths are just artifacts
    181184                return;
    182185            }
    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));
    186189        }
    187190        // flip the image (svg using a reversed Y coordinate system)
     
    240243
    241244    private String grabSVG(URL url) throws IOException, OsmTransferException {
    242         wmsInterface.urlConn = (HttpURLConnection)url.openConnection();
     245        wmsInterface.urlConn = (HttpURLConnection) url.openConnection();
    243246        wmsInterface.urlConn.setRequestProperty("Connection", "close");
    244247        wmsInterface.urlConn.setRequestMethod("GET");
     
    253256                 BufferedReader br = new BufferedReader(isr)) {
    254257                String line;
    255                 while ( null!=(line=br.readLine())){
     258                while (null != (line = br.readLine())) {
    256259                    line += "\n";
    257260                    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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    111111        ArrayList<Double> fitViewBox = new ArrayList<>();
    112112        ArrayList<ArrayList<EastNorth>> eastNorths = new ArrayList<>();
    113         for (int i=0; i< SVGpaths.length; i++) {
     113        for (int i = 0; i < SVGpaths.length; i++) {
    114114            ArrayList<EastNorth> eastNorth = new ArrayList<>();
    115             fitViewBox.add( createNodes(SVGpaths[i], eastNorth) );
     115            fitViewBox.add(createNodes(SVGpaths[i], eastNorth));
    116116            eastNorths.add(eastNorth);
    117117        }
     
    149149        double maxY = Double.MIN_VALUE;
    150150        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));
    155155            minX = minX > east ? east : minX;
    156156            minY = minY > north ? north : minY;
     
    193193
    194194    private String grabSVG(URL url) throws IOException, OsmTransferException {
    195         wmsInterface.urlConn = (HttpURLConnection)url.openConnection();
     195        wmsInterface.urlConn = (HttpURLConnection) url.openConnection();
    196196        wmsInterface.urlConn.setRequestProperty("Connection", "close");
    197197        wmsInterface.urlConn.setRequestMethod("GET");
     
    203203                file.delete();
    204204            try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file, true));
    205                  InputStreamReader isr =new InputStreamReader(is);
     205                 InputStreamReader isr = new InputStreamReader(is);
    206206                 BufferedReader br = new BufferedReader(isr)) {
    207207                String line;
    208                 while ( null!=(line=br.readLine())){
     208                while (null != (line = br.readLine())) {
    209209                    line += "\n";
    210210                    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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    2424
    2525    private class Task extends PleaseWaitRunnable {
    26         public Task(WMSLayer wmsLayer, Bounds bounds) {
     26        Task(WMSLayer wmsLayer, Bounds bounds) {
    2727            super(tr("Downloading {0}", wmsLayer.getName()));
    2828        }
     
    3535                if (wmsLayer.grabber.getWmsInterface().retrieveInterface(wmsLayer)) {
    3636                    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);
    4138                        // this below is a temporary workaround to fix the "always on top" issue
    4239                        JDialog dialog = pane.createDialog(Main.parent, "");
     
    4542                        // till here
    4643                        dontGeoreference = true;
    47                     } else if (wmsLayer.grabber.getWmsInterface().downloadCanceled){
     44                    } else if (wmsLayer.grabber.getWmsInterface().downloadCanceled) {
    4845                        // do nothing
    4946                    } else {
     
    7370                                    "Use the normal Cadastre Grab menu."));*/
    7471                            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);
    7774                            // this below is a temporary workaround to fix the "always on top" issue
    7875                            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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    4242                    if (wmsLayer.isRaster()) {
    4343                        // 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\""));
    4546                        Main.getLayerManager().removeLayer(wmsLayer);
    4647                        wmsLayer = null;
     
    5354                // grab new images from wms server into active layer
    5455                wmsLayer.grab(bounds);
    55             }
    56             else if(wmsLayer.getImages().size()==0)
     56            } else if (wmsLayer.getImages().size() == 0)
    5757              // failed to contact WMS of find this commune. Remove layer if empty.
    5858              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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
    44class 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
  • 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    4444    private double pixelPerEast;
    4545    private double pixelPerNorth;
    46    
    4746
    4847    public GeorefImage(BufferedImage img, EastNorth min, EastNorth max, WMSLayer wmsLayer) {
    4948        image = img;
    50  
     49
    5150        this.min = min;
    5251        this.max = max;
     
    8180     */
    8281    private EastNorthBound computeNewBounding(EastNorth p1, EastNorth p2, EastNorth p3, EastNorth p4) {
    83         EastNorth pt[] = new EastNorth[4];
     82        EastNorth[] pt = new EastNorth[4];
    8483        pt[0] = p1;
    8584        pt[1] = p2;
     
    9089        double highestEast = Double.MIN_VALUE;
    9190        double highestNorth = Double.MIN_VALUE;
    92         for(int i=0; i<=3; i++) {
     91        for (int i = 0; i <= 3; i++) {
    9392            smallestEast = Math.min(pt[i].east(), smallestEast);
    9493            smallestNorth = Math.min(pt[i].north(), smallestNorth);
     
    111110
    112111        // 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) {
    115114            dx = wmsLayer.deltaEast;
    116115            dy = wmsLayer.deltaNorth;
     
    131130            } else {
    132131                Point[] croppedPoint = new Point[5];
    133                 for (int i=0; i<4; i++)
     132                for (int i = 0; i < 4; i++) {
    134133                    croppedPoint[i] = nc.getPoint(
    135134                            new EastNorth(orgCroppedRaster[i].east()+dx, orgCroppedRaster[i].north()+dy));
     135                }
    136136                croppedPoint[4] = croppedPoint[0];
    137                 for (int i=0; i<4; i++) {
     137                for (int i = 0; i < 4; i++) {
    138138                    g.setColor(Color.green);
    139139                    g.drawLine(croppedPoint[i].x, croppedPoint[i].y, croppedPoint[i+1].x, croppedPoint[i+1].y);
     
    173173    /**
    174174     * Make all pixels masked by the given georefImage transparent in this image
    175      *
    176      * @param georefImage
    177175     */
    178176    public void withdraw(GeorefImage georefImage) {
     
    189187            int heightYMaskPixel = Math.abs((int) ((maxMaskNorth - minMaskNorth) / pxPerNorth));
    190188            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++) {
    193191                    image.setRGB(x, y, VectorImageModifier.cadastreBackgroundTransp);
     192                }
     193            }
    194194            g.dispose();
    195195        }
     
    222222        if (WMSLayer.currentFormat >= 4) {
    223223            imageOriginalHeight = in.readInt();
    224             imageOriginalWidth =  in.readInt();
    225         }
    226         image = (BufferedImage) ImageIO.read(ImageIO.createImageInputStream(in));
     224            imageOriginalWidth = in.readInt();
     225        }
     226        image = ImageIO.read(ImageIO.createImageInputStream(in));
    227227        updatePixelPer();
    228228    }
     
    285285        min = new EastNorth(min.east() + dx, min.north() + dy);
    286286        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++) {
    288288            orgRaster[i] = new EastNorth(orgRaster[i].east() + dx, orgRaster[i].north() + dy);
    289289            orgCroppedRaster[i] = new EastNorth(orgCroppedRaster[i].east() + dx, orgCroppedRaster[i].north() + dy);
    290290        }
    291291    }
    292    
     292
    293293    /**
    294294     * Change this image scale by moving the min,max coordinates around an anchor
    295      * @param anchor
    296      * @param proportion
    297295     */
    298296    public void scale(EastNorth anchor, double proportion) {
    299297        min = anchor.interpolate(min, proportion);
    300298        max = anchor.interpolate(max, proportion);
    301         for (int i=0; i<4; i++) {
     299        for (int i = 0; i < 4; i++) {
    302300            orgRaster[i] = anchor.interpolate(orgRaster[i], proportion);
    303301            orgCroppedRaster[i] = anchor.interpolate(orgCroppedRaster[i], proportion);
     
    316314            return;
    317315        // rotate the bounding boxes coordinates first
    318         for (int i=0; i<4; i++) {
     316        for (int i = 0; i < 4; i++) {
    319317            orgRaster[i] = orgRaster[i].rotate(anchor, delta_ang);
    320318            orgCroppedRaster[i] = orgCroppedRaster[i].rotate(anchor, delta_ang);
     
    323321        double sin = Math.abs(Math.sin(angle+delta_ang)), cos = Math.abs(Math.cos(angle+delta_ang));
    324322        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);
    327325        GraphicsConfiguration gc = getDefaultConfiguration();
    328326        BufferedImage result = gc.createCompatibleImage(neww, newh, image.getTransparency());
     
    336334        min = enb.min;
    337335        max = enb.max;
    338         angle+=delta_ang;
     336        angle += delta_ang;
    339337    }
    340338
     
    346344    public void crop(EastNorth adj1, EastNorth adj2) {
    347345        // 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());
    352350        int newWidth = Math.abs(sx2 - sx1);
    353351        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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    3535    /**
    3636     * Call directly grabber for raster images or prepare thread for vector images
    37      * @param moreImages
    3837     */
    3938    public void addImages(ArrayList<EastNorthBound> moreImages) {
     
    4140        imagesToGrab.addAll(moreImages);
    4241        lockImagesToGrag.unlock();
    43         synchronized(this) {
     42        synchronized (this) {
    4443            this.notify();
    4544        }
     
    139138                notifyWaiter();
    140139            }
    141             waitNotification();        }
     140            waitNotification();
     141        }
    142142    }
    143143
     
    152152            getCacheControl().deleteCacheFile();
    153153            wmsLayer.imagesLock.lock();
    154             for (GeorefImage image : wmsLayer.getImages())
     154            for (GeorefImage image : wmsLayer.getImages()) {
    155155                getCacheControl().saveCache(image);
     156            }
    156157            wmsLayer.imagesLock.unlock();
    157158        }
     
    199200        croppedPoint[3] = mv.getPoint(new EastNorth(img.max.east(), img.min.north()));
    200201        croppedPoint[4] = croppedPoint[0];
    201         for (int i=0; i<4; i++) {
     202        for (int i = 0; i < 4; i++) {
    202203            g.setColor(color);
    203204            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.
    32package cadastre_fr;
    43
     
    2524    protected BufferedImage convert1(BufferedImage src) {
    2625        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}
    3030        );
    3131
     
    113113
    114114    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++) {
    116116            if (rgb == cBuilingFootColors[i])
    117117                    return true;
     118        }
    118119        if (ignoreParcelColor && (rgb == parcelColor))
    119120            return true;
     
    122123
    123124    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++) {
    125126            if (rgb == cRoofColors[i])
    126127                    return true;
     128        }
    127129        if (ignoreParcelColor && (rgb == parcelColor))
    128130            return true;
     
    153155    /**
    154156     * Checks if the rgb value is the black background color
    155      * @param
    156      * @return
    157157     */
    158158    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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    2222    }
    2323
     24    @Override
    2425    public void actionPerformed(ActionEvent arg0) {
    2526        wmsLayer = WMSDownloadAction.getLayer();
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionCancelGrab.java

    r26382 r32556  
     1// License: GPL. For details, see LICENSE file.
    12package cadastre_fr;
    23
     4import static org.openstreetmap.josm.tools.I18n.marktr;
    35import static org.openstreetmap.josm.tools.I18n.tr;
    4 import static org.openstreetmap.josm.tools.I18n.marktr;
    56
    67import java.awt.event.ActionEvent;
     
    2021    }
    2122
    22 
    2323    @Override
    2424    public void actionPerformed(ActionEvent arg0) {
     
    2727        }
    2828    }
    29 
    3029}
  • 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    2525    }
    2626
     27    @Override
    2728    public void actionPerformed(ActionEvent e) {
    2829        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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    2525    private WMSLayer wmsLayer;
    2626    private RasterImageGeoreferencer rasterImageGeoreferencer;
    27    
     27
    2828    public MenuActionGrabPlanImage() {
    2929        super(tr(name), "cadastre_small", tr("Grab non-georeferenced image"), null, false, "cadastrefr/grabplanimage", true);
     
    3636        if (!rasterImageGeoreferencer.isRunning()) return;
    3737        if (Main.getLayerManager().containsLayer(wmsLayer))
    38                 return;
     38            return;
    3939        JOptionPane.showMessageDialog(Main.parent, tr("Georeferencing interrupted"));
    4040        rasterImageGeoreferencer.actionInterrupted();
     
    4242
    4343    @Override
    44         public void actionPerformed(ActionEvent ae) {
     44    public void actionPerformed(ActionEvent ae) {
    4545        if (Main.map != null) {
    4646            if (CadastrePlugin.isCadastreProjection()) {
     
    5858
    5959    @Override
    60         public void run() {
     60    public void run() {
    6161        // wait until plan image is fully loaded and joined into one single image
    6262        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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    3939            if (file.exists()) {
    4040                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());
    4242                if ((ext.length() == 3 && ext.substring(0, CacheControl.C_LAMBERT_CC_9Z.length()).equals(CacheControl.C_LAMBERT_CC_9Z) &&
    4343                    !(CadastrePlugin.isLambert_cc9()))
     
    4545                            !(CadastrePlugin.isUtm_france_dom()))
    4646                    || (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);
    4849                        continue;
    4950                } else {
     
    5657                    try {
    5758                        int cacheZone = Integer.parseInt(ext) - 1;
    58                         if (cacheZone >=0 && cacheZone <= 9) {
     59                        if (cacheZone >= 0 && cacheZone <= 9) {
    5960                            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);
    6164                                continue nextFile;
    6265                            } 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    2323    private static final long serialVersionUID = 1L;
    2424
    25     private static final String departements[] = {
     25    // CHECKSTYLE.OFF: LineLength
     26    // CHECKSTYLE.OFF: SingleSpaceSeparator
     27
     28    private static final String[] departements = {
    2629        "", tr("(optional)"),
    2730        "001", "01 - Ain",                 "002", "02 - Aisne",              "003", "03 - Allier",                "004", "04 - Alpes de Haute-Provence", "005", "05 - Hautes-Alpes",
     
    4851    };
    4952
     53    // CHECKSTYLE.ON: SingleSpaceSeparator
     54    // CHECKSTYLE.ON: LineLength
     55
    5056    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);
    5259    }
    5360
     
    6673        JPanel p = new JPanel(new GridBagLayout());
    6774        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"));
    6976        inputTown.setToolTipText(tr("<html>Enter the town,village or city name.<br>"
    7077                + "Use the syntax and punctuation known by www.cadastre.gouv.fr .</html>"));
    71         JLabel labelDepartement =  new JLabel(tr("Departement"));
     78        JLabel labelDepartement = new JLabel(tr("Departement"));
    7279        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) {
    7481            inputDepartement.addItem(departements[i]);
    7582        }
    7683        inputDepartement.setToolTipText(tr("<html>Departement number (optional)</html>"));
    7784        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) {
    7986                if (departements[i].equals(Main.pref.get("cadastrewms.codeDepartement")))
    8087                    inputDepartement.setSelectedIndex(i/2);
     88            }
    8189        }
    8290        p.add(labelSectionNewLocation, GBC.eol());
     
    119127            Main.info("Add new layer with Location:" + inputTown.getText());
    120128        } else if (existingLayers != null && existingLayers.size() > 0 && Main.getLayerManager().getActiveLayer() instanceof WMSLayer) {
    121             wmsLayer = (WMSLayer)Main.getLayerManager().getActiveLayer();
     129            wmsLayer = (WMSLayer) Main.getLayerManager().getActiveLayer();
    122130        }
    123131
  • 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    1111import org.openstreetmap.josm.gui.preferences.PreferenceDialog;
    1212
    13 public class MenuActionOpenPreferences extends JosmAction { 
    14     private static final long serialVersionUID = 1L; 
     13public class MenuActionOpenPreferences extends JosmAction {
     14    private static final long serialVersionUID = 1L;
    1515
    16     public static String name = marktr("Preferences"); 
     16    public static String name = marktr("Preferences");
    1717
    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    }
    2728}
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionRefineGeoRef.java

    r30859 r32556  
     1// License: GPL. For details, see LICENSE file.
    12package cadastre_fr;
    23
     
    2425    @Override
    2526    public void actionPerformed(ActionEvent arg0) {
    26         if(!wmsLayer.isRaster()) {
     27        if (!wmsLayer.isRaster()) {
    2728            Main.info("MenuActionRefineGeoRef called for unexpected layer type");
    2829            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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    1919    }
    2020
     21    @Override
    2122    public void actionPerformed(ActionEvent e) {
    2223        //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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    4343            return file.getName().toLowerCase().endsWith(".png");
    4444        }
     45
    4546        @Override
    4647        public String getDescription() {
     
    5758            return file.getName().toLowerCase().endsWith(".tif");
    5859        }
     60
    5961        @Override
    6062        public String getDescription() {
     
    8284            file = fc.getSelectedFile();
    8385            BufferedImage bi = wmsLayer.getImage(0).image;
    84             if (fc.getFileFilter().equals(filtrePng))
    85             {
     86            if (fc.getFileFilter().equals(filtrePng)) {
    8687                if (!file.getName().endsWith(".png"))
    8788                    file = new File(file.getParent(), file.getName()+".png");
     
    9899                    e.printStackTrace();
    99100                }
    100             }
    101             else if (fc.getFileFilter().equals(filtreTiff))
    102             {
     101            } else if (fc.getFileFilter().equals(filtreTiff)) {
    103102                boolean alpha = bi.getColorModel().hasAlpha();
    104103                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.
    12package cadastre_fr;
    23
     
    3940    private int initialClickDelay;
    4041
    41     public void addListener(){
     42    public void addListener() {
    4243        Main.map.mapView.addMouseListener(this);
    4344    }
     
    5152       mode = cGetCorners;
    5253       countMouseClicked = 0;
    53        initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay",200);
     54       initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay", 200);
    5455       mouseClickedTime = System.currentTimeMillis();
    55        Object[] options = { "OK", "Cancel" };
    56        int ret = JOptionPane.showOptionDialog( null,
     56       Object[] options = {"OK", "Cancel"};
     57       int ret = JOptionPane.showOptionDialog(null,
    5758               tr("Click first corner for image cropping\n(two points required)"),
    5859               tr("Image cropping"),
     
    7576      countMouseClicked = 0;
    7677      mode = cGetLambertCrosspieces;
    77       initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay",200);
     78      initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay", 200);
    7879      mouseClickedTime = System.currentTimeMillis();
    79       Object[] options = { "OK", "Cancel" };
    80       int ret = JOptionPane.showOptionDialog( null,
     80      Object[] options = {"OK", "Cancel"};
     81      int ret = JOptionPane.showOptionDialog(null,
    8182              tr("Click first Lambert crosspiece for georeferencing\n(two points required)"),
    8283              tr("Image georeferencing"),
     
    9192  }
    9293
    93   public boolean isRunning()
    94   {
     94  public boolean isRunning() {
    9595      return (countMouseClicked != 0 || mode != 0);
    9696  }
     
    101101          Main.info("mouse click bounce detected");
    102102          return; // mouse click anti-bounce
    103       }
    104       else
     103      } else
    105104          mouseClickedTime = System.currentTimeMillis();
    106105      if (e.getButton() != MouseEvent.BUTTON1)
     
    115114          // ignore clicks outside the image
    116115          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()) {
    119117              Main.info("ignore click outside the image");
    120118              return;
     
    144142  }
    145143
    146 
    147144  /**
    148145   *
     
    150147   */
    151148 private boolean canceledOrRestartCurrAction(String action) {
    152      Object[] options = { "Cancel", "Retry" };
    153      int selectedValue = JOptionPane.showOptionDialog( null,
     149     Object[] options = {"Cancel", "Retry"};
     150     int selectedValue = JOptionPane.showOptionDialog(null,
    154151             tr("Do you want to cancel completely\n"+
    155152                     "or just retry "+action+" ?"), "",
     
    177174 private void affineTransform(EastNorth org1, EastNorth org2, EastNorth dst1, EastNorth dst2) {
    178175     // 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) {
    181177         JOptionPane.showMessageDialog(Main.parent,
    182178                 tr("Ooops. I failed to catch all coordinates\n"+
     
    286282 */
    287283private boolean continueCropping() {
    288     Object[] options = { "OK", "Cancel" };
    289     int ret = JOptionPane.showOptionDialog( null,
     284    Object[] options = {"OK", "Cancel"};
     285    int ret = JOptionPane.showOptionDialog(null,
    290286            tr("Click second corner for image cropping"),
    291287            tr("Image cropping"),
     
    316312 */
    317313private boolean continueGeoreferencing() {
    318     Object[] options = { "OK", "Cancel" };
    319     int ret = JOptionPane.showOptionDialog( null,
     314    Object[] options = {"OK", "Cancel"};
     315    int ret = JOptionPane.showOptionDialog(null,
    320316            tr("Click second Lambert crosspiece for georeferencing"),
    321317            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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    1212
    1313    private int cadastreBackground = -1; // white
    14    
     14
    1515    public static int cadastreBackgroundTransp = 16777215; // original white but transparent
    16    
     16
    1717    private boolean transparencyEnabled = false;
    1818
    1919    public RasterImageModifier(BufferedImage bi) {
    2020        bufferedImage = bi;
    21         transparencyEnabled = Main.pref.getBoolean("cadastrewms.backgroundTransparent"); 
     21        transparencyEnabled = Main.pref.getBoolean("cadastrewms.backgroundTransparent");
    2222        if (transparencyEnabled)
    2323            makeTransparent();
     
    3535            for (int y = 0; y < h; y++) {
    3636                int pixel = bufferedImage.getRGB(x, y);
    37                 if ((!transparencyEnabled && pixel != cadastreBackground) 
     37                if ((!transparencyEnabled && pixel != cadastreBackground)
    3838                        || (transparencyEnabled && pixel != cadastreBackgroundTransp)) {
    3939                    bufferedImage.setRGB(x, y, reverseIfGrey(pixel));
     
    4646     * Reverse the grey value if the pixel is grey (light grey becomes dark grey)
    4747     * Used for texts.
    48      * @param pixel
    49      * @return
    5048     */
    5149    private int reverseIfGrey(int pixel) {
     
    7775                    Color maskedColor;
    7876                    if (rgb == cadastreBackground) {
    79                         maskedColor = simplifyColors ? new Color(0xff, 0xff, 0xff, 0x00) : 
     77                        maskedColor = simplifyColors ? new Color(0xff, 0xff, 0xff, 0x00) :
    8078                            new Color(r, g, b, 0x00); // transparent
    8179                    } else {
    82                         maskedColor = simplifyColors ? new Color(0, 0, 0, 0xFF) : 
     80                        maskedColor = simplifyColors ? new Color(0, 0, 0, 0xFF) :
    8381                            new Color(r, g, b, 0xFF); // opaque
    8482                    }
     
    9088        return;
    9189    }
    92    
     90
    9391    /**
    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.
    9794     * @return new image
    9895     */
     
    10198        int height = img.getHeight();
    10299        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    103         int rgbArray[] = new int[width * height];
     100        int[] rgbArray = new int[width * height];
    104101        img.getRGB(0, 0, width, height, rgbArray, 0, width);
    105102        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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    77 * This class is not intended to be a real SVG parser. It's also not using existing
    88 * 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
    1010 *
    1111 */
     
    2929            try {
    3030                String str = svg.substring(s, e);
    31                 String [] viewBox = str.split(" ");
     31                String[] viewBox = str.split(" ");
    3232                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                }
    3536                return dbox;
    3637            } catch (Exception ex) {
     
    4041        return null;
    4142    }
    42    
     43
    4344    /**
    4445     * Closed SVG paths are finishing with a "Z" at the end of the moves list.
    45      * @param svg
    46      * @return
    4746     */
    48     public String [] getClosedPaths(String svg) {
     47    public String[] getClosedPaths(String svg) {
    4948        ArrayList<String> path = new ArrayList<>();
    5049        int i = 0;
     
    5352            int e = svg.indexOf(cClosedPathEnd, s);
    5453            if (s != -1 && e != -1) {
    55                 String onePath = svg.substring(s, e); 
     54                String onePath = svg.substring(s, e);
    5655                if (onePath.indexOf("Z") != -1) // only closed SVG path
    5756                    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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    2424        this.value = value;
    2525    }
     26
     27    @Override
    2628    public String toString() {
    2729        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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    1010/**
    1111 * Imported from plugin UtilsPlugin
    12  * @author 
     12 * @author
    1313 *
    1414 */
     
    2626            simplifyWayRange(wnew, from, to, ns, thr);
    2727            List<Node> nodes = wnew.getNodes();
    28             for (int j = to - 1; j > from; j--)
     28            for (int j = to - 1; j > from; j--) {
    2929                nodes.remove(j);
     30            }
    3031            nodes.addAll(from+1, ns);
    3132            wnew.setNodes(nodes);
    3233        }
    3334    }
    34    
     35
    3536    /*
    3637     * Takes an interval [from,to] and adds nodes from (from,to) to ns.
     
    6061        }
    6162    }
     63
    6264    public static double EARTH_RAD = 6378137.0;
     65
    6366    /* From Aviaton Formulary v1.3
    6467     * http://williams.best.vwh.net/avform.htm
     
    7477                % (2 * Math.PI);
    7578    }
     79
    7680    public static double xtd(double lat1, double lon1, double lat2, double lon2, double lat3, double lon3) {
    7781        double dist_AD = dist(lat1, lon1, lat3, lon3);
     
    8084        return Math.asin(Math.sin(dist_AD) * Math.sin(crs_AD - crs_AB));
    8185    }
    82 
    8386}
  • 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    77import java.awt.image.IndexColorModel;
    88import java.awt.image.WritableRaster;
     9
    910import org.openstreetmap.josm.Main;
    1011import org.openstreetmap.josm.tools.ColorHelper;
     
    1314
    1415    private int cadastreBackground = -1; // white
    15    
     16
    1617    public static int cadastreBackgroundTransp = 1; // original white but transparent
    1718
    1819    private int backgroundPixel = 0;
    1920
    20     public VectorImageModifier() {super();}
    21    
     21    public VectorImageModifier() {
     22        super();
     23    }
     24
    2225    public VectorImageModifier(BufferedImage bi, boolean monocolor) {
    2326        bufferedImage = bi;
     
    7073     * Reverse the grey value if the pixel is grey (light grey becomes dark grey)
    7174     * Used for texts.
    72      * @param pixel
    73      * @return
    7475     */
    7576    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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    1616
    1717import org.openstreetmap.josm.Main;
     18import org.openstreetmap.josm.actions.mapmode.MapMode;
     19import org.openstreetmap.josm.data.coor.EastNorth;
    1820import org.openstreetmap.josm.gui.MapFrame;
    1921import org.openstreetmap.josm.gui.MapView;
    20 import org.openstreetmap.josm.actions.mapmode.MapMode;
    21 import org.openstreetmap.josm.data.coor.EastNorth;
    2222import org.openstreetmap.josm.tools.ImageProvider;
    2323
    2424public class WMSAdjustAction extends MapMode implements
    25         MouseListener, MouseMotionListener{
     25        MouseListener, MouseMotionListener {
    2626
    2727    private static final long serialVersionUID = 1L;
     
    2929    private boolean rasterMoved;
    3030    private EastNorth prevEastNorth;
    31     enum Mode { moveXY, moveZ, rotate}
     31    enum Mode { moveXY, moveZ, rotate }
     32
    3233    private static Mode mode = null;
    3334    private static EastNorth[] croppedRaster = new EastNorth[5];;
     
    4243        if (Main.map != null) {
    4344            if (Main.getLayerManager().getActiveLayer() instanceof WMSLayer) {
    44                 modifiedLayer = (WMSLayer)Main.getLayerManager().getActiveLayer();
     45                modifiedLayer = (WMSLayer) Main.getLayerManager().getActiveLayer();
    4546                super.enterMode();
    4647                Main.map.mapView.addMouseListener(this);
     
    5253//                        +"a cadastre layer"));
    5354                exitMode();
    54                 Main.map.selectMapMode((MapMode)Main.map.getDefaultButtonAction());
     55                Main.map.selectMapMode((MapMode) Main.map.getDefaultButtonAction());
    5556            }
    5657        }
     
    9798
    9899    @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());
    100101        if (mode == Mode.rotate) {
    101102            rotateFrameOnly(prevEastNorth, newEastNorth);
     
    105106            } else if (mode == Mode.moveZ) {
    106107                resize(newEastNorth);
    107             } 
     108            }
    108109            prevEastNorth = newEastNorth;
    109110        }
    110111        Main.map.mapView.repaint();
    111112    }
    112    
     113
    113114    public static void paintAdjustFrames(Graphics2D g, final MapView mv) {
    114115        if (mode == Mode.rotate && croppedRaster != null) {
    115116            g.setColor(Color.red);
    116             for (int i=0; i<4; i++)
     117            for (int i = 0; i < 4; i++) {
    117118                g.drawLine(mv.getPoint(croppedRaster[i]).x,
    118119                        mv.getPoint(croppedRaster[i]).y,
    119120                        mv.getPoint(croppedRaster[i+1]).x,
    120121                        mv.getPoint(croppedRaster[i+1]).y);
     122            }
    121123        }
    122124    }
     
    148150            double rotationAngle = endAngle - startAngle;
    149151            if (modifiedLayer.getImage(0).orgCroppedRaster != null) {
    150                 for (int i=0; i<4; i++) {
     152                for (int i = 0; i < 4; i++) {
    151153                    croppedRaster[i] = modifiedLayer.getImage(0).orgCroppedRaster[i].rotate(pivot, rotationAngle);
    152154                }
     
    157159
    158160    @Override public void mouseReleased(MouseEvent e) {
    159         //Main.map.mapView.repaint();
    160161        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());
    162163            rotate(prevEastNorth, newEastNorth);
    163164            Main.map.mapView.repaint();
     
    168169    }
    169170
     171    @Override
    170172    public void mouseEntered(MouseEvent e) {
    171173    }
     174
     175    @Override
    172176    public void mouseExited(MouseEvent e) {
    173177    }
     178
     179    @Override
    174180    public void mouseMoved(MouseEvent e) {
    175181    }
  • 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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    1313import org.openstreetmap.josm.gui.layer.Layer;
    1414
    15 public class WMSDownloadAction /*extends JosmAction */{
     15public class WMSDownloadAction /*extends JosmAction */ {
    1616
    1717//    public WMSDownloadAction(String layerName) {
     
    3232            for (Layer l : Main.getLayerManager().getLayers()) {
    3333                if (l instanceof WMSLayer) {
    34                     existingWMSlayers.add((WMSLayer)l);
     34                    existingWMSlayers.add((WMSLayer) l);
    3535                }
    3636            }
     
    5050        return null;
    5151    }
    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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    55    private String message;
    66    private static final long serialVersionUID = 1L;
    7     public WMSException(String message) {
     7
     8    WMSException(String message) {
    89        super();
    910        this.message = message;
    1011    }
     12
     13    @Override
    1114    public String getMessage() {
    1215        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 others
     1// License: GPL. For details, see LICENSE file.
    22package cadastre_fr;
    33
     
    7777    private String codeCommune = "";
    7878
    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));
    8080
    8181    private boolean isRaster;
     
    100100    @SuppressWarnings("serial")
    101101    class ResetOffsetActionMenu extends JosmAction {
    102         public ResetOffsetActionMenu() {
     102        ResetOffsetActionMenu() {
    103103            super(tr("Reset offset"), null, tr("Reset offset (only vector images)"), null, false);
    104104        }
     105
    105106        @Override
    106107        public void actionPerformed(ActionEvent arg0) {
     
    136137    public void destroy() {
    137138        // if the layer is currently saving the images in the cache, wait until it's finished
    138         if(grabThread != null)
     139        if (grabThread != null)
    139140                grabThread.cancel();
    140141        grabThread = null;
     
    149150        if (codeCommune != null && !codeCommune.isEmpty())
    150151            ret += "(" + codeCommune + ")";
    151         return  ret;
     152        return ret;
    152153    }
    153154
     
    160161        grabThread.setGrabber(grabber);
    161162        // 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) {
    163164            final Bounds bounds = this.getCommuneBBox().toBounds();
    164165            GuiHelper.runInEDTAndWait(new Runnable() {
     
    174175                        Integer.parseInt(Main.pref.get("cadastrewms.rasterDivider", CadastrePreferenceSetting.DEFAULT_RASTER_DIVIDER)));
    175176            } else
    176                 divideBbox(b, 
     177                divideBbox(b,
    177178                        Integer.parseInt(Main.pref.get("cadastrewms.scale", CadastrePreferenceSetting.DEFAULT_GRAB_MULTIPLIER)));
    178179        }
     
    199200        dividedBbox.clear();
    200201        if (factor < 4 || isRaster) {
    201             for (int xEast = 0; xEast < factor; xEast++)
     202            for (int xEast = 0; xEast < factor; xEast++) {
    202203                for (int xNorth = 0; xNorth < factor; xNorth++) {
    203204                    dividedBbox.add(new EastNorthBound(new EastNorth(minEast + xEast * dEast, minNorth + xNorth * dNorth),
    204205                                new EastNorth(minEast + (xEast + 1) * dEast, minNorth + (xNorth + 1) * dNorth)));
     206                }
    205207            }
    206208        } else {
     
    208210            // grab all square in a spiral starting from the center (usually the most interesting place)
    209211            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);
    212214            EastNorth mid = lambertMax.getCenter(lambertMin);
    213215            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};
    219221            int currDir = -1, lDir = 1, i = 1, j = 0, k = -1;
    220222            if (x == 1)
     
    231233                    }
    232234                    j = 0;
    233                     currDir = (currDir+1)%4;
     235                    currDir = (currDir+1) % 4;
    234236                } else if (currDir >= 0 && j >= (currDir == 0 || currDir == 2 ? (x-1) : (y-1))) {
    235237                    // the overall is a rectangle, not a square. Jump to the other side to grab next square.
     
    240242                    }
    241243                    j = lDir-1;
    242                     currDir = (currDir+1)%4;
     244                    currDir = (currDir+1) % 4;
    243245                    mid = new EastNorth(mid.east() + dx[currDir]*c*(lDir-1), mid.north() + dy[currDir]*c*(lDir-1));
    244246                }
     
    260262            str += "\n"+tr("Is not vectorized.");
    261263            str += "\n"+tr("Bounding box: {0}", communeBBox);
    262             if(!images.isEmpty())
     264            if (!images.isEmpty())
    263265                str += "\n"+tr("Image size (px): {0}/{1}", images.get(0).image.getWidth(), images.get(0).image.getHeight());
    264266        } else {
     
    281283    @Override
    282284    public void paint(Graphics2D g, final MapView mv, Bounds bounds) {
    283         synchronized(this){
     285        synchronized (this) {
    284286            Object savedInterpolation = g.getRenderingHint(RenderingHints.KEY_INTERPOLATION);
    285287            if (savedInterpolation == null) savedInterpolation = RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR;
     
    292294                g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
    293295            imagesLock.lock();
    294             for (GeorefImage img : images)
     296            for (GeorefImage img : images) {
    295297                img.paint(g, mv, CadastrePlugin.backgroundTransparent,
    296298                        CadastrePlugin.transparency, CadastrePlugin.drawBoundaries);
     299            }
    297300            imagesLock.unlock();
    298301            g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, savedInterpolation);
     
    329332        refineGeoRef.setEnabled(isRaster && grabThread.getImagesToGrabSize() == 0);
    330333        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));
    332335        return new Action[] {
    333336                LayerListDialog.getInstance().createShowHideLayerAction(),
     
    447450     * Called by CacheControl when a new cache file is created on disk.
    448451     * Save only primitives to keep cache independent of software changes.
    449      * @param oos
    450      * @throws IOException
    451452     */
    452453    public void write(File associatedFile, ObjectOutputStream oos) throws IOException {
     
    475476     * Called by CacheControl when a cache file is read from disk.
    476477     * Cache uses only primitives to stay independent of software changes.
    477      * @param ois
    478      * @throws IOException
    479      * @throws ClassNotFoundException
    480478     */
    481479    public boolean read(File associatedFile, ObjectInputStream ois, int currentLambertZone) throws IOException, ClassNotFoundException {
     
    506504        double maxX = ois.readDouble();
    507505        double maxY = ois.readDouble();
    508         this.communeBBox =  new EastNorthBound(new EastNorth(minX, minY), new EastNorth(maxX, maxY));
     506        this.communeBBox = new EastNorthBound(new EastNorth(minX, minY), new EastNorth(maxX, maxY));
    509507        if (this.lambertZone != currentLambertZone && currentLambertZone != -1) {
    510508            JOptionPane.showMessageDialog(Main.parent, tr("Lambert zone {0} in cache "+
     
    513511            return false;
    514512        }
    515         synchronized(this){
     513        synchronized (this) {
    516514            boolean EOF = false;
    517515            try {
     
    534532            } catch (EOFException ex) {
    535533                // expected exception when all images are read
     534                Main.trace(ex);
    536535            }
    537536        }
     
    560559            Graphics g = newImg.getGraphics();
    561560            // 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());
    563562            for (int h = 0; h < lx.size(); h++) {
    564563                for (int v = 0; v < ly.size(); v++) {
     
    569568                }
    570569            }
    571             synchronized(this) {
     570            synchronized (this) {
    572571                images.clear();
    573572                images.add(new GeorefImage(newImg, min, max, this));
     
    581580     * Works only for raster image layer (only one image in collection).
    582581     * 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) {
    587584        // adj1 is corner bottom, left
    588585        EastNorth adj1 = new EastNorth(en1.east() <= en2.east() ? en1.east() : en2.east(),
     
    596593        rasterMax = adj2;
    597594        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)));
    600597        rasterRatio = (rasterMax.getX()-rasterMin.getX())/(communeBBox.max.getX() - communeBBox.min.getX());
    601598    }
     
    613610        double minY = Double.MAX_VALUE;
    614611        double maxY = Double.MIN_VALUE;
    615         for (GeorefImage image:images){
     612        for (GeorefImage image:images) {
    616613            minX = image.min.east() < minX ? image.min.east() : minX;
    617614            maxX = image.max.east() > maxX ? image.max.east() : maxX;
     
    649646            images.get(0).shear(dx, dy);
    650647        } else {
    651             deltaEast+=dx;
    652             deltaNorth+=dy;
     648            deltaEast += dx;
     649            deltaNorth += dy;
    653650        }
    654651    }
     
    675672            EastNorthBound currentView = new EastNorthBound(mv.getEastNorth(0, mv.getHeight()),
    676673                    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);
    684681                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));
    688685                        g.drawLine(p.x-px, p.y, p.x+px, p.y);
    689686                        g.drawLine(p.x, p.y-px, p.x, p.y+px);
Note: See TracChangeset for help on using the changeset viewer.