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

📄 link.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            if (delimiter == GRAPHICS_HEADER) {                if (layer != null) {                    graphicList = new LinkGraphicList(this, graphics, layer.getProjection(), generator);                } else {                    graphicList = new LinkGraphicList(this, graphics, proj, generator);                }                delimiter = graphicList.getLinkStatus();            } else if (delimiter == ACTIONS_HEADER) {                actionList = new LinkActionList(this, layer, proj, generator);                delimiter = actionList.getLinkStatus();            } else if (delimiter == GUI_HEADER) {                guiList = new LinkGUIList(this);                delimiter = guiList.getLinkStatus();            } else if (delimiter == CLOSE_LINK_HEADER) {                closeLink = true;            } else if (delimiter == SHUTDOWN_HEADER) {                Debug.message("link", "Link.received command to exit");                if (obeyCommandToExit) {                    System.exit(0);                }            } else if (delimiter == HUH_HEADER) {                delimiter = readDelimiter(true);            } else if (delimiter == MAP_REQUEST_HEADER) {                mapRequest = new LinkMapRequest(this);                delimiter = mapRequest.getLinkStatus();            } else if (delimiter == ACTION_REQUEST_HEADER) {                actionRequest = new LinkActionRequest(this);                delimiter = actionRequest.getLinkStatus();            } else if (delimiter == GUI_REQUEST_HEADER) {                guiRequest = new LinkGUIRequest(this);                delimiter = guiRequest.getLinkStatus();            } else if (delimiter == PING_REQUEST_HEADER) {                start(PING_RESPONSE_HEADER);                end(END_TOTAL);                delimiter = readDelimiter(false);            }            if (delimiter == END_TOTAL) {                return;            }        }    }    public void setObeyCommandToExit(boolean value) {        obeyCommandToExit = value;    }    public boolean getAcceptCommandToExit() {        return obeyCommandToExit;    }    /**     * After a readAndParse() has been called on a link, this can be     * called to retrieve a graphics request, if one was sent.     *      * @return LinkMapRequest containing the request.     */    public LinkMapRequest getMapRequest() {        return mapRequest;    }    /**     * After a readAndParse() has been called on a link, this can be     * called to retrieve graphics in an LinkOMGraphicList, if any     * graphics were sent.     *      * @return GraphicLinkRsponse containing the information. If no     *         graphics were sent the list will be empty.     */    public LinkGraphicList getGraphicList() {        return graphicList;    }    /**     * After a readAndParse() has been called on a link, this can be     * called to retrieve a gesture notification/request, if one was     * sent.     *      * @return LinkActionRequest containing the request.     */    public LinkActionRequest getActionRequest() {        return actionRequest;    }    /**     * After a readAndParse() has been called on a link, this can be     * called to retrieve the gesture response.     *      * @return LinkActionList containing the information.     */    public LinkActionList getActionList() {        return actionList;    }    /**     * After a readAndParse() has been called on a link, this can be     * called to retrieve a gesture notification/request, if one was     * sent.     *      * @return LinkGUIRequest containing the request.     */    public LinkGUIRequest getGUIRequest() {        return guiRequest;    }    /**     * After a readAndParse() has been called on a link, this can be     * called to retrieve the GUI response, if any GUI components were     * sent.     *       */    public LinkGUIList getGUIList() {        return guiList;    }    /**     * readDelimiter is a function designed to read a header string     * off the data input stream in the Link object. It expects that     * the next byte off the link will be a ' <' in the stream, and     * then reads through the stream until it finds the '>' expected     * at the end of the string. It will also return a string version     * of END_TOTAL or END_SECTION if it is encountered instead. If     * desired, an intern version of the string is returned.     *      * @param returnString if true, an intern String version of the     *        characters is returned.     * @throws IOException     * @throws ArrayIndexOutOfBoundsException     */    protected String readDelimiter(boolean returnString) throws IOException,            ArrayIndexOutOfBoundsException {        String ret = END_TOTAL;        char END_TOTAL_CHAR = END_TOTAL.charAt(0);        char END_SECTION_CHAR = END_SECTION.charAt(0);        char c = (char) dis.readByte();        // NOTE: possibility of early exits here...        if (c == END_TOTAL_CHAR) {            Debug.message("link", "Link|readDelimiter: Found END_TOTAL");            return END_TOTAL;        } else if (c == END_SECTION_CHAR) {            Debug.message("link", "Link|readDelimiter: Found END_SECTION");            return END_SECTION;        } else if (c != '<') {            if (Debug.debugging("link")) {                System.out.println("Link|readDelimiter: unexpected protocol data read '"                        + c + "'");            }            throw new IOException("readDelimiter: unexpected protocol data read.");        }        // The byte read does indeed equal '<'        int charCount = 0;        // c should == '<'        charArray[charCount++] = c;        // Get the rest of the header information        c = (char) dis.readByte();        while (c != '>' && charCount < MAX_HEADER_LENGTH - 1) {            charArray[charCount++] = c;            c = (char) dis.readByte();        }        // c should == '>' or uh-oh - too many characters between        // them. Exit with a faulty return if this is the case.        if (c != '>') {            throw new IOException("readDelimiter: header is too long.");        }        charArray[charCount++] = c;        // OK, got it - return string        if (returnString) {            ret = new String(charArray, 0, charCount).intern();        } else {            ret = "";        }        return ret;    }    /**     * Other threads can check to see if the link is in use.     *      * @return true if link in use and unavailable.     */    public boolean isLocked() {        return locked;    }    /**     * Set the lock. Should only be called in a synchronized block of     * code, where you have control over the link.     *      * @param set true if the lock should be turned on, false if the     *        link should be released.     */    public synchronized boolean setLocked(boolean set) {        if (set == true) {            if (locked == true) {                // The lock was NOT set for the caller - unsuccessful.                return false;            } else {                locked = true;                // The lock was set for the caller, successfully.                return true;            }        } else {            locked = set;            // The state was set to false, successfully.            return true;        }    }    /**     * This method is provided for those who want to optimize how they     * write the graphical objects to the output stream. Look in the     * Link <graphics>API to find out the order of the pieces for     * each graphic type. Not recommended for the faint of heart.     */    public DataOutput getDOS() {        return dos;    }    /**     * This method complements getDOS().     */    public DataInput getDIS() {        return dis;    }    /**     * Returns the number of bytes written since the last     * clearBytesWritten() call.     */    public int getBytesWritten() {        return dos.size();    }    /**     * Reset the bytes written count to 0.     *      * @return the old byte count     */    public int clearBytesWritten() {        return dos.clearWritten();    }}

⌨️ 快捷键说明

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