Class JDialogVOIStatistics

  • All Implemented Interfaces:
    AlgorithmInterface, ScriptableActionInterface, VOIVectorListener, VOIStatisticList, DialogDefaultsInterface, java.awt.event.ActionListener, java.awt.event.FocusListener, java.awt.event.ItemListener, java.awt.event.WindowListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

    public class JDialogVOIStatistics
    extends JDialogScriptableBase
    implements AlgorithmInterface, VOIStatisticList, VOIVectorListener
    Dialog for calculating statistics of a (set of) Volumes of Interest. User selects a Volume of Interest (or more than one) to act on, selects the statistics from a selectable checklist panel. The User selects "Calculate"; the output from the statistics is reported in a "log-panel" and may be sent to a file.

    $Logfile: /mipav/src/gov/nih/mipav/view/dialogs/JDialogVOIStatistics.java $

    See Also:
    Serialized Form
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Use serialVersionUID for interoperability.
        See Also:
        Constant Field Values
      • APPEND

        private static final int APPEND
        File handler output mode - append.
        See Also:
        Constant Field Values
      • OVERWRITE

        private static final int OVERWRITE
        File handler output mode - overwriteBox.
        See Also:
        Constant Field Values
      • checkList

        protected boolean[] checkList
        boolean array mirroring checkbox panel's selection.
      • doForce

        private boolean doForce
        force precision to display at maximum.
      • everything

        protected javax.swing.JTabbedPane everything
        Tabbed pane that holds all components.
      • image

        protected ModelImage image
        Global image reference to the currently active image during script running and recording.
      • logFileText

        private java.lang.StringBuffer logFileText
        The text of the log process to be written to file.
      • logModel

        protected ViewTableModel logModel
        Model where data is stored for the table.
      • logTable

        private javax.swing.JTable logTable
        Table holding log of statistics calculated.
      • noisyProcess

        private final boolean noisyProcess
        Flag where true means notifying the user of stupid errors.
        See Also:
        Constant Field Values
      • overwriteBox

        private javax.swing.JCheckBoxMenuItem overwriteBox
        Check box item indicating if we're to always overwriteBox the statistics file.
      • precision

        private int precision
        Number of digits after decimal place to allow.
      • processType

        protected int processType
        DOCUMENT ME!
      • activeVolume

        private int activeVolume
      • initialActiveVolume

        private int initialActiveVolume
      • tDim

        private int tDim
      • doAllVolumes

        private boolean doAllVolumes
      • rangeMaximum

        private float rangeMaximum
        DOCUMENT ME!
      • rangeMinimum

        private float rangeMinimum
        DOCUMENT ME!
      • rangeMaximumR

        private float rangeMaximumR
      • rangeMinimumR

        private float rangeMinimumR
      • rangeMaximumG

        private float rangeMaximumG
      • rangeMinimumG

        private float rangeMinimumG
      • rangeMaximumB

        private float rangeMaximumB
      • rangeMinimumB

        private float rangeMinimumB
      • selectedList

        protected javax.swing.JList selectedList
        List of selected VOIs.
      • showTotals

        protected boolean showTotals
        DOCUMENT ME!
      • tableDestination

        private java.io.File tableDestination
        Log file destination.
      • tableDestinationUsage

        private int tableDestinationUsage
        Indicates options for OVERWRITE, APPEND for the xlat file.
      • toolBar

        protected javax.swing.JToolBar toolBar
        Toolbar.
      • volumesList

        private final javax.swing.JList volumesList
        List of available VOIs.
      • xUnits

        protected int xUnits
        The units printed to the logModel, set in createNewLogile
      • yUnits

        protected int yUnits
        The units printed to the logModel, set in createNewLogile
      • zUnits

        protected int zUnits
        The units printed to the logModel, set in createNewLogile
    • Constructor Detail

      • JDialogVOIStatistics

        public JDialogVOIStatistics()
        Empty constructor needed for dynamic instantiation.
      • JDialogVOIStatistics

        public JDialogVOIStatistics​(VOIVector voiList)
        builds and packs the frame. does not set it visible.

        install the panels of source directory, destination directory, the checkbox for approving the translation-table file and the panel containing the ok and cancel buttons. Installs the checkbox panel.

        Parameters:
        voiList - DOCUMENT ME!
      • JDialogVOIStatistics

        public JDialogVOIStatistics​(ModelImage srcImage,
                                    VOIVector voiList)
        builds and packs the frame. does not set it visible.

        install the panels of source directory, destination directory, the checkbox for approving the translation-table file and the panel containing the ok and cancel buttons. Installs the checkbox panel.

        Parameters:
        srcImage - input image
        voiList - DOCUMENT ME!
    • Method Detail

      • actionPerformed

        public void actionPerformed​(java.awt.event.ActionEvent ae)
        when a button is clicked.
        Specified by:
        actionPerformed in interface java.awt.event.ActionListener
        Overrides:
        actionPerformed in class JDialogBase
        Parameters:
        ae - DOCUMENT ME!
      • addedVOI

        public void addedVOI​(VOIVectorEvent voiEvent)
        resets the volumes list to the current VOIVector. adds the highlighter to the new VOI.
        Specified by:
        addedVOI in interface VOIVectorListener
        Parameters:
        voiEvent - DOCUMENT ME!
      • anotherCall

        private void anotherCall()
      • refreshVOIList

        public void refreshVOIList​(VOIVector VOIlist)
        Refreshes the list of available and selected VOIs.
        Parameters:
        VOIlist - imageActive's current VOIVector
      • removedVOI

        public void removedVOI​(VOIVectorEvent voiEvent)
        resets the volumes list to the current VOIVector. removes the highlighter from the removed VOI.
        Specified by:
        removedVOI in interface VOIVectorListener
        Parameters:
        voiEvent - DOCUMENT ME!
      • callAlgorithm

        protected void callAlgorithm()
        Once all the necessary variables are set, call the VOI Props algorithm to run the statistic calculation.
        Specified by:
        callAlgorithm in class JDialogScriptableBase
      • cleanUpAndDispose

        protected void cleanUpAndDispose()
        Clean up some things done by the dialog which may affect other parts of MIPAV.
      • doPostAlgorithmActions

        protected void doPostAlgorithmActions()
        Used to perform actions after the execution of the algorithm is completed (e.g., put the result image in the image table). Defaults to no action, override to actually have it do something.
        Overrides:
        doPostAlgorithmActions in class JDialogScriptableBase
      • setGUIFromParams

        protected void setGUIFromParams()
        Set the dialog GUI using the script parameters while running this algorithm as part of a script.
        Specified by:
        setGUIFromParams in class JDialogScriptableBase
      • buildCheckBoxPanel

        protected void buildCheckBoxPanel()
      • buildDialog

        protected void buildDialog​(VOIVector voiList)
        Builds main dialog.
      • buildLogPanel

        protected javax.swing.JScrollPane buildLogPanel()
        creates a panel for the output log.
        Returns:
        DOCUMENT ME!
      • buildMenuEntries

        protected javax.swing.JMenuBar buildMenuEntries()
        Builds a small menu with "Clear log" and "Overwrite" options.
        Returns:
        DOCUMENT ME!
      • buildOKCancelPanel

        protected javax.swing.JPanel buildOKCancelPanel()
        creates the panel which consists of the OKAY button and the Cancel button.
        Returns:
        DOCUMENT ME!
      • buildSelectedListing

        private javax.swing.JPanel buildSelectedListing()
        creates the visual display in which to list all selected directories in the directory tree. The panel is 240 pixels wide though that is supposed to be the minimum size
        Returns:
        the panel which is to hold the list of selected items
      • buildSourceListingPanel

        private javax.swing.JPanel buildSourceListingPanel​(VOIVector VOIlist)
        Creates the panel holding the directory tree.
        Parameters:
        VOIlist - DOCUMENT ME!
        Returns:
        Panel.
      • buildSourcePanel

        private javax.swing.JPanel buildSourcePanel​(VOIVector VOIlist)
        creates the source panel which consists of the directory line, the browse button, and a check box approving the anonymize in sub-directories.
        Parameters:
        VOIlist - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • buildToolBar

        protected void buildToolBar()
        Build the toolbar control.
      • buildVOIPanel

        protected javax.swing.JPanel buildVOIPanel​(VOIVector VOIlist)
        creates the source panel for the VOI tab which consists of the directory line, the browse button, and a check box approving the anonymize in sub-directories. Also includes the file-format selection for the output file.
        Parameters:
        VOIlist - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • createNewLogModel

        protected void createNewLogModel()
        This method resets the logModel in preparation for writing new statistics values
      • isStatisticSelectionOkay

        private boolean isStatisticSelectionOkay()
        checks to see if the checklist has had any selections made to it. If it hasn't, then the "Statistics Options" tab is brought to the front (it contains the checklist), and the warning message "No statistics were selected! Select a statistic." is displayed.
        Returns:
        boolean if a selection in the JPanelAnonymizeImage has been made, returns true. Otherwise, returns false.
        See Also:
        JPanelAnonymizeImage
      • isTableDestinationOkay

        private boolean isTableDestinationOkay()
        Locates the translation/key-file destination directory. If the directory is not there already, the directory is made. If there is a problem in creating the destination directory, the "Directory" tab is brought to the front; the warning message describing the error is displayed; then the text field with the destination directory is given focus, and all available text is displayed. If the translation/key-file is already present in the chosen directory, there will be an options dialog allowing the user to Overwrite the old translation/key-file, to append the the new translation/key to the end of the current file, or to cancel the entire operation (to look for a new location).
        Returns:
        boolean if the selected destination has been made, returns true. Otherwise, returns false.
      • setupNew

        private java.io.File setupNew​(java.io.File selected)
                               throws java.io.IOException,
                                      java.lang.SecurityException
        makes the submitted directory as given by the inputted File, or the text as given in the given given textField. Priority is given to the text in the textfield, so if the File's path does not agree with the path in the text field, the directory will be made with the path in the text field. Should the text field not have any path, an IOException will be thrown indicating this problem. If the directory does not exist, it will be created; if there are errors in creating the directory, an IOException will be thrown, with error message describing the problem, with a possible remedy as a suggestion.
        Parameters:
        selected - DOCUMENT ME!
        Returns:
        File a directory
        Throws:
        java.io.IOException - -- failure to create the directory
        java.lang.SecurityException - DOCUMENT ME!
      • setVariables

        private boolean setVariables()
        use the GUI results to set up the variables needed to run the algorithm.
        Returns:
        true if parameters set successfully, falseotherwise.
      • updateDialog

        protected void updateDialog()
        Method for updating the GUI after the algorithm has completed, should not be called when scripting.
      • updateStatLog

        protected void updateStatLog()
        Method for updating the table after the algorithm has completed. All relevant statistics are stored in the log model.
      • updateDialogRow

        protected void updateDialogRow​(VOI voi,
                                       java.util.Vector<VOIBase>[] contours,
                                       VOIStatisticalProperties properties,
                                       javax.swing.ListModel list,
                                       int i,
                                       java.lang.String[] rowData,
                                       java.lang.String[] totalData)
        Writes the statistic data for contours
        Parameters:
        voi -
      • updateRowStatistics

        protected java.lang.String[] updateRowStatistics​(VOI voi,
                                                         VOIStatisticalProperties properties,
                                                         java.lang.String[] rowData,
                                                         java.lang.String[] totalData,
                                                         java.lang.String end,
                                                         int count)
        Writes general statistics data for any VOI structure given a valid "end" modifier to specify the property being fetched.
        Parameters:
        voi -
      • writeLogHeader

        protected void writeLogHeader()
        Writes the column titles of selected statistics calculations to the logModel.
      • writeLogModelToString

        protected java.lang.StringBuffer writeLogModelToString()
        Converts the current logModel into either a tab-delimited text file or an XML file. TODO: Fix XML functionality.
        Returns:
      • writeStatisticFile

        protected void writeStatisticFile()
        Writes out the statistics file based on the current logModel