Ignore:
Timestamp:
2014-12-17T01:49:45+01:00 (9 years ago)
Author:
bastiK
Message:

fixed #10860 - set initial viewport correctly when mapview is opened

Location:
trunk/src/org/openstreetmap/josm/data
Files:
4 edited

Legend:

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

    r6830 r7816  
    8484    }
    8585
     86    public boolean hasExtend() {
     87        return minEast != maxEast || minNorth != maxNorth;
     88    }
    8689}
  • trunk/src/org/openstreetmap/josm/data/ViewportData.java

    r6992 r7816  
    55
    66/**
    7  * Simple data class that keeps map center and scale in one object.
     7 * Data class to keep viewport information.
     8 *
     9 * This can be either a combination of map center and map scale or
     10 * a rectangle in east-north coordinate space.
     11 *
     12 * Either of those will be null, so the consumer of the ViewportData
     13 * object has to check, which one is set.
     14 *
    815 * @since 5670 (creation)
    9  * @since 6992 (extraction in this package) 
     16 * @since 6992 (extraction in this package)
    1017 */
    1118public class ViewportData {
    12     private EastNorth center;
    13     private Double scale;
     19    private final EastNorth center;
     20    private final Double scale;
     21
     22    private final ProjectionBounds bounds;
    1423
    1524    /**
     
    2130        this.center = center;
    2231        this.scale = scale;
     32        this.bounds = null;
     33    }
     34
     35    public ViewportData(ProjectionBounds bounds) {
     36        this.center = null;
     37        this.scale = null;
     38        this.bounds = bounds;
    2339    }
    2440
     
    3854        return scale;
    3955    }
     56
     57    /**
     58     * Return the bounds in east-north coordinate space.
     59     * @return the bounds
     60     */
     61    public ProjectionBounds getBounds() {
     62        return bounds;
     63    }
    4064}
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r7714 r7816  
    2626import org.openstreetmap.josm.data.Data;
    2727import org.openstreetmap.josm.data.DataSource;
     28import org.openstreetmap.josm.data.ProjectionBounds;
    2829import org.openstreetmap.josm.data.SelectionChangedListener;
    2930import org.openstreetmap.josm.data.coor.EastNorth;
     
    3940import org.openstreetmap.josm.data.osm.event.TagsChangedEvent;
    4041import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent;
     42import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    4143import org.openstreetmap.josm.data.projection.Projection;
    4244import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
     
    13481350        invalidateEastNorthCache();
    13491351    }
     1352
     1353    public ProjectionBounds getDataSourceBoundingBox() {
     1354        BoundingXYVisitor bbox = new BoundingXYVisitor();
     1355        for (DataSource source : dataSources) {
     1356            bbox.visit(source.bounds);
     1357        }
     1358        if (bbox.hasExtend()) {
     1359            return bbox.getBounds();
     1360        }
     1361        return null;
     1362    }
     1363
    13501364}
  • trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java

    r7509 r7816  
    8585    }
    8686
    87     public boolean hasExtend()
    88     {
    89         return bounds != null && !bounds.getMin().equals(bounds.getMax());
     87    public boolean hasExtend() {
     88        return bounds != null && bounds.hasExtend();
    9089    }
    9190
Note: See TracChangeset for help on using the changeset viewer.