Changeset 32968 in osm for applications/editors


Ignore:
Timestamp:
2016-09-10T16:45:11+02:00 (8 years ago)
Author:
donvip
Message:

checkstyle

Location:
applications/editors/josm/plugins/canvec_helper
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/canvec_helper/.project

    r32286 r32968  
    1616                        </arguments>
    1717                </buildCommand>
     18                <buildCommand>
     19                        <name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
     20                        <arguments>
     21                        </arguments>
     22                </buildCommand>
    1823        </buildSpec>
    1924        <natures>
    2025                <nature>org.eclipse.jdt.core.javanature</nature>
     26                <nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
    2127        </natures>
    2228</projectDescription>
  • applications/editors/josm/plugins/canvec_helper/src/org/openstreetmap/josm/plugins/canvec_helper/CanVecTile.java

    r32483 r32968  
    1 // License: GPL
     1// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.canvec_helper;
    33
    4 import java.util.ArrayList;
    5 import java.util.Enumeration;
    6 import java.util.List;
    7 import java.util.zip.ZipEntry;
    8 import java.util.zip.ZipFile;
    9 import java.util.regex.Pattern;
    10 import java.util.regex.Matcher;
    11 
    12 import org.openstreetmap.josm.Main;
    13 import org.openstreetmap.josm.data.Bounds;
    14 
     4import java.awt.Graphics2D;
    155import java.awt.Point;
    16 
    17 import org.openstreetmap.josm.data.coor.LatLon;
    18 import org.openstreetmap.josm.gui.MapView;
    19 import org.openstreetmap.josm.io.IllegalDataException;
    20 import org.openstreetmap.josm.io.CachedFile;
    21 
    22 import java.awt.Graphics2D;
    236import java.awt.Polygon;
    247import java.io.File;
    258import java.io.IOException;
    269import java.io.InputStream;
    27 
     10import java.util.ArrayList;
     11import java.util.Enumeration;
     12import java.util.List;
     13import java.util.regex.Matcher;
     14import java.util.regex.Pattern;
     15import java.util.zip.ZipEntry;
     16import java.util.zip.ZipFile;
     17
     18import org.openstreetmap.josm.Main;
     19import org.openstreetmap.josm.data.Bounds;
     20import org.openstreetmap.josm.data.coor.LatLon;
     21import org.openstreetmap.josm.gui.MapView;
     22import org.openstreetmap.josm.io.CachedFile;
     23import org.openstreetmap.josm.io.IllegalDataException;
    2824import org.openstreetmap.josm.io.OsmImporter;
    2925import org.openstreetmap.josm.io.OsmImporter.OsmImporterData;
     
    3430    private List<String> subTileIds = new ArrayList<>();
    3531    private boolean zipScanned = false;
    36    
     32
    3733    private List<CanVecTile> subTiles = new ArrayList<>();
    3834    private boolean subTilesMade = false;
     
    4036    private List<String> index;
    4137    private int depth;
    42    
     38
    4339    private int corda;
    4440    private int cordc;
     
    4945    String tileid;
    5046    CanVecTile(String tileid, CanvecLayer layer) {
    51         String parta,partb,partc,partd;
    52         parta = tileid.substring(0,3);
     47        String parta, partb, partc, partd;
     48        parta = tileid.substring(0, 3);
    5349        partb = tileid.substring(3, 4);
    5450        partc = tileid.substring(4, 6);
    5551        partd = tileid.substring(6);
    56         int a,c;
     52        int a, c;
    5753        a = Integer.parseInt(parta);
    5854        c = Integer.parseInt(partc);
    59         realInit(a,partb,c,partd,layer,new ArrayList<String>());
    60     }
    61     CanVecTile(int a,String b,int c,String d,CanvecLayer layer, List<String> index) {
    62         realInit(a,b,c,d,layer,index);
    63     }
    64     private void realInit(int a,String b,int c,String d,CanvecLayer layer, List<String> index) {
     55        realInit(a, partb, c, partd, layer, new ArrayList<String>());
     56    }
     57
     58    CanVecTile(int a, String b, int c, String d, CanvecLayer layer, List<String> index) {
     59        realInit(a, b, c, d, layer, index);
     60    }
     61
     62    private void realInit(int a, String b, int c, String d, CanvecLayer layer, List<String> index) {
    6563        this.index = index;
    6664        this.layer = layer;
     
    8179            zeroPointLat = 40 + 4 * row;
    8280            zeroPointLon = -56 - 8 * column;
    83        
     81
    8482            // size of each grid
    8583            if (row <= 6) {
     
    10098        if (b.isEmpty()) grid2 = 0;
    10199        else grid2 = b.charAt(0) - 64;
    102         int[] rows1 = { 0, 0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3 };
    103         int[] cols1 = { 0, 3,2,1,0, 0,1,2,3, 3,2,1,0, 0,1,2,3 };
     100        int[] rows1 = {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3};
     101        int[] cols1 = {0, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3};
    104102        lat2 = zeroPointLat + (latSpan/4)*rows1[grid2];
    105103        lon2 = zeroPointLon + (lonSpan/4)*cols1[grid2];
     
    111109        }
    112110
    113         int[] rows3 = { 0, 0,0,0,0, 1,1,1,1, 2,2,2,2, 3,3,3,3 };
     111        int[] rows3 = {0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3};
    114112        lat2 = lat2 + (latSpan/4)*rows3[c];
    115         int[] cols3 = { 0, 3,2,1,0, 0,1,2,3, 3,2,1,0, 0,1,2,3 };
     113        int[] cols3 = {0, 3, 2, 1, 0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2, 3};
    116114        lon2 = lon2 + (lonSpan/4)*cols3[c];
    117115
     
    121119            depth = 3;
    122120        }
    123        
     121
    124122        if (!cordd.isEmpty()) {
    125123            depth = 4;
     
    153151        }
    154152
    155         bounds = new Bounds(lat2,lon2,lat2+latSpan,lon2+lonSpan);
    156         if (cordb.isEmpty()) this.tileid = String.format("%03d",corda);
    157         else if (cordc == 0) this.tileid = String.format("%03d%s",corda,cordb);
    158         else if (cordd.isEmpty()) this.tileid = String.format("%03d%s%02d",corda,cordb,cordc);
    159         else this.tileid = String.format("%03d%s%02d%s",corda,cordb,cordc,cordd);
     153        bounds = new Bounds(lat2, lon2, lat2+latSpan, lon2+lonSpan);
     154        if (cordb.isEmpty()) this.tileid = String.format("%03d", corda);
     155        else if (cordc == 0) this.tileid = String.format("%03d%s", corda, cordb);
     156        else if (cordd.isEmpty()) this.tileid = String.format("%03d%s%02d", corda, cordb, cordc);
     157        else this.tileid = String.format("%03d%s%02d%s", corda, cordb, cordc, cordd);
    160158        valid = true;
    161159    }
     160
    162161    boolean isValid() {
    163162        return valid;
    164163    }
     164
    165165    String getTileId() {
    166166        return this.tileid;
    167167    }
     168
    168169    boolean isVisible(Bounds view) {
    169170        return view.intersects(bounds);
    170171    }
     172
    171173    Point[] getCorners(MapView mv) {
    172174        LatLon min = bounds.getMin();
    173175        LatLon max = bounds.getMax();
    174         LatLon x1 = new LatLon(min.lat(),max.lon());
    175         LatLon x2 = new LatLon(max.lat(),min.lon());
     176        LatLon x1 = new LatLon(min.lat(), max.lon());
     177        LatLon x2 = new LatLon(max.lat(), min.lon());
    176178        return new Point[] {
    177179            mv.getPoint(min), // south west
     
    181183            };
    182184    }
     185
    183186    public String getDownloadUrl() {
    184         return String.format("http://ftp2.cits.rncan.gc.ca/OSM/pub/%1$03d/%2$s/%1$03d%2$s%3$02d.zip",corda,cordb,cordc);
    185     }
     187        return String.format("http://ftp2.cits.rncan.gc.ca/OSM/pub/%1$03d/%2$s/%1$03d%2$s%3$02d.zip", corda, cordb, cordc);
     188    }
     189
    186190    private ZipFile openZip() throws IOException {
    187191        File downloadPath = new File(layer.plugin.getPluginDir() + File.separator);
     
    192196        return new ZipFile(tileZip.getFile());
    193197    }
     198
    194199    void downloadSelf() {
    195200        if (zipScanned) return;
     
    207212            subTileIds.add(entry.getName());
    208213            zipScanned = true;
    209             CanVecTile finalTile = new CanVecTile(entry.getName(),layer);
     214            CanVecTile finalTile = new CanVecTile(entry.getName(), layer);
    210215            if (finalTile.isValid()) {
    211216                subTiles.add(finalTile);
     
    213218        }
    214219    }
     220
    215221    void loadRawOsm() {
    216222        ZipFile zipFile;
     
    234240        }
    235241    }
     242
    236243    private void makeSubTiles(int layer) {
    237244        List<String> buffer = new ArrayList<>();
     
    252259                    buffer.add(m.group(0));
    253260                } else {
    254                     subTiles.add(new CanVecTile(corda,lastCell,0,"",this.layer,buffer));
     261                    subTiles.add(new CanVecTile(corda, lastCell, 0, "", this.layer, buffer));
    255262                    buffer = new ArrayList<>();
    256263                    buffer.add(m.group(0));
     
    258265                lastCell = cell;
    259266            }
    260             subTiles.add(new CanVecTile(corda,lastCell,0,"",this.layer,buffer));
     267            subTiles.add(new CanVecTile(corda, lastCell, 0, "", this.layer, buffer));
    261268            break;
    262269        case 2:
     
    273280                    buffer.add(m.group(0));
    274281                } else {
    275                     subTiles.add(new CanVecTile(corda,cordb,lastCell2,"",this.layer,buffer));
     282                    subTiles.add(new CanVecTile(corda, cordb, lastCell2, "", this.layer, buffer));
    276283                    buffer = new ArrayList<>();
    277284                    buffer.add(m.group(0));
     
    279286                lastCell2 = cell;
    280287            }
    281             if (lastCell2 != -1) subTiles.add(new CanVecTile(corda,cordb,lastCell2,"",this.layer,buffer));
     288            if (lastCell2 != -1) subTiles.add(new CanVecTile(corda, cordb, lastCell2, "", this.layer, buffer));
    282289            break;
    283290        }
    284291        subTilesMade = true;
    285292    }
     293
    286294    void paint(Graphics2D g, MapView mv, Bounds bounds, int maxZoom) {
    287295        boolean showSubTiles = false;
     
    310318            for (int i = 0; i < subTiles.size(); i++) {
    311319                CanVecTile tile = subTiles.get(i);
    312                 tile.paint(g,mv,bounds,maxZoom);
     320                tile.paint(g, mv, bounds, maxZoom);
    313321            }
    314322        } else {
    315323            Point[] corners = getCorners(mv);
    316             int[] xs = { corners[0].x, corners[1].x, corners[2].x, corners[3].x };
    317             int[] ys = { corners[0].y, corners[1].y, corners[2].y, corners[3].y };
    318             Polygon shape = new Polygon(xs,ys,4);
     324            int[] xs = {corners[0].x, corners[1].x, corners[2].x, corners[3].x };
     325            int[] ys = {corners[0].y, corners[1].y, corners[2].y, corners[3].y };
     326            Polygon shape = new Polygon(xs, ys, 4);
    319327            g.draw(shape);
    320             g.drawString(getTileId(),corners[0].x,corners[0].y);
     328            g.drawString(getTileId(), corners[0].x, corners[0].y);
    321329        }
    322330    }
  • applications/editors/josm/plugins/canvec_helper/src/org/openstreetmap/josm/plugins/canvec_helper/CanvecHelper.java

    r30757 r32968  
    1 // License: GPL
     1// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.canvec_helper;
    33
  • applications/editors/josm/plugins/canvec_helper/src/org/openstreetmap/josm/plugins/canvec_helper/CanvecHelperAction.java

    r32483 r32968  
    1 // License: GPL
     1// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.canvec_helper;
    33
     4import org.openstreetmap.josm.Main;
    45import org.openstreetmap.josm.actions.JosmAction;
    5 import org.openstreetmap.josm.Main;
    66
    77class CanvecHelperAction extends JosmAction {
    88    private CanvecHelper parentTemp;
    99    CanvecHelperAction(CanvecHelper parent) {
    10         super("CanVec Helper","layericon24",null,null,false);
     10        super("CanVec Helper", "layericon24", null, null, false);
    1111        parentTemp = parent;
    1212    }
     
    1414    @Override
    1515    public void actionPerformed(java.awt.event.ActionEvent action) {
    16         Main.getLayerManager().addLayer(new CanvecLayer("canvec tile helper",parentTemp));
     16        Main.getLayerManager().addLayer(new CanvecLayer("canvec tile helper", parentTemp));
    1717    }
    1818}
  • applications/editors/josm/plugins/canvec_helper/src/org/openstreetmap/josm/plugins/canvec_helper/CanvecLayer.java

    r30757 r32968  
    1 // License: GPL
     1// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.canvec_helper;
    33
     
    4444    List<CanVecTile> openable = new ArrayList<>();
    4545
    46     CanvecLayer(String name, CanvecHelper self){
     46    CanvecLayer(String name, CanvecHelper self) {
    4747        super(name);
    4848        plugin = self;
     
    6565                        list.add(m.group(0));
    6666                    } else if (lastCell != -1) {
    67                         CanVecTile tile = new CanVecTile(lastCell,"",0,"",this,list);
     67                        CanVecTile tile = new CanVecTile(lastCell, "", 0, "", this, list);
    6868                        if (tile.isValid()) tiles.add(tile);
    6969                        list = new ArrayList<>();
     
    7575                }
    7676            }
    77             CanVecTile tile = new CanVecTile(lastCell,"",0,"",this,list);
     77            CanVecTile tile = new CanVecTile(lastCell, "", 0, "", this, list);
    7878            if (tile.isValid()) tiles.add(tile);
    7979
     
    8787        }
    8888    }
     89
    8990    @Override
    9091    public Action[] getMenuEntries() {
     
    9899            new OpenOsmAction(this)};
    99100    }
    100     private static class MaxZoomAction extends AbstractAction implements LayerAction {
     101
     102    private static final class MaxZoomAction extends AbstractAction implements LayerAction {
    101103        private final CanvecLayer parent;
    102104        private MaxZoomAction(CanvecLayer parent) {
    103105            this.parent = parent;
    104106        }
     107
    105108        @Override
    106109        public void actionPerformed(ActionEvent e) {
    107110            // Do nothing
    108111        }
     112
    109113        @Override
    110114        public boolean supportLayers(List<Layer> layers) {
    111115            return false;
    112116        }
     117
    113118        @Override
    114119        public Component createMenuComponent() {
    115120            JMenu maxZoomMenu = new JMenu("max zoom");
    116             maxZoomMenu.add(new JMenuItem(new SetMaxZoom(parent,1)));
    117             maxZoomMenu.add(new JMenuItem(new SetMaxZoom(parent,2)));
    118             maxZoomMenu.add(new JMenuItem(new SetMaxZoom(parent,3)));
    119             maxZoomMenu.add(new JMenuItem(new SetMaxZoom(parent,4)));
     121            maxZoomMenu.add(new JMenuItem(new SetMaxZoom(parent, 1)));
     122            maxZoomMenu.add(new JMenuItem(new SetMaxZoom(parent, 2)));
     123            maxZoomMenu.add(new JMenuItem(new SetMaxZoom(parent, 3)));
     124            maxZoomMenu.add(new JMenuItem(new SetMaxZoom(parent, 4)));
    120125            return maxZoomMenu;
    121126        }
    122127    }
    123     private static class AllowDownload extends AbstractAction {
     128
     129    private static final class AllowDownload extends AbstractAction {
    124130        private final CanVecTile tile;
    125131        private AllowDownload(CanVecTile tile) {
     
    127133            this.tile = tile;
    128134        }
     135
    129136        @Override
    130137        public void actionPerformed(ActionEvent arg0) {
     
    132139        }
    133140    }
    134     private class OpenOsmAction extends AbstractAction implements LayerAction {
     141
     142    private final class OpenOsmAction extends AbstractAction implements LayerAction {
    135143        private CanvecLayer layer;
    136144        private OpenOsmAction(CanvecLayer layer) {
    137145            this.layer = layer;
    138146        }
     147
    139148        @Override
    140149        public void actionPerformed(ActionEvent e) {
    141150            // Do nothing
    142151        }
     152
    143153        @Override
    144154        public Component createMenuComponent() {
     
    149159            return openOsm;
    150160        }
     161
    151162        @Override
    152163        public boolean supportLayers(List<Layer> layers) {
     
    154165        }
    155166    }
    156     private static class DoOpenOsm extends AbstractAction {
     167
     168    private static final class DoOpenOsm extends AbstractAction {
    157169        private final CanVecTile tile;
    158170        private DoOpenOsm(CanVecTile tile) {
     
    160172            this.tile = tile;
    161173        }
     174
    162175        @Override
    163176        public void actionPerformed(ActionEvent e) {
     
    165178        }
    166179    }
    167     private class DownloadCanvecAction extends AbstractAction implements LayerAction {
     180
     181    private final class DownloadCanvecAction extends AbstractAction implements LayerAction {
    168182        private CanvecLayer parent;
    169183        private DownloadCanvecAction(CanvecLayer parent) {
    170184            this.parent = parent;
    171185        }
     186
    172187        @Override
    173188        public void actionPerformed(ActionEvent e) {
    174189            // Do nothing
    175190        }
     191
    176192        @Override
    177193        public boolean supportLayers(List<Layer> layers) {
    178194            return false;
    179195        }
     196
    180197        @Override
    181198        public Component createMenuComponent() {
     
    187204        }
    188205    }
     206
    189207    void setMaxZoom(int maxZoom) {
    190208        this.maxZoom = maxZoom;
    191209    }
     210
    192211    @Override
    193212    public Object getInfoComponent() {
    194213        return getToolTipText();
    195214    }
     215
    196216    @Override
    197217    public String getToolTipText() {
    198218        return tr("canvec tile helper");
    199219    }
     220
    200221    @Override
    201222    public void visitBoundingBox(BoundingXYVisitor v) {
    202223        // Do nothing
    203224    }
     225
    204226    @Override
    205227    public boolean isMergable(Layer other) {
    206228        return false;
    207229    }
     230
    208231    @Override
    209232    public void mergeFrom(Layer from) {
    210233        // Do nothing
    211234    }
     235
    212236    @Override
    213237    public Icon getIcon() {
    214238        return layerIcon;
    215239    }
     240
    216241    @Override
    217242    public void paint(Graphics2D g, MapView mv, Bounds bounds) {
     
    222247        for (int i = 0; i < tiles.size(); i++) {
    223248            CanVecTile tile = tiles.get(i);
    224             tile.paint(g,mv,bounds,maxZoom);
     249            tile.paint(g, mv, bounds, maxZoom);
    225250        }
    226251    }
  • applications/editors/josm/plugins/canvec_helper/src/org/openstreetmap/josm/plugins/canvec_helper/SetMaxZoom.java

    r30757 r32968  
    1 // License: GPL
     1// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.canvec_helper;
    33
    44import java.awt.event.ActionEvent;
     5
    56import javax.swing.AbstractAction;
    67
     
    89    private CanvecLayer parent;
    910    private int level;
    10     SetMaxZoom(CanvecLayer parent,int level) {
     11    SetMaxZoom(CanvecLayer parent, int level) {
    1112        super(""+level);
    1213        this.level = level;
    1314        this.parent = parent;
    1415    }
     16
    1517    @Override
    1618    public void actionPerformed(ActionEvent ev) {
Note: See TracChangeset for help on using the changeset viewer.