Ignore:
Timestamp:
2015-08-01T23:03:12+02:00 (9 years ago)
Author:
donvip
Message:

[jmapviewer] fix some findbugs issues

Location:
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java

    r31429 r31430  
    4444public class JMapViewer extends JPanel implements TileLoaderListener {
    4545
    46     public static boolean debug = false;
     46    public static final boolean DEBUG = false;
    4747
    4848    /**
    4949     * Vectors for clock-wise tile painting
    5050     */
    51     protected static final Point[] move = {new Point(1, 0), new Point(0, 1), new Point(-1, 0), new Point(0, -1)};
     51    private static final Point[] move = {new Point(1, 0), new Point(0, 1), new Point(-1, 0), new Point(0, -1)};
    5252
    5353    public static final int MAX_ZOOM = 22;
    5454    public static final int MIN_ZOOM = 0;
    5555
    56     protected List<MapMarker> mapMarkerList;
    57     protected List<MapRectangle> mapRectangleList;
    58     protected List<MapPolygon> mapPolygonList;
     56    protected transient List<MapMarker> mapMarkerList;
     57    protected transient List<MapRectangle> mapRectangleList;
     58    protected transient List<MapPolygon> mapPolygonList;
    5959
    6060    protected boolean mapMarkersVisible;
     
    6565    protected boolean scrollWrapEnabled;
    6666
    67     protected TileController tileController;
     67    protected transient TileController tileController;
    6868
    6969    /**
     
    9191    protected transient TileSource tileSource;
    9292
    93     protected AttributionSupport attribution = new AttributionSupport();
     93    protected transient AttributionSupport attribution = new AttributionSupport();
    9494
    9595    /**
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JobDispatcher.java

    r31429 r31430  
    3434    protected BlockingDeque<TileJob> jobQueue = new LinkedBlockingDeque<>();
    3535
    36     protected static int workerThreadMaxCount = 8;
     36    private static int workerThreadMaxCount = 8;
    3737
    3838    /**
     
    4242     * ignores the timeout and will never terminate itself.
    4343     */
    44     protected static int workerThreadTimeout = 30;
     44    private static int workerThreadTimeout = 30;
    4545
    4646    /**
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmMercator.java

    r31429 r31430  
    1616     * default tile size
    1717     */
    18     public static int DEFAUL_TILE_SIZE = 256;
     18    public static final int DEFAUL_TILE_SIZE = 256;
    1919    /** maximum latitude (north) for mercator display */
    2020    public static final double MAX_LAT = 85.05112877980659;
     
    128128     * @return [0..2^Zoomlevel*TILE_SIZE[
    129129     */
    130     public double LonToX(double aLongitude, int aZoomlevel) {
     130    public double lonToX(double aLongitude, int aZoomlevel) {
    131131        int mp = getMaxPixels(aZoomlevel);
    132132        double x = (mp * (aLongitude + 180L)) / 360L;
     
    151151     * @return [0..2^Zoomlevel*TILE_SIZE[
    152152     */
    153     public double LatToY(double aLat, int aZoomlevel) {
     153    public double latToY(double aLat, int aZoomlevel) {
    154154        if (aLat < MIN_LAT)
    155155            aLat = MIN_LAT;
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java

    r31429 r31430  
    144144            } catch (NumberFormatException e) {
    145145                // ignore malformed Cache-Control headers
    146                 if (JMapViewer.debug) {
     146                if (JMapViewer.DEBUG) {
    147147                    System.err.println(e.getMessage());
    148148                }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java

    r31429 r31430  
    2727     * Hourglass image that is displayed until a map tile has been loaded, except for overlay sources
    2828     */
    29     public static BufferedImage LOADING_IMAGE;
     29    public static final BufferedImage LOADING_IMAGE = loadImage("images/hourglass.png");
    3030
    3131    /**
    3232     * Red cross image that is displayed after a loading error, except for overlay sources
    3333     */
    34     public static BufferedImage ERROR_IMAGE;
    35 
    36     static {
     34    public static final BufferedImage ERROR_IMAGE = loadImage("images/error.png");
     35
     36    private static BufferedImage loadImage(String path) {
    3737        try {
    38             LOADING_IMAGE = ImageIO.read(JMapViewer.class.getResourceAsStream("images/hourglass.png"));
    39             ERROR_IMAGE = ImageIO.read(JMapViewer.class.getResourceAsStream("images/error.png"));
     38            return ImageIO.read(JMapViewer.class.getResourceAsStream(path));
    4039        } catch (Exception ex) {
    4140            ex.printStackTrace();
     41            return null;
    4242        }
    4343    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/AbstractTMSTileSource.java

    r31429 r31430  
    129129    @Override
    130130    public int lonToX(double lon, int zoom) {
    131         return (int) osmMercator.LonToX(lon, zoom);
     131        return (int) osmMercator.lonToX(lon, zoom);
    132132    }
    133133
    134134    @Override
    135135    public int latToY(double lat, int zoom) {
    136         return (int) osmMercator.LatToY(lat, zoom);
     136        return (int) osmMercator.latToY(lat, zoom);
    137137    }
    138138
     
    140140    public Point latLonToXY(double lat, double lon, int zoom) {
    141141        return new Point(
    142                 (int) osmMercator.LonToX(lon, zoom),
    143                 (int) osmMercator.LatToY(lat, zoom)
     142                (int) osmMercator.lonToX(lon, zoom),
     143                (int) osmMercator.latToY(lat, zoom)
    144144                );
    145145    }
     
    175175    @Override
    176176    public double latToTileY(double lat, int zoom) {
    177         return osmMercator.LatToY(lat, zoom) / tileSize;
     177        return osmMercator.latToY(lat, zoom) / tileSize;
    178178    }
    179179
    180180    @Override
    181181    public double lonToTileX(double lon, int zoom) {
    182         return osmMercator.LonToX(lon, zoom) / tileSize;
     182        return osmMercator.lonToX(lon, zoom) / tileSize;
    183183    }
    184184
     
    186186    public TileXY latLonToTileXY(double lat, double lon, int zoom) {
    187187        return new TileXY(
    188                 osmMercator.LonToX(lon, zoom) / tileSize,
    189                 osmMercator.LatToY(lat, zoom) / tileSize
     188                osmMercator.lonToX(lon, zoom) / tileSize,
     189                osmMercator.latToY(lat, zoom) / tileSize
    190190                );
    191191    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java

    r31429 r31430  
    196196                for (int i = 0; i < 5 && getAttribution() == null; i++) {
    197197                    // Makes sure attribution is loaded
    198                     if (JMapViewer.debug) {
     198                    if (JMapViewer.DEBUG) {
    199199                        System.out.println("Bing attribution attempt " + (i+1));
    200200                    }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TemplatedTMSTileSource.java

    r31429 r31430  
    9090        if (m.matches()) {
    9191            if (m.group(1) != null) {
    92                 finalZoom = Integer.valueOf(m.group(1))-zoom;
     92                finalZoom = Integer.parseInt(m.group(1))-zoom;
    9393            }
    9494            if (m.group(2) != null) {
     
    9696                if (ofs.startsWith("+"))
    9797                    ofs = ofs.substring(1);
    98                 finalZoom += Integer.valueOf(ofs);
     98                finalZoom += Integer.parseInt(ofs);
    9999            }
    100100        }
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TileSourceInfo.java

    r31429 r31430  
    1313public class TileSourceInfo {
    1414    /** id for this imagery entry, optional at the moment */
    15     protected String id;
     15    private final String id;
     16
    1617    /** URL of the imagery service */
    17     protected  String url = null;
     18    private final String url;
    1819
    1920    /** name of the imagery layer */
    20     protected String name;
     21    private final String name;
    2122
    2223    /** headers meaning, that there is no tile at this zoom level */
     
    4647     */
    4748    public TileSourceInfo(String name, String base_url, String id) {
    48         this(name);
     49        this.name = name;
    4950        this.url = base_url;
    5051        this.id = id;
     
    5758     */
    5859    public TileSourceInfo(String name) {
    59         this.name = name;
     60        this(name, null, null);
    6061    }
    6162
     
    6465     */
    6566    public TileSourceInfo() {
     67        this(null, null, null);
    6668    }
    6769
     
    7072     * @return name of the tile source
    7173     */
    72     public String getName() {
     74    public final String getName() {
    7375        return name;
    7476    }
     
    7880     * @return url of the tile source
    7981     */
    80     public String getUrl() {
     82    public final String getUrl() {
    8183        return url;
     84    }
     85
     86    /**
     87     * Request ID of the tile source
     88     * @return id of the tile source
     89     */
     90    public final String getId() {
     91        return id;
    8292    }
    8393
Note: See TracChangeset for help on using the changeset viewer.