Changeset 8384 in josm for trunk/src


Ignore:
Timestamp:
2015-05-17T15:52:24+02:00 (9 years ago)
Author:
Don-vip
Message:

squid:S1244 - Floating point numbers should not be tested for equality

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

Legend:

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

    r8378 r8384  
    232232        // center. This method is ok as long as distances are short
    233233        // relative to the distance from the N or S poles.
    234         if (radius == 0) {
     234        if (Double.doubleToRawLongBits(radius) == 0) {
    235235            for (Node n : nodes) {
    236236                radius += distance(center, n.getEastNorth());
  • trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java

    r8357 r8384  
    363363            b = xM - xB;
    364364            double norm = Math.sqrt(a*a + b*b);
    365             if (norm == 0)
     365            if (Double.doubleToRawLongBits(norm) == 0)
    366366                // Nodes have same coordinates !
    367367                throw new InvalidSelection();
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r8357 r8384  
    4646import org.openstreetmap.josm.tools.Pair;
    4747import org.openstreetmap.josm.tools.Shortcut;
     48import org.openstreetmap.josm.tools.Utils;
    4849
    4950/**
     
    357358                double candidateAngle = getAngle(headNode, candidatePrevNode, prevNode);
    358359
    359                 if(mostLeft == null || candidateAngle < angle || (candidateAngle == angle && !candidateComingToHead)) {
     360                if(mostLeft == null || candidateAngle < angle || (Utils.equalsEpsilon(candidateAngle, angle) && !candidateComingToHead)) {
    360361                    // Candidate is most left
    361362                    mostLeft = candidateWay;
  • trunk/src/org/openstreetmap/josm/actions/SelectByInternalPointAction.java

    r8338 r8384  
    6161                    EastNorth en2 = Main.map.mapView.getProjection().latlon2eastNorth(bBox.getBottomRight());
    6262                    double s = Math.abs((en1.east() - en2.east()) * (en1.north() - en2.north()));
    63                     if (s == 0) s = 1e8;
     63                    if (Double.doubleToRawLongBits(s) == 0) {
     64                        s = 1e8;
     65                    }
    6466                    found.put(s, r);
    6567                }
  • trunk/src/org/openstreetmap/josm/actions/audio/AudioPlayPauseAction.java

    r6830 r8384  
    1414import org.openstreetmap.josm.tools.AudioPlayer;
    1515import org.openstreetmap.josm.tools.Shortcut;
     16import org.openstreetmap.josm.tools.Utils;
    1617
    1718/**
     
    3839                AudioPlayer.play(url);
    3940            } else if (AudioPlayer.playing()){
    40                 if (AudioPlayer.speed() != 1.0)
     41                if (!Utils.equalsEpsilon(AudioPlayer.speed(), 1.0))
    4142                    AudioPlayer.play(url, AudioPlayer.position());
    4243                else
  • trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java

    r8378 r8384  
    10051005            // In practice this will probably only happen when a way has been duplicated
    10061006
    1007             if (u == 0)
     1007            if (Double.doubleToRawLongBits(u) == 0)
    10081008                return;
    10091009
  • trunk/src/org/openstreetmap/josm/actions/mapmode/PlayHeadDragMode.java

    r8308 r8384  
    6060            dragging = true;
    6161        }
    62         if (p.distance(mousePos) == 0) return;
     62        if (Double.doubleToRawLongBits(p.distance(mousePos)) == 0) return;
    6363        playHeadMarker.drag(Main.map.mapView.getEastNorth(ev.getX(), ev.getY()));
    6464        mousePos = p;
  • trunk/src/org/openstreetmap/josm/data/ProjectionBounds.java

    r7816 r8384  
    33
    44import org.openstreetmap.josm.data.coor.EastNorth;
     5import org.openstreetmap.josm.tools.Utils;
    56
    67/**
     
    2526        this.maxNorth = max.north();
    2627    }
     28
    2729    public ProjectionBounds(EastNorth p) {
    2830        this.minEast = this.maxEast = p.east();
    2931        this.minNorth = this.maxNorth = p.north();
    3032    }
     33
    3134    public ProjectionBounds(EastNorth center, double east, double north) {
    3235        this.minEast = center.east()-east/2.0;
     
    3538        this.maxNorth = center.north()+north/2.0;
    3639    }
     40
    3741    public ProjectionBounds(double minEast, double minNorth, double maxEast, double maxNorth) {
    3842        this.minEast = minEast;
     
    4145        this.maxNorth = maxNorth;
    4246    }
    43     public void extend(EastNorth e)
    44     {
     47
     48    public void extend(EastNorth e) {
    4549        if (e.east() < minEast) {
    4650            minEast = e.east();
     
    5660        }
    5761    }
    58     public EastNorth getCenter()
    59     {
     62
     63    public EastNorth getCenter() {
    6064        return new EastNorth((minEast + maxEast) / 2.0, (minNorth + maxNorth) / 2.0);
    6165    }
    6266
    63     @Override public String toString() {
     67    @Override
     68    public String toString() {
    6469        return "ProjectionBounds["+minEast+","+minNorth+","+maxEast+","+maxNorth+"]";
    6570    }
     
    8590
    8691    public boolean hasExtend() {
    87         return minEast != maxEast || minNorth != maxNorth;
     92        return !Utils.equalsEpsilon(minEast, maxEast) || !Utils.equalsEpsilon(minNorth, maxNorth);
    8893    }
    8994}
  • trunk/src/org/openstreetmap/josm/data/coor/QuadTiling.java

    r8345 r8384  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.coor;
     3
     4import org.openstreetmap.josm.tools.Utils;
    35
    46public final class QuadTiling {
     
    6870    static long lon2x(double lon) {
    6971        long ret = (long)((lon + 180.0) * WORLD_PARTS / 360.0);
    70         if (ret == WORLD_PARTS) {
     72        if (Utils.equalsEpsilon(ret, WORLD_PARTS)) {
    7173            ret--;
    7274        }
     
    7678    static long lat2y(double lat) {
    7779        long ret = (long)((lat + 90.0) * WORLD_PARTS / 180.0);
    78         if (ret == WORLD_PARTS) {
     80        if (Utils.equalsEpsilon(ret, WORLD_PARTS)) {
    7981            ret--;
    8082        }
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java

    r8373 r8384  
    1818import org.openstreetmap.josm.data.DataSource;
    1919import org.openstreetmap.josm.data.coor.EastNorth;
     20import org.openstreetmap.josm.tools.Utils;
    2021
    2122/**
     
    211212    */
    212213    public Date[] getMinMaxTimeForAllTracks() {
    213         double min=1e100, max=-1e100, t;
     214        double min=1e100;
     215        double max=-1e100;
    214216        double now = System.currentTimeMillis()/1000.0;
    215217        for (GpxTrack trk: tracks) {
    216218            for (GpxTrackSegment seg : trk.getSegments()) {
    217219                for (WayPoint pnt : seg.getWayPoints()) {
    218                     t = pnt.time;
     220                    double t = pnt.time;
    219221                    if (t>0 && t<=now) {
    220222                        if (t>max) max=t;
     
    224226            }
    225227        }
    226         if (min==1e100 || max==-1e100) return null;
    227         return new Date[]{new Date((long) (min * 1000)), new Date((long) (max * 1000)), };
     228        if (Utils.equalsEpsilon(min,1e100) || Utils.equalsEpsilon(max,-1e100)) return new Date[0];
     229        return new Date[]{new Date((long) (min * 1000)), new Date((long) (max * 1000))};
    228230    }
    229231
     
    293295                        double C = -A * rx - B * ry;
    294296                        double RSsq = A * A + B * B;
    295                         if (RSsq == 0.0) {
     297                        if (Double.doubleToRawLongBits(RSsq) == 0) {
    296298                            continue;
    297299                        }
  • trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java

    r8365 r8384  
    948948    public String getToolbarName() {
    949949        String res = name;
    950         if(pixelPerDegree != 0.0) {
     950        if (Double.doubleToRawLongBits(pixelPerDegree) != 0) {
    951951            res += "#PPD="+pixelPerDegree;
    952952        }
     
    956956    public String getMenuName() {
    957957        String res = name;
    958         if(pixelPerDegree != 0.0) {
     958        if (Double.doubleToRawLongBits(pixelPerDegree) != 0) {
    959959            res += " ("+pixelPerDegree+")";
    960960        }
  • trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java

    r8338 r8384  
    7171        res.add(String.valueOf(dx));
    7272        res.add(String.valueOf(dy));
    73         if (this.centerX != 0 || this.centerY != 0) {
     73        if (Double.doubleToRawLongBits(centerX) != 0 || Double.doubleToRawLongBits(centerY) != 0) {
    7474            res.add(String.valueOf(centerX));
    7575            res.add(String.valueOf(centerY));
  • trunk/src/org/openstreetmap/josm/data/imagery/WmsCache.java

    r8357 r8384  
    354354    private CacheEntry findEntry(ProjectionEntries projectionEntries, double pixelPerDegree, double east, double north) {
    355355        for (CacheEntry entry: projectionEntries.entries) {
    356             if (entry.pixelPerDegree == pixelPerDegree && entry.east == east && entry.north == north)
     356            if (Utils.equalsEpsilon(entry.pixelPerDegree, pixelPerDegree)
     357                    && Utils.equalsEpsilon(entry.east, east) && Utils.equalsEpsilon(entry.north, north))
    357358                return entry;
    358359        }
  • trunk/src/org/openstreetmap/josm/data/osm/BBox.java

    r7509 r8384  
    274274        if (o instanceof BBox) {
    275275            BBox b = (BBox)o;
    276             return b.xmax == xmax && b.ymax == ymax && b.xmin == xmin && b.ymin == ymin;
     276            return Utils.equalsEpsilon(b.xmax, xmax) && Utils.equalsEpsilon(b.ymax, ymax)
     277                    && Utils.equalsEpsilon(b.xmin, xmin) && Utils.equalsEpsilon(b.ymin, ymin);
    277278        } else
    278279            return false;
     
    281282    @Override
    282283    public String toString() {
    283         return "[ x: " + xmin + " -> " + xmax +
    284         ", y: " + ymin + " -> " + ymax + " ]";
     284        return "[ x: " + xmin + " -> " + xmax + ", y: " + ymin + " -> " + ymax + " ]";
    285285    }
    286286
  • trunk/src/org/openstreetmap/josm/data/osm/NodePositionComparator.java

    r8308 r8384  
    2626            return -1;
    2727        double dLon = n1.getCoor().lon() - n2.getCoor().lon();
    28         if (dLon == 0)
     28        if (Double.doubleToRawLongBits(dLon) == 0)
    2929            return 0;
    3030        return dLon > 0 ? 1 : -1;
  • trunk/src/org/openstreetmap/josm/data/osm/Storage.java

    r8290 r8384  
    9090    private int size;
    9191    private volatile int modCount = 0;
    92     private float loadFactor = 0.6f;
     92    private double loadFactor = 0.6d;
    9393    private static final int DEFAULT_CAPACITY = 16;
    9494    private final boolean safeIterator;
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java

    r8377 r8384  
    9999    private class OffsetIterator implements Iterator<Point> {
    100100
    101         private List<Node> nodes;
    102         private float offset;
     101        private final List<Node> nodes;
     102        private final double offset;
    103103        private int idx;
    104104
     
    110110        private int xPrev0, yPrev0;
    111111
    112         public OffsetIterator(List<Node> nodes, float offset) {
     112        public OffsetIterator(List<Node> nodes, double offset) {
    113113            this.nodes = nodes;
    114114            this.offset = offset;
     
    123123        @Override
    124124        public Point next() {
    125             if (Math.abs(offset) < 0.1f) return nc.getPoint(nodes.get(idx++));
     125            if (Math.abs(offset) < 0.1d) return nc.getPoint(nodes.get(idx++));
    126126
    127127            Point current = nc.getPoint(nodes.get(idx));
     
    138138            Point next = nc.getPoint(nodes.get(idx+1));
    139139
    140             int dx_next = next.x - current.x;
    141             int dy_next = next.y - current.y;
    142             double len_next = Math.sqrt(dx_next*dx_next + dy_next*dy_next);
    143 
    144             if (len_next == 0) {
    145                 len_next = 1; // value does not matter, because dy_next and dx_next is 0
    146             }
    147 
    148             int x_current0 = current.x + (int) Math.round(offset * dy_next / len_next);
    149             int y_current0 = current.y - (int) Math.round(offset * dx_next / len_next);
     140            int dxNext = next.x - current.x;
     141            int dyNext = next.y - current.y;
     142            double lenNext = Math.sqrt(dxNext*dxNext + dyNext*dyNext);
     143
     144            if (Double.doubleToRawLongBits(lenNext) == 0) {
     145                lenNext = 1; // value does not matter, because dy_next and dx_next is 0
     146            }
     147
     148            int xCurrent0 = current.x + (int) Math.round(offset * dyNext / lenNext);
     149            int yCurrent0 = current.y - (int) Math.round(offset * dxNext / lenNext);
    150150
    151151            if (idx==0) {
    152152                ++idx;
    153153                prev = current;
    154                 xPrev0 = x_current0;
    155                 yPrev0 = y_current0;
    156                 return new Point(x_current0, y_current0);
     154                xPrev0 = xCurrent0;
     155                yPrev0 = yCurrent0;
     156                return new Point(xCurrent0, yCurrent0);
    157157            } else {
    158                 int dx_prev = current.x - prev.x;
    159                 int dy_prev = current.y - prev.y;
    160 
    161                 // determine intersection of the lines parallel to the two
    162                 // segments
    163                 int det = dx_next*dy_prev - dx_prev*dy_next;
     158                int dxPrev = current.x - prev.x;
     159                int dyPrev = current.y - prev.y;
     160
     161                // determine intersection of the lines parallel to the two segments
     162                int det = dxNext*dyPrev - dxPrev*dyNext;
    164163
    165164                if (det == 0) {
    166165                    ++idx;
    167166                    prev = current;
    168                     xPrev0 = x_current0;
    169                     yPrev0 = y_current0;
    170                     return new Point(x_current0, y_current0);
    171                 }
    172 
    173                 int m = dx_next*(y_current0 - yPrev0) - dy_next*(x_current0 - xPrev0);
    174 
    175                 int cx_ = xPrev0 + Math.round((float)m * dx_prev / det);
    176                 int cy_ = yPrev0 + Math.round((float)m * dy_prev / det);
     167                    xPrev0 = xCurrent0;
     168                    yPrev0 = yCurrent0;
     169                    return new Point(xCurrent0, yCurrent0);
     170                }
     171
     172                int m = dxNext*(yCurrent0 - yPrev0) - dyNext*(xCurrent0 - xPrev0);
     173
     174                int cx = xPrev0 + (int) Math.round((double)m * dxPrev / det);
     175                int cy = yPrev0 + (int) Math.round((double)m * dyPrev / det);
    177176                ++idx;
    178177                prev = current;
    179                 xPrev0 = x_current0;
    180                 yPrev0 = y_current0;
    181                 return new Point(cx_, cy_);
     178                xPrev0 = xCurrent0;
     179                yPrev0 = yCurrent0;
     180                return new Point(cx, cy);
    182181            }
    183182        }
     
    452451                g.setPaint(texture);
    453452                Float alpha = fillImage.getAlphaFloat();
    454                 if (alpha != 1f) {
     453                if (!Utils.equalsEpsilon(alpha, 1f)) {
    455454                    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
    456455                }
     
    602601            LineMetrics metrics = text.font.getLineMetrics(s, frc);
    603602            if (bs.vAlign == VerticalTextAlignment.ABOVE) {
    604                 y -= - box.y + metrics.getDescent();
     603                y -= -box.y + metrics.getDescent();
    605604            } else if (bs.vAlign == VerticalTextAlignment.TOP) {
    606                 y -= - box.y - metrics.getAscent();
     605                y -= -box.y - metrics.getAscent();
    607606            } else if (bs.vAlign == VerticalTextAlignment.CENTER) {
    608607                y += (metrics.getAscent() - metrics.getDescent()) / 2;
     
    623622     * @param spacing spacing between two images
    624623     * @param phase initial spacing
    625      * @param align alignment of the image. The top, center or bottom edge
    626      * can be aligned with the way.
     624     * @param align alignment of the image. The top, center or bottom edge can be aligned with the way.
    627625     */
    628     public void drawRepeatImage(Way way, MapImage pattern, boolean disabled, float offset, float spacing, float phase, LineImageAlignment align) {
     626    public void drawRepeatImage(Way way, MapImage pattern, boolean disabled, double offset, double spacing, double phase,
     627            LineImageAlignment align) {
    629628        final int imgWidth = pattern.getWidth();
    630629        final double repeat = imgWidth + spacing;
     
    744743        float alpha = img.getAlphaFloat();
    745744
    746         if (alpha != 1f) {
     745        if (!Utils.equalsEpsilon(alpha, 1f)) {
    747746            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
    748747        }
     
    999998
    1000999        double fromAngle;
    1001         if(dx == 0.0) {
     1000        if (Double.doubleToRawLongBits(dx) == 0) {
    10021001            fromAngle = Math.PI/2;
    10031002        } else {
     
    11571156                double end = longHalfSegmentEnd.get(i);
    11581157                double dist = Math.abs(0.5 * (end + start) - 0.5 * pathLength);
    1159                 if (longHalfsegmentQuality.get(i) > bestQuality || (dist < bestDistanceToCenter && longHalfsegmentQuality.get(i) == bestQuality)) {
     1158                if (longHalfsegmentQuality.get(i) > bestQuality
     1159                        || (dist < bestDistanceToCenter && Utils.equalsEpsilon(longHalfsegmentQuality.get(i), bestQuality))) {
    11601160                    bestStart = start;
    11611161                    bestEnd = end;
     
    13151315                    if (showHeadArrowOnly ? !it.hasNext() : showOrientation) {
    13161316                        final double segmentLength = p1.distance(p2);
    1317                         if (segmentLength != 0.0) {
     1317                        if (Double.doubleToRawLongBits(segmentLength) != 0) {
    13181318                            final double l =  (10. + line.getLineWidth()) / segmentLength;
    13191319
     
    13281328                    if (showOneway) {
    13291329                        final double segmentLength = p1.distance(p2);
    1330                         if (segmentLength != 0.0) {
     1330                        if (Double.doubleToRawLongBits(segmentLength) != 0) {
    13311331                            final double nx = (p2.x - p1.x) / segmentLength;
    13321332                            final double ny = (p2.y - p1.y) / segmentLength;
  • trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java

    r8346 r8384  
    342342        boolean isCentric = true;
    343343        for (Double param : towgs84Param) {
    344             if (param != 0.0) {
     344            if (Double.doubleToRawLongBits(param) != 0) {
    345345                isCentric = false;
    346346                break;
     
    351351        boolean is3Param = true;
    352352        for (int i = 3; i<towgs84Param.size(); i++) {
    353             if (towgs84Param.get(i) != 0.0) {
     353            if (Double.doubleToRawLongBits(towgs84Param.get(i)) != 0) {
    354354                is3Param = false;
    355355                break;
  • trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java

    r8378 r8384  
    5959                if (coor == null)
    6060                    return null;
    61                 if (precision==0)
     61                if (Double.doubleToRawLongBits(precision) == 0)
    6262                    return coor.getRoundedToOsmPrecision();
    6363                return roundCoord(coor);
     
    6666                if (coor == null)
    6767                    return null;
    68                 if (precision==0)
     68                if (Double.doubleToRawLongBits(precision) == 0)
    6969                    return coor.getRoundedToOsmPrecision();
    7070                return roundCoord(coor);
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r8378 r8384  
    461461        }
    462462
    463         if (!newCenter.equals(center) || (scale != newScale)) {
     463        if (!newCenter.equals(center) || !Utils.equalsEpsilon(scale, newScale)) {
    464464            if (!initial) {
    465465                pushZoomUndo(center, scale);
     
    484484            }
    485485        }
    486         if (scale != newScale) {
     486        if (!Utils.equalsEpsilon(scale, newScale)) {
    487487            double oldScale = scale;
    488488            scale = newScale;
     
    843843                    // the selected node if multiple nodes have the same
    844844                    // coordinates (e.g. after unglue)
    845                     useNtsel |= (distSq == minDistSq);
     845                    useNtsel |= Utils.equalsEpsilon(distSq, minDistSq);
    846846                }
    847                 if (ntref == null && preferredRefs != null && distSq == minDistSq) {
     847                if (ntref == null && preferredRefs != null && Utils.equalsEpsilon(distSq, minDistSq)) {
    848848                    List<OsmPrimitive> ndRefs = nd.getReferrers();
    849849                    for (OsmPrimitive ref: preferredRefs) {
  • trunk/src/org/openstreetmap/josm/gui/NotificationManager.java

    r8346 r8384  
    357357            g.setColor(getBackground());
    358358            float lineWidth = 1.4f;
    359             Shape rect = new RoundRectangle2D.Float(
    360                     lineWidth/2 + getInsets().left,
    361                     lineWidth/2 + getInsets().top,
    362                     getWidth() - lineWidth/2 - getInsets().left - getInsets().right,
    363                     getHeight() - lineWidth/2 - getInsets().top - getInsets().bottom,
     359            Shape rect = new RoundRectangle2D.Double(
     360                    lineWidth/2d + getInsets().left,
     361                    lineWidth/2d + getInsets().top,
     362                    getWidth() - lineWidth/2d - getInsets().left - getInsets().right,
     363                    getHeight() - lineWidth/2d - getInsets().top - getInsets().bottom,
    364364                    20, 20);
    365365
  • trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapBBoxChooser.java

    r8378 r8384  
    296296    @Override
    297297    public void setBoundingBox(Bounds bbox) {
    298         if (bbox == null || (bbox.getMinLat() == 0.0 && bbox.getMinLon() == 0.0
    299                 && bbox.getMaxLat() == 0.0 && bbox.getMaxLon() == 0.0)) {
     298        if (bbox == null || (Double.doubleToRawLongBits(bbox.getMinLat()) == 0 && Double.doubleToRawLongBits(bbox.getMinLon()) == 0
     299                && Double.doubleToRawLongBits(bbox.getMaxLat()) == 0 && Double.doubleToRawLongBits(bbox.getMaxLon()) == 0)) {
    300300            this.bbox = null;
    301301            iSelectionRectStart = null;
  • trunk/src/org/openstreetmap/josm/gui/history/CoordinateInfoViewer.java

    r8372 r8384  
    269269
    270270            // display the coordinates
    271             //
    272271            lblLat.setText(coord != null ? coord.latToString(CoordinateFormat.DECIMAL_DEGREES) : tr("(none)"));
    273272            lblLon.setText(coord != null ? coord.lonToString(CoordinateFormat.DECIMAL_DEGREES) : tr("(none)"));
    274273
    275274            // update background color to reflect differences in the coordinates
    276             //
    277275            if (coord == oppositeCoord ||
    278276                    (coord != null && oppositeCoord != null && coord.lat() == oppositeCoord.lat())) {
  • trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java

    r8308 r8384  
    4949import org.openstreetmap.josm.tools.GBC;
    5050import org.openstreetmap.josm.tools.ImageProvider;
     51import org.openstreetmap.josm.tools.Utils;
    5152
    5253public abstract class ImageryLayer extends Layer {
     
    143144                panel.add(new UrlLabel(url), GBC.eol().insets(2, 5, 10, 0));
    144145            }
    145             if (dx != 0.0 || dy != 0.0) {
     146            if (Double.doubleToRawLongBits(dx) != 0 || Double.doubleToRawLongBits(dy) != 0) {
    146147                panel.add(new JLabel(tr("Offset: ") + dx + ";" + dy), GBC.eol().insets(0, 5, 10, 0));
    147148            }
     
    208209            }
    209210            JCheckBoxMenuItem item = new JCheckBoxMenuItem(new ApplyOffsetAction(b));
    210             if (b.dx == dx && b.dy == dy) {
     211            if (Utils.equalsEpsilon(b.dx, dx) && Utils.equalsEpsilon(b.dy, dy)) {
    211212                item.setSelected(true);
    212213            }
  • trunk/src/org/openstreetmap/josm/gui/layer/Layer.java

    r8378 r8384  
    3131import org.openstreetmap.josm.tools.Destroyable;
    3232import org.openstreetmap.josm.tools.ImageProvider;
     33import org.openstreetmap.josm.tools.Utils;
    3334
    3435/**
     
    269270        boolean oldValue = isVisible();
    270271        this.visible  = visible;
    271         if (visible && opacity == 0) {
     272        if (visible && Double.doubleToRawLongBits(opacity) == 0) {
    272273            setOpacity(1);
    273274        } else if (oldValue != isVisible()) {
     
    281282     */
    282283    public boolean isVisible() {
    283         return visible && opacity != 0;
     284        return visible && Double.doubleToRawLongBits(opacity) != 0;
    284285    }
    285286
     
    294295        boolean oldVisible = isVisible();
    295296        this.opacity = opacity;
    296         if (oldOpacity != getOpacity()) {
     297        if (!Utils.equalsEpsilon(oldOpacity, getOpacity())) {
    297298            fireOpacityChanged(oldOpacity, getOpacity());
    298299        }
  • trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java

    r8349 r8384  
    419419        int screenPixels = mv.getWidth()*mv.getHeight();
    420420        double tilePixels = Math.abs((y2-y1)*(x2-x1)*tileSource.getTileSize()*tileSource.getTileSize());
    421         if (screenPixels == 0 || tilePixels == 0) return 1;
     421        if (screenPixels == 0 || Double.doubleToRawLongBits(tilePixels) == 0) return 1;
    422422        return screenPixels/tilePixels;
    423423    }
     
    12611261        EastNorth botRight = mv.getEastNorth(mv.getWidth(), mv.getHeight());
    12621262
    1263         if (botRight.east() == 0.0 || botRight.north() == 0) {
     1263        if (Double.doubleToRawLongBits(botRight.east()) == 0 || Double.doubleToRawLongBits(botRight.north()) == 0) {
    12641264            /*Main.debug("still initializing??");*/
    12651265            // probably still initializing
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r8345 r8384  
    6767import org.openstreetmap.josm.io.imagery.WMSRequest;
    6868import org.openstreetmap.josm.tools.ImageProvider;
     69import org.openstreetmap.josm.tools.Utils;
    6970
    7071/**
     
    327328    }
    328329
    329     @Override public void paint(Graphics2D g, final MapView mv, Bounds b) {
     330    @Override
     331    public void paint(Graphics2D g, final MapView mv, Bounds b) {
    330332        if(info.getUrl() == null || (usesInvalidUrl && !isInvalidUrlConfirmed)) return;
    331333
    332         if (autoResolutionEnabled && getBestZoom() != mv.getDist100Pixel()) {
     334        if (autoResolutionEnabled && !Utils.equalsEpsilon(getBestZoom(), mv.getDist100Pixel())) {
    333335            changeResolution(this, true);
    334336        }
     
    533535     */
    534536    private int getRequestPriority(WMSRequest request) {
    535         if (request.getPixelPerDegree() != info.getPixelPerDegree())
     537        if (!Utils.equalsEpsilon(request.getPixelPerDegree(), info.getPixelPerDegree()))
    536538            return -1;
    537539        if (bminx > request.getXIndex()
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java

    r8378 r8384  
    907907                    // parse slider position into real timezone
    908908                    double tz = Math.abs(sldTimezone.getValue());
    909                     String zone = tz % 2 == 0
     909                    String zone = Double.doubleToRawLongBits(tz % 2) == 0
    910910                    ? (int)Math.floor(tz/2) + ":00"
    911911                            : (int)Math.floor(tz/2) + ":30";
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/DateFilterPanel.java

    r8378 r8384  
    4848        final Date startTime, endTime;
    4949        Date[] bounds = layer.data.getMinMaxTimeForAllTracks();
    50         startTime = (bounds==null) ? new GregorianCalendar(2000, 1, 1).getTime():bounds[0];
    51         endTime = (bounds==null) ? new Date() : bounds[1];
     50        startTime = (bounds.length == 0) ? new GregorianCalendar(2000, 1, 1).getTime():bounds[0];
     51        endTime = (bounds.length == 0) ? new Date() : bounds[1];
    5252
    5353        dateFrom.setDate(startTime);
  • trunk/src/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelper.java

    r8378 r8384  
    280280        if (colored == ColorMode.TIME) {
    281281            Date[] bounds = data.getMinMaxTimeForAllTracks();
    282             if (bounds!=null) {
     282            if (bounds.length >= 2) {
    283283                minval = bounds[0].getTime()/1000.0;
    284284                maxval = bounds[1].getTime()/1000.0;
    285285            } else {
    286                 minval = 0; maxval=now;
     286                minval = 0;
     287                maxval = now;
    287288            }
    288289            dateScale.setRange(minval, maxval);
     
    457458                    g.setColor(customColoringTransparent);
    458459                    // hdop cirles
    459                     int hdopp = mv.getPoint(new LatLon(trkPnt.getCoor().lat(), trkPnt.getCoor().lon() + 2*6*hdop*360/40000000)).x - screen.x;
     460                    int hdopp = mv.getPoint(new LatLon(
     461                            trkPnt.getCoor().lat(),
     462                            trkPnt.getCoor().lon() + 2*6*hdop*360/40000000d)).x - screen.x;
    460463                    g.drawArc(screen.x-hdopp/2, screen.y-hdopp/2, hdopp, hdopp, 0, 360);
    461464                }
  • trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarker.java

    r8056 r8384  
    7979        int h = img.getHeight(null);
    8080        if (w>h) {
    81             h = Math.round(maxSize*((float)h/w));
     81            h = (int) Math.round(maxSize*((double)h/w));
    8282            w = maxSize;
    8383        } else {
    84             w = Math.round(maxSize*((float)w/h));
     84            w = (int) Math.round(maxSize*((double)w/h));
    8585            h = maxSize;
    8686        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/Cascade.java

    r8376 r8384  
    147147            return !(s.isEmpty() || "false".equals(s) || "no".equals(s) || "0".equals(s) || "0.0".equals(s));
    148148        if (o instanceof Number)
    149             return ((Number) o).floatValue() != 0.0f;
     149            return Float.floatToRawIntBits(((Number) o).floatValue()) != 0;
    150150        if (o instanceof List)
    151151            return !((List) o).isEmpty();
  • trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyle.java

    r8377 r8384  
    1111import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
    1212import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction.RelativeFloat;
     13import org.openstreetmap.josm.tools.Utils;
    1314
    1415public abstract class ElemStyle implements StyleKeys {
     
    208209            return false;
    209210        ElemStyle s = (ElemStyle) o;
    210         return majorZIndex == s.majorZIndex &&
    211                 zIndex == s.zIndex &&
    212                 objectZIndex == s.objectZIndex &&
    213                 isModifier == s.isModifier;
     211        return isModifier == s.isModifier &&
     212                Utils.equalsEpsilon(majorZIndex, s.majorZIndex) &&
     213                Utils.equalsEpsilon(zIndex, s.zIndex) &&
     214                Utils.equalsEpsilon(objectZIndex, s.objectZIndex);
    214215    }
    215216
  • trunk/src/org/openstreetmap/josm/gui/mappaint/LineElemStyle.java

    r8346 r8384  
    335335            Objects.equals(dashesLine, other.dashesLine) &&
    336336            Objects.equals(dashesBackground, other.dashesBackground) &&
    337             offset == other.offset &&
    338             realWidth == other.realWidth;
     337            Utils.equalsEpsilon(offset, other.offset) &&
     338            Utils.equalsEpsilon(realWidth, other.realWidth);
    339339    }
    340340
     
    356356            " realWidth=" + realWidth + " color=" + Utils.toString(color) +
    357357            " dashed=" + Arrays.toString(line.getDashArray()) +
    358             (line.getDashPhase() == 0f ? "" : " dashesOffses=" + line.getDashPhase()) +
     358            (Float.floatToRawIntBits(line.getDashPhase()) == 0 ? "" : " dashesOffses=" + line.getDashPhase()) +
    359359            " dashedColor=" + Utils.toString(dashesBackground) +
    360360            " linejoin=" + linejoinToString(line.getLineJoin()) +
    361361            " linecap=" + linecapToString(line.getEndCap()) +
    362             (offset == 0 ? "" : " offset=" + offset) +
     362            (Float.floatToRawIntBits(offset) == 0 ? "" : " offset=" + offset) +
    363363            '}';
    364364    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/RepeatImageElemStyle.java

    r8085 r8384  
    77import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
    88import org.openstreetmap.josm.tools.CheckParameterUtil;
     9import org.openstreetmap.josm.tools.Utils;
    910
    1011public class RepeatImageElemStyle extends ElemStyle implements StyleKeys {
     
    6970        final RepeatImageElemStyle other = (RepeatImageElemStyle) obj;
    7071        if (!this.pattern.equals(other.pattern)) return false;
    71         if (this.offset != other.offset) return false;
    72         if (this.spacing != other.spacing) return false;
    73         if (this.phase != other.phase) return false;
     72        if (!Utils.equalsEpsilon(this.offset, other.offset)) return false;
     73        if (!Utils.equalsEpsilon(this.spacing, other.spacing)) return false;
     74        if (!Utils.equalsEpsilon(this.phase, other.phase)) return false;
    7475        if (this.align != other.align) return false;
    7576        return true;
  • trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java

    r8342 r8384  
    1111import org.openstreetmap.josm.data.osm.Storage;
    1212import org.openstreetmap.josm.tools.Pair;
     13import org.openstreetmap.josm.tools.Utils;
    1314
    1415/**
     
    164165            ++i;
    165166        }
    166         if (bd.get(i) == lower) {
     167        if (Utils.equalsEpsilon(bd.get(i), lower)) {
    167168            if (upper > bd.get(i+1))
    168169                throw new RangeViolatedError();
     
    170171                throw new AssertionError("the new range must be within a subrange that has no data");
    171172
    172             if (bd.get(i+1) == upper) {
     173            if (Utils.equalsEpsilon(bd.get(i+1), upper)) {
    173174                //  --|-------|--------|--
    174175                //   i-1      i       i+1
     
    212213        if (bd.size() != data.size() + 1) throw new AssertionError();
    213214        if (bd.get(0) != 0) throw new AssertionError();
    214         if (bd.get(bd.size() - 1) != Double.POSITIVE_INFINITY) throw new AssertionError();
     215        if (!Utils.equalsEpsilon(bd.get(bd.size() - 1), Double.POSITIVE_INFINITY)) throw new AssertionError();
    215216        for (int i=0; i<data.size() - 1; ++i) {
    216217            if (bd.get(i) >= bd.get(i + 1)) throw new AssertionError();
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r8377 r8384  
    177177            float res = args[0];
    178178            for (int i = 1; i < args.length; ++i) {
    179                 if (args[i] == 0.0F) {
     179                if (Float.floatToRawIntBits(args[i]) == 0) {
    180180                    return null;
    181181                }
  • trunk/src/org/openstreetmap/josm/io/NmeaReader.java

    r8378 r8384  
    270270                }
    271271
    272                 if ((latLon.lat()==0.0) && (latLon.lon()==0.0)) {
     272                if (LatLon.ZERO.equals(latLon)) {
    273273                    ps.zeroCoord++;
    274274                    return false;
     
    384384                        e[GPRMC.LENGTH_EAST.position]
    385385                );
    386                 if(latLon.lat()==0.0 && latLon.lon()==0.0) {
     386                if (LatLon.ZERO.equals(latLon)) {
    387387                    ps.zeroCoord++;
    388388                    return false;
  • trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java

    r8375 r8384  
    6565            elapsed = 1;
    6666        }
    67         float uploads_per_ms = (float)progress / elapsed;
    68         float uploads_left = list_size - progress;
    69         int ms_left = (int)(uploads_left / uploads_per_ms);
    70         int minutes_left = ms_left / MSECS_PER_MINUTE;
    71         int seconds_left = (ms_left / MSECS_PER_SECOND) % SECONDS_PER_MINUTE ;
    72         String time_left_str = Integer.toString(minutes_left) + ":";
     67        double uploads_per_ms = (double)progress / elapsed;
     68        double uploads_left = list_size - progress;
     69        long ms_left = (long)(uploads_left / uploads_per_ms);
     70        long minutes_left = ms_left / MSECS_PER_MINUTE;
     71        long seconds_left = (ms_left / MSECS_PER_SECOND) % SECONDS_PER_MINUTE ;
     72        String time_left_str = Long.toString(minutes_left) + ":";
    7373        if (seconds_left < 10) {
    7474            time_left_str += "0";
    7575        }
    76         return time_left_str + Integer.toString(seconds_left);
     76        return time_left_str + Long.toString(seconds_left);
    7777    }
    7878
  • trunk/src/org/openstreetmap/josm/io/session/SessionWriter.java

    r7089 r8384  
    204204            el.setAttribute("name", layer.getName());
    205205            el.setAttribute("visible", Boolean.toString(layer.isVisible()));
    206             if (layer.getOpacity() != 1.0) {
     206            if (!Utils.equalsEpsilon(layer.getOpacity(), 1.0)) {
    207207                el.setAttribute("opacity", Double.toString(layer.getOpacity()));
    208208            }
  • trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java

    r8126 r8384  
    277277                            if (playingUrl != command.url() ||
    278278                                    stateChange != State.PAUSED ||
    279                                     offset != 0.0)
     279                                    Double.doubleToRawLongBits(offset) != 0)
    280280                            {
    281281                                if (audioInputStream != null) {
  • trunk/src/org/openstreetmap/josm/tools/GeoPropertyIndex.java

    r7596 r8384  
    164164        boolean isInside(LatLon ll) {
    165165            return bbox.getTopLeftLon() <= ll.lon() &&
    166                     (ll.lon() < bbox.getBottomRightLon() || (ll.lon() == 180.0 && bbox.getBottomRightLon() == 180.0)) &&
     166                    (ll.lon() < bbox.getBottomRightLon() ||
     167                            (Utils.equalsEpsilon(ll.lon(), 180.0) && Utils.equalsEpsilon(bbox.getBottomRightLon(), 180.0))) &&
    167168                    bbox.getBottomRightLat() <= ll.lat() &&
    168                     (ll.lat() < bbox.getTopLeftLat() || (ll.lat() == 90.0 && bbox.getTopLeftLat() == 90.0));
     169                    (ll.lat() < bbox.getTopLeftLat() ||
     170                            (Utils.equalsEpsilon(ll.lat(), 90.0) && Utils.equalsEpsilon(bbox.getTopLeftLat(), 90.0)));
    169171        }
    170172
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r8345 r8384  
    352352        // Solve the equations
    353353        double det = a1 * b2 - a2 * b1;
    354         if (det == 0)
     354        if (Double.doubleToRawLongBits(det) == 0)
    355355            return null; // Lines are parallel
    356356
     
    387387        double ldy = p2.getY() - p1.getY();
    388388
    389         if (ldx == 0 && ldy == 0) //segment zero length
     389        //segment zero length
     390        if (Double.doubleToRawLongBits(ldx) == 0 && Double.doubleToRawLongBits(ldy) == 0)
    390391            return p1;
    391392
     
    829830            b[i] = pt1.north() - pt2.north();
    830831            double d = Math.sqrt(a[i]*a[i] + b[i]*b[i]);
    831             if(d == 0) return null;
     832            if (Double.doubleToRawLongBits(d) == 0) return null;
    832833            a[i] /= d;
    833834            b[i] /= d;
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r8324 r8384  
    11801180        // convert rotatedAngle to an integer value from 0 to 360
    11811181        Long originalAngle = Math.round(rotatedAngle % 360);
    1182         if (rotatedAngle != 0 && originalAngle == 0) {
     1182        if (Double.doubleToRawLongBits(rotatedAngle) != 0 && originalAngle == 0) {
    11831183            originalAngle = 360L;
    11841184        }
     
    11971197                // convert originalAngle to a value from 0 to 90
    11981198                double angle = originalAngle % 90;
    1199                 if (originalAngle != 0.0 && angle == 0.0) {
     1199                if (originalAngle != 0 && Double.doubleToRawLongBits(angle) == 0) {
    12001200                    angle = 90.0;
    12011201                }
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r8376 r8384  
    973973        // Is it less than 1 minute ?
    974974        if (elapsedTime < MILLIS_OF_MINUTE) {
    975             return String.format("%.1f %s", elapsedTime / (float) MILLIS_OF_SECOND, tr("s"));
     975            return String.format("%.1d %s", elapsedTime / (double) MILLIS_OF_SECOND, tr("s"));
    976976        }
    977977        // Is it less than 1 hour ?
Note: See TracChangeset for help on using the changeset viewer.