src/Tools/Graphview/graphview.scala
author wenzelm
Mon, 25 Mar 2019 17:21:26 +0100
changeset 69981 3dced198b9ec
parent 67547 aefe7a7b330a
child 71601 97ccf48c2f0c
permissions -rw-r--r--
more strict AFP properties;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59459
985fc55e9f27 clarified module name;
wenzelm
parents: 59443
diff changeset
     1
/*  Title:      Tools/Graphview/graphview.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
e411afcfaa29 tuned headers;
wenzelm
parents: 59236
diff changeset
     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
59459
985fc55e9f27 clarified module name;
wenzelm
parents: 59443
diff changeset
     5
Graphview visualization parameters and GUI 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
37b53813426f tuned signature;
wenzelm
parents: 49736
diff changeset
    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
59290
569a8109eeb2 separate module Metrics;
wenzelm
parents: 59286
diff changeset
    13
import java.awt.{Font, Color, Shape, Graphics2D}
59305
b5e33012180e tuned signature;
wenzelm
parents: 59303
diff changeset
    14
import java.awt.geom.{Point2D, Rectangle2D}
49729
f53a8f73b40f more basic tooltips;
wenzelm
parents: 49573
diff changeset
    15
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
    16
61988f9df94d added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff changeset
    17
59462
c7eff4356885 tuned signature;
wenzelm
parents: 59460
diff changeset
    18
abstract class Graphview(full_graph: Graph_Display.Graph)
50465
wenzelm
parents: 50464
diff changeset
    19
{
59459
985fc55e9f27 clarified module name;
wenzelm
parents: 59443
diff changeset
    20
  graphview =>
50472
bad1a1ca61e1 separate instance of class Parameters for each Main_Panel -- avoid global program state;
wenzelm
parents: 50471
diff changeset
    21
59302
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    22
59395
4c5396f52546 tuned signature;
wenzelm
parents: 59392
diff changeset
    23
  def options: Options
59392
02bacfc31446 support for tree view on graph nodes;
wenzelm
parents: 59384
diff changeset
    24
59462
c7eff4356885 tuned signature;
wenzelm
parents: 59460
diff changeset
    25
  val model = new Model(full_graph)
c7eff4356885 tuned signature;
wenzelm
parents: 59460
diff changeset
    26
59392
02bacfc31446 support for tree view on graph nodes;
wenzelm
parents: 59384
diff changeset
    27
59302
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    28
  /* layout state */
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    29
59290
569a8109eeb2 separate module Metrics;
wenzelm
parents: 59286
diff changeset
    30
  // owned by GUI thread
59303
15cd9bcd6ddb tuned signature;
wenzelm
parents: 59302
diff changeset
    31
  private var _layout: Layout = Layout.empty
15cd9bcd6ddb tuned signature;
wenzelm
parents: 59302
diff changeset
    32
  def layout: Layout = _layout
59290
569a8109eeb2 separate module Metrics;
wenzelm
parents: 59286
diff changeset
    33
569a8109eeb2 separate module Metrics;
wenzelm
parents: 59286
diff changeset
    34
  def metrics: Metrics = layout.metrics
59302
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    35
  def visible_graph: Graph_Display.Graph = layout.input_graph
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    36
59303
15cd9bcd6ddb tuned signature;
wenzelm
parents: 59302
diff changeset
    37
  def translate_vertex(v: Layout.Vertex, dx: Double, dy: Double): Unit =
15cd9bcd6ddb tuned signature;
wenzelm
parents: 59302
diff changeset
    38
    _layout = _layout.translate_vertex(v, dx, dy)
59302
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    39
59305
b5e33012180e tuned signature;
wenzelm
parents: 59303
diff changeset
    40
  def find_node(at: Point2D): Option[Graph_Display.Node] =
b5e33012180e tuned signature;
wenzelm
parents: 59303
diff changeset
    41
    layout.output_graph.iterator.collectFirst({
59384
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    42
      case (Layout.Node(node), (info, _)) if Shapes.shape(info).contains(at) => node
59305
b5e33012180e tuned signature;
wenzelm
parents: 59303
diff changeset
    43
    })
b5e33012180e tuned signature;
wenzelm
parents: 59303
diff changeset
    44
b5e33012180e tuned signature;
wenzelm
parents: 59303
diff changeset
    45
  def find_dummy(at: Point2D): Option[Layout.Dummy] =
b5e33012180e tuned signature;
wenzelm
parents: 59303
diff changeset
    46
    layout.output_graph.iterator.collectFirst({
59384
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    47
      case (dummy: Layout.Dummy, (info, _)) if Shapes.shape(info).contains(at) => dummy
59305
b5e33012180e tuned signature;
wenzelm
parents: 59303
diff changeset
    48
    })
