Changeset 11704 in josm for trunk/src/org


Ignore:
Timestamp:
2017-03-09T00:21:54+01:00 (8 years ago)
Author:
michael2402
Message:

Use Utils.clamp instead of Math.max(Math.min()) for doubles

File:
1 edited

Legend:

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

    r11702 r11704  
    740740
    741741        // alpha value is based on zoom and line with combined with global layer alpha
    742         float theLineAlpha = Math.min(Math.max((0.50f/(float) zoomScale)/(globalLineWidth + 1), 0.01f), 0.50f) * layerAlpha;
     742        float theLineAlpha = (float) Utils.clamp((0.50 / zoomScale) / (globalLineWidth + 1), 0.01, 0.50) * layerAlpha;
    743743        final int theLineWith = (int) (lineWidth / zoomScale) + 1;
    744744
     
    11921192
    11931193        // global alpha adjustment
    1194         float lineAlpha = Math.min(Math.max((0.40f/(float) zoomScale)/(globalLineWidth+1), 0.01f), 0.40f);
     1194        float lineAlpha = (float) Utils.clamp((0.40 / zoomScale) / (globalLineWidth + 1), 0.01, 0.40);
    11951195
    11961196        // adjust 0.15 .. 1.85
     
    11981198
    11991199        // add to calculated values
    1200         float lineAlphaBPoint = Math.max(Math.min(((lineAlpha * 0.65f) * scaleAlpha), 0.90f), 0.001f);
    1201         float lineAlphaBLine = Math.max(Math.min(((lineAlpha * 1.00f) * scaleAlpha), 0.90f), 0.001f);
    1202         float lineAlphaFLine = Math.max(Math.min(((lineAlpha / 1.50f) * scaleAlpha), 0.90f), 0.001f);
     1200        float lineAlphaBPoint = (float) Utils.clamp((lineAlpha * 0.65) * scaleAlpha, 0.001, 0.90);
     1201        float lineAlphaBLine = (float) Utils.clamp((lineAlpha * 1.00) * scaleAlpha, 0.001, 0.90);
     1202        float lineAlphaFLine = (float) Utils.clamp((lineAlpha / 1.50) * scaleAlpha, 0.001, 0.90);
    12031203
    12041204        // 3rd Calculate the heat map data by draw GPX traces with alpha value ----------
Note: See TracChangeset for help on using the changeset viewer.