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
  • Field Details

    • init_file

      public static java.io.File init_file
    • current_dir

      protected static java.io.File current_dir
    • logging_target

      protected static LoggingTarget logging_target
    • logging_type

      protected static LoggingType 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

      public static boolean init​(InterfaceFrame frame, java.lang.String initFile)
      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., the init function has been called).
      Returns:
    • getOsType

      public static InterfaceEnvironment.OsType getOsType()
    • getLoggingTarget

      public static LoggingTarget getLoggingTarget()
    • getLoggingType

      public static LoggingType getLoggingType()
    • setLoggingType

      public static void setLoggingType​(LoggingType type)
    • getLogFile

      public static java.io.File getLogFile()
    • getLoggingTimestamp

      public static boolean getLoggingTimestamp()
    • getLineHeight

      public static int getLineHeight()
      Specifies the line width for panels using LineLayouts or CategoryLayouts.
      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

      public static InterfaceFrame getFrame()
    • setFrame

      public static void setFrame​(InterfaceFrame frame)
    • getWorkspaceInstance

      public static InterfaceWorkspace getWorkspaceInstance()
    • getSnapshot3DMode

      public static InterfaceEnvironment.Snapshot3DMode 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

      public 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).

      TODO: implement.

      Specified by:
      getInterfaceObjectList in interface Environment
      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() returns true 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

      public static ParallelOutputStream getSystemOutputStream()
      Gets the system output stream.
    • getSystemErrorStream

      public static ParallelOutputStream 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

      public static SpatialUnit getDefaultSpatialUnit()
    • getAllUnits

      public static java.util.ArrayList<Unit> getAllUnits()
    • getSpatialUnits

      public static java.util.ArrayList<SpatialUnit> getSpatialUnits()
    • getUnit

      public static Unit getUnit​(java.lang.String name)
    • getSpatialUnit

      public static SpatialUnit getSpatialUnit​(java.lang.String name)
      Returns the spatial unit with the specified name, or null 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

      public static boolean addColourMap​(ColourMap cm)
      Add new colour map to the environment.
      Parameters:
      cm -
      Returns:
    • getGraphicsWindows

      public static java.util.ArrayList<InterfaceGraphicWindow> getGraphicsWindows()
      Deprecated.
      Returns all loaded graphics windows.
      Returns:
      all loaded graphics windows
    • getColourMaps

      public static java.util.ArrayList<ColourMap> 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

      public static ColourMap getColourMap​(java.lang.String name)
      Gets a the colour map with the name name. 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

      public static java.util.ArrayList<ContinuousColourMap> getContinuousColourMaps()
      Returns all loaded continuous colour maps.
      Returns:
      all loaded continuous colour maps
    • getDiscreteColourMaps

      public static java.util.ArrayList<DiscreteColourMap> getDiscreteColourMaps()
      Returns all loaded discrete colour maps.
      Returns:
      all loaded discrete colour maps
    • addNameMap

      public static void addNameMap​(NameMap map)
      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

      public static void removeNameMap​(NameMap map)
      Removes a name map from the environment.
    • getNameMaps

      public static java.util.ArrayList<NameMap> getNameMaps()
      Gets a list of loaded name maps.
      Returns:
    • getNameMap

      public static NameMap getNameMap​(java.lang.String name)
      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

      public static DataSourceDriver getDataSourceDriver​(java.lang.String name)
    • getDataSourceDriverByClass

      public static DataSourceDriver getDataSourceDriverByClass​(java.lang.String className)
    • getVideoTaskTypes

      public static java.util.HashMap<java.lang.String,​VideoTaskType> getVideoTaskTypes()
      Returns a dialog panel for the indicated driver, if one exists. Otherwise returns null.
      Parameters:
      name - Name of the driver for which to find a dialog panel
    • getVideoTaskType

      public static VideoTaskType getVideoTaskType​(java.lang.Class c)
    • addVideoTaskType

      public static void addVideoTaskType​(java.lang.String name, VideoTaskType type)
    • 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

      public static boolean addDataSourceDriver​(DataSourceDriver driver)
      Add the JDBC driver driver 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 driver driver 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

      public static java.util.ArrayList<DataSource> getDataSources()
      Returns a list of the data sources loaded at init
      Returns:
    • getIOTypes

      public static java.util.HashMap<java.lang.String,​InterfaceIOType> getIOTypes()
      Returns a list of the IO types loaded at init
      Returns:
    • getIOType

      public static InterfaceIOType getIOType​(java.lang.String name)
      Returns a the IO types associated with name
      Parameters:
      name -
      Returns:
      the type, if one exists; null otherwise.
    • getIOTypeForInstance

      public static InterfaceIOType getIOTypeForInstance​(InterfaceIO instance)
      Return the I/O type associated with the specific instance of InterfaceIO.
      Parameters:
      instance -
      Returns:
    • getIOTypesForClass

      public static java.util.ArrayList<InterfaceIOType> getIOTypesForClass​(java.lang.Class<?> clazz)
      Return all I/O types which are assignable from clazz.
      Parameters:
      clazz -
      Returns:
    • getXMLHeader

      public static java.lang.String getXMLHeader()
    • getVertexShapes

      public static java.util.HashMap<java.lang.String,​NodeShape> getVertexShapes()
      Returns a map of vertex shapes.
      Returns:
    • getPipelineProcessLibraries

      public static java.util.ArrayList<PipelineProcessLibrary> getPipelineProcessLibraries()
      Gets a list of all registered pipeline process libraries.
      Returns:
      list of all registered pipeline processes
    • getPipelineProcessLibrary

      public static PipelineProcessLibrary getPipelineProcessLibrary​(java.lang.String name)
      Returns the pipeline process library with the given name. Returns null if no such library exists in this environment.
      Parameters:
      name -
      Returns:
    • addPipelineProcessLibrary

      public static boolean addPipelineProcessLibrary​(PipelineProcessLibrary library)
      Adds pipeline process library to this environment.
      Parameters:
      name -
      Returns:
    • getProcesses

      public static java.util.ArrayList<PipelineProcess> getProcesses​(java.lang.String library_name)
      Returns a list of processes contained in the given library.
      Parameters:
      library_name -
      Returns:
    • getPipelineProcess

      public static PipelineProcess getPipelineProcess​(java.lang.String compound_name)
      Gets a specific pipeline process with the compound name compound_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 name process_name from the library library_name.
      Parameters:
      library_name -
      process_name -
      Returns:
      pipeline process with the name process_name
    • registerPipelineProcessLibrary

      public static void registerPipelineProcessLibrary​(PipelineProcessLibrary library)
      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

      public static InterfacePanel getInterfacePanelInstance​(java.lang.String name)
      Creates an instance of the specified interface panel.
      Parameters:
      name -
      Returns:
      new instance of specified panel, or null if not found.
    • getInterfaceGraphicInstance

      public static InterfaceGraphic<?> getInterfaceGraphicInstance​(java.lang.String name)
      Creates an instance of the specified graphic panel.
      Parameters:
      name -
      Returns:
      new instance of specified panel, or null if not found.
    • getInterfacePlotInstance

      public static InterfacePlot<?> getInterfacePlotInstance​(java.lang.String name)
      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 all InterfacePanel classes currently loaded in this environment.
      Returns:
    • getInterfaceGraphicNames

      public static java.util.ArrayList<java.lang.String> getInterfaceGraphicNames()
      Returns a list of all InterfaceGraphic classes currently loaded in this environment.
      Returns:
    • getInterfacePlotNames

      public static java.util.ArrayList<java.lang.String> getInterfacePlotNames()
      Returns a list of all InterfacePlot 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)