Programming Guide Development for Java Bde (bde2java)
Programming Reference Guide Part II

State Machine Models for bde2java Implementation

91.523 - bde2java project - fall '96 - UMass Lowell


Jie Li, Guillermo Zeballos
bde2java team: Wing-Kin Au, Jie Li, Aditya Vedula, Li Fu Wang, Zhigang Wang, Guillermo Zeballos

Edition: 1.0
(path:[an error occurred while processing this directive] file:javabdeSM.shtml)


1. Introduction

The following is a summary description using state models of some of the operations in bde2java or javaBde. The diagrams are modeled after standard FA notation. The purpose of this type of documentation is to support the documentation supplied by the javadoc facility. While the javadoc facility provides a means of defining code elements, it is not necessaraly representative of its operation. It is hoped that the creation and maintenance of this document will permit greater understanding for future developers of javaBde.

1.1 Document Layout

The document is organized around a graphical representation of the some of the operations within javaBde. Each figure is followed by explanatory text. Paths to original idraw images are to be stated.

Following this section will be a textual analysis of the states. This differs in being more an identification of the branching conditions within the class methods defined in javaBde.

This text will only refer to "some" operations because as of the time of this writing it cannot be claimed that a complete picture of the states and transition rules of for javaBDE can be drawn. It is also to identify a single alphabet on which to define transition rules as pre-conditions are not necessaraly identified and assigned to any one variable. It is often the case that method calls and actions are set into motion by identification of several conditions (such as if (cond1 && cond2 && cond3)). Many of the rules for transitions are located in specific methods and not readaly available as case statements.

1.2 Machine Descriptions:

Machines were described using finite state machine notation. Strict interpretation of these models is not recommended as they describe operations over class definitions, almost as if the class definitions themselves are representative of a higher level state definition. This is not the case with the current implementation. While a common entry is defined, it is only meant to represent that the transitions described will only be pertinent to the states of one particular flag variable (the alphabet). Interpretation of the notation at this point should be flexible as they are more representative of the structures of classes.

These descriptions could be expanded upon if a clearer description of the preconditions for entry to a particular method of a class be better defined. Figure 2 comes closest to illustrating the event cycle that defines the process. It is hoped that this will be done in future work and this document will accordingly be ammended.

2. Operation Descriptions:

Fig.1 - Fundamental Modes for bde2java

/usr/proj3/case/96f523/bde2java/gzeballo/idraw/state1.idraw
This figure illustrates the current basic modes of operation for bde2java. The modes of operations are identified within the class bde2JavaApplet , and more specifically the methods init() and init1(). The flag variables used are nAppletMode and JavaMode

Breakdown of states:

  1. Stand alone application: Operating as Graph Editor
  2. Browser Applet: Operates as graph viewer

Fig.2 - bde2java Event Handling Outline

/usr/proj3/case/96f523/bde2java/gzeballo/idraw/bdeOutline.idraw
This figure is meant to illustrate the event handling loop as it appears to be implemented within bde2java. It is not specific to any one class definition. Its basic operation is based on detecting any mouse event. The event handler verifies if Event=ACTION() or evt.id=MouseUp || MouseDown || MouseDrag. If it is Event=ACTION() then it is checked as an action over the UpperCaseBox (UCB) or the LowerCaseBox(LCB). The respective box is highlighted and selection flagged. The process then loops back to await another event.

If it is an event setting evt.id to the above states, then Navigator checks to see if it is a node hotspot event. If so it will print out a new graph and then reinitialize that graph before returning to an event wait state.

Non hotspot events are then passed to an event handler that determines whether UpperCheckBoxSelect(US) is on (=1) and then check if LowerCheckBoxSelect(LS) is on (=1). If both are true event is handled otherwise it loops back to wait event. After event is handled process loops back to wait event.


Fig.3 - Graph Operations

/usr/proj3/case/96f523/bde2java/gzeballo/idraw/bdeGraph.idraw
This figure illustrates current understanding of the operation for methods within the bdeNode.java class over the possible values of the variable evt.id. It also contains the handling of the switch over the value of UpperCheckBoxIndex.

The most important operation within this class appears to be that within StateSelector as it appears to be the closest parallel to the original bde's case switch on state. It switches on the operation of the value of UpperCheckBoxIndex which can take on the following values:

      NODE:       call nodeFunction()
      LINK:       call linkFunction()
      TEXT:       call textFunction()
      BENDPOINT:  call bendpointFunction()
      GRAPH:      call graphFunction()
      CAPTION:    call captionFunction()
      DEFAULT:    print error message.

Fig.4 - Node Operations

/usr/proj3/case/96f523/bde2java/gzeballo/idraw/bdeNode.idraw
This figure illustrates current understanding of the operation for methods within the bdeNode.java class over the possible values of the variable evt.id.

Two points of note: 1) that within Delete, a branching condition exists on deletion based on whether or not the mouse is currently over the selected node when the Mouse Up event occurs. 2) that within Restyle, the process of restyling is controlled by whether the current node is the first or second node selected.


Fig.5 - Link Operations

/usr/proj3/case/96f523/bde2java/gzeballo/idraw/bdeLink.idraw
This figure illustrates current understanding for the operation for methods within the bdeLink.java class over the possible values of the variable evt.id. The point to note here is that in the method Create, selection of the second node after the Mouse Drag event only occurs mouse is actually over a different node.

Fig.6 - Bend Point Operations

/usr/proj3/case/96f523/bde2java/gzeballo/idraw/bdeBendPoint.idraw
This figure illustrates current understanding for the operation for methods within the bdeBendPoint.java class over the possible values of the variable evt.id.

