public class Configuration
extends java.lang.Object
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.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_LOGGER_NAME |
Modifier and Type | Method and 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 World Wind. |
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.
|
public static final java.lang.String DEFAULT_LOGGER_NAME
public static java.lang.Boolean getBooleanValue(java.lang.String 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'
key
- the key for the desired value.public static java.lang.Boolean getBooleanValue(java.lang.String key, java.lang.Boolean defaultValue)
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'
key
- the key for the desired value.defaultValue
- the value to return if the key does not exist.public static java.lang.String getCurrentUserAppDataDirectory()
Operating System | Path |
---|---|
Mac OS X | ~/Library/Application Support |
Windows | ~\\Application Data |
Linux, Unix, Solaris | ~/ |
public static java.lang.String getCurrentWorkingDirectory()
public static java.lang.Double getDoubleValue(java.lang.String key)
key
- the key for the desired value.public static java.lang.Double getDoubleValue(java.lang.String key, java.lang.Double defaultValue)
key
- the key for the desired value.defaultValue
- the value to return if the key does not exist.public static org.w3c.dom.Element getElement(java.lang.String xpathExpression)
xpathExpression
- an XPath expression identifying the element of interest.java.lang.NullPointerException
- if the XPath expression is null.public static java.lang.Integer getIntegerValue(java.lang.String key)
key
- the key for the desired value.public static java.lang.Integer getIntegerValue(java.lang.String key, java.lang.Integer defaultValue)
key
- the key for the desired value.defaultValue
- the value to return if the key does not exist.public static float getJavaVersion()
public static java.lang.Long getLongValue(java.lang.String key)
key
- the key for the desired value.public static java.lang.Long getLongValue(java.lang.String key, java.lang.Long defaultValue)
key
- the key for the desired value.defaultValue
- the value to return if the key does not exist.public static com.jogamp.opengl.GLProfile getMaxCompatibleGLProfile()
public static com.jogamp.opengl.GLCapabilities getRequiredGLCapabilities()
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.public static java.lang.String getStringValue(java.lang.String key)
key
- the key for the desired value.public static java.lang.String getStringValue(java.lang.String key, java.lang.String defaultValue)
key
- the key for the desired value.defaultValue
- the value to return if the key does not exist.public static java.lang.String getSystemTempDirectory()
public static java.lang.String getUserHomeDirectory()
public static boolean hasKey(java.lang.String key)
key
- the key of interest.public static void insertConfigurationDocument(java.lang.String fileName)
public static boolean isLinuxOS()
public static boolean isMacOS()
public static boolean isSolarisOS()
public static boolean isUnixOS()
public static boolean isWindows7OS()
public static boolean isWindowsOS()
public static boolean isWindowsVistaOS()
public static boolean isWindowsXPOS()
public static void removeKey(java.lang.String key)
key
- the key of interest.public static void setValue(java.lang.String key, java.lang.Object value)
key
- the key to set.value
- the value to associate with the key.