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

📄 netmapgraphicloader.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                String label = eventProps.getProperty(LABEL_FIELD);                if (label == null) {                    // This label misdirection is temporary...                    label = eventProps.getProperty(INDEX_FIELD);                }                String ip = eventProps.getProperty(IP_FIELD);                /*                 * float elevation =                 * LayerUtils.floatFromProperties(eventProps,                 * ELEVATION_FIELD, 0f);                 */                boolean isLocalhost = false;                if (ip != null && localhostIP != null) {                    isLocalhost = localhostIP.equals(ip);                    if (DEBUG) {                        Debug.output("NetMapGraphicLoader displaying a node running on the localhost: "                                + localhostIP);                    }                }                if (DEBUG) {                    Debug.output("Creating node (" + label + ")");                }                try {                    if (shape != ERROR_VALUE_INT) {                        node = nodeList.add(label, index, shape, menu, status);                        node.setLocalhost(isLocalhost);                    }                } catch (Exception e) {                    Debug.error("NMGL: error creating node");                }                setNodePositionFromEventProps(node, eventProps);            }        } else if (cmd.equals(NODE_OBJECT_STATUS)) {            if (index == ERROR_VALUE_INT) {                Debug.error("NMGL: error parsing object index for status update.");                return;            }            node = nodeList.get(index);            if (node != null) {                status = PropUtils.intFromProperties(eventProps,                        STATUS_FIELD,                        ERROR_VALUE_INT);                if (status != ERROR_VALUE_INT) {                    node.setStatus(status);                }            }        } else if (cmd.equals(LINK_OBJECT_STATUS)) {            if (index == ERROR_VALUE_INT) {                Debug.error("NMGL: error parsing line index for status update.");                return;            }            line = lineList.get(index);            if (line != null) {                status = PropUtils.intFromProperties(eventProps,                        STATUS_FIELD,                        ERROR_VALUE_INT);                if (status != ERROR_VALUE_INT) {                    line.setStatus(status);                }            }        } else if (cmd.equals(LINK_OBJECT)) {            if (index == ERROR_VALUE_INT) {                Debug.error("NMGL: error parsing line index for link.");                return;            }            line = lineList.get(index);            int shape = PropUtils.intFromProperties(eventProps,                    SHAPE_FIELD,                    ERROR_VALUE_INT);            if (shape == NODE_DELETE) {                lineList.del(index);            } else {                status = PropUtils.intFromProperties(eventProps,                        STATUS_FIELD,                        0);                int node1 = PropUtils.intFromProperties(eventProps,                        LINK_NODE1_FIELD,                        ERROR_VALUE_INT);                int node2 = PropUtils.intFromProperties(eventProps,                        LINK_NODE2_FIELD,                        ERROR_VALUE_INT);                if (node1 == ERROR_VALUE_INT || node2 == ERROR_VALUE_INT) {                    Debug.error("NMGL: error parsing node indexes for link");                    return;                }                Node n1 = nodeList.get(node1);                Node n2 = nodeList.get(node2);                if (n1 != null && n2 != null) {                    lineList.add(String.valueOf(index),                            index,                            shape,                            status,                            n1,                            n2);                } else {                    if (DEBUG) {                        Debug.output("NetMapGraphicLoader: can't create lobj, nodes are undefined");                    }                }            }        } else if (cmd.equals(REFRESH) || cmd.equals(UPDATE)) {            // manageGraphics();        } else if (cmd.equals(CLEAR)) {            if (nodeList != null) {                nodeList.flush();            }            if (lineList != null) {                lineList.flush();            }            // manageGraphics();        } else {            if (DEBUG) {                Debug.output("NMGL: received unused event: "                        + eventProps.toString());            }        }        manageGraphics();    }    /**     * Internal method used to create a single OMGraphicList from the     * NodeCache and the LineCache.     */    protected OMGraphicList getOMList() {        /*         * By creating a new list, we avoid         * ConcurrentModificationExceptions within the PlugInLayer,         * and within the GraphicLoaderPlugIn during generate().         */        omList = new OMGraphicList();        if (nodeList != null) {            Enumeration list = nodeList.elements();            while ((list != null) && list.hasMoreElements()) {                Node point = (Node) list.nextElement();                point.setMatted(point.isLocalhost());                omList.add(point);            }        }        if (lineList != null) {            Enumeration list = lineList.elements();            while ((list != null) && list.hasMoreElements()) {                Line line = (Line) list.nextElement();                if (line == null)                    continue;                line.setPos();                omList.add((OMLine) line);            }        }        if (DEBUG) {            int size = omList.size();            Debug.output("NMGL.getOMList(): created list with " + size                    + (size == 1 ? " graphic." : " graphics."));        }        return omList;    }    /**     * Called by the GraphicLoaderPlugIn, the GUI is provided from the     * NetMapConnector.     */    public Component getGUI() {        if (connector != null) {            return connector.getGUI();        } else            return null;    }    /**     * Needed to fill in a GUI with a receiver's name, to enable the     * user to send a graphic to a specific object. Should be a pretty     * name, suitable to let a user know what it is.     */    public String getName() {        return "NetMap";    }    /**     * The inherited AbstractGraphicLoader method, that sends the     * current OMGrapicList to the receiver.     */    public void manageGraphics() {        // receiver is inherited from        // com.bbn.openmap.graphicLoader.MMLGraphicLoader/AbstractGraphicLoader.        if (receiver != null) {            if (DEBUG) {                Debug.output("NetMapConnector.update: Updating graphics.");            }            receiver.setList(getOMList());        } else {            if (DEBUG) {                Debug.output("NetMapConnector.update: no receiver to notify.");            }        }    }    protected boolean toolTipUp = 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(java.awt.event.MouseEvent e) {        if (receiver instanceof PlugIn && omList != null) {            OMGraphic graphic = omList.getOMGraphicThatContains(e.getX(),                    e.getY());            String label = null;            if (graphic instanceof Node) {                label = ((Node) graphic).getLabel();                // } else if (graphic instanceof Line) {                // label = ((Line)graphic).getLabel();            }            if (receiver instanceof PlugIn) {                Component comp = ((PlugIn) receiver).getComponent();                if (comp instanceof Layer) {                    if (graphic != null && label != null) {                        ((Layer) comp).fireRequestToolTip("Node " + label);                        toolTipUp = true;                    } else if (toolTipUp) {                        ((Layer) comp).fireHideToolTip();                        toolTipUp = false;                    }                    return true;                }            }        }        return false;    }}

⌨️ 快捷键说明

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