Class ViewUserInterface

java.lang.Object
gov.nih.mipav.view.ViewUserInterface
All Implemented Interfaces:
ScriptRecordingListener, CommandLineParser, ActionListener, KeyListener, WindowListener, EventListener

public class ViewUserInterface extends Object implements ActionListener, WindowListener, KeyListener, ScriptRecordingListener, CommandLineParser
This class is the _glue_ keeps a record of the present structure of the application. It keeps a list of all the image frames presently being displayed and keeps a hash table of all the images (ModelImage) open in the application. In addition, this class keeps a reference to the main MIPAV frame and the message frame with much of the imaging results are output.
Version:
1.1 June 1, 2012
Author:
Justin Senseney, Matthew McAuliffe, Ph.D.
  • Field Details

    • userInterfaceReference

      protected static ViewUserInterface userInterfaceReference
      A reference to the only ViewUserInterface object in MIPAV.
      See Also:
    • OPENING_STR

      private static final String OPENING_STR
      String to use as the progress bar opening prefix.
      See Also:
    • LOADING_STR

      private static final String LOADING_STR
      String to use as the progress bar loading prefix.
      See Also:
    • shortcutEd

      private static JDialogShortcutEditor shortcutEd
      Key shortcut editor dialog.
    • providedUserDefaultDir

      private static boolean providedUserDefaultDir
      This boolean tells if the user has provided an inputDir parameter as a command line argument when running a script
    • userDefaultDir

      private static String userDefaultDir
      This is the inputDir path that the user entered as a command line argument when running a script *
    • providedOutputDir

      private static boolean providedOutputDir
      This boolean tells if the user has provided an ouputDir parameter as a command line argument when running a script
    • outputDir

      private static String outputDir
      This is the outputDir path that the user entered as a command line argument when running a script *
    • mainFrame

      protected JFrame mainFrame
      The main menu bar that runs MIPAV.
    • messageField

      protected JTextField messageField
      Message line at the bottom of the mainFrame.
    • messageFrame

      protected ViewJFrameMessage messageFrame
      Message area for multi-line text output. The message area has the ability to save/copy/paste the data to a file or clip board. This frame contains the Global Data, Data, Logging and Debug text areas. The Global and Debug text areas are common to all images (i.e. there is only one). The Data and logging window are unique and associated to their respect image.
    • openingMenuBar

      protected JMenuBar openingMenuBar
      Initial menubar for MIPAV.
    • clippedMatrix

      private TransMatrix clippedMatrix
      Matrix for copy/paste actions in image's or between image's matrix edit panel.
    • clippedScannerVectors

      private final Vector<Vector<WildMagic.LibFoundation.Mathematics.Vector3f>> clippedScannerVectors
      DOCUMENT ME!
    • clippedVOIs

      private final ViewVOIVector clippedVOIs
      Vector to hold clipped VOIs (multiple).
    • copyVOIList

      private Vector<VOIBase> copyVOIList
      Vector to hold clipped VOIs (multiple).
    • copyVOINameList

      private final Vector<String> copyVOINameList
      Vector to hold VOI names (multiple).
    • jarClassLoader

      private JarClassLoader jarClassLoader
      Class/resource loader for plugins that are in jars
    • cmdLineArguments

      private String cmdLineArguments
      String holding the command line arguments for data provenance usage.
    • DICOMcatcher

      private DICOM_Receiver DICOMcatcher
      Reference to the DICOM receiver that listens for DICOM formatted images sent by a DICOM server.
    • DICOMQueryFrame

      private ViewJFrameDICOMQuery DICOMQueryFrame
      DICOM query frame for sending and receiving DICOM images.
    • frameLocation

      private final Dimension frameLocation
      Location of new image frames. This location is updated with each additional image opened.
      See Also:
      • invalid reference
        #getNewFrameLocation()
    • imageFrameVector

      private final Vector<Frame> imageFrameVector
      Stores array of images frames the first of which is the active image frame.
    • imageHashtable

      private final CustomHashtable<ModelImage> imageHashtable
      A list of image models currently open in MIPAV.
    • imgMonitorFrame

      private ViewJFrameRegisteredImages imgMonitorFrame
      Frame that monitors the registered images.
    • isAppFrameVisible

      private boolean isAppFrameVisible
      Whether the mipav GUI should be shown; set by the -hide command line option.
    • isPlugInFrameVisible

      private boolean isPlugInFrameVisible
      Whether a plugin standalone frame is visible
    • lastStackFlag

      private boolean lastStackFlag
      Indicates the user's last choice of whether to open images as multi-file (stack) or single file in the file open dialog.
    • mallocFrame

      private JDialogMemoryAllocation mallocFrame
      Dialog that allows changes to the amount of heap requested of the system by the java Virtual Machine for MIPAV during java start.
    • memoryFrame

      private ViewJFrameMemory memoryFrame
      Dialog that displays the used and available memory.
    • dpDialog

      private JDialogDataProvenance dpDialog
      Dialog to display the mipav system data provenance
    • memoryUsageLabel

      private JLabel memoryUsageLabel
      The label showing the current memory usage of MIPAV.
    • btnMultiCore

      private JButton btnMultiCore
      The button indicating that MIPAV is set to run in a threaded environment
    • btnGpuComp

      private JButton btnGpuComp
      The button indicating that MIPAV is set to run OpenCL -- GPU based algorithms
    • memoryUsageUpdater

      private ViewUserInterface.MemoryUsageUpdater memoryUsageUpdater
      The periodic thread which updates the memory usage display once every second.
      See Also:
    • optionsDialog

      private JDialogMipavOptions optionsDialog
      Dialog that allows changes to the amount of heap requested of the system by the java Virtual Machine for MIPAV during java start.
    • pluginsMenu

      private JMenu pluginsMenu
      Stores the plugins menu so that it can be removed/updated when plugins are installed.
    • aloneMenu

      protected Vector<JMenuBar> aloneMenu
      Stores all stand-alone menus that have been created by the user.
    • progressBarPrefix

      private String progressBarPrefix
      The current progress bar prefix to use.
    • shortcutRecording

      private boolean shortcutRecording
      Indicates whether the user is currently recording a new keyboard shortcut using the shortcut editor dialog.
    • systemDPHolder

      private ProvenanceHolder systemDPHolder
      System DP holder (separate from images data provenance...this has everything).
    • forceAlgorithmInPlace

      private boolean forceAlgorithmInPlace
      boolean to force the algorithm to replace the image rather than opening a new frame
    • exitCmdLineOnError

      private boolean exitCmdLineOnError
      error handling for cmd line, if set to false will not exit on MipavUtil.displayError()
    • numTileSheets

      private int numTileSheets
      if user selects to open images as tiles, then this counter tells us how many tile sheets there are*
    • exceptions

      private static File exceptions
      Exception logging file
    • tempDirList

      private static Vector<String> tempDirList
  • Constructor Details

    • ViewUserInterface

      protected ViewUserInterface()
      Constructs main UI frame. Accesses the .preferences file to set up variables. Sets up DICOM hashtable for reading in DICOM files and starts the catcher, if appropriate. This method cannot be called directly. To use this constructor, you must call createReference. This class is a singleton, which means that only one type of this class is allowed to be instantiated in a single VM.
    • ViewUserInterface

      protected ViewUserInterface(boolean forceQuiet)
      Constructs main UI frame. Accesses the .preferences file to set up variables. Sets up DICOM hashtable for reading in DICOM files and starts the catcher, if appropriate. This method cannot be called directly. To use this constructor, you must call createReference. This class is a singleton, which means that only one type of this class is allowed to be instantiated in a single VM.
      Parameters:
      forceQuiet - Mipav will not display any error, warning, or info messages. If a error displays MIPAV will exit.
  • Method Details

    • create

      public static ViewUserInterface create()
      This method should only be called once, and it should only be called by MipavMain to during the initialization of MIPAV.
      Returns:
      ViewUserInterface
    • getReference

      public static ViewUserInterface getReference()
      Get a reference to the ViewUserInterface object.
      Returns:
      ViewUserInterface
    • about

      public void about()
      Creates simple dialog that describes basic info about MIPAV, with MIPAV as the title.
    • about

      public void about(String title, String filename)
      Creates a fairly simple plain-text viewing box.
      Parameters:
      title - the title for the about frame.
      filename - the filename of the about file to display.
    • aboutDataProvenance

      public void aboutDataProvenance()
      Displays the system data provenance using a simple dialog with table and jtextarea (for current selection).

      .

    • aboutJava

      public void aboutJava()
      Creates simple dialog that describes basic info about the version of Java.
    • addAloneMenu

      public boolean addAloneMenu(JMenuBar menu)
      Adds a standalone menu to the user interface.
      Parameters:
      menu - the standalone JMenu
      Returns:
      whether addition to the vector was successful
    • actionPerformed

      public void actionPerformed(ActionEvent event)
      Calls various methods based on the user's actions.
      Specified by:
      actionPerformed in interface ActionListener
      Parameters:
      event - Event that triggered this function.
    • createEmptyImage

      public ModelImage createEmptyImage(FileInfoBase fileInfo)
      Creates a blank Image based on the information found in the default fileInfo object.
      Parameters:
      fileInfo - This object contains the enough image information to build a ModelImage with nothing inside (eg. blank image).
      image - Created blank image.
    • copyClippedVOIs

      @Deprecated public void copyClippedVOIs(ViewVOIVector copyList)
      Deprecated.
      Copies into the VOI clipboard.
      Parameters:
      voi - VOI
    • copyVOIs

      public void copyVOIs(Vector<VOIBase> copyList)
    • buildAnonDirectoryDialog

      public void buildAnonDirectoryDialog()
      Builds the anonymize directory dialog and displays it.
    • buildDICOMFrame

      public ViewJFrameDICOMParser buildDICOMFrame()
      Builds the image tree dialog and displays it.
    • buildEditDICOMFrame

      public void buildEditDICOMFrame()
      Builds the edit dicom tag interface.
    • buildDICOMDIRFrame

      public JDialogDicomDir buildDICOMDIRFrame()
      Builds the image tree dialog and displays it.
    • buildMenu

      public JMenuBar buildMenu()
      Builds menus for the User Interface.
    • buildMessageFrame

      public ViewJFrameMessage buildMessageFrame()
      Builds the message frame where user/program data can be displayed.
    • buildPlugInsMenu

      public JMenu buildPlugInsMenu(ActionListener al)
      Called by either userInterface (this) or by another actionlistener (ViewJFrameImage) to build the plugins menu bar.
      Parameters:
      al - the listener that wants to know about actions on the plugins menu
      Returns:
      the new plugin menu
    • addPluginToMenu

      private void addPluginToMenu(Class<?> plugin, String pluginName, String name, JMenu currentMenu, ActionListener al, String jarContainer)
    • deleteMenu

      private void deleteMenu(JMenu menu)
      Recursive deletion algorithm to delete JMenus which contain no JMenuItems exclusive of JMenus in any children.
      Parameters:
      menu - The menu to run through deletion
    • loadMouseDrivers

      private void loadMouseDrivers()
    • buildTreeDialog

      public void buildTreeDialog()
      Builds the image tree dialog and displays it.
    • changeRecordingStatus

      public void changeRecordingStatus(int recorderStatus)
      Alerts the listener to a change in whether the ScriptRecorder is currently recording a script..*
      Specified by:
      changeRecordingStatus in interface ScriptRecordingListener
      Parameters:
      recorderStatus - DOCUMENT ME!
    • clearAllDataText

      public final void clearAllDataText()
      Accessor to clear all of data frame.
    • clearClippedVOIs

      @Deprecated public void clearClippedVOIs()
      Deprecated.
      DOCUMENT ME!
    • createBlankImage

      public ModelImage createBlankImage(FileInfoBase fileInfo)
      Creates a blank Image based on the information found in the fileInfo object and places it in a frame.
      Parameters:
      fileInfo - This object contains the enough image information to build a ModelImage with nothing inside (eg. blank image).
    • createBlankImage

      public ModelImage createBlankImage(FileInfoBase fileInfo, boolean doDisplay, boolean allowRecording)
      Creates a blank Image based on the information found in the fileInfo object.
      Parameters:
      fileInfo - This object contains the enough image information to build a ModelImage with nothing inside (eg. blank image).
      doDisplay -
      allowRecording -
    • enableOutputWindow

      public void enableOutputWindow(boolean doShowFrame)
      Toggles the display of the Output window and updates all JFrameImages so that the menu checkbox will reflect the status of the output window.
      Parameters:
      doShowFrame - Whether the output window should be shown.
    • getActiveImageFrame

      public ViewJFrameImage getActiveImageFrame()
      Accessor that returns the active image frame vector. If the top frame is not an image frame, then the frame vector is iterated until an image frame is found. If none is found then null is returned.
      Returns:
      The vector that has a list of frames visible in the GUI.
    • getAppTitle

      public String getAppTitle()
      Accessor to get the title of this application.
      Returns:
      The title of this application.
    • getClippedMatrix

      public TransMatrix getClippedMatrix()
      Retrieves the clipped matrix for paste action.
      Returns:
      clippedMatrix
    • getClippedScannerVectors

      @Deprecated public Vector<Vector<WildMagic.LibFoundation.Mathematics.Vector3f>> getClippedScannerVectors()
      Deprecated.
      DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • getClippedVOIs

      @Deprecated public ViewVOIVector getClippedVOIs()
      Deprecated.
      Returns the VOIs copied into the clip board. For copying and pasting VOIs between images.
      Returns:
      Vector
    • getCopyVOIs

      public Vector<VOIBase> getCopyVOIs()
    • getCopyVOINames

      public Vector<String> getCopyVOINames()
    • getCmdLineArguments

      public String getCmdLineArguments()
      Returns the Command line arguments (as one string, each separated by a space) .@return command line arguments concatenated with spaces
      Returns:
      DOCUMENT ME!
    • getDefaultDirectory

      public String getDefaultDirectory()
      Accessor to get directory location of last file access.
      Returns:
      The last file directory
    • getDefaultScriptDirectory

      public String getDefaultScriptDirectory()
      Accessor to get directory location of script files.
      Returns:
      The script file directory
    • getDICOMCatcher

      public DICOM_Receiver getDICOMCatcher()
      Accessor to get the DICOM receiver.
      Returns:
      the DICOM receiver
    • getDICOMQueryFrame

      public ViewJFrameDICOMQuery getDICOMQueryFrame()
      Accessor to get the DICOM query frame.
      Returns:
      The DICOM query frame.
    • getFrameContainingImage

      public ViewJFrameImage getFrameContainingImage(ModelImage image)
      Accessor that returns the active image frame vector. If the top frame is not an image frame, then the frame vector is iterated until an image frame is found. If none is found then null is returned.
      Parameters:
      image - the image to find the frame for.
      Returns:
      The vector that has a list of frames visible in the GUI.
    • getImageFrameVector

      public Vector<Frame> getImageFrameVector()
      Accessor that returns frame vector.
      Returns:
      The vector that has a list of frames visible in the GUI.
    • getJarClassLoader

      public JarClassLoader getJarClassLoader()
    • getLastScript

      public String getLastScript()
      Returns the last script file used from the preferences.
      Returns:
      LastScript
    • getLastStackFlag

      public boolean getLastStackFlag()
      Gets the last checkbox entry for "multi-file" for opening images.
      Returns:
      boolean
    • getMainFrame

      public JFrame getMainFrame()
      Accessor that returns the main user interface frame.
      Returns:
      The main user interface frame.
    • getMenuBuilder

      public ViewMenuBuilder getMenuBuilder()
      Returns the interface's menu builder.
    • getMessageFrame

      public ViewJFrameMessage getMessageFrame()
      Accessor that returns the message frame.
      Returns:
      The message frame.
    • getMessageText

      public String getMessageText()
      Accessor to get text of message field.
    • getNewFrameLocation

      public Dimension getNewFrameLocation(int newImageXDim, int newImageYDim)
      Changes location of image when first displayed.
      Returns:
      The new location.
    • getNewFrameYLocation

      public Dimension getNewFrameYLocation()
      Changes vertical location of image when first displayed.
      Returns:
      The new location.
    • getProgressBarPrefix

      public String getProgressBarPrefix()
      Gets the string "Opening " or "Loading " based on what the progress bar should be displaying.
      Returns:
      String OPENING_STR or LOADING_STR
    • getProvenanceHolder

      public ProvenanceHolder getProvenanceHolder()
      Accessor for the mipav's data provenance .@return mipav's data provenance holder
      Returns:
      DOCUMENT ME!
    • getRegisteredFramedImagesNum

      public int getRegisteredFramedImagesNum()
      Return an num of images with frames(elements) from the image hashtable.
      Returns:
      images number
      See Also:
    • getRegisteredImageByName

      public ModelImage getRegisteredImageByName(String name)
      Return a registered image from the image hashtable based on the name of the image. This works as long as the image was registered and the name is unique.
      Parameters:
      name - The name of the image to be retrieved.
      Returns:
      the ImageModel associated with this name.
      Throws:
      IllegalArgumentException - if the name is not in the image hastable.
      See Also:
    • getRegisteredImageNames

      public Enumeration<String> getRegisteredImageNames()
      Return an enumeration of keys (image names) from the image hashtable.
      Returns:
      An Enumeration containing the keys (image names).
      See Also:
    • getRegisteredImages

      public Enumeration<ModelImage> getRegisteredImages()
      Return an enumeration of images (elements) from the image hashtable.
      Returns:
      An Enumeration containing the elements (images).
      See Also:
    • getRegisteredImagesNum

      public int getRegisteredImagesNum()
      Return an num of images (elements) from the image hashtable.
      Returns:
      images number
      See Also:
    • imageRegistryMonitoring

      public void imageRegistryMonitoring()
      Display image registry frame.
    • imagesToFront

      public void imagesToFront()
      Brings all images and message frame to the front.
    • initializeGui

      public void initializeGui()
      Initializes the user interface. Starts by reading out some starting options out of the preferences file; setting up the main frame; building the message frame and setting the message frame into the preferences; building the menu; setting controls; initialising the DICOM dictionary; setting up the message field that is used in the main frame; setting the application titles; and showing the main frame.

      Recommendations for how to most easily perform modifications to the initialisation procedure are included with the individual method comments, although in most cases, it suffices to simply over-ride an individual method.

      See Also:
    • isAppFrameVisible

      public boolean isAppFrameVisible()
      Accessor to check whether the application frame visible or not.
      Returns:
      isAppFrameVisible application frame visibility flag
    • isImageHashtableEmpty

      public boolean isImageHashtableEmpty()
      Indicates if the image hashtable is empty.
      Returns:
      A boolean showing state of hashtable.
      See Also:
    • isImageRegistered

      public boolean isImageRegistered(String imageName)
      Indicates if the image name is found in the hashtable.
      Parameters:
      imageName - the image name (key).
      Returns:
      A boolean indicating that image name.
      See Also:
    • isPlugInFrameVisible

      public boolean isPlugInFrameVisible()
      Accessor to see if a stand-alone plugin frame is visible (not app frame)
      Returns:
    • isShorcutRecording

      public boolean isShorcutRecording()
      Determines if the UserInterface is currently recording an action command as a shortcut.
      Returns:
      boolean is it recording
    • setAppFrameVisible

      public void setAppFrameVisible(boolean isVisible)
      Tells the application to show the MIPAV UI or suppress it (progress bars, image frames, etc).
      Parameters:
      isVisible - Set to false to hide the MIPAV UI.
    • setPlugInFrameVisible

      public void setPlugInFrameVisible(boolean isVisible)
      Tells the UI that a standalone plugin frame is visible
      Parameters:
      isVisible - is the plugin frame visible
    • keyPressed

      public void keyPressed(KeyEvent e)
      Pass the key event to the selected image frame (if one exists). If not, check the shortcut table and attempt to handle it here.
      Specified by:
      keyPressed in interface KeyListener
      Parameters:
      e - a key event generated by the user
    • keyReleased

      public void keyReleased(KeyEvent e)
      Pass the key event to the selected image frame (if one exists).
      Specified by:
      keyReleased in interface KeyListener
      Parameters:
      e - a key event generated by the user
    • keyTyped

      public void keyTyped(KeyEvent e)
      Pass the key event to the selected image frame (if one exists).
      Specified by:
      keyTyped in interface KeyListener
      Parameters:
      e - a key event generated by the user
    • memoryAllocation

      public void memoryAllocation()
      Display memory allocation frame (request more from the JVM on next JVM-start).
    • memoryFrame

      public void memoryFrame()
      Display memory usage frame.
    • closeAllImages

      public void closeAllImages()
      this method closes all registered images
    • deleteItem

      private void deleteItem(String name, boolean deleteFrame, boolean runGC)
      Deletes the item specified by name. If false, only the model image is deleted
      Parameters:
      name - the object to delete
      deleteFrame - whether the frame should be deleted along with the image
      runGC - whether to run application-wide garbage collector once item is deleted
    • openJSONImageFrames

      public void openJSONImageFrames()
    • openImageFrame

      public void openImageFrame()
      This method opens an image and puts it into a frame.
    • openImageFrame

      public void openImageFrame(String imageFile)
      Open an image and put it into a new frame, given the image file name.
      Parameters:
      imageFile - the image file name with the path.
    • openImageFrame

      public void openImageFrame(String imageFileName, String imageFileDir)
      Open an image and put it into a new frame, given the image file name.
      Parameters:
      imageFileName - the file name, without the path
      imageFileDir - the directory where the file is
    • openImageFrame

      public void openImageFrame(String imageFile, boolean multiFile)
      Open an image or images and put it into a new frame, given the image file name.
      Parameters:
      imageFile - the image file name with the path.
      multiFile - If true, the image is composed of image slices each in their own file.
    • openLastImage

      public void openLastImage(int index)
      Attempts to open an image from the quicklist.
      Parameters:
      index - int index of image on quicklist
    • options

      public void options()
      Display Options dialog for all mipav options (including image specific options) to allow user to adjust display in one place.
    • parseArguments

      public int parseArguments(String[] args, int initArg)
      Required by the CommandLineParser interface. Processes MIPAV command line arguments that require MIPAV to have already been initialized. Returns the next argument to be processed (finished if returns args.length)
      Specified by:
      parseArguments in interface CommandLineParser
      Parameters:
      args - command arguments
      Returns:
      the location of the next command to be processed, if equal to args.length, then no further processing is necessary
    • regFrame

      public void regFrame(Frame frame)
      Method that registers an image frame by putting it in the image frame vector and does NOT loads controls.
      Parameters:
      frame - Frame to be registered with this the main UI.
    • registerFrame

      public void registerFrame(Frame frame)
      Method that registers an image frame by adding it to the vector and loads controls.
      Parameters:
      frame - Frame to be registered with this the main UI. The zero element frame is the active image. Any new image registered is made the active window.
    • setMenuActionListeners

      private void setMenuActionListeners(Component comp, ActionListener frame)
    • registerImage

      public String registerImage(ModelImage image)
      Register image model by adding it to the image hashtable. Use the image name as the key. If the name is not unique then the CustomHashtable will attempt to make it unique. The image name will be reset with the new name. Classes calling this method need to check the returned key (image name) from this method.
      Parameters:
      image - Image to be registered.
      Returns:
      the String value of the key (image name)
      See Also:
    • registerImage

      public String registerImage(String key, ModelImage image)
      Register image model by adding it to the image hashtable. Use the String provided as the key. If the key is not unique then the CustomHashtable will attempt to make it unique. The actual key used will be returned.
      Parameters:
      key - the desired image key
      image - Image to be registered.
      Returns:
      the actual image key used (unique)
      See Also:
    • removeAloneMenu

      public boolean removeAloneMenu(JMenuBar menu)
      Removes the stand-alone menu from the user interface.
      Parameters:
      menu - the menu to be removed.
    • setActiveFrame

      public void setActiveFrame(Frame frame)
      Method sets the parameter frame to top and active.
      Parameters:
      frame - Frame to be set active (i.e. to the top of the list).
    • setClippedMatrix

      public void setClippedMatrix(TransMatrix tMat)
      Sets the clipped matrix for copy/paste actions.
      Parameters:
      tMat - transmatrix for copy/paste
    • setControls

      public void setControls()
      Sets the menu for the main frame.
    • setDataText

      public final void setDataText(String str)
      Accessor to set text of data FRAME.
      Parameters:
      str - String to be displayed in text panel.
    • setDefaultDirectory

      public void setDefaultDirectory(String defaultDirectory)
      Sets directory location of last file access.
      Parameters:
      defaultDirectory - Directory to set it to.
    • setDefaultScriptDirectory

      public void setDefaultScriptDirectory(String dir)
      Sets directory location of the script files.
      Parameters:
      dir - Directory to set the script directory to.
    • setDICOMCatcher

      public void setDICOMCatcher(DICOM_Receiver rcv)
      Accessor to set the DICOM receiver.
      Parameters:
      rcv - the DICOM receiver
    • setDICOMQueryFrame

      public void setDICOMQueryFrame(ViewJFrameDICOMQuery frame)
      Accessor to set the DICOM query frame.
      Parameters:
      frame - The DICOM query frame.
    • setExitCmdLineOnError

      public void setExitCmdLineOnError(boolean doExit)
      Sets MIPAV to exit (true) or not (false) on an error when running from the command line
      Parameters:
      doExit -
    • doExitCmdLineOnError

      public boolean doExitCmdLineOnError()
      Tells whether or not to exit on an error when running from the command line
      Returns:
      boolean whether to exit
    • doForceInPlace

      public boolean doForceInPlace()
      Checks whether the dialog should force the algorithm to replace the image (no new frame)
      Returns:
      if only algorithm image replacement is allowed
    • setForceInPlace

      public void setForceInPlace(boolean doForce)
      Sets the dialogs to only replace the image (no new frame)
      Parameters:
      doForce - do force the dialog to replace the image (in-place)
    • setGlobalDataText

      public final void setGlobalDataText(String str)
      Accessor to set text of global data FRAME.
      Parameters:
      str - String to be displayed in text panel.
    • setJarClassLoader

      public void setJarClassLoader(JarClassLoader jarClassLoader)
    • setLastScript

      public void setLastScript(String script)
      Sets last used script files in preferences.
      Parameters:
      script - Script to set the LastScript to.
    • setLastStackFlag

      public void setLastStackFlag(boolean lastStackFlag)
      Sets the last value for opened multi-files (or single).
      Parameters:
      lastStackFlag - boolean
    • setLoad

      public void setLoad(boolean doLoad)
      Tells the progress bar to say "Loading" rather than "Opening" for images being loaded if true.
      Parameters:
      doLoad - boolean do set progress bar to load
    • setMessageText

      public void setMessageText(String str)
      Accessor to set text of message field.
      Parameters:
      str - String to be displayed in text field.
    • setShortcutRecording

      public void setShortcutRecording(boolean doRecord)
      Sets the UI to either be/not be recording action command.
      Parameters:
      doRecord - boolean true = is recording, false = not
    • setTitle

      public void setTitle(String str)
      Gets the application title from the preference file and prepends to the string passed into the method and displays the resultant string in the title of the main frame.
      Parameters:
      str - the application title
    • setUseVOIName

      public void setUseVOIName(boolean useName)
      Sets the Preference to use VOI Names instead of labels, then updates all frames to reflect this change with their VOIs.
      Parameters:
      useName - boolean show name instead of label
    • setVisible

      public void setVisible(boolean visible)
      Change whether the GUI should be visible. The order is strage because we want the main frame to be first on the taskbar, but also focused when the windows show up.
      Parameters:
      visible - whether the message and main frames should be shown on the screen
    • showLicense

      public void showLicense()
      Displays the MIPAV Software Transfer Agreement in a JDialogText window.

      The "license.html" file is read (using the GetPath class) and displayed as HTML with a JDialogText. If the file is not found, or there is a problem opening it, a notation is made in the Preferences.debug window and is otherwise ignored. A warning box is displayed when the license dialog cannot be created (and throws a NullPointerException). Finally, the main frame does not record this item in its list of windows, so many instances of this window may be made.

    • showLicense

      public void showLicense(String title, String filename)
      Displays the MIPAV Software Transfer Agreement in a JDialogText window.

      The "license.html" file is read (using the GetPath class) and displayed as HTML with a JDialogText. If the file is not found, or there is a problem opening it, a notation is made in the Preferences.debug window and is otherwise ignored. A warning box is displayed when the license dialog cannot be created (and throws a NullPointerException). Finally, the main frame does not record this item in its list of windows, so many instances of this window may be made.

      Parameters:
      title - The title of the frame
      filename - the name of the license file.
    • showShortcutEditor

      public void showShortcutEditor(boolean doUpdate)
      Opens a dialog for viewing/modifying shortcuts.
      Parameters:
      doUpdate - whether to update the shortcut table
    • showSplashGraphics

      public void showSplashGraphics()
      Shows the MIPAV splash screen for a few seconds, or until the user clicks it.
    • unregisterFrame

      public void unregisterFrame(Frame frame)
      Method that unregisters an image frame by removing it from the image frame vector.
      Parameters:
      frame - Frame to be unregistered with this the main UI.
    • unregisterFrame

      public void unregisterFrame(Frame frame, boolean closeAll)
      Method that unregisters an image frame by removing it from the image frame vector.
      Parameters:
      frame - Frame to be unregistered with this the main UI.
    • unRegisterImage

      public void unRegisterImage(ModelImage image)
      Unregister image model by removing it from the image hashtable. Assume that the imageName is the key to the image. Display an error if the image key is not found.
      Parameters:
      image - Image to be unregistered.
      Throws:
      IllegalArgumentException - if image is null
    • unRegisterImage

      public void unRegisterImage(String imageKey)
      Unregister image model by removing it from the image hashtable given the key to the hashtable. Display an error if the image key is not found.
      Parameters:
      imageKey - The key to the image to be unregistered (a string).
      Throws:
      IllegalArgumentException - if imageKey is null
    • updateMemoryUsage

      public void updateMemoryUsage()
      This method is a callback method. The purpose is to update the memory usage readout every one second. A separate thread calls this method every one second.
    • updateMultiCoreUsage

      public void updateMultiCoreUsage()
      This method updates the "whether multi-core should be used" button when the relevant button has been pushed in either the preferences pane.
    • updateGpuUsage

      public void updateGpuUsage()
      This method updates the "whether algorithms will use the GPU" when the relevant button has been pushed in either the preferences pane.
    • updateScript

      public void updateScript(String newScriptText)
      Do nothing - required by ScriptRecordingListener interface.
      Specified by:
      updateScript in interface ScriptRecordingListener
      Parameters:
      newScriptText - Ignored.
    • windowActivated

      public void windowActivated(WindowEvent event)
      Do nothing.
      Specified by:
      windowActivated in interface WindowListener
      Parameters:
      event - the window event.
    • windowClosed

      public void windowClosed(WindowEvent event)
      Do nothing.
      Specified by:
      windowClosed in interface WindowListener
      Parameters:
      event - the window event.
    • windowClosing

      public void windowClosing(WindowEvent event)
      Confirms if the user really wants to exit, then closes the application.
      Specified by:
      windowClosing in interface WindowListener
      Parameters:
      event - Event that triggered this function.
    • cleanupAndExit

      public void cleanupAndExit()
    • windowDeactivated

      public void windowDeactivated(WindowEvent event)
      Do nothing.
      Specified by:
      windowDeactivated in interface WindowListener
      Parameters:
      event - the window event.
    • windowDeiconified

      public void windowDeiconified(WindowEvent event)
      Deiconify only the other frames who's last state was normal (ie- restore other frames to their lastState).
      Specified by:
      windowDeiconified in interface WindowListener
      Parameters:
      event - the deiconify window event.
    • windowIconified

      public void windowIconified(WindowEvent event)
      Iconify all other frames associateed with MIPAV.
      Specified by:
      windowIconified in interface WindowListener
      Parameters:
      event - the iconify window event.
    • windowOpened

      public void windowOpened(WindowEvent event)
      Do nothing.
      Specified by:
      windowOpened in interface WindowListener
      Parameters:
      event - the window event.
    • writeDataProvenance

      public void writeDataProvenance()
      Writes Mipav's data provenance to the default location.

      .

    • initCreateMemoryUsagePanel

      protected JPanel initCreateMemoryUsagePanel()
      Construct the panel which displays the current memory usage/limit and a garbage collection button.
      Returns:
      the memory usage panel
    • initCreateMultiCoreGpuIndicatorPanel

      protected JPanel initCreateMultiCoreGpuIndicatorPanel()
      Construct the panel which displays whether the CPU and GPU could be utilized by algorithms based on the preferences settings by the user.
      Returns:
      the memory usage panel
    • initCreateMessageBar

      protected void initCreateMessageBar()
      Create the panel containing components which show the application title initially, and will later be used to show image coordinates and intensities.
    • initCreateMessageField

      protected JTextField initCreateMessageField(String title)
      Creates the message field for the main frame using the title given. For other applications, extend this method to call the super method with the appropriate title.
      Parameters:
      title - the string use in the newly-created message field.
      Returns:
      the message field (displays coordinate info when an image is opened)
    • initDicomReceiver

      protected void initDicomReceiver()
      Starts the DICOM receiver if the flag in the preference file is true.
    • initMacintoshJDKversionCheck

      protected void initMacintoshJDKversionCheck()
      Method checks to verify that when running on a Machintosh, the JDK version is at least 1invalid input: '&#0'x2e;4. It sets the start up file "Info.plist" to use java1.4 if it can. The check for these routines is System.getProperty("os.name").indexOf("Mac"), and we simply return doing nothing if the property for os.name is something different. If the os.name does not contain "Mac", and the Info.plist file is found,

      "Info.plist" file to hold its startup arguments, so we need that file anyway. All exceptions caught here are not propogated.

    • initPrefsFile

      protected void initPrefsFile()
      Set the preferences file to use (Preferences defaults to mipav.preferences).
    • initPrefsTrim

      protected void initPrefsTrim()
      Gets the TRIM_VOI, TRIM_MASK and TRIM_FLAG values from the preferences file, and if it cannot find them, it sets to some default value: TRIM_VOI will be 0.3, TRIM_MASK will be 0.0, and TRIM_FLAG will be true.

      Over-ride this method if these defaults are unnacceptable.

    • initSetMainFrameDefaults

      protected void initSetMainFrameDefaults(LayoutManager prefLayout, boolean resize)
      Sets the layout of the Main Frame with the given, preferred layout manager; makes the main frame resizable as given; makes this class a window-listener; sets the default operation to do nothing on close; and the icon is set. The image icon is set by the preferences.

      Over-riding classes can alter the preferred layout most easily by over-riding this method, but calling this method with a different layout and desired size-setting. To change the default close-operation with an over-riding class, call this super method, then set the default close operation, rather than creating a custom re-implemention of this method.

      Parameters:
      prefLayout - A layout manager to handle the main frame.
      resize - Whether to allow resizing of the main frame.
      See Also:
    • initSetTitles

      protected void initSetTitles(String mainFrameTitle, String appTitle)
      Sets the titles for for the main frame and the application using the strings given. For other applications, extend this method to call the super method with the appropriate title.
      Parameters:
      mainFrameTitle - The string to use as the title for the main frame.
      appTitle - The string to put in the main frame's bottom status field.
    • initUsingPreferences

      protected void initUsingPreferences()
      Performs a variety of start-up operations based on user-preferences; First, it tries to read from the preferences file; if it cannot, it sets the user directory. It then follows from the preferences file:
      1. splash screen
      2. checks the VM heap size max
      3. sets the default directory
      4. debug output
      5. sets the TRIM

      Over-riding classes should not over-ride this method unless one of these intermediate operations is not desired or more operations are needed. To modify the defaults used in creating a preferences file, over-ride one of the called methods.

      See Also:
    • runCmdLine

      protected void runCmdLine(String scriptFile, Vector<ViewUserInterface.OpenFileInfo> imageList, Vector<Vector<String>> voiList)
      This method is used when running MIPAV from the command line.
      Parameters:
      scriptFile - The script to run.
      imageList - A list of OpenImageFile objects to use in the script.
      voiList - A list of VOIs to put into the various images.
      See Also:
    • checkHeapMaxAgainstPreferences

      private void checkHeapMaxAgainstPreferences()
      Test for VM memory sizes being the same as last run in preferences: displays a user-warning that the preferences & VM config files disagree and presents the JDialogMemoryAllocation dialog with "use preference" buttons to quicken the matching process.

      Note, this method does not throw any NullPointerExceptions.

    • printUsageAndExit

      public static void printUsageAndExit()
      Displays command line help information on usage of all commands and then exits.
    • printUsageAndExit

      public static void printUsageAndExit(Argument c)
      Displays command line help information on usage to standard out and then into an informational dialog box then exits the MIPAV application. Help display just shows the different options, display help, load image, load script, load VOI, and hide menu bar, as well as examples of use.
    • generateCmdUsageInfo

      public static String generateCmdUsageInfo()
      Generates automatic list of available commands.
    • isProvidedOutputDir

      public static boolean isProvidedOutputDir()
      This is the getter for providedOutputDir providedOutputDir: This boolean tells if the user has provided an ouputDir parameter as a command line argument when running a script
      Returns:
    • isProvidedUserDefaultDir

      public static boolean isProvidedUserDefaultDir()
    • getDiscoverableActionList

      public static Vector<Class<ActionDiscovery>> getDiscoverableActionList()
    • getDiscoverableActionList

      public static Vector<Class<ActionDiscovery>> getDiscoverableActionList(String baseDir)
    • getExceptions

      public static File getExceptions()
      Returns:
      the exceptions
    • getOutputDir

      public static String getOutputDir()
    • getSecondaryPluginsDir

      public static File getSecondaryPluginsDir()
    • getUserDefaultDir

      public static String getUserDefaultDir()
    • setProvidedOutputDir

      public static void setProvidedOutputDir(boolean providedOutputDir)
    • setProvidedUserDefaultDir

      public static void setProvidedUserDefaultDir(boolean providedUserDefaultDir)
    • setOutputDir

      public static void setOutputDir(String outputDir)
    • setSecondaryPluginsDir

      public static void setSecondaryPluginsDir(File secondaryPluginsDir)
    • setUserDefaultDir

      public static void setUserDefaultDir(String userDefaultDir)
    • parseStaticArguments

      public static int parseStaticArguments(String[] args, int initArg)
      Required by the CommandLineParser interface. Processes MIPAV command line arguments that DO NOT require MIPAV to have already been initialized. In cases like the plugins directory, it is specifically required that MIPAV has not been initialized yet. Returns the next argument to be processed (finished if returns args.length)
    • checkPrefDirCommand

      public static void checkPrefDirCommand(String[] args, int initArg)
      If the preferences name command is about to be performed before an existing preferences directory command, this guarantees that the directory command will be executed first.
    • addToTempDirList

      public static void addToTempDirList(String path)