standup.clouds
Class CloudFrontend

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by standup.clouds.CloudFrontend
All Implemented Interfaces:
ClipboardOwner, ImageObserver, MenuContainer, Serializable, Accessible, Profileable

public class CloudFrontend
extends JPanel
implements ClipboardOwner, Profileable

The main class that launches the STANDUP GUI and sets up all the various user interface components.

Author:
Ruli Manurung
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int animationDelay
          Delay in milliseconds between 'frames' of animation.
private  boolean atProfileSelectionStage
          This field records whether the user is currently at the profile selection stage, or whether a profile has been chosen and someone is using the system proper.
private  Backend backend
           
private  BufferedImage backgroundNoProgressMap
           
private  BufferedImage backgroundProgressMap
           
(package private)  Hashtable<String,LexemeSet> cachedWordClusters
           
(package private)  WordTrie cachedWordTrie
           
private  JFrame ff
           
private static JFrame frame
          Create the GUI and show it.
private  ProfileCloudFrontend frontendProfile
          Fields and methods that handle scanning functionality
private  int height
           
private  HelpCoordinator helpCoordinator
           
private  HistoryCoordinator historyCoordinator
           
private  boolean isInteractive
           
private  Logger logger
           
private  PanelMessageWindow messageWindow
           
private  CloudDialog myDialog
           
private  CloudDialogNonModal myDialogNonModal
           
private  PanelCloudButtonMenu panelCloudButtonMenu
           
private  PanelProgressMap panelProgressMap
           
private  PanelToolbar panelToolbar
           
private  Scanner scanner
           
private static long serialVersionUID
           
 STANDUPSpeaker speaker
           
private  int width
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CloudFrontend(JFrame _ff, int w, int h, Logger log, STANDUPSpeaker spk, Scanner scn, Backend bck, boolean interact, boolean hideDecorations)
          Constructor for the Frontend.
 
Method Summary
 boolean animationInProgress()
           
 void clickScanner()
          Sends a 'click' to the Scanner, i.e.
private static void createAndShowGUI(Backend backendInstance)
           
 boolean createProfile(File directory)
          Instantiates a 'default' profile and saves it in the specified user directory.
 void dehighlightAll()
           
 Backend getBackend()
           
 JFrame getFrame()
           
 int getHeight()
           
 HelpCoordinator getHelpCoordinator()
           
 HistoryCoordinator getHistoryCoordinator()
           
(package private)  Logger getLogger()
           
 CloudButton getMainMenu()
          This displays the main menu -- implements Use Case 1 in the Frontend spec doc.
 PanelMessageWindow getMessageWindow()
           
 CloudDialog getMyDialog()
           
 CloudDialogNonModal getMyDialogNonModal()
           
 PanelCloudButtonMenu getPanelCloudButtonMenu()
           
(package private)  PanelProgressMap getPanelProgressMap()
           
 PanelToolbar getPanelToolbar()
           
 ProfileCloudFrontend getProfile()
          Returns the Profile currently being used by this Profileable.
 String getProfileFilename()
          Returns the filename used to specify the profile filename.
 STANDUPSpeaker getSpeaker()
           
 String getVersionNumber()
           
 int getWidth()
           
(package private)  Hashtable<String,LexemeSet> getWordClusters()
           
(package private)  WordTrie getWordTrie()
           
 boolean isAtProfileSelectionStage()
          Returns true if the user is at the profile selection stage, and falseotherwise.
(package private)  boolean isInteractive()
           
 Profile loadProfile(File directory)
          Loads the Profile associated with this Profileable from the specified directory and returns it.
 void lostOwnership(Clipboard arg0, Transferable arg1)
           
static void main(String[] args)
           
protected  void paintComponent(Graphics arg0)
           
 void pauseScanner()
           
(package private)  void recomputeWordClusters()
           
 void resetMainGUIPanels()
           
