diva.whiteboard
Class Whiteboard

java.lang.Object
  extended by diva.gui.AbstractApplication
      extended by diva.gui.MDIApplication
          extended by diva.whiteboard.Whiteboard
All Implemented Interfaces:
Application

public class Whiteboard
extends MDIApplication

A digital whiteboard application that supports freeform sketching and gestural command editing.

Version:
$Revision: 1.60 $
Author:
Heloise Hse (hwawen@eecs.berkeley.edu)

Nested Class Summary
 class Whiteboard.WBAppViewListener
           
 class Whiteboard.WBPageListener
           
protected  class Whiteboard.WBStateListener
          Listens to the whiteboard state and updates the widgets accordingly.
 
Field Summary
protected  JMenuItem _closeMenuItem
           
protected  JButton _commandModeButton
           
protected  JButton _fillColorButton
           
protected  JPopupMenu _fillPopupMenu
           
protected  JButton _highlightModeButton
           
protected  JButton _newPageButton
          Tool Bar Buttons
protected  JMenuItem _newPageMenuItem
          Menu items
protected  JButton _nextButton
           
protected  JMenuItem _nextMenuItem
           
protected  JButton _openButton
           
protected  JButton _outlineColorButton
           
protected  JPopupMenu _outlinePopupMenu
           
protected  JButton _previousButton
           
protected  JMenuItem _previousMenuItem
           
protected  JMenuItem _printMenuItem
           
protected  JMenuItem _redoMenuItem
           
protected  JMenuItem _saveAsGIFMenuItem
           
protected  JMenuItem _saveAsMenuItem
           
protected  JButton _saveButton
           
protected  JMenuItem _saveMenuItem
           
protected  JButton _sketchModeButton
           
protected  SketchStoragePolicy _storagePolicy
          A copy of the storage policy reference
protected  diva.whiteboard.Whiteboard.UndoAdaptor _undoAdaptor
           
protected  JMenuItem _undoMenuItem
           
protected  WhiteboardState _whiteboardState
          Tool Bar Buttons
protected  JButton _widthButton
           
protected  JPopupMenu _widthPopupMenu
           
static int BUTTON_HEIGHT
          The height of the image on a button in the toolbar.
static int BUTTON_WIDTH
          The width of the image on a button in the toolbar.
 
Constructor Summary
Whiteboard(DesktopContext context)
          Construct a new whiteboard application.
 
Method Summary
 void addDocument(Document d)
          Add a document to the list of documents currently known by this application.
 boolean closeDocument(Document d)
          Try to close the given document using the storage policy.
 View createView(Document d)
          Return a view for the given document.
 void displayDocument(Document d)
          Display the given document.
protected  DesktopContext getDesktopContext()
           
 String getTitle()
          Get the title of this application
 WhiteboardState getWhiteboardState()
           
protected  void initializeDebugMenu(JMenuBar mb)
          Create the Debug menu with the following items: Save Gestures Load Gestures
protected  void initializeEditMenu(JMenuBar mb)
          Create the Edit menu with the following items: Cut Copy Paste
protected  void initializeFileMenu(JMenuBar mb)
          Create the File menu with the following items: New Open Close Save Save As Print Exit
 void initializeMenuBar(JMenuBar mb)
          Initialize the given menubar.
protected  void initializeToolBar(JToolBar tb)
          Initialize the given toolbar.
protected  void initializeToolbarPenColorMenu(JToolBar tb)
          Adds a button to the toolbar which allows the user to change the color of the pen ink.
protected  void initializeToolbarPenWidthMenu(JToolBar tb)
          Adds a button to the toolbar which allows the user to change the thickness of the pen.
protected  void initializeViewMenu(JMenuBar mb)
          Create the View menu with the following items: Next Page Previous Page
static void main(String[] argv)
          Create and run a new whiteboard application.
 
Methods inherited from class diva.gui.MDIApplication
addView, getMDIContext, getView, removeView, setCurrentView
 
Methods inherited from class diva.gui.AbstractApplication
actions, addAction, addDocumentListener, addMenuItem, addMenuItem, addPropertyChangeListener, addToolBarButton, addToolBarButton, addViewListener, closeView, documentList, getAction, getAppContext, getClipboard, getCurrentView, getDocumentFactory, getResources, getStoragePolicy, isVisible, removeDocument, removeDocumentListener, removePropertyChangeListener, removeViewListener, setAppContext, setClipboard, setDocumentFactory, setStoragePolicy, setVisible, showError, viewList, viewList
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUTTON_WIDTH

public static final int BUTTON_WIDTH
The width of the image on a button in the toolbar.

See Also:
Constant Field Values

BUTTON_HEIGHT

public static final int BUTTON_HEIGHT
The height of the image on a button in the toolbar.

See Also:
Constant Field Values

_storagePolicy

protected SketchStoragePolicy _storagePolicy
A copy of the storage policy reference


_newPageMenuItem

protected JMenuItem _newPageMenuItem
Menu items


