Class wb.WBCanvas
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class wb.WBCanvas

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----wb.WBCanvas

public class WBCanvas
extends Canvas
implements GTypes
WBCanvas is derived from Canvas and is corresponds to View in the MVC paradigm. Objects are not only rendered here but are also sent to all the clients. It has the Repositary of objects that are created and that came over the network

Constructor Index

 o WBCanvas(Frame)
Creates a new Canvas.
 o WBCanvas(Frame, WriteClient)
Creates a new Canvas that is ready for conference.

Method Index

 o Add(GraphUnit, String)
Add adds a graphunit to the canvas.
 o CancelDelete()
 o Clear()
Clear As the name implies clears the screen and the storage losing all the previously created object info.
 o LoadCanvas(DataInputStream)
Method that reads GraphUnits from a file.
 o NewColor(Color)
NewColor changes the state of current color
 o NewFont(int)
NewFontSize changes the size of the Text size
 o Refresh()
Refresh As the name implies it refreshes the screen.
 o SaveCanvas(DataOutputStream)
Method that saves the GraphUnits to a file.
 o action(Event, Object)
Handler for action events.
 o getDrawType()
returns the current drawing mode of the canvas
 o inside(int, int)
Needed to fix a bug in Java
 o keyDown(Event, int)
Handler for keyDown events.
 o keyUp(Event, int)
Handler for keyUp events.
 o mouseDown(Event, int, int)
Handler for mouseDown events.
 o mouseDrag(Event, int, int)
Handler for mouseDrag events.
 o mouseEnter(Event, int, int)
Handler for mouseEnter events.
 o mouseExit(Event, int, int)
Handler for mouseExit events.
 o mouseMove(Event, int, int)
Handler for mouseMove events.
 o mouseUp(Event, int, int)
Handler for mouseUp events.
 o paint(Graphics)
Handler for paint requests.
 o setDrawType(int)
setDrawType set the current mode of the canvas
 o setWriter(WriteClient)
Set the Writer for this Canvas
 o update(Graphics)
Handler for update requests.

Constructors

 o WBCanvas
  public WBCanvas(Frame arg)
Creates a new Canvas.
Parameters:
arg - the frame that holds this canvas
 o WBCanvas
  public WBCanvas(Frame arg,
                  WriteClient passed)
Creates a new Canvas that is ready for conference.
Parameters:
arg - the frame that holds this canvas
passed - the writer to whom the locally created objects/messages are sent for transmission.

Methods

 o setWriter
  public void setWriter(WriteClient arg)
Set the Writer for this Canvas
Parameters:
arg - WriteClient
 o NewColor
  public synchronized void NewColor(Color arg)
NewColor changes the state of current color
Parameters:
arg - the Color of the objects that would be created in future.
 o NewFont
  public synchronized void NewFont(int arg)
NewFontSize changes the size of the Text size
Parameters:
arg - the size of the objects that would be created in future.
 o Refresh
  public synchronized void Refresh()
Refresh As the name implies it refreshes the screen.
 o Clear
  public synchronized void Clear()
Clear As the name implies clears the screen and the storage losing all the previously created object info.
 o Add
  public synchronized void Add(GraphUnit passed,
                               String userhost)
Add adds a graphunit to the canvas. this specifically handles the requests from other participants. It identifies if the added object is a message and deciphers it accordingly
Parameters:
passed - the GraphUnit/Message received over the network
userhost - the source of GraphUnit/Message
 o getDrawType
  public int getDrawType()
returns the current drawing mode of the canvas
Returns:
int the current mode
See Also:
setDrawType, GTypes
 o setDrawType
  public synchronized void setDrawType(int t)
setDrawType set the current mode of the canvas
Parameters:
t - the new mode
See Also:
getDrawType
 o mouseEnter
  public boolean mouseEnter(Event e,
                            int x,
                            int y)
