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