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

📄 gotomenu.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/GoToMenu.java,v $// $RCSfile: GoToMenu.java,v $// $Revision: 1.9.2.6 $// $Date: 2006/01/13 22:17:07 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.gui;import java.awt.FlowLayout;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Point;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Enumeration;import java.util.Hashtable;import java.util.Properties;import java.util.Vector;import javax.swing.BoxLayout;import javax.swing.JButton;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JMenuItem;import javax.swing.JPanel;import javax.swing.JSeparator;import javax.swing.JTextField;import com.bbn.openmap.I18n;import com.bbn.openmap.LatLonPoint;import com.bbn.openmap.MapBean;import com.bbn.openmap.gui.menu.DataBoundsViewMenuItem;import com.bbn.openmap.gui.menu.OMBasicMenu;import com.bbn.openmap.proj.Mercator;import com.bbn.openmap.proj.Projection;import com.bbn.openmap.proj.ProjectionFactory;import com.bbn.openmap.util.DataBoundsProvider;import com.bbn.openmap.util.Debug;import com.bbn.openmap.util.PropUtils;/** * Menu that keeps track of different saved map views (lat/lon, scale and * projection type), and provides a way to set the map projection to those * views. There is a set of optional default views, but new views can be added. * If these views are added to the properties file, they will be added to the * menu automatically for later uses. This menu can understand a set of * properties: *  * <pre> *   *   *   gotoMenu.class=com.bbn.openmap.gui.GoToMenu *   #Add the default, world view option *   gotoMenu.addDefaults=true *   #Add the menu for DataBoundsProviders *   gotoMenu.addDataViews=true *   #Additional views *   goto.views=Argentina India United_States Caspian_Sea *   Argentina.latitude=-39.760445 *   Argentina.longitude=-65.92294 *   Argentina.name=Argentina *   Argentina.projection=Mercator *   Argentina.scale=5.0E7 *   India.latitude=20.895763 *   India.longitude=80.437485 *   India.name=India *   India.projection=Mercator *   India.scale=3.86688E7 *   United_States.latitude=38.82259 *   United_States.longitude=-96.74999 *   United_States.name=United States *   United_States.projection=Mercator *   United_States.scale=5.186114E7 *   Caspian_Sea.name=Caspian Sea *   Caspian_Sea.latitude=40f *   Caspian_Sea.longitude=47f *   Caspian_Sea.scale=1000000 *   Caspian_Sea.projection=CADRG *   *    * </pre> */public class GoToMenu extends AbstractOpenMapMenu {    private String defaultText = "Views";    private String defaultMnemonic = "V";    protected Hashtable dataBoundsProviders = new Hashtable();    protected OMBasicMenu dataBoundsMenu;    protected MapBean map;    /**     * A space separated list of marker names for the views to be loaded from     * the properties.     */    public final static String ViewListProperty = "views";    /** The name of the view to use in the GUI. */    public final static String NameProperty = "name";    /** The center latitude of the view projection. */    public final static String LatProperty = "latitude";    /** The center longitude of the view projection. */    public final static String LonProperty = "longitude";    /** The scale of the view projection. */    public final static String ScaleProperty = "scale";    /** The projection type of the view projection. */    public final static String ProjectionTypeProperty = "projection";    /** Flag to use to add default views (World, each continent. */    public final static String AddDefaultListProperty = "addDefaults";    /**     * Flag to use to enable/disable the gathering of DataBoundsProviders.     */    public final static String AddDataViewsProperty = "addDataViews";    protected boolean addDefaults = true;    protected boolean addDataViews = true;    public GoToMenu() {        super();        setText(i18n.get(this, "goto", defaultText));        setMnemonic(i18n.get(this, "goto", I18n.MNEMONIC, defaultMnemonic)                .charAt(0));        // dataBoundsMenu = new OMBasicMenu("Go Over Data");        dataBoundsMenu = new OMBasicMenu(i18n.get(this,                "goOverData",                "Go Over Data"));        // add(new AddNewViewButton("Add Saved View..."));        add(new AddNewViewButton(i18n.get(this,                "addSavedView",                "Add Saved View...")));        add(dataBoundsMenu);        add(new JSeparator());    }    public void findAndUndo(Object someObj) {        super.findAndUndo(someObj);        if (someObj instanceof MapBean) {            // do the initializing that need to be done here            if (getMap() == (MapBean) someObj) {                setMap(null);            }        }        if (someObj instanceof DataBoundsProvider) {            removeDataBoundsProvider((DataBoundsProvider) someObj);        }    }    public void findAndInit(Object someObj) {        super.findAndInit(someObj);        if (someObj instanceof MapBean) {            // do the initializing that need to be done here            setMap((MapBean) someObj);        }        if (someObj instanceof DataBoundsProvider) {            addDataBoundsProvider((DataBoundsProvider) someObj);        }    }    /** Set the map to control. */    public void setMap(MapBean mb) {        map = mb;    }    public MapBean getMap() {        return map;    }    /** PropertyConsumer interface method. */    public void setProperties(String prefix, Properties props) {        super.setProperties(prefix, props);        prefix = PropUtils.getScopedPropertyPrefix(prefix);        addDefaults = PropUtils.booleanFromProperties(props, prefix                + AddDefaultListProperty, addDefaults);        addDataViews = PropUtils.booleanFromProperties(props, prefix                + AddDataViewsProperty, addDataViews);        dataBoundsMenu.setVisible(addDataViews);        if (addDefaults) {            addDefaultLocations();            add(new JSeparator());        }        String locationList = props.getProperty(prefix + ViewListProperty);        if (locationList != null) {            Vector views = PropUtils.parseSpacedMarkers(locationList);            Enumeration things = views.elements();            while (things.hasMoreElements()) {                String viewPrefix = (String) things.nextElement();                addLocationItem(viewPrefix, props);            }        }    }    /** PropertyConsumer interface method. */    public Properties getProperties(Properties props) {        props = super.getProperties(props);        String prefix = PropUtils.getScopedPropertyPrefix(this);        props.put(prefix + AddDefaultListProperty,                new Boolean(addDefaults).toString());        props.put(prefix + AddDataViewsProperty,                new Boolean(addDataViews).toString());        StringBuffer viewList = new StringBuffer();        Enumeration cv = customViews.elements();        while (cv.hasMoreElements()) {            GoToButton gtb = (GoToButton) cv.nextElement();            String sanitizedName = gtb.getText().replace(' ', '_');            viewList.append(" " + sanitizedName);            sanitizedName = PropUtils.getScopedPropertyPrefix(sanitizedName);            props.put(sanitizedName + NameProperty, gtb.getText());            props.put(sanitizedName + LatProperty,                    new Float(gtb.latitude).toString());            props.put(sanitizedName + LonProperty,                    new Float(gtb.longitude).toString());            props.put(sanitizedName + ScaleProperty,                    new Float(gtb.scale).toString());            props.put(sanitizedName + ProjectionTypeProperty, gtb.projectionID);

⌨️ 快捷键说明

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