edu.virginia.cs.mng.hypercast.demo
Class WBFrame

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--edu.virginia.cs.mng.hypercast.demo.WBFrame

public class WBFrame
extends javax.swing.JFrame

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AWTTreeLock
 
Field Summary
(package private)  boolean aboutopen
           
(package private)  int activepage
          The current/active page.
(package private)  java.awt.Color back
          Color.
(package private)  boolean backclear
           
(package private)  java.awt.BorderLayout borderLayout1
           
(package private)  boolean busy
           
(package private)  int chosentool
          The current tool chosen by the current user.
(package private)  javax.swing.JPanel contentPane
           
(package private)  DrawArea darea
           
(package private)  java.util.Vector dareas
           
(package private)  java.util.Vector entries
          Vector internally used to store all drawing entries.
(package private)  int entryid
          The ID used to identify the current drawing entry.
(package private)  java.awt.Color fore
          Color.
(package private)  boolean foreclear
           
(package private)  java.awt.GridBagLayout gridBagLayout1
           
private  int HEIGHT
           
(package private)  java.lang.String id
          The person ID used for user interface.
(package private)  javax.swing.JMenuBar jMenuBar1
           
(package private)  javax.swing.JMenu jMenuFile
           
(package private)  javax.swing.JMenuItem jMenuFileExit
           
(package private)  javax.swing.JMenuItem jMenuFileSave
           
(package private)  javax.swing.JMenu jMenuHelp
           
(package private)  javax.swing.JMenuItem jMenuHelpAbout
           
(package private)  javax.swing.JPanel jPanel1
           
(package private)  javax.swing.JPanel jPanel2
           
(package private)  javax.swing.JPanel jPanel3
           
(package private)  javax.swing.JPanel jPanel6
           
(package private)  WBSocket m_wbSock
          The I_OverlaySocket object used to communicate with other whiteboards.
(package private)  char nextc
          Next character when you use a TEXT tool.
(package private)  ColorPanel panColor
           
(package private)  PagePanel panPage
           
(package private)  ToolPanel panTool
           
(package private)  UserPanel panUser
           
(package private)  javax.swing.JScrollPane panWb
           
(package private)  boolean pensizeopen
           
(package private)  int penwidth
          The current pen width.
(package private)  int personid
          The person ID internally used.
(package private)  int textsize
          The current text size.
(package private)  boolean textsizeopen
           
(package private)  javax.swing.border.TitledBorder titledBorder1
           
(package private)  javax.swing.border.TitledBorder titledBorder2
           
(package private)  int totalpages
          Number of total pages.
(package private)  java.util.Hashtable userlist
          Hashtable internally used to store all users.
private  int WIDTH
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, defaultCloseOperation, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
base, CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, frameSerializedDataVersion, HAND_CURSOR, icon, ICONIFIED, mbManagement, menuBar, MOVE_CURSOR, N_RESIZE_CURSOR, nameCounter, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, ownedWindows, resizable, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, serialVersionUID, state, SW_RESIZE_CURSOR, TEXT_CURSOR, title, W_RESIZE_CURSOR, WAIT_CURSOR, weakThis
 
Fields inherited from class java.awt.Window
active, base, focusMgr, inputContext, nameCounter, OPENED, ownedWindowList, serialVersionUID, state, warningString, weakThis, windowListener, windowSerializedDataVersion
 
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
 
Constructor Summary
WBFrame()
           
 
Method Summary
 void add(Entry e, boolean send)
          To add a drawing entry to the vector and draw it to the whiteboard.
(package private)  void addpage(boolean mine)
          To add one page to the current whiteboar.
(package private)  boolean adduser(int id, java.lang.String name)
          Add a user to the user list.
(package private)  Entry ddfind(int x, int y)
          To find an entry according to a given coordinate.
(package private)  void doInits()
          To do some startup things, mainly some internal data members.
(package private)  void dropuser(int id)
          To remove a user from the user list.
(package private)  Entry efind(int pid, int eid)
          To find a specific entry according to a person ID and the entry ID.
(package private)  Entry find(int x, int y)
          To find an entry according to a given coordinate.
(package private)  int findnewid(int pid)
          To get a new entry ID according to the given person ID.
