Class UserInterface

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--UserInterface

public class UserInterface
extends javax.swing.JPanel
implements UserOptions

This class builds the user interface of the application and manages the events occuring when opening or closing a document.

See Also:
UserOptions, Serialized Form

Inner Class Summary
(package private)  class UserInterface.FileLoader
          this inner class starts a thread for loading a document
(package private)  class UserInterface.FileSaver
          this inner class starts a thread and saves a document to the disk
private static class UserInterface.ModelToCurrentTurnPanelAdaptor
          this adaptor is for CurrentTurnPanel controls
private static class UserInterface.ModelToDialogActPanelAdaptor
          this adaptor id for the DialogActPanel
private static class UserInterface.ModelToInformationsElementPanelAdaptor
          this adaptor is for InformationElementsPanel controls
private static class UserInterface.ModelToNextTurnPanelAdaptor
          this adaptor is for NextTurnPanel controls
private static class UserInterface.ModelToRecognizerPanelAdaptor
          this adaptor is for showing the recognition
private static class UserInterface.ModelToTranslationPanelAdaptor
          this adaptor is for showing the translations
private static class UserInterface.ModelToTurnCorectnessPanelAdaptor
          This adaptor is TurnCorrectnessPanel controls
(package private)  class UserInterface.Progress
          this inner class builts a frame which shows the progress of the loading
 
Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent, javax.swing.JComponent.IntVector, javax.swing.JComponent.KeyboardBinding, javax.swing.JComponent.KeyboardState
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
(package private)  boolean autom_compar
          indicated the way to perform the comparison in the Recognizer Panel window
(package private)  ChangeFrequency change_freq
          reference to the window "Save every...", popped-up from the options sub-menu, from Settings menu
(package private)  CurrentTurnPanel ct
          reference to the panel containing the current analysed turn
private  Document curr_doc
          holds a reference to the current showed document
(package private)  DialogActPanel dialog_dialog
          reference to the "Dialog act" panel
(package private)  DialogStatistics dialog_judgements
          reference to the "Judgements Statististics" panel
(package private)  DialogPattern dialog_pattern
          reference to the "Patterns" panel
(package private)  TranslationStatistics dialog_stat_trans
          reference to the "Translations Statistics" panel
(package private)  java.util.Vector docs
          contains the current opened docs
(package private)  java.util.Vector docs_names
          contains the names of the current opened docs
(package private)  InformationElementsPanel ie
          reference to the panel Information elements, which shows also the number of the current turn dispayed
(package private)  UserInterface.FileLoader loader
          this object loads a document
(package private)  javax.swing.JFrame mainframe
          holds a reference to the frame of the application.
(package private)  MyMenu menu
          holds a reference to the main menu of the application
(package private)  boolean new_document
          indicates if the current opened document is a new one, or it was opened earlier
(package private)  NextTurnPanel nt
          reference to the panel containing the next turn in the dialogue
(package private)  OptionsString Options
          reference to the object which performs the changes of the characters to be replaced
(package private)  RecognizerPanel recognizer_dialog
          reference to the "Recognizer Input" panel
(package private)  ReplaceCharacters repl_char
          reference to the window "Replace characters", accessed from the options sub-menu, from Settings menu
(package private)  UserInterface.FileSaver saver
          this object saves a document
(package private)  TurnCorrectnessPanel tc
          reference to the panel containing informations about the current turn panel
(package private)  javax.swing.Timer timer
          used for starting the progress monitor
(package private)  TranslationPanel translation_dialog
          reference to the "Translations Window" panel
 
Fields inherited from class javax.swing.JPanel
defaultLayout, uiClassID
 
