Package com.bbn.openmap.proj

Examples of com.bbn.openmap.proj.Proj


                    || point2 == null)
                return;

            MapBean map = (MapBean) obj;
            Projection projection = map.getProjection();
            Proj p = (Proj) projection;

            synchronized (this) {
                point2 = getRatioPoint((MapBean) e.getSource(),
                        point1,
                        e.getPoint());
                int dx = Math.abs(point2.x - point1.x);
                int dy = Math.abs(point2.y - point1.y);

                // Dont bother redrawing if the rectangle is too small
                if ((dx < 5) || (dy < 5)) {
                    // clean up the rectangle, since point2 has the
                    // old value.
                    paintRectangle(map, point1, point2);

                    // If rectangle is too small in both x and y then
                    // recenter the map
                    if ((dx < 5) && (dy < 5)) {
                        LatLonPoint llp = projection.inverse(e.getPoint());

                        boolean shift = e.isShiftDown();
                        boolean control = e.isControlDown();

                        if (control) {
                            if (shift) {
                                p.setScale(p.getScale() * 2.0f);
                            } else {
                                p.setScale(p.getScale() / 2.0f);
                            }
                        }

                        // reset the points here so the point doesn't
                        // get rendered on the repaint.
                        point1 = null;
                        point2 = null;

                        p.setCenter(llp);
                        map.setProjection(p);
                    }
                    return;
                }

                // Figure out the new scale
                dx = Math.abs(point2.x - point1.x);
                dy = Math.abs(point2.y - point1.y);

                // cornerPoint 1 should be the upper left.
                Point cornerPoint1 = new Point(point2.x < point1.x ? point2.x
                        : point1.x, point2.y < point1.y ? point2.y : point1.y);
                Point cornerPoint2 = new Point(cornerPoint1.x + 2 * dx, cornerPoint1.y
                        + 2 * dy);

                float newScale = com.bbn.openmap.proj.ProjMath.getScale(cornerPoint1,
                        cornerPoint2,
                        projection);

                // Figure out the center of the rectangle
                com.bbn.openmap.LatLonPoint center = projection.inverse(point1.x,
                        point1.y);

                // Set the parameters of the projection and then set
                // the projection of the map. This way we save having
                // the MapBean fire two ProjectionEvents.
                p.setScale(newScale);
                p.setCenter(center);

                // reset the points so they don't show up in the
                // listener paint.
                point1 = null;
                point2 = null;
View Full Code Here


                    + projClass.getName() + ", with HEIGHT = " + height
                    + ", WIDTH = " + width + ", lat = " + latitude + ", lon = "
                    + longitude);
        }

        Proj proj = (Proj) ProjectionFactory.makeProjection(projClass,
                latitude,
                longitude,
                scale,
                width,
                height);
View Full Code Here

        if (!(obj instanceof MapBean) || point1 == null)
            return;
       
        MapBean map = (MapBean) obj;
        Projection projection = map.getProjection();
        Proj p = (Proj) projection;
       
        LatLonPoint llp = projection.inverse(e.getPoint());
       
        boolean shift = e.isShiftDown();
        boolean control = e.isControlDown();

        if (control) {
            if (shift) {
                p.setScale(p.getScale() * 2.0f);
            } else {
                p.setScale(p.getScale() / 2.0f);
            }
        }

        // reset the points here so the point doesn't get
        // rendered on the repaint.
        point1 = null;
        point2 = null;

        p.setCenter(llp);
        map.setProjection(p);
    }