_closeMenuItem

protected JMenuItem _closeMenuItem

_saveMenuItem

protected JMenuItem _saveMenuItem

_printMenuItem

protected JMenuItem _printMenuItem

_saveAsMenuItem

protected JMenuItem _saveAsMenuItem

_saveAsGIFMenuItem

protected JMenuItem _saveAsGIFMenuItem

_undoMenuItem

protected JMenuItem _undoMenuItem

_redoMenuItem

protected JMenuItem _redoMenuItem

_nextMenuItem

protected JMenuItem _nextMenuItem

_previousMenuItem

protected JMenuItem _previousMenuItem

_newPageButton

protected JButton _newPageButton
Tool Bar Buttons


_openButton

protected JButton _openButton

_saveButton

protected JButton _saveButton

_nextButton

protected JButton _nextButton

_previousButton

protected JButton _previousButton

_outlinePopupMenu

protected JPopupMenu _outlinePopupMenu

_fillPopupMenu

protected JPopupMenu _fillPopupMenu

_outlineColorButton

protected JButton _outlineColorButton

_fillColorButton

protected JButton _fillColorButton

_widthPopupMenu

protected JPopupMenu _widthPopupMenu

_widthButton

protected JButton _widthButton

_sketchModeButton

protected JButton _sketchModeButton

_highlightModeButton

protected JButton _highlightModeButton

_commandModeButton

protected JButton _commandModeButton

_whiteboardState

protected WhiteboardState _whiteboardState
Tool Bar Buttons


_undoAdaptor

protected diva.whiteboard.Whiteboard.UndoAdaptor _undoAdaptor
Constructor Detail

Whiteboard

public Whiteboard(DesktopContext context)
Construct a new whiteboard application. The application will not have any open sketch documents, until they are opened by getting the "Open" action and invoking its actionPerformed() method.

Method Detail

main

public static void main(String[] argv)
Create and run a new whiteboard application.


addDocument

public void addDocument(Document d)
Description copied from class: AbstractApplication
Add a document to the list of documents currently known by this application. Fire a document list event to registered listeners. Throw an exception if the document is already in the list of documents.

Specified by:
addDocument in interface Application
Overrides:
addDocument in class AbstractApplication

closeDocument

public boolean closeDocument(Document d)
Description copied from class: AbstractApplication
Try to close the given document using the storage policy.

Specified by:
closeDocument in interface Application
Overrides:
closeDocument in class AbstractApplication

createView

public View createView(Document d)
Return a view for the given document. Invoked by DefaultActions newAction and openAction. Add a page listener to the multipage document and then instantiate a whiteboard view object.

Specified by:
createView in interface Application
Specified by:
createView in class MDIApplication

displayDocument

public void displayDocument(Document d)
Display the given document. The document should already be added to the application. After calling this method, most callers should set this document to be the current document.


getDesktopContext

protected DesktopContext getDesktopContext()

getTitle

public String getTitle()
Get the title of this application

Specified by:
getTitle in interface Application
Specified by:
getTitle in class AbstractApplication

getWhiteboardState

public WhiteboardState getWhiteboardState()

initializeMenuBar

public void initializeMenuBar(JMenuBar mb)
Initialize the given menubar. Currently, all strings are hard-wired, but maybe we should be getting them out of the ApplicationResources.


initializeDebugMenu

protected void initializeDebugMenu(JMenuBar mb)
Create the Debug menu with the following items:
  1. Save Gestures
  2. Load Gestures


initializeEditMenu

protected void initializeEditMenu(JMenuBar mb)
Create the Edit menu with the following items:
  1. Cut
  2. Copy
  3. Paste


initializeFileMenu

protected void initializeFileMenu(JMenuBar mb)
Create the File menu with the following items:
  1. New
  2. Open
  3. Close
  4. Save
  5. Save As
  6. Print
  7. Exit


initializeViewMenu

protected void initializeViewMenu(JMenuBar mb)
Create the View menu with the following items:
  1. Next Page
  2. Previous Page


initializeToolBar

protected void initializeToolBar(JToolBar tb)
Initialize the given toolbar. Image icons will be obtained from the ApplicationResources object and added to the actions. Note that the image icons are not added to the actions -- if we did that, the icons would appear in the menus, which I suppose is a neat trick but completely useless.


initializeToolbarPenColorMenu

protected void initializeToolbarPenColorMenu(JToolBar tb)
Adds a button to the toolbar which allows the user to change the color of the pen ink. When the button is pressed, a menu will show up, and the menu provides 4 basic colors for convenience. The last item in the menu is "custom...". This will bring up a color palette and give the user a lot more color choices.


initializeToolbarPenWidthMenu

protected void initializeToolbarPenWidthMenu(JToolBar tb)
Adds a button to the toolbar which allows the user to change the thickness of the pen. When the button is pressed, a menu will show up, and the menu provides 5 choices of line widths for convenience. User can also perform this task through the menu.



Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.