Fields inherited from class javax.swing.JComponent
_bounds, accessibleContext, alignmentX, alignmentY, ANCESTOR_USING_BUFFER, ancestorNotifier, autoscroller, border, changeSupport, clientProperties, flags, HAS_FOCUS, IS_DOUBLE_BUFFERED, IS_OPAQUE, IS_PAINTING_TILE, KEYBOARD_BINDINGS_KEY, listenerList, maximumSize, minimumSize, NEXT_FOCUS, paintImmediatelyClip, paintingChild, preferredSize, readObjectCallbacks, REQUEST_FOCUS_DISABLED, tmpRect, TOOL_TIP_TEXT_KEY, ui, uiClassID, UNDEFINED_CONDITION, vetoableChangeSupport, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, maxSize, ncomponents, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
Fields inherited from interface UserOptions
DEFAULTSFILENAME, FREQUENCY_SAVE_TURNS, MAXIMUM_WORDS_STRING, NO_TURNS, REPLACEMASKSIZE, TRANSLATION_SEGMENTS
 
Constructor Summary
UserInterface(javax.swing.JFrame mainframe, MyMenu menu)
          Constructor of the user interface
 
Method Summary
 void BrowseData(boolean browse)
          enables or disables the browsing of the turns in the current document
 void changed()
          this method is called when the user changes the replace characters model in the Settings --> Options menu
 void Close()
          close the file being in use
private  void create_adaptors()
          created the adaptors for a new document
private  void deleteDocument(java.lang.String name)
           
 void DeleteOldDoc(java.lang.String filename)
          erases all references to the old document (which will not exist anymore as another file overwrites it)
 void DisplayCurrentTurn()
          displays the current turn of the document
private  void DisplayNull()
          displays information when no document is opened
 void EditData(boolean edit)
          enables changes of different components of the user interface
 boolean getAutomaticCompare()
           
 Document getCurrentDocument()
           
 InformationElementsPanel getInformationElementsPanel()
           
 UserInterface getUI()
           
 void Open(javax.swing.JComponent parent)
          opens a file if it is a new one or redisplays an existent one
private  void openExistentFile(java.io.File file)
          retrieves an already opened file
private  void openNewFile(java.io.File file)
          created a new Document based on the current selected file
 void Quit()
          exits the application and saves the non-saved information
 void Redisplay()
          dispalys from memory the current document
 void Reload()
          reloads from the disk the current document
 void Save()
          starts a thread for saving if the current document is not saved
 void SaveAs(javax.swing.JComponent parent)
          saves the document under another name
 void SaveAsNewDoc(java.io.File file)
          saves a new document to disk
 void SaveAsOldDoc(java.io.File file)
          saves the document over an already opened one
private  java.io.File SelectFile(javax.swing.JComponent parent, char type)
          Pops up a dialog window in order to select a file for opening or for saving under another name
 void setAutomaticComparison(boolean compar)
           
 void setAutosave(boolean auto)
          assigns the autosave property to the current document
private  Document setCurrentDocument(java.lang.String name)
           
 void setDocument(java.lang.String name)
          sets the current opened document
 void setOutput(int output)
          sets the type of module that produced the translation
private  void updateDocsNames(java.lang.String name)
          deletes the name of a document from the docs_names vector
 void UpdateMenusAndVariables(java.io.File file)
          updates the menu and the docs_names vector
private  java.io.File verifyExtension(java.io.File file)
          checks if the selected file has the correct extension (eval) if not this extention is added to the name of the file
 
Methods inherited from class javax.swing.JPanel
, getAccessibleContext, getUIClassID, paramString, updateUI, writeObject
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, adjustPaintFlags, alwaysOnTop, bindingForKeyStroke, checkIfChildObscuredBySibling, computeVisibleRect, computeVisibleRect, contains, createToolTip, enableSerialization, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperties, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getFlag, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, keyboardBindings, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paintWithBuffer, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, readObject, rectangleIsObscured, rectangleIsObscuredBySibling, registerKeyboardAction, registerKeyboardAction, registerWithKeyboardManager, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFlag, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPaintingChild, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, shouldDebugGraphics, superProcessMouseMotionEvent, unregisterKeyboardAction, unregisterWithKeyboardManager, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getCursorTarget, getLayout, getMouseEventTarget, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, nextFocus, paintComponents, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printOneComponent, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, setCursor, setFocusOwner, setLayout, transferFocus, updateCursor, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, constructComponentName, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getIntrinsicCursor, getLocale, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getToolkit, getToolkitImpl, getTreeLock, getWindowForObject, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isEnabledImpl, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

curr_doc

private Document curr_doc
holds a reference to the current showed document

