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

📄 omdrawingtool.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    public void setMouseDelegator(MouseDelegator md) {        mouseDelegator = md;    }    /**     * Get the MouseDelegator used to receive mouse events.     */    public MouseDelegator getMouseDelegator() {        return mouseDelegator;    }    public void setCursor(java.awt.Cursor cursor) {        if (canvas != null) {            canvas.setCursor(cursor);        }    }    public java.awt.Cursor getCursor() {        if (canvas != null) {            return canvas.getCursor();        } else {            return null;        }    }    /**     * Set the JComponent this thing is directing events for. If the     * MouseDelegator is not set, the Canvas is contacted to get     * MouseEvents from. Within the BeanContext, the OMDrawingTool     * looks for MapBeans to use as canvases.     */    public void setCanvas(JComponent can) {        canvas = can;    }    /**     * Get the JComponent this thing is directing events for.     */    public JComponent getCanvas() {        return canvas;    }    /**     * Set whether the Tool's face should be used. The subclasses to     * this class should either remove all components from its face,     * or make its face invisible if this is set to false.     */    public void setUseAsTool(boolean value) {        super.setUseAsTool(value);    }    /**     * Called from the findAndInit(Iterator) method, when objects are     * added to the MapHandler. so the OMDrawingTool can hook up with     * what it needs. An InformationDelegator is used to provide map     * coordinates of the mouse movements. The MouseDelegator is used     * to intercept MouseEvents when the OMDrawingTool is activated.     * The MapBean is used to get mouse events if the MouseDelegator     * isn't loaded, and is also used to help out with smooth     * repaints() in general. EditToolLoaders are looked for to load     * into the OMDrawingTool to handler different graphic requests.     */    public void findAndInit(Object someObj) {        if (someObj instanceof InformationDelegator) {            if (DEBUG)                Debug.output("DrawingTool: found InformationDelegator");            if (dtmm != null) {                dtmm.setInfoDelegator((InformationDelegator) someObj);            }            setInformationDelegator((InformationDelegator) someObj);        }        if (someObj instanceof MouseDelegator) {            if (DEBUG)                Debug.output("DrawingTool: found MouseDelegator.");            setMouseDelegator((MouseDelegator) someObj);        }        if (someObj instanceof MapBean) {            if (DEBUG)                Debug.output("DrawingTool: found MapBean.");            setCanvas((JComponent) someObj);        }        if (someObj instanceof EditToolLoader) {            if (DEBUG)                Debug.output("DrawingTool: found EditToolLoader: "                        + someObj.getClass().getName());            addLoader((EditToolLoader) someObj);        }    }    /**     * Called by childrenRemoved, it provides a good method for     * handling any object you may want to take away from the     * OMDrawingTool. The OMDrawingTool figures out if it should     * disconnect itseld from the object.     */    public void findAndUndo(Object someObj) {        if (someObj == getInformationDelegator()) {            if (dtmm != null                    && dtmm.getInfoDelegator() == (InformationDelegator) someObj) {                dtmm.setInfoDelegator(null);            }            setInformationDelegator(null);        }        if (someObj == getMouseDelegator()) {            setMouseDelegator(null);        }        if (someObj == getCanvas()) {            setCanvas(null);        }        if (someObj instanceof EditToolLoader) {            removeLoader((EditToolLoader) someObj);        }    }    // ////////////// end BeanContext stuff    /**     * Display the palette.     */    public void showPalette() {        Debug.message("drawingtool", "OMDrawingTool.showPalette()");        resetGUIWhenDeactivated = true;        getGUI(); // resets the gui.        /*         * This repaint needs to be here because sometimes the GUI         * doesn't update on the revalidate being called in the GUI.         */        repaint();        // Should only be visible if the tool isn't being used as a        // tool, which means that it's being held by something else,        // or if it is a tool and the SHOW_GUI flag is set.        boolean shouldBeVisible = !getUseAsTool()                || (isMask(SHOW_GUI_BEHAVIOR_MASK) && getUseAsTool());        setVisible(shouldBeVisible);    }    /**     * Hide the OMDrawingTool palette.     */    public void hidePalette() {        Debug.message("drawingtool", "OMDrawingTool.hidePalette()");        setVisible(visibleWhenInactive);        WindowSupport ws = getWindowSupport();        if (ws != null) {            ws.killWindow();        }    }    public void showInWindow() {        if (!getUseAsTool() && getWindowSupport() == null) {            setWindowSupport(new WindowSupport(getGUI(), i18n.get(OMDrawingTool.class,                    "drawingtool",                    "Drawing Tool")));        }        WindowSupport ws = getWindowSupport();        if (ws != null && !getUseAsTool()) {            MapHandler mh = (MapHandler) getBeanContext();            Frame frame = null;            int xoffset = 0;            int yoffset = 0;            if (mh != null) {                frame = (Frame) mh.get(java.awt.Frame.class);                if (frame != null) {                    xoffset = frame.getX();                    yoffset = frame.getY();                }            }            ws.displayInWindow(frame,                    windowx + xoffset,                    windowy + yoffset,                    -1,                    -1);        } else {            Debug.output("OMDrawingTool.showPalette(): NOT showing palette, ws == null:"                    + (ws == null) + ", used as tool:" + getUseAsTool());        }    }    /**     * A integer that is looked at internally, bitwise, to determine     * different behaviors. If you care about specific behavior of the     * DrawingTool, you should set this to what you want to make sure     * the tool acts the way you want.     */    public void setBehaviorMask(int mask) {        behaviorMask = mask;    }    /**     * A integer that is looked at internally, bitwise, to determine     * different behaviors.     */    public int getBehaviorMask() {        return behaviorMask;    }    /**     * Set the behavior mask to the default.     */    public void resetBehaviorMask() {        behaviorMask = DEFAULT_BEHAVIOR_MASK;    }    /**     * Set a particular mask bit in the internal value.     *      * @param mask an OMDrawingTool behavior mask.     * @return the changed integer value.     */    public int setMask(int mask) {        behaviorMask = OMAction.setMask(behaviorMask, mask);        return behaviorMask;    }    /**     * Unset a particular mask bit in the internal value.     *      * @param mask an OMDrawingTool behavior mask.     * @return the changed integer value.     */    public int unsetMask(int mask) {        behaviorMask = OMAction.unsetMask(behaviorMask, mask);        return behaviorMask;    }    /**     * Return whether a mask value is set in the internal value.     *      * @param mask an OMDrawingTool behavior mask.     * @return whether the value bit is set on the internal value.     */    public boolean isMask(int mask) {        return OMAction.isMask(behaviorMask, mask);    }    /**     * PropertyChangeListener method. If DrawingAttribute parameters     * change, this method is called, and we update the OMGraphic     * parameters.     */    public void propertyChange(PropertyChangeEvent pce) {        Object source = pce.getSource();        if (source instanceof DrawingAttributes && currentEditable != null) {            graphicAttributes.setTo(currentEditable.getGraphic());            if (projection != null) {                currentEditable.regenerate(projection);            }            if (canvas != null) {                canvas.repaint();            }        }    }    /**     * Used to hold the last thing displayed to the remarks window.     */    String lastRemarks = "";    JPopupMenu popup = null;    int windowx, windowy;    /**     * This is a EOMGListener method, and gets called by the     * EditableOMGraphic when something changes.     */    public void eomgChanged(EOMGEvent event) {        if (Debug.debugging("drawingtooldetail")) {            Debug.output("OMDrawingTool.eomgChanged()");        }        Cursor cursor = event.getCursor();        if (cursor != null) {            setCursor(cursor);        }        // We might have used the InformationDelgator to put the        // comments        // in the info line, but that can't work, because we are        // already putting the lat/lon info on the info line.        // Updated, 4.6 - now that the InformationDelegator has new        // places for coordinate information and map object        // information, we can sent the info there, and it looks OK.        String message = event.getMessage();        if (message != null && !message.equals(lastRemarks)) {            lastRemarks = message;            setRemarks(message);        }        if (event.shouldShowGUI() && isMask(ALT_POPUP_BEHAVIOR_MASK)) {            if (DEBUG)                Debug.output("OMDrawingTool.eomgChanged(): try for menu.");            MouseEvent me = event.getMouseEvent();            // While we're here, get a good place for the window in            // case we need to put it up later.            if (currentEditable != null) {                currentEditable.getStateMachine().setSelected();                currentEditable.redraw(me, true);                Shape ces = currentEditable.getGraphic().getShape();                if (ces != null) {                    Rectangle rect = ces.getBounds();                    windowx = (int) rect.getX();                    windowy = (int) rect.getY() - 50;                }            }            /**             * Let's see if we should bring up pop-up menu with all             * sorts of lovely options - if the right mouse key was             * pressed, or if the ctrl key was pressed with the mouse             * button being released, display the option menu.             * Otherwise, just get ready to end.             */            doPopup(me.getX(), me.getY(), null);        } else if (event.shouldDeactivate()) {            if (DEBUG) {                Debug.output("OMDrawingTool.eomgChanged(): omdt being told to deactivate");            }            if (isMask(USE_POPUP_BEHAVIOR_MASK) && !getUseAsTool()) {                EditableOMGraphic eomg = getCurrentEditable();                if (eomg != null) {                    java.awt.Shape shape = eomg.getGraphic().getShape();                    Rectangle rect = shape.getBounds();                    Vector vec = new Vector();                    vec.add(new JSeparator());                    JMenuItem done = new JMenuItem("Done");                    done.addActionListener(new ActionListener() {                        public void actionPerformed(ActionEvent ae) {                            deactivate();                        }                    });                    vec.add(done);                    if (!doPopup((int) (rect.getX() + rect.getWidth()),                            (int) (rect.getY() + rect.getHeight()),                            vec)) {                

⌨️ 快捷键说明

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