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

📄 layer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    /**     * Check to see if the removable layer can be removed now.     *      * @return true if layer should be allowed to be deleted.     */    public boolean removeConfirmed() {        return true;    }    /**     * This is the method that your layer can use to find other     * objects within the MapHandler (BeanContext). This method gets     * called when the Layer gets added to the MapHandler, or when     * another object gets added to the MapHandler after the Layer is     * a member. If the LayerHandler creates the Layer from     * properties, the LayerHandler will add the Layer to the     * BeanContext if Layer.addToBeanContext is true. It is false by     * default.     *      * For Layers, this method doesn't do anything by default. If you     * need your layer to get ahold of another object, then you can     * use the Iterator to go through the objects to look for the one     * you need.     */    public void findAndInit(Iterator it) {        while (it.hasNext()) {            findAndInit(it.next());        }    }    /**     * This method is called by the findAndInit(Iterator) method, once     * for every object inside the iterator. It's here to allow     * subclasses a way to receive objects and still let the super     * classes have a shot at the object. So, you can override this     * method can call super.findAndInit(obj), or override the     * findAndInit(Iterator) method and call super.findAndInit(obj).     * Whatever.     */    public void findAndInit(Object obj) {}    /**     * BeanContextMembershipListener method. Called when a new object     * is added to the BeanContext of this object.     */    public void childrenAdded(BeanContextMembershipEvent bcme) {        findAndInit(bcme.iterator());    }    /**     * BeanContextMembershipListener method. Called when a new object     * is removed from the BeanContext of this object. For the Layer,     * this method doesn't do anything. If your layer does something     * with the childrenAdded method, or findAndInit, you should take     * steps in this method to unhook the layer from the object used     * in those methods.     */    public void childrenRemoved(BeanContextMembershipEvent bcme) {        Iterator it = bcme.iterator();        while (it.hasNext()) {            findAndUndo(it.next());        }    }    /**     * This is the method that does the opposite as the     * findAndInit(Object). Lets you call super classes with objects     * that need to be removed.     */    public void findAndUndo(Object obj) {}    /** Method for BeanContextChild interface. */    public BeanContext getBeanContext() {        return beanContextChildSupport.getBeanContext();    }    /**     * Method for BeanContextChild interface. Gets an iterator from     * the BeanContext to call findAndInit() over.     */    public void setBeanContext(BeanContext in_bc) throws PropertyVetoException {        if (in_bc != null) {            connectToBeanContext(in_bc);            findAndInit(in_bc.iterator());        }    }    /**     * Layer method to just connect to the BeanContext, without     * grabbing the interator as in setBeanContext(). Good for     * protected sub-layers where you want to optimize the calling of     * the findAndInit() method over them.     */    public void connectToBeanContext(BeanContext in_bc)            throws PropertyVetoException {        if (in_bc != null) {            in_bc.addBeanContextMembershipListener(this);            beanContextChildSupport.setBeanContext(in_bc);        }    }    /**     * Method for BeanContextChild interface. Uses the     * BeanContextChildSupport to add a listener to this object's     * property. This listener wants to have the right to veto a     * property change.     */    public void addVetoableChangeListener(String propertyName,                                          VetoableChangeListener in_vcl) {        beanContextChildSupport.addVetoableChangeListener(propertyName, in_vcl);    }    /**     * Method for BeanContextChild interface. Uses the     * BeanContextChildSupport to remove a listener to this object's     * property. The listener has the power to veto property changes.     */    public void removeVetoableChangeListener(String propertyName,                                             VetoableChangeListener in_vcl) {        beanContextChildSupport.removeVetoableChangeListener(propertyName,                in_vcl);    }    /**     * Report a vetoable property update to any registered listeners.     * If anyone vetos the change, then fire a new event reverting     * everyone to the old value and then rethrow the     * PropertyVetoException.     * <P>     *      * No event is fired if old and new are equal and non-null.     * <P>     *      * @param name The programmatic name of the property that is about     *        to change     *      * @param oldValue The old value of the property     * @param newValue - The new value of the property     *      * @throws PropertyVetoException if the recipient wishes the     *         property change to be rolled back.     */    public void fireVetoableChange(String name, Object oldValue, Object newValue)            throws PropertyVetoException {        super.fireVetoableChange(name, oldValue, newValue);        beanContextChildSupport.fireVetoableChange(name, oldValue, newValue);    }    public void clearListeners() {        if (localHackList != null) {            localHackList.removeAll();        }        if (IDListeners != null) {            IDListeners.removeAll();        }        if (lsListeners != null) {            lsListeners.removeAll();        }        BeanContext bc = getBeanContext();        if (bc != null) {            bc.removeBeanContextMembershipListener(this);        }    }    public void finalize() {        if (Debug.debugging("gc")) {            Debug.output("Layer |" + getName() + " |: getting GC'd");        }    }    /**     * Fire a component event to the Layer component listeners, with     * the palette as the component, letting them know if it's visible     * or not.     */    public void firePaletteEvent(ComponentEvent event) {        if (localHackList == null) {            return;        }        palette = (Container) event.getSource();        int eventType = event.getID();        for (Iterator it = localHackList.iterator(); it.hasNext();) {            ComponentListener target = (ComponentListener) it.next();            if (eventType == ComponentEvent.COMPONENT_HIDDEN) {                target.componentHidden(event);            } else if (eventType == ComponentEvent.COMPONENT_SHOWN) {                target.componentShown(event);            }        }        if (eventType == ComponentEvent.COMPONENT_HIDDEN) {            palette = null;        }    }    /**     * Return the JDialog, or JInternalFrame, that serves as the     * palette for the layer. May be null.     */    public Container getPalette() {        return palette;    }    /**     * Called when something about the layer has changed that would     * require the palette to be reconfigured. Will cause getGUI() to     * be called again. You should take steps before calling this     * method to make sure that the getGUI() method is ready to     * recreate the palette components from scratch if needed.     */    protected void resetPalette() {        java.awt.Container pal = getPalette();        boolean putUp = false;        if (pal != null && pal.isVisible()) {            putUp = true;            setPaletteVisible(false);        }        if (putUp) {            setPaletteVisible(true);        }    }    /**     * Make the palette visible or not, destroy if invisible.     */    public void setPaletteVisible(boolean visible) {        if (visible) {            showPalette();        } else {            hidePalette();        }    }    /**     * Set the WindowSupport object handling the palette.     */    public void setWindowSupport(WindowSupport ws) {        windowSupport = ws;    }    /**     * Get the WindowSupport object handling the palette.     */    public WindowSupport getWindowSupport() {        return windowSupport;    }    protected WindowSupport createWindowSupport() {        return new ScrollPaneWindowSupport(getGUI(), getName());    }    /**     * Make the palette visible. Will automatically determine if we're     * running in an applet environment and will use a JInternalFrame     * over a JFrame if necessary.     */    public void showPalette() {        WindowSupport ws = getWindowSupport();        if (ws == null) {            ws = createWindowSupport();            paletteListener = new ComponentAdapter() {                public void componentShown(ComponentEvent e) {                    firePaletteEvent(e);                }                public void componentHidden(ComponentEvent e) {                    firePaletteEvent(e);                }            };            setWindowSupport(ws);        } else {            ws.setTitle(getName());            ws.setContent(getGUI());        }        if (ws != null) {            MapHandler mh = (MapHandler) getBeanContext();            Frame frame = null;            if (mh != null) {                frame = (Frame) mh.get(java.awt.Frame.class);                if (frame == null) {                    MapBean mapBean = (MapBean) mh.get("com.bbn.openmap.MapBean");                    if (mapBean == null) {                        Debug.message("layer",                                "Layer.showPalette: Warning...mapBean = null");                    } else {                        try {                            java.awt.Component parent = mapBean.getParent();                            while (parent.getParent() != null                                    && !(parent instanceof java.awt.Frame)) {                                parent = parent.getParent();                            }                            if (parent instanceof java.awt.Frame) {                                frame = (java.awt.Frame) parent;                            }                        } catch (Exception e) {                            e.printStackTrace();                        } // ignore any problems here                    }                }            }            if (paletteListener != null) {                ws.addComponentListener(paletteListener);            }            ws.displayInWindow(frame);        }    }    /**     * Hide the layer's palette.     */    public void hidePalette() {        WindowSupport ws = getWindowSupport();        if (ws != null) {            ws.killWindow();        }    }    /**     * The default actionPerformed method for Layer. Make sure you     * call super.actionPerformed if you care about receiving palette     * show/hide commands. This method is also set up to receive the     * DisplayPropertiesCmd, and will bring up the Inspector for the     * layer.     */    public void actionPerformed(ActionEvent ae) {        String command = ae.getActionCommand();        if (command == DisplayPaletteCmd) {            if (Debug.debugging("layer")) {                Debug.output(getName() + " displaying palette");            }            showPalette();        } else if (command == HidePaletteCmd) {            if (Debug.debugging("layer")) {                Debug.output(getName() + " hiding palette");            }            hidePalette();        } else if (command == DisplayPropertiesCmd) {            Inspector inspector = new Inspector();            inspector.inspectPropertyConsumer(this);        }    }    /**     * Handle Serialization a little bit better, replacing the I18n     * and BeanContextChildSupport.     *      * @param in     * @throws IOException     * @throws ClassNotFoundException     */    private void readObject(ObjectInputStream in) throws IOException,            ClassNotFoundException {        in.defaultReadObject();        i18n = Environment.getI18n();        beanContextChildSupport = new BeanContextChildSupport(this);    }    public Icon getIcon() {        return icon;    }    public void setIcon(Icon icon) {        this.icon = icon;    }    public boolean isAutoPalette() {        return autoPalette;    }    public void setAutoPalette(boolean autoPalette) {        this.autoPalette = autoPalette;    }    public float getMaxScale() {        return maxScale;    }    public void setMaxScale(float maxScale) {        this.maxScale = maxScale;    }    public float getMinScale() {        return minScale;    }    public void setMinScale(float minScale) {        this.minScale = minScale;    }}

⌨️ 快捷键说明

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