Create requires existing link. Restyle allows for 3 different kinds of styles.


Fig.7 - Graph Caption Operations

/usr/proj3/case/96f523/bde2java/gzeballo/idraw/bdeGraphCaption.idraw
This figure illustrates current understanding for the operation for methods within the bdeGraphCaption.java class over the possible values of the variable evt.id.


Fig.8 - Text Operations

/usr/proj3/case/96f523/bde2java/gzeballo/idraw/bdeText.idraw
This figure illustrates current understanding for the operation for methods within the bdeText.java class over the possible values of the variable evt.id.

Text operations within the bdeText.java class are somewhat involved in that they operate over GraphCaptionText, CaptionText, and Node. Also Create involves the operation of GraphBox, but whether it returns from Graph Box was not clear.

Additional remards: Move() contains branching to select if movement involves node (set node selected), or GraphCaptionText (set graphCaptionText selected), or neither(return) Delete3() operates strictly over CaptionText. Delete() over node or GraphCaptionText by branching whether one or the other is selected.


Fig. 9 - Some Java Operations

/usr/proj3/case/96f523/bde2java/gzeballo/idraw/javaOps.idraw
This figure is included to illustrate some java operations that also operate over the two often used variables evt.id and evt.target. They also contain different values. The developer should take not of the range of values for these two.

3. Additional Descriptions

The following text is based on an analysis of the branching operations within methods. It is from this same analysis that the above figures were derived. What follows is the textual description of operations not illustrated as pseudocode. This is because it was not clear how their operation fitted in with the operation of other methods and the variety of different methods make tracking transition rules difficult. An example of the last case is bde2JavaApplet where many operations happen on a variety of flags making it hard to define a common language on which to define transitions (on evt.id, or nAppletMode, or evt.target?)

Hopefully the tracking of mouse events illustrated in the "Event Handling Outline" figure should act as guidance with respect to transition on events.

(excerpted from $case/96f523/bde2java/jli/state.3)

1. DisplayFrame.java:
   Method: handleEvent()
   evt.target = scrollbarV --> get offset Y --> repaint;
   evt.target = scrollbarH --> get offset X --> repaint.

2. bdeAppletFrame.java:
   Method: handleEvent()
   evt.target = MenuItem {Exit  --> exit system;
                          New   --> not implemented;
                          Print --> print PS file;
                          Open  --> read in a bde data file and show 
                                    on the Applet Frame;
                          Save  --> save file to current filename;
                          Save As   --> save file to the filename specified;
                          About BDE --> print bde message;
                          }

3. bde2JavaApplet.java: 
   Method: handleEvent()
   evt.target = Graphlist --> get GraphName --> repaint the Graph.
   // this is a (choice) java event. The choice items are graph names.     
   // Selecting one choice item will make corresponding graph painted.  -jie

   evt.id = WINDOW_DESTROY{if inApplet --> dispose the window;
                           else        --> exit system;
                          }
 
4.  bdeToolBox.java
    Method: handleEvent()
    evt.target = NODE      --> show node related attributes
    evt.target = LINK      --> show link related attributes
    evt.target = TEXT      --> show text related attributes
    evt.target = BENDPOINT --> show bendpoint related attributes
    evt.target = GRAPH     --> show graph related attributes
    evt.target = CAPTION   --> show caption related attributes
 
5.  bdeGraphSelectionBox.java:
    evt.target = OKbutton --> set flag from ACTION_PENDING to ACTION_OK.    
    evt.id = Event.WINDOW_DESTROY --> hide window and set flag to
                                      ACTION_CANCEL
 


6.  bdeNodeAttributesBox.java
    Method: action()    // the action clears OK button
    evt.target = OKbutton --> hide the OK_button
                              set status = ACTION_OK

    Method: handleEvent()
    evt.id = WINDOW_DESTORY --> hide window

7.  menutest.java
    Method: mouseEnter() --> set bSelected = true in terms of mouse (x,y)
                             repaint

    Method: mouseExit() --> set bSelected = false in terms of mouse (x,y)
                            repaint

    Method: mouseDown() --> set nSelectedNode = -1
                            reaint
        // i.e. set nSelectedNode = NOT_FOUND (file: bdeRefrence.java)

    Method: mouseUp()   --> set bMouseDown = false
                            repaint

    Method: mousedrag() --> set bdeMouseItemText = "Test"
                            repaint
                            set bMouseDown = true
For a full listing consult the files $case/96f523/bde2java/jli/state.1, and $case/96f523/bde2java/jli/state.3.

4. Final Comments on Section

The model needs an improved definition of the pre-conditions regarding entry into the functional operational modes of javaBde. Currently the handling of some events passed to evt.id and evt.target have been identified, but there are other variables that need to be checked such as selectObject.selected of which there are various.

A seperate analysis of operational states only from the interface (as opposed to the way the method calls are implemented) may help in more clearly identifying the flags used to verify preconditions before executing an operation.

Finally, it is hoped that test suites can be developed from the information gathered from these references.

5. A Note on this Document's Figures

The figures in this document were created using the idraw (interviews graph editor) application to generate the original diagrams as *.idraw files. The images were "grabbed" from their application window using the xv(v.3.01) application, cropped to fit the page, and then saved under the local gif's directory as gif files. Updating of this document will require a similar process.


91.523 - Software Engineering Project - · - 96f523 - bde2java

[an error occurred while processing this directive]/javabdeSM.shtml
Last updated: Friday, 20-Dec-1996 21:26:58 EST