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 classInterfaceEnvironment.OsTypestatic classInterfaceEnvironment.Snapshot3DMode -
Field Summary
Fields Modifier and Type Field Description protected static java.io.Filecurrent_dirstatic java.io.Fileinit_fileprotected static java.io.Filelog_fileprotected static LoggingTargetlogging_targetprotected static booleanlogging_timestampprotected static LoggingTypelogging_type -
Constructor Summary
Constructors Modifier Constructor Description protectedInterfaceEnvironment() -
Method Summary
Modifier and Type Method Description static booleanaddColourMap(java.io.File file)Load new colour map into the environment from the specified file.static booleanaddColourMap(ColourMap cm)Add new colour map to the environment.static booleanaddDataSourceDriver(java.lang.String params)Looks for format:static booleanaddDataSourceDriver(DataSourceDriver driver)Add the JDBC driverdriverto the environment.static booleanaddDataSourceDriver(DataSourceDriver driver, java.lang.Class<? extends DataSourceDialogPanel> panel_class)Add the JDBC driverdriverto the environment.static booleanaddInterfaceGraphicClass(java.lang.String name, java.lang.String full)static booleanaddInterfacePanelClass(java.lang.String name, java.lang.String full)static booleanaddInterfacePlotClass(java.lang.String name, java.lang.String full)static booleanaddNameMap(java.io.File file)Loads and adds a new name map to the environment.static voidaddNameMap(NameMap map)Adds a new name map to the environment.static booleanaddPipelineProcessLibrary(PipelineProcessLibrary library)Adds pipeline process library to this environment.static voidaddVideoTaskType(java.lang.String name, VideoTaskType type)static booleanderegisterPipelineProcessLibrary(java.lang.String library_name)Deregisters the given library.static java.util.ArrayList<Unit>getAllUnits()static java.io.FilegetApplicationDataDir()Returns the application data directory; if this is not set, returns the current dirstatic ColourMapgetColourMap(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.FilegetCurrentDir()Returns the current directorystatic DataSourceDrivergetDataSourceDriver(java.lang.String name)static DataSourceDrivergetDataSourceDriverByClass(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 SpatialUnitgetDefaultSpatialUnit()static java.util.ArrayList<DiscreteColourMap>getDiscreteColourMaps()Returns all loaded discrete colour maps.static InterfaceFramegetFrame()static java.util.ArrayList<InterfaceGraphicWindow>getGraphicsWindows()Deprecated.static java.io.FilegetInitFile()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 allInterfaceGraphicclasses 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 InterfacePanelgetInterfacePanelInstance(java.lang.String name)Creates an instance of the specified interface panel.static java.util.ArrayList<java.lang.String>getInterfacePanelNames()Returns a list of allInterfacePanelclasses 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 allInterfacePlotclasses currently loaded in this environment.static InterfaceIOTypegetIOType(java.lang.String name)Returns a the IO types associated withnamestatic InterfaceIOTypegetIOTypeForInstance(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 intgetLineHeight()Specifies the line width for panels usingLineLayouts orCategoryLayouts.static java.util.LocalegetLocale()Gets the locale.static java.io.FilegetLogFile()static LoggingTargetgetLoggingTarget()static booleangetLoggingTimestamp()static LoggingTypegetLoggingType()static java.lang.StringgetLookAndFeel()static intgetMaxDisplayVertices()Specifies the maximal number of vertices to display on a shape for the current system.static java.lang.StringgetNameForInterfaceGraphicClass(java.lang.Class<? extends InterfaceGraphic> _class)Returns the name corresponding to the given interface graphic class.static NameMapgetNameMap(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.StringgetNow(java.lang.String dateFormat)static InterfaceEnvironment.OsTypegetOsType()static PipelineProcessgetPipelineProcess(java.lang.String compound_name)Gets a specific pipeline process with the compound namecompound_name, of the form [library_name].[process_name].static PipelineProcessgetPipelineProcess(java.lang.String library_name, java.lang.String process_name)Gets a specific pipeline process with the nameprocess_namefrom the librarylibrary_name.static java.util.ArrayList<PipelineProcessLibrary>getPipelineProcessLibraries()Gets a list of all registered pipeline process libraries.static PipelineProcessLibrarygetPipelineProcessLibrary(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.Snapshot3DModegetSnapshot3DMode()Returns the current mode for take 3D screenshots.static SpatialUnitgetSpatialUnit(java.lang.String name)Returns the spatial unit with the specified name, ornullif not spatial unit exists by that name.static java.util.ArrayList<SpatialUnit>getSpatialUnits()static ParallelOutputStreamgetSystemErrorStream()Gets the system input stream.static ParallelOutputStreamgetSystemOutputStream()Gets the system output stream.static UnitgetUnit(java.lang.String name)static java.lang.StringgetVersion()static java.util.HashMap<java.lang.String,NodeShape>getVertexShapes()Returns a map of vertex shapes.static VideoTaskTypegetVideoTaskType(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 InterfaceWorkspacegetWorkspaceInstance()static java.lang.StringgetXMLHeader()static booleaninit()Initiate environment from the set init file, or the default init file if none is set.static booleaninit(InterfaceFrame frame, java.lang.String initFile)Initiate environment from a specified init file.static voidinitOSType()Initialize the environmentstatic booleanisInit()Indicates whether this environment has been initialized (i.e., theinitfunction has been called).booleanisTaskLocked()Indicates whether the environment is locked with a task.static voidready()This method should be called once a Workspace is instantiated and the Session is ready for use.static voidregisterPipelineProcessLibrary(PipelineProcessLibrary library)Registers a new pipeline process library.static booleanremoveDataSourceDriver(java.lang.String name)Removes the specified data source driver from the environment.static voidremoveNameMap(NameMap map)Removes a name map from the environment.static voidsetApplicationDataDir(java.lang.String dir)Sets the application data directory; if this is not set, returns the current dirstatic booleansetComboPanel(InterfaceComboPanel panel, InterfaceDisplayPanel dp, boolean sort)Fills a combo panel with new instances of all loaded InterfacePanel classesstatic voidsetDefaultSpatialUnit(java.lang.String name)static voidsetFrame(InterfaceFrame frame)static voidsetInitFile(java.lang.String file)static voidsetLocale(java.util.Locale newLocale)Sets the locale of this environment.booleansetLockTask(java.lang.String task)Attempts to lock the environment with the specified task.static voidsetLoggingType(LoggingType type)static voidsetLookAndFeel(java.lang.String s)static voidsetVersion(java.lang.String v)voidunsetTaskLock()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., theinitfunction 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 usingLineLayouts orCategoryLayouts.- 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:
trueif no errors were encountered,falseotherwise.
-
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:
getInterfaceObjectListin 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()returnstrueand 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, ornullif 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:
trueif 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
nullif 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
nullif 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 driverdriverto 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 driverdriverto 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:
trueif 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;
nullotherwise.
-
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. Returnsnullif 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_namefrom 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:
trueif removed;falseif 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
nullif not found.
-
getInterfaceGraphicInstance
Creates an instance of the specified graphic panel.- Parameters:
name-- Returns:
- new instance of specified panel, or
nullif not found.
-
getInterfacePlotInstance
Creates an instance of the specified plot panel.- Parameters:
name-- Returns:
- new instance of specified plot, or
nullif not found.
-
getInterfacePanelNames
public static java.util.ArrayList<java.lang.String> getInterfacePanelNames()Returns a list of allInterfacePanelclasses currently loaded in this environment.- Returns:
-
getInterfaceGraphicNames
public static java.util.ArrayList<java.lang.String> getInterfaceGraphicNames()Returns a list of allInterfaceGraphicclasses currently loaded in this environment.- Returns:
-
getInterfacePlotNames
public static java.util.ArrayList<java.lang.String> getInterfacePlotNames()Returns a list of allInterfacePlotclasses 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)
-