src/Tools/Graphview/graph_file.scala
changeset 59443 5b552b4f63a5
parent 59441 ab2c3597f1d3
child 59459 985fc55e9f27
equal deleted inserted replaced
59442:9f45b95d3543 59443:5b552b4f63a5
    13 import java.awt.{Color, Graphics2D}
    13 import java.awt.{Color, Graphics2D}
    14 
    14 
    15 
    15 
    16 object Graph_File
    16 object Graph_File
    17 {
    17 {
    18   def write(visualizer: Visualizer, file: JFile)
    18   def write(file: JFile, visualizer: Visualizer)
    19   {
    19   {
    20     val box = visualizer.bounding_box()
    20     val box = visualizer.bounding_box()
    21     val w = box.width.ceil.toInt
    21     val w = box.width.ceil.toInt
    22     val h = box.height.ceil.toInt
    22     val h = box.height.ceil.toInt
    23 
    23 
    32     val name = file.getName
    32     val name = file.getName
    33     if (name.endsWith(".png")) Graphics_File.write_png(file, paint _, w, h)
    33     if (name.endsWith(".png")) Graphics_File.write_png(file, paint _, w, h)
    34     else if (name.endsWith(".pdf")) Graphics_File.write_pdf(file, paint _, w, h)
    34     else if (name.endsWith(".pdf")) Graphics_File.write_pdf(file, paint _, w, h)
    35     else error("Bad type of file: " + quote(name) + " (.png or .pdf expected)")
    35     else error("Bad type of file: " + quote(name) + " (.png or .pdf expected)")
    36   }
    36   }
       
    37 
       
    38   def write(options: Options, file: JFile, graph: Graph_Display.Graph)
       
    39   {
       
    40     val model = new Model(graph.transitive_reduction_acyclic)
       
    41 
       
    42     val the_options = options
       
    43     val visualizer = new Visualizer(model) { def options = the_options }
       
    44     visualizer.update_layout()
       
    45 
       
    46     write(file, visualizer)
       
    47   }
    37 }
    48 }