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


Ignore:
Timestamp:
2008-08-05T02:14:58+02:00 (16 years ago)
Author:
framm
Message:
  • changed AutoScaleAction to leave some margin around selected objects when zooming to selection
  • added code to support the new RemoteControl plugin
Location:
trunk/src/org/openstreetmap/josm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java

    r731 r746  
    8484                        for (OsmPrimitive osm : sel)
    8585                                osm.visit(v);
    86                         // special case to zoom nicely to one single node
    87                         if (v.min != null && v.max != null && v.min.north() == v.max.north() && v.min.east() == v.max.east()) {
    88                                 EastNorth en = Main.proj.latlon2eastNorth(new LatLon(0.001, 0.001));
    89                                 v.min = new EastNorth(v.min.east()-en.east(), v.min.north()-en.north());
    90                                 v.max = new EastNorth(v.max.east()+en.east(), v.max.north()+en.north());
    91                         }
     86                        // increase bbox by 0.001 degrees on each side. this is required
     87                        // especially if the bbox contains one single node, but helpful
     88                        // in most other cases as well.
     89                        // if (v.min != null && v.max != null && v.min.north() == v.max.north() && v.min.east() == v.max.east()) {
     90                        EastNorth en = Main.proj.latlon2eastNorth(new LatLon(0.001, 0.001));
     91                        v.min = new EastNorth(v.min.east()-en.east(), v.min.north()-en.north());
     92                        v.max = new EastNorth(v.max.east()+en.east(), v.max.north()+en.north());
    9293                }
    9394                return v;
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r726 r746  
    5858
    5959        public void download(DownloadAction action, double minlat, double minlon, double maxlat, double maxlon) {
    60     // Swap min and max if user has specified them the wrong way round
    61     // (easy to do if you are crossing 0, for example)
    62     if (minlat > maxlat) {
    63       double t = minlat; minlat = maxlat; maxlat = t;
    64     }
    65     if (minlon > maxlon) {
    66       double t = minlon; minlon = maxlon; maxlon = t;
    67     }
     60                // Swap min and max if user has specified them the wrong way round
     61                // (easy to do if you are crossing 0, for example)
     62                // FIXME should perhaps be done in download dialog?
     63                if (minlat > maxlat) {
     64                        double t = minlat; minlat = maxlat; maxlat = t;
     65                }
     66                if (minlon > maxlon) {
     67                        double t = minlon; minlon = maxlon; maxlon = t;
     68                }
    6869   
    69                 Task task = new Task(action.dialog == null || action.dialog.newLayer.isSelected(), new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon));
     70                Task task = new Task(action != null && (action.dialog == null || action.dialog.newLayer.isSelected()), new BoundingBoxDownloader(minlat, minlon, maxlat, maxlon));
    7071                Main.worker.execute(task);
    7172    }
  • trunk/src/org/openstreetmap/josm/data/Bounds.java

    r655 r746  
    11// License: GPL. Copyright 2007 by Immanuel Scholz and others
    22package org.openstreetmap.josm.data;
     3
     4import java.awt.geom.Rectangle2D;
     5import java.awt.geom.RectangularShape;
    36
    47import org.openstreetmap.josm.data.coor.LatLon;
     
    6669                return true;
    6770        }
     71       
     72        /**
     73         * Returns the lat/lon bounding box as an object of type Rectangle2D.Double
     74         * @return
     75         */
     76        public Rectangle2D.Double asRect() {
     77                return new Rectangle2D.Double(min.lon(), min.lat(), max.lon()-min.lon(), max.lat()-min.lat());
     78        }
     79
    6880}
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r655 r746  
    22package org.openstreetmap.josm.data.osm;
    33
     4import java.awt.Polygon;
     5import java.awt.Shape;
     6import java.awt.geom.Area;
    47import java.util.Arrays;
    58import java.util.Collection;
     
    204207            return ds;
    205208    }
     209       
     210        /**
     211         * Returns the total area of downloaded data (the "yellow rectangles").
     212         * @return Area object encompassing downloaded data.
     213         */
     214        public Area getDataSourceArea()
     215        {
     216                Area a = new Area();
     217                for (DataSource source : dataSources) {
     218                        // create area from data bounds
     219                        a.add(new Area(source.bounds.asRect()));
     220                }
     221                return a;
     222               
     223        }
    206224}
Note: See TracChangeset for help on using the changeset viewer.