src/Tools/Graphview/src/shapes.scala
changeset 50474 6ee044e2d1a7
parent 50472 bad1a1ca61e1
child 50475 8cc351df4a23
equal deleted inserted replaced
50473:ca4088bf8365 50474:6ee044e2d1a7
    24     private val stroke =
    24     private val stroke =
    25       new BasicStroke(3, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)
    25       new BasicStroke(3, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)
    26 
    26 
    27     def shape(g: Graphics2D, visualizer: Visualizer, peer: Option[String]): Rectangle2D.Double =
    27     def shape(g: Graphics2D, visualizer: Visualizer, peer: Option[String]): Rectangle2D.Double =
    28     {
    28     {
    29       val caption = visualizer.Caption(peer.get)
       
    30       val bounds = g.getFontMetrics.getStringBounds(caption, g)
       
    31       val (x, y) = visualizer.Coordinates(peer.get)
    29       val (x, y) = visualizer.Coordinates(peer.get)
    32 
    30       val bounds = g.getFontMetrics.getStringBounds(visualizer.Caption(peer.get), g)
    33       new Rectangle2D.Double(
    31       val w = bounds.getWidth + visualizer.parameters.pad_x
    34         x -(bounds.getWidth / 2 + 25),
    32       val h = bounds.getHeight + visualizer.parameters.pad_y
    35         y -(bounds.getHeight / 2 + 5),
    33       new Rectangle2D.Double(x - (w / 2), y - (h / 2), w, h)
    36         bounds.getWidth + 50,
       
    37         bounds.getHeight + 10
       
    38       )
       
    39     }
    34     }
    40 
    35 
    41     def paint(g: Graphics2D, visualizer: Visualizer, peer: Option[String])
    36     def paint(g: Graphics2D, visualizer: Visualizer, peer: Option[String])
    42     {
    37     {
    43       val caption = visualizer.Caption(peer.get)
    38       val caption = visualizer.Caption(peer.get)
    59 
    54 
    60   object Dummy extends Node
    55   object Dummy extends Node
    61   {
    56   {
    62     private val stroke =
    57     private val stroke =
    63       new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)
    58       new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND)
    64     private val shape = new Rectangle2D.Double(-8, -8, 16, 16)
    59     private val shape = new Rectangle2D.Double(-5, -5, 10, 10)
    65     private val identity = new AffineTransform()
    60     private val identity = new AffineTransform()
    66 
    61 
    67     def shape(g: Graphics2D, visualizer: Visualizer, peer: Option[String]): Shape = shape
    62     def shape(g: Graphics2D, visualizer: Visualizer, peer: Option[String]): Shape = shape
    68 
    63 
    69     def paint(g: Graphics2D, visualizer: Visualizer, peer: Option[String]): Unit =
    64     def paint(g: Graphics2D, visualizer: Visualizer, peer: Option[String]): Unit =