Package com.bbn.openmap

Examples of com.bbn.openmap.MapHandler


            }
        });

        System.out.println("Creating MapHandler");
        // Create the BeanContext, known as the MapHandler.
        MapHandler mapHandler = new MapHandler();
        System.out.println("Creating MapBean");
        // Create a MapBean, and add it to the MapHandler.
        MapBean map = new MapBean();

        // Set the map's center property...
        map.setCenter(new LatLonPoint(43.0f, -95.0f));
        // and scale
        map.setScale(80000000f);

        mapHandler.add(map);
        // Add the map to the JFrame
        getContentPane().add(map, BorderLayout.CENTER);

        System.out.println("Adding MouseEvent support...");
        // Add Mouse handling objects. The MouseDelegator manages the
        // MouseModes, controlling which one receives events from the
        // MapBean. The active MouseMode sends events to the layers
        // that want to receive events from it. The MouseDelegator
        // will find the MapBean in the MapHandler, and hook itself up
        // to it.
        mapHandler.add(new MouseDelegator());

        // Add MouseMode. The MouseDelegator will find it via the
        // MapHandler.

        //  Adding NavMouseMode first makes it active.
        mapHandler.add(new NavMouseMode());

        System.out.println("Creating ToolPanel...");
        // Add the standard panning and zoom GUI to the JFrame.
        // Create the tool...
        mapHandler.add(new OMToolSet());
        // Create the ToolPanel. It will find the OMToolSet in the
        // MapHandler.
        ToolPanel toolPanel = new ToolPanel();
        mapHandler.add(toolPanel);

        // Add the ToolPanel to the right place in this JFrame.
        getContentPane().add(toolPanel, BorderLayout.NORTH);

        System.out.println("Creating Layers...");
        Layer[] layers = getLayers(props);

        // Use the LayerHandler to manage all layers, whether they are
        // on the map or not. You can add a layer to the map by
        // setting layer.setVisible(true).
        LayerHandler layerHandler = new LayerHandler();
        for (int i = 0; i < layers.length; i++) {
            layers[i].setVisible(true);
            layerHandler.addLayer(layers[i]);
        }

        mapHandler.add(layerHandler);
        System.out.println("Done creating...");
    }
