lib/browser/GraphBrowser/GraphView.java
author paulson
Fri, 20 Nov 1998 10:37:12 +0100
changeset 5941 1db9fad40a4f
parent 3599 89cbba12863d
child 6541 d3ac35b2bfbf
permissions -rw-r--r--
better miniscoping rules: the premise C~={} is not good because Safe_tac eliminates such assumptions.
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/GraphView.java
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     3
  ID:         $Id$
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     4
  Author:     Stefan Berghofer, TU Muenchen
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     5
  Copyright   1997  TU Muenchen
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     6
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     7
  This class defines the window in which the graph is displayed. It
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     8
  contains methods for handling events such as collapsing / uncollapsing
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
     9
  nodes of the graph.
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.io.*;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    16
import java.util.*;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    17
import awtUtilities.*;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    18
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    19
public class GraphView extends ScrollCanvas {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    20
	Graph gra,gra2;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    21
	GraphBrowser parent;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    22
	Vertex v=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    23
	Vector collapsed=new Vector(10,10);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    24
	Vector collapsedDirs=new Vector(10,10);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    25
	TreeBrowser tb;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    26
	long timestamp;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    27
	Vertex highlighted=null;
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 void setTreeBrowser(TreeBrowser br) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    30
		tb=br;
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 getBrowser() { return parent; }
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 Graph getGraph() { return gra; }
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    36
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    37
	public Graph getOriginalGraph() { return gra2; }
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    38
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    39
	public GraphView(Graph gr,GraphBrowser br) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    40
		gra2=gr;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    41
		parent=br;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    42
		gra=(Graph)(gra2.clone());
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
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    45
	public void PS(String fname,boolean printable) throws IOException {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    46
		gra.PS(fname,printable);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    47
	}
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
	public void paintCanvas(Graphics g)
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
		set_size(gra.max_x-gra.min_x,gra.max_y-gra.min_y);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    52
		gra.draw(g);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    53
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    54
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    55
	public boolean mouseMove(Event evt,int x,int y) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    56
		x+=gra.min_x;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    57
		y+=gra.min_y;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    58
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    59
		Vertex v2=gra.vertexAt(x,y);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    60
		Graphics g=getGraphics();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    61
		g.translate(-gra.min_x,-gra.min_y);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    62
		if (highlighted!=null) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    63
			highlighted.drawBox(g,Color.lightGray);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    64
			highlighted=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    65
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    66
		if (v2!=v) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    67
			if (v!=null) v.removeButtons(g);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    68
			if (v2!=null) v2.drawButtons(g);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    69
			v=v2;
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
		return true;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    72
	}
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
	/*****************************************************************/
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    75
	/* This method is called if successor / predecessor nodes (whose */
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    76
	/* numbers are stored in Vector c) of a certain node should be   */
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    77
        /* displayed again                                               */
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    78
	/*****************************************************************/
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
	void uncollapse(Vector c) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    81
		collapsed.removeElement(c);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    82
		collapseNodes();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    83
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    84
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    85
	/*****************************************************************/
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    86
	/* This method is called by class TreeBrowser when directories   */
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    87
	/* are collapsed / uncollapsed by the user                       */
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    88
	/*****************************************************************/
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    89
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    90
	public void collapseDir(Vector v) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    91
		collapsedDirs=v;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    92
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    93
		collapseNodes();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    94
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    95
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    96
	/*****************************************************************/
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    97
	/*                      Inflate node again                       */
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    98
	/*****************************************************************/
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
    99
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   100
	public void inflateNode(Vector c) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   101
		Enumeration e1;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   102
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   103
		e1=collapsedDirs.elements();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   104
		while (e1.hasMoreElements()) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   105
			Directory d=(Directory)(e1.nextElement());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   106
			if (d.collapsed==c) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   107
				tb.selectNode(d.getNode());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   108
				return;
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
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   111
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   112
		collapsed.removeElement(c);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   113
		e1=gra2.getVertices();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   114
		while (e1.hasMoreElements()) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   115
			Vertex vx=(Vertex)(e1.nextElement());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   116
			if (vx.getUp()==c) vx.setUp(null);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   117
			if (vx.getDown()==c) vx.setDown(null);
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
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   120
		collapseNodes();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   121
		relayout();
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
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   124
	public void relayout() {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   125
		parent.showWaitMessage();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   126
		highlighted=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   127
		gra.layout(getGraphics());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   128
		v=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   129
		update(getGraphics());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   130
		parent.showReadyMessage();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   131
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   132
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   133
	public void focusToVertex(int n) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   134
		Vertex vx=gra.getVertexByNum(n);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   135
		if (vx!=null) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   136
			focus_to(vx.getX()-gra.min_x,vx.getY()-gra.min_y);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   137
			highlighted=vx;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   138
			Graphics g=getGraphics();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   139
			g.translate(-gra.min_x,-gra.min_y);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   140
			vx.drawBox(g,Color.white);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   141
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   142
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   143
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   144
	/*****************************************************************/
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   145
	/*             Create new graph with collapsed nodes             */
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   146
	/*****************************************************************/
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   147
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   148
	public void collapseNodes() {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   149
		Enumeration e1=collapsed.elements();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   150
		gra=(Graph)(gra2.clone());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   151
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   152
		while (e1.hasMoreElements()) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   153
			Vector v1=(Vector)(e1.nextElement());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   154
			Vector v2=gra.decode(v1);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   155
			if (!v2.isEmpty()) gra.collapse(v2,"[. . . .]",v1);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   156
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   157
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   158
		e1=collapsedDirs.elements();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   159
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   160
		while (e1.hasMoreElements()) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   161
			Directory d=(Directory)(e1.nextElement());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   162
			Vector v=gra.decode(d.getCollapsed());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   163
			if (!v.isEmpty())
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   164
				gra.collapse(v,"["+d.getName()+"]",d.getCollapsed());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   165
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   166
	}
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
	public boolean mouseDown(Event evt,int x,int y) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   169
		Vector code=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   170
		Vertex v2;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   171
		x+=gra.min_x;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   172
		y+=gra.min_y;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   173
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   174
		if (v!=null) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   175
			int num=v.getNumber();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   176
			v2=gra2.getVertexByNum(num);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   177
			if (v.leftButton(x,y)) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   178
				if (v.getUp()!=null) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   179
					code=v.getUp();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   180
					v2.setUp(null);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   181
					v=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   182
					uncollapse(code);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   183
					relayout();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   184
					focusToVertex(num);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   185
				} else {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   186
					Vector vs=v2.getPreds();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   187
					code=gra2.encode(vs);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   188
					v.setUp(code);v2.setUp(code);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   189
					v=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   190
					collapsed.insertElementAt(code,0);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   191
					collapseNodes();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   192
					relayout();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   193
					focusToVertex(num);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   194
				}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   195
			} else if (v.rightButton(x,y)) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   196
				if (v.getDown()!=null) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   197
					code=v.getDown();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   198
					v2.setDown(null);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   199
					v=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   200
					uncollapse(code);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   201
					relayout();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   202
					focusToVertex(num);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   203
				} else {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   204
					Vector vs=v2.getSuccs();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   205
					code=gra2.encode(vs);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   206
					v.setDown(code);v2.setDown(code);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   207
					v=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   208
					collapsed.insertElementAt(code,0);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   209
					collapseNodes();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   210
					relayout();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   211
					focusToVertex(num);
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
			} else if (v.getInflate()!=null) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   214
				inflateNode(v.getInflate());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   215
				v=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   216
			} else {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   217
				if (evt.when-timestamp < 400 && !(v.getPath().equals("")))
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   218
					parent.viewFile(v.getPath());
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   219
				timestamp=evt.when;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   220
			}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   221
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   222
		return true;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   223
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   224
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   225
	public boolean mouseExit(Event evt,int x,int y) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   226
		Graphics g=getGraphics();
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   227
		g.translate(-gra.min_x,-gra.min_y);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   228
		if (highlighted!=null) {
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   229
			highlighted.drawBox(g,Color.lightGray);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   230
			highlighted=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   231
		}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   232
		if (v!=null) v.removeButtons(g);
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   233
		v=null;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   234
		return true;
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   235
	}
89cbba12863d Source files for Isabelle theory graph browser.
berghofe
parents:
diff changeset
   236
}