Class c2.comp.StackArtist
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class c2.comp.StackArtist

java.lang.Object
   |
   +----c2.framework.Brick
           |
           +----c2.framework.Component
                   |
                   +----c2.framework.ComponentThread
                           |
                           +----c2.comp.StackArtist

public class StackArtist
extends ComponentThread
StackArtist class.

Implements a graphical visualization of a stack. Maintains an abstract model of the entire contents of a stack, as well as buttons to push elements onto the stack, pop them off the stack, and access the top element. A text field allows a user to specify the value to be pushed, and a quit button to exit the application to which the Artist belongs.

The Artist issues stack manipulation requests to a stack ADT above it in a C2 architecture and notifications to components (if any) below it. In turn, it receives notifications from the stack ADT and requests from a graphics server and acts accordingly.


StackArtist's C2 Message Interface

StackArtist's methods should not be invoked directly in a C2 architecture. Instead, the Artist's functionality is accessed via C2 messages (requests and notifications). In response to those messages, the Artist emits requests to a stack ADT above it and sends notifications of its internal state changes down.

   Incoming Notifications
       pushed                (Integer value);
       popped                (Integer value);
       top                   (Integer value);
       state                 (Vector stack);
       empty                 ();
   Outgoing Requests
       push                  (Integer value);
       pop                   ();
       top                   ()
       get_state             ();
   Incoming Requests
       AcceptEvent           (String button, String parent_id);
       AcceptEvent           (String text_field, String value,
                              String parent_id);
   Outgoing Notifications
       ViewportCreated       (Integer x, Integer y,
                              Integer width, Integer height,
                              String title, String id,
                              String foreground, String background);
       ApplicationTerminated ();
       PanelAdded            (Integer x, Integer y,
                              Integer width, Integer height,
                              String foreground, String background,
                              String id, String parent_id);
       PanelCleared          (String id);
       ButtonAdded           (Integer x, Integer y,
                              Integer width, Integer height,
                              String foreground, String background,
                              String label, String parent_id);
       TextFieldAdded        (Integer x, Integer y,
                              Integer width, Integer height,
                              String foreground, String background,
                              String label, String parent_id);
       TextFieldSet          (String label, String value,
                              String parent_id);
       TextFieldCleared      (String label, String parent_id);
       c2Gtext               (Integer x, Integer y,
                              String value, String font,
                              String color, String style,
                              Integer size, String parent_id);

Variable Index

 o panel
Panel in which the contents of the stack are to be displayed.
 o pop_button
Button for popping elements off the stack.
 o push_button
Button for pushing elements onto the stack.
 o quit_button
Button for exiting the application.
 o tf_value
Integer value of the text field.
 o top_button
Button for returning the top stack element.
 o txt_field
Button for entering the value to be pushed onto the stack and viewing the top stack element.
 o vport
Viewport in which the contents of the stack and widgets for its manipulation are to be displayed.

Constructor Index

 o StackArtist()
 o StackArtist(String)

Method Index

 o create(String)
Creates and initializes an instance of the StackArtist.
 o handle(Notification)
Handles notifications from the stack ADT.
 o handle(Request)
Handles requests resulting from a user's manipulation of stack's depiction.
 o start()
At startup, it creates an abstract viewport, panel, quit, push, pop, and top buttons, and a text field, and emits notifications of these changes to any listening components below.

Variables

 o vport
  protected String vport
Viewport in which the contents of the stack and widgets for its manipulation are to be displayed.
 o panel
  protected String panel
Panel in which the contents of the stack are to be displayed.
 o push_button
  protected String push_button
Button for pushing elements onto the stack.
 o pop_button
  protected String pop_button
Button for popping elements off the stack.
 o top_button
  protected String top_button
Button for returning the top stack element.
 o quit_button
  protected String quit_button
Button for exiting the application.
 o txt_field
  protected String txt_field
Button for entering the value to be pushed onto the stack and viewing the top stack element.
 o tf_value
  protected Integer tf_value
Integer value of the text field.

Constructors

 o StackArtist
  public StackArtist()
 o StackArtist
  public StackArtist(String _name)

Methods

 o create
  public void create(String _name)
Creates and initializes an instance of the StackArtist.
Parameters:
_name - Name of the class.
 o start
  public void start()
At startup, it creates an abstract viewport, panel, quit, push, pop, and top buttons, and a text field, and emits notifications of these changes to any listening components below.
Overrides:
start in class ComponentThread
 o handle
  public synchronized void handle(Request r)
Handles requests resulting from a user's manipulation of stack's depiction. Depending on the request, it either sends stack manipulation requests to the ADT, records the value of the text field, or sends a ApplicationTerminated notification to the graphics binding (when the quit button is pressed).
Parameters:
r - Request to be handled.
Overrides:
handle in class Component
 o handle
  public synchronized void handle(Notification n)
Handles notifications from the stack ADT. If the ADT notifies that the stack has been pushed or popped, the entire stack state is requested and a notifications of that state sent down. If the ADT sends a notification with the stack's top value, that value is recorded in the Artist's abstract text field; the Artist sends a notification of that state change down.
Parameters:
n - Notification to be handled.
Overrides:
handle in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index