(package private)  void flippage()
           
 java.awt.Dimension GetMinimalSize()
           
(package private)  boolean inside(int index, int x1, int y1, int x2, int y2)
          To determine whether the given entry is in the given region.
private  void jbInit()
          Component initialization
 void jMenuFileDump_actionPerformed(java.awt.event.ActionEvent e)
           
 void jMenuFileExit_actionPerformed(java.awt.event.ActionEvent e)
           
 void jMenuFileSave_actionPerformed(java.awt.event.ActionEvent e)
           
 void jMenuHelpAbout_actionPerformed(java.awt.event.ActionEvent e)
           
(package private)  void leavenet()
          The local whiteboard declares its quit to all others.
(package private)  int myhash(java.lang.String s)
          A customized hash algorithm, calculate a hashing result for a string.
(package private)  void panTool_mouseClicked(java.awt.event.MouseEvent e)
           
(package private)  void panTool_mousePressed(java.awt.event.MouseEvent e)
           
protected  void processWindowEvent(java.awt.event.WindowEvent e)
          Overridden so we can exit when window is closed
 Entry typing(int pid)
          To find the current TEXT entry according to the given person ID.
 void updatedrawcolors()
          To update the current color.
 void writeJpegFile(java.lang.String sFilename, java.awt.Image img)
           
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, createRootPaneException, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
, addNotify, addToFrameList, constructComponentName, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, initIDs, isResizable, postProcessKeyEvent, readObject, remove, removeFromFrameList, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle, writeObject
 
Methods inherited from class java.awt.Window
addOwnedWindow, addWindowListener, applyResourceBundle, applyResourceBundle, connectOwnedWindow, dispatchEventImpl, dispose, eventEnabled, getFocusOwner, getInputContext, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, isActive, isShowing, nextFocus, ownedInit, pack, postEvent, postWindowEvent, preProcessKeyEvent, processEvent, removeOwnedWindow, removeWindowListener, setFocusOwner, setWarningString, show, toBack, toFront, transferFocus
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyOrientation, countComponents, deliverEvent, dispatchEventToSelf, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, paint, paintComponents, postsOldMouseEvents, preferredSize, print, printComponents, printOneComponent, processContainerEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

m_wbSock

WBSocket m_wbSock
The I_OverlaySocket object used to communicate with other whiteboards.

personid

int personid
The person ID internally used. Derived from id by hashing.

id

java.lang.String id
The person ID used for user interface. Consituted by a local user name, a local host name and a timestamp.

entryid

int entryid
The ID used to identify the current drawing entry.

fore

java.awt.Color fore
Color.

back

java.awt.Color back
Color.

foreclear

boolean foreclear

backclear

boolean backclear

chosentool

int chosentool
The current tool chosen by the current user.

penwidth

int penwidth
The current pen width.

textsize

int textsize
The current text size.

nextc

char nextc
Next character when you use a TEXT tool.

totalpages

int totalpages
Number of total pages.

activepage

int activepage
The current/active page.

aboutopen

boolean aboutopen

entries

java.util.Vector entries
Vector internally used to store all drawing entries.

userlist

java.util.Hashtable userlist
Hashtable internally used to store all users.

busy

boolean busy

dareas

java.util.Vector dareas

darea

DrawArea darea

pensizeopen

boolean pensizeopen

textsizeopen

boolean textsizeopen

WIDTH

private final int WIDTH

HEIGHT

private final int HEIGHT

jMenuBar1

javax.swing.JMenuBar jMenuBar1

jMenuFile

javax.swing.JMenu jMenuFile

jMenuFileSave

javax.swing.JMenuItem jMenuFileSave

jMenuFileExit

javax.swing.JMenuItem jMenuFileExit

jMenuHelp

javax.swing.JMenu jMenuHelp

jMenuHelpAbout

javax.swing.JMenuItem jMenuHelpAbout

contentPane

javax.swing.JPanel contentPane

borderLayout1

java.awt.BorderLayout borderLayout1

jPanel1

javax.swing.JPanel jPanel1

panWb

javax.swing.JScrollPane panWb

jPanel2

javax.swing.JPanel jPanel2

panPage

PagePanel panPage

titledBorder1

