Changeset 11891 in josm


Ignore:
Timestamp:
2017-04-13T00:03:15+02:00 (7 weeks ago)
Author:
Don-vip
Message:

see #7427 - sonar - squid:S1226 - Method parameters, caught exceptions and foreach variables should not be reassigned

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

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

    r11883 r11891  
    14441444        TileXY t1, t2;
    14451445        if (coordinateConverter.requiresReprojection()) {
    1446             Projection projCurrent = Main.getProjection();
    14471446            Projection projServer = Projections.getProjectionByCode(tileSource.getServerCRS());
    1448             bounds = new ProjectionBounds(
     1447            ProjectionBounds projBounds = new ProjectionBounds(
    14491448                    new EastNorth(coordinateConverter.shiftDisplayToServer(bounds.getMin())),
    14501449                    new EastNorth(coordinateConverter.shiftDisplayToServer(bounds.getMax())));
    1451             bounds = projServer.getEastNorthBoundsBox(bounds, projCurrent);
    1452             t1 = tileSource.projectedToTileXY(bounds.getMin().toProjected(), zoom);
    1453             t2 = tileSource.projectedToTileXY(bounds.getMax().toProjected(), zoom);
     1450            ProjectionBounds bbox = projServer.getEastNorthBoundsBox(projBounds, Main.getProjection());
     1451            t1 = tileSource.projectedToTileXY(bbox.getMin().toProjected(), zoom);
     1452            t2 = tileSource.projectedToTileXY(bbox.getMax().toProjected(), zoom);
    14541453        } else {
    14551454            IProjected topLeftUnshifted = coordinateConverter.shiftDisplayToServer(bounds.getMin());
  • trunk/src/org/openstreetmap/josm/tools/ImageWarp.java

    r11866 r11891  
    119119    }
    120120
     121    private static int clamp(int i, int max) {
     122        if (i < 0) {
     123            return 0;
     124        } else if (i >= max) {
     125            return max - 1;
     126        } else {
     127            return i;
     128        }
     129    }
     130
    121131    private static Color getColor(int x, int y, BufferedImage img) {
    122132        // border strategy: continue with the color of the outermost pixel,
    123133        // but change alpha component to fully translucent
    124         boolean transparent = false;
    125         if (x < 0) {
    126             x = 0;
    127             transparent = true;
    128         } else if (x >= img.getWidth()) {
    129             x = img.getWidth() - 1;
    130             transparent = true;
    131         }
    132         if (y < 0) {
    133             y = 0;
    134             transparent = true;
    135         } else if (y >= img.getHeight()) {
    136             y = img.getHeight() - 1;
    137             transparent = true;
    138         }
    139         Color clr = new Color(img.getRGB(x, y));
    140         if (!transparent)
     134        int a = clamp(x, img.getWidth());
     135        int b = clamp(y, img.getHeight());
     136        Color clr = new Color(img.getRGB(a, b));
     137        if (a == x && b == y)
    141138            return clr;
    142139        // keep color components, but set transparency to 0
Note: See TracChangeset for help on using the changeset viewer.