mainframe

javax.swing.JFrame mainframe
holds a reference to the frame of the application. Used as parrent for any other window built while the application runs
See Also:
UserInterface(JFrame,MyMenu)

menu

MyMenu menu
holds a reference to the main menu of the application

translation_dialog

TranslationPanel translation_dialog
reference to the "Translations Window" panel

recognizer_dialog

RecognizerPanel recognizer_dialog
reference to the "Recognizer Input" panel

dialog_dialog

DialogActPanel dialog_dialog
reference to the "Dialog act" panel

dialog_judgements

DialogStatistics dialog_judgements
reference to the "Judgements Statististics" panel

dialog_stat_trans

TranslationStatistics dialog_stat_trans
reference to the "Translations Statistics" panel

dialog_pattern

DialogPattern dialog_pattern
reference to the "Patterns" panel

ct

CurrentTurnPanel ct
reference to the panel containing the current analysed turn

tc

TurnCorrectnessPanel tc
reference to the panel containing informations about the current turn panel

nt

NextTurnPanel nt
reference to the panel containing the next turn in the dialogue

ie

InformationElementsPanel ie
reference to the panel Information elements, which shows also the number of the current turn dispayed

repl_char

ReplaceCharacters repl_char
reference to the window "Replace characters", accessed from the options sub-menu, from Settings menu

change_freq

ChangeFrequency change_freq
reference to the window "Save every...", popped-up from the options sub-menu, from Settings menu

Options

OptionsString Options
reference to the object which performs the changes of the characters to be replaced

docs

java.util.Vector docs
contains the current opened docs

docs_names

java.util.Vector docs_names
contains the names of the current opened docs

new_document

boolean new_document
indicates if the current opened document is a new one, or it was opened earlier

autom_compar

boolean autom_compar
indicated the way to perform the comparison in the Recognizer Panel window

loader

UserInterface.FileLoader loader
this object loads a document

saver

UserInterface.FileSaver saver
this object saves a document

timer

javax.swing.Timer timer
used for starting the progress monitor
Constructor Detail

UserInterface

public UserInterface(javax.swing.JFrame mainframe,
                     MyMenu menu)
Constructor of the user interface
Method Detail

getUI

public UserInterface getUI()
Returns:
the reference to the user interface

getCurrentDocument

public Document getCurrentDocument()
Returns:
a reference to the current opened document, if there is one

setCurrentDocument

private Document setCurrentDocument(java.lang.String name)
Parameters:
name - the name of the document to be retieved
Returns:
the document with a specified name
See Also:
Document

updateDocsNames

private void updateDocsNames(java.lang.String name)
deletes the name of a document from the docs_names vector
Parameters:
name - the string to be removed

setDocument

public void setDocument(java.lang.String name)
sets the current opened document
Parameters:
name - the name of the document to be set
See Also:
setCurrentDocument(String)

getInformationElementsPanel

public InformationElementsPanel getInformationElementsPanel()
Returns:
reference to the InformationElementsPanel object. used for dispaying informations concerning the new opened file
See Also:
DisplayCurrentTurn()

setOutput

public void setOutput(int output)
sets the type of module that produced the translation
Parameters:
output - indicates the module (each module has a number assigned)

setAutomaticComparison

public void setAutomaticComparison(boolean compar)
Parameters:
compar - determines if in the Recognizer panel the comparison is done automatically

getAutomaticCompare

public boolean getAutomaticCompare()
Returns:
true if the comparison in the recognizer panel is done automatically

setAutosave

public void setAutosave(boolean auto)
assigns the autosave property to the current document
Parameters:
auto - is true if the "autosave" option in the Settings menu is selected
See Also:
MyMenu.actionPerformed(ActionEvent)

EditData

public void EditData(boolean edit)
enables changes of different components of the user interface
Parameters:
edit - is true if the option "Edit Data" in the Settings menu is selected
See Also:
MyMenu.actionPerformed(ActionEvent)

BrowseData

public void BrowseData(boolean browse)
enables or disables the browsing of the turns in the current document
Parameters:
browse - is true when at least one document is opened and false otherwise
See Also:
Close(), Open(JComponent)

