Download Enhancement 2 - UML Computer Science

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
91. 522
Object Oriented Analysis and Design
BDE2Java
Project Report
December 17, 2003
Project Team
Meera V Kudur
UshaRani Guntu
Mandar Garge
Instructor
Dr. Robert Lechner
Department of Computer Science
University of Massachusetts, Lowell
Bde2Java: Fall ’03
1 of 35
Table of Contents
Page
Table of Contents
2
1. Problem analysis
1.1. BDE2Java Introduction ………………………………………………
1.2. BDE2Java Background ………………………………………………..
1.3. Bde2Java Objectives …………………………………………………..
1.4. Architecture of BDE2Java …………………………………………….
1.5. Limitations …………………………………………………………….
3
3
3
4
4
5
2. Project Plan. …………………………………………………………………
7
3. Design Specifications……………………………………………………….
3.1.1. Enhancements and Documentation ………………………………...
8
8
3.1.1.1 Enhancement 1: WC to DC and LC to WC conversion…………………….
3.1.1.2 Enhancement 2: Saving a newly created file……………………………….
3.1.1.3 Enhancement 3: Displaying Graph Title in Top Left Combo box………….
3.1.1.4 Enhancement 4: Creating a Self Link………………………………………
3.1.1.5 Enhancement 5: Making “Graph- Create” from the left menu panel work ..
3.1.1.6 Enhancement 6: Multi-line text box for Node and Caption text……………
8
11
13
15
24
25
3.1.2. Details about Design Issues…………………………………………
31
4. Development Environment Tools Used ……………………………………… 33
5. Testing of the New Features/Enhancements………………………………….. 33
6. Future Enhancements…………………………………………………………. 33
7. Source Code Location…………………………………………………………. 34
8. User Guide…………………………………………………………………….. 34
9. Build/Tests/Debug……………………………………………………………. . 34
10. References…………………………………………………………………… 35
Bde2Java: Fall ’03
2 of 35
1. Problem analysis
1.1 BDE2Java Introduction:
BDE is a Block Diagram Editor written in C++ using X11/Motif as its GUI.
BDE is built using imake, make and the gnu g++ compiler. The purpose of BDE is to
capture the semantics of software design diagrams that support various CASE tools and
track design changes. BDE is also a Structured diagrams and Data Flow diagrams . It
maintains Persistent Diagram Database.
BDE has certain Graphic features as to use only one button of mouse, to draw nodes of
various shapes, to connect nodes by edges or links, move or resize nodes or captions,
maintain node-link connections, split links into multiple segments and also to change
link segment drawing style. In the same way it also has Text Features like creating text
captions in diagrams, attaching text attribute lists to nodes, to attach text label lists to
links, delete and relative-move text lines, to update any text line and Lexically parse
and tokenize text.
BDE also has few Persistent Data Features like storing multiple diagrams in a file, to
save diagrams as . ps , convert diagrams to .gif+ .htm+ .map,Convert diagrams to
GEN/LCP DB, also to capture and replay attribute updates .
BDE2Java is a Java based Block Diagram Editor application which runs as an applet
allowing user to construct Data flow diagrams ,Structured diagrams and State
Transition diagrams etc..,
1.2 BDE2Java Project Background:
BDE2Java project was started by a team of 4 graduate students, as a part of the
91.523 Spring 96 class (graduate Software Engineering) at the University of
Massachusetts Lowell. The project was accomplished under the guidance of Instructor
Dr. Robert Lechner. It was then continued in the Fall of 2002 by a team of two students
as BDE2Java v2.0.
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.
The original project was programmed with Java components and the Fall ’02
version was re-designed using Java Swing Components. [Ref. 02F522 BDE2Java
finalreport.txt] The design changes can be found there. The idea was to have Client,
Bde2Java: Fall ’03
3 of 35
Server and Shared Packages and delegation of the classes and methods.The Project was
then implemented by ntrivedi .
And now our Team took the Project and implemented few things which were not
working in the previous version of ntrivedi. We are able to implement few tasks which
were already their at project without implementing. So we took those tasks and made
the few of them to work under the guidance of Instructor Dr. Robert Lechner .
1.3 Bde2Java Objectives:
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 in
form of Applets.
The BDE2Java applet gives any user on the Internet with a Java enabled
browser the ability to view BDE files. This allows 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. Almost every browser can support
Java Applets as we know. This makes the access universal.
There were some known limitations at the end of the previous version. Some of
the logic to overcome the limitations was there already, but we choose to give this
project a finishing touch because it was designed really nicely and because of my
interest in Java Technology. we had to face some problems because of the
documentation issues and our inability to understand lengthy code really quickly being
on our own.
1.4 Architecture of BDE2Java:
The design of the BDE2Java applet is based on high-level class design
architecture. Designing the BDE Java application form scratch takes advantage of the
object-oriented nature of Java, in order to help produce a well structured and efficient
application. This design requires less code than the original BDE application.
The implementation has been categorized basically into three different but dependent
modules explained below
Client:
This module is the main module for the functioning of the applet. All the classes
that provide their functionalities to the applet are included in this module. For example
bde2JavaGUIController for the GUI in the applet, which in turn consists of many other
classes for the menu, drawing canvas, display area and selection combo boxes.
Bde2Java: Fall ’03
4 of 35
Server:
This module helps the maintenance of the files that store one or more graphs. It
has a class named bde2JavaDataManager that helps in the loading and the saving of
files. 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.
Shared:
This package is a placeholder for shared variables and classes.
Main Classes for BDE2Java Application:
Bde2JavaGUIController is the main class for handling the entire GUI for the
BDE2Java Applet. The main purpose of this class to register various other classes that
play a key role in the GUI components. These classes and the methods inside them are
explained at length in v 2.0 final report [/usr/proj3/case/03f522/bde2java03f522/]
1.5 Limitations:
The previous implementation of BDE2Java Project had some limitations, which
are listed below. We have addressed some of the limitations by adding some new
functions and by modifying the currently available functions. Please refer to the
updated version of User Guide on /nfs/earth/misc/proj3/case/03f522/bde2java for the
changes from Fall’03 Version.
1. Current version (version2) of Bde2Java saves coordinate values in Device
Coordinates (DC). Some components like Link and BendPoints are stored in
Link Coordinates (LC). But there is no provision for storing the coordinates and
component dimensions in World Coordinates (WC) like Bde2Unix does. There
are no routines for conversions between WC and DC
1. SAVING a newly created file: When the user creates a new file, the application
does not prompt the user whether the existing file needs to be saved as a new
file nor does it prompt the user if the existing file is to be overwritten. Instead it
simply adds the components to existing file. The right way is that the
application should prompt the user whether he wants to save as a new file or
overwrite the existing (open) file.
2. The top left combo box which allows selection of a graph in the current file
displays only the HGid key. The expected behavior is that the application
should display the entire table which shows all the graph records. Simply
Bde2Java: Fall ’03
5 of 35
displaying the graph key value is not very helpful. The application should at
least display the graph name along with HGid key.
3. Self Link: There is no means to create a self link – a link that connects a node to
itself. Application allows nodes only between two different nodes.
4. GRAPH –CREATE option on the left panel of the application is not
implemented. The previous version implemented graph creation from the top
menu as a menu item option. A BDE graph is also a component like any other
component. The idea behind a document-database UI of the application is that
given a single file the user should be able to add multiple graphs to the same file
from the left panel just as he is able to add other components.
5. Multi line Text Creation: Bde2Java version 2 allows adding only single line of
test to nodes, links or caption. Real life application should allow adding multiline text and also allow wrapping of text.
6. Text update is not working. When a text is created, it takes a left mouse click to
display the text on the screen at the selected point. This is true for all types of
text items – Link text, node text and caption text.
7. Undo and Redo: Just like any real life application Bde2Java should allow
multiple ‘undo’ and redo’ operations. User should be able to undo till the last
save and redo again to the current status. Current version of Bde2Java does not
have this capability.
8. Edit operations such as Select, Copy, Cut, Paste are disabled menu items.
The above were the limitations we saw from time to time and the changes we
have done to enhance the functionality of BDE2Java. BDE2Java also supports
JavaDocs, so user can generate Documentation using an IDE or from command line to
view the changes and the enhanced functionality. we have used Oracle JDeveloper as
the IDE but you can compile and run BDE2Java from command line too. we have
generated javadocs for the last version we compiled. They are a set of HTML Files
uploaded on the server under respective packages (Client, Server and Shared).
Bde2Java: Fall ’03
6 of 35
2. Project Plan
In this BDE2Java Project we have few Limitations as described above. So our
project team decided to implement following of those Limitations:
1. WC to DC and LC to WC conversions.
Provide a means to allow conversions between World Coordinates (WC)
and Device Coordinates (DC). The application would store the coordinates of
Caption Text, Graph Caption, Nodes and Node Attributes and Text in World
Coordinates. The java component classes would always maintain the
coordinates and dimensions in Device coordinates after they are read from the a
data file which always stores them as WC (float values between 0 to 1.0).
2
Saving a newly created file:
The user needs to be prompted whether or not to save changes in the
existing file when he creates a new file, opens an existing file, or closes current
working file.
3
Displaying Graph title in addition to HGid key in the top left Combo Box:
Current version (version 2) displays only the HGid key values of graphs
in the combo box. Our team attempted to implement display of Graph Title in
addition HGid key value in the top left combo box. Displaying only primary
HGid key (as it is displaying currently) is not very informative.
4
Self Link - Making a self link to node:
Provide a means to create a self link for a node. User should be able to
create a self link to a node by using an additional tiny node called as Secondary
Node. This will give an effect that a link originates from the main node to the
secondary node and then there is a second link with an additional bendpoint in
the middle.
5
Making ‘GRAPH –CREATE ‘ in the left menu panel work:
This operation will be working in version 3. When ‘Graph-Create’ is the
chosen combination in the left panel, a text box will pop up that would take as
an input, the name of the new graph. The application will show this new empty
graph as the current graph. This will also change the selection in the top left
combo box to display the new graph.
6
Multi-Line Text Create:
Bde2Java version2 allows only single line text creation for node, link
and Caption text. This enhancement enables the user to add multilane text to –
- Graph caption
- Nodes
Every line of the text is stored as a separate row or record (HA record
for Node text and GX record for Caption text)
Bde2Java: Fall ’03
7 of 35
3. Design Specifications
3.1.1. Enhancements and Documentation
3.1.1.1 Enhancement 1:
WC to DC and LC to WC conversions:
Task Description:
Currently for some components (like Node, Caption, Caption Text, Node Text), the
data file stores the location and size in Device Coordinates (or Pixel Coordinates), and
for others (like Links, Bendpoints) they are stored in Link Coordinates. A well
developed application should have all the values such as x and y coordinates (of
component position) and component dimensions stored in World Coordinates. In order
to achieve this there should be conversion routines between WC and DC, WC and LC
and DC and LC. Out of these, Bde2Java Version 2 already implements LC to WC
partially.
Our team attempted to implement WC to DC and DC to WC conversions so that all
those values that were stored as Pixel values would be henceforth stored as float values
between [0, 1.0]
Working:
The World coordinates always range from 0 to 1.0 units. The Device coordinates are
always integers – ranging from 0 to some maximum value. So for example for a screen
size of 800 x 800 pixels, a point [200,400] transforms to point [0.25, 0.50] in WC.
Similarly for a screen size of 400 x 400, the point would transform to [0.50, 1.0]. The
application makes the component save its location and dimensions in DC but the
application always saves them to data file in WC.
Files Updated:
Package: shared
bdeConstants.java
bdeReference.java
Package: shared
bdeCaptionText.java
bdeGraphCaption.java
bdeNode.java
bdeNodeAttribute.java
bdeText.java
Enhancements to the code:
Bde2Java: Fall ’03
8 of 35
The conversion routines reside in the package ‘shared’, in bdeReference.java. There are
two main transformations WCToDC() and DCToWc(). Each has two overrides with
different arguments. The components - bdeCaptionText, bdeGraphCaption, bdeNode,
bdeNodeAttribute, bdeText, use version WCToDC to read values in WC and store them
in DC, and use the other version DCToWC to store the values back to the file.
The four different conversion routines are as follows:
1. Routine to convert x, y values DC coordinates to WC coordinates
Parameters:
int xDC, yDC – DC coordinates
int canvasWidth, canvasHeight –
Screen size
Return:
Point2D.Float
– WC point
public static Point2D.Float DCToWC( int xDC, int yDC,
int canvasWidth, int canvasHeight )
{
Point2D.Float pointWC = new Point2D.Float();
if( xDC < 0 ) { xDC = 0; }
if( xDC > canvasWidth ) { xDC = canvasWidth; }
if( yDC < 0 ){ yDC = 0; }
if( yDC > canvasHeight ) {
yDC = canvasHeight; }
pointWC.x = (float)(xDC)/(float)(canvasWidth);
pointWC.y = (float)(yDC)/(float)(canvasHeight);
return pointWC;
}
2. Routine to convert x, y values DC coordinates to WC coordinates
Parameters:
Point ptDC – DC coordinates
int canvasWidth, canvasHeight
– Screen size
Return:
Point2D.Float
– WC point
public static Point2D.Float DCToWC( Point ptDC, int canvasWidth, int canvasHeight )
{
Point2D.Float pointWC = new Point2D.Float();
if( ptDC.x < 0 ) { ptDC.x = 0; }
if( ptDC.x > canvasWidth ) {
ptDC.x = canvasWidth; }
if( ptDC.y < 0 ) {ptDC.y = 0; }
if( ptDC.y > canvasHeight ) { ptDC.y = canvasHeight; }
pointWC.x = (float)(ptDC.x)/(float)(canvasWidth);
Bde2Java: Fall ’03
9 of 35
pointWC.y = (float)(ptDC.y)/(float)(canvasHeight);
return pointWC;
}
3. Routine to convert float WC coordinates to DC coordinates
Parameters:
float xWC, yWC – WC coordinates
int canvasWidth, canvasHeight –
Screen size
Return:
Point
– DC point
public static Point WCToDC( float xWC, float yWC, int canvasWidth, int canvasHeight )
{
Point pointDC = new Point();
if( xWC < 0 ) { xWC = 0; }
if( yWC > 1 ) { yWC = 1; }
if( yWC < 0 ) { yWC = 0; }
if( yWC > 1 ) { yWC = 1; }
pointDC.x = (int)(xWC * canvasWidth);
pointDC.y = (int)(yWC * canvasHeight);
return pointDC;
}
4. Routine to convert float WC coordinates to DC coordinates
Parameters:
Point2D.Float ptWC – WC point
int canvasWidth, canvasHeight
– Screen size
Return:
Point
– DC point
public static Point WCToDC( Point2D.Float ptWC, int canvasWidth, int canvasHeight )
{
Point pointDC = new Point();
if( ptWC.x < 0 )
ptWC.x = 0;
if( ptWC.x > 1 )
ptWC.x = 1;
if( ptWC.y < 0 )
ptWC.y = 0;
if( ptWC.y > 1 )
ptWC.y = 1;
pointDC.x = (int)(ptWC.x * canvasWidth);
pointDC.y = (int)(ptWC.y * canvasHeight);
return pointDC;
}
Bde2Java: Fall ’03
10 of 35
Apart from the conversion routines, following code changes have been made in
bdeCaptionText, bdeGraphCaption, bdeNode, bdeNodeAttribute, bdeText, to call the
conversion routines in order to convert from WC to DC and DC to WC.
A. Code that converts the X, Y point picked by mouse click to WC coordinates.
This is the code implemented in bdeNode.create()
// WC coordinates for x,y mounse click point
Point2D.Float pointPosWC = bdeReference.DCToWC( x, y, bdeConstants.CANVAS_WIDTH,
bdeConstants.CANVAS_HEIGHT );
This point is then used to construct the record string that is passed to another routine
called addToParent(), that is also called when a record is read from a data file. The
data file always stores the records in WC.
B. Code that converts a WC point to DC coordinates.
This is the code implemented in bdeNode.addToParent()
// The values are in WC. Convert to DC
float uNodePos = (float)Double.valueOf(stDataString.nextToken()).floatValue();
float vNodePos = (float)Double.valueOf(stDataString.nextToken()).floatValue();
Point pointDC = bdeReference.WCToDC( uNodePos, vNodePos,
bdeConstants.CANVAS_WIDTH, bdeConstants.CANVAS_HEIGHT );
NewNode.x = pointDC.x;
NewNode.y = pointDC.y;
This point is then stored onto the node as DC point.
C. Code that converts a DC point to WC coordinates.
This is the code implemented in bdeNode.getRow(). This piece of code converts
the DC values of the node’s width and to WC values. This routine is called to get a
record string to be saved to the data file.
// DC to WC for Node Width and Height
Point2D.Float pointNodeDimWC = bdeReference.DCToWC( width, height,
bdeConstants.CANVAS_WIDTH, bdeConstants.CANVAS_HEIGHT );
Enhancement 2:
Saving a newly created file: The user needs to be prompted whether or not to overwrite
an existing file when he creates a new file, open an existing file, or closing a current
file.
Bde2Java: Fall ’03
11 of 35
Task Description:
When user is working on some file and when the user clicks on the new file, or open
file, or Close file, the user was not prompted to save his work before creating a new
file. In the new implementation the user is prompted a warning dialog box whether to
save his work before creating a new file, or open an existing file or Close a current file.
Working:
Now the user can save his files by clicking on the yes button or user can ignore the
changes made to the current file by clicking No button on the Warning Dialog box. If
the user clicks on Yes button, It opens a save dialog box appears on the screen to
choose appropriate path for the current file if the file is not saved previously.
Otherwise saves the changes to the current file.
Files Updated/Modified:
BDE2JavaGUIController.java
bdegraph.java
Enhancements to the code:
To provide the warning Dialog box a new method called showDialog() is added in the
BDE2JavaGUIController.java
public void showDialog()
{
Object[] options = { "YES", "NO" };
int n = JOptionPane.showOptionDialog(null, "Do you want to save changes?",
"Warning",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
if(n==0)
{
if (currentFileName == null){
saveAs();
}
else {
dataManager.saveFile(currentFileName, vectorOfGraphs);
}
} else if (n==1)
{
//do nothing
}
}
Any user made changes to the file is noticed by listening to mouse actions such as
mousePressed , mouseReleased , mouseDragged , mouseClicked on the canvas.
This is achieved by adding a Boolean isFileChanged in the
BDE2JavaGUIController.java, and any changes to the file sets this Boolean to true.
This is shown in one of the mouse event(mousePressed) below.
public void mousePressed(MouseEvent e) {
Bde2Java: Fall ’03
12 of 35
System.out.println("Entered bdeGraph..mousePressed()...X
="+e.getX()+" Y="+e.getY());
boolean bNavigate = bdeNavigate(e.getX(), e.getY(),
Event.MOUSE_DOWN);
boolean nStateReturn = StateSelector(e, e.getX(), e.getY());
if (nStateReturn==false)
{
parent.getGUIController().isFileChanged =true;
}
repaint();
}
Depending on the value of the Boolean isFileChanged, the user is prompted to
save his file or not in functions performNewFile(), performClose(), performOpen() of
BDE2JavaGUIController.java.
if (isFileChanged==true)
{
showDialog();
}
Enhancement 3:
Displaying HG rows with primary key and Graph title in the Top left combobox
Task Description:
The top combobox was just showing the graph primary key. And though the
user was prompted to enter the graph title, but it was never captured and stored in the
database, instead it was storing as untitled as graph title for all the graphs. In the new
implementation the top combobox shows both graph primary key and graph title. Also
the user entered graph title is captured and stored in the database.
Working:
Previously as soon as user creates a new file a default graph was created with
the graph title same as the primary key. Now the user will be prompted to enter the new
graph title for the graph that is created by default when user clicks new file from the
File menu. Hence it is possible to show both the graph primary key and user entered
graph title in the top combo box.
Files Updated/Modified:
bdeGraphBox.java
bdeGraph.java
BDE2JavaGUIController.java
Enhancements to the code:
Bde2Java: Fall ’03
13 of 35
1. BDE2JavaGUIController.java: When a new file is created a new Graph by default
gets added to the file, In order to get the name of this default graph the following code
is added in performNewFile() function of BDE2JavGUIController.java.
private void performNewFile() {
…
…
{
bdeGraph graph = new bdeGraph(parentApplet, 0, 0);
//graph.Create("HG000001"); //BY MK
//titleLabel.setText("New"); //By MK
//Added by MK
//Begin
bdeGraph.MaxGraphKey=0;
bdeGraphBox gb =
new bdeGraphBox( parentApplet,
"Enter new graph name",
"Enter new graph name",
graph
);
…
}
2. bdeGraph.java: When user select graph create from the left menu, application
should get the Graph title from the user, hence the following code is added in
graphFunction() of bdeGraph.java.
public synchronized void graphFunction(int x, int y, MouseEvent evt)
{
…
if(parent.getGUIController().nBlocking==
bdeConstants.ACTION_NOT_PENDING)
{
parent.getGUIController().nBlocking=
bdeConstants.ACTION_PENDING;
//Added by MK
//Begin
bdeGraph graph = new bdeGraph(parent, 0, 0);
bdeGraphBox gb =
new bdeGraphBox( parent,
"Enter new graph name",
"Enter new graph name",
graph
);
gb.show();
//End
…
}
3. bdeGraphBox.java:
A Graph can created in two ways
a. By clicking “new Graph” option from File menu.
b. By Selecting “Graph” and “Create” options from the left menu.
BdeGraphBox class is used to display the graphTitle box for the user input, for both
the ways of graph creation, here alone the graph object is created if the user presses
the OK button, after entering the graph title.
Bde2Java: Fall ’03
14 of 35
public void actionPerformed(ActionEvent evt) {
…
if((parentApplet.getGUIController().getSelectedObject()
bdeConstants.GRAPH)
|| isFileMenuGraphCreate) //Added by MK
{
//Added by MK
//begin
parentGraph.Create(txt.getText());
if((parentApplet.getGUIController().getSelectedObject()
bdeConstants.GRAPH))
{
parentApplet.getGUIController().isGraphCreated=true;
}
//end
}
…
}
==
==
Another minor enhancement is done while doing changes for this enhancement.
When user opens an existing file while he is working on other file, the top combo box
was not cleared, so the combo box was showing the previously working file’s graphs
along with opened file’s graphs. In the new implementation this problem is overcome
by clearing the top combo box before opening the user chosen file. This is done in the
function performOpenFile() of BDE2JavaGUIController.java.
private void performOpen() {
…
if (returnVal == JFileChooser.APPROVE_OPTION) {
topComboBox.removeAllItems();//By MK
File selectedFile = fileChooser.getSelectedFile();
currentFileName = new String(selectedFile.getPath());
loadFile(currentFileName);
titleLabel.setText(currentFileName);
}
…
}
Enhancement 4:
Creating a Self Link:
Task Description:
In the current Bde2Java version2 there is no provision for providing a Self Link or a
link that has the same node as the source and destination node. One could only create a
link between two nodes in either direction. One can not pick the same node as source
node and destination node.
Following diagrams shows self Links
Bde2Java: Fall ’03
15 of 35
Working:
As a solution to this the user will have to follow certain rules. In order to provide a self
link the user will have to add another node which acts as a ‘secondary’ node only. This
secondary node exists only for the purpose of self linking. The user should not be able
to add any text to this node. In order to achieve this, the user needs to resize the
secondary node to a very tiny sized node where adding text is not possible. The user
then needs to establish the first link between the main node and the secondary node.
The user can also change the order of the above two steps – he can create the link first
and then change a node to a secondary node. With these two conditions in place if the
user now establishes a link in the other direction the link is created with an additional
bendpoint in the middle that bends the straight link by 10 percent of its length in the
direction opposite to the first link.
Files Updated:
bdeGraph.java
bdeLink.java
Enhancements to the code:
This section explains in detail what changes have been made to the code for the
provided enhancement. It lists the methods added and modifications made to existing
code.
Two methods were added to bdeGraph.java:
A. Method to determine if a link already exists between two nodes:
This method iterates through the list of nodes of the graph and finds out if a link exists
between the two nodes. If there exists one it returns the bdeLink else it returns ‘null’
Parameters:
String sourceNodeName – Source Node name
String destNodeName - Destination Node name
Bde2Java: Fall ’03
16 of 35
Return:
bdeLink – Existing link between the nodes
public bdeLink ExistingLinkBetweenNodes( String sourceNodeName,
String destNodeName )
{
boolean bSourceNameMatches = false;
boolean bDestNameMatches = false;
int index = -1;
for(int nIndex = 0; nIndex < links.size(); nIndex++)
{
if(((bdeLink)links.elementAt(nIndex)).
SourceName.compareTo(sourceNodeName) == 0)
{
bSourceNameMatches = true;
index = nIndex;
break;
}
}
for(int nIndex = 0; nIndex < links.size(); nIndex++)
{
if(((bdeLink)links.elementAt(nIndex)).DestinationName.compareTo(
destNodeName) == 0)
{
bDestNameMatches = true;
break;
}
}
boolean bResult = (bSourceNameMatches & bDestNameMatches);
if( bResult){
// Get the midpoint of the existing link.
bdeLink link = (bdeLink)links.elementAt(index);
return link;
}
return null;
}
B. Method to determine if a Node is a Secondary Node:
This method checks the size of a node and determines if it is a Secondary node. A
secondary node needs to be a tiny node.
Parameters:
String nodeName – Source Node name
Return:
Boolean – True or False
Bde2Java: Fall ’03
17 of 35
public boolean IsSecondaryNode( String nodeName )
{
int nIndex = this.getNodeIndex(nodeName);
float w = ((bdeNode)nodes.elementAt(nIndex)).width/2;
float h = ((bdeNode)nodes.elementAt(nIndex)).height/2;
if( w > 10 && h > 10 )
return false;
return true;
}
Method added to bdeLink.java:
A. Method to create additional bendpoint a link already exists between two nodes:
Parameters:
bdeGraph parentGraph – parent graph
Point2D.Float ptNode1, ptNode2 – end node points
Point2D.Float ptBendPoint1,
ptBendPoint2 – link end points
bdeLink existingLink – existing link between the nodes
Return:
Point2D.Float – the DC coordinates of Middle Bend Point
static Point2D.Float CreateSelfLinkBendPoint( bdeGraph parentGraph,
Point2D.Float ptNode1,
Point2D.Float ptNode2,
Point2D.Float ptBendPoint1,
Point2D.Float ptBendPoint2,
bdeLink existingLink,
String KeyName, String strIndex )
{
Point2D.Float pointBendPoint3 = new Point2D.Float();
int count = existingLink.bendpoints.size();
Point ptMidExistingLink = existingLink.getSpanMidPoint(parentGraph);
float xMidExistingLink = ptMidExistingLink.x; // xFirstExistingLink +
(xLastExistingLink - xFirstExistingLink)/2;
float yMidExistingLink = ptMidExistingLink.y; // yFirstExistingLink +
(yLastExistingLink - yFirstExistingLink)/2;
// Get the WC coordinates of midpoint of the new link
float deltaX = ptBendPoint2.x - ptBendPoint1.x;
float deltaY = ptBendPoint2.y - ptBendPoint1.y;
// Length of the link between the two intersectin points with node
float linkExposedLength = (float)Math.sqrt(deltaX*deltaX +
deltaY*deltaY );
float xMid = ptBendPoint1.x + deltaX/2;
float yMid = ptBendPoint1.y + deltaY/2;
float sinB = deltaX/linkExposedLength;
float cosB = deltaY/linkExposedLength;
Bde2Java: Fall ’03
18 of 35
// Shift the point by 10 percent of link length away from the other
link
float shiftLength = linkExposedLength * (float)0.1;
float shiftX = shiftLength * cosB;
float shiftY = shiftLength * sinB;
// Get point in one direction
float xMid1 = xMid + shiftX;
float yMid1 = yMid - shiftY;
float fDistX1 = xMidExistingLink - xMid1;
float fDistY1 = yMidExistingLink - yMid1;
// Get point in other direction
float xMid2 = xMid - shiftX;
float yMid2 = yMid + shiftY;
float fDistX2 = xMidExistingLink - xMid2;
float fDistY2 = yMidExistingLink - yMid2;
// Compare the two distances
float fDist1 = (float)Math.sqrt(fDistX1*fDistX1 + fDistY1*fDistY1);
float fDist2 = (float)Math.sqrt(fDistX2*fDistX2 + fDistY2*fDistY2);
float uT = 0;
float vT = 0;
//WCtoLC(nx1, ny1, nx2, ny2, xx1, yy1, uT1, vT1);
float dnx = (float)(ptNode2.x - ptNode1.x);
float dny = (float)(ptNode2.y - ptNode1.y);
float linkLength = (float)Math.sqrt(dnx*dnx + dny*dny);
float cosa = dnx/linkLength;
float sina = dny/linkLength;
if( fDist1 > fDist2 ){
// convert to LC from WC
uT = (float)(1/linkLength)*((xMid1 - ptNode1.x)*cosa + (yMid1 ptNode1.y)*sina);
vT = (float)(1/linkLength)*((xMid1 - ptNode1.x)*(-sina) + (yMid1
- ptNode1.y)*cosa);
pointBendPoint3.x = xMid1;
pointBendPoint3.y = yMid1;
}
else{
uT = (float)(1/linkLength)*((xMid2 - ptNode1.x)*cosa + (yMid2 ptNode1.y)*sina);
vT = (float)(1/linkLength)*((xMid2 - ptNode1.x)*(-sina) + (yMid2
- ptNode1.y)*cosa);
pointBendPoint3.x = xMid2;
pointBendPoint3.y = yMid2;
}
return pointBendPoint3;
}
Bde2Java: Fall ’03
19 of 35
Method Modified in to bdeLink.java to add additional bendpoint to the link:
The method bdeLink.Create() has been significantly modified to create additional
bendpoint. It should now look as follows:
static public void Create(bdeGraph parentGraph)
{
String RecordHL, RecordHP, SourceName, DestinationName;
MaxLinkKey = MaxLinkKey + 1;
String KeyName = new String();
float nx1 =0, ny1 = 0, nx2 = 0, ny2 = 0;
float xx1 = 0, yy1 = 0, xx2 = 0, yy2 = 0;
Point NewPoint = new Point(0,0);
float dnx, dny, llength, cosa, sina;
float uT1 = 0, vT1 = 0;
float uT2 = 0, vT2 = 0;
System.out.println(" New NodeKey:" + MaxLinkKey);
KeyName = String.valueOf(MaxLinkKey);
int nLen = KeyName.length();
SourceName = parentGraph.FirstSelectedNode.Name;
DestinationName = parentGraph.SecondSelectedNode.Name;
String zeros = "0000000000".substring(0, (6 - nLen));
KeyName = ObjectType + zeros + KeyName;
RecordHL = bdeReference.DATATOKEN + KeyName + bdeReference.DATATOKEN +
SourceName + bdeReference.DATATOKEN + DestinationName + bdeReference.DATATOKEN
+ "2" + bdeReference.DATATOKEN + "-1";
parentGraph.addLink(RecordHL);
//put in add to parent
//e(bdeGraph parentGraph, float x, float y, int nPosition, String
Pname, String LinePattern)
nx1
=
parentGraph.FirstSelectedNode.x
parentGraph.FirstSelectedNode.width/2;
ny1
=
parentGraph.FirstSelectedNode.y
parentGraph.FirstSelectedNode.height/2;
+
nx2
=
parentGraph.SecondSelectedNode.x
parentGraph.SecondSelectedNode.width/2;
ny2
=
parentGraph.SecondSelectedNode.y
parentGraph.SecondSelectedNode.height/2;
+
NewPoint
(float)ny1,
=
+
parentGraph.FirstSelectedNode.getIntersection((float)nx1,
xx1 = NewPoint.x;
(float)parentGraph.FirstSelectedNode.width/2,
(float)parentGraph.FirstSelectedNode.height/2,
(float)nx2, (float)ny2,
parentGraph.FirstSelectedNode.NodeType);
yy1 = NewPoint.y;
System.out.println("node1:
Bde2Java: Fall ’03
+
(" + nx1 + ", " + ny1 + ")");
20 of 35
System.out.println("node2:
System.out.println("NewPoint1:
(" + nx2 + ", " + ny2 + ")");
(" + xx1 + ", " + yy1 + ")");
//WCtoLC(nx1, ny1, nx2, ny2, xx1, yy1, uT1, vT1);
dnx = (float)(nx2 - nx1);
dny = (float)(ny2 - ny1);
llength = (float)Math.sqrt(dnx*dnx + dny*dny);
cosa = dnx/llength;
sina = dny/llength;
uT1 = (float)(1/llength)*((xx1 - nx1)*cosa + (yy1 - ny1)*sina);
vT1 = (float)(1/llength)*((xx1 - nx1)*(-sina) + (yy1 - ny1)*cosa);
System.out.println("(uT1, vT1): (" + uT1 + ", " + vT1 + ")");
NewPoint = parentGraph.SecondSelectedNode.getIntersection((float)nx2,
(float)ny2,
(float)parentGraph.SecondSelectedNode.width/2,
(float)parentGraph.SecondSelectedNode.height/2,
(float)nx1, (float)ny1,
parentGraph.SecondSelectedNode.NodeType);
xx2 = NewPoint.x; yy2 = NewPoint.y;
System.out.println("NewPoint1:
(" + xx2 + ", " + yy2 + ")");
//WCtoLC(nx1, ny1, nx2, ny2, xx2, yy2, uT2, vT2);
dnx = (float)(nx2 - nx1);
dny = (float)(ny2 - ny1);
llength = (float)Math.sqrt(dnx*dnx + dny*dny);
cosa = dnx/llength;
sina = dny/llength;
uT2 = (float)(1/llength)*((xx2 - nx1)*cosa + (yy2 - ny1)*sina);
vT2 = (float)(1/llength)*((xx2 - nx1)*(-sina) + (yy2 - ny1)*cosa);
System.out.println("(uT2, vT2): (" + uT2 + ", " + vT2 + ")");
/*
String strEndIndex = "0";
// First Bend Point
bdeBendPoint.Create4(parentGraph, uT1, vT1, 0, KeyName, "0");
strEndIndex = "1";
*/
int indexLink = -1;
//
//
//
//
Added
Logic
While
1. If
by MGARGE - Dec 2003
:
creating a link between two nodes, we check for 2 things
a link already exists in other direction
// Get existing link if there is one
String secondaryNode = parentGraph.FirstSelectedNode.Name;
Bde2Java: Fall ’03
21 of 35
float uT3 = 0;
float vT3 = 0;
boolean bAddBendPoint3 = false;
bdeLink
existingLink
=
parentGraph.ExistingLinkBetweenNodes(
parentGraph.SecondSelectedNode.Name, parentGraph.FirstSelectedNode.Name );
// If a link exists, check if the source node is a SECONDARY node
if( existingLink != null )
{
// This is Secondary Node and there is already a Link existing
between the two nodes in the
// opposite direction.
// Get the first and last bendpoints
// Get the X,Y values of first and last points
int count = existingLink.bendpoints.size();
Point2D.Float ptStartExistingLink = new Point2D.Float();
ptStartExistingLink.x
((bdeBendPoint)existingLink.bendpoints.elementAt(0)).uvX;
ptStartExistingLink.y
((bdeBendPoint)existingLink.bendpoints.elementAt(0)).uvY;
=
=
Point2D.Float ptEndExistingLink = new Point2D.Float();
ptEndExistingLink.x
((bdeBendPoint)existingLink.bendpoints.elementAt(count-1)).uvX;
ptEndExistingLink.y
((bdeBendPoint)existingLink.bendpoints.elementAt(count-1)).uvY;
=
=
// Node Point1
Point2D.Float ptNode1 = new Point2D.Float();
ptNode1.x = nx1;
ptNode1.y = ny1;
// Node Point2
Point2D.Float ptNode2 = new Point2D.Float();
ptNode2.x = nx2;
ptNode2.y = ny2;
// BendPoint 1
Point2D.Float ptBendPoint1 = new Point2D.Float();
ptBendPoint1.x = xx1;
ptBendPoint1.y = yy1;
// BendPoint 2
Point2D.Float ptBendPoint2 = new Point2D.Float();
ptBendPoint2.x = xx2;
ptBendPoint2.y = yy2;
// Now add the central bendpoint automatically
Point2D.Float
pointBendPoint3
CreateSelfLinkBendPoint(parentGraph,
ptNode1,ptNode2,
ptBendPoint2, existingLink, KeyName, "0");
Bde2Java: Fall ’03
=
ptBendPoint1,
22 of 35
dnx = (float)(nx2 - nx1);
dny = (float)(ny2 - ny1);
llength = (float)Math.sqrt(dnx*dnx + dny*dny);
cosa = dnx/llength;
sina = dny/llength;
float xBendPoint3 = pointBendPoint3.x;
float yBendPoint3 = pointBendPoint3.y;
uT3
=
(float)(1/llength)*((xBendPoint3
ptNode1.x)*cosa
(yBendPoint3 - ptNode1.y)*sina);
vT3 = (float)(1/llength)*((xBendPoint3 - ptNode1.x)*(-sina)
(yBendPoint3 - ptNode1.y)*cosa);
+
+
bAddBendPoint3 = true;
// Now that we have the 3rd bendpoint.. we need to djust the 1 st
and 2 nd bendpoints
// BendPoint 1
NewPoint
=
ptNode1.x, ptNode1.y,
parentGraph.FirstSelectedNode.getIntersection(
(float)parentGraph.FirstSelectedNode.width/2,
(float)parentGraph.FirstSelectedNode.height/2,
pointBendPoint3.x, pointBendPoint3.y,
parentGraph.FirstSelectedNode.NodeType);
xx1 = NewPoint.x;
yy1 = NewPoint.y;
uT1 = (float)(1/llength)*((xx1 - nx1)*cosa + (yy1 - ny1)*sina);
vT1 = (float)(1/llength)*((xx1 - nx1)*(-sina) + (yy1 - ny1)*cosa);
// BendPoint 2
NewPoint
=
ptNode2.x, ptNode2.y,
parentGraph.SecondSelectedNode.getIntersection(
(float)parentGraph.SecondSelectedNode.width/2,
(float)parentGraph.SecondSelectedNode.height/2,
pointBendPoint3.x, pointBendPoint3.y,
parentGraph.SecondSelectedNode.NodeType);
xx2 = NewPoint.x;
yy2 = NewPoint.y;
//WCtoLC(nx1, ny1, nx2, ny2, xx2, yy2, uT2, vT2);
uT2 = (float)(1/llength)*((xx2 - nx1)*cosa + (yy2 - ny1)*sina);
vT2 = (float)(1/llength)*((xx2 - nx1)*(-sina) + (yy2 - ny1)*cosa);
}
// Finally add the bendPoints
String strEndIndex = "0";
// First Bend Point
bdeBendPoint.Create4(parentGraph, uT1, vT1, 0, KeyName, strEndIndex);
// 3 rd or Middle BendPoint.
strEndIndex = "0";
if(bAddBendPoint3){
Bde2Java: Fall ’03
23 of 35
bdeBendPoint.Create4(parentGraph,
strEndIndex);
}
uT3,
vT3,
0,
KeyName,
strEndIndex = "1";
// Second Bend Point
bdeBendPoint.Create4(parentGraph, uT2, vT2, 0, KeyName, strEndIndex );
}
/* Create() - end */
Enhancement 5:
Making “Graph- Create” from the left menu panel work.
Task Description: When the user selects Left menu option “Graph- Create”, and when
user click on the canvas, application pops up graph-title user input box, and creates a
new graph every time the user clicks Ok button on the graph-title user input box.
Disabling the Graph option as soon as the user clicks on Ok button solves this problem.
If the user has to create a new graph then, user has to reselect the graph option from the
left menu.
Files Modified:
Bde2JavaWorkspacePanel.java
Bde2JavaGUIController.java
BdeGraphBox.java
A variable isGraphCreated is added to the Bde2JavaWorkspacePanel and it is set to true
in bdeGraphBox class when a graph is created, by selecting Graph-Create from the left
menu. This is set to false when the user reselects the Graph option from the left menu.
Enhancements to the code:
A variable isGraphCreated is added to the Bde2JavaWorkspacePanel and it is set to true
in bdeGraphBox class when a graph is created, by selecting Graph-Create from the left
menu. This is set to false when the user reselects the Graph option from the left menu.
Depending on isGraphCreated variable in the function getSelectedObject() of
Bde2JavaGUIController.java, the graph option is disabled.
public int getSelectedObject()
{
int index = -1;
ButtonModel model = objectButtons.getSelection();
if (model != null) {
if ("Node".equals(model.getActionCommand())) {
index = NODE;
…
}
else if ("Graph".equals(model.getActionCommand())) {
Bde2Java: Fall ’03
24 of 35
//Added by MK
//begin
if (isGraphCreated==true)
{
index = -1;
}else{
index = GRAPH;
}
//end
…
return index;
}
Enhancement 6:
Popping a Multi-line text box for Node and Caption text.
Task Description:
A multi-line text box is popped up for Node and Caption text. And each line of
the multi-line text box is stored as a separate record in the data file (separate HA rows
for Node and separate GX rows for Caption). With “Text – Create” option from left
menu, When the user clicks on some Node/Caption the text of the Node/Caption gets
displayed in the multi-line text box, if text had already added to that Node/Caption,
otherwise a empty multi-line text box is popped up. This utility provides user to edit
text in Node/Caption. In previous implementation it use to store Node text as part of
HN row, and Caption text as a separate GX row. But to edit the text, the user had to
delete and recreate the text again.
Working:
A multi-line text box is created with horizontal and vertical scrollbars, and the
text font of the multi-line box is fixed.
Files Modified:
bdeNode.java
bdeGraphCaption.java
File Created:
BdeTextArea.java
Enhancements to the code:
1. bdeNode.java: Two new functions are added to this class.
a. getAttributes() : For accessing the Node attributes
b. clearAttributes(): For clearing the attributes, to repopulate from the multiline text box.
Bde2Java: Fall ’03
25 of 35
public Vector getAttributes()
{
return attributes;
}
public void clearAttributes()
{
attributes = new Vector();
}
2. bdeGraphCaption.java: Two new functions are added to this class.
a. getCaptionText() : For accessing the Caption text(data member of
bdeGraphCaption class)
b. clearCaptionText (): For clearing the Caption Text, to repopulate from the
multi-line text box.
public Vector getCaptionText()
{
return captionText;
}
public void clearCaptionText()
{
captionText = new Vector();
}
3. BdeTextArea.java: A new class is created for displaying multi-line text box for
Node/Caption Text.
package bde2java.client;
import java.awt.*;
import java.awt.event.*;
import java.util.StringTokenizer;
import java.util.Vector;
import javax.swing.*;
import bde2java.shared.*;
public class bdeTextArea extends JFrame
implements ActionListener
{
protected static final String buttonString = "JButton";
protected JTextArea textArea;
protected JButton OKbutton;
bdeGraph parentGraph;
Bde2JavaPanel parentPanel;
Bde2JavaApplet parentApplet;
int width, height;
bdeNode Node;
bdeGraphCaption GraphCaption;
bdeLink Link;
private static final int LINE_SPLIT_SIZE=25;
int Xcurr,Ycurr;
public bdeTextArea(Bde2JavaPanel parent1,Bde2JavaApplet parentApplet, String
title, String Info, bdeGraph parentGraph, int xcurr, int ycurr)
{
super.setTitle(title);
this.parentPanel= parent1;
this.parentGraph=parentGraph;
this.parentApplet=parentApplet;
//this.setModal(true);
Xcurr = xcurr;
Bde2Java: Fall ’03
26 of 35
Ycurr = ycurr;
width = 300;
height = 200;
Dimension d = parentPanel.getSize();
Point pt = parentPanel.getLocation();
int x, y;
x = pt.x + (d.width - width)/2;
y = pt.y + (d.height - height)/2;
JPanel panel= new JPanel(new GridBagLayout());
textArea = new JTextArea(5,20);
Font textFont = new Font("Courier", Font.PLAIN, 16);
textArea.setFont(textFont);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
JScrollPane areaScrollPane = new JScrollPane(textArea,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
areaScrollPane.setBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder(Info),
BorderFactory.createEmptyBorder(5,5,5,5)),
areaScrollPane.getBorder()));
OKbutton = new JButton("OK");
OKbutton.setActionCommand(buttonString);
//Add Components to this panel.
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.BOTH;
c.weightx = 1.0;
c.weighty = 1.0;
panel.add(areaScrollPane, c);
c.fill = GridBagConstraints.CENTER;
panel.add(OKbutton, c);
setDefaultLookAndFeelDecorated(true);
JComponent newContentPane=panel;
newContentPane.setOpaque(true);
getContentPane().add(panel);
pack();
if((parentApplet.getGUIController().getSelectedObject() ==
bdeConstants.TEXT) &&
(parentGraph.FirstSelectedNode != null))
{
Node = parentGraph.FirstSelectedNode;
GraphCaption = parentGraph.selectedGraphCaption;
if (GraphCaption != null)
{
Vector captionTxt= GraphCaption.getCaptionText();
for(int i=0; i<captionTxt.size(); i++)
{
textArea.append(((bdeCaptionText)captionTxt.elementAt(i)).toString()+"\n");
}
}
Bde2Java: Fall ’03
27 of 35
if (parentApplet.getGUIController().getNodeTextMode() ==
parentApplet.getGUIController().NODE_NAME)
textArea.setText(Node.Caption);
else
{
Vector attrs = Node.getAttributes();
for(int i=0; i<attrs.size(); i++)
{
textArea.append(((bdeNodeAttribute)attrs.elementAt(i)).AttributeText+"\n");
}
}
}
GraphCaption = parentGraph.selectedGraphCaption;
if (GraphCaption != null)
{
Vector captionTxt= GraphCaption.getCaptionText();
for(int i=0; i<captionTxt.size(); i++)
{
textArea.append(((bdeCaptionText)captionTxt.elementAt(i)).Caption+"\n");
}
}
textArea.requestFocus();
this.setBounds(x, y, width, height);
}
public bdeTextArea(Bde2JavaPanel parent1,Bde2JavaApplet parentApplet, String
title, String Info, bdeGraph parentGraph)
{
super.setTitle(title);
this.parentPanel= parent1;
this.parentGraph=parentGraph;
this.parentApplet=parentApplet;
width = 300;
height = 200;
Dimension d = parentPanel.getSize();
Point pt = parentPanel.getLocation();
int x, y;
x = pt.x + (d.width - width)/2;
y = pt.y + (d.height - height)/2;
JPanel panel= new JPanel(new GridBagLayout());
textArea = new JTextArea();
Font textFont = new Font("Courier", Font.PLAIN, 16);
textArea.setFont(textFont);//new Font("Serif", Font.TRUETYPE_FONT, 16));
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
JScrollPane areaScrollPane = new JScrollPane(textArea,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
/*areaScrollPane.setVerticalScrollBarPolicy(
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
// areaScrollPane.setPreferredSize(new Dimension(250, 250));*/
areaScrollPane.setBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createCompoundBorder(
BorderFactory.createTitledBorder(Info),
BorderFactory.createEmptyBorder(5,5,5,5)),
areaScrollPane.getBorder()));
OKbutton = new JButton("OK");
OKbutton.setActionCommand(buttonString);
OKbutton.addActionListener(this);
Bde2Java: Fall ’03
28 of 35
//Add Components to this panel.
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
/*c.fill = GridBagConstraints.HORIZONTAL;
add(textArea, c);*/
c.fill = GridBagConstraints.BOTH;
c.weightx = 1.0;
c.weighty = 1.0;
panel.add(areaScrollPane, c);
c.fill = GridBagConstraints.CENTER;
panel.add(OKbutton, c);
setDefaultLookAndFeelDecorated(true);
JComponent newContentPane=panel;
newContentPane.setOpaque(true);
getContentPane().add(panel);
pack();
if((parentApplet.getGUIController().getSelectedObject() ==
bdeConstants.TEXT) &&
(parentGraph.FirstSelectedNode != null))
{
Node = parentGraph.FirstSelectedNode;
GraphCaption = parentGraph.selectedGraphCaption;
if (GraphCaption != null)
{
Vector captionTxt= GraphCaption.getCaptionText();
for(int i=0; i<captionTxt.size(); i++)
{
textArea.append(((bdeCaptionText)captionTxt.elementAt(i)).toString()+"\n");
}
}
if (parentApplet.getGUIController().getNodeTextMode() ==
parentApplet.getGUIController().NODE_NAME)
textArea.setText(Node.Caption);
else
{
Vector attrs = Node.getAttributes();
for(int i=0; i<attrs.size(); i++)
{
textArea.append(((bdeNodeAttribute)attrs.elementAt(i)).AttributeText.trim() + "\n");
}
}
}
GraphCaption = parentGraph.selectedGraphCaption;
if (GraphCaption != null)
{
Vector captionTxt= GraphCaption.getCaptionText();
for(int i=0; i<captionTxt.size(); i++)
{
textArea.append(((bdeCaptionText)captionTxt.elementAt(i)).Caption+"\n");
}
}
textArea.requestFocus();
this.setBounds(x, y, width, height);
}
public void show() {
Bde2Java: Fall ’03
29 of 35
//createAndShowGUI();
super.show();
}
public void actionPerformed(ActionEvent evt) {
if(evt.getActionCommand().equals(buttonString) )
{
if (bdeGraph.MaxGraphKey == -1) {
bdeGraph.MaxGraphKey =0;
parentGraph.Create(textArea.getText());
}
/*if(parentApplet.getGUIController().getSelectedObject() ==
bdeConstants.GRAPH)
{
parentGraph.Create(txt.getText());
}*/
if(parentApplet.getGUIController().getSelectedObject() ==
bdeConstants.TEXT)
{
if(GraphCaption != null)
{
String textString = textArea.getText();
int noOfLines = textArea.getLineCount();
StringTokenizer tokens = new StringTokenizer(textString,
System.getProperty("line.separator"));
GraphCaption.clearCaptionText();
while(tokens.hasMoreElements())
{
String tokenStr = tokens.nextToken();
if(tokenStr.length() < LINE_SPLIT_SIZE)
bdeCaptionText.Create(0, 0, tokenStr, parentGraph);
else
{
int noOfSplits =
(int)Math.ceil(tokenStr.length()/(double)LINE_SPLIT_SIZE);
int beginIndex=0;
int endIndex = LINE_SPLIT_SIZE;
for(int i=0; i<noOfSplits; i++)
{
bdeCaptionText.Create(0, 0,
tokenStr.substring(beginIndex,endIndex), parentGraph);
beginIndex = endIndex-1;
endIndex += LINE_SPLIT_SIZE;
if(endIndex > tokenStr.length())
{
endIndex= tokenStr.length();
}
}
}
}
}
if(Node != null)
{
parentApplet.getGUIController().setNodeTextMode(1);
if (parentApplet.getGUIController().getNodeTextMode() ==
parentApplet.getGUIController().NODE_NAME)
{
Node.Caption = textArea.getText();
Node.CaptionX = 20;
Node.CaptionY = 25;
Node.CaptionWidth = 60;
Node.CaptionHeightY = 13;
}
else{
Bde2Java: Fall ’03
30 of 35
// node attribute
String textString = textArea.getText();
int noOfLines = textArea.getLineCount();
StringTokenizer tokens = new StringTokenizer(textString,
System.getProperty("line.separator"));
Node.clearAttributes();
while(tokens.hasMoreElements())
{
String tokenStr = tokens.nextToken();
if(tokenStr.length() < LINE_SPLIT_SIZE)
bdeNodeAttribute.Create(tokenStr, Node);
else
{
int noOfSplits =
(int)Math.ceil(tokenStr.length()/(double)LINE_SPLIT_SIZE);
int beginIndex=0;
int endIndex = LINE_SPLIT_SIZE;
for(int i=0; i<noOfSplits; i++)
{
bdeNodeAttribute.Create(tokenStr.substring(beginIndex,endIndex), Node);
beginIndex = endIndex-1;
endIndex += LINE_SPLIT_SIZE;
if(endIndex > tokenStr.length())
{
endIndex= tokenStr.length();
}
}
}
}
}
}
}
hide();
//status = bdeConstants.ACTION_OK;
parentApplet.getGUIController().nBlocking =
bdeConstants.ACTION_NOT_PENDING;
dispose();
}
}
}
3.1.2 Details about Design Issues:
3.2.1 Code Design
Any enhancement to the existing code is documented with comments and naming
conventions. In case of new functions added, a detail explanation of the function is
provided just above its declaration.
3.2.2 Comments
Comments have been added at all places where the modifications have been done.
By each of the team member as shown below.
“//Modified by MGARGE” if code changes are done by Mandar Garge
Bde2Java: Fall ’03
31 of 35
“//Added by MK” if code changes are done by Meera Kudur
“//Added by usha code changes are done by Usha Guntu.
3.2.3 Naming conventions
The naming of newly added functions and variables are self-explanatory.
Bde2Java: Fall ’03
32 of 35
4. Development Environment Tools Used:
Environment:
IDE:
Platforms:
Documentation:
Java J2SDK 1.4.2
Sun ONE Studio 5, Standard Edition, JDeveloper,
Netbeans
Windows XP, LINUX
Microsoft Word XP, TextPad
5. Testing of the New Features/Enhancements
We have tested the new features that have been added us. All the tasks accomplished by
are working fine and properly to our knowledge. The enhancements do not hinder
working of any other functions.
The entire project code has been uploaded onto the server only after testing.
6. Future Enhancements:
1. DC to LC and LC to DC routines.
LC to WC and WC to LC routines exist and make it possible to store the Link
parameters in terms of Link Coordinates (LC). Future version can make possible DC to
LC and LC to DC routines.
2. Displaying table of entire HG rows
This version (3) enables display of graph title in addition to HGid of each graph.
Future version should display a table of entire rows of all graphs.
3. Font and Display of multi line text.
This version (3) provides support fixed font multi-line text box and is resizable.
Future versions can provide a variable font size and fixed size multi-line text box.
4. Having a special Self Link node
Provide UI that helps creation of a special Secondary tiny node that acts only
for purpose of providing a self-link. This link cannot act as other nodes. No resizing
and restyling should be allowed.
5. Allow creating link texts only at the bend points.
6. Select option:
Select operation should be made to work
Bde2Java: Fall ’03
33 of 35
7. Text Edit:
When the mode is TEXT + SELECT - a multi line text box can appear with the
text to be edited. The user can edit the text and this can replace the previous HA or GX
records.
8. Text Create Options:
Display all the options for fonts that Bde2Unix displays in the lower-left corner.
7. Source Code Location
The source code can be found in:
/usr/proj3/case/03f522/bde2java03f/mkudur/bde2java/src
While the Documentation and additional files are in the folder:
/usr/proj3/case/03f522/bde2java03f/uguntu/bde2java/docs
8. User guide:
/usr/proj3/case/03f522/bde2java03f/uguntu/bde2java/docs
9. Build/Tests/Debug:
Compilation type script:
[mkudur@mercury bde2java]$ javac -classpath ./classes/ -d ./classes/ ./shared/*.java
./client/*.java ./server/*.java
Note: Some input files use or override a deprecated API.
Note: Recompile with -deprecation for details.
Setting Classpath:
[mkudur@mercury classes]$
CLASSPATH=/usr/proj3/case/03f522/bde2java03f/mkudur/bde2java/classes
[mkudur@mercury classes]$ export CLASSPATH
[mkudur@mercury classes]$ echo $CLASSPATH
/usr/proj3/case/03f522/bde2java03f/mkudur/bde2java/classes
Executing Bde2JavaApplet:
Since Xterm cannot be open from windows machine. The following error is
encountered.
[mkudur@mercury classes]$ java bde2java.client.Bde2JavaApplet
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window
server using '172.147.117.32:0.0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
Bde2Java: Fall ’03
34 of 35
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:77)
at java.lang.Class.forName1(Native Method)
at java.lang.Class.forName(Class.java:142)
at
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.ja
va:72)
at java.awt.Window.<init>(Window.java:202)
at java.awt.Window.<init>(Window.java:244)
at java.awt.Frame.<init>(Frame.java:329)
at java.awt.Frame.<init>(Frame.java:308)
at javax.swing.JFrame.<init>(JFrame.java:183)
at bde2java.client.Bde2JavaApplet.main(Bde2JavaApplet.java:36)
10. References:
Ntrivedi’s Report helped us to get a good knowledge and insight of the previous
project (Bde2Java Version 2) which has been implemented before. Other versions
helped us in this project and also Dr. Lechner’s notes were of great help to give our
team a good understanding of the concepts.
Bde2Java: Fall ’03
35 of 35