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

📄 environment.java

📁 openmap java写的开源数字地图程序. 用applet实现,可以像google map 那样放大缩小地图.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            doingXWindowsWorkaround = false;        }    }    /**     * Indicates whether the current process is an applet.     *      * @return <code>true</code> if process is an applet;     *         <code>false</code> otherwise.     */    public static boolean isApplet() {        return (applet != null);    }    protected static void setApplet(Applet applet) {        Environment.applet = applet;        if (applet instanceof JApplet) {            Environment.useInternalFrames(((JApplet) applet).getRootPane());        }    }    /**     * Indicates whether the current process is an application.     *      * @return <code>true</code> if process is an application;     *         <code>false</code> otherwise.     */    public static boolean isApplication() {        return (applet == null);    }    /**     * Searches for the named property in the environment. If the key     * is not found, null is returned. All three property lists,     * runtime, user, and system are searched in that order.     *      * @param key the property key     * @return the value of the property with the specified key or     *         <code>null</code> if there is no property with that     *         key.     */    public static String get(String key) {        return Environment.get(key, null);    }    /**     * Searches for the named property in the environment. If the key     * is not found, the default value is returned. All three property     * lists, runtime, user, and system are searched in that order.     *      * @param key the property key     * @param defaultValue a default value     * @return the value of the property with the specified key or     *         <code>defaultValue</code> if there is no property     *         with that key.     */    public static String get(String key, String defaultValue) {        if (env == null) {            if (Debug.debugging("env")) {                System.err.println("Environment.get(" + key + ", "                        + defaultValue + ") called with null environment");            }            return defaultValue;        } else {            return env.getProperty(key, defaultValue);        }    }    /**     * Puts a property into the environment.     *      * @param key the property key.     * @param value the value to the key.     * @return the value of the property set, or null if the     *         environment isn't ready for it.     */    public static String set(String key, String value) {        if (env == null) {            if (Debug.debugging("env")) {                System.err.println("Can't Environment.put(" + key + ", "                        + value + ") - no environment yet.");            }            return null;        } else {            return (String) env.put(key, value);        }    }    /**     * Gets a boolean value out of the Environment.     *      * @param key the property key     * @return the boolean value of the property or false if there is     *         no property with that key     *       */    public static boolean getBoolean(String key) {        return getBoolean(key, false);    }    /**     * Gets a boolean value out of the Environment.     *      * @param key the property key     * @param defaultValue a default value     * @return the boolean value of the property or defaultValue if     *         there is no property with that key     *       */    public static boolean getBoolean(String key, boolean defaultValue) {        String str = Environment.get(key, null);        if (str == null) {            return defaultValue;        }        return (Boolean.valueOf(str)).booleanValue();    }    /**     * Gets an integer value out of the Environment.     *      * @param key the property key     * @return the integer value of the property or defaultValue if     *         there is no property with that key     *       */    public static int getInteger(String key) {        return getInteger(key, Integer.MIN_VALUE, 10);    }    /**     * Gets an integer value out of the Environment.     *      * @param key the property key     * @param defaultValue a default value     * @return the integer value of the property or defaultValue if     *         there is no property with that key     *       */    public static int getInteger(String key, int defaultValue) {        return getInteger(key, defaultValue, 10);    }    /**     * Gets an integer value out of the Environment.     *      * @param key the property key     * @param defaultValue a default value     * @param radix base value     * @return the integer value of the property or defaultValue if     *         there is no property with that key     *       */    public static int getInteger(String key, int defaultValue, int radix) {        String str = Environment.get(key, null);        if (str == null) {            return defaultValue;        }        try {            return Integer.parseInt(str, radix);        } catch (NumberFormatException e) {            return defaultValue;        }    }    /**     * Gets a float value out of the Environment.     *      * @param key the property key     * @return the float value of the property or defaultValue if     *         there is no property with that key     *       */    public static float getFloat(String key) {        return getFloat(key, Float.NaN);    }    /**     * Gets a float value out of the Environment.     *      * @param key the property key     * @param defaultValue a default value     * @return the float value of the property or defaultValue if     *         there is no property with that key     *       */    public static float getFloat(String key, float defaultValue) {        String str = Environment.get(key, null);        if (str == null) {            return defaultValue;        }        try {            return Float.valueOf(str).floatValue();        } catch (NumberFormatException e) {            return defaultValue;        }    }    /**     * Gets a double value out of the Environment.     *      * @param key the property key     * @return the double value of the property or defaultValue if     *         there is no property with that key     *       */    public static double getDouble(String key) {        return getDouble(key, Double.NaN);    }    /**     * Gets a double value out of the Environment.     *      * @param key the property key     * @param defaultValue a default value     * @return the double value of the property or defaultValue if     *         there is no property with that key     *       */    public static double getDouble(String key, double defaultValue) {        String str = Environment.get(key, null);        if (str == null) {            return defaultValue;        }        try {            return Double.valueOf(str).doubleValue();        } catch (NumberFormatException e) {            return defaultValue;        }    }    /**     * Gets the applet associated with this process.     *      * @return the applet, or null if process is an application     */    public static Applet getApplet() {        return applet;    }    /**     * Adds a key/value pair to the Environment's system properties     * list.     *      * @param key the key, used later for retrieval     * @param value the associate value     * @see Environment#get     */    public static void addSystemProperty(String key, String value) {        env.put(key, value);    }    /**     * Adds a key/value pair to the Environment's runtime properties     * list.     *      * @param key the key, used later for retrieval     * @param value the associate value     * @see Environment#get     */    public static void addRuntimeProperty(String key, String value) {        env.runtimeProps.put(key, value);    }    /**     * Returns the toplevel Properties list of the Environment.     *      * @return Properties system properties     *       */    public static Properties getProperties() {        return env;    }    /**     * Returns a stringified value of the current time.     * <p>     * Note: you probably don't want to call this in a tight loop.     *      * @return String timestamp YYYYMMDDhhmmss     *       */    public static String timestamp() {        Calendar calendar = Calendar.getInstance();        return "" + calendar.get(Calendar.YEAR) + calendar.get(Calendar.MONTH)                + calendar.get(Calendar.DAY_OF_MONTH)                + calendar.get(Calendar.HOUR) + calendar.get(Calendar.MINUTE)                + calendar.get(Calendar.SECOND);    }    /**     * Check if this is an XWindows-based VM.     * <p>     * Note: this only returns a valid result if the Environment has     * been initialized.     * <p>     *      * @return boolean     *       */    public final static boolean isXWindowSystem() {        return isXWindows;    }    /**     * Generate a unique string. This should be unique compared to     * other strings generated this way.     *      * @return String     * @see Environment#timestamp     */    public static String generateUniqueString() {        return Environment.get(UniqueID) + (counter++);    }    /**     * Returns elements of the CLASSPATH that are directories.     * CLASSPATH elements that are not directories are not returned.     *      * @return Vector of Strings     */    public final static Vector getClasspathDirs() {        Vector v = new Vector();        try {            String classPath = System.getProperty("java.class.path");            StringTokenizer st = new StringTokenizer(classPath, File.pathSeparator);            while (st.hasMoreTokens()) {                String path = st.nextToken();                if ((new File(path)).isDirectory()) {                    v.addElement(path);                }            }        } catch (java.security.AccessControlException ace) {            // Running as an applet?!?        }        v.addAll(extraPaths);        return v;    }    /**     * Add a resource path to internal Vector. This path will get     * added to the classpath, if the Environment is asked for     * classpaths.     */    public static void addPathToClasspaths(String path) {        extraPaths.addElement(path);    }    /**     * Checks the Environment to see if a BackgroundColor string, set     * as a hex ARGB string, has been set. If it hasn't or if it     * doesn't represent a valid color number, then null is returned,     * which should be interpreted as an excuse to use the default     * pretty blue embedded in the projection.     */    public static Color getCustomBackgroundColor() {        String colorRep = get(BackgroundColor);        if (colorRep == null) {            return null;        } else {            try {                return PropUtils.parseColor(colorRep);            } catch (NumberFormatException nfe) {                return null;            }        }    }    /**     * A method to set the Environment to be able to tell other     * components to InternalFrames.     *      * @param rootPane to use for the internal frames - the method     *        gets the LayeredPane from the rootPane.     */    public static void useInternalFrames(JRootPane rootPane) {        if (rootPane != null) {            useInternalFrames(rootPane.getLayeredPane());        } else {            useInternalFrames((JLayeredPane) null);        }    }    /**     * A method to set the Environment to be able to tell other     * components to InternalFrames.     *      * @param layeredPane to use for the internal frames.     */    public static void useInternalFrames(JLayeredPane layeredPane) {        if (layeredPane != null) {            env.desktop = layeredPane;            env.desktop.setOpaque(true);            set(UseInternalFrames, "true");        } else {            env.desktop = null;            set(UseInternalFrames, "false");        }    }    /**     * Get the JLayeredPane to use for Internal Frames. May be null if     * the Environment hasn't be set with the root pane.     */    public static JLayeredPane getInternalFrameDesktop() {        return env.desktop;    }    private static I18n i18n = new BasicI18n();    /**     * Get the Internationalization instance.     */    public static I18n getI18n() {        return i18n;    }}

⌨️ 快捷键说明

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