Changeset 5261 in josm


Ignore:
Timestamp:
Jun 1, 2012 11:52:08 AM (13 months ago)
Author:
bastiK
Message:

applied #7739 - TMSLayer.java added some javadoc and reformatted brackets (patch by Locked)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r5017 r5261  
    6767import org.openstreetmap.josm.data.preferences.StringProperty; 
    6868import org.openstreetmap.josm.data.projection.Projection; 
     69import org.openstreetmap.josm.gui.MapFrame; 
    6970import org.openstreetmap.josm.gui.MapView; 
    7071import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 
     
    124125    HashSet<Tile> tileRequestsOutstanding = new HashSet<Tile>(); 
    125126    @Override 
    126     public synchronized void tileLoadingFinished(Tile tile, boolean success) 
    127     { 
     127    public synchronized void tileLoadingFinished(Tile tile, boolean success) { 
    128128        if (tile.hasError()) { 
    129129            success = false; 
     
    143143     
    144144    @Override 
    145     public TileCache getTileCache() 
    146     { 
     145    public TileCache getTileCache() { 
    147146        return tileCache; 
    148147    } 
     
    189188    } 
    190189 
    191     void clearTileCache(ProgressMonitor monitor) 
    192     { 
     190    /** 
     191     * Clears the tile cache. 
     192     *  
     193     * If the current tileLoader is an instance of OsmTileLoader, a new  
     194     * TmsTileClearController is created and passed to the according clearCache  
     195     * method. 
     196     *  
     197     * @param monitor  
     198     * @see MemoryTileCache#clear() 
     199     * @see OsmFileCacheTileLoader#clearCache(org.openstreetmap.gui.jmapviewer.interfaces.TileSource, org.openstreetmap.gui.jmapviewer.OsmFileCacheTileLoader.TileClearController)  
     200     */ 
     201    void clearTileCache(ProgressMonitor monitor) { 
    193202        tileCache.clear(); 
    194203        if (tileLoader instanceof OsmFileCacheTileLoader) { 
     
    217226    protected boolean showErrors; 
    218227 
    219     void redraw() 
    220     { 
     228    /** 
     229     * Initiates a repaint of Main.map 
     230     *  
     231     * @see Main#map 
     232     * @see MapFrame#repaint()  
     233     */ 
     234    void redraw() { 
    221235        needRedraw = true; 
    222236        Main.map.repaint(); 
    223237    } 
    224238 
    225     static int checkMaxZoomLvl(int maxZoomLvl, TileSource ts) 
    226     { 
     239    static int checkMaxZoomLvl(int maxZoomLvl, TileSource ts) { 
    227240        if(maxZoomLvl > MAX_ZOOM) { 
    228241            /*Main.debug("Max. zoom level should not be more than 30! Setting to 30.");*/ 
     
    239252    } 
    240253 
    241     public static int getMaxZoomLvl(TileSource ts) 
    242     { 
     254    public static int getMaxZoomLvl(TileSource ts) { 
    243255        return checkMaxZoomLvl(PROP_MAX_ZOOM_LVL.get(), ts); 
    244256    } 
     
    249261    } 
    250262 
    251     static int checkMinZoomLvl(int minZoomLvl, TileSource ts) 
    252     { 
     263    static int checkMinZoomLvl(int minZoomLvl, TileSource ts) { 
    253264        if(minZoomLvl < MIN_ZOOM) { 
    254265            /*Main.debug("Min. zoom level should not be less than "+MIN_ZOOM+"! Setting to that.");*/ 
     
    266277    } 
    267278 
    268     public static int getMinZoomLvl(TileSource ts) 
    269     { 
     279    public static int getMinZoomLvl(TileSource ts) { 
    270280        return checkMinZoomLvl(PROP_MIN_ZOOM_LVL.get(), ts); 
    271281    } 
     
    317327    } 
    318328 
     329    /** 
     330     * Creates and returns a new TileSource instance depending on the {@link ImageryType} 
     331     * of the passed ImageryInfo object. 
     332     *  
     333     * If no appropriate TileSource is found, null is returned. 
     334     * Currently supported ImageryType are {@link ImageryType#TMS},  
     335     * {@link ImageryType#BING}, {@link ImageryType#SCANEX}. 
     336     *  
     337     * @param info 
     338     * @return a new TileSource instance or null if no TileSource for the ImageryInfo/ImageryType could be found. 
     339     * @throws IllegalArgumentException  
     340     */ 
    319341    public static TileSource getTileSource(ImageryInfo info) throws IllegalArgumentException { 
    320342        if (info.getImageryType() == ImageryType.TMS) { 
     
    351373    } 
    352374 
    353     private void initTileSource(TileSource tileSource) 
    354     { 
     375    private void initTileSource(TileSource tileSource) { 
    355376        this.tileSource = tileSource; 
    356377        attribution.initialize(tileSource); 
     
    624645    } 
    625646 
    626     void zoomChanged() 
    627     { 
     647    void zoomChanged() { 
    628648        /*if (debug) { 
    629649            Main.debug("zoomChanged(): " + currentZoomLevel); 
     
    634654    } 
    635655 
    636     int getMaxZoomLvl() 
    637     { 
     656    int getMaxZoomLvl() { 
    638657        if (info.getMaxZoom() != 0) 
    639658            return checkMaxZoomLvl(info.getMaxZoom(), tileSource); 
     
    642661    } 
    643662 
    644     int getMinZoomLvl() 
    645     { 
     663    int getMinZoomLvl() { 
    646664        return getMinZoomLvl(tileSource); 
    647665    } 
     
    652670     * @return    true, if zoom increasing was successfull, false othervise 
    653671     */ 
    654     public boolean zoomIncreaseAllowed() 
    655     { 
     672    public boolean zoomIncreaseAllowed() { 
    656673        boolean zia = currentZoomLevel < this.getMaxZoomLvl(); 
    657674        /*if (debug) { 
     
    660677        return zia; 
    661678    } 
    662     public boolean increaseZoomLevel() 
    663     { 
     679     
     680    public boolean increaseZoomLevel() { 
    664681        if (zoomIncreaseAllowed()) { 
    665682            currentZoomLevel++; 
     
    676693    } 
    677694 
    678     public boolean setZoomLevel(int zoom) 
    679     { 
     695    public boolean setZoomLevel(int zoom) { 
    680696        if (zoom == currentZoomLevel) return true; 
    681697        if (zoom > this.getMaxZoomLvl()) return false; 
     
    691707     * @return    true, if zoom increasing was successfull, false othervise 
    692708     */ 
    693     public boolean zoomDecreaseAllowed() 
    694     { 
     709    public boolean zoomDecreaseAllowed() { 
    695710        return currentZoomLevel > this.getMinZoomLvl(); 
    696711    } 
     712     
    697713    public boolean decreaseZoomLevel() { 
    698714        //int minZoom = this.getMinZoomLvl(); 
     
    724740        return new Tile(tileSource, x, y, zoom); 
    725741    } 
     742     
    726743    synchronized Tile getOrCreateTile(int x, int y, int zoom) { 
    727744        Tile tile = getTile(x, y, zoom); 
     
    746763    } 
    747764 
    748     synchronized boolean loadTile(Tile tile, boolean force) 
    749     { 
     765    synchronized boolean loadTile(Tile tile, boolean force) { 
    750766        if (tile == null) 
    751767            return false; 
     
    803819        return !done; 
    804820    } 
     821     
    805822    boolean imageLoaded(Image i) { 
    806823        if (i == null) 
     
    811828        return false; 
    812829    } 
    813     Image getLoadedTileImage(Tile tile) 
    814     { 
     830     
     831    /** 
     832     * Returns the image for the given tile if both tile and image are loaded.  
     833     * Otherwise returns  null. 
     834     *  
     835     * @param tile the Tile for which the image should be returned 
     836     * @return  the image of the tile or null. 
     837     */ 
     838    Image getLoadedTileImage(Tile tile) { 
    815839        if (!tile.isLoaded()) 
    816840            return null; 
     
    821845    } 
    822846 
    823     LatLon tileLatLon(Tile t) 
    824     { 
     847    LatLon tileLatLon(Tile t) { 
    825848        int zoom = t.getZoom(); 
    826849        return new LatLon(tileSource.tileYToLat(t.getYtile(), zoom), 
     
    828851    } 
    829852 
    830     Rectangle tileToRect(Tile t1) 
    831     { 
     853    Rectangle tileToRect(Tile t1) { 
    832854        /* 
    833855         * We need to get a box in which to draw, so advance by one tile in 
     
    847869    // 'border' is the screen cordinates that need to be drawn. 
    848870    //  We must not draw outside of it. 
    849     void drawImageInside(Graphics g, Image sourceImg, Rectangle source, Rectangle border) 
    850     { 
     871    void drawImageInside(Graphics g, Image sourceImg, Rectangle source, Rectangle border) { 
    851872        Rectangle target = source; 
    852873 
     
    899920        } 
    900921    } 
     922     
    901923    // This function is called for several zoom levels, not just 
    902924    // the current one.  It should not trigger any tiles to be 
     
    10181040        return Main.map.mapView.getPoint(Main.getProjection().latlon2eastNorth(ll).add(getDx(), getDy())); 
    10191041    } 
     1042     
    10201043    private Point pixelPos(Tile t) { 
    10211044        double lon = tileSource.tileXToLon(t.getXtile(), t.getZoom()); 
     
    10231046        return pixelPos(tmpLL); 
    10241047    } 
     1048     
    10251049    private LatLon getShiftedLatLon(EastNorth en) { 
    10261050        return Main.getProjection().eastNorth2latlon(en.add(-getDx(), -getDy())); 
    10271051    } 
     1052     
    10281053    private Coordinate getShiftedCoord(EastNorth en) { 
    10291054        LatLon ll = getShiftedLatLon(en); 
     
    10801105            } 
    10811106        } 
     1107         
    10821108        boolean tooSmall() { 
    10831109            return this.tilesSpanned() < 2.1; 
    10841110        } 
     1111         
    10851112        boolean tooLarge() { 
    10861113            return this.tilesSpanned() > 10; 
    10871114        } 
     1115         
    10881116        boolean insane() { 
    10891117            return this.tilesSpanned() > 100; 
    10901118        } 
     1119         
    10911120        double tilesSpanned() { 
    10921121            return Math.sqrt(1.0 * this.size()); 
     
    11031132         * already in the tileCache. 
    11041133         */ 
    1105         List<Tile> allExistingTiles() 
    1106         { 
     1134        List<Tile> allExistingTiles() { 
    11071135            return this.__allTiles(false); 
    11081136        } 
    1109         List<Tile> allTilesCreate() 
    1110         { 
     1137         
     1138        List<Tile> allTilesCreate() { 
    11111139            return this.__allTiles(true); 
    11121140        } 
    1113         private List<Tile> __allTiles(boolean create) 
    1114         { 
     1141         
     1142        private List<Tile> __allTiles(boolean create) { 
    11151143            // Tileset is either empty or too large 
    11161144            if (zoom == 0 || this.insane()) 
     
    11321160            return ret; 
    11331161        } 
    1134         private List<Tile> allLoadedTiles() 
    1135         { 
     1162         
     1163        private List<Tile> allLoadedTiles() { 
    11361164            List<Tile> ret = new ArrayList<Tile>(); 
    11371165            for (Tile t : this.allExistingTiles()) { 
     
    11421170        } 
    11431171 
    1144         void loadAllTiles(boolean force) 
    1145         { 
     1172        void loadAllTiles(boolean force) { 
    11461173            if (!autoLoad && !force) 
    11471174                return; 
     
    11511178        } 
    11521179 
    1153         void loadAllErrorTiles(boolean force) 
    1154         { 
     1180        void loadAllErrorTiles(boolean force) { 
    11551181            if (!autoLoad && !force) 
    11561182                return; 
     
    12241250    } 
    12251251 
    1226     /** 
    1227      */ 
    12281252    @Override 
    12291253    public void paint(Graphics2D g, MapView mv, Bounds bounds) { 
Note: See TracChangeset for help on using the changeset viewer.