Ignore:
Timestamp:
2016-03-08T01:22:33+01:00 (4 years ago)
Author:
Don-vip
Message:

make MapScaler and SizeButton implement Accessible interface, add unit tests, fix checkstyle violation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r9916 r9954  
    9292    private static final char[] DEFAULT_STRIP = {'\u200B', '\uFEFF'};
    9393
     94    private static final String[] SIZE_UNITS = {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
     95
    9496    /**
    9597     * Tests whether {@code predicate} applies to at least one element from {@code collection}.
     
    10421044            throw new IllegalArgumentException("bytes must be >= 0");
    10431045        }
    1044         final String[] units = {"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
    10451046        int unitIndex = 0;
    10461047        double value = bytes;
    1047         while (value >= 1024 && unitIndex < units.length) {
     1048        while (value >= 1024 && unitIndex < SIZE_UNITS.length) {
    10481049            value /= 1024;
    10491050            unitIndex++;
    10501051        }
    10511052        if (value > 100 || unitIndex == 0) {
    1052             return String.format(locale, "%.0f %s", value, units[unitIndex]);
     1053            return String.format(locale, "%.0f %s", value, SIZE_UNITS[unitIndex]);
    10531054        } else if (value > 10) {
    1054             return String.format(locale, "%.1f %s", value, units[unitIndex]);
     1055            return String.format(locale, "%.1f %s", value, SIZE_UNITS[unitIndex]);
    10551056        } else {
    1056             return String.format(locale, "%.2f %s", value, units[unitIndex]);
     1057            return String.format(locale, "%.2f %s", value, SIZE_UNITS[unitIndex]);
    10571058        }
    10581059    }
Note: See TracChangeset for help on using the changeset viewer.