NASA World Wind

gov.nasa.worldwind
Class Configuration

java.lang.Object
  extended by gov.nasa.worldwind.Configuration

public class Configuration
extends Object

This class manages the initial World Wind configuration. It reads World Wind 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 World Wind start-up objects query this information to determine the classes to create. For example, the first World Wind object created by an application is typically a WorldWindowGLCanvas. During construction that class causes World Wind's internal classes to be constructed, using the names of those classes drawn from the Configuration singleton, this class.

The default World Wind 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 World Wind object or invoking any static methods of World Wind classes, including the Configuration class. When an application specifies a different configuration location it typically does so in its main method prior to using World Wind. If a file is specified its location must be on the classpath. (The contents of application and World Wind 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. World Wind 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. World Wind 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
static String DEFAULT_LOGGER_NAME
           
 
Method Summary
static Boolean getBooleanValue(String key)
          Return as a Boolean the value associated with a specified key.
static Boolean getBooleanValue(String key, Boolean defaultValue)
          Return as a Boolean the value associated with a specified key.
static String getCurrentUserAppDataDirectory()
          Returns the path to the current user's application data directory.
static String getCurrentWorkingDirectory()
          Returns the path to the application's current working directory.
static Double getDoubleValue(String key)
          Return as an Double the value associated with a specified key.
static Double getDoubleValue(String key, Double defaultValue)
          Return as an Double the value associated with a specified key.
static Element getElement(String xpathExpression)
          Returns a specified element of an XML configuration document.
static Integer getIntegerValue(String key)
          Return as an Integer the value associated with a specified key.
static Integer getIntegerValue(String key, 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 Long getLongValue(String key)
          Return as an Long the value associated with a specified key.
static Long getLongValue(String key, Long defaultValue)
          Return as an Long the value associated with a specified key.
static GLProfile getMaxCompatibleGLProfile()
          Returns the highest OpenGL profile available on the current graphics device that is compatible with World Wind.
static GLCapabilities getRequiredGLCapabilities()
          Returns a GLCapabilities identifying graphics features required by World Wind.
static String getStringValue(String key)
          Return as a string the value associated with a specified key.
static String getStringValue(String key, String defaultValue)
          Return as a string the value associated with a specified key.
static String getSystemTempDirectory()
          Returns the path to the operating system's temp directory.
static String getUserHomeDirectory()
          Returns the path to the application user's home directory.
static boolean hasKey(String key)
          Determines whether a key exists in the configuration.
static void insertConfigurationDocument(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(String key)
          Removes a key and its value from the configuration if the configuration contains the key.
static void setValue(String key, 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, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LOGGER_NAME

public static final String DEFAULT_LOGGER_NAME
See Also:
Constant Field Values
Method Detail

getBooleanValue

public static Boolean getBooleanValue(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.

getBooleanValue

public static Boolean getBooleanValue(String key,
                                      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.

getCurrentUserAppDataDirectory

public static 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:

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.

getCurrentWorkingDirectory

public static String getCurrentWorkingDirectory()
Returns the path to the application's current working directory.

Returns:
the absolute path to the application's current working directory.

getDoubleValue

public static Double getDoubleValue(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.

getDoubleValue

public static Double getDoubleValue(String key,
                                    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.

getElement

public static Element getElement(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:
NullPointerException - if the XPath expression is null.

getIntegerValue

public static Integer getIntegerValue(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.

getIntegerValue

public static Integer getIntegerValue(String key,
                                      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.

getJavaVersion

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

Returns:
the Java virtual machine version.

getLongValue

public static Long getLongValue(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.

getLongValue

public static Long getLongValue(String key,
                                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.

getMaxCompatibleGLProfile

public static GLProfile getMaxCompatibleGLProfile()
Returns the highest OpenGL profile available on the current graphics device that is compatible with World Wind. The returned profile favors hardware acceleration over software acceleration. With JOGL version 2.0, this returns the highest available profile from the following list:

Returns:
the highest compatible OpenGL profile.

getRequiredGLCapabilities

public static GLCapabilities getRequiredGLCapabilities()
Returns a GLCapabilities identifying graphics features required by World Wind. 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.

getStringValue

public static String getStringValue(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.

getStringValue

public static String getStringValue(String key,
                                    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.

getSystemTempDirectory

public static String getSystemTempDirectory()
Returns the path to the operating system's temp directory.

Returns:
the absolute path to the operating system's temporary directory.

getUserHomeDirectory

public static String getUserHomeDirectory()
Returns the path to the application user's home directory.

Returns:
the absolute path to the application user's home directory.

hasKey

public static boolean hasKey(String key)
Determines whether a key exists in the configuration.

Parameters:
key - the key of interest.
Returns:
true if the key exists, otherwise false.

insertConfigurationDocument

public static void insertConfigurationDocument(String fileName)

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.

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.

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.

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.

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.

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.

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.

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.

removeKey

public static void removeKey(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(String key,
                            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.

NASA World Wind