Changeset 10181 in josm for trunk/src/org/openstreetmap/josm


Ignore:
Timestamp:
2016-05-11T04:44:00+02:00 (8 years ago)
Author:
Don-vip
Message:

sonar - squid:S2184 - Math operands should be cast before assignment

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r10131 r10181  
    287287        case "download":
    288288
    289             if (lastZoomTime > 0 && System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", 10*1000)) {
     289            if (lastZoomTime > 0 && System.currentTimeMillis() - lastZoomTime > Main.pref.getLong("zoom.bounds.reset.time", 10L*1000L)) {
    290290                lastZoomTime = -1;
    291291            }
  • trunk/src/org/openstreetmap/josm/actions/JumpToAction.java

    r9062 r10181  
    187187
    188188            // 10 000 000 = 10 000 * 1000 = World * (km -> m)
    189             zm.setText(Double.toString(Math.round(10000000 * Math.pow(2, (-1) * zoomLvl))));
     189            zm.setText(Double.toString(Math.round(10000000d * Math.pow(2d, (-1d) * zoomLvl))));
    190190        }
    191191    }
  • trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java

    r9970 r10181  
    562562    private static void execCommands(List<Command> cmds, List<Node> newNodes) {
    563563        Main.main.undoRedo.add(new SequenceCommand(/* for correct i18n of plural forms - see #9110 */
    564                 trn("Dupe into {0} node", "Dupe into {0} nodes", newNodes.size() + 1, newNodes.size() + 1), cmds));
     564                trn("Dupe into {0} node", "Dupe into {0} nodes", newNodes.size() + 1L, newNodes.size() + 1L), cmds));
    565565        // select one of the new nodes
    566566        getCurrentDataSet().setSelected(newNodes.get(0));
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r10179 r10181  
    11421142        Point p2 = mv.getPoint(currentMouseEastNorth);
    11431143
    1144         double t = Math.atan2(p2.y-p1.y, p2.x-p1.x) + Math.PI;
     1144        double t = Math.atan2((double) p2.y - p1.y, (double) p2.x - p1.x) + Math.PI;
    11451145
    11461146        b.moveTo(p1.x, p1.y);
     
    14831483                if (absoluteFix) {
    14841484                    b.moveTo(p2.x, p2.y);
    1485                     b.lineTo(2*p1.x-p2.x, 2*p1.y-p2.y); // bi-directional line
     1485                    b.lineTo(2f*p1.x-p2.x, 2f*p1.y-p2.y); // bi-directional line
    14861486                } else {
    14871487                    b.moveTo(p2.x, p2.y);
  • trunk/src/org/openstreetmap/josm/data/Preferences.java

    r10063 r10181  
    9999    };
    100100
    101     private static final long MAX_AGE_DEFAULT_PREFERENCES = 60 * 60 * 24 * 50; // 50 days (in seconds)
     101    private static final long MAX_AGE_DEFAULT_PREFERENCES = 60L * 60L * 24L * 50L; // 50 days (in seconds)
    102102
    103103    /**
  • trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java

    r10134 r10181  
    2626import org.openstreetmap.josm.tools.HttpClient;
    2727import org.openstreetmap.josm.tools.Utils;
     28
     29import sun.net.www.protocol.http.HttpURLConnection;
    2830
    2931/**
     
    340342            }
    341343
    342 
    343344            attributes = parseHeaders(urlConn);
    344345
    345346            for (int i = 0; i < 5; ++i) {
    346                 if (urlConn.getResponseCode() == 503) {
    347                     Thread.sleep(5000+(new Random()).nextInt(5000));
     347                if (urlConn.getResponseCode() == HttpURLConnection.HTTP_UNAVAILABLE) {
     348                    Thread.sleep(5000L+(new Random()).nextInt(5000));
    348349                    continue;
    349350                }
     
    351352                attributes.setResponseCode(urlConn.getResponseCode());
    352353                byte[] raw;
    353                 if (urlConn.getResponseCode() == 200) {
     354                if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
    354355                    raw = Utils.readBytesFromStream(urlConn.getContent());
    355356                } else {
  • trunk/src/org/openstreetmap/josm/data/coor/LatLon.java

    r10060 r10181  
    174174        if (cDms60.equals(sSeconds)) {
    175175            sSeconds = cDms00;
    176             sMinutes = cDmsMinuteFormatter.format(tMinutes+1);
     176            sMinutes = cDmsMinuteFormatter.format(tMinutes+1L);
    177177        }
    178178        if ("60".equals(sMinutes)) {
  • trunk/src/org/openstreetmap/josm/data/coor/QuadTiling.java

    r10001 r10181  
    2525        // The question is how far we move for each bit being set.
    2626        // In the case of the top level, we move half of the world.
    27         double xUnit = X_PARTS/2;
    28         double yUnit = Y_PARTS/2;
    29         long shift = (NR_LEVELS*2)-2;
     27        double xUnit = X_PARTS/2d;
     28        double yUnit = Y_PARTS/2d;
     29        long shift = (NR_LEVELS*2L)-2L;
    3030
    3131        double x = 0;
  • trunk/src/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSource.java

    r9864 r10181  
    119119            // use well known scale set "GoogleCompatibile" from OGC WMTS spec to calculate number of tiles per zoom level
    120120            // this makes the zoom levels "glued" to standard TMS zoom levels
    121             degreesPerTile[zoom] = (SCALE_DENOMINATOR_ZOOM_LEVEL_1 / Math.pow(2, zoom - 1)) * crsScale;
     121            degreesPerTile[zoom] = (SCALE_DENOMINATOR_ZOOM_LEVEL_1 / Math.pow(2d, zoom - 1d)) * crsScale;
    122122            TileXY minTileIndex = eastNorthToTileXY(topLeft, zoom);
    123123            tileXMin[zoom] = minTileIndex.getXIndex();
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRenderer.java

    r8616 r10181  
    221221                    int x = (p.x+lastP.x)/2;
    222222                    int y = (p.y+lastP.y)/2;
    223                     path.moveTo(x-virtualNodeSize, y);
    224                     path.lineTo(x+virtualNodeSize, y);
    225                     path.moveTo(x, y-virtualNodeSize);
    226                     path.lineTo(x, y+virtualNodeSize);
     223                    path.moveTo((float) x-virtualNodeSize, y);
     224                    path.lineTo((float) x+virtualNodeSize, y);
     225                    path.moveTo(x, (float) y-virtualNodeSize);
     226                    path.lineTo(x, (float) y+virtualNodeSize);
    227227                }
    228228                lastP = p;
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/LineClip.java

    r9243 r10181  
    3939        }
    4040        return cohenSutherland(p1.x, p1.y, p2.x, p2.y, clipBounds.x, clipBounds.y,
    41                 clipBounds.x + clipBounds.width, clipBounds.y + clipBounds.height);
     41                (long) clipBounds.x + clipBounds.width,
     42                (long) clipBounds.y + clipBounds.height);
    4243    }
    4344
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r10000 r10181  
    144144            int dxNext = next.x - current.x;
    145145            int dyNext = next.y - current.y;
    146             double lenNext = Math.sqrt(dxNext*dxNext + dyNext*dyNext);
     146            double lenNext = Math.sqrt((double) dxNext*dxNext + (double) dyNext*dyNext);
    147147
    148148            if (lenNext == 0) {
     
    814814                final double segmentLength = thisP.distance(lastP);
    815815
    816                 final double dx = thisP.x - lastP.x;
    817                 final double dy = thisP.y - lastP.y;
     816                final double dx = (double) thisP.x - lastP.x;
     817                final double dy = (double) thisP.y - lastP.y;
    818818
    819819                // pos is the position from the beginning of the current segment
     
    12631263
    12641264            if (lastPoint != null) {
    1265                 dx = p.x - lastPoint.x;
    1266                 dy = p.y - lastPoint.y;
     1265                dx = (long) p.x - lastPoint.x;
     1266                dy = (long) p.y - lastPoint.y;
    12671267                double segmentLength = Math.sqrt(dx*dx + dy*dy);
    12681268                if (segmentLength > 2*(rec.getWidth()+4)) {
     
    17561756        // Can be optimized if it turns out to be slow.
    17571757        for (int i = 1; i < poly.npoints; ++i) {
    1758             dx = poly.xpoints[i] - poly.xpoints[i-1];
    1759             dy = poly.ypoints[i] - poly.ypoints[i-1];
     1758            dx = (long) poly.xpoints[i] - poly.xpoints[i-1];
     1759            dy = (long) poly.ypoints[i] - poly.ypoints[i-1];
    17601760            segLen = Math.sqrt(dx*dx + dy*dy);
    17611761            if (totalLen > curLen + segLen) {
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java

    r9243 r10181  
    432432                final double sy = l * (p1.y - p2.y);
    433433
    434                 path.lineTo(p2.x + (int) Math.round(cosPHI * sx - sinPHI * sy), p2.y + (int) Math.round(sinPHI * sx + cosPHI * sy));
    435                 path.moveTo(p2.x + (int) Math.round(cosPHI * sx + sinPHI * sy), p2.y + (int) Math.round(-sinPHI * sx + cosPHI * sy));
     434                path.lineTo(p2.x + (float) Math.round(cosPHI * sx - sinPHI * sy), p2.y + (float) Math.round(sinPHI * sx + cosPHI * sy));
     435                path.moveTo(p2.x + (float) Math.round(cosPHI * sx + sinPHI * sy), p2.y + (float) Math.round(-sinPHI * sx + cosPHI * sy));
    436436                path.lineTo(p2.x, p2.y);
    437437            }
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r10001 r10181  
    249249                if (zone == null || zone < 1 || zone > 60)
    250250                    throw new ProjectionConfigurationException(tr("Expected integer value in range 1-60 for ''+zone=...'' parameter."));
    251                 this.lon0 = 6 * zone - 183;
     251                this.lon0 = 6d * zone - 183d;
    252252                this.k0 = 0.9996;
    253253                this.x0 = 500000;
  • trunk/src/org/openstreetmap/josm/data/validation/PaintVisitor.java

    r10009 r10181  
    141141    protected void drawSegment(Point p1, Point p2, Color color) {
    142142
    143         double t = Math.atan2(p2.x - p1.x, p2.y - p1.y);
     143        double t = Math.atan2((double) p2.x - p1.x, (double) p2.y - p1.y);
    144144        double cosT = 5 * Math.cos(t);
    145145        double sinT = 5 * Math.sin(t);
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r10001 r10181  
    635635                        zoomTo(oldCenter.interpolate(finalNewCenter, (i+1) / frames));
    636636                        try {
    637                             Thread.sleep(1000 / fps);
     637                            Thread.sleep(1000L / fps);
    638638                        } catch (InterruptedException ex) {
    639639                            Main.warn("InterruptedException in "+NavigatableComponent.class.getSimpleName()+" during smooth scrolling");
  • trunk/src/org/openstreetmap/josm/gui/layer/Layer.java

    r10153 r10181  
    169169    public void hookUpMapView() {
    170170        // calculate total memory needed for all layers
    171         long memoryBytesRequired = 50 * 1024 * 1024; // assumed minimum JOSM memory footprint
     171        long memoryBytesRequired = 50L * 1024L * 1024L; // assumed minimum JOSM memory footprint
    172172        if (Main.map != null && Main.map.mapView != null) {
    173173            for (Layer layer: Main.map.mapView.getAllLayers()) {
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r10176 r10181  
    925925                    lblTimezone.setText(tr("Timezone: {0}", timezone.formatTimezone()));
    926926                    lblMinutes.setText(tr("Minutes: {0}", sldMinutes.getValue()));
    927                     lblSeconds.setText(tr("Seconds: {0}", Offset.milliseconds(100 * sldSeconds.getValue()).formatOffset()));
     927                    lblSeconds.setText(tr("Seconds: {0}", Offset.milliseconds(100L * sldSeconds.getValue()).formatOffset()));
    928928
    929929                    delta = Offset.milliseconds(100 * sldSeconds.getValue()
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r10175 r10181  
    419419                            || screen.y < oldA.y - delta || screen.y > oldA.y + delta)) {
    420420                        g.setColor(trkPnt.customColoring);
    421                         double t = Math.atan2(screen.y - old.y, screen.x - old.x) + Math.PI;
     421                        double t = Math.atan2((double) screen.y - old.y, (double) screen.x - old.x) + Math.PI;
    422422                        g.drawLine(screen.x, screen.y, (int) (screen.x + 10 * Math.cos(t - PHI)),
    423423                                (int) (screen.y + 10 * Math.sin(t - PHI)));
  • trunk/src/org/openstreetmap/josm/gui/widgets/UrlLabel.java

    r8510 r10181  
    6868        setDescription(description);
    6969        if (fontPlus != 0) {
    70             setFont(getFont().deriveFont(0, getFont().getSize()+fontPlus));
     70            setFont(getFont().deriveFont(0, (float) getFont().getSize()+fontPlus));
    7171        }
    7272        refresh();
  • trunk/src/org/openstreetmap/josm/io/CachedFile.java

    r9995 r10181  
    7676
    7777    public static final long DEFAULT_MAXTIME = -1L;
    78     public static final long DAYS = 24*60*60; // factor to get caching time in days
     78    public static final long DAYS = 24L*60L*60L; // factor to get caching time in days
    7979
    8080    private final Map<String, String> httpHeaders = new ConcurrentHashMap<>();
  • trunk/src/org/openstreetmap/josm/io/MessageNotifier.java

    r8846 r10181  
    9696            Main.info(tr("{0} not available (offline mode)", tr("Message notifier")));
    9797        } else if (!isRunning() && interval > 0 && isUserEnoughIdentified()) {
    98             task = EXECUTOR.scheduleAtFixedRate(WORKER, 0, interval * 60, TimeUnit.SECONDS);
     98            task = EXECUTOR.scheduleAtFixedRate(WORKER, 0, interval * 60L, TimeUnit.SECONDS);
    9999            Main.info("Message notifier active (checks every "+interval+" minute"+(interval > 1 ? "s" : "")+')');
    100100        }
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r10001 r10181  
    6868        }
    6969        double uploadsPerMs = (double) progress / elapsed;
    70         double uploadsLeft = listSize - progress;
     70        double uploadsLeft = (double) listSize - progress;
    7171        long msLeft = (long) (uploadsLeft / uploadsPerMs);
    7272        long minutesLeft = msLeft / MSECS_PER_MINUTE;
Note: See TracChangeset for help on using the changeset viewer.