Handler for mouseEnter events. Takes care of the cursor shape and sets the inside flag true
Parameters:
e - Event to be handled
x - the x co-ordinate of the event to be handled
y - the y co-ordinate of the event to be handled
Returns:
boolean indicating if the event is handled.
Overrides:
mouseEnter in class Component
 o mouseExit
  public boolean mouseExit(Event e,
                           int x,
                           int y)
Handler for mouseExit events. sets the inside flag false
Parameters:
e - Event to be handled
x - the x co-ordinate of the event to be handled
y - the y co-ordinate of the event to be handled
Returns:
boolean indicating if the event is handled.
Overrides:
mouseExit in class Component
 o mouseDown
  public boolean mouseDown(Event e,
                           int x,
                           int y)
Handler for mouseDown events. Used to initiate the creation of graphunits.
Parameters:
e - Event to be handled
x - the x co-ordinate of the event to be handled
y - the y co-ordinate of the event to be handled
Returns:
boolean indicating if the event is handled.
Overrides:
mouseDown in class Component
 o mouseDrag
  public boolean mouseDrag(Event e,
                           int x,
                           int y)
Handler for mouseDrag events. This whole stuff is required to give the rubber banding effect
Parameters:
e - Event to be handled
x - the x co-ordinate of the event to be handled
y - the y co-ordinate of the event to be handled
Returns:
boolean indicating if the event is handled.
Overrides:
mouseDrag in class Component
 o mouseMove
  public boolean mouseMove(Event e,
                           int x,
                           int y)
Handler for mouseMove events. This whole stuff is required to give the rubber banding effect esp. for polylines and spokes
Parameters:
e - Event to be handled
x - the x co-ordinate of the event to be handled
y - the y co-ordinate of the event to be handled
Returns:
boolean indicating if the event is handled.
Overrides:
mouseMove in class Component
 o mouseUp
  public boolean mouseUp(Event e,
                         int x,
                         int y)
Handler for mouseUp events. Marks the end of object creation in most cases.
Parameters:
e - Event to be handled
x - the x co-ordinate of the event to be handled
y - the y co-ordinate of the event to be handled
Returns:
boolean indicating if the event is handled.
Overrides:
mouseUp in class Component
 o keyUp
  public boolean keyUp(Event evt,
                       int key)
Handler for keyUp events.
Parameters:
e - Event to be handled
key - the key released
Returns:
boolean indicating if the event is handled.
Overrides:
keyUp in class Component
 o action
  public boolean action(Event evt,
                        Object what)
Handler for action events.
Parameters:
evt - Event to be handled
what - the object
Returns:
boolean indicating if the event is handled.
Overrides:
action in class Component
 o keyDown
  public boolean keyDown(Event evt,
                         int key)
Handler for keyDown events. Used in Text
Parameters:
evt - Event to be handled
key - the key pressed
Returns:
boolean indicating if the event is handled.
Overrides:
keyDown in class Component
 o update
  public synchronized void update(Graphics g)
Handler for update requests. Called either locally or by the screen update thread of the runtime.
Parameters:
g - Graphics onto which the update needs to be performed
Overrides:
update in class Component
 o paint
  public synchronized void paint(Graphics g)
Handler for paint requests. Called either locally or by the screen refresh thread of the runtime.
Parameters:
g - Graphics onto which the update needs to be performed
Overrides:
paint in class Canvas
 o inside
  public boolean inside(int x,
                        int y)
Needed to fix a bug in Java
Parameters:
x - x-coordinate of the point
y - y-coordinate of the point
Returns:
true iff (x,y) is inside this
Overrides:
inside in class Component
 o SaveCanvas
  public synchronized void SaveCanvas(DataOutputStream dos) throws IOException
Method that saves the GraphUnits to a file.
Parameters:
dos - DataOutputStream to a file stream
Throws: IOException
if there is any I/O Error
 o LoadCanvas
  public synchronized void LoadCanvas(DataInputStream din) throws IOException
Method that reads GraphUnits from a file.
Parameters:
din - DataInputStream to a file stream
Throws: IOException
if there is any I/O Error
 o CancelDelete
  public void CancelDelete()

All Packages  Class Hierarchy  This Package  Previous  Next  Index