Class Configuration


  • public class Configuration
    extends java.lang.Object
    This class manages the initial WorldWind configuration. It reads WorldWind configuration files and registers their contents. Configurations files contain the names of classes to create at run-time, the initial model definition, including the globe, elevation model and layers, and various control quantities such as cache sizes and data retrieval timeouts.

    The Configuration class is a singleton, but its instance is not exposed publicly. It is addressed only via static methods of the class. It is constructed upon first use of any of its static methods.

    When the Configuration class is first instantiated it reads the XML document config/worldwind.xml and registers all the information there. The information can subsequently be retrieved via the class' various getValue methods. Many WorldWind start-up objects query this information to determine the classes to create. For example, the first WorldWind object created by an application is typically a WorldWindowGLCanvas. During construction that class causes WorldWind's internal classes to be constructed, using the names of those classes drawn from the Configuration singleton, this class.

    The default WorldWind configuration document is config/worldwind.xml. This can be changed by setting the Java property gov.nasa.worldwind.config.file to a different file name or a valid URL prior to creating any WorldWind object or invoking any static methods of WorldWind classes, including the Configuration class. When an application specifies a different configuration location it typically does so in its main method prior to using WorldWind. If a file is specified its location must be on the classpath. (The contents of application and WorldWind jar files are typically on the classpath, in which case the configuration file may be in the jar file.)

    Additionally, an application may set another Java property, gov.nasa.worldwind.app.config.document, to a file name or URL whose contents contain configuration values to override those of the primary configuration document. WorldWind overrides only those values in this application document, it leaves all others to the value specified in the primary document. Applications usually specify an override document in order to specify the initial layers in the model.

    See config/worldwind.xml for documentation on setting configuration values.

    Configuration values can also be set programatically via setValue(String, Object), but they are not retroactive so affect only Configuration queries made subsequent to setting the value.

    Note: Prior to September of 2009, configuration properties were read from the file config/worldwind.properties. An alternate file could be specified via the gov.nasa.worldwind.config.file Java property. These mechanisms remain available but are deprecated. WorldWind no longer contains a worldwind.properties file. If worldwind.properties or its replacement as specified through the Java property exists at run-time and can be found via the classpath, configuration values specified by that mechanism are given precedence over values specified by the new mechanism.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_LOGGER_NAME  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Boolean getBooleanValue​(java.lang.String key)
      Return as a Boolean the value associated with a specified key.
      static java.lang.Boolean getBooleanValue​(java.lang.String key, java.lang.Boolean defaultValue)
      Return as a Boolean the value associated with a specified key.
      static java.lang.String getCurrentUserAppDataDirectory()
      Returns the path to the current user's application data directory.
      static java.lang.String getCurrentWorkingDirectory()
      Returns the path to the application's current working directory.
      static java.lang.Double getDoubleValue​(java.lang.String key)
      Return as an Double the value associated with a specified key.
      static java.lang.Double getDoubleValue​(java.lang.String key, java.lang.Double defaultValue)
      Return as an Double the value associated with a specified key.
      static org.w3c.dom.Element getElement​(java.lang.String xpathExpression)
      Returns a specified element of an XML configuration document.
      static java.lang.Integer getIntegerValue​(java.lang.String key)
      Return as an Integer the value associated with a specified key.
      static java.lang.Integer getIntegerValue​(java.lang.String key, java.lang.Integer defaultValue)
      Return as an Integer the value associated with a specified key.
      static float getJavaVersion()
      Returns the version of the Java virtual machine.
      static java.lang.Long getLongValue​(java.lang.String key)
      Return as an Long the value associated with a specified key.
      static java.lang.Long getLongValue​(java.lang.String key, java.lang.Long defaultValue)
      Return as an Long the value associated with a specified key.
      static com.jogamp.opengl.GLProfile getMaxCompatibleGLProfile()
      Returns the highest OpenGL profile available on the current graphics device that is compatible with WorldWind.
      static com.jogamp.opengl.GLCapabilities getRequiredGLCapabilities()
      Returns a GLCapabilities identifying graphics features required by WorldWind.
      static java.lang.String getStringValue​(java.lang.String key)
      Return as a string the value associated with a specified key.
      static java.lang.String getStringValue​(java.lang.String key, java.lang.String defaultValue)
      Return as a string the value associated with a specified key.
      static java.lang.String getSystemTempDirectory()
      Returns the path to the operating system's temp directory.
      static java.lang.String getUserHomeDirectory()
      Returns the path to the application user's home directory.
      static boolean hasKey​(java.lang.String key)
      Determines whether a key exists in the configuration.
      static void insertConfigurationDocument​(java.lang.String fileName)  
      static boolean isLinuxOS()
      Determines whether the operating system is Linux operating system.
      static boolean isMacOS()
      Determines whether the operating system is a Mac operating system.
      static boolean isSolarisOS()
      Determines whether the operating system is Solaris operating system.
      static boolean isUnixOS()
      Determines whether the operating system is Unix operating system.
      static boolean isWindows7OS()
      Determines whether the operating system is Windows 7 operating system.
      static boolean isWindowsOS()
      Determines whether the operating system is Windows operating system.
      static boolean isWindowsVistaOS()
      Determines whether the operating system is Windows Vista operating system.
      static boolean isWindowsXPOS()
      Determines whether the operating system is Windows XP operating system.
      static void removeKey​(java.lang.String key)
      Removes a key and its value from the configuration if the configuration contains the key.
      static void setValue​(java.lang.String key, java.lang.Object value)
      Adds a key and value to the configuration, or changes the value associated with the key if the key is already in the configuration.
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_LOGGER_NAME

        public static final java.lang.String DEFAULT_LOGGER_NAME
        See Also:
        Constant Field Values
    • Method Detail

      • insertConfigurationDocument

        public static void insertConfigurationDocument​(java.lang.String fileName)
      • getStringValue

        public static java.lang.String getStringValue​(java.lang.String key,
                                                      java.lang.String defaultValue)
        Return as a string the value associated with a specified key.
        Parameters:
        key - the key for the desired value.
        defaultValue - the value to return if the key does not exist.
        Returns:
        the value associated with the key, or the specified default value if the key does not exist.
      • getStringValue

        public static java.lang.String getStringValue​(java.lang.String key)
        Return as a string the value associated with a specified key.
        Parameters:
        key - the key for the desired value.
        Returns:
        the value associated with the key, or null if the key does not exist.
      • getIntegerValue

        public static java.lang.Integer getIntegerValue​(java.lang.String key,
                                                        java.lang.Integer defaultValue)
        Return as an Integer the value associated with a specified key.
        Parameters:
        key - the key for the desired value.
        defaultValue - the value to return if the key does not exist.
        Returns:
        the value associated with the key, or the specified default value if the key does not exist or is not an Integer or string representation of an Integer.
      • getIntegerValue

        public static java.lang.Integer getIntegerValue​(java.lang.String key)
        Return as an Integer the value associated with a specified key.
        Parameters:
        key - the key for the desired value.
        Returns:
        the value associated with the key, or null if the key does not exist or is not an Integer or string representation of an Integer.
      • getLongValue

        public static java.lang.Long getLongValue​(java.lang.String key,
                                                  java.lang.Long defaultValue)
        Return as an Long the value associated with a specified key.
        Parameters:
        key - the key for the desired value.
        defaultValue - the value to return if the key does not exist.
        Returns:
        the value associated with the key, or the specified default value if the key does not exist or is not a Long or string representation of a Long.
      • getLongValue

        public static java.lang.Long getLongValue​(java.lang.String key)
        Return as an Long the value associated with a specified key.
        Parameters:
        key - the key for the desired value.
        Returns:
        the value associated with the key, or null if the key does not exist or is not a Long or string representation of a Long.
      • getDoubleValue

        public static java.lang.Double getDoubleValue​(java.lang.String key,
                                                      java.lang.Double defaultValue)
        Return as an Double the value associated with a specified key.
        Parameters:
        key - the key for the desired value.
        defaultValue - the value to return if the key does not exist.
        Returns:
        the value associated with the key, or the specified default value if the key does not exist or is not an Double or string representation of an Double.
      • getDoubleValue

        public static java.lang.Double getDoubleValue​(java.lang.String key)
        Return as an Double the value associated with a specified key.
        Parameters:
        key - the key for the desired value.
        Returns:
        the value associated with the key, or null if the key does not exist or is not an Double or string representation of an Double.
      • getBooleanValue

        public static java.lang.Boolean getBooleanValue​(java.lang.String key,
                                                        java.lang.Boolean defaultValue)
        Return as a Boolean the value associated with a specified key.

        Valid values for true are '1' or anything that starts with 't' or 'T'. ie. 'true', 'True', 't' Valid values for false are '0' or anything that starts with 'f' or 'F'. ie. 'false', 'False', 'f'

        Parameters:
        key - the key for the desired value.
        defaultValue - the value to return if the key does not exist.
        Returns:
        the value associated with the key, or the specified default value if the key does not exist or is not a Boolean or string representation of an Boolean.
      • getBooleanValue

        public static java.lang.Boolean getBooleanValue​(java.lang.String key)
        Return as a Boolean the value associated with a specified key.

        Valid values for true are '1' or anything that starts with 't' or 'T'. ie. 'true', 'True', 't' Valid values for false are '0' or anything that starts with 'f' or 'F'. ie. 'false', 'False', 'f'

        Parameters:
        key - the key for the desired value.
        Returns:
        the value associated with the key, or null if the key does not exist or is not a Boolean or string representation of an Boolean.
      • hasKey

        public static boolean hasKey​(java.lang.String key)
        Determines whether a key exists in the configuration.
        Parameters:
        key - the key of interest.
        Returns:
        true if the key exists, otherwise false.
      • removeKey

        public static void removeKey​(java.lang.String key)
        Removes a key and its value from the configuration if the configuration contains the key.
        Parameters:
        key - the key of interest.
      • setValue

        public static void setValue​(java.lang.String key,
                                    java.lang.Object value)
        Adds a key and value to the configuration, or changes the value associated with the key if the key is already in the configuration.
        Parameters:
        key - the key to set.
        value - the value to associate with the key.
      • getCurrentWorkingDirectory

        public static java.lang.String getCurrentWorkingDirectory()
        Returns the path to the application's current working directory.
        Returns:
        the absolute path to the application's current working directory.
      • getUserHomeDirectory

        public static java.lang.String getUserHomeDirectory()
        Returns the path to the application user's home directory.
        Returns:
        the absolute path to the application user's home directory.
      • getSystemTempDirectory

        public static java.lang.String getSystemTempDirectory()
        Returns the path to the operating system's temp directory.
        Returns:
        the absolute path to the operating system's temporary directory.
      • getCurrentUserAppDataDirectory

        public static java.lang.String getCurrentUserAppDataDirectory()
        Returns the path to the current user's application data directory. The path returned depends on the operating system on which the Java Virtual Machine is running. The following table provides the path for all supported operating systems:
        Mapping
        Operating SystemPath
        Mac OS X~/Library/Application Support
        Windows~\\Application Data
        Linux, Unix, Solaris~/
        Returns:
        the absolute path to the current user's application data directory.
      • isMacOS

        public static boolean isMacOS()
        Determines whether the operating system is a Mac operating system.
        Returns:
        true if the operating system is a Mac operating system, otherwise false.
      • isWindowsOS

        public static boolean isWindowsOS()
        Determines whether the operating system is Windows operating system.
        Returns:
        true if the operating system is a Windows operating system, otherwise false.
      • isWindowsXPOS

        public static boolean isWindowsXPOS()
        Determines whether the operating system is Windows XP operating system.
        Returns:
        true if the operating system is a Windows XP operating system, otherwise false.
      • isWindowsVistaOS

        public static boolean isWindowsVistaOS()
        Determines whether the operating system is Windows Vista operating system.
        Returns:
        true if the operating system is a Windows Vista operating system, otherwise false.
      • isWindows7OS

        public static boolean isWindows7OS()
        Determines whether the operating system is Windows 7 operating system.
        Returns:
        true if the operating system is a Windows Vista operating system, otherwise false.
      • isLinuxOS

        public static boolean isLinuxOS()
        Determines whether the operating system is Linux operating system.
        Returns:
        true if the operating system is a Linux operating system, otherwise false.
      • isUnixOS

        public static boolean isUnixOS()
        Determines whether the operating system is Unix operating system.
        Returns:
        true if the operating system is a Unix operating system, otherwise false.
      • isSolarisOS

        public static boolean isSolarisOS()
        Determines whether the operating system is Solaris operating system.
        Returns:
        true if the operating system is a Solaris operating system, otherwise false.
      • getJavaVersion

        public static float getJavaVersion()
        Returns the version of the Java virtual machine.
        Returns:
        the Java virtual machine version.
      • getMaxCompatibleGLProfile

        public static com.jogamp.opengl.GLProfile getMaxCompatibleGLProfile()
        Returns the highest OpenGL profile available on the current graphics device that is compatible with WorldWind. The returned profile favors hardware acceleration over software acceleration. With JOGL version 2.0, this returns the highest available profile from the following list:
        • OpenGL compatibility profile 4.x
        • OpenGL compatibility profile 3.x
        • OpenGL profile 1.x up to 3.0
        Returns:
        the highest compatible OpenGL profile.
      • getRequiredGLCapabilities

        public static com.jogamp.opengl.GLCapabilities getRequiredGLCapabilities()
        Returns a GLCapabilities identifying graphics features required by WorldWind. The capabilities instance returned requests the maximum OpenGL profile supporting GL fixed function operations, a frame buffer with 8 bits each of red, green, blue and alpha, a 24-bit depth buffer, double buffering, and if the Java property "gov.nasa.worldwind.stereo.mode" is set to "device", device supported stereo.
        Returns:
        a new capabilities instance identifying required graphics features.
      • getElement

        public static org.w3c.dom.Element getElement​(java.lang.String xpathExpression)
        Returns a specified element of an XML configuration document.
        Parameters:
        xpathExpression - an XPath expression identifying the element of interest.
        Returns:
        the element of interest if the XPath expression is valid and the element exists, otherwise null.
        Throws:
        java.lang.NullPointerException - if the XPath expression is null.