View Full Code Here

     *
     * @param props LinkProperties containing map parameters.
     */
    public void updateMap(LinkProperties props) {

        Proj projection = (Proj) getProjection();
        float latitude = PropUtils.floatFromProperties(props,
                LPC_CENTER_LAT,
                projection.getCenter().getLatitude());
        float longitude = PropUtils.floatFromProperties(props,
                LPC_CENTER_LONG,
                projection.getCenter().getLongitude());
        float scale = PropUtils.floatFromProperties(props,
                LPC_SCALE,
                projection.getScale());
        int width = PropUtils.intFromProperties(props,
                LPC_WIDTH,
                projection.getWidth());
        int height = PropUtils.intFromProperties(props,
                LPC_HEIGHT,
                projection.getHeight());

        String projType = props.getProperty(LPC_PROJECTION);

        float latmin = PropUtils.floatFromProperties(props, LPC_LATMIN, -1000.f);
        float latmax = PropUtils.floatFromProperties(props, LPC_LATMAX, -1000.f);
        float lonmin = PropUtils.floatFromProperties(props, LPC_LONMIN, -1000.f);
        float lonmax = PropUtils.floatFromProperties(props, LPC_LONMAX, -1000.f);

        if (latmin >= -90.f && latmax <= 90.f && lonmin >= -180.f
                && lonmax <= 180.f && latmin <= latmax && lonmin <= lonmax) {
            // Calculate center point
            float dist = 0.5f * GreatCircle.spherical_distance(ProjMath.degToRad(latmax),
                    ProjMath.degToRad(lonmin),
                    ProjMath.degToRad(latmin),
                    ProjMath.degToRad(lonmax));
            float azimuth = GreatCircle.spherical_azimuth(ProjMath.degToRad(latmax),
                    ProjMath.degToRad(lonmin),
                    ProjMath.degToRad(latmin),
                    ProjMath.degToRad(lonmax));
            LatLonPoint center = GreatCircle.spherical_between(ProjMath.degToRad(latmax),
                    ProjMath.degToRad(lonmin),
                    dist,
                    azimuth);
            latitude = center.getLatitude();
            longitude = center.getLongitude();
        }

        MapHandler mapHandler = (MapHandler) getBeanContext();
        if (mapHandler == null) {
            Debug.message("link", "Warning...mapHandler = null");
        } else {
            MapBean mapBean = (MapBean) mapHandler.get("com.bbn.openmap.MapBean");
            if (mapBean == null) {
                Debug.message("link", "Warning...mapBean = null");
            } else {
                if (projType != null) {
                    Class projClass = ProjectionFactory.getProjClassForName(projType);
                    if (projClass == null) {
                        projClass = Mercator.class;
                    }
                    projection = (Proj) ProjectionFactory.makeProjection(projClass,
                            latitude,
                            longitude,
                            scale,
                            width,
                            height);
                } else {
                    projection = (Proj) mapBean.getProjection();
                    projection.setCenter(latitude, longitude);
                    projection.setScale(scale);
                    projection.setWidth(width);
                    projection.setHeight(height);
                }

                if (latmin >= -90.f && latmax <= 90.f && lonmin >= -180.f
                        && lonmax <= 180.f && latmin <= latmax
                        && lonmin <= lonmax) {
                    LatLonPoint upperLeft = new LatLonPoint(latmax, lonmin);
                    LatLonPoint lowerRight = new LatLonPoint(latmin, lonmax);
                    scale = ProjMath.getScale(upperLeft, lowerRight, projection);
                    projection.setScale(scale);
                    LatLonPoint ul = projection.getUpperLeft();
                    LatLonPoint lr = projection.getLowerRight();
                    float factor1 = (latmax - latmin)
                            / (ul.getLatitude() - lr.getLatitude());
                    float factor2 = (lonmax - lonmin)
                            / (lr.getLongitude() - ul.getLongitude());
                    if (factor2 > factor1)
                        factor1 = factor2;
                    if (factor1 > 1.0) {
                        scale *= factor1;
                        projection.setScale(scale);
                    }
                }

                mapBean.setProjection(projection);
            }
View Full Code Here

        addActionListener(this);
    }

    public void actionPerformed(ActionEvent ae) {
        if (map != null) {
            Proj proj = (Proj) map.getProjection();
            DataBounds bounds = provider.getDataBounds();

            if (bounds != null) {
                java.awt.geom.Point2D center = bounds.getCenter();
                if (center != null) {
                    proj.setCenter((float) center.getY(), (float) center.getX());
                    LatLonPoint llp1 = new LatLonPoint(bounds.getMax().getY(), bounds.getMin()
                            .getX());

                    LatLonPoint llp2 = new LatLonPoint(bounds.getMin().getY(), bounds.getMax()
                            .getX());

                    // 1.1 buffers the edges for viewing a little, a
                    // little zommed out.
                    proj.setScale(ProjMath.getScale(llp1, llp2, proj) * 1.1f);
                    map.setProjection(proj);
                }
            } else {
                String complaint = "Can't move map over data: "
                        + provider.getName() + " isn't ready.  Add to map?";
View Full Code Here

                if (rec != null) {
                    LatLonPoint center = new LatLonPoint(rec.getCenterY(), rec.getCenterX());
                    LatLonPoint anchor1 = new LatLonPoint(rec.getMaxY(), rec.getMinX());
                    LatLonPoint anchor2 = new LatLonPoint(rec.getMinY(), rec.getMaxX());

                    Proj proj = (Proj) mapBean.getProjection();

                    float scale = com.bbn.openmap.proj.ProjMath.getScale(anchor1,
                            anchor2,
                            proj);

                    if (logger.isLoggable(Level.FINE)) {
                        logger.info("Images cover " + anchor1 + " to "
                                + anchor2 + ", scale adjusted to " + scale);
                    }
                    proj.setCenter(center);
                    proj.setScale(scale);
                    mapBean.setProjection(proj);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.bbn.openmap.proj.Proj

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.