Ignore:
Timestamp:
2009-12-19T18:56:45+01:00 (16 years ago)
Author:
bastiK
Message:

geoimage: reworked image correlation dialog. Might still have some quirks here and there. New: displays and updates the number of matched images in the status bar while you type.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r2646 r2662  
    7979    private int currentPhoto = -1;
    8080
    81     // These are used by the auto-guess function to store the result,
    82     // so when the dialig is re-opened the users modifications don't
    83     // get overwritten
    84     public boolean hasTimeoffset = false;
    85     public long timeoffset = 0;
    86 
    8781    boolean useThumbs = false;
    8882    ThumbsLoader thumbsloader;
     83    boolean thumbsLoaded = false;
    8984    private BufferedImage offscreenBuffer;
    9085    boolean updateOffscreenBuffer = true;
    91 
    92     /*
    93      * Stores info about each image
    94      */
    95 
    96     static final class ImageEntry implements Comparable<ImageEntry> {
    97         File file;
    98         Date time;
    99         LatLon exifCoor;
    100         CachedLatLon pos;
    101         Image thumbnail;
    102         /** Speed in kilometer per second */
    103         Double speed;
    104         /** Elevation (altitude) in meters */
    105         Double elevation;
    106 
    107         public void setCoor(LatLon latlon)
    108         {
    109             pos = new CachedLatLon(latlon);
    110         }
    111         public int compareTo(ImageEntry image) {
    112             if (time != null && image.time != null)
    113                 return time.compareTo(image.time);
    114             else if (time == null && image.time == null)
    115                 return 0;
    116             else if (time == null)
    117                 return -1;
    118             else
    119                 return 1;
    120         }
    121     }
    12286
    12387    /** Loads a set of images, while displaying a dialog that indicates what the plugin is currently doing.
     
    277241                    boolean noGeotagFound = true;
    278242                    for (ImageEntry e : layer.data) {
    279                         if (e.pos != null) {
     243                        if (e.getPos() != null) {
    280244                            noGeotagFound = false;
    281245                        }
     
    344308        int i = 0;
    345309        for (ImageEntry e : data)
    346             if (e.pos != null) {
     310            if (e.getPos() != null) {
    347311                i++;
    348312            }
     
    397361    private Dimension scaledDimension(Image thumb) {
    398362        final double d = Main.map.mapView.getDist100Pixel();
    399         final double size = 40 /*meter*/;     /* size of the photo on the map */
     363        final double size = 10 /*meter*/;     /* size of the photo on the map */
    400364        double s = size * 100 /*px*/ / d;
    401365
     
    441405
    442406                for (ImageEntry e : data) {
    443                     if (e.pos == null) {
     407                    if (e.getPos() == null) {
    444408                        continue;
    445409                    }
    446                     Point p = mv.getPoint(e.pos);
     410                    Point p = mv.getPoint(e.getPos());
    447411                    if (e.thumbnail != null) {
    448412                        Dimension d = scaledDimension(e.thumbnail);
     
    464428        else {
    465429            for (ImageEntry e : data) {
    466                 if (e.pos == null) {
     430                if (e.getPos() == null) {
    467431                    continue;
    468432                }
    469                 Point p = mv.getPoint(e.pos);
     433                Point p = mv.getPoint(e.getPos());
    470434                icon.paintIcon(mv, g,
    471435                        p.x - icon.getIconWidth() / 2,
     
    477441            ImageEntry e = data.get(currentPhoto);
    478442
    479             if (e.pos != null) {
    480                 Point p = mv.getPoint(e.pos);
     443            if (e.getPos() != null) {
     444                Point p = mv.getPoint(e.getPos());
    481445
    482446                if (e.thumbnail != null) {
     
    496460    public void visitBoundingBox(BoundingXYVisitor v) {
    497461        for (ImageEntry e : data) {
    498             v.visit(e.pos);
     462            v.visit(e.getPos());
    499463        }
    500464    }
     
    549513
    550514            e.setCoor(new LatLon(lat, lon));
    551             e.exifCoor = e.pos;
     515            e.exifCoor = e.getPos();
    552516
    553517        } catch (Exception p) {
    554             e.pos = null;
     518            e.exifCoor = null;
     519            e.setPos(null);
    555520        }
    556521    }
     
    614579                    new String[] {tr("Cancel"), tr("Delete")})
    615580                .setButtonIcons(new String[] {"cancel.png", "dialogs/delete.png"})
    616                 .setContent(new JLabel(tr("<html><h3>Delete the file {0}  from the disk?<p>The image file will be permanently lost!"
     581                .setContent(new JLabel(tr("<html><h3>Delete the file {0}  from disk?<p>The image file will be permanently lost!"
    617582                    ,toDelete.file.getName()), ImageProvider.get("dialogs/geoimage/deletefromdisk"),SwingConstants.LEFT))
    618583                .toggleEnable("geoimage.deleteimagefromdisk")
     
    674639                for (int i = data.size() - 1; i >= 0; --i) {
    675640                    ImageEntry e = data.get(i);
    676                     if (e.pos == null) {
     641                    if (e.getPos() == null) {
    677642                        continue;
    678643                    }
    679                     Point p = Main.map.mapView.getPoint(e.pos);
     644                    Point p = Main.map.mapView.getPoint(e.getPos());
    680645                    Rectangle r;
    681646                    if (e.thumbnail != null) {
     
    744709        }
    745710    }
     711   
     712    public void loadThumbs() {   
     713        if (useThumbs && !thumbsLoaded) {
     714            thumbsLoaded = true;
     715            thumbsloader = new ThumbsLoader(this);
     716            Thread t = new Thread(thumbsloader);
     717            t.setPriority(Thread.MIN_PRIORITY);
     718            t.start();
     719        }
     720    }
     721   
     722    public void updateBufferAndRepaint() {
     723        updateOffscreenBuffer = true;
     724        Main.map.mapView.repaint();
     725    }
    746726}
Note: See TracChangeset for help on using the changeset viewer.