Ignore:
Timestamp:
2016-07-23T18:46:45+02:00 (8 years ago)
Author:
Don-vip
Message:

see #11390 - sonar - squid:S1604 - Java 8: Anonymous inner classes containing only one method should become lambdas

Location:
trunk/src/org/openstreetmap/josm/gui/mappaint
Files:
4 edited

Legend:

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

    r10378 r10611  
    5959    public void clearCached() {
    6060        // run in EDT to make sure this isn't called during rendering run
    61         GuiHelper.runInEDT(new Runnable() {
    62             @Override
    63             public void run() {
    64                 cacheIdx++;
    65                 preferenceCache.clear();
    66             }
     61        GuiHelper.runInEDT(() -> {
     62            cacheIdx++;
     63            preferenceCache.clear();
    6764        });
    6865    }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java

    r10567 r10611  
    365365        @Override
    366366        protected void finish() {
    367             SwingUtilities.invokeLater(new Runnable() {
    368                 @Override
    369                 public void run() {
    370                     fireMapPaintSylesUpdated();
    371                     styles.clearCached();
    372                     if (Main.isDisplayingMapView()) {
    373                         Main.map.mapView.preferenceChanged(null);
    374                         Main.map.mapView.repaint();
    375                     }
     367            SwingUtilities.invokeLater(() -> {
     368                fireMapPaintSylesUpdated();
     369                styles.clearCached();
     370                if (Main.isDisplayingMapView()) {
     371                    Main.map.mapView.preferenceChanged(null);
     372                    Main.map.mapView.repaint();
    376373                }
    377374            });
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java

    r10045 r10611  
    3939import org.openstreetmap.josm.tools.RightAndLefthandTraffic;
    4040import org.openstreetmap.josm.tools.Utils;
     41import org.openstreetmap.josm.tools.Utils.Function;
    4142
    4243/**
     
    11271128
    11281129        public Float aggregateList(List<?> lst) {
    1129             final List<Float> floats = Utils.transform(lst, new Utils.Function<Object, Float>() {
    1130                 @Override
    1131                 public Float apply(Object x) {
    1132                     return Cascade.convertTo(x, float.class);
    1133                 }
    1134             });
     1130            final List<Float> floats = Utils.transform(lst, (Function<Object, Float>) x -> Cascade.convertTo(x, float.class));
    11351131            final Collection<Float> nonNullList = Utils.filter(floats, Predicates.not(Predicates.isNull()));
    11361132            return nonNullList.isEmpty() ? (Float) Float.NaN : computeMax ? Collections.max(nonNullList) : Collections.min(nonNullList);
     
    11411137            List<?> l = Cascade.convertTo(args.get(0).evaluate(env), List.class);
    11421138            if (args.size() != 1 || l == null)
    1143                 l = Utils.transform(args, new Utils.Function<Expression, Object>() {
    1144                     @Override
    1145                     public Object apply(Expression x) {
    1146                         return x.evaluate(env);
    1147                     }
    1148                 });
     1139                l = Utils.transform(args, (Function<Expression, Object>) x -> x.evaluate(env));
    11491140            return aggregateList(l);
    11501141        }
  • trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/MapImage.java

    r10378 r10611  
    9999                .setHeight(height)
    100100                .setOptional(true)
    101                 .getInBackground(new ImageCallback() {
    102                     @Override
    103                     public void finished(ImageIcon result) {
    104                         synchronized (MapImage.this) {
    105                             if (result == null) {
    106                                 source.logWarning(tr("Failed to locate image ''{0}''", name));
    107                                 ImageIcon noIcon = MapPaintStyles.getNoIcon_Icon(source);
    108                                 img = noIcon == null ? null : (BufferedImage) noIcon.getImage();
    109                             } else {
    110                                 img = (BufferedImage) rescale(result.getImage());
    111                             }
    112                             if (temporary) {
    113                                 disabledImgCache = null;
    114                                 Main.map.mapView.preferenceChanged(null); // otherwise repaint is ignored, because layer hasn't changed
    115                                 Main.map.mapView.repaint();
    116                             }
    117                             temporary = false;
     101                .getInBackground((ImageCallback) result -> {
     102                    synchronized (MapImage.this) {
     103                        if (result == null) {
     104                            source.logWarning(tr("Failed to locate image ''{0}''", name));
     105                            ImageIcon noIcon = MapPaintStyles.getNoIcon_Icon(source);
     106                            img = noIcon == null ? null : (BufferedImage) noIcon.getImage();
     107                        } else {
     108                            img = (BufferedImage) rescale(result.getImage());
    118109                        }
     110                        if (temporary) {
     111                            disabledImgCache = null;
     112                            Main.map.mapView.preferenceChanged(null); // otherwise repaint is ignored, because layer hasn't changed
     113                            Main.map.mapView.repaint();
     114                        }
     115                        temporary = false;
    119116                    }
    120117                }
Note: See TracChangeset for help on using the changeset viewer.