Changeset 15041 in josm


Ignore:
Timestamp:
2019-05-03T15:27:07+02:00 (7 months ago)
Author:
Don-vip
Message:

performance - avoid to create the same EastNorth instances during mapview rendering

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

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

    r14607 r15041  
    684684        }
    685685
    686         if (getCenter() == null)
     686        EastNorth oldCenter = getCenter();
     687        if (oldCenter == null)
    687688            return false; // no data loaded yet.
    688689
     
    691692            Point l1 = getLocationOnScreen();
    692693            final EastNorth newCenter = new EastNorth(
    693                     getCenter().getX()+ (l1.x-oldLoc.x - (oldSize.width-getWidth())/2.0)*getScale(),
    694                     getCenter().getY()+ (oldLoc.y-l1.y + (oldSize.height-getHeight())/2.0)*getScale()
     694                    oldCenter.getX()+ (l1.x-oldLoc.x - (oldSize.width-getWidth())/2.0)*getScale(),
     695                    oldCenter.getY()+ (oldLoc.y-l1.y + (oldSize.height-getHeight())/2.0)*getScale()
    695696                    );
    696697            oldLoc = null; oldSize = null;
  • trunk/src/org/openstreetmap/josm/gui/MapViewState.java

    r14273 r15041  
    740740        public MapViewPoint getLineEntry(MapViewPoint start, MapViewPoint end) {
    741741            ProjectionBounds bounds = getProjectionBounds();
    742             if (bounds.contains(start.getEastNorth())) {
     742            EastNorth enStart = start.getEastNorth();
     743            if (bounds.contains(enStart)) {
    743744                return start;
    744745            }
    745746
    746             double dx = end.getEastNorth().east() - start.getEastNorth().east();
     747            EastNorth enEnd = end.getEastNorth();
     748            double dx = enEnd.east() - enStart.east();
    747749            double boundX = dx > 0 ? bounds.minEast : bounds.maxEast;
    748             EastNorth borderIntersection = Geometry.getSegmentSegmentIntersection(start.getEastNorth(), end.getEastNorth(),
     750            EastNorth borderIntersection = Geometry.getSegmentSegmentIntersection(enStart, enEnd,
    749751                    new EastNorth(boundX, bounds.minNorth),
    750752                    new EastNorth(boundX, bounds.maxNorth));
     
    753755            }
    754756
    755             double dy = end.getEastNorth().north() - start.getEastNorth().north();
     757            double dy = enEnd.north() - enStart.north();
    756758            double boundY = dy > 0 ? bounds.minNorth : bounds.maxNorth;
    757             borderIntersection = Geometry.getSegmentSegmentIntersection(start.getEastNorth(), end.getEastNorth(),
     759            borderIntersection = Geometry.getSegmentSegmentIntersection(enStart, enEnd,
    758760                    new EastNorth(bounds.minEast, boundY),
    759761                    new EastNorth(bounds.maxEast, boundY));
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r14995 r15041  
    680680        newCenter = newCenter.subtract(enShift);
    681681
    682         if (!newCenter.equals(getCenter()) || !Utils.equalsEpsilon(getScale(), newScale)) {
     682        EastNorth oldCenter = getCenter();
     683        if (!newCenter.equals(oldCenter) || !Utils.equalsEpsilon(getScale(), newScale)) {
    683684            if (!initial) {
    684                 pushZoomUndo(getCenter(), getScale());
     685                pushZoomUndo(oldCenter, getScale());
    685686            }
    686687            zoomNoUndoTo(newCenter, newScale, initial);
     
    741742        final int fps = 20;     // animation frames per second
    742743        final int speed = 1500; // milliseconds for full-screen-width pan
    743         if (!newCenter.equals(getCenter())) {
    744             final EastNorth oldCenter = getCenter();
     744        final EastNorth oldCenter = getCenter();
     745        if (!newCenter.equals(oldCenter)) {
    745746            final double distance = newCenter.distance(oldCenter) / getScale();
    746747            final double milliseconds = distance / getWidth() * speed;
Note: See TracChangeset for help on using the changeset viewer.