src/Tools/Graphview/visualizer.scala
changeset 59305 b5e33012180e
parent 59303 15cd9bcd6ddb
child 59313 d7f4f46e9a59
equal deleted inserted replaced
59304:848e27e4ac37 59305:b5e33012180e
     9 
     9 
    10 
    10 
    11 import isabelle._
    11 import isabelle._
    12 
    12 
    13 import java.awt.{Font, Color, Shape, Graphics2D}
    13 import java.awt.{Font, Color, Shape, Graphics2D}
    14 import java.awt.geom.Rectangle2D
    14 import java.awt.geom.{Point2D, Rectangle2D}
    15 import javax.swing.JComponent
    15 import javax.swing.JComponent
    16 
    16 
    17 
    17 
    18 class Visualizer(options: => Options, val model: Model)
    18 class Visualizer(options: => Options, val model: Model)
    19 {
    19 {
    29   def metrics: Metrics = layout.metrics
    29   def metrics: Metrics = layout.metrics
    30   def visible_graph: Graph_Display.Graph = layout.input_graph
    30   def visible_graph: Graph_Display.Graph = layout.input_graph
    31 
    31 
    32   def translate_vertex(v: Layout.Vertex, dx: Double, dy: Double): Unit =
    32   def translate_vertex(v: Layout.Vertex, dx: Double, dy: Double): Unit =
    33     _layout = _layout.translate_vertex(v, dx, dy)
    33     _layout = _layout.translate_vertex(v, dx, dy)
       
    34 
       
    35   def find_node(at: Point2D): Option[Graph_Display.Node] =
       
    36     layout.output_graph.iterator.collectFirst({
       
    37       case (Layout.Node(node), _) if Shapes.Node.shape(visualizer, node).contains(at) => node
       
    38     })
       
    39 
       
    40   def find_dummy(at: Point2D): Option[Layout.Dummy] =
       
    41     layout.output_graph.iterator.collectFirst({
       
    42       case (dummy: Layout.Dummy, (d, _)) if Shapes.Dummy.shape(visualizer, d).contains(at) => dummy
       
    43     })
    34 
    44 
    35   def bounding_box(): Rectangle2D.Double =
    45   def bounding_box(): Rectangle2D.Double =
    36   {
    46   {
    37     var x0 = 0.0
    47     var x0 = 0.0
    38     var y0 = 0.0
    48     var y0 = 0.0