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

📄 dominputcapsule.java

📁 java 3d game jme 工程开发源代码
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
            throw ex;        }        currentElem = (Element) currentElem.getParentNode();        return ret;    }    public long readLong(String name, long defVal) throws IOException {        long ret = defVal;        try {            ret = Long.parseLong(currentElem.getAttribute(name));        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;        }        return ret;    }    public long[] readLongArray(String name, long[] defVal) throws IOException {    	long[] ret = defVal;        try {            Element tmpEl;            if (name != null) {                tmpEl = findChildElement(currentElem, name);            } else {                tmpEl = currentElem;            }            if (tmpEl == null) {                return defVal;            }            int size = Integer.parseInt(tmpEl.getAttribute("size"));            long[] tmp = new long[size];            String[] strings = tmpEl.getAttribute("data").split("\\s+");            for (int i = 0; i < size; i++) {                tmp[i] = Long.parseLong(strings[i]);            }            ret = tmp;        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;        }        return ret;    }    public long[][] readLongArray2D(String name, long[][] defVal) throws IOException {    	long[][] ret = defVal;        try {            Element tmpEl;            if (name != null) {                tmpEl = findChildElement(currentElem, name);            } else {                tmpEl = currentElem;            }            if (tmpEl == null) {                return defVal;            }            int size = Integer.parseInt(tmpEl.getAttribute("size"));            long[][] tmp = new long[size][];            NodeList nodes = currentElem.getChildNodes();            int strIndex = 0;            for (int i = 0; i < nodes.getLength(); i++) {                Node n = nodes.item(i);                if (n instanceof Element && n.getNodeName().contains("array")) {                    if (strIndex < size) {                        tmp[strIndex++] = readLongArray(n.getNodeName(), null);                    } else {           			 throw new IOException("String array contains more elements than specified!");           		 }           	 }                            }            ret = tmp;        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;        }        currentElem = (Element) currentElem.getParentNode();        return ret;    }    public short readShort(String name, short defVal) throws IOException {        short ret = defVal;        try {            ret = Short.parseShort(currentElem.getAttribute(name));        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;        }        return ret;    }    public short[] readShortArray(String name, short[] defVal) throws IOException {    	short[] ret = defVal;         try {             Element tmpEl;             if (name != null) {                 tmpEl = findChildElement(currentElem, name);             } else {                 tmpEl = currentElem;             }             if (tmpEl == null) {                 return defVal;             }             int size = Integer.parseInt(tmpEl.getAttribute("size"));             short[] tmp = new short[size];             String[] strings = tmpEl.getAttribute("data").split("\\s+");             for (int i = 0; i < size; i++) {                 tmp[i] = Short.parseShort(strings[i]);             }             ret = tmp;        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;         }         return ret;    }    public short[][] readShortArray2D(String name, short[][] defVal) throws IOException {    	short[][] ret = defVal;        try {            Element tmpEl;            if (name != null) {                tmpEl = findChildElement(currentElem, name);            } else {                tmpEl = currentElem;            }            if (tmpEl == null) {                return defVal;            }            int size = Integer.parseInt(tmpEl.getAttribute("size"));            short[][] tmp = new short[size][];            NodeList nodes = currentElem.getChildNodes();            int strIndex = 0;            for (int i = 0; i < nodes.getLength(); i++) {                Node n = nodes.item(i);                if (n instanceof Element && n.getNodeName().contains("array")) {                    if (strIndex < size) {                        tmp[strIndex++] = readShortArray(n.getNodeName(), null);                    } else {           			 throw new IOException("String array contains more elements than specified!");           		 }           	 }                            }            ret = tmp;        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;        }        currentElem = (Element) currentElem.getParentNode();        return ret;    }    public boolean readBoolean(String name, boolean defVal) throws IOException {        boolean ret = defVal;        try {            String s = currentElem.getAttribute(name);            if (s.length() > 0) {                ret = Boolean.parseBoolean(s);            }        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;        }        return ret;    }    public boolean[] readBooleanArray(String name, boolean[] defVal) throws IOException {        boolean[] ret = defVal;        try {            Element tmpEl;            if (name != null) {                tmpEl = findChildElement(currentElem, name);            } else {                tmpEl = currentElem;            }            if (tmpEl == null) {                return defVal;            }            int size = Integer.parseInt(tmpEl.getAttribute("size"));            boolean[] tmp = new boolean[size];            String[] strings = tmpEl.getAttribute("data").split("\\s+");            for (int i = 0; i < size; i++) {                tmp[i] = Boolean.parseBoolean(strings[i]);            }            ret = tmp;        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;        }        return ret;    }    public boolean[][] readBooleanArray2D(String name, boolean[][] defVal) throws IOException {    	boolean[][] ret = defVal;        try {            Element tmpEl;            if (name != null) {                tmpEl = findChildElement(currentElem, name);            } else {                tmpEl = currentElem;            }            if (tmpEl == null) {                return defVal;            }            int size = Integer.parseInt(tmpEl.getAttribute("size"));            boolean[][] tmp = new boolean[size][];            NodeList nodes = currentElem.getChildNodes();            int strIndex = 0;            for (int i = 0; i < nodes.getLength(); i++) {                Node n = nodes.item(i);                if (n instanceof Element && n.getNodeName().contains("array")) {                    if (strIndex < size) {                        tmp[strIndex++] = readBooleanArray(n.getNodeName(), null);                    } else {           			 throw new IOException("String array contains more elements than specified!");           		 }           	 }                            }            ret = tmp;        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;        }        currentElem = (Element) currentElem.getParentNode();        return ret;    }    public String readString(String name, String defVal) throws IOException {        String ret = defVal;        try {            ret = decodeString(currentElem.getAttribute(name));        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;        }        return ret;    }    public String[] readStringArray(String name, String[] defVal) throws IOException {    	 String[] ret = defVal;         try {             Element tmpEl;             if (name != null) {                 tmpEl = findChildElement(currentElem, name);             } else {                 tmpEl = currentElem;             }             if (tmpEl == null) {                 return defVal;             }             int size = Integer.parseInt(tmpEl.getAttribute("size"));             String[] tmp = new String[size];             NodeList nodes = currentElem.getChildNodes();             int strIndex = 0;             for (int i = 0; i < nodes.getLength(); i++) {                Node n = nodes.item(i);                if (n instanceof Element && n.getNodeName().contains("String")) {                    if (strIndex < size) {                        tmp[strIndex++] = ((Element) n).getAttributeNode("value").getValue();                    } else {            			 throw new IOException("String array contains more elements than specified!");            		 }            	 }                             }             ret = tmp;        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;         }         currentElem = (Element) currentElem.getParentNode();         return ret;    }    public String[][] readStringArray2D(String name, String[][] defVal) throws IOException {    	String[][] ret = defVal;        try {            Element tmpEl;            if (name != null) {                tmpEl = findChildElement(currentElem, name);            } else {                tmpEl = currentElem;            }            if (tmpEl == null) {                return defVal;            }            int size = Integer.parseInt(tmpEl.getAttribute("size"));            String[][] tmp = new String[size][];            NodeList nodes = currentElem.getChildNodes();            int strIndex = 0;            for (int i = 0; i < nodes.getLength(); i++) {                Node n = nodes.item(i);                if (n instanceof Element && n.getNodeName().contains("array")) {                    if (strIndex < size) {                        tmp[strIndex++] = readStringArray(n.getNodeName(), null);                    } else {           			 throw new IOException("String array contains more elements than specified!");           		 }           	 }                            }            ret = tmp;        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;        }        currentElem = (Element) currentElem.getParentNode();        return ret;    }    public BitSet readBitSet(String name, BitSet defVal) throws IOException {        BitSet ret = defVal;        try {            BitSet set = new BitSet();            String bitString = currentElem.getAttribute(name);            String[] strings = bitString.split("\\s+");            for (int i = 0; i < strings.length; i++) {            	int isSet = Integer.parseInt(strings[i]);                if (isSet == 1) {            		set.set(i);            	}            }            ret = set;        } catch (Exception e) {            IOException ex = new IOException();            ex.initCause(e);            throw ex;        }        return ret;    }    public Savable readSavable(String name, Savable defVal) throws IOException {        Savable ret = defVal;        if (name != null && name.equals("")) {            System.out.println("-");        }        if (false) {        } else {            try {                Element tmpEl = null;                if (name != null) {                    tmpEl = findChildElement(currentElem, name);                    if (tmpEl == null) {                        return defVal;                    }                } else if (isAtRoot) {                    tmpEl = doc.getDocumentElement();                    isAtRoot = false;                } else {                    tmpEl = findFirstChildElement(currentElem);                }                currentElem = tmpEl;                ret = readSavableFromCurrentElem(defVal);                if (currentElem.getParentNode() instanceof Element) {                    currentElem = (Element) currentElem.getParentNode();                } else {                    currentElem = null;                }            } catch (Exception e) {                IOException ex = new IOException();                ex.initCause(e);                throw ex;            }        }        return ret;    }        private Savable readSavableFromCurrentElem(Savable defVal) throws            InstantiationException, ClassNotFoundException,            IOException, IllegalAccessException {        Savable ret = defVal;        Savable tmp = null;        if (currentElem == null || currentElem.getNodeName().equals("null")) {            return null;        }        String reference = currentElem.getAttribute("ref");        if (reference.length() > 0) {            ret = referencedSavables.get(reference);        } else {            String className = currentElem.getNodeName();            if (defVal != null) {                className = defVal.getClass().getName();            } else if (currentElem.hasAttribute("class")) {                className = currentElem.getAttribute("class");            }            tmp = (Savable) Thread.currentThread().getContextClassLoader().loadClass(className).newInstance();            String refID = currentElem.getAttribute("reference_ID");            if (refID.length() > 0) {                referencedSavables.put(refID, tmp);            }            if (tmp != null) {                tmp.read(importer);                ret = tmp;            }        }        return ret;    }    private TextureState readTextureStateFromCurrent() {        Element el = currentElem;        TextureState ret = null;        try {            ret = (TextureState) readSavableFromCurrentElem(null);            //Renderer r = DisplaySystem.getDisplaySystem().getRenderer();            Savable[] savs = readSavableArray("texture", new Texture[0]);            for (int i = 0; i < savs.length; i++) {                Texture t = (Texture) savs[i];                TextureKey tKey = t.getTextureKey();                t = TextureManager.loadTexture(tKey);

⌨️ 快捷键说明

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