13968
|
1 |
/***************************************************************************
|
|
2 |
Title: GraphBrowser/Console.java
|
|
3 |
ID: $Id$
|
13970
|
4 |
Author: Gerwin Klein, TU Muenchen
|
13968
|
5 |
License: GPL (GNU GENERAL PUBLIC LICENSE)
|
|
6 |
|
|
7 |
This is the graph browser's main class when run as a console application.
|
|
8 |
|
|
9 |
***************************************************************************/
|
|
10 |
|
|
11 |
package GraphBrowser;
|
|
12 |
|
|
13 |
import java.io.*;
|
|
14 |
import java.util.*;
|
|
15 |
import java.net.*;
|
|
16 |
import awtUtilities.*;
|
|
17 |
|
|
18 |
public class Console {
|
|
19 |
Graph g;
|
|
20 |
String gfname;
|
|
21 |
|
|
22 |
public Console(String name) {
|
|
23 |
gfname = name;
|
|
24 |
}
|
|
25 |
|
13970
|
26 |
public void PS(String fname, boolean printable) throws IOException {
|
13968
|
27 |
g.layout(null);
|
|
28 |
g.PS(fname,printable);
|
|
29 |
}
|
|
30 |
|
|
31 |
public void initBrowser(InputStream is) {
|
|
32 |
try {
|
|
33 |
TreeNode tn = new TreeNode("Root", "", -1, true);
|
|
34 |
g = new Graph(is, tn);
|
|
35 |
} catch (IOException exn) {
|
|
36 |
System.err.println("\nI/O error while reading graph file.");
|
|
37 |
} catch (ParseError exn) {
|
|
38 |
System.err.println("\nParse error in graph file:");
|
|
39 |
System.err.println(exn.getMessage());
|
13970
|
40 |
System.err.println("\nSyntax:\n<vertexname> <vertexID> <dirname> [ + ] <path> "+
|
|
41 |
"[ < | > ] [ <vertexID> [ ... [ <vertexID> ] ... ] ] ;");
|
13968
|
42 |
}
|
|
43 |
}
|
|
44 |
|
|
45 |
public static void main(String[] args) {
|
|
46 |
try {
|
|
47 |
if (args.length <= 1) {
|
13970
|
48 |
System.err.println("Graph and output file expected.");
|
13968
|
49 |
return;
|
|
50 |
}
|
13970
|
51 |
|
13968
|
52 |
Console console=new Console(args[0]);
|
|
53 |
InputStream is=new FileInputStream(args[0]);
|
|
54 |
console.initBrowser(is);
|
|
55 |
is.close();
|
|
56 |
|
|
57 |
try {
|
|
58 |
if (args[1].endsWith(".ps"))
|
|
59 |
console.PS(args[1], true);
|
|
60 |
else if (args[1].endsWith(".eps"))
|
|
61 |
console.PS(args[1], false);
|
|
62 |
else
|
|
63 |
System.err.println("Unknown file type: " + args[1]);
|
|
64 |
} catch (IOException exn) {
|
|
65 |
System.err.println("Unable to write file " + args[1]);
|
|
66 |
}
|
|
67 |
} catch (IOException exn) {
|
|
68 |
System.err.println("Can't open graph file "+args[0]);
|
|
69 |
}
|
|
70 |
}
|
|
71 |
}
|