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

📄 toolpanel.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    public void setComponentList(List list) {        componentList = list;    }    /**     * Get the list of strings used by the ToolPanel to figure out     * which Tools should be added (in the findAndInit()) method and     * where they should go.     */    public List getComponentList() {        return componentList;    }    /**     * Set the list of strings used by the ToolPanel to figure out     * which Tools should not be added (in the findAndInit()) method.     */    public void setAvoidList(List list) {        avoidList = list;    }    /**     * Get the list of strings used by the ToolPanel to figure out     * which Tools should not be added (in the findAndInit()) method.     */    public List getAvoidList() {        return avoidList;    }    /**     * Called when the ToolPanel is added to the BeanContext, and when     * new objects are added to the BeanContext after that. The     * ToolPanel looks for Tools that are part of the BeanContext.     *      * @param it iterator to use to go through the new objects.     */    public void findAndInit(Iterator it) {        while (it.hasNext()) {            findAndInit(it.next());        }    }    /**     * Figure out if the string key is in the provided list, and     * provide the location index of it is.     *      * @param key the key of the component to check for.     * @param list the list of keys to check.     * @return -1 if not on the list, the index starting at 0 if it     *         is.     */    protected int keyOnList(String key, List list) {        int ret = -1;        int index = 0;        if (list != null) {            Iterator it = list.iterator();            while (it.hasNext()) {                String listKey = (String) it.next();                if (listKey.equalsIgnoreCase(key)) {                    ret = index;                    break;                }                index++;            }        }        return ret;    }    public void findAndInit(Object someObj) {        if (someObj instanceof Tool) {            String key = ((Tool) someObj).getKey();            List list = getComponentList();            int index;            if (list != null) {                index = keyOnList(key, list);                if (index >= 0) {                    if (Debug.debugging("basic")) {                        Debug.output("ToolPanel: found a tool Object " + key                                + " for placement at " + index);                    }                    add((Tool) someObj, index);                }            } else {                index = keyOnList(key, getAvoidList());                if (index < 0) {                    Debug.message("basic", "ToolPanel: found a tool Object");                    add((Tool) someObj);                }            }        }    }    /**     * BeanContextMembershipListener method. Called when objects have     * been added to the parent BeanContext.     *      * @param bcme the event containing the iterator with new objects.     */    public void childrenAdded(BeanContextMembershipEvent bcme) {        findAndInit(bcme.iterator());    }    /**     * BeanContextMembershipListener method. Called when objects have     * been removed from the parent BeanContext. If the ToolPanel     * finds a Tool in the list, it removes it from the ToolPanel.     *      * @param bcme the event containing the iterator with removed     *        objects.     */    public void childrenRemoved(BeanContextMembershipEvent bcme) {        Iterator it = bcme.iterator();        Object someObj;        while (it.hasNext()) {            someObj = it.next();            if (someObj instanceof Tool) {                // do the initializing that need to be done here                Debug.message("toolpanel", "ToolPanel removing tool Object");                remove(((Tool) someObj).getKey());            }        }    }    /** Method for BeanContextChild interface. */    public BeanContext getBeanContext() {        return beanContextChildSupport.getBeanContext();    }    /**     * Method for BeanContextChild interface. Called when the     * ToolPanel is added to the BeanContext.     *      * @param in_bc the BeanContext.     */    public void setBeanContext(BeanContext in_bc) throws PropertyVetoException {        if (in_bc != null) {            in_bc.addBeanContextMembershipListener(this);            beanContextChildSupport.setBeanContext(in_bc);            findAndInit(in_bc.iterator());        }    }    /** Method for BeanContextChild interface. */    public void addPropertyChangeListener(String propertyName,                                          PropertyChangeListener in_pcl) {        beanContextChildSupport.addPropertyChangeListener(propertyName, in_pcl);    }    /** Method for BeanContextChild interface. */    public void removePropertyChangeListener(String propertyName,                                             PropertyChangeListener in_pcl) {        beanContextChildSupport.removePropertyChangeListener(propertyName,                in_pcl);    }    /** Method for BeanContextChild interface. */    public void addVetoableChangeListener(String propertyName,                                          VetoableChangeListener in_vcl) {        beanContextChildSupport.addVetoableChangeListener(propertyName, in_vcl);    }    /** Method for BeanContextChild interface. */    public void removeVetoableChangeListener(String propertyName,                                             VetoableChangeListener in_vcl) {        beanContextChildSupport.removeVetoableChangeListener(propertyName,                in_vcl);    }    public void setPropertyPrefix(String prefix) {        propertyPrefix = prefix;    }    public String getPropertyPrefix() {        return propertyPrefix;    }    public void setProperties(Properties props) {        setProperties(null, props);    }    public void setProperties(String prefix, Properties props) {        setPropertyPrefix(prefix);        prefix = PropUtils.getScopedPropertyPrefix(prefix);        String componentsString = props.getProperty(prefix + ComponentsProperty);        if (componentsString != null) {            setComponentList(PropUtils.parseSpacedMarkers(componentsString));        }        String avoidComponentsString = props.getProperty(prefix                + AvoidComponentsProperty);        if (avoidComponentsString != null) {            setAvoidList(PropUtils.parseSpacedMarkers(avoidComponentsString));        }        String preferredLocationString = props.getProperty(prefix                + PreferredLocationProperty);        if (preferredLocationString != null) {            try {                preferredLocationString = (String) java.awt.BorderLayout.class.getField(preferredLocationString)                        .get(null);            } catch (NoSuchFieldException nsfe) {                preferredLocationString = null;            } catch (IllegalAccessException iae) {                preferredLocationString = null;            }            if (preferredLocationString != null) {                setPreferredLocation(preferredLocationString);            }        }    }    /**     * Take a List of strings, and return a space-separated version.     * Return null if the List is null.     */    protected StringBuffer rebuildListProperty(List aList) {        StringBuffer list = null;        if (aList != null) {            list = new StringBuffer();            Iterator it = aList.iterator();            while (it.hasNext()) {                list.append((String) it.next() + " ");            }        }        return list;    }    public Properties getProperties(Properties props) {        if (props == null) {            props = new Properties();        }        String prefix = PropUtils.getScopedPropertyPrefix(this);        StringBuffer listProp = rebuildListProperty(getComponentList());        if (listProp != null) {            props.put(prefix + ComponentsProperty, listProp.toString());        }        listProp = rebuildListProperty(getAvoidList());        if (listProp != null) {            props.put(prefix + AvoidComponentsProperty, listProp.toString());        }        props.put(prefix + PreferredLocationProperty, getPreferredLocation());        return props;    }    public Properties getPropertyInfo(Properties props) {        if (props == null) {            props = new Properties();        }        props.put(ComponentsProperty, "List of Names of Tools to Add");        return props;    }    /**     * If any of the components are visible, set the ToolPanel to be     * visible. If all of them are invisible, make the ToolPanel     * invisible.     */    protected void setVisibility() {        setVisible(areComponentsVisible());    }    public boolean areComponentsVisible() {        Enumeration enumeration = items.elements();        while (enumeration.hasMoreElements()) {            Tool tool = (Tool) enumeration.nextElement();            Container face = tool.getFace();            if (tool != filler && face != null && face.isVisible()) {                return true;            }        }        return false;    }    public void componentHidden(ComponentEvent ce) {        setVisibility();    }    public void componentMoved(ComponentEvent ce) {    }    public void componentResized(ComponentEvent ce) {    }    public void componentShown(ComponentEvent ce) {        setVisibility();    }}

⌨️ 快捷键说明

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