⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 openmapframe.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// **********************************************************************// // <copyright>// //  BBN Technologies//  10 Moulton Street//  Cambridge, MA 02138//  (617) 873-8000// //  Copyright (C) BBNT Solutions LLC. All rights reserved.// // </copyright>// **********************************************************************// // $Source: /cvs/distapps/openmap/src/openmap/com/bbn/openmap/gui/OpenMapFrame.java,v $// $RCSfile: OpenMapFrame.java,v $// $Revision: 1.9.2.3 $// $Date: 2005/08/09 17:59:30 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.gui;import java.awt.Container;import java.awt.Dimension;import java.awt.Toolkit;import java.beans.PropertyVetoException;import java.beans.VetoableChangeListener;import java.beans.beancontext.BeanContext;import java.beans.beancontext.BeanContextChild;import java.beans.beancontext.BeanContextChildSupport;import java.beans.beancontext.BeanContextMembershipEvent;import java.beans.beancontext.BeanContextMembershipListener;import java.util.Iterator;import java.util.Properties;import javax.swing.JFrame;import javax.swing.JMenuBar;import com.bbn.openmap.Environment;import com.bbn.openmap.PropertyConsumer;import com.bbn.openmap.PropertyHandler;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PropUtils;/** * The OpenMapFrame is the application window frame that holds the * MapPanel, and eventually the MapBean. It listens to the MapHandler * for the addition of Beans to the MapHandler BeanContext, and then * positions the widgets it can deal with within itself. The frame * does not present itself until an MapPanel is found. *  * <p> * The OpenMapFrame is intended to be used in an application * environment. The applet checks and code to handle the applet * environment was moved to the OpenMapApplet class. */public class OpenMapFrame extends JFrame implements        BeanContextMembershipListener, BeanContextChild, PropertyConsumer {    /** Starting X coordinate of window */    public static final String xProperty = Environment.OpenMapPrefix + ".x";    /** Starting Y coordinate of window */    public static final String yProperty = Environment.OpenMapPrefix + ".y";    /**     * useAsInternalFrameRootPaneIfNecessary will tell the     * OpenMapFrame to set its root pane as the Environment's desktop     * if the Environment has been told to use internal frames, and if     * a root pane hasn't been set. True by default.     */    protected boolean useAsInternalFrameRootPaneIfNecessary = true;    /**     * BeanContextChildSupport object provides helper functions for     * BeanContextChild interface.     */    private BeanContextChildSupport beanContextChildSupport = new BeanContextChildSupport(this);    /**     * Create the frame with "OpenMap <version>" in the title.     */    public OpenMapFrame() {        this(Environment.get(Environment.Title));    }    /**     * @param useAsInternalFrameRootPaneIfNecessary will tell the     *        OpenMapFrame to set its root pane as the Environment's     *        desktop if the Environment has been told to use internal     *        frames, and if a root pane hasn't been set.     */    public OpenMapFrame(boolean useAsInternalFrameRootPaneIfNecessary) {        this(Environment.get(Environment.Title),             useAsInternalFrameRootPaneIfNecessary);    }    /**     * Create a OpenMap frame with a title.     *      * @param title The Frame title.     */    public OpenMapFrame(String title) {        this(title, true);    }    /**     * Create a OpenMap frame with a title, with a WindowListner that     * says what to do when the OpenMapFrame is closed.     *      * @param title The Frame title.     * @param useAsInternalFrameRootPaneIfNecessary will tell the     *        OpenMapFrame to set its root pane as the Environment's     *        desktop if the Environment has been told to use internal     *        frames, and if a root pane hasn't been set.     */    public OpenMapFrame(String title,            boolean useAsInternalFrameRootPaneIfNecessary) {        super(title);        this.useAsInternalFrameRootPaneIfNecessary = useAsInternalFrameRootPaneIfNecessary;    }    /**     * For applications, checks where the Environment says the window     * should be placed, and then uses the packed height and width to     * make adjustments.     */    protected void setPosition() {        // get starting width and height        pack();        int w = getWidth();        int h = getHeight();        Dimension d = Toolkit.getDefaultToolkit().getScreenSize();        Debug.message("basic", "Screen dimensions are " + d);        if (w > d.width)            w = d.width - d.width / 10;        if (h > d.height)            h = d.height - d.height / 10;        int x = Environment.getInteger(xProperty, -1);        int y = Environment.getInteger(yProperty, -1);        if (x < 0)            x = d.width / 2 - w / 2;        if (y < 0)            y = d.height / 2 - h / 2;        if (Debug.debugging("basic")) {            Debug.output("Setting Frame X and Y from properties to " + x + " "                    + y);        }        // compose the frame, but don't show it here        // contentPane.setBounds(x, y, w, h);        setBounds(x, y, w, h);    }    /**     * Called when the OpenMapFrame is added to a BeanContext, and     * when other objects are added to the BeanContext. The     * OpenMapFrame looks for objects that it knows how to place upon     * itself (MapPanel, JMenuBar). The OpenMapFrame does not check to     * see if the objects looked for are already added to itself. It     * assumes that if some object type is getting added to it, the     * caller must know what they are doing - just like a regular     * JFrame.     *      * @param it Iterator to use to go through the BeanContext     *        objects.     */    public void findAndInit(Iterator it) {        while (it.hasNext()) {            findAndInit(it.next());        }    }    /**     * Called when an object is added to the MapHandler.     */    public void findAndInit(Object someObj) {        if (someObj instanceof MapPanel && someObj instanceof Container) {            Debug.message("basic", "OpenMapFrame: Found a MapPanel");            getContentPane().add((Container) someObj);            JMenuBar jmb = ((MapPanel) someObj).getMapMenuBar();            if (jmb != null) {                Debug.message("basic",                        "OpenMapFrame: Got MenuBar from MapPanel");                getRootPane().setJMenuBar(jmb);            }            setPosition();            invalidate();            show();        }        // We shouldn't find this if we've already defined one        // in the MapPanel, but we have this for backward        // compatibility.        if (someObj instanceof JMenuBar) {            Debug.message("basic", "OpenMapFrame: Found a MenuBar");            getRootPane().setJMenuBar((JMenuBar) someObj);            invalidate();        }        if (someObj instanceof PropertyHandler) {            // Might get called twice if someone uses the            // ComponentFactory to create the OpenMapFrame, but the            // default OpenMap application doesn't use the            // ComponentFactory to create the OpenMapFrame, so            // setProperties isn't called by default.            setProperties(((PropertyHandler) someObj).getProperties());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -