Package com.bbn.openmap

Examples of com.bbn.openmap.MapBean


            // Get the default MapHandler the BasicMapPanel created.
            MapHandler mapHandler = mapPanel.getMapHandler();
            mapHandler.add(frame);

            // Get the default MapBean that the BasicMapPanel created.
            MapBean mapBean = mapPanel.getMapBean();

            // Set the map's center
            mapBean.setCenter(new LatLonPoint(43.0f, -95.0f));

            // Set the map's scale 1:120 million
            mapBean.setScale(120000000f);

            /*
             * Create and add a LayerHandler to the MapHandler. The
             * LayerHandler manages Layers, whether they are part of
             * the map or not. layer.setVisible(true) will add it to
View Full Code Here


     * Invoked from the MouseWheelListener interface.
     */
    public void mouseWheelMoved(MouseWheelEvent e) {
        int rot = e.getWheelRotation();
        if (e.getSource() instanceof MapBean) {
            MapBean mb = (MapBean) e.getSource();
            if (rot > 0) {
                // Positive, zoom out
                mb.zoom(new ZoomEvent(mb, ZoomEvent.RELATIVE, 1.1f));
            } else {
                mb.zoom(new ZoomEvent(mb, ZoomEvent.RELATIVE, .9f));
            }
        }
    }
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.
                p.setScale(newScale);
                p.setCenter(center);

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

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

        mouseSupport.fireMapMouseClicked(e);

        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

        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);
            // Debug.output("Centerx: " +centerx +
            // " Centery: " + centery);
            // Debug.output("New Scale: " + newScale);
            // Debug.output("New Center: " +center);

            // 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 here so the point doesn't get rendered
            // on the repaint.
            point1 = null;
            point2 = null;

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

    public MapBean getMapBean() {
        return mapBean;
    }

    public void actionPerformed(ActionEvent ae) {
        MapBean mb = getMapBean();
        if (mb != null) {
            MapBeanPrinter.printMap(mb);
        }
    }
View Full Code Here

        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

     * disconnect from it if necessary. 
     */
    public void findAndUndo(Object someObj) {
        if (someObj instanceof com.bbn.openmap.MapBean) {
            Debug.message("projectionstack","ProjectionStack removing a MapBean.");
            MapBean map = getMapBean();
            if (map != null && map == (MapBean)someObj) {
                setMapBean(null);
            }
        }
    }
View Full Code Here

    /*
     * Contructor.
     */
    public ExampleApplet() {
        _mapBean = new MapBean();
        _toolPanel = new ToolPanel();
        _omts = new OMToolSet();
        _omts.findAndInit(_mapBean);
        _mouseDelegator = new MouseDelegator(_mapBean);

View Full Code Here

        }
        Object obj = e.getSource();
        if (!mouseSupport.fireMapMouseReleased(e)) {
            if (!(obj instanceof MapBean) || !autoZoom || point1 == null)
                return;
            MapBean map = (MapBean) obj;
            Projection projection = map.getProjection();

            synchronized (this) {
                point2 = e.getPoint();
                int dx = Math.abs(point2.x - point1.x);
                int dy = Math.abs(point2.y - point1.y);
View Full Code Here

TOP

Related Classes of com.bbn.openmap.MapBean

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.