Package com.bbn.openmap.proj

Examples of com.bbn.openmap.proj.Projection


     * @param projEvent the ProjectionEvent from the ProjectionListener method.
     * @return The new Projection if it is different from the one we already
     *         have, null if is the same as the current one.
     */
    public Projection setProjection(ProjectionEvent projEvent) {
        Projection newProjection = projEvent.getProjection();

        if (!newProjection.equals(getProjection())) {
            Projection clone = newProjection.makeClone();
            setProjection(clone);
            return clone;
        } else {
            return null;
        }
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) {
View Full Code Here

        if (!(obj instanceof MapBean) || !autoZoom || point1 == null
                || 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);

            // Don't 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
            float newScale = com.bbn.openmap.proj.ProjMath.getScale(point1,
                    point2,
                    projection);

            // Figure out the center of the rectangle
            int centerx = Math.min(point1.x, point2.x) + dx / 2;
            int centery = Math.min(point1.y, point2.y) + dy / 2;
            com.bbn.openmap.LatLonPoint center = projection.inverse(centerx,
                    centery);

            // Fire events on main map to change view to match rect1
            // Debug.output("point1: " +point1);
            // Debug.output("point2: " +point2);
View Full Code Here

     * Given a MapBean, which provides the projection, and the starting point of
     * a box (pt1), look at pt2 to see if it represents the ratio of the
     * projection map size. If it doesn't, provide a point that does.
     */
    protected Point getRatioPoint(MapBean map, Point pt1, Point pt2) {
        Projection proj = map.getProjection();
        float mapRatio = (float) proj.getHeight() / (float) proj.getWidth();

        float boxHeight = (float) (pt1.y - pt2.y);
        float boxWidth = (float) (pt1.x - pt2.x);
        float boxRatio = Math.abs(boxHeight / boxWidth);
        int isNegative = -1;
View Full Code Here

            tp.drawBackground((Graphics2D) graphics, map.getBckgrnd());

            if (layers != null) {
                for (int i = layers.length - 1; i >= 0; i--) {
                    Projection oldProj = layers[i].getProjection();
                    layers[i].renderDataForProjection(tp, graphics);
                    if (Debug.debugging("formatter")) {
                        Debug.output("AbstractImageFormatter: rendering "
                                + layers[i].getName());
                    }
                    // Need to set the old Projection object on the
                    // Layer, not the current MapBean Proj object. If
                    // you set the MapBean Proj object, make sure you
                    // clone it first. The Layer will do a check on
                    // the Projection object it has against any new
                    // ones it receives. If it has the original from
                    // the MapBean, the check it does will return a
                    // false negative, and the layer will think it
                    // doesn't have to do anything.

                    if (oldProj != null && oldProj == map.getProjection()) {
                        // Seems like a lot of users are getting
                        // burned by manually setting the same
                        // projection on the MapBean as they are on
                        // the layers, and the layers are freezing up
                        // after they are used to create an image.

                        // I don't see how this problem is manifesting
                        // itself, but this code section is an attempt
                        // to help.
                        oldProj = oldProj.makeClone();
                    }

                    layers[i].setProjection(oldProj);
                }
View Full Code Here

            this.addActionListener(this);
        }

        public void actionPerformed(ActionEvent ae) {
            if (map != null) {
                Projection proj = map.getProjection();
                LatLonPoint llp = proj.getCenter();
                new GoToButton(llp.getLatitude(), llp.getLongitude(), proj.getScale(), proj.getName());
            }
        }
View Full Code Here

            GoToMenu.this.addView(this);
        }

        public void actionPerformed(ActionEvent ae) {
            if (map != null) {
                Projection oldProj = map.getProjection();
                Class projClass = ProjectionFactory.getProjClassForName(projectionID);

                if (projClass == null) {
                    projClass = com.bbn.openmap.proj.Mercator.class;
                }

                Projection newProj = ProjectionFactory.makeProjection(projClass,
                        latitude,
                        longitude,
                        scale,
                        oldProj.getWidth(),
                        oldProj.getHeight());
View Full Code Here

            Debug.message("dted", getName()
                    + "|TerrainLayer.prepare(): aborted.");
            return null;
        }

        Projection projection = getProjection();

        if (projection == null) {
            System.err.println("Terrain Layer needs to be added to the MapBean before it can be used!");
            return new OMGraphicList();
        }
View Full Code Here

            if (!(obj instanceof MapBean) || !autoZoom || point1 == null
                    || 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.
View Full Code Here

            Debug.error(ioe.getMessage());
            return list;
        }

        // grab local
        Projection proj = getProjection();

        LatLonPoint ul = proj.getUpperLeft();
        LatLonPoint lr = proj.getLowerRight();
        float ulLat = ul.getLatitude();
        float ulLon = ul.getLongitude();
        float lrLat = lr.getLatitude();
        float lrLon = lr.getLongitude();

        // check for dateline anomaly on the screen. we check for
        // ulLon >= lrLon, but we need to be careful of the check for
        // equality because of floating point arguments...
        if (ProjMath.isCrossingDateline(ulLon, lrLon, proj.getScale())) {
            if (Debug.debugging("shape")) {
                Debug.output("ShapeLayer.computeGraphics(): Dateline is on screen");
            }

            double ymin = (double) Math.min(ulLat, lrLat);
View Full Code Here

TOP

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

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.