Software Engineering I BDE2Java 96s523 Project Final Report Document May 9,1996 Project Team: Manuel G. Fernandes III Daniel A. Rosato Priya Sathyanarayanan Hubert Sevanathan Instructor: Dr. Robert Lechner Path: /usr/proj3/case/96s523/bde2jav1/base/public_html/finalrpt.doc Table of Contents 1. Purpose 1. 2. Introduction 1. 3. Design 1. 4. Features of BDE2JAVA 3. 5. Development 3. 6. Detailed Design 4. 7. Applet Development 8. 8. Testing 12. 9. Summary 16. Appendix A - bde2Java Schedule 17. Appendix B - bde2Java Documentation 21. Appendix C - bde2Java User Guide 22. Appendix D - bde2Java Source Code 25. 1. Purpose The purpose of this document is to convey the effort of the BDE2Java project team for the 91.523 spring 96 class (graduate Software Engineering) at the University of Massachusetts Lowell. The instructor of the class is Dr. Robert Lechner. The BDE2Java project mission was to create a Java applet that will have the same behavior of a 'display only' BDE application. The Java applet will be loaded as a standard applet embedded in an HTML document. The applet will load a BDE data (.dat) file across the internet or local area network and display the contents the same as BDE does. 2. Introduction Java was selected as the development environment for this project because of its platform independence and the ability to provide access to BDE across the internet. Java was developed by Sun Microsystems in order to provide these features in a powerful object oriented language that is an intersection of C++. The BDE2Java applet will give any user on the internet with a Java enabled browser the ability to view BDE files. This will allow faculty and students the ability to display presentations across the internet utilizing graphs created in BDE. Providing the University and the BDE project internet exposure. Currently the Java Powered internet browsers available are HotJava by Sun Microsystems and Netscape Navigator 2.0 by Netscape Corp. which is available for IBM PC, Macintosh and UNIX platforms. 3. Design The design of the BDE2Java applet is based on a high level class design architecture. The BDE data file is read and objects are created as the file is parsed. For example a node that is read from a line of the data file will create a node object from the HN class. This node object will draw itself on it's parent graph automatically. By designing the BDE Java application form scratch, the object oriented nature of Java was taken advantage of, in order to help produce a well structured and efficient application. This design requires less code than the original BDE application. This was achieved by designing classes that are laid out to utilize the inheritance that comes naturally from an object oriented design. All the BDE objects that are currently used in the BDE application are also used in the project. Also the current object hierarchy of BDE was utilized with some enhancements to make the architecture more efficient. The following is a layout of the classes that are used in the application: Classes: GF - Graph file class HG - Graph class CG - Graphic Caption class HN - Node class HL - Link class GX - Caption Text Class HA - Attribute class HI - Link Caption Class XB - Text object class Figure 1. Object Class Instance Hierarchy 4. Features of BDE2Java The following features are incorporated into the BDE2Java: Look and feel of the current BDE application. With features not yet implemented disabled. Ability to read in a .dat file created in the existing BDE application and display it in the applet embedded in an HTML document, also features of the .dat file will be displayed, including nodes, links, bendpoints, and text ... Ability to switch between graphs contained in the .dat file, both by clicking on the connecting node and with a graph dropdown box that displays all the graphs available for browsing. The first graph in the data file is selected as the default graph. Ability to dump the data base out in order to facilitate testing by comparing the output file to the input file. Class structure of the applet will be created as discussed in meeting and displayed in figure 1. Ability to move nodes on the graph and output the dat file to the standard output. Hot spots on the nodes that drop down and display a list of fields contained in that node. 5. Development The following is the development environment for the BDE2Java project: Environment: Java JDK 1.0, Sun Microsystems Compiler: Windows 32 bit JAVAC compiler Platforms: Windows 95, Windows NT 3.51, Linux 1.2.13 Editor: Notepad, any text editor Version Control: RCS Documentation: Word 6.0, HTML 2.0 6. Detailed Design 6.1 Graphical User Interface One of the objectives of the bde2Jav1 project was to incorporate the look and feel of the current bde applications Graphical User Interface into an applet that may be run on any computer platform with a Java enabled browser over the Internet. The GUI was modeled after the current bde application as of the spring semester of 1996. Because of Java's platform independence the individual components of the GUI will take on the look of their native platform. Figure 2 shows the bde2jav1 applet in the Microsoft Windows environment. As can be seen the radio buttons, scroll bars and drop down lists all have the look of any other Windows application. Figure 2. bde2Jav1 Applet GUI The development of the GUI consisted of breaking it down into several smaller sub components which were then added as child objects to the applet frame object. This approach was taken to provide easier development and maintenance of the code, as well as to have the Java code consistent with the existing bde code. A listing of these sub components may be found in Table 1. A further break down of the individual components which make up these classes may be found in Tables 2 - 4. Table 1 - GUI Java Applet bde Name Java Class Name 1 Tool Box Left Menu bdeToolBox.java 2 Menu Menu bdeMenuBox.java 3 Display Frame Canvas DisplayFrame.java Table 2 - BdeToolBox Java Applet Java Class Name 1 Tool Box bdeToolBox.java CheckBox1 java.awt.CheckboxGroup Node java.awt.Chechbox Link java.awt.Chechbox Bendpoint java.awt.Chechbox Text java.awt.Chechbox Graph java.awt.Chechbox Caption java.awt.Chechbox CheckBox1 java.awt.CheckboxGroup Create java.awt.Chechbox Move java.awt.Chechbox Delete java.awt.Chechbox Select java.awt.Chechbox Resize java.awt.Chechbox Restyle java.awt.Chechbox 2 Graph Selection java.awt.Choice 3 Node Type java.awt.Choice Table 3 - Menu Java Applet Java Class Name 2 Menu bdeMenuBox.java File bdeMenuItem Edit bdeMenuItem Options bdeMenuItem Help bdeMenuItem Table 4 - Display Frame Java Applet Java Class Name 3 Display Frame DisplayFrame.java Canvas bdeDisplay Graph Title java.awt.Panel File Name java.awt.Panel Scroll Bar - Vertical java.awt.Scrollbar Scroll Bar - Horizontal java.awt.Scrollbar 6.2 System Architecture The bde2jav1 applet is based on the object oriented design architecture as show in figure 1. The following is a summary of the classes contained in the bde2jav1 applet and their function: bde2JavaApplet The bde2JavaApplet class is a sub class of the Java Applet class. bdeToolBox The bdeToolBox class is a sub class of the Java Panel class and is presented in more detain in the GUI section of this document. bdeMenuBox The bdeMenuBox class is a sub class of the Java Panel class and is presented in more detain in the GUI section of this document. DisplayFrame The DisplayFrame class is a sub class of the Java class Panel. The DisplayFrame class is the parent of the bdeGraph class and the bdeDisplay. Its purpose is to manage the graph objects and to display them to the user. The Java Class CardLayout Manager is used to allow the user the switch between multiple graph object contained in a single .dat file. bdeGraph (HG) The bdeGraph class is a sub class of the Java class Panel. This class is used to display the individual components of the bde graph. It is responsible for all mouse movements within the display canvas. bdeGraphCaption (CG) The bdeGraphCaption class is used to contain the position and a reference to the XB child class which displays its text. bdeCaptionText (GX) This class was eliminated and replaced by the XB class. bdeNode (HN) The bdeNode class is a child object of the bdeGraph class. This class draws the nodes when called upon. bdeNodeAttribute (HA) The bdeNodeAttribute is a child of the bdeNode class. Its function is to contain the name and position of a node attribute as well as a reference to the XB child class which displays the text. bdeLink (HL) The bdeLink class is a child of the bdeGraph class. It contains the relationship between two nodes. bdeBendPoint (HP) The bdeBendPoint class is a child of the bdeLink class. It contains a reference to its HL parent as well as a relative location of the bendpoint. Also contained in this class is an arrow attribute which determine whether an arrow is displayed and in what direction. bdeLinkAttribute (HI) The bdeLinkAttribute is a child of the bdeLink class. Its function is to contain the name and position of a link attribute as well as a reference to the XB child class which displays the text. bdeTextBlock (XB) The bdeTextBlock class is a general text object that contains the information needed to display the text on the screen. The XB class may be a child of the HI, HA and CG classes. Applet Initialization After the browser loads the applet, the init member function of the bde2JavaApplet class is called. The init function first creates instances of the GUI children classes. Next, the .dat file is read, parsed and loaded into the internal data structure line by line. Finally, objects from the .dat file are created dynamically and associated to their respective parent. 7. Applet Development The bde2JavaApplet development consists of numerous classes. Some of these classes were created by sub-classing the existing Java classes while others had to be created from scratch. The following is a list of these classes and there associated methods: bde2JavaApplet.class This class implements the bde2JavaApplet. The methods here are called directly by the web browser when appropriate. When the applet is loaded the web browser calls the init() method first. This method performs the layout of applet GUI, the applet configuration as specified in the HTML document, and creates the object contained in the .dat file. public class bde2JavaApplet extends Applet implements Runnable { public void DropDownMenuDisplay(boolean Mode, int Index, int PosX) public void init() public void start() public void run() public synchronized void paint(Graphics g) public boolean action(Event evt, Object arg) public boolean handleEvent(Event evt) public void addGraph(String strRow) public int getGraphIndex(String strGraphName) public int getNodeParentIndex(String strNodeName) public int getCaptionParentIndex(String strName) public int getLinkParentIndex(String strLinkName) } bdeBendPoint.class This class is the container for the bend point objects. This represents the bde HP objects. class bendPoint { public void Create() public void Move() public void Delete() public void Select() public void Resize() public void Restyle() public String getRow() public void draw(Graphics g) } bdeCaptionText.class This class is the container for the caption text objects. This represents the bde CX objects. class bdeCaptionText { public void Create() public void Move() public void Delete() public void Select() public void Resize() public void Restyle() public String getRow() public void draw(Graphics g) } bdeGraph.class This class is the container for the graph objects. This represents the bde HG objects. class bdeGraph extends Panel { bdeGraph(bde2JavaApplet bdeParent, int x, int y) public void Create() public void Move() public void Delete() public void Select() public void Resize() public void Restyle() int getNodeIndex(String Name) int getLinkIndex(String Name) int getNodeAttribute(String Name) int getGraphCaptionIndex(String Name) public void addGraphCaption(String strRow) public void addGraphCaptionText(String strRow) public void addBendPoint(String strRow) int addNode(String strRow) void addLink(String strRow) void addAttribute(String strRow, int ParentIndex) public synchronized void update(Graphics g) public synchronized boolean mouseDown(Event evt, int x, int y) public void captionFunction(int x, int y) public void nodeFunction(int x, int y) public synchronized boolean mouseDrag(Event evt, int x, int y) public synchronized boolean mouseUp(Event evt, int x, int y) public String getRow() } bdeGraphCaption.class This class is the container for the graph caption objects. This represents the bde GC objects. class bdeGraphCaption extends Vector { public void Create() public void Move() public void Delete() public void Select() public void Resize() public void Restyle() public String getRow() public void draw(Graphics g) } bdeLink.class This class is the container for the link objects. This represents the bde HL objects. class bdeLink extends Vector { public void Create() public void Move() public void Delete() public void Select() public void Resize() public void Restyle() public String getRow() public void draw(Graphics g) void WCtoLC(int nx1, int ny1, int nx2, int ny2, float x, float y, float u , float v) void LCtoWC(float u, float v, float x, float y) public void drawArrow(int x1, int y1, int x2, int y2, int z, Graphics g) Point getIntersection(float NodeCenterX, float NodeCenterY, float NodeHalfWidth, float NodeHalfHeight, float PointCenterX, float PointCenterY, String shapetype) } bdeMenuBox.class Currently this class is not implemented but eventually will be a container for the menu methods. bdeNode.class This class is the container for the Node objects. This represents the bde HN objects. class bdeNode extends Vector { public void Create() public void Move() public void Delete() public void Select() public void Resize() public void Restyle() public String getRow() public void draw(Graphics g) public void drawAttributes(Graphics g) } bdeNodeAttribute.class This class is the container for the node attributes objects. This represents the bde HA objects. class bdeNodeAttribute { public void Create() public void Move() public void Delete() public void Select() public void Resize() public void Restyle() public String getRow() public void draw(Graphics g) } bdeReference.class This class is the container for the default and resource information of the bde2Java applet. class bdeReference { public void init() public static void InitList(Choice ShapeList) public static void VersionMessage() } bdeToolBox.class This class is the container for the tool box menu functions. public class bdeToolBox extends Panel { public boolean handleEvent(Event evt) bdeToolBox(bde2JavaApplet Parent) public void paint(Graphics g) } DisplayFrame.class This class implements the management of the display of the bde graphs. class DisplayFrame extends Panel { DisplayFrame(bde2JavaApplet Parent, int x, int y, int width, int height) public synchronized void paint(Graphics g) public boolean handleEvent(Event evt) } 8. Testing The basic idea is to include numerous test files that will conform with the features of the BDE2Java project developed this semester: The look and feel of the BDE application should be similar to the already existing one. Create .dat files using the existing BDE application to see if the .dat files can be opened and the features of the .dat file displayed in Java and if they are an exact replica of the file created by the BDE application. Create a .dat file with a single graph to see if it is opened and displayed immediately on entry. Create a .dat file with multiple graphs to see if a list of all graphs is displayed on entry. Create a .dat file with multiple graphs, and check the ability to switch between graphs contained in the .dat file. Switch by clicking on the connecting node Switch by using the graph menu that displays all the graphs available for browsing as described in the features of the BDE2Java project. Create graphs with various features as explained below to check the integrity of the application: A graph containing single node of each type i.e., circle, ellipse, rectangle etc. A graph containing multiple nodes of each type as described above. A graph containing embedded nodes of each type. A graph containing a single straight link between two nodes. A graph containing multiple links between two nodes or between many nodes. A graph containing bendpoints. A graph containing text within the nodes. And finally a graph containing multiple nodes with text and link between the nodes and also incorporating bendpoints. Check the integrity of the database if it conforms to the one created by existing BDE application. i.e., check if the output file is similar to the input file. Check if on-line presentations can be displayed using the BDE2Java application. If time permits and the rest of the features mentioned are also implemented then adequate testing for these features too: Check the help facility available for all topics. Check the context sensitive help facility. Create a graph with nodes and check the ability to move the nodes in the graph retaining the integrity of the graph. Move a few nodes and check the ability to save the modified file on the local disk. If hot spots are created on the nodes, then check if these drop down to display a list of fields contained in that node. A test plan will be written that will include a test suite of numerous BDE files. On conclusion of the testing a report of the results will be published. Any bugs that are found that can easily be fixed, will be fixed. Test Results The testing suite that was followed was the same way as that which was included in the test plan of the design phase. Testing was performed on the UNIX workstations running the current version of bde and Netscape Navigator version 2.0 was used to display the bde2Java applet. A file was created for each of the features that were mentioned and the consistency of it's appearance was tested. The .dat file created using BDE was viewed through the Java applet and it's consistency with the originally created .dat file was observed. Numerous test files were created and the following features were tested, the results of the testing are also included below : The first feature that was tested was the look and the feel of the BDE application. The application created has a similar look and feel as the existing BDE application with the menu bar on the top and the toolbar on the left hand side, and the vertical and horizontal scroll bars on the right and the bottom of the main screen. The path name and the graph name are also displayed in their respective positions as in the original BDE application. All features not implemented display a message stating such. A few notable differences however are bde2Java has incorporated the attributes drop down list to display the node attributes. Also bde2Java has implemented a drop down list of graphs available as well as hyperlinks on some of the nodes in order to navigate between graphs. Most of the files created using the original BDE application conformed with the files opened by the bde2Java applet. However the ability to display different fonts has not been implemented, this results in the systems default fonts being used. Therefore all test files created with multiple fonts when viewed with the bde2Java applet use the default font settings as compared to the selected one. Test files were created for the following : A .dat file with a single graph was created. When opened using the BDE2JAVA application, the single graph was instantly displayed on entry with the graph primary key displayed in the left hand corner. This confirms with the feature detailed in the initial design of the project. A .dat file with multiple graphs. The first graph in the .dat file is displayed immediately after the file has been loaded. This confirms the implementation as stated in the original design. The ability to switch between graphs was verified. When a choice is made by clicking on the graph drop down list box, the corresponding graph is displayed confirming this feature as stated in the design phase. Switching to the connecting graph by clicking on the button on the connecting node is also implemented as stated. The corresponding graph always appears in the place of the present graph with the name of the graph and the HG number also displayed in their respective places. A graph with a single node of each type and multiple nodes of each type. The graph displayed using the BDE2JAVA application was a replica of the original graph created by the existing BDE application. Testing was also performed with nodes of different sizes which each time resulted in a replica of the original graph. Nodes were in the same position with the same shape and the same size as the one that was created using the existing BDE. Consistency of the two graphs has been successfully observed. A graph with a single link between two nodes. Consistency in the appearance of the link with the arrowhead was observed. A graph with multiple links between two nodes or many nodes. Here again consistency was observed. A graph with text within the nodes. The text appears in the systems default font. Various fonts have not been implemented as stated earlier. The position of the text within the node has been consistent. A .dat file with multiple graphs and connecting nodes between graphs, multiple nodes and links between nodes. The testing showed integrity between the input and the output. Switching between graphs by clicking on the connecting node was possible. Appearance of the nodes ,links and text in the graph was consistent. Ability to move nodes in the graph. Selecting a node and dragging it enables you to move the node anywhere in the graph. The links and associated bend points from the node if any have always moved accordingly retaining the integrity of the entire graph. Most of the features suggested in the design phase have been implemented and tested. A few of the features mentioned, to be implemented if time permits could be implemented in the next version of this project. All the different fonts available in the BDE application. Context - sensitive help facility which would make it even more user-friendly. All the features presently disabled could be implemented in the next version. Currently not implemented are the HA, HI, XB, toolbar and menubar functions. 9. Summary The Java language provides an environment for creating robust object oriented applications which may be executed over the Internet using a Java powered browser. By harnessing the features of the Java language, the bde2Java team has developed a useful and powerful version of the original bde. This version will allow internal and external viewing of bde graphs via the Internet. Future version of this project will allow students the ability to fully utilize the powerful features of bde from any location, running any operating system supporting Java. Appendix A BDE2Java Schedule Appendix B BDE2Java Documentation Project requirements document. Weekly project status reports. Test Plan and report. A final project report will be generated detailing the BDE2Java project. A technical specification will delivered listing the configuration options which include a users guide for imbedding a BDE2Java applet into an HTML document. All project documation can be found in the following directory: /usr/proj3/case/96s523/bde2jav1/base/public_html/ Files with the doc extension are Microsoft Word 6.0 documents. Files with the extension txt are text files. Files with the html are HTML web documents. All web pages can be browsed at the above path Appendix C BDE2Java User Guide The following is a list of parameters to configure the bde2JavaApplet. Table 1 show the required parameters and Table 2 shows the optional values. Applet Parameters code This parameter is required and must be set to "bde2JavaApplet.class". width The width parameter controls the display width of the bde2JavaApplet shown in the HTML Web page. height The height parameter controls the display height of the bde2JavaApplet shown in the HTML Web page. Applet Mode The applet appletmode parameter changes the mode that the applet will run in. When set to "1" the applet will run in viewer mode. The viewer mode is used for non-interactive display in a web page. The default is bde mode. PR Dump Mode The applet pr_dump parameter enables or disables the pr_dump method to write to standard i/o upon termination of the applet. Setting this parameter to "1" enables the pr_dump. The default is to disable the pr_dump. Edit Mode The applet editmode parameter enables or disables the capability to move, create, restyle, resize, or delete any object. The editmode parameter is not required and if omitted the default value is set to disable edit mode. To allow the user to edit any object set the value to "1". File Name The filename parameter is the name of the file that will be loaded. ColorR The applet colorR parameter set the red component of the applet. This parameter must used with the colorG and colorB parameters. If these parameter is not used the default color is gray (RGB - 192,192, 192). colorG The applet colorG parameter set the green component of the applet. This parameter must used with the colorR and colorB parameters. If these parameter is not used the default color is gray (RGB - 192,192, 192). colorB value The applet colorB parameter set the blue component of the applet. This parameter must used with the colorR and colorG parameters. If these parameter is not used the default color is gray (RGB - 192,192, 192). Vertical Scroll Bar Mode The applet vertscroll parameter enables or disables the vertical scroll bar. This parameter when set to "1" will hide the vertical scroll bar. the default is to show the vertical scroll bar. Horizontal Scroll Bar Mode The applet horzscroll parameter enables or disables the horizontal scroll bar. This parameter when set to "1" will hide the horizontal scroll bar. the default is to show the horizontal scroll bar. Diagram Editing Operations Example of HTML code for a bde2Java Applet The above HTML code is an example of the code needed to embed the bdeJava applet into an HTML document. Table 1. Required Parameters Parameter Value Description 1 bde2JavaApplet.class bde2JavaApplet.class Name of Applet to run 2 width any positive value Width of Applet 3 height any positive value Height of Applet Table 2. Optional Parameters Parameter Value Description 1 appletmode 1 or 0 1 for Viewer mode 2 pr_dump 1 or 0 1 for pr_dump activation 3 editmode 1 or 0 1 for to edit a graph 4 filename Any valid bde file bde file to be displayed 5 colorR value Between 0 and 256 Red value for applet color 6 colorG value Between 0 and 256 Green value for applet color 7 colorB value Between 0 and 256 Blue value for applet color 8 vertscroll 1 or 0 1 to hide vert scroll bar 9 horzscroll 1 or 0 1 to hide horz scroll bar Appendix D bde2Java Source Code 1