Class JDialogAnonymizeDirectory

All Implemented Interfaces:
DialogDefaultsInterface, ActionListener, FocusListener, ItemListener, WindowListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible, RootPaneContainer, WindowConstants

public class JDialogAnonymizeDirectory extends JDialogBase
Visual Interface to anonymize DICOM images by the directory-full. Multiple directories may be chosen to operate on; it will operate on sub-directories as well.

When one directory is chosen as the source, all anonymized Dicom files in source are placed directly in the destination. Any images in any subdirectories (when chkChildren is selected) are sent into the children of the sub-directories.

More than one submitted source directory will be placed into discrete child directories of the submitted destination directory. As as example, /images/a, /images/b are selected, and /dest is the selected destination directory. They would get put into /dest/a, and /dest/b.

Naming can change the way the destination is made. Selecting a top-level randomisation, will randomate the output directory ofthe selected image directory. This isalong the lines in the above example as /images/a becoming /dest/abcde; and /images/b becoming /dest/12345. Selecting only one input directory will notmakea difference for top-level randomising. Child-directory randomising will give a random name when processing child direcories. this amounts to selecting /images (and recursive processing) and the destination directory /dest,and getting /images/a becoming /dest/abcde, and /images/b becoming /dest/12345.

See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Use serialVersionUID for interoperability.
      See Also:
    • DIR_TAB

      private static final int DIR_TAB
      DOCUMENT ME!
      See Also:
    • ANON_TAB

      private static final int ANON_TAB
      DOCUMENT ME!
      See Also:
    • PUBLIC_TAB

      private static final int PUBLIC_TAB
      See Also:
    • PRIVATE_TAB

      private static final int PRIVATE_TAB
      See Also:
    • LOG_TAB

      private static final int LOG_TAB
      DOCUMENT ME!
      See Also:
    • WRITE

      private static final int WRITE
      DOCUMENT ME!
      See Also:
    • APPEND

      private static final int APPEND
      DOCUMENT ME!
      See Also:
    • OVERWRITE

      private static final int OVERWRITE
      DOCUMENT ME!
      See Also:
    • NO_RANDOM_NAMES

      public static final int NO_RANDOM_NAMES
      DOCUMENT ME!
      See Also:
    • RANDOM_DIRECTORY_NAME

      public static final int RANDOM_DIRECTORY_NAME
      DOCUMENT ME!
      See Also:
    • RANDOM_SUBDIRECTORY_NAME

      public static final int RANDOM_SUBDIRECTORY_NAME
      DOCUMENT ME!
      See Also:
    • actOnPath

      private TreePath[] actOnPath
      for the files selected ...
    • anonymizer

      private Thread anonymizer
      Access to the running thread which is anonymising directories.
    • changeFilenameBox

      private JCheckBox changeFilenameBox
      DOCUMENT ME!
    • checkBoxPanel

      private JPanelAnonymizeImage checkBoxPanel
      DOCUMENT ME!
    • directoryTree

      private JTree directoryTree
      Actual things we can see...
    • everything

      private JTabbedPane everything
      Onscreen objects.
    • filePanel

      private JPanel filePanel
      Logical construct to reuild a source tree...
    • genericImageName

      private String genericImageName
      Used as part of the image name; used in all processed image-sets.
    • grouping

      private ButtonGroup grouping
      DOCUMENT ME!
    • imageDestBrowse

      private JButton imageDestBrowse
      DOCUMENT ME!
    • imageDestDirectory

      private File imageDestDirectory
      private File srcDirectory; // Defined by the.
    • imageDestDirText

      private JTextField imageDestDirText
      DOCUMENT ME!
    • imageNameText

      private JTextField imageNameText
      DOCUMENT ME!
    • keyLog

      private String keyLog
      Translation key, stored in "patient.key.doc".
    • logPane

      private JTextArea logPane
      holds output log; updated as processed.
    • noisyProcess

      private boolean noisyProcess
      Noisy means notifying the user of stupid errors.
    • noRandButton

      private JRadioButton noRandButton
      DOCUMENT ME!
    • outputLog

      private String outputLog
      String to hold all file checks, changes and ignores.
    • rand

      private Random rand
      To generate wierd, unrecoverable names for anon images.
    • randChildButton

      private JRadioButton randChildButton
      DOCUMENT ME!
    • randTopButton

      private JRadioButton randTopButton
      DOCUMENT ME!
    • recursiveCheckBox

      private JCheckBox recursiveCheckBox
      private JButton srcBrowse;.
    • selectedList

      private JTextArea selectedList
      All directory-tree selected directories are listed for user-consumption in this whitespace.
    • sequenceStart

      private int sequenceStart
      Used as part of the image name; represents beginning of sequence for all processed image sets.
    • sequenceText

      private JTextField sequenceText
      DOCUMENT ME!
    • sourcePanel

      private JPanel sourcePanel
      DOCUMENT ME!
    • stopButton

      private JButton stopButton
      stops the thread from continuing its processing. on same panel as OK and Cancel.
    • toplevelOnly

      private int toplevelOnly
      DOCUMENT ME!
    • xlatDestBrowse

      private JButton xlatDestBrowse
      DOCUMENT ME!
    • xlatDestDirectory

      private File xlatDestDirectory
      DOCUMENT ME!
    • xlatDestDirText

      private JTextField xlatDestDirText
      DOCUMENT ME!
    • xlatDestinationUsage

      private int xlatDestinationUsage
      Defines options for WRITE, OVERWRITE, APPEND for the xlat file.
    • privateTagsPanel

      private JPanelAnonymizePrivateTags privateTagsPanel
    • publicTagsPanel

      private JPanelAnonymizePublicTags publicTagsPanel
    • removeBox

      private JCheckBox removeBox
  • Constructor Details

    • JDialogAnonymizeDirectory

      public JDialogAnonymizeDirectory(String dir)
      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:
      dir - DOCUMENT ME!
  • Method Details

    • privateKeySearch

      private ArrayList<String> privateKeySearch(String dir)
    • actionPerformed

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

      public void anonymizationComplete(JDialogAnonymizeDirectory.AnonymizeDicomDirectories event)
      A psuedo-event-handler. Takes the event (An instance of AnonymizeDicomDirectories) resets the enabled status of the OK and Cancel buttons, appends the key-log text to the key-log and calls writeKeyFile().
      Parameters:
      event - the event
    • applyGenericName

      private void applyGenericName()
      converts the name and sequence JTextFields into native types. Ensures that if the textFields are empty, the empty values don't cause problems. That means the generic name is the original generated random string and sequence is 0.
    • buildFilePanel

      private JPanel buildFilePanel(String dir)
      creates the source panel which consists of the directory line, the browse button, and a check box approving the anonymize in sub-directories.
      Parameters:
      dir - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • buildImageDestPanel

      private JPanel buildImageDestPanel()
      creates the destination panel which consists of the directory textline, the browse button, and a sub-panel to provide the name of the randomized image.
      Returns:
      DOCUMENT ME!
    • buildLogPanel

      private JPanel buildLogPanel()
      creates a panel for the output log.
      Returns:
      DOCUMENT ME!
    • buildMenuEntries

      private JMenuBar buildMenuEntries()
      Creates the menu bar for the dialog. Builds a small menu with "New directory" and "Refresh directory" options.
      Returns:
      DOCUMENT ME!
    • buildNameSuggestionPanel

      private JPanel buildNameSuggestionPanel()
      creates a name-suggestion panel.
      Returns:
      DOCUMENT ME!
    • buildNewSourceTree

      private JTree buildNewSourceTree(String directory)
      Creates a new directory tree starting with directory as the root. Each leaf of the tree is populated by ViewFileTreeNodes, representing directories.

      It is selectable with TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION. Each item that is selected will be placed into a JTextArea displaying all the selected items. And as the tree is expanded, the leaves will be explored, but as yet, there is no utility to un-explore them, or refresh their view once explored.

      Parameters:
      directory - a string signifying the root of the tree
      Returns:
      a directory-tree, with the input argumenbt as the root.
      See Also:
    • buildOKCancelPanel

      private JPanel buildOKCancelPanel()
      Creates the panel which consists of the OKAY button and the Cancel button. The OKAY button is set to read "Run", and the Cancel button is set to read "Close".

      a STOP button to stop the seperate thread is on the panel after the cancel button. The stop button reads "Stop".

      Places a "Help" button to the right of the "Stop" button.

      Returns:
      DOCUMENT ME!
    • buildOptionPanel

      private JPanel buildOptionPanel()
      creates the random-button panel,which are two radio-buttons determining the naming actions for the output directories.
      Returns:
      DOCUMENT ME!
    • buildRandButtonPanel

      private JPanel buildRandButtonPanel()
      creates the random-button panel,which are two radio-buttons determining the naming actions for the output directories.
      Returns:
      DOCUMENT ME!
    • buildRandSelectionPanel

      private JPanel buildRandSelectionPanel()
      puts together the panel of recursive box and directory-randomization level radio button.
      Returns:
      the loaded panel
      See Also:
    • buildSelectedListing

      private 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
    • buildSourcePanel

      private JPanel buildSourcePanel(String dir)
      creates the source panel which consists of the directory line, the browse button, and a check box approving the anonymize in sub-directories.
      Parameters:
      dir - DOCUMENT ME!
      Returns:
      DOCUMENT ME!
    • buildSourceTreeListing

      private JPanel buildSourceTreeListing(String directory)
      Creates the panel holding the directory tree.
      Parameters:
      directory - DOCUMENT ME!
      Returns:
      Panel.
    • buildStopButton

      private void buildStopButton()
      Builds the Stop button.
    • buildXLATdestPanel

      private JPanel buildXLATdestPanel()
      creates the destination panel which consists of the directory textline, the browse button for the translation key file.
      Returns:
      DOCUMENT ME!
    • generateRandString

      private String generateRandString()
      generates a random, up to-5 character, hexadecimal string.
      Returns:
      a hexadeciaml string of up to 5-characters.
    • isImageDestinationOkay

      private boolean isImageDestinationOkay()
      Makes the image destination directory. 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.
      Returns:
      boolean if the selected destination has been made, returns true. Otherwise, returns false.
    • isRemovalSelectionOkay

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

      private boolean isSelectedPathsOkay()
      Records all paths chosen in the source tree. If no selections have been made, the "Directory" tab is brought to the front, and the warning message "Select at least one directory to work on." is displayed.
      Returns:
      boolean if a selection in the source tree has been made, returns true. Otherwise, returns false.
    • isXLATdestinationOkay

      private boolean isXLATdestinationOkay()
      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.
    • makeDirectory

      private File makeDirectory(File selDir, JTextField txtField) throws IOException
      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:
      selDir - DOCUMENT ME!
      txtField - DOCUMENT ME!
      Returns:
      File a directory
      Throws:
      IOException - -- failure to create the directory
    • newKeyLog

      private String newKeyLog()
      creates a new keylog, writing which tags are to be removed from the image information; the table header for the image read/write logging is added. the string created here is not automatically turned into the keylog string. that must be done by the caller.
      Returns:
      the new KeyLog String.
    • writeKeyFile

      private void writeKeyFile()
      creates a keyFile named "patient.key.doc" in the destination directory as specified by the user. the keyFile contains a tab-delimited table of original filenames and the anonymous filename which replaced it; it flushes the keyLog into the keyFile. Any further writes to the keyLog will be writing into a new keyLog. Writing to the keyFile later will overwrite the keyFile already there.
    • getProfiles

      private ArrayList<String> getProfiles()
      Searches for all profiles in the MIPAV preferences that start with profileAnonymizeDICOM. Works for both the anonymize image dialog and the anonymize directory dialog.
    • loadProfile

      private void loadProfile(String name)
      Parses through the profile in the MIPAV preferences to determine which Supplement 55 tags are selected, which public tags exists (and were selected), and which private tags exist (and were selected). Since for this dialog we do not go into an image to determine which tags are present, whatever was in the profile is displayed.
      Parameters:
      name -
    • saveProfile

      private void saveProfile(String name)
      Saves off a profile into the preferences. This is basically the exact same as what is seen in the anonymize image version.
      Parameters:
      name -