Changeset 8570 in josm for trunk


Ignore:
Timestamp:
2015-07-05T02:25:58+02:00 (9 years ago)
Author:
Don-vip
Message:

checkstyle

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r8569 r8570  
    110110        }
    111111
    112         private final String getTypeString() {
     112        private String getTypeString() {
    113113            return typeString;
    114114        }
     
    124124    }
    125125
    126     private class SelectLayerDialog extends ExtendedDialog {
     126    private final class SelectLayerDialog extends ExtendedDialog {
    127127        private Layer[] layers;
    128128        private JList<String> list;
     
    133133            this.list = new JList<>(getLayerNames(layers));
    134134            this.list.setPreferredSize(new Dimension(400, 400));
    135             this.list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) ;
     135            this.list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    136136            JPanel panel = new JPanel(new GridBagLayout());
    137137            panel.add(this.list, GBC.eol().fill());
     
    141141        private String[] getLayerNames(Collection<Layer> layers) {
    142142            Collection<String> ret = new ArrayList<>();
    143             for(Layer layer: layers) {
     143            for (Layer layer: layers) {
    144144                ret.add(layer.name);
    145145            }
     
    167167     * Creates a tile source based on imagery info
    168168     * @param info imagery info
    169      * @throws IOException
     169     * @throws IOException if any I/O error occurs
    170170     */
    171171    public WMTSTileSource(ImageryInfo info) throws IOException {
     
    189189        initProjection();
    190190    }
    191 
    192 
    193191
    194192    private String handleTemplate(String url) {
     
    222220            }
    223221            Document document = builder.parse(new ByteArrayInputStream(data));
    224             Node getTileOperation = getByXpath(document, "/Capabilities/OperationsMetadata/Operation[@name=\"GetTile\"]/DCP/HTTP/Get").item(0);
     222            Node getTileOperation = getByXpath(document,
     223                    "/Capabilities/OperationsMetadata/Operation[@name=\"GetTile\"]/DCP/HTTP/Get").item(0);
    225224            this.baseUrl = getStringByXpath(getTileOperation, "@href");
    226             this.transferMode = TransferMode.fromString(getStringByXpath(getTileOperation, "Constraint[@name=\"GetEncoding\"]/AllowedValues/Value"));
     225            this.transferMode = TransferMode.fromString(getStringByXpath(getTileOperation,
     226                    "Constraint[@name=\"GetEncoding\"]/AllowedValues/Value"));
    227227            NodeList layersNodeList = getByXpath(document, "/Capabilities/Contents/Layer");
    228228            Map<String, TileMatrixSet> matrixSetById = parseMatrices(getByXpath(document, "/Capabilities/Contents/TileMatrixSet"));
     
    231231        } catch (Exception e) {
    232232            Main.error(e);
    233             //Main.error(new String(data, "UTF-8"));
    234233        }
    235234        return null;
     
    242241    }
    243242
    244     private final Collection<Layer> parseLayer(NodeList nodeList, Map<String, TileMatrixSet> matrixSetById) throws XPathExpressionException {
     243    private Collection<Layer> parseLayer(NodeList nodeList, Map<String, TileMatrixSet> matrixSetById) throws XPathExpressionException {
    245244        Collection<Layer> ret = new ArrayList<>();
    246245        for (int layerId = 0; layerId < nodeList.getLength(); layerId++) {
     
    262261    }
    263262
    264     private final Map<String, TileMatrixSet> parseMatrices(NodeList nodeList) throws DOMException, XPathExpressionException {
     263    private Map<String, TileMatrixSet> parseMatrices(NodeList nodeList) throws DOMException, XPathExpressionException {
    265264        Map<String, TileMatrixSet> ret = new ConcurrentHashMap<>();
    266265        for (int matrixSetId = 0; matrixSetId < nodeList.getLength(); matrixSetId++) {
     
    292291
    293292    private static String crsToCode(String crsIdentifier) {
    294         if(crsIdentifier.startsWith("urn:ogc:def:crs:")) {
     293        if (crsIdentifier.startsWith("urn:ogc:def:crs:")) {
    295294            return crsIdentifier.replaceFirst("urn:ogc:def:crs:([^:]*):[^:]*:(.*)$", "$1:$2");
    296295        }
    297296        return crsIdentifier;
    298297    }
     298
    299299    private static String getStringByXpath(Node document, String xpathQuery) throws XPathExpressionException {
    300300        return (String) getByXpath(document, xpathQuery, XPathConstants.STRING);
     
    304304        return (NodeList) getByXpath(document, xpathQuery, XPathConstants.NODESET);
    305305    }
    306 
    307306
    308307    private static Object getByXpath(Node document, String xpathQuery, QName returnType) throws XPathExpressionException {
     
    325324    public void initProjection(Projection proj) {
    326325        this.currentTileMatrixSet = currentLayer.tileMatrixSetByCRS.get(proj.toCode());
    327         if(this.currentTileMatrixSet == null) {
     326        if (this.currentTileMatrixSet == null) {
    328327            Main.warn("Unsupported CRS selected");
    329328            // take first, maybe it will work (if user sets custom projections, codes will not match)
    330329            this.currentTileMatrixSet = currentLayer.tileMatrixSetByCRS.values().iterator().next();
    331330        }
    332         this.crsScale = getTileSize() * 0.28e-03 / proj.getMetersPerUnit() ;
     331        this.crsScale = getTileSize() * 0.28e-03 / proj.getMetersPerUnit();
    333332    }
    334333
     
    381380    /**
    382381     *
    383      * @param zoom
     382     * @param zoom zoom level
    384383     * @return TileMatrix that's working on this zoom level
    385384     */
     
    423422        throw new UnsupportedOperationException("Not implemented");
    424423    }
    425 
    426424
    427425    @Override
     
    513511    public Coordinate XYToLatLon(int x, int y, int zoom) {
    514512        TileMatrix matrix = getTileMatrix(zoom);
    515         if (matrix == null ){
     513        if (matrix == null) {
    516514            return new Coordinate(0, 0);
    517515        }
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r8568 r8570  
    3636public class CustomProjection extends AbstractProjection {
    3737
    38     private final static Map<String, Double> UNITS_TO_METERS = getUnitsToMeters();
    39     private final static double METER_PER_UNIT_DEGREE = 2 * Math.PI * 6370997 / 360;
     38    private static final Map<String, Double> UNITS_TO_METERS = getUnitsToMeters();
     39    private static final double METER_PER_UNIT_DEGREE = 2 * Math.PI * 6370997 / 360;
    4040
    4141    /**
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r8568 r8570  
    276276
    277277    private final class ShowTileInfoAction extends AbstractAction {
    278         private transient final TileHolder clickedTileHolder;
     278        private final transient TileHolder clickedTileHolder;
    279279
    280280        private ShowTileInfoAction(TileHolder clickedTileHolder) {
  • trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java

    r8568 r8570  
    8888         LatLon botLeft = mv.getLatLon(0, tileSource.getTileSize());
    8989
    90          return Math.abs((north.getLat() - south.getLat()) / ( topLeft.lat() - botLeft.lat()));
     90         return Math.abs((north.getLat() - south.getLat()) / (topLeft.lat() - botLeft.lat()));
    9191    }
    9292
     
    9595        if (!Main.isDisplayingMapView()) return 1;
    9696
    97         for(int i=getMinZoomLvl(); i <= getMaxZoomLvl(); i++) {
     97        for (int i = getMinZoomLvl(); i <= getMaxZoomLvl(); i++) {
    9898            double ret = getTileToScreenRatio(i);
    9999            if (ret < 1) {
     
    106106    @Override
    107107    public boolean isProjectionSupported(Projection proj) {
    108         return ((WMTSTileSource)tileSource).getSupportedProjections().contains(proj.toCode());
     108        return ((WMTSTileSource) tileSource).getSupportedProjections().contains(proj.toCode());
    109109    }
    110110
     
    112112    public String nameSupportedProjections() {
    113113        StringBuilder ret = new StringBuilder();
    114         for (String e: ((WMTSTileSource)tileSource).getSupportedProjections()) {
     114        for (String e: ((WMTSTileSource) tileSource).getSupportedProjections()) {
    115115            ret.append(e).append(", ");
    116116        }
     
    121121    public void projectionChanged(Projection oldValue, Projection newValue) {
    122122        super.projectionChanged(oldValue, newValue);
    123         ((WMTSTileSource)tileSource).initProjection(newValue);
     123        ((WMTSTileSource) tileSource).initProjection(newValue);
    124124    }
    125 
    126125}
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMTSLayerPanel.java

    r8568 r8570  
    2929        registerValidableComponent(rawUrl);
    3030    }
     31
    3132    @Override
    3233    protected ImageryInfo getImageryInfo() {
  • trunk/src/org/openstreetmap/josm/io/CachedFile.java

    r8568 r8570  
    500500     * @since TODO
    501501     */
    502     public static HttpURLConnection connectFollowingRedirect(URL downloadUrl, String httpAccept, Long ifModifiedSince, Map<String, String> headers)
    503             throws MalformedURLException, IOException {
     502    public static HttpURLConnection connectFollowingRedirect(URL downloadUrl, String httpAccept, Long ifModifiedSince,
     503            Map<String, String> headers) throws MalformedURLException, IOException {
    504504        CheckParameterUtil.ensureParameterNotNull(downloadUrl, "downloadUrl");
    505505        String downloadString = downloadUrl.toExternalForm();
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r8568 r8570  
    13421342     * Reads the input stream and closes the stream at the end of processing (regardless if an exception was thrown)
    13431343     *
    1344      * @param stream
     1344     * @param stream input stream
    13451345     * @return byte array of data in input stream
    1346      * @throws IOException
     1346     * @throws IOException if any I/O error occurs
    13471347     */
    13481348    public static byte[] readBytesFromStream(InputStream stream) throws IOException {
  • trunk/test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java

    r8569 r8570  
    5050        verifyMercatorTile(testSource, 0, 0, 2);
    5151        verifyMercatorTile(testSource, 1, 1, 2);
    52         for(int x = 0; x < 4; x++) {
    53             for(int y = 0; y < 4; y++) {
     52        for (int x = 0; x < 4; x++) {
     53            for (int y = 0; y < 4; y++) {
    5454                verifyMercatorTile(testSource, x, y, 3);
    5555            }
    5656        }
    57         for(int x = 0; x < 8; x++) {
    58             for(int y = 0; y < 4; y++) {
     57        for (int x = 0; x < 8; x++) {
     58            for (int y = 0; y < 4; y++) {
    5959                verifyMercatorTile(testSource, x, y, 4);
    6060            }
    6161        }
    6262
    63         verifyMercatorTile(testSource, 2<<9 - 1, 2<<8 - 1, 10);
     63        verifyMercatorTile(testSource, 2 << 9 - 1, 2 << 8 - 1, 10);
    6464
    6565        assertEquals("TileXMax", 1, testSource.getTileXMax(1));
     
    6969        assertEquals("TileXMax", 5, testSource.getTileXMax(3));
    7070        assertEquals("TileYMax", 4, testSource.getTileYMax(3));
    71 
    7271    }
    7372
     
    8786        verifyMercatorTile(testSource, 0, 0, 2, zoomOffset);
    8887        verifyMercatorTile(testSource, 1, 1, 2, zoomOffset);
    89         for(int x = 0; x < 4; x++) {
    90             for(int y = 0; y < 4; y++) {
     88        for (int x = 0; x < 4; x++) {
     89            for (int y = 0; y < 4; y++) {
    9190                verifyMercatorTile(testSource, x, y, 3, zoomOffset);
    9291            }
    9392        }
    94         for(int x = 0; x < 8; x++) {
    95             for(int y = 0; y < 4; y++) {
     93        for (int x = 0; x < 8; x++) {
     94            for (int y = 0; y < 4; y++) {
    9695                verifyMercatorTile(testSource, x, y, zoomOffset);
    9796            }
    9897        }
    9998
    100         verifyMercatorTile(testSource, 2<<9 - 1, 2<<8 - 1, zoomOffset);
     99        verifyMercatorTile(testSource, 2 << 9 - 1, 2 << 8 - 1, zoomOffset);
    101100
    102101        assertEquals("TileXMax", 1, testSource.getTileXMax(1));
     
    106105        assertEquals("TileXMax", 4, testSource.getTileXMax(3));
    107106        assertEquals("TileYMax", 4, testSource.getTileYMax(3));
    108 
    109107    }
    110108
     
    113111        Main.setProjection(Projections.getProjectionByCode("EPSG:4326"));
    114112        WMTSTileSource testSource = new WMTSTileSource(testImageryTOPO_PL);
    115         verifyTile(new LatLon(56,12), testSource, 0, 0, 1);
    116         verifyTile(new LatLon(56,12), testSource, 0, 0, 2);
     113        verifyTile(new LatLon(56, 12), testSource, 0, 0, 1);
     114        verifyTile(new LatLon(56, 12), testSource, 0, 0, 2);
    117115        verifyTile(new LatLon(51.1268639, 16.8731360), testSource, 1, 1, 2);
    118116
Note: See TracChangeset for help on using the changeset viewer.