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

📄 beanpanel.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* ********************************************************************** *  *    Use, duplication, or disclosure by the Government is subject to *           restricted rights as set forth in the DFARS. *   *                         BBNT Solutions LLC *                             A Part of  *                  Verizon       *                          10 Moulton Street *                         Cambridge, MA 02138 *                          (617) 873-3000 * *    Copyright (C) 2002 by BBNT Solutions, LLC *                 All Rights Reserved. * ********************************************************************** */package com.bbn.openmap.tools.beanbox;import java.awt.*;import java.awt.event.*;import java.awt.dnd.*;import java.beans.*;import javax.swing.*;import javax.swing.event.*;import java.io.*;import java.util.*;import java.net.*;import com.bbn.openmap.*;import com.bbn.openmap.util.Debug;import com.bbn.openmap.LayerHandler;import com.bbn.openmap.gui.OMToolComponent;import com.bbn.openmap.tools.dnd.DefaultTransferableObject;/** * The BeanPanel class is an openmap component that loads a set of * java bean classes upon startup and organizes them into one or more * tabbed panes. The organization of the tabs is specified in the * openmap properties file (see below). A bean loaded by the BeanPanel * is represented using information available in the BeanInfo. The * BeanPanel tries to represent the bean as an icon followed by the * bean's pretty name. It gets the (32 x 32 pixels size) color icon * from the BeanInfo and it gets the bean's pretty name from the * BeanDescriptor defined in the BeanInfo. If no icon is available, * the default bluebean.gif icon included in this package is used. If * no pretty name is available, the last portion of the bean's fully * qualified class name is used to represent the bean's name. * <p> * The BeanPanel uses Java Drag-And-Drop and is registered as the * DragSource for Drag-And-Drop events. A user can drag and drop a * bean from one of the tabs in the BeanPanel onto the map where the * {@link com.bbn.openmap.tools.beanbox.BeanBoxDnDCatcher}catches the * bean. * <p> * <p> * The following are the properties that the BeanPanel reads from the * openmap properties file: * <p> *  * <pre> *  *  #------------------------------ *  # Properties for BeanPanel *  #------------------------------ *  # This property should reflect the paths to the directories  *  # containing the bean jars, separated by a space. *  beanpanel.beans.path=g:/path-one/jars h:/path-two/lib *   *  # This property should reflect the logical names of tabs in the BeanPanel, *  # separated by a space. The order in which the tabs are specified in this *  property is the order in which they appear in the BeanPanel *  beanpanel.tabs=tab1 tab2 *  *  # for each tab specified in the beanpabel.tabs property, the following *  # two properties should respectively reflect the pretty name of the tab and *  # the class names of the beans that should appear in the tab. Class names should *  # be separated by spaces. *  beanpanel.tab1.name=tab1-pretty-name *  beanpanel.tab1.beans=fully-qualified-bean-class-name fully-qualified-bean-class-name ... *  beanpanel.tab2.name=tab2-pretty-name *  beanpanel.tab2.beans=fully-qualified-bean-class-name fully-qualified-bean-class-name ... *   *  #------------------------------------- *  # End of properties for BeanPanel *  #------------------------------------- *   * <p> * <p> *  *  The BeanPanel looks for beanInfos in the same package as the associated *  bean as well as in the Introspector's search path. The Introspector's *  search path can be augmented by specifying a comma separated list of *  package names in the bean.infos.path system (-D) property. *   * <p><p> *  *  A BeanPanel can also be created and used as a standalone class, i.e. independent  *  of the openmap components architecture by using the BeanPanel constructor that *  takes a Properties object as an argument. This constructor creates and initializes  *  a BeanPanel object from properties in the Properties object. The format of the  *  properties is the same as the one specified in the openmap properties file. *   * </pre> */public class BeanPanel extends OMToolComponent implements Serializable {    /** Default icon for representating a bean */    public static ImageIcon defaultBeanIcon;    static {        augmentBeanInfoSearchPath();        setDefaultIcon();    }    /** Default key for the BeanPanel Tool. */    public static final String defaultKey = "beanpanel";    private BeanHelper helper = new BeanHelper();    private Vector beanLabels = new Vector();    private Vector beanNames = new Vector();    private Vector beanIcons = new Vector();    private Vector beanJars = new Vector();    private Vector beanInfos = new Vector();    private Vector beanPaths;    private HashMap toolbarTabInfo;    private Vector toolbarTabOrder;    /** DnD source */    private DragSource dragSource;    private JTabbedPane tabbedPane;    private Cursor customCursor;    private JFrame beanFrame = null;    /**     * Constructs the BeanPanel component, creates a DragSource and     * DragSourceListener objects and registers itself as the source     * of Java drag events. Note that this constructor does not     * initialize the BeanPanel GUI. Instead the GUI is initialized     * lazily when the user clicks on the 'Face' of this object on the     * openmap components bar. Thus, this constructor should not be     * used to create a standalone BeanPanel. Use the parameterized     * constructor to create a standalone BeanPanel.     */    public BeanPanel() {        super();        setKey(defaultKey);        beanPaths = new Vector();        toolbarTabInfo = new HashMap();        toolbarTabOrder = new Vector();        tabbedPane = new JTabbedPane();        dragSource = new DragSource();        ComponentDragSourceListener tdsl = new ComponentDragSourceListener();        dragSource.createDefaultDragGestureRecognizer(tabbedPane,                DnDConstants.ACTION_MOVE,                new ComponentDragGestureListener(tdsl));        if (Debug.debugging("beanpanel"))            Debug.output("Created Bean Panel");    }    /**     * This constructor does everything that the default constructor     * does and in addition initializes the BeanPanel's properties     * from the Properties object and initializes the BeanPanel GUI.     * Use this constructor to create a standalone BeanPanel.     */    public BeanPanel(Properties props) {        this();        if (props == null)            throw new IllegalArgumentException("null props");        this.loadBeanPanelProperties(props);        this.initGui();    }    /**     * Tool interface method. The retrieval tool's interface. This     * method creates a button that will bring up the BeanPanel.     *      * @return A container that will contain the 'face' of this panel     *         on the OpenMap ToolPanel.     */    public Container getFace() {        if (Debug.debugging("beanpanel"))            Debug.output("Enter> BP::getFace");        JButton button = null;        if (defaultBeanIcon == null) {            if (Debug.debugging("beanpanel"))                Debug.output("Enter> null defaultBeanIcon!");            button = new JButton("Bean Box");        } else            button = new JButton(defaultBeanIcon);        button.setBorderPainted(false);        button.setToolTipText("Bean Box");        button.setMargin(new Insets(0, 0, 0, 0));        button.addActionListener(new ActionListener() {            public void actionPerformed(ActionEvent evt) {                showBeanPanel(true);            }        });        if (Debug.debugging("beanpanel"))            Debug.output("Exit> BP::getFace");        button.setVisible(getUseAsTool());        return button;    }    /**     * Called when things are removed from the MapHandler.     */    public void findAndUndo(Object someObj) {        if (someObj instanceof LayerHandler) {            // do the initializing that need to be done here        }    }    /**     * Utility method for finding the BeanInfo associated with a bean     * class name. This method first attaches the String "BeanInfo" to     * the end of the class name and then searches the package of the     * specified class for the BeanInfo class. If the BeanInfo is not     * found in the bean class's package, then the method searches for     * the BeanInfo in the Introspector search path.     *      * @param beanClassName the fully qualified name of the bean class     * @return an instance of the BeanInfo class for the specified     *         class, if one is found, otherwise null.     */    public static synchronized BeanInfo findBeanInfo(String beanClassName) {        //System.out.println("Finding beanInfo for " +        // beanClassName);        String[] beanInfoPaths = Introspector.getBeanInfoSearchPath();        String infoClassName = beanClassName + "BeanInfo";        Class infoClass = null;        try {            infoClass = Class.forName(infoClassName);            //System.out.println("returning " + infoClass);            return (BeanInfo) infoClass.newInstance();        } catch (Exception ex) {            //System.out.println ("Unable to find BeanInfo class for            // " + infoClassName);        }        for (int i = 0; i < beanInfoPaths.length; i++) {            //System.out.println ("Looking in " + beanInfoPaths[i]);            int index = beanClassName.lastIndexOf(".");            String classNameWithDot = beanClassName.substring(index);            infoClassName = beanInfoPaths[i] + classNameWithDot + "BeanInfo";            try {                infoClass = Class.forName(infoClassName);                break;            } catch (ClassNotFoundException ex) {                //System.out.println ("Unable to find BeanInfo class                // for " + infoClassName);            }        }        Object retval = null;        if (infoClass != null) {            try {                retval = infoClass.newInstance();            } catch (Exception ex) {                //System.out.println("Unable to instantiate " +                // infoClassName);            }        }        //System.out.println("returning " + infoClass);        return (BeanInfo) retval;    }

⌨️ 快捷键说明

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