Package mgui.interfaces
Class InterfaceEnvironment
java.lang.Object
mgui.interfaces.InterfaceEnvironment
- All Implemented Interfaces:
Environment
public class InterfaceEnvironment extends java.lang.Object implements Environment
Stores environmental variables and provides static methods to retrieve them. The
init()
method should be called by InterfaceFrame
in order to calibrate the session environment
from a specific init file. By default this file is /mgui/resources/init/mgui.model.init.- Since:
- 1.0 TODO: implement logging to file
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InterfaceEnvironment.OsType
static class
InterfaceEnvironment.Snapshot3DMode
-
Field Summary
Fields Modifier and Type Field Description protected static java.io.File
current_dir
static java.io.File
init_file
protected static java.io.File
log_file
protected static LoggingTarget
logging_target
protected static boolean
logging_timestamp
protected static LoggingType
logging_type
-
Constructor Summary
Constructors Modifier Constructor Description protected
InterfaceEnvironment()
-
Method Summary
Modifier and Type Method Description static boolean
addColourMap(java.io.File file)
Load new colour map into the environment from the specified file.static boolean
addColourMap(ColourMap cm)
Add new colour map to the environment.static boolean
addDataSourceDriver(java.lang.String params)
Looks for format:static boolean
addDataSourceDriver(DataSourceDriver driver)
Add the JDBC driverdriver
to the environment.static boolean
addDataSourceDriver(DataSourceDriver driver, java.lang.Class<? extends DataSourceDialogPanel> panel_class)
Add the JDBC driverdriver
to the environment.static boolean
addInterfaceGraphicClass(java.lang.String name, java.lang.String full)
static boolean
addInterfacePanelClass(java.lang.String name, java.lang.String full)
static boolean
addInterfacePlotClass(java.lang.String name, java.lang.String full)
static boolean
addNameMap(java.io.File file)
Loads and adds a new name map to the environment.static void
addNameMap(NameMap map)
Adds a new name map to the environment.static boolean
addPipelineProcessLibrary(PipelineProcessLibrary library)
Adds pipeline process library to this environment.static void
addVideoTaskType(java.lang.String name, VideoTaskType type)
static boolean
deregisterPipelineProcessLibrary(java.lang.String library_name)
Deregisters the given library.static java.util.ArrayList<Unit>
getAllUnits()
static java.io.File
getApplicationDataDir()
Returns the application data directory; if this is not set, returns the current dirstatic ColourMap
getColourMap(java.lang.String name)
Gets a the colour map with the namename
.static java.util.ArrayList<ColourMap>
getColourMaps()
Gets a list of currently loaded colour maps.static java.util.ArrayList<ContinuousColourMap>
getContinuousColourMaps()
Returns all loaded continuous colour maps.static java.io.File
getCurrentDir()
Returns the current directorystatic DataSourceDriver
getDataSourceDriver(java.lang.String name)
static DataSourceDriver
getDataSourceDriverByClass(java.lang.String className)
static java.util.ArrayList<java.lang.String>
getDataSourceDriverNames()
Returns a list of the currently loaded data source drivers.static java.util.ArrayList<DataSource>
getDataSources()
Returns a list of the data sources loaded at initstatic SpatialUnit
getDefaultSpatialUnit()
static java.util.ArrayList<DiscreteColourMap>
getDiscreteColourMaps()
Returns all loaded discrete colour maps.static InterfaceFrame
getFrame()
static java.util.ArrayList<InterfaceGraphicWindow>
getGraphicsWindows()
Deprecated.static java.io.File
getInitFile()
static InterfaceGraphic<?>
getInterfaceGraphicInstance(java.lang.String name)
Creates an instance of the specified graphic panel.static java.util.ArrayList<java.lang.String>
getInterfaceGraphicNames()
Returns a list of allInterfaceGraphic
classes currently loaded in this environment.java.util.ArrayList<InterfaceObject>
getInterfaceObjectList(java.lang.String name)
Returns a named list of interface objects, probably belonging to a particular container and having the same type (although this is not necessarily true).static InterfacePanel
getInterfacePanelInstance(java.lang.String name)
Creates an instance of the specified interface panel.static java.util.ArrayList<java.lang.String>
getInterfacePanelNames()
Returns a list of allInterfacePanel
classes currently loaded in this environment.static InterfacePlot<?>
getInterfacePlotInstance(java.lang.String name)
Creates an instance of the specified plot panel.static java.util.ArrayList<java.lang.String>
getInterfacePlotNames()
Returns a list of allInterfacePlot
classes currently loaded in this environment.static InterfaceIOType
getIOType(java.lang.String name)
Returns a the IO types associated withname
static InterfaceIOType
getIOTypeForInstance(InterfaceIO instance)
Return the I/O type associated with the specific instance ofInterfaceIO
.static java.util.HashMap<java.lang.String,InterfaceIOType>
getIOTypes()
Returns a list of the IO types loaded at initstatic java.util.ArrayList<InterfaceIOType>
getIOTypesForClass(java.lang.Class<?> clazz)
Return all I/O types which are assignable fromclazz
.static int
getLineHeight()
Specifies the line width for panels usingLineLayout
s orCategoryLayout
s.static java.util.Locale
getLocale()
Gets the locale.static java.io.File
getLogFile()
static LoggingTarget
getLoggingTarget()
static boolean
getLoggingTimestamp()
static LoggingType
getLoggingType()
static java.lang.String
getLookAndFeel()
static int
getMaxDisplayVertices()
Specifies the maximal number of vertices to display on a shape for the current system.static java.lang.String
getNameForInterfaceGraphicClass(java.lang.Class<? extends InterfaceGraphic> _class)
Returns the name corresponding to the given interface graphic class.static NameMap
getNameMap(java.lang.String name)
Gets the NameMap with the specified namestatic java.util.ArrayList<NameMap>
getNameMaps()
Gets a list of loaded name maps.static java.lang.String
getNow(java.lang.String dateFormat)
static InterfaceEnvironment.OsType
getOsType()
static PipelineProcess
getPipelineProcess(java.lang.String compound_name)
Gets a specific pipeline process with the compound namecompound_name
, of the form [library_name].[process_name].static PipelineProcess
getPipelineProcess(java.lang.String library_name, java.lang.String process_name)
Gets a specific pipeline process with the nameprocess_name
from the librarylibrary_name
.static java.util.ArrayList<PipelineProcessLibrary>
getPipelineProcessLibraries()
Gets a list of all registered pipeline process libraries.static PipelineProcessLibrary
getPipelineProcessLibrary(java.lang.String name)
Returns the pipeline process library with the given name.static java.util.ArrayList<PipelineProcess>
getProcesses(java.lang.String library_name)
Returns a list of processes contained in the given library.static InterfaceEnvironment.Snapshot3DMode
getSnapshot3DMode()
Returns the current mode for take 3D screenshots.static SpatialUnit
getSpatialUnit(java.lang.String name)
Returns the spatial unit with the specified name, ornull
if not spatial unit exists by that name.static java.util.ArrayList<SpatialUnit>
getSpatialUnits()
static ParallelOutputStream
getSystemErrorStream()
Gets the system input stream.static ParallelOutputStream
getSystemOutputStream()
Gets the system output stream.static Unit
getUnit(java.lang.String name)
static java.lang.String
getVersion()
static java.util.HashMap<java.lang.String,NodeShape>
getVertexShapes()
Returns a map of vertex shapes.static VideoTaskType
getVideoTaskType(java.lang.Class c)
static java.util.HashMap<java.lang.String,VideoTaskType>
getVideoTaskTypes()
Returns a dialog panel for the indicated driver, if one exists.static InterfaceWorkspace
getWorkspaceInstance()
static java.lang.String
getXMLHeader()
static boolean
init()
Initiate environment from the set init file, or the default init file if none is set.static boolean
init(InterfaceFrame frame, java.lang.String initFile)
Initiate environment from a specified init file.static void
initOSType()
Initialize the environmentstatic boolean
isInit()
Indicates whether this environment has been initialized (i.e., theinit
function has been called).boolean
isTaskLocked()
Indicates whether the environment is locked with a task.static void
ready()
This method should be called once a Workspace is instantiated and the Session is ready for use.static void
registerPipelineProcessLibrary(PipelineProcessLibrary library)
Registers a new pipeline process library.static boolean
removeDataSourceDriver(java.lang.String name)
Removes the specified data source driver from the environment.static void
removeNameMap(NameMap map)
Removes a name map from the environment.static void
setApplicationDataDir(java.lang.String dir)
Sets the application data directory; if this is not set, returns the current dirstatic boolean
setComboPanel(InterfaceComboPanel panel, InterfaceDisplayPanel dp, boolean sort)
Fills a combo panel with new instances of all loaded InterfacePanel classesstatic void
setDefaultSpatialUnit(java.lang.String name)
static void
setFrame(InterfaceFrame frame)
static void
setInitFile(java.lang.String file)
static void
setLocale(java.util.Locale newLocale)
Sets the locale of this environment.boolean
setLockTask(java.lang.String task)
Attempts to lock the environment with the specified task.static void
setLoggingType(LoggingType type)
static void
setLookAndFeel(java.lang.String s)
static void
setVersion(java.lang.String v)
void
unsetTaskLock()
Unlocks the environment from its present task.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
init_file
public static java.io.File init_file -
current_dir
protected static java.io.File current_dir -
logging_target
-
logging_type
-
logging_timestamp
protected static boolean logging_timestamp -
log_file
protected static java.io.File log_file
-
-
Constructor Details
-
InterfaceEnvironment
protected InterfaceEnvironment()
-
-
Method Details
-
init
Initiate environment from a specified init file.- Parameters:
frame
-initFile
-- Returns:
-
isInit
public static boolean isInit()Indicates whether this environment has been initialized (i.e., theinit
function has been called).- Returns:
-
getOsType
-
getLoggingTarget
-
getLoggingType
-
setLoggingType
-
getLogFile
public static java.io.File getLogFile() -
getLoggingTimestamp
public static boolean getLoggingTimestamp() -
getLineHeight
public static int getLineHeight()Specifies the line width for panels usingLineLayout
s orCategoryLayout
s.- Returns:
-
getMaxDisplayVertices
public static int getMaxDisplayVertices()Specifies the maximal number of vertices to display on a shape for the current system. Shapes with more vertices than this should not attempt to render them. -
initOSType
public static void initOSType()Initialize the environment -
getFrame
-
setFrame
-
getWorkspaceInstance
-
getSnapshot3DMode
Returns the current mode for take 3D screenshots. One of:- OffscreenBuffer [default]: Write to an offscreen buffer
- ScreenCapture : Use a screen capture to get the graphics; only use if buffer is not working with your system
- Returns:
-
getCurrentDir
public static java.io.File getCurrentDir()Returns the current directory- Returns:
-
getApplicationDataDir
public static java.io.File getApplicationDataDir()Returns the application data directory; if this is not set, returns the current dir- Parameters:
line
-- Returns:
-
setApplicationDataDir
public static void setApplicationDataDir(java.lang.String dir)Sets the application data directory; if this is not set, returns the current dir- Parameters:
line
-
-
init
public static boolean init()Initiate environment from the set init file, or the default init file if none is set. Terminates execution if init file is not found.- Returns:
true
if no errors were encountered,false
otherwise.
-
ready
public static void ready()This method should be called once a Workspace is instantiated and the Session is ready for use. -
setLookAndFeel
public static void setLookAndFeel(java.lang.String s) -
getLookAndFeel
public static java.lang.String getLookAndFeel() -
getInterfaceObjectList
Returns a named list of interface objects, probably belonging to a particular container and having the same type (although this is not necessarily true).TODO: implement.
- Specified by:
getInterfaceObjectList
in interfaceEnvironment
- Parameters:
name
-- Returns:
-
setLockTask
public boolean setLockTask(java.lang.String task)Attempts to lock the environment with the specified task. Once the environment locks,isTaskLocked()
returnstrue
and new tasks should not be run.- Parameters:
task
- name of the task to be run; should indicate class, function, and time started- Returns:
-
unsetTaskLock
public void unsetTaskLock()Unlocks the environment from its present task. -
isTaskLocked
public boolean isTaskLocked()Indicates whether the environment is locked with a task. If so, new tasks should not be run.- Returns:
- true if environment is locked; false otherwise.
-
getSystemOutputStream
Gets the system output stream. -
getSystemErrorStream
Gets the system input stream. -
setLocale
public static void setLocale(java.util.Locale newLocale)Sets the locale of this environment.- Parameters:
newLocale
-
-
getLocale
public static java.util.Locale getLocale()Gets the locale. -
setInitFile
public static void setInitFile(java.lang.String file) -
getInitFile
public static java.io.File getInitFile() -
setDefaultSpatialUnit
public static void setDefaultSpatialUnit(java.lang.String name) -
getDefaultSpatialUnit
-
getAllUnits
-
getSpatialUnits
-
getUnit
-
getSpatialUnit
Returns the spatial unit with the specified name, ornull
if not spatial unit exists by that name.- Parameters:
name
-- Returns:
-
addColourMap
public static boolean addColourMap(java.io.File file)Load new colour map into the environment from the specified file.- Parameters:
cm
-- Returns:
true
if successful.
-
addColourMap
Add new colour map to the environment.- Parameters:
cm
-- Returns:
-
getGraphicsWindows
Deprecated.Returns all loaded graphics windows.- Returns:
- all loaded graphics windows
-
getColourMaps
Gets a list of currently loaded colour maps. List is a direct link, since components will want to access an updated version.TODO: This presents concurrency issues; address
- Returns:
- The list of colour maps
-
getColourMap
Gets a the colour map with the namename
. List is a direct link, since components will want to access an updated version.TODO: This presents concurrency issues; address
- Parameters:
name
- Name of the colour map to return- Returns:
- the corresponding colour map, or
null
if none were found
-
getContinuousColourMaps
Returns all loaded continuous colour maps.- Returns:
- all loaded continuous colour maps
-
getDiscreteColourMaps
Returns all loaded discrete colour maps.- Returns:
- all loaded discrete colour maps
-
addNameMap
Adds a new name map to the environment.- Parameters:
map
-
-
addNameMap
public static boolean addNameMap(java.io.File file)Loads and adds a new name map to the environment.- Parameters:
map
-
-
removeNameMap
Removes a name map from the environment. -
getNameMaps
Gets a list of loaded name maps.- Returns:
-
getNameMap
Gets the NameMap with the specified name- Returns:
-
addInterfacePanelClass
public static boolean addInterfacePanelClass(java.lang.String name, java.lang.String full) -
addInterfacePlotClass
public static boolean addInterfacePlotClass(java.lang.String name, java.lang.String full) -
addInterfaceGraphicClass
public static boolean addInterfaceGraphicClass(java.lang.String name, java.lang.String full) -
getNameForInterfaceGraphicClass
public static java.lang.String getNameForInterfaceGraphicClass(java.lang.Class<? extends InterfaceGraphic> _class)Returns the name corresponding to the given interface graphic class.- Parameters:
_class
-- Returns:
- The name, or
null
if no such class is installed
-
getDataSourceDriverNames
public static java.util.ArrayList<java.lang.String> getDataSourceDriverNames()Returns a list of the currently loaded data source drivers.- Returns:
-
getDataSourceDriver
-
getDataSourceDriverByClass
-
getVideoTaskTypes
Returns a dialog panel for the indicated driver, if one exists. Otherwise returnsnull
.- Parameters:
name
- Name of the driver for which to find a dialog panel
-
getVideoTaskType
-
addVideoTaskType
-
setComboPanel
public static boolean setComboPanel(InterfaceComboPanel panel, InterfaceDisplayPanel dp, boolean sort)Fills a combo panel with new instances of all loaded InterfacePanel classes- Parameters:
panel
-- Returns:
-
addDataSourceDriver
public static boolean addDataSourceDriver(java.lang.String params)Looks for format:#addDataSourceDriver name_without_spaces driver_class [user] [login]
- Parameters:
params
-- Returns:
-
addDataSourceDriver
Add the JDBC driverdriver
to the environment. Fails if a driver of the same name already exists.- Parameters:
driver
-- Returns:
-
addDataSourceDriver
public static boolean addDataSourceDriver(DataSourceDriver driver, java.lang.Class<? extends DataSourceDialogPanel> panel_class)Add the JDBC driverdriver
to the environment. Fails if a driver of the same name already exists.- Parameters:
driver
-- Returns:
-
removeDataSourceDriver
public static boolean removeDataSourceDriver(java.lang.String name)Removes the specified data source driver from the environment.- Parameters:
name
-- Returns:
true
if data source driver was removed
-
getDataSources
Returns a list of the data sources loaded at init- Returns:
-
getIOTypes
Returns a list of the IO types loaded at init- Returns:
-
getIOType
Returns a the IO types associated withname
- Parameters:
name
-- Returns:
- the type, if one exists;
null
otherwise.
-
getIOTypeForInstance
Return the I/O type associated with the specific instance ofInterfaceIO
.- Parameters:
instance
-- Returns:
-
getIOTypesForClass
Return all I/O types which are assignable fromclazz
.- Parameters:
clazz
-- Returns:
-
getXMLHeader
public static java.lang.String getXMLHeader() -
getVertexShapes
Returns a map of vertex shapes.- Returns:
-
getPipelineProcessLibraries
Gets a list of all registered pipeline process libraries.- Returns:
- list of all registered pipeline processes
-
getPipelineProcessLibrary
Returns the pipeline process library with the given name. Returnsnull
if no such library exists in this environment.- Parameters:
name
-- Returns:
-
addPipelineProcessLibrary
Adds pipeline process library to this environment.- Parameters:
name
-- Returns:
-
getProcesses
Returns a list of processes contained in the given library.- Parameters:
library_name
-- Returns:
-
getPipelineProcess
Gets a specific pipeline process with the compound namecompound_name
, of the form [library_name].[process_name].- Parameters:
compound_name
-- Returns:
- pipeline process with the name
process_name
-
getPipelineProcess
public static PipelineProcess getPipelineProcess(java.lang.String library_name, java.lang.String process_name)Gets a specific pipeline process with the nameprocess_name
from the librarylibrary_name
.- Parameters:
library_name
-process_name
-- Returns:
- pipeline process with the name
process_name
-
registerPipelineProcessLibrary
Registers a new pipeline process library.- Parameters:
process
- process to register
-
deregisterPipelineProcessLibrary
public static boolean deregisterPipelineProcessLibrary(java.lang.String library_name)Deregisters the given library.- Parameters:
library_name
-- Returns:
true
if removed;false
if library is not registered with this environment.
-
getInterfacePanelInstance
Creates an instance of the specified interface panel.- Parameters:
name
-- Returns:
- new instance of specified panel, or
null
if not found.
-
getInterfaceGraphicInstance
Creates an instance of the specified graphic panel.- Parameters:
name
-- Returns:
- new instance of specified panel, or
null
if not found.
-
getInterfacePlotInstance
Creates an instance of the specified plot panel.- Parameters:
name
-- Returns:
- new instance of specified plot, or
null
if not found.
-
getInterfacePanelNames
public static java.util.ArrayList<java.lang.String> getInterfacePanelNames()Returns a list of allInterfacePanel
classes currently loaded in this environment.- Returns:
-
getInterfaceGraphicNames
public static java.util.ArrayList<java.lang.String> getInterfaceGraphicNames()Returns a list of allInterfaceGraphic
classes currently loaded in this environment.- Returns:
-
getInterfacePlotNames
public static java.util.ArrayList<java.lang.String> getInterfacePlotNames()Returns a list of allInterfacePlot
classes currently loaded in this environment.- Returns:
-
getVersion
public static java.lang.String getVersion() -
setVersion
public static void setVersion(java.lang.String v) -
getNow
public static java.lang.String getNow(java.lang.String dateFormat)
-