(package private)  void resetPanels(boolean apss, PanelToolbar tb, PanelMessageWindow mw, PanelProgressMap pm, PanelCloudButtonMenu bb)
           
 void resetProfileChooser()
          This method brings up the 'profile chooser' menu.
 void resetScanner()
           
 void resumeScanner()
           
 void setAtProfileSelectionStage(boolean apss)
          Sets the atProfileSelectionStage field.
 void setHeight(int height)
           
 void setMyDialog(CloudDialog myd)
           
 boolean setProfile(Profile profile, boolean repeat)
          This sets the CloudFrontendProfile.
 void setWidth(int width)
           
(package private)  void showMainMenu()
           
(package private)  void showProfileChooser()
           
 void tryToEnd()
           
 void tryToExit()
           
 void tryToGoHome()
           
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

panelToolbar

private PanelToolbar panelToolbar

panelCloudButtonMenu

private PanelCloudButtonMenu panelCloudButtonMenu

messageWindow

private PanelMessageWindow messageWindow

panelProgressMap

private PanelProgressMap panelProgressMap

myDialog

private CloudDialog myDialog

myDialogNonModal

private final CloudDialogNonModal myDialogNonModal

historyCoordinator

private final HistoryCoordinator historyCoordinator

helpCoordinator

private final HelpCoordinator helpCoordinator

scanner

private final Scanner scanner

logger

private final Logger logger

speaker

public STANDUPSpeaker speaker

animationDelay

public static final int animationDelay
Delay in milliseconds between 'frames' of animation.

See Also:
Constant Field Values

ff

private final JFrame ff

backend

private final Backend backend

atProfileSelectionStage

private boolean atProfileSelectionStage
This field records whether the user is currently at the profile selection stage, or whether a profile has been chosen and someone is using the system proper. The profile selection stage differs from the main interaction as follows:


width

private int width

height

private int height

backgroundProgressMap

private final BufferedImage backgroundProgressMap

backgroundNoProgressMap

private final BufferedImage backgroundNoProgressMap

isInteractive

private final boolean isInteractive

frame

private static JFrame frame
Create the GUI and show it. For thread safety, this method should be invoked from the event-dispatching thread.


cachedWordClusters

Hashtable<String,LexemeSet> cachedWordClusters

cachedWordTrie

WordTrie cachedWordTrie

frontendProfile

private ProfileCloudFrontend frontendProfile
Fields and methods that handle scanning functionality

Constructor Detail

CloudFrontend

public CloudFrontend(JFrame _ff,
                     int w,
                     int h,
                     Logger log,
                     STANDUPSpeaker spk,
                     Scanner scn,
                     Backend bck,
                     boolean interact,
                     boolean hideDecorations)
Constructor for the Frontend. Reads the parameters and sets up all the subcomponents: BubbleBrowser, Toolbar, ProgressMap, HistoryCoordinator, Backend (mock or otherwise), etc.

Parameters:
w -
h -
log -
spk -
scn -
bck -
interact -
Method Detail

getPanelToolbar

public PanelToolbar getPanelToolbar()

getPanelCloudButtonMenu

public PanelCloudButtonMenu getPanelCloudButtonMenu()

getMessageWindow

public PanelMessageWindow getMessageWindow()

getPanelProgressMap

PanelProgressMap getPanelProgressMap()

getMyDialog

public CloudDialog getMyDialog()

setMyDialog

public void setMyDialog(CloudDialog myd)

getMyDialogNonModal

public CloudDialogNonModal getMyDialogNonModal()

getHistoryCoordinator

public HistoryCoordinator getHistoryCoordinator()

getHelpCoordinator

public HelpCoordinator getHelpCoordinator()

clickScanner

public void clickScanner()
Sends a 'click' to the Scanner, i.e. calls Scanner.clickScanner(), if warranted


pauseScanner

public void pauseScanner()

resumeScanner

public void resumeScanner()

resetScanner

public void resetScanner()

getLogger

Logger getLogger()

getSpeaker

public STANDUPSpeaker getSpeaker()

getFrame

public JFrame getFrame()

getBackend

public Backend getBackend()

resetMainGUIPanels

public void resetMainGUIPanels()

resetProfileChooser

