lib/browser/GraphBrowser/GraphBrowser.java
author webertj
Fri, 17 Aug 2012 20:31:12 +0200
changeset 48853 ec82c33c75f8
parent 33686 8e33ca8832b1
child 50473 ca4088bf8365
permissions -rw-r--r--
Typo fixed.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     1
/***************************************************************************
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     2
  Title:      GraphBrowser/GraphBrowser.java
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     3
  Author:     Stefan Berghofer, TU Muenchen
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     4
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     5
  This is the graph browser's main class. It contains the "main(...)"
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     6
  method, which is used for the stand-alone version, as well as
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     7
  "init(...)", "start(...)" and "stop(...)" methods which are used for
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     8
  the applet version.
6541
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
     9
  Note: GraphBrowser is designed for the 1.1.x version of the JDK.
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    10
***************************************************************************/
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    11
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    12
package GraphBrowser;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    13
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    14
import java.awt.*;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    15
import java.applet.*;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    16
import java.io.*;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    17
import java.util.*;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    18
import java.net.*;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    19
import awtUtilities.*;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    20
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    21
public class GraphBrowser extends Applet {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    22
	GraphView gv;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    23
	TreeBrowser tb=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    24
	String gfname;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    25
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    26
	static boolean isApplet;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    27
	static Frame f;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    28
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    29
	public GraphBrowser(String name) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    30
		gfname=name;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    31
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    32
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    33
	public GraphBrowser() {}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    34
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    35
	public void showWaitMessage() {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    36
		if (isApplet)
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    37
			getAppletContext().showStatus("calculating layout, please wait ...");
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    38
		else {
6541
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
    39
			f.setCursor(new Cursor(Cursor.WAIT_CURSOR));
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    40
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    41
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    42
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    43
	public void showReadyMessage() {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    44
		if (isApplet)
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    45
			getAppletContext().showStatus("ready !");
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    46
		else {
6541
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
    47
			f.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    48
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    49
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    50
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    51
	public void viewFile(String fname) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    52
		try {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    53
			if (isApplet)
6541
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
    54
				getAppletContext().showDocument(new URL(getDocumentBase(), fname), "_blank");
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    55
			else {
6541
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
    56
				String path = gfname.substring(0, gfname.lastIndexOf('/') + 1);
6648
d70810da5565 Added some code to enable browser to display remote documents.
berghofe
parents: 6541
diff changeset
    57
				Reader rd;
6541
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
    58
				BufferedReader br;
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
    59
				String line, text = "";
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    60
6648
d70810da5565 Added some code to enable browser to display remote documents.
berghofe
parents: 6541
diff changeset
    61
				try {
d70810da5565 Added some code to enable browser to display remote documents.
berghofe
parents: 6541
diff changeset
    62
					rd = new BufferedReader(new InputStreamReader((new URL(fname)).openConnection().getInputStream()));
d70810da5565 Added some code to enable browser to display remote documents.
berghofe
parents: 6541
diff changeset
    63
				} catch (Exception exn) {
d70810da5565 Added some code to enable browser to display remote documents.
berghofe
parents: 6541
diff changeset
    64
					rd = new FileReader(path + fname);
d70810da5565 Added some code to enable browser to display remote documents.
berghofe
parents: 6541
diff changeset
    65
				}
d70810da5565 Added some code to enable browser to display remote documents.
berghofe
parents: 6541
diff changeset
    66
				br = new BufferedReader(rd);
d70810da5565 Added some code to enable browser to display remote documents.
berghofe
parents: 6541
diff changeset
    67
6541
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
    68
				while ((line = br.readLine()) != null)
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
    69
					text += line + "\n";
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    70
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    71
				if (fname.endsWith(".html")) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    72
					/**** convert HTML to text (just a quick hack) ****/
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    73
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    74
					String buf="";
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    75
					char[] text2,text3;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    76
					int i,j=0;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    77
					boolean special=false, html=false;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    78
					char ctrl;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    79
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    80
					text2 = text.toCharArray();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    81
					text3 = new char[text.length()];
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    82
					for (i = 0; i < text.length(); i++) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    83
						char c = text2[i];
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    84
						if (c == '&') {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    85
							special = true;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    86
							buf = "";
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    87
						} else if (special) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    88
							if (c == ';') {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    89
								special = false;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    90
								if (buf.equals("lt"))
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    91
									text3[j++] = '<';
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    92
								else if (buf.equals("gt"))
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    93
									text3[j++] = '>';
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    94
								else if (buf.equals("amp"))
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    95
									text3[j++] = '&';
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    96
							} else
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    97
								buf += c;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    98
						} else if (c == '<') {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    99
							html = true;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   100
							ctrl = text2[i+1];
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   101
						} else if (c == '>')
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   102
							html = false;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   103
						else if (!html)
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   104
							text3[j++] = c;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   105
					}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   106
					text = String.valueOf(text3);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   107
				}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   108
							
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   109
				Frame f=new TextFrame(fname.substring(fname.lastIndexOf('/')+1),text);
6541
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
   110
				f.setSize(500,600);
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   111
				f.show();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   112
			}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   113
		} catch (Exception exn) {
11798
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   114
			System.err.println("Can't read file "+fname);
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   115
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   116
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   117
				
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   118
	public void PS(String fname,boolean printable) throws IOException {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   119
		gv.PS(fname,printable);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   120
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   121
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   122
	public boolean isEmpty() {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   123
		return tb==null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   124
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   125
11876
6ac0627167ed Fixed problem with batch mode layout, which caused an AWT exception when
berghofe
parents: 11812
diff changeset
   126
	public void initBrowser(InputStream is, boolean noAWT) {
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   127
		try {
11876
6ac0627167ed Fixed problem with batch mode layout, which caused an AWT exception when
berghofe
parents: 11812
diff changeset
   128
			Font font = noAWT ? null : new Font("Helvetica", Font.PLAIN, 12);
6ac0627167ed Fixed problem with batch mode layout, which caused an AWT exception when
berghofe
parents: 11812
diff changeset
   129
			TreeNode tn = new TreeNode("Root", "", -1, true);
6ac0627167ed Fixed problem with batch mode layout, which caused an AWT exception when
berghofe
parents: 11812
diff changeset
   130
			gv = new GraphView(new Graph(is, tn), this, font);
6ac0627167ed Fixed problem with batch mode layout, which caused an AWT exception when
berghofe
parents: 11812
diff changeset
   131
			tb = new TreeBrowser(tn, gv, font);
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   132
			gv.setTreeBrowser(tb);
6541
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
   133
			Vector v = new Vector(10,10);
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   134
			tn.collapsedDirectories(v);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   135
			gv.collapseDir(v);
6541
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
   136
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
   137
			ScrollPane scrollp1 = new ScrollPane();
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
   138
			ScrollPane scrollp2 = new ScrollPane();
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
   139
			scrollp1.add(gv);
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
   140
			scrollp2.add(tb);
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
   141
			scrollp1.getHAdjustable().setUnitIncrement(20);
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
   142
			scrollp1.getVAdjustable().setUnitIncrement(20);
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
   143
			scrollp2.getHAdjustable().setUnitIncrement(20);
d3ac35b2bfbf Updated to JDK 1.1.x
berghofe
parents: 3641
diff changeset
   144
			scrollp2.getVAdjustable().setUnitIncrement(20);
6753
43507781dc4d broder size 3;
wenzelm
parents: 6648
diff changeset
   145
			Component gv2 = new Border(scrollp1, 3);
43507781dc4d broder size 3;
wenzelm
parents: 6648
diff changeset
   146
			Component tb2 = new Border(scrollp2, 3);
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   147
			GridBagLayout gridbag = new GridBagLayout();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   148
			GridBagConstraints cnstr = new GridBagConstraints();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   149
			setLayout(gridbag);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   150
			cnstr.fill = GridBagConstraints.BOTH;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   151
			cnstr.insets = new Insets(5,5,5,5);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   152
			cnstr.weightx = 1;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   153
			cnstr.weighty = 1;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   154
			cnstr.gridwidth = 1;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   155
			gridbag.setConstraints(tb2,cnstr);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   156
			add(tb2);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   157
			cnstr.weightx = 2.5;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   158
			cnstr.gridwidth = GridBagConstraints.REMAINDER;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   159
			gridbag.setConstraints(gv2,cnstr);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   160
			add(gv2);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   161
		} catch (IOException exn) {
11798
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   162
			System.err.println("\nI/O error while reading graph file.");
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   163
		} catch (ParseError exn) {
11798
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   164
			System.err.println("\nParse error in graph file:");
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   165
			System.err.println(exn.getMessage());
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   166
			System.err.println("\nSyntax:\n<vertexname> <vertexID> <dirname> [ + ] <path> [ < | > ] [ <vertexID> [ ... [ <vertexID> ] ... ] ] ;");
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   167
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   168
	}		
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   169
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   170
	public void init() {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   171
		isApplet=true;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   172
		gfname=getParameter("graphfile");
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   173
		try {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   174
			InputStream is=(new URL(getDocumentBase(), gfname)).openConnection().getInputStream();
11876
6ac0627167ed Fixed problem with batch mode layout, which caused an AWT exception when
berghofe
parents: 11812
diff changeset
   175
			initBrowser(is, false);
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   176
			is.close();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   177
		} catch (MalformedURLException exn) {
11798
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   178
			System.err.println("Invalid URL: "+gfname);
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   179
		} catch (IOException exn) {
11798
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   180
			System.err.println("I/O error while reading "+gfname+".");
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   181
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   182
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   183
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   184
	public static void main(String[] args) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   185
		isApplet=false;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   186
		try {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   187
			GraphBrowser gb=new GraphBrowser(args.length > 0 ? args[0] : "");
11798
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   188
			if (args.length > 0) {
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   189
				InputStream is=new FileInputStream(args[0]);
11876
6ac0627167ed Fixed problem with batch mode layout, which caused an AWT exception when
berghofe
parents: 11812
diff changeset
   190
				gb.initBrowser(is, args.length > 1);
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   191
				is.close();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   192
			}
11798
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   193
			if (args.length > 1) {
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   194
                            try {
11876
6ac0627167ed Fixed problem with batch mode layout, which caused an AWT exception when
berghofe
parents: 11812
diff changeset
   195
			      if (args[1].endsWith(".ps"))
11798
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   196
                                gb.gv.PS(args[1], true);
11876
6ac0627167ed Fixed problem with batch mode layout, which caused an AWT exception when
berghofe
parents: 11812
diff changeset
   197
                              else if (args[1].endsWith(".eps"))
11798
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   198
                                gb.gv.PS(args[1], false);
11876
6ac0627167ed Fixed problem with batch mode layout, which caused an AWT exception when
berghofe
parents: 11812
diff changeset
   199
                              else
11798
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   200
                                System.err.println("Unknown file type: " + args[1]);
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   201
                            } catch (IOException exn) {
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   202
                              System.err.println("Unable to write file " + args[1]);
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   203
                            }
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   204
                        } else {
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   205
			    f=new GraphBrowserFrame(gb);
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   206
			    f.setSize(700,500);
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   207
			    f.show();
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   208
                        }
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   209
		} catch (IOException exn) {
11798
fbab70de9b0d Added support for batch mode layout (without X11 connection).
berghofe
parents: 9459
diff changeset
   210
			System.err.println("Can't open graph file "+args[0]);
3599
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   211
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   212
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   213
}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   214