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


Ignore:
Timestamp:
2016-06-14T18:47:33+02:00 (8 years ago)
Author:
Don-vip
Message:

fix #12944 - Reduce use of addLayer(..., bounds) - patch by michael2402 - gsoc-core

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

Legend:

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

    r10340 r10371  
    7575import org.openstreetmap.josm.data.osm.OsmPrimitive;
    7676import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy;
    77 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    7877import org.openstreetmap.josm.data.projection.Projection;
    7978import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
     
    769768     */
    770769    public final void addLayer(final Layer layer) {
    771         BoundingXYVisitor v = new BoundingXYVisitor();
    772         layer.visitBoundingBox(v);
    773         addLayer(layer, v.getBounds());
     770        addLayer(layer, layer.getViewProjectionBounds());
    774771    }
    775772
  • trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java

    r10318 r10371  
    259259                final OsmDataLayer layer = createNewLayer(newLayerName);
    260260                if (Main.main != null)
    261                     Main.main.addLayer(layer, computeBbox(bounds));
     261                    Main.main.addLayer(layer);
    262262                return layer;
    263263            }
  • trunk/src/org/openstreetmap/josm/gui/layer/Layer.java

    r10364 r10371  
    2323import org.openstreetmap.josm.actions.SaveActionBase;
    2424import org.openstreetmap.josm.actions.SaveAsAction;
     25import org.openstreetmap.josm.data.ProjectionBounds;
    2526import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    2627import org.openstreetmap.josm.data.projection.Projection;
     
    593594        }
    594595    }
     596
     597    /**
     598     * Gets the {@link ProjectionBounds} for this layer to be visible to the user. This can be the exact bounds, the UI handles padding. Return
     599     * <code>null</code> if you cannot provide this information. The default implementation uses the bounds from
     600     * {@link #visitBoundingBox(BoundingXYVisitor)}.
     601     * @return The bounds for this layer.
     602     * @since 10371
     603     */
     604    public ProjectionBounds getViewProjectionBounds() {
     605        BoundingXYVisitor v = new BoundingXYVisitor();
     606        visitBoundingBox(v);
     607        return v.getBounds();
     608    }
    595609}
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r10344 r10371  
    4949import org.openstreetmap.josm.data.Bounds;
    5050import org.openstreetmap.josm.data.DataSource;
     51import org.openstreetmap.josm.data.ProjectionBounds;
    5152import org.openstreetmap.josm.data.SelectionChangedListener;
    5253import org.openstreetmap.josm.data.conflict.Conflict;
     
    10791080        return dialog;
    10801081    }
     1082
     1083    @Override
     1084    public ProjectionBounds getViewProjectionBounds() {
     1085        BoundingXYVisitor v = new BoundingXYVisitor();
     1086        v.visit(data.getDataSourceBoundingBox());
     1087        if (!v.hasExtend()) {
     1088            v.computeBoundingBox(data.getNodes());
     1089        }
     1090        return v.getBounds();
     1091    }
    10811092}
  • trunk/src/org/openstreetmap/josm/io/OsmImporter.java

    r9547 r10371  
    1515import org.openstreetmap.josm.actions.ExtensionFileFilter;
    1616import org.openstreetmap.josm.data.osm.DataSet;
    17 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    1817import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1918import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    9796            public void run() {
    9897                OsmDataLayer layer = data.getLayer();
    99                 BoundingXYVisitor v = new BoundingXYVisitor();
    100                 v.visit(layer.data.getDataSourceBoundingBox());
    101                 if (!v.hasExtend()) {
    102                     v.computeBoundingBox(layer.data.getNodes());
    103                 }
    104                 Main.main.addLayer(layer, v.getBounds());
     98                Main.main.addLayer(layer);
    10599                data.getPostLayerTask().run();
    106100                data.getLayer().onPostLoadFromFile();
Note: See TracChangeset for help on using the changeset viewer.