Class SketchArea

Class SketchArea

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----SketchArea

public class SketchArea
extends Canvas

Variable Index

 o GC
 o moveObj
 o objToMove
 o offscreenG
 o offscreenImg
 o selectedObj

Method Index

 o addStack(Object)
add one object to the stack
 o erase_recvd_obj(int)
searches through the stack to find the correct object to be deleted following the remote DELETE request.
 o insets()
set border width
 o isCircle(DrawObject, int, int)
Checks whether desired object from the stack is a Circle object.
 o isLine(DrawObject, int, int)
Checks whether desired object from the stack is a Line object.
 o isOval(DrawObject, int, int)
Checks whether desired object from the stack is an Oval object.
 o isRect(DrawObject, int, int)
Checks whether desired object from the stack is a Rectangle.
 o isText(DrawObject, int, int)
Checks whether desired object from the stack is a Text object.
 o mouseDown(Event, int, int)
event handler for mouse down
 o mouseDrag(Event, int, int)
event handler for mouse drag
 o mouseUp(Event, int, int)
event handler for house up
 o moveObj(DrawObject, DataInputStream)
 o paint(Graphics)
member function to handle exposure event and create offscreen buffer
 o paste(DrawObject)
pastes objects from the clipboard.
 o proc_obj(byte[], int)
dispatches object to either the method to move or delete the object, based on the requestType.
 o processInData(byte[])
process data passed from network, the data contains essential parameter for various drawing objects
 o proctextfield(int, int, int, String)
Processes text , if any, entered into the textfield, when mouseDown event has occurred.
 o update_moved_obj(int, byte[])
Updates the object whenever this object has been moved remotely.
 o update_obj_params(Object, DataInputStream, Graphics)

Variables

 o offscreenImg
  public Image offscreenImg
 o GC
  public Graphics GC
 o offscreenG
  public Graphics offscreenG
 o moveObj
  public Object moveObj
 o objToMove
  public DrawObject objToMove
 o selectedObj
  public DrawObject selectedObj

Methods

 o insets
  public Insets insets()
set border width
Returns:
Insets
 o paint
  public void paint(Graphics g)
member function to handle exposure event and create offscreen buffer
Parameters:
g - graphics context
Returns:
void
Overrides:
paint in class Canvas
 o paste
  public void paste(DrawObject objToPaste)
pastes objects from the clipboard.
Parameters:
objToPaste - object from the clipboard
 o mouseDown
  public boolean mouseDown(Event e,
                           int x,
                           int y)
event handler for mouse down
Parameters:
e - event instance
x - x value
y - y value
Returns:
true
Overrides:
mouseDown in class Component
 o proctextfield
  public void proctextfield(int x,
                            int y,
                            int color,
                            String textStr)
Processes text , if any, entered into the textfield, when mouseDown event has occurred.
Parameters:
x - x coordinate of mouseDown event.
y - y coordinate of mouseDown event.
color - color of text entered.
 o mouseUp
  public boolean mouseUp(Event e,
                         int x,
                         int y)
event handler for house up
Parameters:
e - event instance
x - x value
y - y value
Returns:
true
Overrides:
mouseUp in class Component
 o isLine
  public boolean isLine(DrawObject top,
                        int x,
                        int y)
Checks whether desired object from the stack is a Line object.
Parameters:
top - topmost object on the graphics object stack.
x - x coordinate of mouse event.
y - y coordinate of mouse event.
Returns:
true when selected object is a line.
 o isRect
  public boolean isRect(DrawObject top,
                        int x,
                        int y)
Checks whether desired object from the stack is a Rectangle.
Parameters:
top - topmost object on the graphics object stack.
x - x coordinate of mouse event.
y - y coordinate of mouse event.
Returns:
true when selected object is a rectangle.
 o isCircle
  public boolean isCircle(DrawObject top,
                          int x,
                          int y)
Checks whether desired object from the stack is a Circle object.
Parameters:
top - topmost object on the graphics object stack.
x - x coordinate of mouse event.
y - y coordinate of mouse event.
Returns:
true when selected object is a circle.
 o isOval
  public boolean isOval(DrawObject top,
                        int x,
                        int y)
Checks whether desired object from the stack is an Oval object.
Parameters:
top - topmost object on the graphics object stack.
x - x coordinate of mouse event.
y - y coordinate of mouse event.
Returns:
true when selected object is a oval.
 o isText
  public boolean isText(DrawObject top,
                        int x,
                        int y)
Checks whether desired object from the stack is a Text object.
Parameters:
top - topmost object on the graphics object stack.
x - x coordinate of mouse event.
y - y coordinate of mouse event.
Returns:
true when selected object is a text string.
 o mouseDrag
  public boolean mouseDrag(Event e,
                           int x,
                           int y)
event handler for mouse drag
Parameters:
e - event type
x - x value
y - y value
Returns:
true
Overrides:
mouseDrag in class Component
 o processInData
  public void processInData(byte buf[])
process data passed from network, the data contains essential parameter for various drawing objects
Parameters:
buf - buffer in bytes to hold the parameters
Returns:
void
 o proc_obj
  public void proc_obj(byte obj_buf[],
                       int requestType)
dispatches object to either the method to move or delete the object, based on the requestType. The requestType is either a MOVE or DELETE request.
Parameters:
obj_buf - buffer holding the object ID and object parameters
requestType - a MOVE or DELETE request
 o update_moved_obj
  public void update_moved_obj(int obj_id,
                               byte buf[])
Updates the object whenever this object has been moved remotely. Function will search through the stack again for every movement of the remote object if and only if this object wasn't previously moved object. Otherwise, it will not need to search the whole stack, thus improving response time.
Parameters:
obj_id - object ID of the object to be updated.
buf - buffer holding the object parameters.
 o moveObj
  public void moveObj(DrawObject top,
                      DataInputStream dataStream)
 o update_obj_params
  public void update_obj_params(Object ObjectType,
                                DataInputStream dataStream,
                                Graphics offscreenG)
 o erase_recvd_obj
  public void erase_recvd_obj(int obj_id)
searches through the stack to find the correct object to be deleted following the remote DELETE request. Called by proc_del_obj function that passes to it the object ID to identify the object to be deleted.
Parameters:
obj_id - object ID to identify the object from the stack to be deleted.
Returns:
void
 o addStack
  public void addStack(Object theObj)
add one object to the stack
Parameters:
theObj - object reference
Returns:
void