b5e33012180e tuned signature;
wenzelm
parents: 59303
diff changeset
    49
59302
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    50
  def bounding_box(): Rectangle2D.Double =
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    51
  {
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    52
    var x0 = 0.0
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    53
    var y0 = 0.0
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    54
    var x1 = 0.0
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    55
    var y1 = 0.0
59384
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    56
    for ((_, (info, _)) <- layout.output_graph.iterator) {
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    57
      val rect = Shapes.shape(info)
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    58
      x0 = x0 min rect.getMinX
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    59
      y0 = y0 min rect.getMinY
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    60
      x1 = x1 max rect.getMaxX
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    61
      y1 = y1 max rect.getMaxY
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    62
    }
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    63
    x0 = (x0 - metrics.gap).floor
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    64
    y0 = (y0 - metrics.gap).floor
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    65
    x1 = (x1 + metrics.gap).ceil
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    66
    y1 = (y1 + metrics.gap).ceil
59302
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    67
    new Rectangle2D.Double(x0, y0, x1 - x0, y1 - y0)
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    68
  }
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    69
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    70
  def update_layout()
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    71
  {
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    72
    val metrics = Metrics(make_font())
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    73
    val visible_graph = model.make_visible_graph()
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    74
59384
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    75
    def node_text(node: Graph_Display.Node, content: XML.Body): String =
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    76
      if (show_content) {
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    77
        val s =
67547
aefe7a7b330a clarified breakgain: keeping it constant avoids margin fluctuation in Pretty_Tooltip vs. Pretty_Text_Area;
wenzelm
parents: 61590
diff changeset
    78
          XML.content(Pretty.formatted(content,
aefe7a7b330a clarified breakgain: keeping it constant avoids margin fluctuation in Pretty_Tooltip vs. Pretty_Text_Area;
wenzelm
parents: 61590
diff changeset
    79
            margin = options.int("graphview_content_margin").toDouble,
aefe7a7b330a clarified breakgain: keeping it constant avoids margin fluctuation in Pretty_Tooltip vs. Pretty_Text_Area;
wenzelm
parents: 61590
diff changeset
    80
            metric = metrics.Pretty_Metric))
59384
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    81
        if (s.nonEmpty) s else node.toString
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    82
      }
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    83
      else node.toString
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    84
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
    85
    _layout = Layout.make(options, metrics, node_text _, visible_graph)
59302
4d985afc0565 explict layout graph structure, with dummies and coordinates;
wenzelm
parents: 59294
diff changeset
    86
  }
59290
569a8109eeb2 separate module Metrics;
wenzelm
parents: 59286
diff changeset
    87
50476
1cb983bccb5b more official graphics context with font metrics;
wenzelm
parents: 50475
diff changeset
    88
59233
876a81f5788b tuned signature;
wenzelm
parents: 59232
diff changeset
    89
  /* tooltips */
876a81f5788b tuned signature;
wenzelm
parents: 59232
diff changeset
    90
876a81f5788b tuned signature;
wenzelm
parents: 59232
diff changeset
    91
  def make_tooltip(parent: JComponent, x: Int, y: Int, body: XML.Body): String = null
876a81f5788b tuned signature;
wenzelm
parents: 59232
diff changeset
    92
876a81f5788b tuned signature;
wenzelm
parents: 59232
diff changeset
    93
59228
56b34fc7a015 more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents: 59220
diff changeset
    94
  /* main colors */
56b34fc7a015 more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents: 59220
diff changeset
    95
56b34fc7a015 more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents: 59220
diff changeset
    96
  def foreground_color: Color = Color.BLACK
56b34fc7a015 more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents: 59220
diff changeset
    97
  def background_color: Color = Color.WHITE
61176
9791f631c20d avoid hardwired colors;
wenzelm
parents: 59462
diff changeset
    98
  def selection_color: Color = new Color(204, 204, 255)
9791f631c20d avoid hardwired colors;
wenzelm
parents: 59462
diff changeset
    99
  def highlight_color: Color = new Color(255, 255, 224)
59228
56b34fc7a015 more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents: 59220
diff changeset
   100
  def error_color: Color = Color.RED
59251
wenzelm
parents: 59250
diff changeset
   101
  def dummy_color: Color = Color.GRAY
59228
56b34fc7a015 more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents: 59220
diff changeset
   102
56b34fc7a015 more dynamic visualizer -- re-use Isabelle/jEdit options;
wenzelm
parents: 59220
diff changeset
   103
