ecologylab.appframework
Interface Environment

All Known Implementing Classes:
ApplicationEnvironment, LogPlayer, PrefsEditorAp, ProjectionVisualizer

public interface Environment

Provides a mechanism for passing parameters/preferences/properties from diverse runtime environments, including applets (via the param tag), applications (via a properties file), and sooner or later, servlets.

Cooperative programming: Any class that implements this interface needs to include the following line of code at the top of its initialization, in order to make the services provided by this Environment interface globally accessible.

       Environment.the.set(this);
 
The nested class The serves to keep a global reference to the actual instance of the singleton class that implements Environment. (Don't have more than 1 instance that does!)

The raison d'etre of this interface is first to allow programs to utilize services in a uniform way, whether they are applets or applications. The raison d'etre of the nested class is to overcome the existence of a single java.applet.Applet instance in the runtime environment which provides services that conceptually, one expects to get from a static, like java.lang.System. This is a simple mechanism that actually does something quite complex, and for complex reasons.

Services are then available globally through syntax such as:

       Environment.the.get().parameter("bgcolor");
 


Nested Class Summary
static class Environment.The
          Holds a reference to the singleton global instance of Environment, and simple methods for getting and setting this reference.
 
Field Summary
static int APPLICATION
           
static int IE
           
static int NS
           
static int PLUGIN
           
static Environment.The the
          Each running entity (be it an applet or an application), should have one and only one instance of an Environment.
 
Method Summary
 int browser()
          Find out which browser we're running in.
 ParsedURL codeBase()
          Change type from URL to ParsedURL.
 ParsedURL docBase()
          Change type from URL to ParsedURL.
 void exit(int code)
          Called at the end of an invocation.
 java.lang.String lookupStringPreference(java.lang.String name)
          Get a parameter or property, based on a key.
 void navigate(ParsedURL purl, java.lang.String frame)
          Open a document in a web browser.
 int runtimeEnv()
          Find out which java runtime we're operating in.
 void status(java.lang.String msg)
          Show msg in the browser's status bar.
 

Field Detail

the

static final Environment.The the
Each running entity (be it an applet or an application), should have one and only one instance of an Environment. "the" is that singleton instance.


APPLICATION

static final int APPLICATION
See Also:
Constant Field Values

IE

static final int IE
See Also:
Constant Field Values

NS

static final int NS
See Also:
Constant Field Values

PLUGIN

static final int PLUGIN
See Also:
Constant Field Values
Method Detail

runtimeEnv

int runtimeEnv()
Find out which java runtime we're operating in.


browser

int browser()
Find out which browser we're running in.


status

void status(java.lang.String msg)
Show msg in the browser's status bar. Short form, with for (@link java.cm.applet.Applet#showStatus). Also more robust: avoids breaking when msg is null.


lookupStringPreference

java.lang.String lookupStringPreference(java.lang.String name)
Get a parameter or property, based on a key. Implements a name/value pair.

Parameters:
name - The name of the key.

codeBase

ParsedURL codeBase()
Change type from URL to ParsedURL.


docBase

ParsedURL docBase()
Change type from URL to ParsedURL.


exit

void exit(int code)
Called at the end of an invocation.

Parameters:
code - -- 0 for normal. other values are application specific.

navigate

void navigate(ParsedURL purl,
              java.lang.String frame)
Open a document in a web browser.

Parameters:
purl - The address of the web document.
frame - Frame to open it in within the web page. This may or may not be used.