6 |
6 |
7 This is the graph browser's main class. It contains the "main(...)" |
7 This is the graph browser's main class. It contains the "main(...)" |
8 method, which is used for the stand-alone version, as well as |
8 method, which is used for the stand-alone version, as well as |
9 "init(...)", "start(...)" and "stop(...)" methods which are used for |
9 "init(...)", "start(...)" and "stop(...)" methods which are used for |
10 the applet version. |
10 the applet version. |
11 Note: GraphBrowser is designed for the 1.0.2 version of the JDK. |
11 Note: GraphBrowser is designed for the 1.1.x version of the JDK. |
12 ***************************************************************************/ |
12 ***************************************************************************/ |
13 |
13 |
14 package GraphBrowser; |
14 package GraphBrowser; |
15 |
15 |
16 import java.awt.*; |
16 import java.awt.*; |
36 |
36 |
37 public void showWaitMessage() { |
37 public void showWaitMessage() { |
38 if (isApplet) |
38 if (isApplet) |
39 getAppletContext().showStatus("calculating layout, please wait ..."); |
39 getAppletContext().showStatus("calculating layout, please wait ..."); |
40 else { |
40 else { |
41 f.setCursor(Frame.WAIT_CURSOR); |
41 f.setCursor(new Cursor(Cursor.WAIT_CURSOR)); |
42 } |
42 } |
43 } |
43 } |
44 |
44 |
45 public void showReadyMessage() { |
45 public void showReadyMessage() { |
46 if (isApplet) |
46 if (isApplet) |
47 getAppletContext().showStatus("ready !"); |
47 getAppletContext().showStatus("ready !"); |
48 else { |
48 else { |
49 f.setCursor(Frame.DEFAULT_CURSOR); |
49 f.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); |
50 } |
50 } |
51 } |
51 } |
52 |
52 |
53 public void viewFile(String fname) { |
53 public void viewFile(String fname) { |
54 try { |
54 try { |
55 if (isApplet) |
55 if (isApplet) |
56 getAppletContext().showDocument(new URL(getDocumentBase(), fname),"_blank"); |
56 getAppletContext().showDocument(new URL(getDocumentBase(), fname), "_blank"); |
57 else { |
57 else { |
58 String path=gfname.substring(0,gfname.lastIndexOf('/')+1); |
58 String path = gfname.substring(0, gfname.lastIndexOf('/') + 1); |
59 InputStream is; |
59 BufferedReader br; |
60 String line, text=""; |
60 String line, text = ""; |
61 DataInputStream di; |
|
62 |
61 |
63 is=new FileInputStream(path+fname); |
62 br = new BufferedReader(new FileReader(path + fname)); |
64 di=new DataInputStream(is); |
63 while ((line = br.readLine()) != null) |
65 while ((line=di.readLine())!=null) |
64 text += line + "\n"; |
66 text+=line+"\n"; |
|
67 |
65 |
68 if (fname.endsWith(".html")) { |
66 if (fname.endsWith(".html")) { |
69 /**** convert HTML to text (just a quick hack) ****/ |
67 /**** convert HTML to text (just a quick hack) ****/ |
70 |
68 |
71 String buf=""; |
69 String buf=""; |
126 try { |
124 try { |
127 TreeNode tn=new TreeNode("Directories","",-1,true); |
125 TreeNode tn=new TreeNode("Directories","",-1,true); |
128 gv=new GraphView(new Graph(is,tn),this); |
126 gv=new GraphView(new Graph(is,tn),this); |
129 tb=new TreeBrowser(tn,gv); |
127 tb=new TreeBrowser(tn,gv); |
130 gv.setTreeBrowser(tb); |
128 gv.setTreeBrowser(tb); |
131 Vector v=new Vector(10,10); |
129 Vector v = new Vector(10,10); |
132 tn.collapsedDirectories(v); |
130 tn.collapsedDirectories(v); |
133 gv.collapseDir(v); |
131 gv.collapseDir(v); |
134 Component gv2=new Border(gv,5); |
132 |
135 Component tb2=new Border(tb,5); |
133 ScrollPane scrollp1 = new ScrollPane(); |
|
134 ScrollPane scrollp2 = new ScrollPane(); |
|
135 scrollp1.add(gv); |
|
136 scrollp2.add(tb); |
|
137 scrollp1.getHAdjustable().setUnitIncrement(20); |
|
138 scrollp1.getVAdjustable().setUnitIncrement(20); |
|
139 scrollp2.getHAdjustable().setUnitIncrement(20); |
|
140 scrollp2.getVAdjustable().setUnitIncrement(20); |
|
141 Component gv2 = new Border(scrollp1, 5); |
|
142 Component tb2 = new Border(scrollp2, 5); |
136 GridBagLayout gridbag = new GridBagLayout(); |
143 GridBagLayout gridbag = new GridBagLayout(); |
137 GridBagConstraints cnstr = new GridBagConstraints(); |
144 GridBagConstraints cnstr = new GridBagConstraints(); |
138 setLayout(gridbag); |
145 setLayout(gridbag); |
139 cnstr.fill = GridBagConstraints.BOTH; |
146 cnstr.fill = GridBagConstraints.BOTH; |
140 cnstr.insets = new Insets(5,5,5,5); |
147 cnstr.insets = new Insets(5,5,5,5); |