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

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--edu.virginia.cs.mng.hypercast.demo.DrawArea

public class DrawArea
extends javax.swing.JPanel

DrawArea class: the class used to draw on.

See Also:
Serialized Form

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 bCanDrawText
           
(package private)  int dragx
          Used to record the intermediate coordinates when you are dragging the mouse.
(package private)  int dragy
          Used to record the intermediate coordinates when you are dragging the mouse.
(package private)  boolean firsttime
           
(package private)  java.awt.FontMetrics fm
           
(package private)  Entry founde
          A entry used to indicate a found entry.
(package private)  MGraphics g
          MGraphics (derived from Graphics) handle used to draw on.
(package private)  MGraphics gDrag
          MGraphics (derived from Graphics) handle used to draw on.
(package private)  MGraphics gOff
          MGraphics (derived from Graphics) handle used to draw on.
(package private) static int HEIGHT
           
(package private)  int idragx
           
(package private)  int idragy
           
(package private)  java.awt.Image imdrag
          Image handles used to buffered-draw on.
(package private)  java.awt.Image imoff
          Image handles used to buffered-draw on.
(package private)  int initx
          The coordinates of the first point of the current entry.
(package private)  int inity
          The coordinates of the first point of the current entry.
(package private)  boolean inpoly
          Whether in the drawing process of a POLY.
(package private)  int killx
          Used to record the coordinates of the first mouse click when you try to KILL an entry.
(package private)  int killy
          Used to record the coordinates of the first mouse click when you try to KILL an entry.
(package private)  boolean kludge
           
(package private)  long lastdragged
          Timestamp used when you draw a BRUSH entry.
(package private)  int lastsize
          Used to store text size when you are drawing a TEXT entry.
(package private)  int lastx
          The coordinates of the last point of the current entry.
(package private)  int lasty
          The coordinates of the last point of the current entry.
(package private)  boolean nuked
           
(package private)  int pagenumber
          The page number this drawing area is associated with.
(package private)  WBFrame parent
          The whiteboard associated with this drawArea.
(package private)  int pointx
          The coordinates of the helping point of the current POLY entry.
(package private)  int pointy
          The coordinates of the helping point of the current POLY entry.
(package private)  java.util.Vector polyx
          Used to store the coordinates of a POLY.
(package private)  java.util.Vector polyy
          Used to store the coordinates of a POLY.
(package private)  int scrollx
           
(package private)  int scrolly
           
private  java.lang.String sPrev
           
(package private)  int strx
          The coordinates used to calculate the drawing position when you draw a TEXT entry.
(package private)  int stry
          The coordinates used to calculate the drawing position when you draw a TEXT entry.
(package private) static long TIMEVAL
           
(package private)  boolean virgin
           
(package private) static int WIDTH
           
(package private) static int xxxxx
           
 
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, 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
 
Constructor Summary
DrawArea(WBFrame p, int pnum)
          Constructor.
 
Method Summary
 void clearEntry(Entry fe)
          To clear a given entry from the drawing area of the whiteboard.
 void doLayout()
          To initialize the layout of this drawing area.
 void draw(MGraphics g, Entry e)
          To draw the given entry on the given Graphics handle.
 void drawTextBox()
          To draw the box that surrounds the text when the user is drawing a TEXT entry.
 java.awt.Image getImage()
           
 java.awt.Dimension getMaximumSize()
          To get the maximun size of this drawing area.
 java.awt.Dimension getMinimumSize()
          To get the minimum size of this drawing area.
 java.awt.Dimension getPreferredSize()
          To get the preferred size of this drawing area.
 void paintComponent(java.awt.Graphics gg)
          To repaint the given Graphics object with overwrite mode.
 void signalfinal()
          A peripheral method which help to draw the POLY and TEXT entry.
 void this_keyPressed(java.awt.event.KeyEvent ev)
          Event handler invoked when the keyboard is pressed.
 void this_mouseDragged(java.awt.event.MouseEvent ev)
          Event handler invoked when the mouse is dragged.
 void this_mouseMoved(java.awt.event.MouseEvent ev)
           
 void this_mousePressed(java.awt.event.MouseEvent ev)
          Event handler invoked when the mouse is pressed.
 void this_mouseReleased(java.awt.event.MouseEvent ev)
          Event handler invoked when the mouse is released.
 void updateGraphics()
           
 
Methods inherited from class javax.swing.JPanel
, getAccessibleContext, getUIClassID, paramString, updateUI, writeObject
 
Methods inherited from class javax.swing.JComponent
_paintImmediately, addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, adjustPaintFlags, alwaysOnTop, bindingForKeyStroke, 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, getNextFocusableComponent, 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, paintImmediately, paintImmediately, paintWithBuffer, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyBindings, processKeyBindingsForAllComponents, processKeyEvent, processMouseMotionEvent, putClientProperty, readObject, rectangleIsObscured, registerKeyboardAction, registerKeyboardAction, registerWithKeyboardManager, removeAncestorListener, removeNotify, 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, 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, eventEnabled, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, 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, setFocusOwner, setLayout, transferFocus, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, 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, 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, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, 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

WIDTH

static final int WIDTH

HEIGHT

static final int HEIGHT

TIMEVAL

static final long TIMEVAL

parent

WBFrame parent
The whiteboard associated with this drawArea.

g

MGraphics g
MGraphics (derived from Graphics) handle used to draw on.

