Package com.bbn.openmap

Examples of com.bbn.openmap.MapBean


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


    /*
     * Constructor.
     */
    public ExampleApplication() {
        _mapBean = new MapBean();
        _menuBar = new JMenuBar();
        _toolPanel = new ToolPanel();
        _omts = new OMToolSet();
        _omts.findAndInit(_mapBean);
        _mouseDelegator = new MouseDelegator(_mapBean);
View Full Code Here

        // Make this call first to load the properties into
        // 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());
        mb.setBckgrnd(Environment.getCustomBackgroundColor());
    }
View Full Code Here

    /**
     * A static method that creates a MapBean and sets its projection
     * and border to the values given.
     */
    public static MapBean createMapBean(Projection proj, Border border) {
        MapBean mapBeano = new BufferedLayerMapBean();
        mapBeano.setBorder(border);
        mapBeano.setProjection(proj);
        mapBeano.setPreferredSize(new Dimension(proj.getWidth(), proj.getHeight()));
        return mapBeano;
    }
View Full Code Here

        // Size the frame appropriately
        frame.setSize(640, 480);

        // Create a MapBean
        MapBean mapBean = new MapBean();

        // 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();
        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);

        // Add the political layer to the map
        mapBean.add(shapeLayer);

        // Add the map to the frame
        frame.getContentPane().add(mapBean);

        frame.addWindowListener(new WindowAdapter() {
View Full Code Here

            return;
        }

        // Could call repaint(), but I think we should paint in this
        // thread...
        MapBean map = (MapBean) obj;
        // Gets the buffer cleaned out.
        map.setBufferDirty(true);
        map.paintChildren(map.getGraphics());
    }
View Full Code Here

        Object obj = e.getSource();
        if (!(obj instanceof MapBean)) {
            return;
        }

        MapBean map = (MapBean) obj;
        Graphics g = map.getGraphics();

        OMGraphic graphic = getGraphic();

        if (firmPaint) {
            // So, with a firm paint, we want to clean the screen. If
            // the map is being buffered, we need to clean out the
            // buffer, which is why we set the Request paint to true,
            // to get the image rebuilt. Otherwise, a copy of the
            // graphic remains.
            map.setBufferDirty(true);
            graphic.generate(getProjection());
            map.repaint();
        } else {
            // If we get here, we are painting a moving object, so we
            // only want to do the outline to make it as fast as
            // possible.
            holder.setFrom(graphic);
View Full Code Here

    public void mouseDragged(MouseEvent arg0) {

        int x = arg0.getX();
        int y = arg0.getY();

        MapBean mb = ((MapBean) arg0.getSource());

        if (!isPanning) {
            int w = mb.getWidth();
            int h = mb.getHeight();

            /*
             * Making the image
             */

            if (bufferedMapImage == null || bufferedRenderingImage == null) {
                createBuffers(w, h);
            }

            GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
            Graphics2D g = (Graphics2D) ge.createGraphics(bufferedMapImage);
            g.setClip(0, 0, w, h);
            Border border = mb.getBorder();
            mb.setBorder(null);
            mb.paintAll(g);
            mb.setBorder(border);

            oX = x;
            oY = y;

            isPanning = true;

        } else {
            if (bufferedMapImage != null && bufferedRenderingImage != null) {
                Graphics2D gr2d = (Graphics2D) bufferedRenderingImage.getGraphics();
                /*
                 * Drawing original image whithout transparence and in the
                 * initial position
                 */
                if (leaveShadow) {
                    gr2d.drawImage(bufferedMapImage, 0, 0, null);
                } else {
                    gr2d.setPaint(mb.getBckgrnd());
                    gr2d.fillRect(0, 0, mb.getWidth(), mb.getHeight());
                }

                /*
                 * Drawing image whith transparence and in the mouse position
                 * minus origianl mouse click position
                 */
                gr2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opaqueness));
                gr2d.drawImage(bufferedMapImage, x - oX, y - oY, null);

                ((Graphics2D) mb.getGraphics()).drawImage(bufferedRenderingImage, 0, 0, null);
            }
        }
        super.mouseDragged(arg0);
    }
View Full Code Here

     * @see java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent)
     *      Make Pan event for the map.
     */
    public void mouseReleased(MouseEvent arg0) {
        if (isPanning && arg0.getSource() instanceof MapBean) {
            MapBean mb = (MapBean) arg0.getSource();
            Projection proj = mb.getProjection();
            Point center = proj.forward(proj.getCenter());
            center.setLocation(center.getX() - arg0.getX() + oX, center.getY() - arg0.getY() + oY);
            mb.setCenter(proj.inverse(center));
            isPanning = false;
            // bufferedMapImage = null; //clean up when not active...
        }
        super.mouseReleased(arg0);
    }
View Full Code Here

    }

    public void projectionChanged(ProjectionEvent e) {
        Object obj = e.getSource();
        if (obj instanceof MapBean) {
            MapBean mb = (MapBean) obj;
            int w = mb.getWidth();
            int h = mb.getHeight();
            createBuffers(w, h);
        }
    }
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.