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

📄 loadpropertiesmenuitem.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
字号:
// **********************************************************************// // <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/menu/LoadPropertiesMenuItem.java,v $// $RCSfile: LoadPropertiesMenuItem.java,v $// $Revision: 1.3.2.1 $// $Date: 2004/10/14 18:26:55 $// $Author: dietrick $// // **********************************************************************package com.bbn.openmap.gui.menu;import java.awt.event.*;import java.awt.*;import java.util.*;import java.io.*;import com.bbn.openmap.*;import com.bbn.openmap.util.Debug;/** * This is a menu item that loads a file. This file should be a valid * openmap properties file, with openmap.layers set and projection * properties set. The components list is ignored, since it is pretty * dependent on order, and it's hard to write a good properties file * automatically with a valid components list. * <P> * If you want to change the components in an application, launch * OpenMap with the properties file you want. */public class LoadPropertiesMenuItem extends MapHandlerMenuItem implements        ActionListener {    public LoadPropertiesMenuItem() {        super("Load Map Properties");        addActionListener(this);    }    public void actionPerformed(ActionEvent ae) {        //Collect properties        if (mapHandler == null) {            return;        }        PropertyHandler ph = null;        Iterator it = mapHandler.iterator();        while (it.hasNext()) {            Object someObj = it.next();            if (someObj instanceof PropertyHandler) {                ph = (PropertyHandler) someObj;                break;            }        }        if (ph == null) {            Debug.error("Couldn't find PropertyHandler");            return;        }        FileDialog fd = new FileDialog(new Frame(), "Loading the map from a Properties file...", FileDialog.LOAD);        fd.show();        String fileName = fd.getFile();        String dirName = fd.getDirectory();        if (fileName == null) {            Debug.message("loadpropertiesmenuitem",                    "User did not select any file");            return;        }        Debug.message("loadpropertiesmenuitem", "User selected file " + dirName                + File.separator + fileName);        File file = new File(new File(dirName), fileName);        try {            Properties newProps = new Properties();            FileInputStream fis = new FileInputStream(file);            newProps.load(fis);            String test = newProps.getProperty("openmap."                    + LayerHandler.layersProperty);            if (test == null) {                throw new IOException("Doesn't seem like a valid properties file");            }            // Just reset the projection and layers, not the            // components.            ph.loadProjectionAndLayers(mapHandler, newProps);        } catch (FileNotFoundException fnfe) {            Debug.error(fnfe.getMessage());        } catch (IOException ioe) {            InformationDelegator id = (InformationDelegator) mapHandler.get("com.bbn.openmap.InformationDelegator");            if (id != null) {                id.displayMessage("Error loading file...",                        "Error occured loading " + file.getAbsolutePath()                                + "\n" + ioe.getMessage());            }            Debug.error("Error occured loading " + file.getAbsolutePath());        }    }}

⌨️ 快捷键说明

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