Ignore:
Timestamp:
2011-01-31T14:18:47+01:00 (13 years ago)
Author:
bastiK
Message:

mappaint restructuring aimed at mapcss support:

  • area- and line style of multipolygon outer & inner ways are no longer determined by MapPaintVisitor, but the information is calculated in advance and cached
  • cache is aware of zoom level
  • z_index property to allow more fancy styles in future

Performance: when the style cache is filled, painting is the same or ~5% faster. The first painting, which includes style generation, takes ~30% longer than before. (There is potential for optimization, though.) Memory usage unchanged.

File:
1 edited

Legend:

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

    r3796 r3836  
    44public class Utils {
    55
    6     public static <T> boolean exists(Iterable<? extends T> coll, Predicate<? super T> pred) {
    7         for (T el : coll) {
    8             if (pred.evaluate(el))
     6    public static <T> boolean exists(Iterable<? extends T> collection, Predicate<? super T> predicate) {
     7        for (T item : collection) {
     8            if (predicate.evaluate(item))
    99                return true;
    1010        }
    1111        return false;
     12    }
     13
     14    public static <T> boolean exists(Iterable collection, Class<? extends T> klass) {
     15        for (Object item : collection) {
     16            if (klass.isInstance(item))
     17                return true;
     18        }
     19        return false;
     20    }
     21
     22    public static <T> T find(Iterable<? extends T> collection, Predicate<? super T> predicate) {
     23        for (T item : collection) {
     24            if (predicate.evaluate(item))
     25                return item;
     26        }
     27        return null;
     28    }
     29
     30    public static <T> T find(Iterable collection, Class<? extends T> klass) {
     31        for (Object item : collection) {
     32            if (klass.isInstance(item)) {
     33                @SuppressWarnings("unchecked") T res = (T) item;
     34                return res;
     35            }
     36        }
     37        return null;
    1238    }
    1339
     
    2854    }
    2955
     56    public static int max(int a, int b, int c, int d) {
     57        return Math.max(Math.max(a, b), Math.max(c, d));
     58    }
     59
    3060    /**
    3161     * for convenience: test whether 2 objects are either both null or a.equals(b)
    3262     */
    3363    public static <T> boolean equal(T a, T b) {
    34         if (a == null && b == null)
     64        if (a == b)
    3565            return true;
    3666        return (a != null && a.equals(b));
Note: See TracChangeset for help on using the changeset viewer.