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

📄 scalefilterlayer.java

📁 OpenMap是一个基于JavaBeansTM的开发工具包。利用OpenMap你就能够快速构建用于访问legacy数据库的应用程序与applets。OpenMap提供了允许用户查看和操作地理空间信息的
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }    /**     * Renders the scale-appropriate layer on the map.     *      * @param g a graphics context     */    public void paint(Graphics g) {        getAppropriateLayer().paint(g);        fireStatusUpdate(LayerStatusEvent.FINISH_WORKING);    }    /**     * Try to handle receiving LayerStatusEvents from child layers. May not     * always work, depending on what thread sends/receives this event - usually     * in the Swing thread, and the GUI can't always be updated as expected.     *      * @param evt LayerStatusEvent     */    public void updateLayerStatus(LayerStatusEvent evt) {        fireStatusUpdate(evt);    }    protected JPanel panel = null;    protected JTabbedPane tabs = null;    /**     * Get the GUI (palettes) for the layers. The BufferedLayer actually creates     * a JTabbedPane holding the palettes for all of its layers, and also has a     * pane for itself that provides visibility control for the group layers.     */    public Component getGUI() {        if (panel == null) {            Iterator it = getLayers().iterator();            panel = new JPanel();            tabs = new JTabbedPane();            // bfPanel still needs controls for controlling scales,            // etc, showing which one is showing, etc., as well as            // some indication as which layer is currently active.            JPanel bfPanel = new JPanel();            GridBagLayout gridbag = new GridBagLayout();            GridBagConstraints c = new GridBagConstraints();            bfPanel.setLayout(gridbag);            tabs.addTab("Scale Filter Controls", bfPanel);            JButton gotoButton = new JButton("Go to Active Layer Tab");            gotoButton.addActionListener(new ActionListener() {                public void actionPerformed(ActionEvent ae) {                    setPaletteTab(targetIndex);                }            });            c.gridy = 0;            gridbag.setConstraints(gotoButton, c);            bfPanel.add(gotoButton);            while (it.hasNext()) {                Layer layer = (Layer) it.next();                Component layerGUI = layer.getGUI();                if (layerGUI != null) {                    tabs.addTab(layer.getName(), layerGUI);                } else {                    tabs.addTab(layer.getName(), getEmptyGUIFiller(layer));                }            }            panel.add(tabs);        }        setPaletteTab(targetIndex);        return panel;    }    public Component getEmptyGUIFiller(Layer layer) {        GridBagLayout gridbag = new GridBagLayout();        GridBagConstraints c = new GridBagConstraints();        JPanel panel = new JPanel();        panel.setLayout(gridbag);        JLabel label = new JLabel("No properties available for");        JLabel label2 = new JLabel("the " + layer.getName() + ".");        c.gridwidth = GridBagConstraints.REMAINDER;        gridbag.setConstraints(label, c);        gridbag.setConstraints(label2, c);        panel.add(label);        panel.add(label2);        return panel;    }    protected void setPaletteTab(int layerIndex) {        Vector layers = getLayers();        if (layers.size() > layerIndex && tabs != null                && layerIndex < tabs.getTabCount()) {            // +1 because the first tab is the ScaleFilterLayer tab            tabs.setSelectedIndex(layerIndex + 1);        }    }    // //////////////////////////////    // InfoDisplayListener Methods    // //////////////////////////////    /**     * Request to have a URL displayed in a Browser.     *      * @param event InfoDisplayEvent     */    public void requestURL(InfoDisplayEvent event) {        fireRequestURL(new InfoDisplayEvent(this, event.getInformation()));    }    /**     * Request to have a message displayed in a dialog window.     *      * @param event InfoDisplayEvent     */    public void requestMessage(InfoDisplayEvent event) {        fireRequestMessage(new InfoDisplayEvent(this, event.getInformation()));    }    /**     * Request to have an information line displayed in an application status     * window.     *      * @param event InfoDisplayEvent     */    public void requestInfoLine(InfoDisplayEvent event) {        fireRequestInfoLine(new InfoDisplayEvent(this, event.getInformation()));    }    /**     * Request that plain text or html text be displayed in a browser.     *      * @param event InfoDisplayEvent     */    public void requestBrowserContent(InfoDisplayEvent event) {        fireRequestBrowserContent(new InfoDisplayEvent(this, event.getInformation()));    }    /**     * Request that the MapBean cursor be set to a certain type.     *      * @param cursor java.awt.Cursor to set over the MapBean.     */    public void requestCursor(java.awt.Cursor cursor) {        fireRequestCursor(cursor);    }    /**     * Request a tool tip be shown.     *      * @param event The InfoDisplayEvent containing the text and requestor.     */    public void requestShowToolTip(InfoDisplayEvent event) {        fireRequestToolTip(new InfoDisplayEvent(this, event.getInformation()));    }    /**     * Request a tool tip be hidden.     */    public void requestHideToolTip() {        fireHideToolTip();    }    /**     * Try to handle mouse events for the current layer.     */    public synchronized MapMouseListener getMapMouseListener() {        return this;    }    /** The current active mouse mode ID. */    protected String mmID = null;    /**     * Flag to specify that the current layer wants events from the current     * active mouse mode.     */    protected boolean coolMM = false;    /**     * The current MapMouseListener from the currently appropriate layer.     */    protected MapMouseListener clmml = null; // current layer map    // mouse listener    /**     * Set the coolMM flag, whenever the scale-appropriate layer changes, or if     * the active mouse mode changes.     */    public synchronized boolean checkMouseMode() {        // check the current MouseMode with the current layer        coolMM = false;        Layer layer = getAppropriateLayer();        MapMouseListener mml = layer.getMapMouseListener();        setCurrentLayerMapMouseListener(mml);        if (mml != null) {            String[] mmsl = mml.getMouseModeServiceList();            for (int i = 0; i < mmsl.length; i++) {                if (mmsl[i].intern() == mmID) {                    coolMM = true;                    break;                }            }        }        return coolMM;    }    /**     * Pre-set the MapMouseListener to received events if the current layer     * wants them.     */    public void setCurrentLayerMapMouseListener(MapMouseListener mml) {        clmml = mml;    }    /**     * Get the MapMouseListener to received events if the current layer wants     * them. May be null, but coolMM should be false in that case.     */    public MapMouseListener getCurrentLayerMapMouseListener() {        return clmml;    }    /**     * Listen for changes to the active mouse mode and for any changes to the     * list of available mouse modes     */    public void propertyChange(PropertyChangeEvent evt) {        if (evt.getPropertyName() == MouseDelegator.ActiveModeProperty) {            mmID = ((MapMouseMode) evt.getNewValue()).getID().intern();            checkMouseMode();        }    }    /**     * Return a list of the modes that are interesting to the MapMouseListener.     * The source MouseEvents will only get sent to the MapMouseListener if the     * mode is set to one that the listener is interested in. Layers interested     * in receiving events should register for receiving events in "select"     * mode: <code>     * <pre>     * return new String[] { SelectMouseMode.modeID };     * </pre>     * <code>     * @return String[] of modeID's     * @see NavMouseMode#modeID     * @see SelectMouseMode#modeID     * @see NullMouseMode#modeID     */    public String[] getMouseModeServiceList() {        HashSet mmsl = new HashSet();        Iterator it = getLayers().iterator();        while (it.hasNext()) {            Layer l = (Layer) it.next();            MapMouseListener mml = l.getMapMouseListener();            if (mml != null) {                String[] llist = mml.getMouseModeServiceList();                for (int i = 0; i < llist.length; i++) {                    mmsl.add(llist[i].intern());                }            }        }        Object[] objs = mmsl.toArray();        String[] rets = new String[objs.length];        for (int i = 0; i < rets.length; i++) {            rets[i] = (String) objs[i];        }        return rets;    }    // Mouse Listener events    // //////////////////////    /**     * Invoked when a mouse button has been pressed on a component.     *      * @param e MouseEvent     * @return true if the listener was able to process the event.     */    public boolean mousePressed(MouseEvent e) {        if (coolMM) {            return getCurrentLayerMapMouseListener().mousePressed(e);        } else {            return false;        }    }    /**     * Invoked when a mouse button has been released on a component.     *      * @param e MouseEvent     * @return true if the listener was able to process the event.     */    public boolean mouseReleased(MouseEvent e) {        if (coolMM) {            return getCurrentLayerMapMouseListener().mouseReleased(e);        } else {            return false;        }    }    /**     * Invoked when the mouse has been clicked on a component. The listener will     * receive this event if it successfully processed     * <code>mousePressed()</code>, or if no other listener processes the     * event. If the listener successfully processes <code>mouseClicked()</code>,     * then it will receive the next <code>mouseClicked()</code> notifications     * that have a click count greater than one.     * <p>     *      * @param e MouseEvent     * @return true if the listener was able to process the event.     */    public boolean mouseClicked(MouseEvent e) {        if (coolMM) {            return getCurrentLayerMapMouseListener().mouseClicked(e);        } else {            return false;        }    }    /**     * Invoked when the mouse enters a component.     *      * @param e MouseEvent     */    public void mouseEntered(MouseEvent e) {        if (coolMM) {            getCurrentLayerMapMouseListener().mouseEntered(e);        }    }    /**     * Invoked when the mouse exits a component.     *      * @param e MouseEvent     */    public void mouseExited(MouseEvent e) {        if (coolMM) {            getCurrentLayerMapMouseListener().mouseExited(e);        }    }    // Mouse Motion Listener events    // /////////////////////////////    /**     * Invoked when a mouse button is pressed on a component and then dragged.     * The listener will receive these events if it successfully processes     * mousePressed(), or if no other listener processes the event.     *      * @param e MouseEvent     * @return true if the listener was able to process the event.     */    public boolean mouseDragged(MouseEvent e) {        if (coolMM) {            return getCurrentLayerMapMouseListener().mouseDragged(e);        } else {            return false;        }    }    /**     * Invoked when the mouse button has been moved on a component (with no     * buttons down).     *      * @param e MouseEvent     * @return true if the listener was able to process the event.     */    public boolean mouseMoved(MouseEvent e) {        if (coolMM) {            return getCurrentLayerMapMouseListener().mouseMoved(e);        } else {            return false;        }    }    /**     * Handle a mouse cursor moving without the button being pressed. This event     * is intended to tell the listener that there was a mouse movement, but     * that the event was consumed by another layer. This will allow a mouse     * listener to clean up actions that might have happened because of another     * motion event response.     */    public void mouseMoved() {        if (coolMM) {            getCurrentLayerMapMouseListener().mouseMoved();        }    }    /** Method for BeanContextChild interface. */    public void setBeanContext(BeanContext in_bc) throws PropertyVetoException {        for (Iterator it = getLayers().iterator(); it.hasNext(); ((Layer) it.next()).connectToBeanContext(in_bc)) {            // You don't actually want to add the layer to the            // BeanContext, because then the LayerHandler will pick it            // up and add it to the main list of layers.        }        super.setBeanContext(in_bc);    }    /**     * MapHandler child methods, passing found objects to child layers.     */    public void findAndInit(Object obj) {        if (obj instanceof MouseDelegator) {            ((MouseDelegator) obj).addPropertyChangeListener(this);        }        for (Iterator it = getLayers().iterator(); it.hasNext(); ((Layer) it.next()).findAndInit(obj)) {        }    }    /**     * MapHandler child methods, passing removed objects to child layers.     */    public void findAndUndo(Object obj) {        if (obj instanceof MouseDelegator) {            ((MouseDelegator) obj).removePropertyChangeListener(this);        }        for (Iterator it = getLayers().iterator(); it.hasNext(); ((Layer) it.next()).findAndUndo(obj)) {        }    }}

⌨️ 快捷键说明

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