Changeset 8530 in josm


Ignore:
Timestamp:
2015-06-25T00:05:23+02:00 (9 years ago)
Author:
Don-vip
Message:

see #11255 - checkstyle/findbugs

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r8526 r8530  
    499499     */
    500500    public void cancelOutstandingTasks() {
    501         for(Runnable r: downloadJobExecutor.getQueue()) {
     501        for (Runnable r: downloadJobExecutor.getQueue()) {
    502502            if (downloadJobExecutor.remove(r) && r instanceof JCSCachedTileLoaderJob) {
    503503                ((JCSCachedTileLoaderJob<?, ?>) r).handleJobCancellation();
  • trunk/src/org/openstreetmap/josm/data/imagery/CachedAttributionBingAerialTileSource.java

    r8526 r8530  
    2020 *
    2121 * @author Wiktor Niesiobędzki
    22  * @since TODO
    23  *
     22 * @since 8526
    2423 */
    2524public class CachedAttributionBingAerialTileSource extends BingAerialTileSource {
     
    7170    }
    7271}
    73 
  • trunk/src/org/openstreetmap/josm/data/imagery/CachedTileLoaderFactory.java

    r8526 r8530  
    1717 *
    1818 * @author Wiktor Niesiobędzki
    19  * @since TODO
    20  *
     19 * @since 8526
    2120 */
    2221public abstract class CachedTileLoaderFactory implements TileLoaderFactory {
     
    5958        try {
    6059            return getLoader(listener, cacheName,
    61                     Main.pref.getInteger("socket.timeout.connect",15) * 1000,
     60                    Main.pref.getInteger("socket.timeout.connect", 15) * 1000,
    6261                    Main.pref.getInteger("socket.timeout.read", 30) * 1000,
    6362                    headers,
     
    6968    }
    7069
    71     protected abstract TileLoader getLoader(TileLoaderListener listener, String cacheName, int connectTimeout, int readTimeout, Map<String, String> headers, String cacheDir) throws IOException;
     70    protected abstract TileLoader getLoader(TileLoaderListener listener, String cacheName, int connectTimeout, int readTimeout,
     71            Map<String, String> headers, String cacheDir) throws IOException;
    7272}
  • trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java

    r8526 r8530  
    160160     * queue from default.
    161161     *
    162      * @param downloadExecutor
     162     * @param downloadExecutor download executor that will be used to download tiles
    163163     */
    164164    public void setDownloadExecutor(ThreadPoolExecutor downloadExecutor) {
     
    172172        return downloadExecutor;
    173173    }
    174 
    175174}
  • trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java

    r8526 r8530  
    3434 *
    3535 * @author Wiktor Niesiobędzki
    36  * @since TODO
    37  *
     36 * @since 8526
    3837 */
    3938public class TemplatedWMSTileSource extends TMSTileSource implements TemplatedTileSource {
     
    5352    private static final String PATTERN_HEIGHT  = "\\{height\\}";
    5453
    55 
    5654    private static final NumberFormat latLonFormat = new DecimalFormat("###0.0000000", new DecimalFormatSymbols(Locale.US));
    5755
     
    6260    /**
    6361     * Creates a tile source based on imagery info
    64      * @param info
     62     * @param info imagery info
    6563     */
    6664    public TemplatedWMSTileSource(ImageryInfo info) {
     
    106104        double s = se.getY();
    107105        double e = se.getX();
    108 
    109106
    110107        if (!serverProjections.contains(myProjCode) && serverProjections.contains("EPSG:4326") && "EPSG:3857".equals(myProjCode)) {
     
    167164
    168165    @Override
    169     public int LonToX(double lon, int zoom) {
    170         throw new UnsupportedOperationException("Not implemented");
    171     }
    172 
    173     @Override
    174     public int LatToY(double lat, int zoom) {
     166    public int lonToX(double lon, int zoom) {
     167        throw new UnsupportedOperationException("Not implemented");
     168    }
     169
     170    @Override
     171    public int latToY(double lat, int zoom) {
    175172        throw new UnsupportedOperationException("Not implemented");
    176173    }
     
    298295    /**
    299296     * Checks if url is acceptable by this Tile Source
    300      * @param url
     297     * @param url URL to check
    301298     */
    302299    public static void checkUrl(String url) {
     
    324321        Matcher matcher = pattern.matcher(this.baseUrl);
    325322        while (matcher.find()) {
    326             headers.put(matcher.group(1),matcher.group(2));
     323            headers.put(matcher.group(1), matcher.group(2));
    327324            matcher.appendReplacement(output, "");
    328325        }
     
    337334                        topLeftCorner.north() - y * scale
    338335                        );
    339 
    340336    }
    341337
     
    372368        return (int) Math.ceil(Math.abs(max.getX() - min.getX()) / scale);
    373369    }
    374 
    375 
    376370}
  • trunk/src/org/openstreetmap/josm/data/imagery/TileLoaderFactory.java

    r8526 r8530  
    1111 *
    1212 * @author Wiktor Niesiobędzki
    13  * @since TODO
    14  *
     13 * @since 8526
    1514 */
    1615public interface TileLoaderFactory {
     
    2827     */
    2928    TileLoader makeTileLoader(TileLoaderListener listener, Map<String, String> headers);
    30 
    3129}
  • trunk/src/org/openstreetmap/josm/data/imagery/WMSCachedTileLoader.java

    r8526 r8530  
    1515 *
    1616 * @author Wiktor Niesiobędzki
    17  * @since TODO
    18  *
     17 * @since 8526
    1918 */
    2019public class WMSCachedTileLoader extends TMSCachedTileLoader {
    2120
    2221    /** limit of concurrent connections to WMS tile source (per source) */
    23     public static IntegerProperty THREAD_LIMIT = new IntegerProperty("imagery.wms.simultaneousConnections", 3);
     22    public static final IntegerProperty THREAD_LIMIT = new IntegerProperty("imagery.wms.simultaneousConnections", 3);
    2423
    2524    /**
  • trunk/src/org/openstreetmap/josm/data/imagery/WMSCachedTileLoaderJob.java

    r8526 r8530  
    1515 *
    1616 * @author Wiktor Niesiobędzki
    17  * @since TODO
    18  *
     17 * @since 8526
    1918 */
    2019public class WMSCachedTileLoaderJob extends TMSCachedTileLoaderJob {
     
    4544        return null;
    4645    }
    47 
    4846}
  • trunk/src/org/openstreetmap/josm/gui/bbox/TileSelectionBBoxChooser.java

    r8510 r8530  
    681681                max = null;
    682682            } else {
    683                 int y1 = tileSource.LatToY(bbox.getMinLat(), MAX_ZOOM);
    684                 int y2 = tileSource.LatToY(bbox.getMaxLat(), MAX_ZOOM);
    685                 int x1 = tileSource.LonToX(bbox.getMinLon(), MAX_ZOOM);
    686                 int x2 = tileSource.LonToX(bbox.getMaxLon(), MAX_ZOOM);
     683                int y1 = tileSource.latToY(bbox.getMinLat(), MAX_ZOOM);
     684                int y2 = tileSource.latToY(bbox.getMaxLat(), MAX_ZOOM);
     685                int x1 = tileSource.lonToX(bbox.getMinLon(), MAX_ZOOM);
     686                int x2 = tileSource.lonToX(bbox.getMaxLon(), MAX_ZOOM);
    687687
    688688                min = new Point(Math.min(x1, x2), Math.min(y1, y2));
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r8526 r8530  
    8080
    8181/**
    82  *
    8382 * Base abstract class that supports displaying images provided by TileSource. It might be TMS source, WMS or WMTS
    8483 *
    8584 * It implements all standard functions of tilesource based layers: autozoom,  tile reloads, layer saving, loading,etc.
    8685 *
     86 * @author Upliner
    8787 * @author Wiktor Niesiobędzki
    88  * @since TODO
    89  *
     88 * @since 3715
     89 * @since 8526 (copied from TMSLayer)
    9090 */
    9191public abstract class AbstractTileSourceLayer extends ImageryLayer implements ImageObserver, TileLoaderListener, ZoomChangeListener {
     
    135135    /**
    136136     * Creates Tile Source based Imagery Layer based on Imagery Info
    137      * @param info
    138      * @param tileSource
     137     * @param info imagery info
    139138     */
    140139    public AbstractTileSourceLayer(ImageryInfo info) {
    141140        super(info);
    142141
    143         if(!isProjectionSupported(Main.getProjection())) {
     142        if (!isProjectionSupported(Main.getProjection())) {
    144143            JOptionPane.showMessageDialog(Main.parent,
    145144                    tr("This layer do not support the projection {0}.\n{1}\n"
     
    160159    /**
    161160     *
    162      * @param info
     161     * @param info imagery info
    163162     * @return TileSource for specified ImageryInfo
    164163     * @throws IllegalArgumentException when Imagery is not supported by layer
     
    185184            tileLoader = new OsmTileLoader(this);
    186185    }
    187 
    188 
    189186
    190187    @Override
     
    219216        tileCache.clear();
    220217        if (tileLoader instanceof CachedTileLoader) {
    221             ((CachedTileLoader)tileLoader).clearCache(tileSource);
    222         }
    223     }
    224 
     218            ((CachedTileLoader) tileLoader).clearCache(tileSource);
     219        }
     220    }
    225221
    226222    /**
     
    262258    }
    263259
    264     private final int getBestZoom() {
     260    private int getBestZoom() {
    265261        double factor = getScaleFactor(1); // check the ratio between area of tilesize at zoom 1 to current view
    266262        double result = Math.log(factor)/Math.log(2)/2+1;
     
    275271         * getScaleFactor(...) is supposed to be between 0.75 and 3
    276272         */
    277         int intResult = (int)Math.floor(result);
     273        int intResult = (int) Math.floor(result);
    278274        if (intResult > getMaxZoomLvl())
    279275            return getMaxZoomLvl();
     
    283279    }
    284280
    285 
    286     private final static boolean actionSupportLayers(List<Layer> layers) {
     281    private static boolean actionSupportLayers(List<Layer> layers) {
    287282        return layers.size() == 1 && layers.get(0) instanceof TMSLayer;
     283    }
     284
     285    private final class ShowTileInfoAction extends AbstractAction {
     286        private final TileHolder clickedTileHolder;
     287
     288        private ShowTileInfoAction(TileHolder clickedTileHolder) {
     289            super(tr("Show Tile Info"));
     290            this.clickedTileHolder = clickedTileHolder;
     291        }
     292
     293        private String getSizeString(int size) {
     294            StringBuilder ret = new StringBuilder();
     295            return ret.append(size).append("x").append(size).toString();
     296        }
     297
     298        private JTextField createTextField(String text) {
     299            JTextField ret = new JTextField(text);
     300            ret.setEditable(false);
     301            ret.setBorder(BorderFactory.createEmptyBorder());
     302            return ret;
     303        }
     304
     305        @Override
     306        public void actionPerformed(ActionEvent ae) {
     307            Tile clickedTile = clickedTileHolder.getTile();
     308            if (clickedTile != null) {
     309                ExtendedDialog ed = new ExtendedDialog(Main.parent, tr("Tile Info"), new String[]{tr("OK")});
     310                JPanel panel = new JPanel(new GridBagLayout());
     311                Rectangle displaySize = tileToRect(clickedTile);
     312                String url = "";
     313                try {
     314                    url = clickedTile.getUrl();
     315                } catch (IOException e) {
     316                    // silence exceptions
     317                    if (Main.isTraceEnabled()) {
     318                        Main.trace(e.getMessage());
     319                    }
     320                }
     321
     322                String[][] content = {
     323                        {"Tile name", clickedTile.getKey()},
     324                        {"Tile url", url},
     325                        {"Tile size", getSizeString(clickedTile.getTileSource().getTileSize()) },
     326                        {"Tile display size", new StringBuilder().append(displaySize.width).append("x").append(displaySize.height).toString()},
     327                };
     328
     329                for (String[] entry: content) {
     330                    panel.add(new JLabel(tr(entry[0]) + ":"), GBC.std());
     331                    panel.add(GBC.glue(5, 0), GBC.std());
     332                    panel.add(createTextField(entry[1]), GBC.eol().fill(GBC.HORIZONTAL));
     333                }
     334
     335                for (Entry<String, String> e: clickedTile.getMetadata().entrySet()) {
     336                    panel.add(new JLabel(tr("Metadata ") + tr(e.getKey()) + ":"), GBC.std());
     337                    panel.add(GBC.glue(5, 0), GBC.std());
     338                    String value = e.getValue();
     339                    if ("lastModification".equals(e.getKey()) || "expirationTime".equals(e.getKey())) {
     340                        value = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(Long.parseLong(value)));
     341                    }
     342                    panel.add(createTextField(value), GBC.eol().fill(GBC.HORIZONTAL));
     343
     344                }
     345                ed.setIcon(JOptionPane.INFORMATION_MESSAGE);
     346                ed.setContent(panel);
     347                ed.showDialog();
     348            }
     349        }
    288350    }
    289351
     
    292354            super(tr("Auto Zoom"));
    293355        }
     356
    294357        @Override
    295358        public void actionPerformed(ActionEvent ae) {
     
    302365            return item;
    303366        }
     367
    304368        @Override
    305369        public boolean supportLayers(List<Layer> layers) {
    306370            return actionSupportLayers(layers);
    307371        }
    308 
    309372    }
    310373
     
    313376            super(tr("Auto load tiles"));
    314377        }
     378
    315379        @Override
    316380        public void actionPerformed(ActionEvent ae) {
    317             autoLoad= !autoLoad;
     381            autoLoad = !autoLoad;
    318382        }
    319383
     
    323387            return item;
    324388        }
     389
    325390        @Override
    326391        public boolean supportLayers(List<Layer> layers) {
     
    333398            super(tr("Load All Tiles"));
    334399        }
     400
    335401        @Override
    336402        public void actionPerformed(ActionEvent ae) {
     
    356422            super(tr("Zoom to native resolution"));
    357423        }
     424
    358425        @Override
    359426        public void actionPerformed(ActionEvent ae) {
     
    368435            super(tr("Change resolution"));
    369436        }
     437
    370438        @Override
    371439        public void actionPerformed(ActionEvent ae) {
     
    374442    }
    375443
    376     /*
     444    /**
    377445     * Simple class to keep clickedTile within hookUpMapView
    378446     */
    379     private class TileHolder {
     447    private static final class TileHolder {
    380448        private Tile t = null;
    381449
     
    432500        }));
    433501
    434         tileOptionMenu.add(new JMenuItem(new AbstractAction(
    435                 tr("Show Tile Info")) {
    436             private String getSizeString(int size) {
    437                 StringBuilder ret = new StringBuilder();
    438                 return ret.append(size).append("x").append(size).toString();
    439             }
    440 
    441             private JTextField createTextField(String text) {
    442                 JTextField ret = new JTextField(text);
    443                 ret.setEditable(false);
    444                 ret.setBorder(BorderFactory.createEmptyBorder());
    445                 return ret;
    446             }
    447 
    448             @Override
    449             public void actionPerformed(ActionEvent ae) {
    450                 Tile clickedTile = clickedTileHolder.getTile();
    451                 if (clickedTile != null) {
    452                     ExtendedDialog ed = new ExtendedDialog(Main.parent, tr("Tile Info"), new String[]{tr("OK")});
    453                     JPanel panel = new JPanel(new GridBagLayout());
    454                     Rectangle displaySize = tileToRect(clickedTile);
    455                     String url = "";
    456                     try {
    457                         url = clickedTile.getUrl();
    458                     } catch (IOException e) {
    459                         // silence exceptions
    460                     }
    461 
    462                     String[][] content = {
    463                             {"Tile name", clickedTile.getKey()},
    464                             {"Tile url", url},
    465                             {"Tile size", getSizeString(clickedTile.getTileSource().getTileSize()) },
    466                             {"Tile display size", new StringBuilder().append(displaySize.width).append("x").append(displaySize.height).toString()},
    467                     };
    468 
    469                     for (String[] entry: content) {
    470                         panel.add(new JLabel(tr(entry[0]) + ":"), GBC.std());
    471                         panel.add(GBC.glue(5,0), GBC.std());
    472                         panel.add(createTextField(entry[1]), GBC.eol().fill(GBC.HORIZONTAL));
    473                     }
    474 
    475                     for (Entry<String, String> e: clickedTile.getMetadata().entrySet()) {
    476                         panel.add(new JLabel(tr("Metadata ") + tr(e.getKey()) + ":"), GBC.std());
    477                         panel.add(GBC.glue(5,0), GBC.std());
    478                         String value = e.getValue();
    479                         if ("lastModification".equals(e.getKey()) || "expirationTime".equals(e.getKey())) {
    480                             value = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(Long.parseLong(value)));
    481                         }
    482                         panel.add(createTextField(value), GBC.eol().fill(GBC.HORIZONTAL));
    483 
    484                     }
    485                     ed.setIcon(JOptionPane.INFORMATION_MESSAGE);
    486                     ed.setContent(panel);
    487                     ed.showDialog();
    488                 }
    489             }
    490         }));
     502        tileOptionMenu.add(new JMenuItem(new ShowTileInfoAction(clickedTileHolder)));
    491503
    492504        tileOptionMenu.add(new JMenuItem(new LoadAllTilesAction()));
     
    586598     */
    587599    public static int checkMaxZoomLvl(int maxZoomLvl, TileSource ts) {
    588         if(maxZoomLvl > MAX_ZOOM) {
     600        if (maxZoomLvl > MAX_ZOOM) {
    589601            maxZoomLvl = MAX_ZOOM;
    590602        }
    591         if(maxZoomLvl < PROP_MIN_ZOOM_LVL.get()) {
     603        if (maxZoomLvl < PROP_MIN_ZOOM_LVL.get()) {
    592604            maxZoomLvl = PROP_MIN_ZOOM_LVL.get();
    593605        }
     
    605617     */
    606618    public static int checkMinZoomLvl(int minZoomLvl, TileSource ts) {
    607         if(minZoomLvl < MIN_ZOOM) {
     619        if (minZoomLvl < MIN_ZOOM) {
    608620            minZoomLvl = MIN_ZOOM;
    609621        }
    610         if(minZoomLvl > PROP_MAX_ZOOM_LVL.get()) {
     622        if (minZoomLvl > PROP_MAX_ZOOM_LVL.get()) {
    611623            minZoomLvl = getMaxZoomLvl(ts);
    612624        }
     
    617629    }
    618630
    619 
    620631    /**
    621632     * @param ts TileSource for which we want to know maximum zoom level
     
    634645    }
    635646
    636 
    637647    /**
    638648     * Sets maximum zoom level, that layer will attempt show
    639      * @param maxZoomLvl
     649     * @param maxZoomLvl maximum zoom level
    640650     */
    641651    public static void setMaxZoomLvl(int maxZoomLvl) {
     
    646656    /**
    647657     * Sets minimum zoom level, that layer will attempt show
    648      * @param minZoomLvl
     658     * @param minZoomLvl minimum zoom level
    649659     */
    650660    public static void setMinZoomLvl(int minZoomLvl) {
     
    652662        PROP_MIN_ZOOM_LVL.put(minZoomLvl);
    653663    }
    654 
    655664
    656665    /**
     
    664673        }
    665674        if (tileLoader instanceof TMSCachedTileLoader) {
    666             ((TMSCachedTileLoader)tileLoader).cancelOutstandingTasks();
     675            ((TMSCachedTileLoader) tileLoader).cancelOutstandingTasks();
    667676        }
    668677        needRedraw = true;
     
    687696        boolean zia = currentZoomLevel < this.getMaxZoomLvl();
    688697        if (Main.isDebugEnabled()) {
    689             Main.debug("zoomIncreaseAllowed(): " + zia + " " + currentZoomLevel + " vs. " + this.getMaxZoomLvl() );
     698            Main.debug("zoomIncreaseAllowed(): " + zia + " " + currentZoomLevel + " vs. " + this.getMaxZoomLvl());
    690699        }
    691700        return zia;
     
    812821        TileSet ts = getVisibleTileSet();
    813822
    814         // if there is more than 18 tiles on screen in any direction, do not
    815         // load all tiles!
     823        // if there is more than 18 tiles on screen in any direction, do not load all tiles!
    816824        if (ts.tooLarge()) {
    817825            Main.warn("Not downloading all tiles because there is more than 18 tiles on an axis!");
     
    884892
    885893        // If a border is specified, only draw the intersection
    886         // if what we have combined with what we are supposed
    887         // to draw.
     894        // if what we have combined with what we are supposed to draw.
    888895        if (border != null) {
    889896            target = source.intersection(border);
     
    906913        int screen_x_offset = target.x - source.x;
    907914        int screen_y_offset = target.y - source.y;
    908         // And how many pixels into the image itself does that
    909         // correlate to?
    910         int img_x_offset = (int)(screen_x_offset * imageXScaling + 0.5);
    911         int img_y_offset = (int)(screen_y_offset * imageYScaling + 0.5);
     915        // And how many pixels into the image itself does that correlate to?
     916        int img_x_offset = (int) (screen_x_offset * imageXScaling + 0.5);
     917        int img_y_offset = (int) (screen_y_offset * imageYScaling + 0.5);
    912918        // Now calculate the other corner of the image that we need
    913919        // by scaling the 'target' rectangle's dimensions.
    914         int img_x_end = img_x_offset + (int)(target.getWidth() * imageXScaling + 0.5);
    915         int img_y_end = img_y_offset + (int)(target.getHeight() * imageYScaling + 0.5);
     920        int img_x_end = img_x_offset + (int) (target.getWidth() * imageXScaling + 0.5);
     921        int img_y_end = img_y_offset + (int) (target.getHeight() * imageYScaling + 0.5);
    916922
    917923        if (Main.isDebugEnabled()) {
     
    951957        // that we do not draw in missedTiles.  ts.allExistingTiles() by
    952958        // default will only return already-existing tiles.  However, we
    953         // need to return *all* tiles to the callers, so force creation
    954         // here.
    955         //boolean forceTileCreation = true;
     959        // need to return *all* tiles to the callers, so force creation here.
    956960        for (Tile tile : ts.allTilesCreate()) {
    957961            Image img = getLoadedTileImage(tile);
     
    975979        Color oldColor = g.getColor();
    976980        g.setColor(Color.black);
    977         g.drawString(text,x+1,y+1);
     981        g.drawString(text, x+1, y+1);
    978982        g.setColor(oldColor);
    979         g.drawString(text,x,y);
     983        g.drawString(text, x, y);
    980984    }
    981985
     
    10041008        if (tile.hasError() && showErrors) {
    10051009            myDrawString(g, tr("Error") + ": " + tr(tile.getErrorMessage()), p.x + 2, texty);
    1006             texty += 1 + fontHeight;
     1010            //texty += 1 + fontHeight;
    10071011        }
    10081012
     
    10481052    private Coordinate getShiftedCoord(EastNorth en) {
    10491053        LatLon ll = getShiftedLatLon(en);
    1050         return new Coordinate(ll.lat(),ll.lon());
    1051     }
    1052 
    1053     private final TileSet nullTileSet = new TileSet((LatLon)null, (LatLon)null, 0);
     1054        return new Coordinate(ll.lat(), ll.lon());
     1055    }
     1056
     1057    private final TileSet nullTileSet = new TileSet((LatLon) null, (LatLon) null, 0);
    10541058    private final class TileSet {
    10551059        int x0, x1, y0, y1;
     
    10601064         */
    10611065        private TileSet(EastNorth topLeft, EastNorth botRight, int zoom) {
    1062             this(getShiftedLatLon(topLeft), getShiftedLatLon(botRight),zoom);
     1066            this(getShiftedLatLon(topLeft), getShiftedLatLon(botRight), zoom);
    10631067        }
    10641068
     
    11781182                    return Math.abs(t.getXtile() - centerX) + Math.abs(t.getYtile() - centerY);
    11791183                }
     1184
    11801185                @Override
    11811186                public int compare(Tile o1, Tile o2) {
     
    11861191            };
    11871192        }
    1188 
    11891193
    11901194        private void loadAllTiles(boolean force) {
     
    12081212        }
    12091213    }
    1210 
    12111214
    12121215    private static class TileSetInfo {
     
    12481251            this.tileSetInfos = new TileSetInfo[maxZoom - minZoom + 1];
    12491252        }
     1253
    12501254        public TileSet getTileSet(int zoom) {
    12511255            if (zoom < minZoom)
     
    13161320            }
    13171321            // Do binary search between currentZoomLevel and displayZoomLevel
    1318             while (zoom > displayZoomLevel && !tsi.hasVisibleTiles && tsi.hasOverzoomedTiles){
     1322            while (zoom > displayZoomLevel && !tsi.hasVisibleTiles && tsi.hasOverzoomedTiles) {
    13191323                zoom = (zoom + displayZoomLevel)/2;
    13201324                tsi = dts.getTileSetInfo(zoom);
     
    14221426            myDrawString(g, tr("Pixel scale: {0}", getScaleFactor(currentZoomLevel)), 50, 170);
    14231427            myDrawString(g, tr("Best zoom: {0}", getBestZoom()), 50, 185);
    1424             if(tileLoader instanceof TMSCachedTileLoader) {
    1425                 TMSCachedTileLoader cachedTileLoader = (TMSCachedTileLoader)tileLoader;
     1428            if (tileLoader instanceof TMSCachedTileLoader) {
     1429                TMSCachedTileLoader cachedTileLoader = (TMSCachedTileLoader) tileLoader;
    14261430                int offset = 185;
    1427                 for(String part: cachedTileLoader.getStats().split("\n")) {
    1428                     myDrawString(g, tr("Cache stats: {0}", part), 50, offset+=15);
     1431                for (String part: cachedTileLoader.getStats().split("\n")) {
     1432                    myDrawString(g, tr("Cache stats: {0}", part), 50, offset += 15);
    14291433                }
    14301434
     
    14951499    @Override
    14961500    public String getToolTipText() {
    1497         if(autoLoad) {
     1501        if (autoLoad) {
    14981502            return tr("{0} ({1}), automatically downloading in zoom {2}", this.getClass().getSimpleName(), getName(), currentZoomLevel);
    14991503        } else {
     
    15531557        public void cancel() {
    15541558            if (tileLoader instanceof TMSCachedTileLoader) {
    1555                 ((TMSCachedTileLoader)tileLoader).cancelOutstandingTasks();
    1556             }
    1557         }
    1558 
     1559                ((TMSCachedTileLoader) tileLoader).cancelOutstandingTasks();
     1560            }
     1561        }
    15591562
    15601563        @Override
     
    15811584     * To prevent accidental clear of the queue, new download executor is created with separate queue
    15821585     *
    1583      * @param precacheTask
    1584      * @param points
     1586     * @param precacheTask Task responsible for precaching imagery
     1587     * @param points lat/lon coordinates to download
    15851588     * @param bufferX how many units in current Coordinate Reference System to cover in X axis in both sides
    15861589     * @param bufferY how many units in current Coordinate Reference System to cover in Y axis in both sides
    15871590     */
    15881591    public void downloadAreaToCache(final PrecacheTask precacheTask, List<LatLon> points, double bufferX, double bufferY) {
    1589         final Set<Tile> requestedTiles = new ConcurrentSkipListSet <>(new Comparator<Tile>() {
     1592        final Set<Tile> requestedTiles = new ConcurrentSkipListSet<>(new Comparator<Tile>() {
    15901593            public int compare(Tile o1, Tile o2) {
    15911594                return String.CASE_INSENSITIVE_ORDER.compare(o1.getKey(), o2.getKey());
     
    16041607            int maxX = Math.min(curTile.getXIndex() + 1, minTile.getXIndex());
    16051608
    1606             for (int x= minX; x<=maxX; x++) {
    1607                 for (int y= minY; y<=maxY; y++) {
     1609            for (int x = minX; x <= maxX; x++) {
     1610                for (int y = minY; y <= maxY; y++) {
    16081611                    requestedTiles.add(new Tile(tileSource, x, y, currentZoomLevel));
    16091612                }
  • trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java

    r8510 r8530  
    7979    /**
    8080     * Constructs a new {@code ImageryLayer}.
     81     * @param info imagery info
    8182     */
    8283    public ImageryLayer(ImageryInfo info) {
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r8526 r8530  
    2323import org.openstreetmap.josm.data.projection.Projection;
    2424
    25 
    2625/**
    2726 * Class that displays a slippy map layer.
     
    3433 */
    3534public class TMSLayer extends AbstractTileSourceLayer {
    36     private static final String PREFERENCE_PREFIX   = "imagery.tms";
     35    private static final String PREFERENCE_PREFIX = "imagery.tms";
    3736
    3837    /** minimum zoom level for TMS layer */
    39     public static final IntegerProperty PROP_MIN_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".min_zoom_lvl", AbstractTileSourceLayer.PROP_MIN_ZOOM_LVL.get());
     38    public static final IntegerProperty PROP_MIN_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".min_zoom_lvl",
     39            AbstractTileSourceLayer.PROP_MIN_ZOOM_LVL.get());
    4040    /** maximum zoom level for TMS layer */
    41     public static final IntegerProperty PROP_MAX_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".max_zoom_lvl", AbstractTileSourceLayer.PROP_MAX_ZOOM_LVL.get());
     41    public static final IntegerProperty PROP_MAX_ZOOM_LVL = new IntegerProperty(PREFERENCE_PREFIX + ".max_zoom_lvl",
     42            AbstractTileSourceLayer.PROP_MAX_ZOOM_LVL.get());
    4243    /** shall TMS layers be added to download dialog */
    4344    public static final BooleanProperty PROP_ADD_TO_SLIPPYMAP_CHOOSER = new BooleanProperty(PREFERENCE_PREFIX + ".add_to_slippymap_chooser", true);
     
    7980    protected Map<String, String> getHeaders(TileSource tileSource) {
    8081        if (tileSource instanceof TemplatedTMSTileSource) {
    81             return ((TemplatedTMSTileSource)tileSource).getHeaders();
     82            return ((TemplatedTMSTileSource) tileSource).getHeaders();
    8283        }
    8384        return null;
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r8526 r8530  
    5858            public void projectionChanged(Projection oldValue, Projection newValue) {
    5959                if (!oldValue.equals(newValue) && tileSource instanceof TemplatedWMSTileSource) {
    60                     ((TemplatedWMSTileSource)tileSource).initProjection(newValue);
     60                    ((TemplatedWMSTileSource) tileSource).initProjection(newValue);
    6161                }
    6262
     
    9696    }
    9797
    98 
    9998    @Override
    10099    protected TileSource getTileSource(ImageryInfo info) throws IllegalArgumentException {
     
    127126    }
    128127
    129 
    130128    /**
    131129     * Checks that WMS layer is a grabber-compatible one (HTML or WMS).
     
    153151    protected Map<String, String> getHeaders(TileSource tileSource) {
    154152        if (tileSource instanceof TemplatedWMSTileSource) {
    155             return ((TemplatedWMSTileSource)tileSource).getHeaders();
     153            return ((TemplatedWMSTileSource) tileSource).getHeaders();
    156154        }
    157155        return null;
  • trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java

    r8513 r8530  
    145145        activeSourcesModel = new ActiveSourcesModel(selectionModel);
    146146        tblActiveSources = new JTable(activeSourcesModel) {
    147             // some kind of hack to prevent the table from scrolling slightly to the
    148             // right when clicking on the text
     147            // some kind of hack to prevent the table from scrolling slightly to the right when clicking on the text
    149148            @Override
    150149            public void scrollRectToVisible(Rectangle aRect) {
  • trunk/src/org/openstreetmap/josm/io/WMSLayerImporter.java

    r8526 r8530  
    4141    }
    4242
    43 
    4443    @Override
    4544    public void importData(File file, ProgressMonitor progressMonitor) throws IOException, IllegalDataException {
     
    6160                double pixelPerDegree = ois.readDouble();
    6261
    63                 String name = (String)ois.readObject();
    64                 String extendedUrl = (String)ois.readObject();
     62                String name = (String) ois.readObject();
     63                String extendedUrl = (String) ois.readObject();
    6564
    6665                info = new ImageryInfo(name);
     
    6867                info.setPixelPerDegree(pixelPerDegree);
    6968                info.setTileSize(imageSize);
    70             } else if (sfv == WMSLayerExporter.CURRENT_FILE_VERSION){
     69            } else if (sfv == WMSLayerExporter.CURRENT_FILE_VERSION) {
    7170                zoomTo = (EastNorth) ois.readObject();
    7271
    7372                @SuppressWarnings("unchecked")
    7473                ImageryPreferenceEntry entry = Preferences.deserializeStruct(
    75                         (Map<String, String>)ois.readObject(),
     74                        (Map<String, String>) ois.readObject(),
    7675                        ImageryPreferenceEntry.class);
    7776                info = new ImageryInfo(entry);
  • trunk/src/org/openstreetmap/josm/io/session/ImagerySessionImporter.java

    r8526 r8530  
    4949            AbstractTileSourceLayer tsLayer = (AbstractTileSourceLayer) layer;
    5050            if (attributes.containsKey("automatic-downloading")) {
    51                 tsLayer.autoLoad = new Boolean(attributes.get("automatic-downloading")).booleanValue();
     51                tsLayer.autoLoad = Boolean.valueOf(attributes.get("automatic-downloading"));
    5252            }
    5353
    5454            if (attributes.containsKey("automatically-change-resolution")) {
    55                 tsLayer.autoZoom = new Boolean(attributes.get("automatically-change-resolution")).booleanValue();
     55                tsLayer.autoZoom = Boolean.valueOf(attributes.get("automatically-change-resolution"));
    5656            }
    5757
    5858            if (attributes.containsKey("show-errors")) {
    59                 tsLayer.showErrors = new Boolean(attributes.get("show-errors")).booleanValue();
     59                tsLayer.showErrors = Boolean.valueOf(attributes.get("show-errors"));
    6060            }
    6161        }
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSourceTest.java

    r8526 r8530  
    7777    }
    7878
    79 
    8079    private void verifyMercatorTile(TemplatedWMSTileSource source, int x, int y, int z) {
    8180        TemplatedTMSTileSource verifier = new TemplatedTMSTileSource(testImageryTMS);
     
    9796                    getTileLatLon(source, tileIndex.getXIndex() + 1, tileIndex.getYIndex() + 1, z)
    9897                    );
    99             assertTrue(location.toDisplayString() + " not within " + bbox.toString() + " for tile " + z + "/" + tileIndex.getXIndex() + "/" + tileIndex.getYIndex(),
     98            assertTrue(location.toDisplayString() + " not within " + bbox.toString() +
     99                    " for tile " + z + "/" + tileIndex.getXIndex() + "/" + tileIndex.getYIndex(),
    100100                    bbox.bounds(location));
    101101        }
     
    109109        return new LatLon(source.tileXYToLatLon(new Tile(source, x, y, z)));
    110110    }
     111
    111112    private void verifyTileSquarness(TemplatedWMSTileSource source, int x, int y, int z) {
    112113        Projection proj = Main.getProjection();
     
    116117        double x_size = Math.abs(min.getX() - max.getX());
    117118        assertEquals(x_size, y_size, 1e-05);
    118 
    119119    }
    120 
    121 
    122120
    123121    private TemplatedWMSTileSource getSource() {
Note: See TracChangeset for help on using the changeset viewer.