Ignore:
Timestamp:
2016-07-26T21:44:16+02:00 (10 years ago)
Author:
Don-vip
Message:

fix #13210 - Start extracting coordinate conversion out of tile source (patch by michael2402, modified) - gsoc-core

File:
1 edited

Legend:

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

    r10596 r10651  
    88import java.awt.geom.Point2D;
    99import java.awt.geom.Point2D.Double;
     10import java.awt.geom.Rectangle2D;
    1011
    1112import javax.swing.JComponent;
     
    144145
    145146    /**
     147     * Gets the {@link MapViewPoint} for the given {@link LatLon} coordinate.
     148     * @param latlon the position
     149     * @return The point for that position.
     150     * @since 10651
     151     */
     152    public MapViewPoint getPointFor(LatLon latlon) {
     153        return getPointFor(getProjection().latlon2eastNorth(latlon));
     154    }
     155
     156    /**
    146157     * Gets a rectangle representing the whole view area.
    147158     * @return The rectangle.
     
    351362            return projection.eastNorth2latlon(getEastNorth());
    352363        }
     364
     365        /**
     366         * Add the given offset to this point
     367         * @param en The offset in east/north space.
     368         * @return The new point
     369         * @since 10651
     370         */
     371        public MapViewPoint add(EastNorth en) {
     372            return new MapViewEastNorthPoint(getEastNorth().add(en));
     373        }
    353374    }
    354375
     
    455476            return projection.getLatLonBoundsBox(getProjectionBounds());
    456477        }
     478
     479        /**
     480         * Gets this rectangle on the screen.
     481         * @return The rectangle.
     482         * @since 10651
     483         */
     484        public Rectangle2D getInView() {
     485            double x1 = p1.getInViewX();
     486            double y1 = p1.getInViewY();
     487            double x2 = p2.getInViewX();
     488            double y2 = p2.getInViewY();
     489            return new Rectangle2D.Double(Math.min(x1, x2), Math.min(y1, y2), Math.abs(x1 - x2), Math.abs(y1 - y2));
     490        }
    457491    }
    458492
Note: See TracChangeset for help on using the changeset viewer.