Reload

public void Reload()
reloads from the disk the current document

Open

public void Open(javax.swing.JComponent parent)
opens a file if it is a new one or redisplays an existent one
Parameters:
parent - the parent frame for the dialog window which allows the selection of the file
See Also:
SelectFile(JComponent,char), MyMenu.EnableMenu(boolean), MyMenu.update(), MyMenu.setSavable(boolean), BrowseData(boolean), UserInterface.FileLoader

SelectFile

private java.io.File SelectFile(javax.swing.JComponent parent,
                                char type)
Pops up a dialog window in order to select a file for opening or for saving under another name
Parameters:
parent - the parent frame of the window
type - is 'o' if the window is popped-up for opening and 's' if it is for saving
Returns:
true if a file was selected
See Also:
verifyExtension(File), openNewFile(File)

verifyExtension

private java.io.File verifyExtension(java.io.File file)
checks if the selected file has the correct extension (eval) if not this extention is added to the name of the file
Parameters:
file - the name of the file for which te test is performed

openNewFile

private void openNewFile(java.io.File file)
created a new Document based on the current selected file
See Also:
Document, create_adaptors()

create_adaptors

private void create_adaptors()
created the adaptors for a new document
See Also:
UserInterface.ModelToCurrentTurnPanelAdaptor, UserInterface.ModelToInformationsElementPanelAdaptor, UserInterface.ModelToTurnCorectnessPanelAdaptor, UserInterface.ModelToNextTurnPanelAdaptor, UserInterface.ModelToTranslationPanelAdaptor, UserInterface.ModelToRecognizerPanelAdaptor, UserInterface.ModelToDialogActPanelAdaptor

openExistentFile

private void openExistentFile(java.io.File file)
retrieves an already opened file

Redisplay

public void Redisplay()
dispalys from memory the current document
See Also:
InformationElementsPanel, DisplayCurrentTurn()

Quit

public void Quit()
exits the application and saves the non-saved information
See Also:
UserInterface.FileSaver, Document

deleteDocument

private void deleteDocument(java.lang.String name)

Close

public void Close()
close the file being in use
See Also:
UserInterface.FileSaver, MyMenu.removeFile(String), MyMenu.updateInClose(String), MyMenu.addFile(String), MyMenu.EnableMenu(boolean), Document.fireChange(), Document.ResetValues(), BrowseData(boolean), setCurrentDocument(String), InformationElementsPanel

SaveAs

public void SaveAs(javax.swing.JComponent parent)
saves the document under another name
Parameters:
parent - the parent of the pop-up window for chosing the name of the file
See Also:
SelectFile(JComponent,char), SaveAsNewDoc(File), SaveAsOldDoc(File)

SaveAsNewDoc

public void SaveAsNewDoc(java.io.File file)
saves a new document to disk
Parameters:
file - the full name of the document to be saved
See Also:
UpdateMenusAndVariables(File), UserInterface.FileSaver, DisplayCurrentTurn()

SaveAsOldDoc

public void SaveAsOldDoc(java.io.File file)
saves the document over an already opened one
Parameters:
file - the name of the file on which the save is done
See Also:
UpdateMenusAndVariables(File), UserInterface.FileSaver, DisplayCurrentTurn()

UpdateMenusAndVariables

public void UpdateMenusAndVariables(java.io.File file)
updates the menu and the docs_names vector
Parameters:
file - the name of the document
See Also:
Document, MyMenu.removeFile(String), MyMenu.addFile(String)

DeleteOldDoc

public void DeleteOldDoc(java.lang.String filename)
erases all references to the old document (which will not exist anymore as another file overwrites it)
See Also:
MyMenu.removeFile(String)

Save

public void Save()
starts a thread for saving if the current document is not saved
See Also:
Document, UserInterface.FileSaver

DisplayCurrentTurn

public void DisplayCurrentTurn()
displays the current turn of the document
See Also:
Document.findTurn(int)

DisplayNull

private void DisplayNull()
displays information when no document is opened

changed

public void changed()
this method is called when the user changes the replace characters model in the Settings --> Options menu
See Also:
ReplaceCharacters.actionPerformed(ActionEvent)