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

📄 layer.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
     *      * @param cursor the cursor to use.     */    public void fireRequestCursor(java.awt.Cursor cursor) {        if (IDListeners != null) {            for (Iterator it = IDListeners.iterator(); it.hasNext();) {                ((InfoDisplayListener) it.next()).requestCursor(cursor);            }        } else if (Debug.debugging("layer")) {            Debug.output(getName()                    + "|Layer.fireRequestCursor(): no info request listener!");        }    }    /**     * Sends a request to the InfoDisplayListener to put the     * information in the InfoDisplay event in a dialog window.     *      * @param evt the InfoDisplayEvent holding the message to put into     *        the dialog window.     */    public void fireRequestMessage(InfoDisplayEvent evt) {        if (IDListeners != null) {            for (Iterator it = IDListeners.iterator(); it.hasNext();) {                ((InfoDisplayListener) it.next()).requestMessage(evt);            }        } else if (Debug.debugging("layer")) {            Debug.output(getName()                    + "|Layer.fireRequestMessage(): no info request listener!");        }    }    /**     * Sends a request to the InfoDisplayListener to display the     * information in a dialog window. The InfoDisplayEvent is created     * here, and the URL location is put inside it.     *      * @param message the message to put in the dialog window.     */    public void fireRequestMessage(String message) {        fireRequestMessage(new InfoDisplayEvent(this, message));    }    /**     * Request to show the tool tips on the map.     *      * @param me MouseEvent location for the tool tip.     * @param tip string to display.     * @deprecated use fireRequestToolTip(String tip) instead.     */    public void fireRequestToolTip(MouseEvent me, String tip) {        fireRequestToolTip(new InfoDisplayEvent(this, tip));    }    /**     * Request to show the tool tips on the map.     *      * @param tip string to display.     */    public void fireRequestToolTip(String tip) {        fireRequestToolTip(new InfoDisplayEvent(this, tip));    }    /**     * Request to hide the tool tips on the map.     *      * @param me MouseEvent location.     * @deprecated use fireHideToolTip() instead.     */    public void fireHideToolTip(MouseEvent me) {        fireRequestToolTip((InfoDisplayEvent) null);    }    /**     * Request to hide the tool tips on the map.     */    public void fireHideToolTip() {        fireRequestToolTip((InfoDisplayEvent) null);    }    /**     * Fire off a Tool Tip request to the InfoDisplayListeners. If the     * InfoDisplayEvent is null, then a requestHideToolTip will be     * fired.     *      * @deprecated use fireHideToolTip(InfoDisplayEvent) instead.     */    public void fireRequestToolTip(MouseEvent me, InfoDisplayEvent event) {        fireRequestToolTip(event);    }    /**     * Fire off a Tool Tip request to the InfoDisplayListeners. If the     * InfoDisplayEvent is null, then a requestHideToolTip will be     * fired.     */    public void fireRequestToolTip(InfoDisplayEvent event) {        if (IDListeners != null) {            for (Iterator it = IDListeners.iterator(); it.hasNext();) {                if (event != null) {                    ((InfoDisplayListener) it.next()).requestShowToolTip(event);                } else {                    ((InfoDisplayListener) it.next()).requestHideToolTip();                }            }        } else if (Debug.debugging("layer")) {            Debug.output(getName()                    + "|Layer.fireRequestShowToolTip(): no info request listener!");        }    }    // /////////////////////////////////////////////////    // LayerStatus Handling Setup and Firing    /**     * Adds a listener for <code>LayerStatusEvent</code>s.     *      * @param aLayerStatusListener LayerStatusListener     */    public synchronized void addLayerStatusListener(                                                    LayerStatusListener aLayerStatusListener) {        if (lsListeners == null) {            lsListeners = new ListenerSupport(this);        }        lsListeners.addListener(aLayerStatusListener);    }    /**     * Removes a LayerStatusListene from this Layer.     *      * @param aLayerStatusListener the listener to remove     */    public synchronized void removeLayerStatusListener(                                                       LayerStatusListener aLayerStatusListener) {        if (lsListeners != null) {            lsListeners.removeListener(aLayerStatusListener);        }    }    /**     * Sends a status update to the LayerStatusListener.     *      * @param evt LayerStatusEvent     */    public void fireStatusUpdate(LayerStatusEvent evt) {        // AWTAvailable conditional removed, not used, not useful.        if (lsListeners != null) {            for (Iterator it = lsListeners.iterator(); it.hasNext();) {                ((LayerStatusListener) it.next()).updateLayerStatus(evt);            }        } else if (Debug.debugging("layer")) {            Debug.output(getName()                    + "|Layer.fireStatusUpdate(): no LayerStatusListeners!");        }    }    /**     * Sends a status update to the LayerStatusListener.     *      * @param status the new status     */    public void fireStatusUpdate(int status) {        fireStatusUpdate(new LayerStatusEvent(this, status));    }    /**     * Repaint the layer. If you are using BufferedMapBean for your     * application, WE STRONGLY RECOMMEND THAT YOU DO NOT OVERRIDE     * THIS METHOD. This method marks the layer buffer so that it will     * be refreshed. If you override this method, and don't call     * super.repaint(), the layers will not be repainted.     */    public void repaint(long tm, int x, int y, int width, int height) {        Component p = getParent();        if (p instanceof MapBean) {            ((MapBean) p).setBufferDirty(true);            if (Debug.debugging("basic")) {                Debug.output(getName() + "|Layer: repaint(tm=" + tm + ", x="                        + x + ", y=" + y + ", width=" + width + ", height="                        + height + ")");            }            // How dangerous is this? Let the MapBean manage the            // repaint call? Seems to work OK, and lets the buffered            // MapBeans work better when they are embedded in other            // components. It's this call here that makes the            // BufferedLayer work right.            // This repaint request has been changed to call a            // specific            // method on the MapBean, which includes the layer making            // the request. This is a hook for a policy object in the            // MapBean to make a decision on whether to honor the            // request, or to handle it in a different way if the            // environment dictates that should happen.            // ((MapBean)p).repaint(); to ->            ((MapBean) p).repaint(this);        } else if (p != null) {            p.repaint(tm, x, y, width, height);        } else {            super.repaint(tm, x, y, width, height);        }    }    /**     * This method is here to provide a default action for Layers as     * they act as a ProjectionPainter. Normally, ProjectionPainters     * are expected to receive the projection, gather/create     * OMGraphics that apply to the projection, and render them into     * the Graphics provided. This is supposed to be done in the same     * thread that calls this function, so the caller knows that when     * this method returns, everything that the ProjectionPainter     * needed to do is complete.     * <P>     * If the layer doesn't override this method, then the     * paint(Graphics) method will be called.     *      * @param proj Projection of the map.     * @param g java.awt.Graphics to draw into.     */    public void renderDataForProjection(Projection proj, Graphics g) {        if (!isProjectionOK(proj)) {            return;        }        paint(g);    }    /**     * Method that responds whether the Layer should render on the     * map, given a particular projection. The method currently just     * tests the projection's scale against the min and max values set     * on the layer.     *      * @param proj The projection to test against.     * @return true if OK.     */    public boolean isProjectionOK(Projection proj) {        return !(proj == null || proj.getScale() < minScale || proj.getScale() > maxScale);    }    /**     * This method is called when the layer is added to the MapBean     *      * @param cont Container     */    public void added(Container cont) {}    /**     * This method is called after the layer is removed from the     * MapBean and when the projection changes. We recommend that     * Layers override this method and nullify memory-intensive     * variables.     *      * @param cont Container     */    public void removed(Container cont) {}    /**     * Part of a layer hack to notify the component listener when the     * component is hidden. These components don't receive the     * ComponentHidden notification. Remove when it works.     */    protected ListenerSupport localHackList;    /**     * Part of a layer hack to notify the component listener when the     * component is hidden. These components don't receive the     * ComponentHidden notification. Remove when it works. Set to     * false to test.     */    protected boolean doHack = true;    /**     * Part of a layer hack to notify the component listener when the     * component is hidden. These components don't receive the     * ComponentHidden notification. Remove when it works.     */    public void setVisible(boolean show) {        super.setVisible(show);        if (doHack && !show) {            notifyHideHack();        }    }    /**     * Part of a layer hack to notify the component listener when the     * component is hidden. These components don't receive the     * ComponentHidden notification. Remove when it works.     */    public void addComponentListener(ComponentListener cl) {        super.addComponentListener(cl);        if (localHackList == null) {            localHackList = new ListenerSupport(this);        }        localHackList.addListener(cl);    }    /**     * Part of a layer hack to notify the component listener when the     * component is hidden. These components don't receive the     * ComponentHidden notification. Remove when it works.     */    public void removeComponentListener(ComponentListener cl) {        super.removeComponentListener(cl);        if (localHackList != null) {            localHackList.removeListener(cl);        }    }    /**     * Part of a layer hack to notify the component listener when the     * component is hidden. These components don't receive the     * ComponentHidden notification. Remove when it works.     */    public void notifyHideHack() {        if (localHackList == null) {            return;        }        ComponentEvent ce = new ComponentEvent(this, ComponentEvent.COMPONENT_HIDDEN);        for (Iterator it = localHackList.iterator(); it.hasNext();) {            ((ComponentListener) it.next()).componentHidden(ce);        }    }    /**     * Set whether the Layer should be added to the BeanContext.     */    public void setAddToBeanContext(boolean set) {        addToBeanContext = set;    }    /**     * Set whether the Layer should be added to the BeanContext.     */    public boolean getAddToBeanContext() {        return addToBeanContext;    }    /**     * Mark the layer as one that should be considered a background     * layer. What that means is up to the MapBean or application.     */    public void setAddAsBackground(boolean set) {        addAsBackground = set;    }    /**     * Check to see if the layer is marked as one that should be     * considered a background layer. What that means is up to the     * MapBean or application.     *      * @return true if layer is a background layer.     */    public boolean getAddAsBackground() {        return addAsBackground;    }    /**     * Mark the layer as removable, or one that can be deleted from     * the application. What that means is up to the LayerHandler or     * other application components. This is the misspelled version of     * the method, it's going away. Really.     *      * @deprecated setRemovable() should be used instead.     */    public void setRemoveable(boolean set) {        setRemovable(set);    }    /**     * Check to see if the layer is marked as one that can be removed     * from an application. This is the misspelled version of the     * method, it's going away. Really.     *      * @deprecated isRemovable() should be used instead.     * @return true if layer should be allowed to be deleted.     */    public boolean isRemoveable() {        return isRemovable();    }    /**     * Mark the layer as removable, or one that can be deleted from     * the application. What that means is up to the LayerHandler or     * other application components.     */    public void setRemovable(boolean set) {        removable = set;    }    /**     * Check to see if the layer is marked as one that can be removed     * from an application.     *      * @return true if layer should be allowed to be deleted.     */    public boolean isRemovable() {        return removable;    }

⌨️ 快捷键说明

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