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


Ignore:
Timestamp:
2014-05-22T11:24:54+02:00 (10 years ago)
Author:
simon04
Message:

see #10063 - MapCSS: add min() and max() according to standard

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r7164 r7165  
    209209
    210210        /**
     211         * Returns the minimum of the given numbers, or NaN if no number is given.
     212         * @see Math#min(float, float)
     213         */
     214        public static float min(float... args) {
     215            if (args.length == 0) {
     216                return Float.NaN;
     217            } else if (args.length == 1) {
     218                return args[0];
     219            } else {
     220                float min = Math.min(args[0], args[1]);
     221                for (int i = 2; i < args.length; i++) {
     222                    min = Math.min(min, args[i]);
     223                }
     224                return min;
     225            }
     226        }
     227
     228        /**
     229         * Returns the maximum of the given numbers, or NaN if no number is given.
     230         * @see Math#max(float, float)
     231         */
     232        public static float max(float... args) {
     233            if (args.length == 0) {
     234                return Float.NaN;
     235            } else if (args.length == 1) {
     236                return args[0];
     237            } else {
     238                float max = Math.max(args[0], args[1]);
     239                for (int i = 2; i < args.length; i++) {
     240                    max = Math.max(max, args[i]);
     241                }
     242                return max;
     243            }
     244        }
     245
     246        /**
    211247         * Splits string {@code toSplit} at occurrences of the separator string {@code sep} and returns a list of matches.
    212248         * @see String#split(String)
Note: See TracChangeset for help on using the changeset viewer.