gOff

MGraphics gOff
MGraphics (derived from Graphics) handle used to draw on.

gDrag

MGraphics gDrag
MGraphics (derived from Graphics) handle used to draw on.

fm

java.awt.FontMetrics fm

imoff

java.awt.Image imoff
Image handles used to buffered-draw on.

imdrag

java.awt.Image imdrag
Image handles used to buffered-draw on.

initx

int initx
The coordinates of the first point of the current entry.

inity

int inity
The coordinates of the first point of the current entry.

lastx

int lastx
The coordinates of the last point of the current entry.

lasty

int lasty
The coordinates of the last point of the current entry.

pointx

int pointx
The coordinates of the helping point of the current POLY entry. Used to record the intermediate point of a POLY.

pointy

int pointy
The coordinates of the helping point of the current POLY entry. Used to record the intermediate point of a POLY.

dragx

int dragx
Used to record the intermediate coordinates when you are dragging the mouse.

dragy

int dragy
Used to record the intermediate coordinates when you are dragging the mouse.

idragx

int idragx

idragy

int idragy

killx

int killx
Used to record the coordinates of the first mouse click when you try to KILL an entry.

killy

int killy
Used to record the coordinates of the first mouse click when you try to KILL an entry.

lastsize

int lastsize
Used to store text size when you are drawing a TEXT entry.

lastdragged

long lastdragged
Timestamp used when you draw a BRUSH entry.

polyx

java.util.Vector polyx
Used to store the coordinates of a POLY.

polyy

java.util.Vector polyy
Used to store the coordinates of a POLY.

inpoly

boolean inpoly
Whether in the drawing process of a POLY.

virgin

boolean virgin

nuked

boolean nuked

founde

Entry founde
A entry used to indicate a found entry. Used when a MOVE or COPY operation is performed.

strx

int strx
The coordinates used to calculate the drawing position when you draw a TEXT entry.

stry

int stry
The coordinates used to calculate the drawing position when you draw a TEXT entry.

scrollx

int scrollx

scrolly

int scrolly

kludge

boolean kludge

pagenumber

int pagenumber
The page number this drawing area is associated with.

bCanDrawText

boolean bCanDrawText

firsttime

boolean firsttime

sPrev

private java.lang.String sPrev

xxxxx

static int xxxxx
Constructor Detail

DrawArea

public DrawArea(WBFrame p,
                int pnum)
Constructor.
Parameters:
p - the whiteboard assoicated with me.
pnum - page number
Method Detail

doLayout

public void doLayout()
To initialize the layout of this drawing area.
Overrides:
doLayout in class java.awt.Container

updateGraphics

public void updateGraphics()

getMinimumSize

public java.awt.Dimension getMinimumSize()
To get the minimum size of this drawing area. That is (0,0).
Returns:
a Dimension object of (0,0).
Overrides:
getMinimumSize in class javax.swing.JComponent

getMaximumSize

public java.awt.Dimension getMaximumSize()
To get the maximun size of this drawing area.
Returns:
a Dimension object corresopnding to the maximum size.
Overrides:
getMaximumSize in class javax.swing.JComponent

getPreferredSize

public java.awt.Dimension getPreferredSize()
To get the preferred size of this drawing area.
Returns:
a Dimension object corresponding to the preferred size.
Overrides:
getPreferredSize in class javax.swing.JComponent

draw

public void draw(MGraphics g,
                 Entry e)
To draw the given entry on the given Graphics handle. All information needed to draw is store in the entry object. The entry may be BRUSH, TEXT, LINE, RECT, ROUNDRECT, OVAL, POLY, IMAGE.
Parameters:
g - the given Graphics handle.
e - the given entry.

paintComponent

public void paintComponent(java.awt.Graphics gg)
To repaint the given Graphics object with overwrite mode.
Parameters:
g - the given Graphics object.
Overrides:
paintComponent in class javax.swing.JComponent

clearEntry

public void clearEntry(Entry fe)
To clear a given entry from the drawing area of the whiteboard. The entry is not remove from internal data structure (a vector) by this method.
Parameters:
fe - the given entry to be cleared.

drawTextBox

public void drawTextBox()
To draw the box that surrounds the text when the user is drawing a TEXT entry.

this_mousePressed

public void this_mousePressed(java.awt.event.MouseEvent ev)
Event handler invoked when the mouse is pressed. It is very important. Whenever the mouse is pressed, a new piece of drawing is beginning, thus an new entry is being created. To create the new entry, its internal data structures are being created in this method. Some entries (POLY) take double click as their end. This is also processed in this method.

this_mouseDragged

public void this_mouseDragged(java.awt.event.MouseEvent ev)
Event handler invoked when the mouse is dragged. It is very important for most drawing is finished by dragging the mouse.

this_mouseMoved

public void this_mouseMoved(java.awt.event.MouseEvent ev)

this_mouseReleased

public void this_mouseReleased(java.awt.event.MouseEvent ev)
Event handler invoked when the mouse is released. The mouse release often means a drawing is finished (POLY is the exception). So many final updating and drawing is done in this methods.

this_keyPressed

public void this_keyPressed(java.awt.event.KeyEvent ev)
Event handler invoked when the keyboard is pressed. It is useful when the user is drawing a TEXT entry.

signalfinal

public void signalfinal()
A peripheral method which help to draw the POLY and TEXT entry.

getImage

public java.awt.Image getImage()