bodhidharma
Class ConfigureFileLocationsJFrame

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by bodhidharma.ConfigureFileLocationsJFrame
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class ConfigureFileLocationsJFrame
extends javax.swing.JFrame
implements java.awt.event.ActionListener

Part of the Bodhidharma automatic music classification project. This is the first dialog box that users of the software are presented with.

This dialog box allows one to choose the paths of the current project, the file containing the musical taxonomy used to train classifiers, the list of recordings to train and/or classify, the features of these recordings, the trained classifying systm, the prefences file and the current directory.

These paths may be chosen by typing them in (except for the project field) or by pressing onBrwose buttons, which will bring up a reusable JFileChoose dialog box.

The Load Project button may be pressed in order to load a project name and its associated file paths into this dialog box.

The Clear Paths button clears all text fields.

The Restore Original Defaults button loads the hardcoded defaults into this dialog box.

The Save As Startup Defaults button saves the contents of the dialog box as the defaults that will fill the dialog box when it is instantiated.

The Start New Project button brings up a dialog box that allows the user to choose the name of a new project and where to save it. The project XML file is then created at the given location with the given name. A new directory with the same name (minus the .xml) is created. The current directory is updated to this directory. The user is asked if s/he would like to copy the files referred to by the existing entries to the new directory. The text fields and fields are all updated.

The Cancel button hides this dialog box. Any changes that were made are lost, except for the creation of new project files.

The OK button hides this window and instantiates the main window. If the main window has already been created, it is replaced.

The path fields of this dialog box hold the paths of these pieces of information after they have been chosen, and may be referenced by other objects.

The setTaxonomyPath, setFeaturesPath and setRecordingsPath methods can be called to reset the appropriate fields and text fields.

The browse methods of this class can also be called by other objects to bring up the JFileChoose dialog box to change these file paths individually. The newly updated path field(s) can then be accessed by other objects.

Objects of this class also hold a JFileChoose dialog box that can be called by other classes in the project. Objects of this class also holdo a reference to the most recently spawned main window.

The loadProject method may also be called by other objects in order to load an entirely new project_file XML without going through this dialog box manually.

The saveFileExternally method may also be called by other objects in order to save a file, potentially with a JFileChooser dialog box, and, if appropriate, update the path fields of this dialog box.

The getFile method may also be called by other objects in order to get a File from a given path.

The saveProjectFile method may also be called by other objects in order to save the current project paths in the current project_file.

The startNewProject method may also be called by other methods to bring up a dialog box allowing the creation of a new project.

The defaults that are loaded when an object of this class is instantiated are set by the default_file_locations.xml file found in the same directory as this class. The only field of this file that is considered is the project file that it refers to, which is then loaded. This default_file_locations file will be automatically recreated if it is absent.

See Also:
Bodhidharma, MainJFrame, FileFilterXML, Serialized Form
Author:
Cory McKay

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 java.lang.String classifiers_path
          Path of the file holding the current classification system.
 java.lang.String current_directory
          Path of the current directory
 java.lang.String features_path
          Path of the current list of feature settings.
 MainJFrame main_window
          The main window of the Bodhidharma GUI
 java.lang.String preferences_path
          Path of the preferences file.
 java.lang.String project_path
          Path of the current project.
 java.lang.String recordings_list_path
          Path of the current list of recordings intended for training and/or testing.
 java.lang.String taxonomy_path
          Path of the current musical taxonomy file.
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ConfigureFileLocationsJFrame()
          Basic constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Calls the appropriate methods when the buttons are pressed.
 boolean browseClassifiersPath(boolean called_externally)
          Opens a JFileChooser dialog box that only displays directories and .xml files.
 boolean browseCurrentDirectoryPath(boolean called_externally)
          Opens a JFileChooser dialog box that only displays directories.
 boolean browseFeaturesPath(boolean called_externally)
          Opens a JFileChooser dialog box that only displays directories and .xml files.
 boolean browsePreferencesPath(boolean called_externally)
          Opens a JFileChooser dialog box that only displays directories and .xml files.
 boolean browseRecordingsPath(boolean called_externally)
          Opens a JFileChooser dialog box that only displays directories and .xml files.
 boolean browseTaxonomyPath(boolean called_externally)
          Opens a JFileChooser dialog box that only displays directories and .xml files.
 void commenceClassifiying(java.lang.String output_classifications_path)
          Commences classifying the recordings specified in this ConfigureFileLocationsJFrame using the classifiers specified in the ConfigureFileLocationsJFrame and the preferences and taxonomy specified in this ConfigureFileLocationsJFrame.
 void commenceFeatureExtraction()
          Perform feature extraction and saves the results.
 void commenceTraining(java.lang.String train_save_path)
          Commences training on the recordings specified in this ConfigureFileLocationsJFrame.
 java.io.File getFile(java.lang.String path, boolean can_erase)
          Gets a File object based on the given path.
 void loadProject(java.lang.String project_path, boolean called_externally)
          Takes in the path of an XML project file (of type file_locations).
 java.io.File saveFileExternally(boolean can_erase, java.lang.String file_type)
          Opens a JFileChooser dialog box that allows the user to choose the path of the file to be saved.
 void saveProjectFile(java.lang.String path, java.lang.String comments, boolean can_erase)
          Saves a project_file XML file in the specified location with the specified comments.
 void setClassifiersPath(java.lang.String new_path)
          Sets the classifiers_path classifiers_text_field fields to the value of the parameter.
 void setCurrentDirectory(java.lang.String new_path)
          Sets the current_directory current_directory_text_field fields to the value of the parameter.
 void setFeaturesPath(java.lang.String new_path)
          Sets the features_path features_text_field fields to the value of the parameter.
 void setPreferencesPath(java.lang.String new_path)
          Sets the preferences_path preferences_text_field fields to the value of the parameter.
 void setProjectPath(java.lang.String new_path)
          Sets the project_path project_text_field fields to the value of the parameter.
 void setRecordingsPath(java.lang.String new_path)
          Sets the recordings_list_path recordings_text_field fields to the value of the parameter.
 void setTaxonomyPath(java.lang.String new_path)
          Sets the taxonomy_path taxonomy_text_field fields to the value of the parameter.
 void startNewProject()
          Brings up a dialog box that allows the user to choose the name of a new project and where to save it.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

