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

checkstyle

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.