src/Tools/Graphview/shapes.scala
changeset 73340 0ffcad1f6130
parent 62812 ce22e5c3d4ce
child 73359 d8a0e996614b
equal deleted inserted replaced
73339:9efdebe24c65 73340:0ffcad1f6130
    21     new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)
    21     new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)
    22 
    22 
    23   def shape(info: Layout.Info): Rectangle2D.Double =
    23   def shape(info: Layout.Info): Rectangle2D.Double =
    24     new Rectangle2D.Double(info.x - info.width2, info.y - info.height2, info.width, info.height)
    24     new Rectangle2D.Double(info.x - info.width2, info.y - info.height2, info.width, info.height)
    25 
    25 
    26   def highlight_node(gfx: Graphics2D, graphview: Graphview, node: Graph_Display.Node)
    26   def highlight_node(gfx: Graphics2D, graphview: Graphview, node: Graph_Display.Node): Unit =
    27   {
    27   {
    28     val metrics = graphview.metrics
    28     val metrics = graphview.metrics
    29     val extra = metrics.char_width
    29     val extra = metrics.char_width
    30     val info = graphview.layout.get_node(node)
    30     val info = graphview.layout.get_node(node)
    31 
    31 
    35       info.y - info.height2 - extra,
    35       info.y - info.height2 - extra,
    36       info.width + 2 * extra,
    36       info.width + 2 * extra,
    37       info.height + 2 * extra))
    37       info.height + 2 * extra))
    38   }
    38   }
    39 
    39 
    40   def paint_node(gfx: Graphics2D, graphview: Graphview, node: Graph_Display.Node)
    40   def paint_node(gfx: Graphics2D, graphview: Graphview, node: Graph_Display.Node): Unit =
    41   {
    41   {
    42     val metrics = graphview.metrics
    42     val metrics = graphview.metrics
    43     val info = graphview.layout.get_node(node)
    43     val info = graphview.layout.get_node(node)
    44     val c = graphview.node_color(node)
    44     val c = graphview.node_color(node)
    45     val s = shape(info)
    45     val s = shape(info)
    64       gfx.drawString(Word.bidi_override(line), x, y)
    64       gfx.drawString(Word.bidi_override(line), x, y)
    65       y += metrics.height.ceil.toInt
    65       y += metrics.height.ceil.toInt
    66     }
    66     }
    67   }
    67   }
    68 
    68 
    69   def paint_dummy(gfx: Graphics2D, graphview: Graphview, info: Layout.Info)
    69   def paint_dummy(gfx: Graphics2D, graphview: Graphview, info: Layout.Info): Unit =
    70   {
    70   {
    71     gfx.setStroke(default_stroke)
    71     gfx.setStroke(default_stroke)
    72     gfx.setColor(graphview.dummy_color)
    72     gfx.setColor(graphview.dummy_color)
    73     gfx.draw(shape(info))
    73     gfx.draw(shape(info))
    74   }
    74   }
    75 
    75 
    76   object Straight_Edge
    76   object Straight_Edge
    77   {
    77   {
    78     def paint(gfx: Graphics2D, graphview: Graphview, edge: Graph_Display.Edge)
    78     def paint(gfx: Graphics2D, graphview: Graphview, edge: Graph_Display.Edge): Unit =
    79     {
    79     {
    80       val p = graphview.layout.get_node(edge._1)
    80       val p = graphview.layout.get_node(edge._1)
    81       val q = graphview.layout.get_node(edge._2)
    81       val q = graphview.layout.get_node(edge._2)
    82       val ds =
    82       val ds =
    83       {
    83       {
   103 
   103 
   104   object Cardinal_Spline_Edge
   104   object Cardinal_Spline_Edge
   105   {
   105   {
   106     private val slack = 0.1
   106     private val slack = 0.1
   107 
   107 
   108     def paint(gfx: Graphics2D, graphview: Graphview, edge: Graph_Display.Edge)
   108     def paint(gfx: Graphics2D, graphview: Graphview, edge: Graph_Display.Edge): Unit =
   109     {
   109     {
   110       val p = graphview.layout.get_node(edge._1)
   110       val p = graphview.layout.get_node(edge._1)
   111       val q = graphview.layout.get_node(edge._2)
   111       val q = graphview.layout.get_node(edge._2)
   112       val ds =
   112       val ds =
   113       {
   113       {
   208         case None => None
   208         case None => None
   209         case Some(line) => binary_search(line, shape)
   209         case Some(line) => binary_search(line, shape)
   210       }
   210       }
   211     }
   211     }
   212 
   212 
   213     def paint(gfx: Graphics2D, path: GeneralPath, shape: Shape)
   213     def paint(gfx: Graphics2D, path: GeneralPath, shape: Shape): Unit =
   214     {
   214     {
   215       position(path, shape) match {
   215       position(path, shape) match {
   216         case None =>
   216         case None =>
   217         case Some(at) =>
   217         case Some(at) =>
   218           val arrow = new GeneralPath(Path2D.WIND_EVEN_ODD, 3)
   218           val arrow = new GeneralPath(Path2D.WIND_EVEN_ODD, 3)