project_path

public java.lang.String project_path
Path of the current project.


taxonomy_path

public java.lang.String taxonomy_path
Path of the current musical taxonomy file.


features_path

public java.lang.String features_path
Path of the current list of feature settings.


recordings_list_path

public java.lang.String recordings_list_path
Path of the current list of recordings intended for training and/or testing.


classifiers_path

public java.lang.String classifiers_path
Path of the file holding the current classification system.


preferences_path

public java.lang.String preferences_path
Path of the preferences file.


current_directory

public java.lang.String current_directory
Path of the current directory


main_window

public MainJFrame main_window
The main window of the Bodhidharma GUI

Constructor Detail

ConfigureFileLocationsJFrame

public ConfigureFileLocationsJFrame()
Basic constructor. Configures the dialog box and loads the default paths from the default_file_locations.xml file. Instantiates and configures the browse_dialo JFileChooser.

Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Calls the appropriate methods when the buttons are pressed.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - The event that is to be reacted to.

loadProject

public void loadProject(java.lang.String project_path,
                        boolean called_externally)
Takes in the path of an XML project file (of type file_locations). Loads this file, parses it to verify its validity and sets the displays and fields of this dialog box to match its contents.

If the argument does not point to a valid project file of if null is passed as the argument, then choose the file using a JFileChooser dialog box.

Parameters:
project_path - Path of a valid file_locations XML file.
called_externally - True if called by an external object, false if called internally.

setProjectPath

public void setProjectPath(java.lang.String new_path)
Sets the project_path project_text_field fields to the value of the parameter.

Parameters:
new_path - The new path.

setTaxonomyPath

public void setTaxonomyPath(java.lang.String new_path)
Sets the taxonomy_path taxonomy_text_field fields to the value of the parameter.

Parameters:
new_path - The new path.

setFeaturesPath

public void setFeaturesPath(java.lang.String new_path)
Sets the features_path features_text_field fields to the value of the parameter.

Parameters:
new_path - The new path.

setRecordingsPath

public void setRecordingsPath(java.lang.String new_path)
Sets the recordings_list_path recordings_text_field fields to the value of the parameter.

Parameters:
new_path - The new path.

setClassifiersPath

public void setClassifiersPath(java.lang.String new_path)
Sets the classifiers_path classifiers_text_field fields to the value of the parameter.

Parameters:
new_path - The new path.

setPreferencesPath

public void setPreferencesPath(java.lang.String new_path)
Sets the preferences_path preferences_text_field fields to the value of the parameter.

Parameters:
new_path - The new path.

setCurrentDirectory

public void setCurrentDirectory(java.lang.String new_path)
Sets the current_directory current_directory_text_field fields to the value of the parameter.

Parameters:
new_path - The new path.

browseTaxonomyPath

public boolean browseTaxonomyPath(boolean called_externally)
Opens a JFileChooser dialog box that only displays directories and .xml files. Allows user to choose the path for the XML file holding the musical taxonomy.

Parameters:
called_externally - True if called by an external object, false if called internally.
Returns:
true if the OK button was pressed, false if the cancel button was pressed
See Also:
FileFilterXML

browseRecordingsPath