javax.swing.border.TitledBorder titledBorder1

jPanel3

javax.swing.JPanel jPanel3

panTool

ToolPanel panTool

jPanel6

javax.swing.JPanel jPanel6

panColor

ColorPanel panColor

gridBagLayout1

java.awt.GridBagLayout gridBagLayout1

titledBorder2

javax.swing.border.TitledBorder titledBorder2

panUser

UserPanel panUser
Constructor Detail

WBFrame

public WBFrame()
Method Detail

doInits

void doInits()
To do some startup things, mainly some internal data members. This is invoked just before jbInit(), by this.constructor().

jbInit

private void jbInit()
             throws java.lang.Exception
Component initialization

processWindowEvent

protected void processWindowEvent(java.awt.event.WindowEvent e)
Overridden so we can exit when window is closed
Overrides:
processWindowEvent in class javax.swing.JFrame

panTool_mouseClicked

void panTool_mouseClicked(java.awt.event.MouseEvent e)

panTool_mousePressed

void panTool_mousePressed(java.awt.event.MouseEvent e)

myhash

int myhash(java.lang.String s)
A customized hash algorithm, calculate a hashing result for a string.
Parameters:
s - the input string
Returns:
the hashing result, integer.

updatedrawcolors

public void updatedrawcolors()
To update the current color.

typing

public Entry typing(int pid)
To find the current TEXT entry according to the given person ID.
Parameters:
pid - the given person ID.
Returns:
the entry found.

findnewid

int findnewid(int pid)
To get a new entry ID according to the given person ID.
Parameters:
pid - the given person ID
Returns:
the new entry ID (integer)

add

public void add(Entry e,
                boolean send)
To add a drawing entry to the vector and draw it to the whiteboard. The entry also may be sent to other whiteboards for drawing.
Parameters:
e - the entry to be added
send - whether to send the entry to other whiteboards.

inside

boolean inside(int index,
               int x1,
               int y1,
               int x2,
               int y2)
To determine whether the given entry is in the given region. Only invoked by drawarea::clearEntry().
Parameters:
index - the index of the given entry
x1,y1,x2,y2 - the coordinates of the given region
Returns:
a boolean result

efind

Entry efind(int pid,
            int eid)
To find a specific entry according to a person ID and the entry ID.
Parameters:
pid - a person Id
eid - an entry ID
Returns:
the entry object with the given person ID and the entry ID

find

Entry find(int x,
           int y)
To find an entry according to a given coordinate. The entry belong to the current person and current page.
Parameters:
x,y - the given coordinate
Returns:
the entry found.

ddfind

Entry ddfind(int x,
             int y)
To find an entry according to a given coordinate. Only used for degugging. The entry belongs to the current page, but don't have to belong to the current person.
Parameters:
x,y - the given coordinate
Returns:
the entry found.

adduser

boolean adduser(int id,
                java.lang.String name)
Add a user to the user list.
Parameters:
id - the ID internally used.
name - the user name (also an ID) publicly used.
Returns:
a boolean indicating success or failure.
See Also:
id, personid

dropuser

void dropuser(int id)
To remove a user from the user list.
Parameters:
id - the ID of the user to be removed.

addpage

void addpage(boolean mine)
To add one page to the current whiteboar.
Parameters:
mine - whether this page is mine(locally). If locally, a NEWPAGE command should also be sent to other whiteboard.

flippage

void flippage()

leavenet

void leavenet()
The local whiteboard declares its quit to all others. The major task is to send a DROP message to other whiteboards.

GetMinimalSize

public java.awt.Dimension GetMinimalSize()

jMenuFileDump_actionPerformed

public void jMenuFileDump_actionPerformed(java.awt.event.ActionEvent e)

jMenuFileSave_actionPerformed

public void jMenuFileSave_actionPerformed(java.awt.event.ActionEvent e)

writeJpegFile

public void writeJpegFile(java.lang.String sFilename,
                          java.awt.Image img)

jMenuFileExit_actionPerformed

public void jMenuFileExit_actionPerformed(java.awt.event.ActionEvent e)

jMenuHelpAbout_actionPerformed

public void jMenuHelpAbout_actionPerformed(java.awt.event.ActionEvent e)