public class Environment
extends java.util.Properties
There is only one Environment, and it is accessed through static member functions.
The environment is comprised of at least three property lists:
Environment.get()
is called, all lists are searched until
the property is found. System properties are searched first, then runtime
properties, and then hardcoded properties.
This search pattern allows system properties and properties specified as applet parameters or command line properties (using -DProperty=value Java flag) to override more hardcoded properties specified elsewhere, say in a user preferences file.
# metanames of the names of the variables used in the OpenMap
# system to configure the Environment class from the properties.
openmap.Title - String for title of application window.
openmap.Version - Version number of application.
openmap.BuildDate - Build data of code base.
openmap.WebBrowser - The launch command to launch a browser.
openmap.TempDirectory - A path to a directory to use for temporary files.
openmap.UseInternalFrames - For an application, to direct it to use InternalFrames for other windows.
openmap.Latitude - Starting latitude for map projection.
openmap.Longitude - Starting longitude for map projection.
openmap.Scale - Starting scale for map projection.
openmap.Projection - Starting projection type for map projection.
openmap.Width - Pixel width for map.
openmap.Height - Pixel height for map.
openmap.HelpURL - The URL to use for OpenMap/Application help pages.
openmap.BackgroundColor - An ARGB integer to use for the background (sea) color.
openmap.Debug - Debug tokens to activate for printout. @see com.bbn.openmap.util.Debug
openmap.UniqueID String for unique identification of OpenMap instance (calculated)
,
Serialized FormModifier and Type | Field and Description |
---|---|
protected static java.applet.Applet |
applet |
static java.lang.String |
BackgroundColor |
static java.lang.String |
build |
static java.lang.String |
BuildDate |
static java.lang.String |
DebugList |
protected javax.swing.JLayeredPane |
desktop |
static boolean |
doingXWindowsWorkaround |
protected static Environment |
env |
protected java.util.Properties |
hardcodedProps |
static java.lang.String |
Height |
static java.lang.String |
HelpURL |
static java.lang.String |
Latitude |
static java.lang.String |
Longitude |
static java.lang.String |
OpenMapPrefix |
static java.lang.String |
PreferencesURL |
static java.lang.String |
Projection |
protected java.util.Properties |
runtimeProps |
static java.lang.String |
Scale |
static java.lang.String |
ThreadPool |
static java.lang.String |
title |
static java.lang.String |
Title |
static java.lang.String |
TmpDir |
static java.lang.String |
UniqueID |
static java.lang.String |
UseInternalFrames |
static java.lang.String |
version |
static java.lang.String |
Version |
static java.lang.String |
WebBrowser |
static java.lang.String |
Width |
Modifier | Constructor and Description |
---|---|
protected |
Environment(java.applet.Applet applet)
Creates an Environment based on applet properties.
|
protected |
Environment(java.util.Properties sysProps)
Creates an Environment with the specified system properties.
|
Modifier and Type | Method and Description |
---|---|
static void |
addPathToClasspaths(java.lang.String path)
Add a resource path to internal Vector.
|
static void |
addRuntimeProperty(java.lang.String key,
java.lang.String value)
Adds a key/value pair to the Environment's runtime properties list.
|
static void |
addSystemProperty(java.lang.String key,
java.lang.String value)
Adds a key/value pair to the Environment's system properties list.
|
protected void |
commonInit()
Adds runtime, user, and base properties to the Environment.
|
static java.lang.String |
generateUniqueString()
Generate a unique string.
|
static java.lang.String |
get(java.lang.String key)
Searches for the named property in the environment.
|
static java.lang.String |
get(java.lang.String key,
java.lang.String defaultValue)
Searches for the named property in the environment.
|
static java.applet.Applet |
getApplet()
Gets the applet associated with this process.
|
static boolean |
getBoolean(java.lang.String key)
Gets a boolean value out of the Environment.
|
static boolean |
getBoolean(java.lang.String key,
boolean defaultValue)
Gets a boolean value out of the Environment.
|
static java.util.Vector<java.lang.String> |
getClasspathDirs()
Returns elements of the CLASSPATH that are directories.
|
static java.awt.Color |
getCustomBackgroundColor()
Checks the Environment to see if a BackgroundColor string, set as a hex
ARGB string, has been set.
|
static double |
getDouble(java.lang.String key)
Gets a double value out of the Environment.
|
static double |
getDouble(java.lang.String key,
double defaultValue)
Gets a double value out of the Environment.
|
static float |
getFloat(java.lang.String key)
Gets a float value out of the Environment.
|
static float |
getFloat(java.lang.String key,
float defaultValue)
Gets a float value out of the Environment.
|
static I18n |
getI18n()
Get the Internationalization instance.
|
static Environment |
getInstance() |
static int |
getInteger(java.lang.String key)
Gets an integer value out of the Environment.
|
static int |
getInteger(java.lang.String key,
int defaultValue)
Gets an integer value out of the Environment.
|
static int |
getInteger(java.lang.String key,
int defaultValue,
int radix)
Gets an integer value out of the Environment.
|
static javax.swing.JLayeredPane |
getInternalFrameDesktop()
Get the JLayeredPane to use for Internal Frames.
|
static java.util.Properties |
getProperties()
Returns the toplevel Properties list of the Environment.
|
static void |
init()
Initializes the OpenMap environment.
|
static void |
init(java.applet.Applet applet)
Initializes the environment of an applet.
|
static void |
init(java.util.Properties sysProps)
Initializes the environment of an application.
|
protected static void |
initHardCodedProperties(java.util.Properties p)
Hardcoded default properties.
|
protected static void |
initRuntimeProperties(java.util.Properties p)
Initializes the runtime properties list.
|
static boolean |
isApplet()
Indicates whether the current process is an applet.
|
static boolean |
isApplication()
Indicates whether the current process is an application.
|
static boolean |
isXWindowSystem()
Check if this is an XWindows-based VM.
|
static java.lang.String |
set(java.lang.String key,
java.lang.String value)
Puts a property into the environment.
|
protected static void |
setApplet(java.applet.Applet applet) |
protected void |
setAppletProperties(java.applet.Applet applet,
java.util.Properties props)
Populates the system properties for an applet.
|
static java.lang.String |
timestamp()
Returns a stringified value of the current time.
|
static void |
useInternalFrames(javax.swing.JLayeredPane layeredPane)
A method to set the Environment to be able to tell other components to
InternalFrames.
|
static void |
useInternalFrames(javax.swing.JRootPane rootPane)
A method to set the Environment to be able to tell other components to
InternalFrames.
|
getProperty, getProperty, list, list, load, load, loadFromXML, propertyNames, save, setProperty, store, store, storeToXML, storeToXML, stringPropertyNames
protected static Environment env
protected java.util.Properties hardcodedProps
protected java.util.Properties runtimeProps
protected javax.swing.JLayeredPane desktop
protected static java.applet.Applet applet
public static final transient java.lang.String OpenMapPrefix
public static final transient java.lang.String PreferencesURL
public static final transient java.lang.String Title
public static final transient java.lang.String Version
public static final transient java.lang.String BuildDate
public static final transient java.lang.String UniqueID
public static final transient java.lang.String WebBrowser
public static final transient java.lang.String TmpDir
public static final transient java.lang.String UseInternalFrames
public static final transient java.lang.String Latitude
public static final transient java.lang.String Longitude
public static final transient java.lang.String Scale
public static final transient java.lang.String Projection
public static final transient java.lang.String Width
public static final transient java.lang.String Height
public static final transient java.lang.String HelpURL
public static final transient java.lang.String BackgroundColor
public static final transient java.lang.String DebugList
public static transient boolean doingXWindowsWorkaround
public static final transient java.lang.String title
public static final transient java.lang.String version
public static final transient java.lang.String build
public static final transient java.lang.String ThreadPool
protected Environment(java.applet.Applet applet)
applet
- an Appletprotected Environment(java.util.Properties sysProps)
sysProps
- system propertiesprotected static final void initHardCodedProperties(java.util.Properties p)
These should be edited before each new version/installation of OpenMap. They are declared in such a way that they can be easily edited from a build script.
p
- Propertiespublic static void init(java.applet.Applet applet)
applet
- An appletApplet
public static void init(java.util.Properties sysProps)
sysProps
- Runtime/System Properties (Toplevel)public static void init()
public static Environment getInstance()
protected void commonInit()
protected void setAppletProperties(java.applet.Applet applet, java.util.Properties props)
applet
- the appletApplet.getParameterInfo()
protected static void initRuntimeProperties(java.util.Properties p)
p
- The runtime properties listpublic static boolean isApplet()
true
if process is an applet; false
otherwise.protected static void setApplet(java.applet.Applet applet)
public static boolean isApplication()
true
if process is an application;
false
otherwise.public static java.lang.String get(java.lang.String key)
key
- the property keynull
if there is no property with that key.public static java.lang.String get(java.lang.String key, java.lang.String defaultValue)
key
- the property keydefaultValue
- a default valuedefaultValue
if there is no property with that key.public static java.lang.String set(java.lang.String key, java.lang.String value)
key
- the property key.value
- the value to the key.public static boolean getBoolean(java.lang.String key)
key
- the property keypublic static boolean getBoolean(java.lang.String key, boolean defaultValue)
key
- the property keydefaultValue
- a default valuepublic static int getInteger(java.lang.String key)
key
- the property keypublic static int getInteger(java.lang.String key, int defaultValue)
key
- the property keydefaultValue
- a default valuepublic static int getInteger(java.lang.String key, int defaultValue, int radix)
key
- the property keydefaultValue
- a default valueradix
- base valuepublic static float getFloat(java.lang.String key)
key
- the property keypublic static float getFloat(java.lang.String key, float defaultValue)
key
- the property keydefaultValue
- a default valuepublic static double getDouble(java.lang.String key)
key
- the property keypublic static double getDouble(java.lang.String key, double defaultValue)
key
- the property keydefaultValue
- a default valuepublic static java.applet.Applet getApplet()
public static void addSystemProperty(java.lang.String key, java.lang.String value)
key
- the key, used later for retrievalvalue
- the associate valueget(java.lang.String)
public static void addRuntimeProperty(java.lang.String key, java.lang.String value)
key
- the key, used later for retrievalvalue
- the associate valueget(java.lang.String)
public static java.util.Properties getProperties()
public static java.lang.String timestamp()
Note: you probably don't want to call this in a tight loop.
public static final boolean isXWindowSystem()
Note: this only returns a valid result if the Environment has been initialized.
public static java.lang.String generateUniqueString()
timestamp()
public static final java.util.Vector<java.lang.String> getClasspathDirs()
public static void addPathToClasspaths(java.lang.String path)
public static java.awt.Color getCustomBackgroundColor()
public static void useInternalFrames(javax.swing.JRootPane rootPane)
rootPane
- to use for the internal frames - the method gets the
LayeredPane from the rootPane.public static void useInternalFrames(javax.swing.JLayeredPane layeredPane)
layeredPane
- to use for the internal frames.public static javax.swing.JLayeredPane getInternalFrameDesktop()
public static I18n getI18n()
Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details