author | wenzelm |
Sat, 03 Jan 2015 13:11:10 +0100 | |
changeset 59241 | 541b95e94dc7 |
parent 59240 | e411afcfaa29 |
child 59242 | fda4091cc6b0 |
permissions | -rw-r--r-- |
59202 | 1 |
/* Title: Tools/Graphview/visualizer.scala |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
2 |
Author: Markus Kaiser, TU Muenchen |
59240 | 3 |
Author: Makarius |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
4 |
|
50475 | 5 |
Graph visualization parameters and interface state. |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
6 |
*/ |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
7 |
|
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
8 |
package isabelle.graphview |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
9 |
|
50464 | 10 |
|
49565
ea4308b7ef0f
ML support for generic graph display, with browser and graphview backends (via print modes);
wenzelm
parents:
49557
diff
changeset
|
11 |
import isabelle._ |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
12 |
|
59220 | 13 |
import java.awt.{Font, FontMetrics, Color, Shape, RenderingHints, Graphics2D} |
59231
6dea47cf6c6b
more dynamic visualizer -- re-use jEdit font info;
wenzelm
parents:
59228
diff
changeset
|
14 |
import java.awt.font.FontRenderContext |
50476
1cb983bccb5b
more official graphics context with font metrics;
wenzelm
parents:
50475
diff
changeset
|
15 |
import java.awt.image.BufferedImage |
59241
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
16 |
import java.awt.geom.Rectangle2D |
49729 | 17 |
import javax.swing.JComponent |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
18 |
|
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
19 |
|
59241
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
20 |
object Visualizer |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
21 |
{ |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
22 |
object Metrics |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
23 |
{ |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
24 |
def apply(font: Font, font_render_context: FontRenderContext) = |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
25 |
new Metrics(font, font_render_context) |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
26 |
|
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
27 |
def apply(gfx: Graphics2D): Metrics = |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
28 |
new Metrics(gfx.getFont, gfx.getFontRenderContext) |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
29 |
} |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
30 |
|
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
31 |
class Metrics private(font: Font, font_render_context: FontRenderContext) |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
32 |
{ |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
33 |
def string_bounds(s: String) = font.getStringBounds(s, font_render_context) |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
34 |
private val specimen = string_bounds("mix") |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
35 |
|
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
36 |
def char_width: Double = specimen.getWidth / 3 |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
37 |
def height: Double = specimen.getHeight |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
38 |
def ascent: Double = font.getLineMetrics("", font_render_context).getAscent |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
39 |
def gap: Double = specimen.getWidth |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
40 |
def pad: Double = char_width |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
41 |
} |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
42 |
} |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
43 |
|
50465 | 44 |
class Visualizer(val model: Model) |
45 |
{ |
|
50472
bad1a1ca61e1
separate instance of class Parameters for each Main_Panel -- avoid global program state;
wenzelm
parents:
50471
diff
changeset
|
46 |
visualizer => |
bad1a1ca61e1
separate instance of class Parameters for each Main_Panel -- avoid global program state;
wenzelm
parents:
50471
diff
changeset
|
47 |
|
50476
1cb983bccb5b
more official graphics context with font metrics;
wenzelm
parents:
50475
diff
changeset
|
48 |
|
59233 | 49 |
/* tooltips */ |
50 |
||
51 |
def make_tooltip(parent: JComponent, x: Int, y: Int, body: XML.Body): String = null |
|
52 |
||
53 |
||
59228
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
54 |
/* main colors */ |
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
55 |
|
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
56 |
def foreground_color: Color = Color.BLACK |
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
57 |
def foreground1_color: Color = Color.GRAY |
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
58 |
def background_color: Color = Color.WHITE |
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
59 |
def selection_color: Color = Color.GREEN |
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
60 |
def error_color: Color = Color.RED |
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
61 |
|
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
62 |
|
50475 | 63 |
/* font rendering information */ |
64 |
||
59241
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
65 |
def font_size: Int = 12 |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
66 |
def font(): Font = new Font("Helvetica", Font.PLAIN, font_size) |
50475 | 67 |
|
68 |
val rendering_hints = |
|
69 |
new RenderingHints( |
|
70 |
RenderingHints.KEY_ANTIALIASING, |
|
71 |
RenderingHints.VALUE_ANTIALIAS_ON) |
|
72 |
||
59231
6dea47cf6c6b
more dynamic visualizer -- re-use jEdit font info;
wenzelm
parents:
59228
diff
changeset
|
73 |
val font_render_context = new FontRenderContext(null, true, false) |
6dea47cf6c6b
more dynamic visualizer -- re-use jEdit font info;
wenzelm
parents:
59228
diff
changeset
|
74 |
|
59241
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
75 |
def metrics(): Visualizer.Metrics = |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
76 |
Visualizer.Metrics(font(), font_render_context) |
50475 | 77 |
|
78 |
||
79 |
/* rendering parameters */ |
|
80 |
||
81 |
var arrow_heads = false |
|
82 |
||
83 |
object Colors |
|
84 |
{ |
|
85 |
private val filter_colors = List( |
|
59220 | 86 |
new Color(0xD9, 0xF2, 0xE2), // blue |
87 |
new Color(0xFF, 0xE7, 0xD8), // orange |
|
88 |
new Color(0xFF, 0xFF, 0xE5), // yellow |
|
89 |
new Color(0xDE, 0xCE, 0xFF), // lilac |
|
90 |
new Color(0xCC, 0xEB, 0xFF), // turquoise |
|
91 |
new Color(0xFF, 0xE5, 0xE5), // red |
|
92 |
new Color(0xE5, 0xE5, 0xD9) // green |
|
50475 | 93 |
) |
94 |
||
95 |
private var curr : Int = -1 |
|
59220 | 96 |
def next(): Color = |
50475 | 97 |
{ |
98 |
curr = (curr + 1) % filter_colors.length |
|
99 |
filter_colors(curr) |
|
100 |
} |
|
101 |
} |
|
102 |
||
50472
bad1a1ca61e1
separate instance of class Parameters for each Main_Panel -- avoid global program state;
wenzelm
parents:
50471
diff
changeset
|
103 |
|
50465 | 104 |
object Coordinates |
105 |
{ |
|
59232 | 106 |
private var layout = Layout.empty |
50465 | 107 |
|
108 |
def apply(k: String): (Double, Double) = |
|
59241
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
109 |
layout.nodes.getOrElse(k, (0.0, 0.0)) |
50465 | 110 |
|
111 |
def apply(e: (String, String)): List[(Double, Double)] = |
|
50470 | 112 |
layout.dummies.get(e) match { |
50465 | 113 |
case Some(ds) => ds |
114 |
case None => Nil |
|
115 |
} |
|
116 |
||
117 |
def reposition(k: String, to: (Double, Double)) |
|
118 |
{ |
|
50470 | 119 |
layout = layout.copy(nodes = layout.nodes + (k -> to)) |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
120 |
} |
50465 | 121 |
|
122 |
def reposition(d: ((String, String), Int), to: (Double, Double)) |
|
123 |
{ |
|
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
124 |
val (e, index) = d |
50470 | 125 |
layout.dummies.get(e) match { |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
126 |
case None => |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
127 |
case Some(ds) => |
50470 | 128 |
layout = layout.copy(dummies = |
129 |
layout.dummies + (e -> |
|
130 |
(ds.zipWithIndex :\ List.empty[(Double, Double)]) { |
|
131 |
case ((t, i), n) => if (index == i) to :: n else t :: n |
|
132 |
})) |
|
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
133 |
} |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
134 |
} |
50465 | 135 |
|
136 |
def translate(k: String, by: (Double, Double)) |
|
137 |
{ |
|
138 |
val ((x, y), (dx, dy)) = (Coordinates(k), by) |
|
139 |
reposition(k, (x + dx, y + dy)) |
|
140 |
} |
|
141 |
||
142 |
def translate(d: ((String, String), Int), by: (Double, Double)) |
|
143 |
{ |
|
144 |
val ((e, i),(dx, dy)) = (d, by) |
|
145 |
val (x, y) = apply(e)(i) |
|
146 |
reposition(d, (x + dx, y + dy)) |
|
147 |
} |
|
148 |
||
50470 | 149 |
def update_layout() |
50465 | 150 |
{ |
50474
6ee044e2d1a7
initial layout coordinates more like old browser;
wenzelm
parents:
50472
diff
changeset
|
151 |
layout = |
59232 | 152 |
if (model.current_graph.is_empty) Layout.empty |
50474
6ee044e2d1a7
initial layout coordinates more like old browser;
wenzelm
parents:
50472
diff
changeset
|
153 |
else { |
59231
6dea47cf6c6b
more dynamic visualizer -- re-use jEdit font info;
wenzelm
parents:
59228
diff
changeset
|
154 |
val m = metrics() |
6dea47cf6c6b
more dynamic visualizer -- re-use jEdit font info;
wenzelm
parents:
59228
diff
changeset
|
155 |
|
50474
6ee044e2d1a7
initial layout coordinates more like old browser;
wenzelm
parents:
50472
diff
changeset
|
156 |
val max_width = |
59228
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
157 |
model.current_graph.iterator.map({ case (_, (info, _)) => |
59231
6dea47cf6c6b
more dynamic visualizer -- re-use jEdit font info;
wenzelm
parents:
59228
diff
changeset
|
158 |
m.string_bounds(info.name).getWidth }).max |
59236 | 159 |
val box_distance = max_width + m.pad + m.gap |
160 |
def box_height(n: Int): Double = m.char_width * 1.5 * (5 max n) |
|
59231
6dea47cf6c6b
more dynamic visualizer -- re-use jEdit font info;
wenzelm
parents:
59228
diff
changeset
|
161 |
|
59232 | 162 |
Layout.make(model.current_graph, box_distance, box_height _) |
50474
6ee044e2d1a7
initial layout coordinates more like old browser;
wenzelm
parents:
50472
diff
changeset
|
163 |
} |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
164 |
} |
50465 | 165 |
|
59241
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
166 |
def bounding_box(): Rectangle2D.Double = |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
167 |
{ |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
168 |
val m = metrics() |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
169 |
var x0 = 0.0 |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
170 |
var y0 = 0.0 |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
171 |
var x1 = 0.0 |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
172 |
var y1 = 0.0 |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
173 |
for (node_name <- model.visible_nodes_iterator) { |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
174 |
val shape = Shapes.Growing_Node.shape(m, visualizer, Some(node_name)) |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
175 |
x0 = x0 min shape.getMinX |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
176 |
y0 = y0 min shape.getMinY |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
177 |
x1 = x1 max shape.getMaxX |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
178 |
y1 = y1 max shape.getMaxY |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
179 |
} |
59241
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
180 |
x0 = x0 - m.gap |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
181 |
y0 = y0 - m.gap |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
182 |
x1 = x1 + m.gap |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
183 |
y1 = y1 + m.gap |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
184 |
new Rectangle2D.Double(x0, y0, x1 - x0, y1 - y0) |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
185 |
} |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
186 |
} |
50465 | 187 |
|
50464 | 188 |
object Drawer |
189 |
{ |
|
50465 | 190 |
def apply(g: Graphics2D, n: Option[String]) |
191 |
{ |
|
192 |
n match { |
|
193 |
case None => |
|
194 |
case Some(_) => Shapes.Growing_Node.paint(g, visualizer, n) |
|
195 |
} |
|
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
196 |
} |
50465 | 197 |
|
198 |
def apply(g: Graphics2D, e: (String, String), head: Boolean, dummies: Boolean) |
|
199 |
{ |
|
200 |
Shapes.Cardinal_Spline_Edge.paint(g, visualizer, e, head, dummies) |
|
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
201 |
} |
50465 | 202 |
|
50464 | 203 |
def paint_all_visible(g: Graphics2D, dummies: Boolean) |
204 |
{ |
|
50465 | 205 |
g.setFont(font) |
50464 | 206 |
|
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
207 |
g.setRenderingHints(rendering_hints) |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
208 |
|
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
55618
diff
changeset
|
209 |
model.visible_edges_iterator.foreach(e => { |
50475 | 210 |
apply(g, e, arrow_heads, dummies) |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
211 |
}) |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
212 |
|
56372
fadb0fef09d7
more explicit iterator terminology, in accordance to Scala 2.8 library;
wenzelm
parents:
55618
diff
changeset
|
213 |
model.visible_nodes_iterator.foreach(l => { |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
214 |
apply(g, Some(l)) |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
215 |
}) |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
216 |
} |
50465 | 217 |
|
59241
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
218 |
def shape(m: Visualizer.Metrics, n: Option[String]): Shape = |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
219 |
if (n.isEmpty) Shapes.Dummy.shape(m, visualizer, n) |
541b95e94dc7
clarified bounding box, similar to old graph browser;
wenzelm
parents:
59240
diff
changeset
|
220 |
else Shapes.Growing_Node.shape(m, visualizer, n) |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
221 |
} |
50465 | 222 |
|
223 |
object Selection |
|
224 |
{ |
|
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
225 |
private var selected: List[String] = Nil |
50465 | 226 |
|
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
227 |
def apply() = selected |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
228 |
def apply(s: String) = selected.contains(s) |
50465 | 229 |
|
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
230 |
def add(s: String) { selected = s :: selected } |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
231 |
def set(ss: List[String]) { selected = ss } |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
232 |
def clear() { selected = Nil } |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
233 |
} |
50465 | 234 |
|
59220 | 235 |
sealed case class Node_Color(border: Color, background: Color, foreground: Color) |
50464 | 236 |
|
59220 | 237 |
def node_color(l: Option[String]): Node_Color = |
238 |
l match { |
|
59228
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
239 |
case None => |
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
240 |
Node_Color(foreground1_color, background_color, foreground_color) |
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
241 |
case Some(c) if Selection(c) => |
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
242 |
Node_Color(foreground_color, selection_color, foreground_color) |
59220 | 243 |
case Some(c) => |
59228
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
244 |
Node_Color(foreground_color, model.colors.getOrElse(c, background_color), foreground_color) |
59220 | 245 |
} |
246 |
||
59228
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
247 |
def edge_color(e: (String, String)): Color = foreground_color |
50465 | 248 |
|
249 |
object Caption |
|
50464 | 250 |
{ |
59228
56b34fc7a015
more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents:
59220
diff
changeset
|
251 |
def apply(key: String) = model.complete_graph.get_node(key).name |
49557
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
252 |
} |
61988f9df94d
added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff
changeset
|
253 |
} |