public boolean browseRecordingsPath(boolean called_externally)
Opens a JFileChooser dialog box that only displays directories and .xml files. Allows user to choose the path for the XML file holding the recordings list.

Parameters:
called_externally - True if called by an external object, false if called internally.
Returns:
true if the OK button was pressed, false if the cancel button was pressed
See Also:
FileFilterXML

browseFeaturesPath

public boolean browseFeaturesPath(boolean called_externally)
Opens a JFileChooser dialog box that only displays directories and .xml files. Allows user to choose the path for the XML file holding the features for the given recording.

Parameters:
called_externally - True if called by an external object, false if called internally.
Returns:
true if the OK button was pressed, false if the cancel button was pressed
See Also:
FileFilterXML

browseClassifiersPath

public boolean browseClassifiersPath(boolean called_externally)
Opens a JFileChooser dialog box that only displays directories and .xml files. Allows user to choose the path for the XML file holding the classification system.

Parameters:
called_externally - True if called by an external object, false if called internally.
Returns:
true if the OK button was pressed, false if the cancel button was pressed
See Also:
FileFilterXML

browsePreferencesPath

public boolean browsePreferencesPath(boolean called_externally)
Opens a JFileChooser dialog box that only displays directories and .xml files. Allows user to choose the path for the XML file holding the preferences.

Parameters:
called_externally - True if called by an external object, false if called internally.
Returns:
true if the OK button was pressed, false if the cancel button was pressed
See Also:
FileFilterXML

browseCurrentDirectoryPath

public boolean browseCurrentDirectoryPath(boolean called_externally)
Opens a JFileChooser dialog box that only displays directories. Allows user to choose the path for the current default directory. Sets the current directory to that value.

Parameters:
called_externally - True if called by an external object, false if called internally.
Returns:
true if the OK button was pressed, false if the cancel button was pressed

saveFileExternally

public java.io.File saveFileExternally(boolean can_erase,
                                       java.lang.String file_type)
Opens a JFileChooser dialog box that allows the user to choose the path of the file to be saved. Makes sure can write to this path and returns the corresponding File. Displays an error dialog box if there is a problem. Returns null if can or should not save.

The file_type parameter specifies the type of file to be saved. The appropriate fields and and text fields are updated if the file type is recognized.

Automatically adds .xml as an extension if this is not already present.

Parameters:
can_erase - Whether or not existing files with the specified path should be overwritten without asking the user.
file_type - The code identifying the type of XML file.
Returns:
A File if appropriate, null if nothing should be saved after all.

saveProjectFile

public void saveProjectFile(java.lang.String path,
                            java.lang.String comments,
                            boolean can_erase)
Saves a project_file XML file in the specified location with the specified comments. This file is given the paths specified in the text boxes in this dialog box.

Parameters:
path - The path under which the file is to be saved.
contents - The contents of the file to save.
can_erase - True means user is not warned if user is overwrting a file, false means is warned.

startNewProject

public void startNewProject()
Brings up a dialog box that allows the user to choose the name of a new project and where to save it. The project XML file is then created at the given location with the given name. A new directory with the same name (minus the .xml) is created. The current directory is updated to this directory. The user is asked if s/he would like to copy the files referred to by the existing entries to the new directory. The text fields and fields are all updated.


getFile

public java.io.File getFile(java.lang.String path,
                            boolean can_erase)
Gets a File object based on the given path. If the can_erase parameter is false, then gives a warning message asking user if s/he wishes to overwrite the file. Returns null if choice is to not overwrite file. Attempts to write empty string and displays error message if cannot (also returns null in this case).

Parameters:
path - The path under which the file is to be saved.
can_erase - Whether or not the file should be automatically overwritten if it already exists.

commenceFeatureExtraction

public void commenceFeatureExtraction()
Perform feature extraction and saves the results. Only performed if features not already extracted.


commenceTraining

public void commenceTraining(java.lang.String train_save_path)
Commences training on the recordings specified in this ConfigureFileLocationsJFrame. Saves the trained classifiers in the specified location (this overrides settings in this ConfigureFileLocationsJFrame). Uses the preferences and taxonomy specified in this ConfigureFileLocationsJFrame. This method is designed to be used with the command line interface of Bodhidharma.

Parameters:
train_save_path - The path to save the trained classifiers. If null, then saves them to the path specified in this ConfigureFileLocationsJFrame.

commenceClassifiying

public void commenceClassifiying(java.lang.String output_classifications_path)
Commences classifying the recordings specified in this ConfigureFileLocationsJFrame using the classifiers specified in the ConfigureFileLocationsJFrame and the preferences and taxonomy specified in this ConfigureFileLocationsJFrame. The classificatoins are saved to the path in the argument. This method is designed to be used with the command line interface of Bodhidharma.

Parameters:
output_classifications_path - The path to save the output classifications.