50475
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   104
  /* font rendering information */
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   105
59290
569a8109eeb2 separate module Metrics;
wenzelm
parents: 59286
diff changeset
   106
  def make_font(): Font =
59286
ac74eedb910a GUI.imitate_font: more explicit result size, e.g. relevant for caching;
wenzelm
parents: 59265
diff changeset
   107
  {
ac74eedb910a GUI.imitate_font: more explicit result size, e.g. relevant for caching;
wenzelm
parents: 59265
diff changeset
   108
    val family = options.string("graphview_font_family")
ac74eedb910a GUI.imitate_font: more explicit result size, e.g. relevant for caching;
wenzelm
parents: 59265
diff changeset
   109
    val size = options.int("graphview_font_size")
ac74eedb910a GUI.imitate_font: more explicit result size, e.g. relevant for caching;
wenzelm
parents: 59265
diff changeset
   110
    new Font(family, Font.PLAIN, size)
ac74eedb910a GUI.imitate_font: more explicit result size, e.g. relevant for caching;
wenzelm
parents: 59265
diff changeset
   111
  }
50475
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   112
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   113
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   114
  /* rendering parameters */
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   115
59294
126293918a37 clarified visualizer parameters;
wenzelm
parents: 59292
diff changeset
   116
  // owned by GUI thread
59384
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
   117
  var show_content = false
c75327a34960 more explicit Layout.Info: size and content;
wenzelm
parents: 59313
diff changeset
   118
  var show_arrow_heads = false
59294
126293918a37 clarified visualizer parameters;
wenzelm
parents: 59292
diff changeset
   119
  var show_dummies = false
61176
9791f631c20d avoid hardwired colors;
wenzelm
parents: 59462
diff changeset
   120
  var editor_style = false
50475
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   121
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   122
  object Colors
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   123
  {
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   124
    private val filter_colors = List(
59220
261ec482cd40 tuned signature;
wenzelm
parents: 59202
diff changeset
   125
      new Color(0xD9, 0xF2, 0xE2), // blue
261ec482cd40 tuned signature;
wenzelm
parents: 59202
diff changeset
   126
      new Color(0xFF, 0xE7, 0xD8), // orange
261ec482cd40 tuned signature;
wenzelm
parents: 59202
diff changeset
   127
      new Color(0xFF, 0xFF, 0xE5), // yellow
261ec482cd40 tuned signature;
wenzelm
parents: 59202
diff changeset
   128
      new Color(0xDE, 0xCE, 0xFF), // lilac
261ec482cd40 tuned signature;
wenzelm
parents: 59202
diff changeset
   129
      new Color(0xCC, 0xEB, 0xFF), // turquoise
261ec482cd40 tuned signature;
wenzelm
parents: 59202
diff changeset
   130
      new Color(0xFF, 0xE5, 0xE5), // red
261ec482cd40 tuned signature;
wenzelm
parents: 59202
diff changeset
   131
      new Color(0xE5, 0xE5, 0xD9)  // green
50475
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   132
    )
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   133
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   134
    private var curr : Int = -1
59220
261ec482cd40 tuned signature;
wenzelm
parents: 59202
diff changeset
   135
    def next(): Color =
50475
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   136
    {
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   137
      curr = (curr + 1) % filter_colors.length
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   138
      filter_colors(curr)
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   139
    }
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   140
  }
8cc351df4a23 just one class with parameters;
wenzelm
parents: 50474
diff changeset
   141
59460
3a357fef24e8 tuned signature;
wenzelm
parents: 59459
diff changeset
   142
  def paint(gfx: Graphics2D)
59294
126293918a37 clarified visualizer parameters;
wenzelm
parents: 59292
diff changeset
   143
  {
126293918a37 clarified visualizer parameters;
wenzelm
parents: 59292
diff changeset
   144
    gfx.setRenderingHints(Metrics.rendering_hints)
59410
19f396384cbe tuned colors;
wenzelm
parents: 59407
diff changeset
   145
59459
985fc55e9f27 clarified module name;
wenzelm
parents: 59443
diff changeset
   146
    for (node <- graphview.current_node)
985fc55e9f27 clarified module name;
wenzelm
parents: 59443
diff changeset
   147
      Shapes.highlight_node(gfx, graphview, node)
59410
19f396384cbe tuned colors;
wenzelm
parents: 59407
diff changeset
   148
59294
126293918a37 clarified visualizer parameters;
wenzelm
parents: 59292
diff changeset
   149
    for (edge <- visible_graph.edges_iterator)
59459
985fc55e9f27 clarified module name;
wenzelm
parents: 59443
diff changeset
   150
      Shapes.Cardinal_Spline_Edge.paint(gfx, graphview, edge)
59410
19f396384cbe tuned colors;
wenzelm
parents: 59407
diff changeset
   151
59294
126293918a37 clarified visualizer parameters;
wenzelm
parents: 59292
diff changeset
   152
    for (node <- visible_graph.keys_iterator)
59459
985fc55e9f27 clarified module name;
wenzelm
parents: 59443
diff changeset
   153
      Shapes.paint_node(gfx, graphview, node)
59294
126293918a37 clarified visualizer parameters;
wenzelm
parents: 59292
diff changeset
   154
  }
