src/Tools/Graphview/visualizer.scala
changeset 59259 399506ee38a5
parent 59258 d5c9900636ef
child 59260 c8bd83f8dad9
equal deleted inserted replaced
59258:d5c9900636ef 59259:399506ee38a5
   144     }
   144     }
   145 
   145 
   146     def update_layout()
   146     def update_layout()
   147     {
   147     {
   148       val m = metrics()
   148       val m = metrics()
       
   149       val visible_graph = model.make_visible_graph()
   149 
   150 
   150       val max_width =
   151       val max_width =
   151         model.current_graph.keys_iterator.map(
   152         visible_graph.keys_iterator.map(node => m.string_bounds(node.toString).getWidth).max
   152           node => m.string_bounds(node.toString).getWidth).max
       
   153       val box_distance = (max_width + m.pad + m.gap).ceil
   153       val box_distance = (max_width + m.pad + m.gap).ceil
   154       def box_height(n: Int): Double = (m.char_width * 1.5 * (5 max n)).ceil
   154       def box_height(n: Int): Double = (m.char_width * 1.5 * (5 max n)).ceil
   155 
   155 
   156       // FIXME avoid expensive operation on GUI thread
   156       // FIXME avoid expensive operation on GUI thread
   157       layout = Layout.make(model.current_graph, box_distance, box_height _)
   157       layout = Layout.make(visible_graph, box_distance, box_height _)
   158     }
   158     }
   159 
   159 
   160     def bounding_box(): Rectangle2D.Double =
   160     def bounding_box(): Rectangle2D.Double =
   161     {
   161     {
   162       val m = metrics()
   162       val m = metrics()
   163       var x0 = 0.0
   163       var x0 = 0.0
   164       var y0 = 0.0
   164       var y0 = 0.0
   165       var x1 = 0.0
   165       var x1 = 0.0
   166       var y1 = 0.0
   166       var y1 = 0.0
   167       for (node <- model.visible_nodes_iterator) {
   167       for (node <- model.make_visible_graph().keys_iterator) {
   168         val shape = Shapes.Node.shape(m, visualizer, node)
   168         val shape = Shapes.Node.shape(m, visualizer, node)
   169         x0 = x0 min shape.getMinX
   169         x0 = x0 min shape.getMinX
   170         y0 = y0 min shape.getMinY
   170         y0 = y0 min shape.getMinY
   171         x1 = x1 max shape.getMaxX
   171         x1 = x1 max shape.getMaxX
   172         y1 = y1 max shape.getMaxY
   172         y1 = y1 max shape.getMaxY
   187     def apply(gfx: Graphics2D, edge: Graph_Display.Edge, head: Boolean, dummies: Boolean): Unit =
   187     def apply(gfx: Graphics2D, edge: Graph_Display.Edge, head: Boolean, dummies: Boolean): Unit =
   188       Shapes.Cardinal_Spline_Edge.paint(gfx, visualizer, edge, head, dummies)
   188       Shapes.Cardinal_Spline_Edge.paint(gfx, visualizer, edge, head, dummies)
   189 
   189 
   190     def paint_all_visible(gfx: Graphics2D, dummies: Boolean)
   190     def paint_all_visible(gfx: Graphics2D, dummies: Boolean)
   191     {
   191     {
   192       gfx.setFont(font)
   192       gfx.setFont(font())
   193       gfx.setRenderingHints(rendering_hints)
   193       gfx.setRenderingHints(rendering_hints)
   194       model.visible_edges_iterator.foreach(apply(gfx, _, arrow_heads, dummies))
   194       val visible_graph = model.make_visible_graph()
   195       model.visible_nodes_iterator.foreach(apply(gfx, _))
   195       visible_graph.edges_iterator.foreach(apply(gfx, _, arrow_heads, dummies))
       
   196       visible_graph.keys_iterator.foreach(apply(gfx, _))
   196     }
   197     }
   197 
   198 
   198     def shape(m: Visualizer.Metrics, node: Graph_Display.Node): Shape =
   199     def shape(m: Visualizer.Metrics, node: Graph_Display.Node): Shape =
   199       if (node.is_dummy) Shapes.Dummy.shape(m, visualizer)
   200       if (node.is_dummy) Shapes.Dummy.shape(m, visualizer)
   200       else Shapes.Node.shape(m, visualizer, node)
   201       else Shapes.Node.shape(m, visualizer, node)