Changeset 17459 in josm


Ignore:
Timestamp:
2021-01-14T19:18:03+01:00 (7 weeks ago)
Author:
Don-vip
Message:

fix #20363 - Extract necessary method for QuadBuckets into separate interface (patch by taylor.smock, modified)

Location:
trunk/src/org/openstreetmap/josm
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/ImageData.java

    r17081 r17459  
    1212import org.openstreetmap.josm.data.coor.LatLon;
    1313import org.openstreetmap.josm.data.gpx.GpxImageEntry;
     14import org.openstreetmap.josm.data.osm.QuadBuckets;
    1415import org.openstreetmap.josm.gui.layer.geoimage.ImageEntry;
    1516import org.openstreetmap.josm.tools.ListenerList;
     
    4243
    4344    private final ListenerList<ImageDataUpdateListener> listeners = ListenerList.create();
     45    private final QuadBuckets<ImageEntry> geoImages = new QuadBuckets<>();
    4446
    4547    /**
     
    6163            this.data = new ArrayList<>();
    6264        }
     65        this.geoImages.addAll(data);
    6366        selectedImagesIndex.add(-1);
    6467    }
     
    8689    public void mergeFrom(ImageData otherData) {
    8790        data.addAll(otherData.getImages());
     91        this.geoImages.addAll(otherData.getImages());
    8892        Collections.sort(data);
    8993
     
    154158
    155159    /**
     160     * Search for images in a bounds
     161     * @param bounds The bounds to search
     162     * @return images in the bounds
     163     * @since 17459
     164     */
     165    public Collection<ImageEntry> searchImages(Bounds bounds) {
     166        return this.geoImages.search(bounds.toBBox());
     167    }
     168
     169    /**
    156170     * Select the next image of the sequence
    157171     */
     
    266280        for (ImageEntry img: getSelectedImages()) {
    267281            data.remove(img);
     282            this.geoImages.remove(img);
    268283        }
    269284        if (selectedImagesIndex.get(0) >= data.size()) {
     
    291306    public void removeImage(ImageEntry img) {
    292307        data.remove(img);
     308        this.geoImages.remove(img);
    293309        notifyImageUpdate();
    294310    }
     
    301317    public void updateImagePosition(ImageEntry img, LatLon newPos) {
    302318        img.setPos(newPos);
     319        this.geoImages.remove(img);
     320        this.geoImages.add(img);
    303321        afterImageUpdated(img);
    304322    }
  • trunk/src/org/openstreetmap/josm/data/gpx/GpxImageEntry.java

    r15225 r17459  
    99import java.util.function.Consumer;
    1010
     11import org.openstreetmap.josm.data.IQuadBucketType;
    1112import org.openstreetmap.josm.data.coor.CachedLatLon;
    1213import org.openstreetmap.josm.data.coor.LatLon;
     14import org.openstreetmap.josm.data.osm.BBox;
    1315import org.openstreetmap.josm.tools.ExifReader;
    1416import org.openstreetmap.josm.tools.JosmRuntimeException;
     
    2931 * @since 14205 (extracted from gui.layer.geoimage.ImageEntry)
    3032 */
    31 public class GpxImageEntry implements Comparable<GpxImageEntry> {
     33public class GpxImageEntry implements Comparable<GpxImageEntry>, IQuadBucketType {
    3234    private File file;
    3335    private Integer exifOrientation;
     
    540542   }
    541543
     544    @Override
     545    public BBox getBBox() {
     546        // new BBox(LatLon) is null safe.
     547        return new BBox(this.getExifCoor());
     548    }
     549
    542550    /**
    543551     * Remove the flag that indicates new GPS data.
  • trunk/src/org/openstreetmap/josm/data/osm/IPrimitive.java

    r17333 r17459  
    66import java.util.Map;
    77
     8import org.openstreetmap.josm.data.IQuadBucketType;
    89import org.openstreetmap.josm.data.osm.visitor.PrimitiveVisitor;
    910import org.openstreetmap.josm.tools.LanguageInfo;
     
    1314 * @since 4098
    1415 */
    15 public interface IPrimitive extends Tagged, PrimitiveId, Stylable, Comparable<IPrimitive> {
     16public interface IPrimitive extends IQuadBucketType, Tagged, PrimitiveId, Stylable, Comparable<IPrimitive> {
    1617
    1718    /**
     
    446447     * @since 13764
    447448     */
     449    @Override
    448450    BBox getBBox();
    449451
  • trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java

    r17093 r17459  
    1111import java.util.stream.IntStream;
    1212
     13import org.openstreetmap.josm.data.IQuadBucketType;
    1314import org.openstreetmap.josm.data.coor.LatLon;
    1415import org.openstreetmap.josm.data.coor.QuadTiling;
     
    2021 *
    2122 * This class is (no longer) thread safe.
    22  * @param <T> type of primitives
    23  * @since 2165
     23 * @param <T> type of object extending {@link IQuadBucketType}.
     24 * @since 2165 ({@link IPrimitive} only), xxx for {@link IQuadBucketType}
    2425 */
    25 public class QuadBuckets<T extends IPrimitive> implements Collection<T> {
     26public class QuadBuckets<T extends IQuadBucketType> implements Collection<T> {
    2627    private static final boolean CONSISTENCY_TESTING = false;
    2728    private static final byte NW_INDEX = 1;
     
    3637    private static final int MAX_OBJECTS_PER_NODE = 48;
    3738
    38     static class QBLevel<T extends IPrimitive> extends BBox {
     39    static class QBLevel<T extends IQuadBucketType> extends BBox {
    3940        private final byte level;
    4041        private final byte index;
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r16970 r17459  
    3838import org.openstreetmap.josm.actions.AutoScaleAction;
    3939import org.openstreetmap.josm.actions.RenameLayerAction;
    40 import org.openstreetmap.josm.actions.mapmode.SelectLassoAction;
    4140import org.openstreetmap.josm.actions.mapmode.MapMode;
    4241import org.openstreetmap.josm.actions.mapmode.SelectAction;
     42import org.openstreetmap.josm.actions.mapmode.SelectLassoAction;
    4343import org.openstreetmap.josm.data.Bounds;
    4444import org.openstreetmap.josm.data.Data;
     
    562562                tempG.setComposite(saveComp);
    563563
    564                 for (ImageEntry e : data.getImages()) {
     564                for (ImageEntry e : data.searchImages(bounds)) {
    565565                    paintImage(e, mv, clip, tempG);
    566566                }
     
    573573            g.drawImage(offscreenBuffer, 0, 0, null);
    574574        } else {
    575             for (ImageEntry e : data.getImages()) {
     575            for (ImageEntry e : data.searchImages(bounds)) {
    576576                if (e.getPos() == null) {
    577577                    continue;
Note: See TracChangeset for help on using the changeset viewer.