View Full Code Here


        }

        WindowSupport ws = getWindowSupport();

        if (ws != null && !getUseAsTool()) {
            MapHandler mh = (MapHandler) getBeanContext();
            Frame frame = null;
            int xoffset = 0;
            int yoffset = 0;
            if (mh != null) {
                frame = (Frame) mh.get(java.awt.Frame.class);
                if (frame != null) {
                    xoffset = frame.getX();
                    yoffset = frame.getY();
                }
            }
View Full Code Here

        // Environment, before the MapBean gets created.
        PropertyHandler ph = getPropertyHandler();
        // Make sure the MapBean is created and added to the
        // MapHandler.
        MapBean mb = getMapBean();
        MapHandler mh = getMapHandler();
        mh.add(this);
        ph.createComponents(getMapHandler());

        // At this point, check the MapHandler to see if a
        // ProjectionFactory has been added. If it hasn't, create one
        // with the default ProjectionLoaders. We might want to
        // remove this at some point, but not having it here will
        // catch some people by suprise when 4.6.1 comes out.
        Object obj = mh.get(com.bbn.openmap.proj.ProjectionFactory.class);
        if (obj == null) {
            Debug.message("basic",
                    "BasicMapPanel adding ProjectionFactory and projections to MapHandler since there are none to be found.");
            mh.add(ProjectionFactory.loadDefaultProjections());
        }

        // Environment will only get loaded after the property file is
        // read.
        mb.setProjection(ProjectionFactory.getDefaultProjectionFromEnvironment());
View Full Code Here

     * MapPanel method. Get the MapHandler used for the MapPanel.
     * Creates a standard MapHandler if it hasn't been created yet.
     */
    public MapHandler getMapHandler() {
        if (mapHandler == null) {
            mapHandler = new MapHandler();
        }
        return mapHandler;
    }
View Full Code Here

    public ActionListener getOverviewFrameActionListener() {
        return new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                WindowSupport ws = getWindowSupport();

                MapHandler mh = (MapHandler) getBeanContext();
                Frame frame = null;
                if (mh != null) {
                    frame = (Frame) mh.get(java.awt.Frame.class);
                }

                if (ws == null) {
                    ws = new WindowSupport(OverviewMapHandler.this, new WindowSupport.Dlg(frame, "Overview Map"));
                    setWindowSupport(ws);
View Full Code Here

        createPanel();
        prefixTextField.setText(DefaultLayerName);

        WindowSupport ws = getWindowSupport();

        MapHandler mh = (MapHandler) getBeanContext();
        Frame frame = null;
        if (mh != null) {
            frame = (Frame) mh.get(java.awt.Frame.class);
        }

        if (ws == null) {
            ws = new WindowSupport(this, i18n.get(LayerAddPanel.class,
                    "title",
View Full Code Here

             * objects.
             */
            MapPanel mapPanel = new BasicMapPanel();

            // 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
             * the map. The LayerHandler has methods to do this, too.
             * The LayerHandler will find the MapBean in the
             * MapHandler.
             */
            mapHandler.add(new LayerHandler());

            // Add a route layer.
            RouteLayer routeLayer = new RouteLayer();
            routeLayer.setVisible(true);
            // The LayerHandler will find the Layer in the MapHandler.

            /*
             * Create a ShapeLayer to show world political boundaries.
             * Set the properties of the layer. This assumes that the
             * datafiles "dcwpo-browse.shp" and "dcwpo-browse.ssx" are
             * in a path specified in the CLASSPATH variable. These
             * files are distributed with OpenMap and reside in the
             * toplevel "share" subdirectory.
             */
            ShapeLayer shapeLayer = new ShapeLayer();

            // Since this Properties object is being used just for
            // this layer, the properties do not have to be scoped
            // with marker name, like the layer properties in the
            // ../hello/HelloWorld.properties file.
            Properties shapeLayerProps = new Properties();
            shapeLayerProps.put("prettyName", "Political Solid");
            shapeLayerProps.put("lineColor", "000000");
            shapeLayerProps.put("fillColor", "BDDE83");
            shapeLayerProps.put("shapeFile", "data/shape/dcwpo-browse.shp");
            shapeLayerProps.put("spatialIndex", "data/shape/dcwpo-browse.ssx");
            shapeLayer.setProperties(shapeLayerProps);
            shapeLayer.setVisible(true);

           
            // Last on top.
            mapHandler.add(shapeLayer);
            mapHandler.add(new GraticuleLayer());
            mapHandler.add(routeLayer);

            // Create the directional and zoom control tool
            OMToolSet omts = new OMToolSet();
            // Create an OpenMap toolbar
            ToolPanel toolBar = new ToolPanel();

            /*
             * Add the ToolPanel and the OMToolSet to the MapHandler.
             * The OpenMapFrame will find the ToolPanel and attach it
             * to the top part of its content pane, and the ToolPanel
             * will find the OMToolSet and add it to itself.
             */
            mapHandler.add(omts);
            mapHandler.add(toolBar);
            // Display the frame
            frame.setVisible(true);

        } catch (MultipleSoloMapComponentException msmce) {
            // The MapHandler is only allowed to have one of certain
View Full Code Here

                    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);
View Full Code Here

                }

                Debug.output("OMDrawingToolLauncher: Something is not set:\n"
                        + sb.toString());

                MapHandler mapHandler = (MapHandler) getBeanContext();
                if (mapHandler != null) {
                    InformationDelegator id = (InformationDelegator) mapHandler.get("com.bbn.openmap.InformationDelegator");
                    if (id != null) {

                        id.displayMessage(i18n.get(OMDrawingToolLauncher.class,
                                "problem",
                                "Problem"),
View Full Code Here

     */
    public ActionListener getActionListener() {
        return new ActionListener() {
            public void actionPerformed(ActionEvent evt) {

                MapHandler mh = (MapHandler) getBeanContext();
                Frame frame = null;
                if (mh != null) {
                    frame = (Frame) mh.get(java.awt.Frame.class);
                }

                // -1 will get size from pack(), and get location (initially) to
                // the middle of the screen if the WindowSupport doesn't have
                // memory of where it's been.
View Full Code Here

TOP

Related Classes of com.bbn.openmap.MapHandler

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.