public void resetProfileChooser()
This method brings up the 'profile chooser' menu. It loads the special 'profile chooser' profile and reinstantiates the Toolbar, MessageWindow, and BubbleBrowser. It is currently called only by the constructor of Frontend, but in theory it can be called at any moment, i.e. by an "exit to profile chooser" option -- just remember to save the current user's profile before calling resetProfile()!


resetPanels

void resetPanels(boolean apss,
                 PanelToolbar tb,
                 PanelMessageWindow mw,
                 PanelProgressMap pm,
                 PanelCloudButtonMenu bb)

isAtProfileSelectionStage

public boolean isAtProfileSelectionStage()
Returns true if the user is at the profile selection stage, and falseotherwise.

Returns:
true if the user is at the profile selection stage, and falseotherwise

setAtProfileSelectionStage

public void setAtProfileSelectionStage(boolean apss)
Sets the atProfileSelectionStage field.

Parameters:
apss - new value for atProfileSelectionStage

showProfileChooser

void showProfileChooser()

showMainMenu

void showMainMenu()

getMainMenu

public CloudButton getMainMenu()
This displays the main menu -- implements Use Case 1 in the Frontend spec doc.

Returns:
BubbleMenu containing the main menu

isInteractive

boolean isInteractive()

paintComponent

protected void paintComponent(Graphics arg0)
Overrides:
paintComponent in class JComponent

tryToEnd

public void tryToEnd()

tryToExit

public void tryToExit()

tryToGoHome

public void tryToGoHome()

createAndShowGUI

private static void createAndShowGUI(Backend backendInstance)

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception

lostOwnership

public void lostOwnership(Clipboard arg0,
                          Transferable arg1)
Specified by:
lostOwnership in interface ClipboardOwner

dehighlightAll

public void dehighlightAll()

getVersionNumber

public String getVersionNumber()

getHeight

public int getHeight()
Overrides:
getHeight in class JComponent

setHeight

public void setHeight(int height)

getWidth

public int getWidth()
Overrides:
getWidth in class JComponent

setWidth

public void setWidth(int width)

getWordClusters

Hashtable<String,LexemeSet> getWordClusters()

getWordTrie

WordTrie getWordTrie()

recomputeWordClusters

void recomputeWordClusters()

animationInProgress

public boolean animationInProgress()

createProfile

public boolean createProfile(File directory)
Description copied from interface: Profileable
Instantiates a 'default' profile and saves it in the specified user directory. Assumes that the directory has been created, and is available from ProfileManager.getUserDirectory(String).

Specified by:
createProfile in interface Profileable
Returns:
true if succesfully created, false otherwise

getProfile

public ProfileCloudFrontend getProfile()
Description copied from interface: Profileable
Returns the Profile currently being used by this Profileable.

Specified by:
getProfile in interface Profileable
Returns:
the currently used Profile

getProfileFilename

public String getProfileFilename()
Description copied from interface: Profileable
Returns the filename used to specify the profile filename. Since a user profile contains various separate Profiles, and they are all stored in the same user directory, the profile filenames must be unique. Convention is to use a .profile file extension, e.g. 'jokegeneration.profile', 'lexical.profile', 'clouds.profile', etc..

Specified by:
getProfileFilename in interface Profileable
Returns:
the filename used to specify the profile file within the user directory

loadProfile

public Profile loadProfile(File directory)
Description copied from interface: Profileable
Loads the Profile associated with this Profileable from the specified directory and returns it. Assumes that the directory has been created, and that it contains a file whose name is the same as that given by Profileable.getProfileFilename(). Note that it doesn't actually use/set the returned Profile -- call Profileable.setProfile(Profile, boolean) for that.

Really this should be a static method, but Java interfaces cannot specify static methods.

Specified by:
loadProfile in interface Profileable
Parameters:
directory - The directory containing the profile (and associated files)
Returns:
returns the instantiated Profile

setProfile

public boolean setProfile(Profile profile,
                          boolean repeat)
This sets the CloudFrontendProfile. This should be called by Backend.useProfile and possibly by ControlPanel

Specified by:
setProfile in interface Profileable
Parameters:
profile -
repeat - whether this is the first time a profile is being set for the current user during this session
Returns:
true if successful, false otherwise.