50472
bad1a1ca61e1 separate instance of class Parameters for each Main_Panel -- avoid global program state;
wenzelm
parents: 50471
diff changeset
   155
59392
02bacfc31446 support for tree view on graph nodes;
wenzelm
parents: 59384
diff changeset
   156
  var current_node: Option[Graph_Display.Node] = None
02bacfc31446 support for tree view on graph nodes;
wenzelm
parents: 59384
diff changeset
   157
50465
wenzelm
parents: 50464
diff changeset
   158
  object Selection
wenzelm
parents: 50464
diff changeset
   159
  {
61590
wenzelm
parents: 61176
diff changeset
   160
    private val state = Synchronized[List[Graph_Display.Node]](Nil)
50465
wenzelm
parents: 50464
diff changeset
   161
59443
5b552b4f63a5 support for off-line graph output, without GUI thread;
wenzelm
parents: 59410
diff changeset
   162
    def get(): List[Graph_Display.Node] = state.value
59245
be4180f3c236 more formal Graph_Display.Node (with ordering) and Graph_Display.Edge;
wenzelm
parents: 59242
diff changeset
   163
    def contains(node: Graph_Display.Node): Boolean = get().contains(node)
50465
wenzelm
parents: 50464
diff changeset
   164
59443
5b552b4f63a5 support for off-line graph output, without GUI thread;
wenzelm
parents: 59410
diff changeset
   165
    def add(node: Graph_Display.Node): Unit = state.change(node :: _)
5b552b4f63a5 support for off-line graph output, without GUI thread;
wenzelm
parents: 59410
diff changeset
   166
    def clear(): Unit = state.change(_ => Nil)
49557
61988f9df94d added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff changeset
   167
  }
50465
wenzelm
parents: 50464
diff changeset
   168
59220
261ec482cd40 tuned signature;
wenzelm
parents: 59202
diff changeset
   169
  sealed case class Node_Color(border: Color, background: Color, foreground: Color)
50464
37b53813426f tuned signature;
wenzelm
parents: 49736
diff changeset
   170
59245
be4180f3c236 more formal Graph_Display.Node (with ordering) and Graph_Display.Edge;
wenzelm
parents: 59242
diff changeset
   171
  def node_color(node: Graph_Display.Node): Node_Color =
59410
19f396384cbe tuned colors;
wenzelm
parents: 59407
diff changeset
   172
    if (Selection.contains(node))
59245
be4180f3c236 more formal Graph_Display.Node (with ordering) and Graph_Display.Edge;
wenzelm
parents: 59242
diff changeset
   173
      Node_Color(foreground_color, selection_color, foreground_color)
59410
19f396384cbe tuned colors;
wenzelm
parents: 59407
diff changeset
   174
    else if (current_node == Some(node))
19f396384cbe tuned colors;
wenzelm
parents: 59407
diff changeset
   175
      Node_Color(foreground_color, highlight_color, foreground_color)
59245
be4180f3c236 more formal Graph_Display.Node (with ordering) and Graph_Display.Edge;
wenzelm
parents: 59242
diff changeset
   176
    else
be4180f3c236 more formal Graph_Display.Node (with ordering) and Graph_Display.Edge;
wenzelm
parents: 59242
diff changeset
   177
      Node_Color(foreground_color, model.colors.getOrElse(node, background_color), foreground_color)
59220
261ec482cd40 tuned signature;
wenzelm
parents: 59202
diff changeset
   178
59407
d43434c60d3a clarified edge_color;
wenzelm
parents: 59404
diff changeset
   179
  def edge_color(edge: Graph_Display.Edge, downwards: Boolean): Color =
d43434c60d3a clarified edge_color;
wenzelm
parents: 59404
diff changeset
   180
    if (downwards || show_arrow_heads) foreground_color
d43434c60d3a clarified edge_color;
wenzelm
parents: 59404
diff changeset
   181
    else error_color
49557
61988f9df94d added Graphview tool, based on Isabelle/Scala and Swing/Graphics2D;
Markus Kaiser <markus.kaiser@in.tum.de>
parents:
diff changeset
   182
}