|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--java.awt.Panel | +--java.applet.Applet | +--DrawPadView
CLASS: DrawPadView
PURPOSE: This class handle all the GUI action and this is also
the main class for the applet
IMPORT: java.awt.Color, java.applet.Applet, java.awt.Graphics,
java.awt.Image, java.awt.event.MouseEvent,
java.awt.event.MouseListener, java.awt.event.MouseMotionListener,
java.awt.event.KeyListener, java.awt.event.KeyEvent, Ellipse,
Rectangle, Line, Polygon, DrawableShape, DrawPadDoc, Point
EXPORT: New Class|DrawPadView
New Method| init, keyPressed, keyReleased,
keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited,
mouseMoved, mousePressed, mouseReleased, paint, setSelectedColor,
update, drawBorder, drawColorBar, drawCurrentColor,
drawOptionBar
Inner classes inherited from class java.applet.Applet |
java.applet.Applet.AccessibleApplet |
Inner classes inherited from class java.awt.Panel |
java.awt.Panel.AccessibleAWTPanel |
Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock |
Field Summary | |
private java.awt.Graphics |
backBufferGraphics
Graphic context associate with the back image buffer |
private java.awt.Image |
backBufferImage
Back Image buffer for drawing |
private boolean |
bChangingColor
A flag to indicate whether we are changing the shape's color |
private boolean |
bDrawingShape
A flag to indicate whether a shape is being draw |
private int |
BORDER_WIDTH
Constant for the border width |
private boolean |
bSelectedPointBox
A flag to indicate whether a point box for a shape has been selected |
private boolean |
bSelectedShape
A flag to indicate whether a shape is selected in the list |
private java.awt.Color[] |
colorList
An Array of color that is available |
private DrawableShape |
currentShape
Current shape object for before adding to DrawPadDoc |
private byte |
DOUBLE_IMAGE_SIZE
Constant for 2 * image size in pixel. |
private int |
drawHeight
Drawing area height. |
private DrawPadDoc |
drawPadDoc
Keep track of all the shape and for the editing methods |
private int |
drawWidth
Drawing area width. |
private Point |
endPoint
keep track of the last point |
private byte |
HALF_IMAGE_SIZE
Constant for half image size in pixel. |
private byte |
IMAGE_DOWN
Constant to indicate the image is in down-state |
private byte |
IMAGE_SIZE
Constant for the image size in pixel. |
private byte |
IMAGE_UP
Constant to indicate the image is in up-state |
private java.lang.String |
imageDirectory
Constant for the path that the image files is in |
private java.lang.String[][] |
imageNames
Name of the option image files (upstate and downstate) |
private byte |
OPT_ELLIPSE
Constant for Ellipseect Option |
private byte |
OPT_FILLED_ELLIPSE
Constant for Filled Ellipse Option |
private byte |
OPT_FILLED_POLYGON
Constant for Filled Polygon Option |
private byte |
OPT_FILLED_RECTANGLE
Constant for Filled Rectangle Option |
private byte |
OPT_LINE
Constant for Line Option |
private byte |
OPT_POLYGON
Constant for Polygon Option |
private byte |
OPT_RECTANGLE
Constant for Rectangle Option |
private byte |
OPT_SELECT
Constant for Select Option |
private java.awt.Image[][] |
optionImages
array to contain the images for options |
private int |
selectedColor
Color that has been selected |
private int |
selectedOption
Option that has been selected |
Fields inherited from class java.applet.Applet |
accessibleContext, serialVersionUID, stub |
Fields inherited from class java.awt.Panel |
base, nameCounter |
Fields inherited from class java.awt.Container |
component, containerListener, containerSerializedDataVersion, dbg, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads |
Fields inherited from class java.awt.Component |
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
DrawPadView()
|
Method Summary | |
private void |
drawBorder(java.awt.Graphics g)
PRE: Valid Graphic object. POST: Draw the border for the drawing area |
private void |
drawColorBar(java.awt.Graphics g)
PRE: Valid Graphic object. POST: Draw the color bar to the given Graphics object |
private void |
drawCurrentColor(java.awt.Graphics g)
PRE: Valid Graphic object. POST: Draw the color that we are using right now |
private void |
drawOptionBar(java.awt.Graphics g)
PRE: Valid Graphic object. POST: Draw the option bar to the given Graphics object |
void |
init()
PRE: None POST: Initialize all the variables and GUI for the applet |
void |
keyPressed(java.awt.event.KeyEvent e)
PRE: A valid KeyEvent Object POST: Perform editing functionality. |
void |
keyReleased(java.awt.event.KeyEvent e)
PRE: A valid KeyEvent Object POST: This method was override from the interface KeyListener. |
void |
keyTyped(java.awt.event.KeyEvent e)
PRE: A valid KeyEvent Object POST: This method was override from the interface KeyListener. |
void |
mouseClicked(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent Object POST: This method was override from the interface MouseListener. |
void |
mouseDragged(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent Object POST: Show rubber band effect and perform editing functionality. |
void |
mouseEntered(java.awt.event.MouseEvent e)
PRE: A valid KeyEvent Object POST: This method was override from the interface MouseMotionListener. |
void |
mouseExited(java.awt.event.MouseEvent e)
PRE: A valid KeyEvent Object POST: This method was override from the interface MouseMotionListener. |
void |
mouseMoved(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent Object POST: For rubber band effect when drawing object. |
void |
mousePressed(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent Object POST: Set all the flags needed. |
void |
mouseReleased(java.awt.event.MouseEvent e)
PRE: A valid MouseEvent Object POST: Set all the flags needed. |
void |
paint(java.awt.Graphics g)
PRE: A valid Graphics Object POST: Will have drawPadDoc draw all its shape and also draw the current shape if we are doing Add shape. |
void |
setSelectedColor(java.awt.Color c)
PRE: A valid Color Object POST: set and update the color bar to the input color |
void |
update(java.awt.Graphics g)
PRE: A valid Graphics Object POST: Will have drawPadDoc draw all its shape and also draw the current shape if we are doing Add shape. |
Methods inherited from class java.applet.Applet |
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop |
Methods inherited from class java.awt.Panel |
|
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, adjustListeningChildren, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, initIDs, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocus, numListening, paintComponents, paintHeavyweightComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, readObject, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, setLayout, transferFocus, validate, validateTree, writeObject |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, 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 |
private Point endPoint
private DrawPadDoc drawPadDoc
private DrawableShape currentShape
private boolean bSelectedShape
private boolean bDrawingShape
private boolean bSelectedPointBox
private boolean bChangingColor
private java.lang.String[][] imageNames
private java.awt.Image[][] optionImages
private final byte IMAGE_UP
private final byte IMAGE_DOWN
private final byte IMAGE_SIZE
private final byte HALF_IMAGE_SIZE
private final byte DOUBLE_IMAGE_SIZE
private final byte OPT_SELECT
private final byte OPT_LINE
private final byte OPT_RECTANGLE
private final byte OPT_FILLED_RECTANGLE
private final byte OPT_ELLIPSE
private final byte OPT_FILLED_ELLIPSE
private final byte OPT_POLYGON
private final byte OPT_FILLED_POLYGON
private final java.lang.String imageDirectory
private final int BORDER_WIDTH
private int selectedOption
private int selectedColor
private java.awt.Image backBufferImage
private java.awt.Graphics backBufferGraphics
private int drawWidth
private int drawHeight
private final java.awt.Color[] colorList
Constructor Detail |
public DrawPadView()
Method Detail |
public void init()
init
in class java.applet.Applet
private void drawCurrentColor(java.awt.Graphics g)
private void drawColorBar(java.awt.Graphics g)
private void drawBorder(java.awt.Graphics g)
private void drawOptionBar(java.awt.Graphics g)
public void paint(java.awt.Graphics g)
paint
in class java.awt.Container
public void update(java.awt.Graphics g)
update
in class java.awt.Container
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved
in interface java.awt.event.MouseMotionListener
public void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged
in interface java.awt.event.MouseMotionListener
public void keyPressed(java.awt.event.KeyEvent e)
keyPressed
in interface java.awt.event.KeyListener
public void setSelectedColor(java.awt.Color c)
public void keyTyped(java.awt.event.KeyEvent e)
keyTyped
in interface java.awt.event.KeyListener
public void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered
in interface java.awt.event.MouseListener
public void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked
in interface java.awt.event.MouseListener
public void mouseExited(java.awt.event.MouseEvent e)
mouseExited
in interface java.awt.event.MouseListener
public void keyReleased(java.awt.event.KeyEvent e)
keyReleased
in interface java.awt.event.KeyListener
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |