# HG changeset patch # User wenzelm # Date 1420315113 -3600 # Node ID abe4c7cdac0e4b50f97cabdb2168fe1c0c6b7700 # Parent 50a3d663333af447fc0cc40ebdd1f18d33df2c61 tuned; diff -r 50a3d663333a -r abe4c7cdac0e src/Tools/Graphview/graph_panel.scala --- a/src/Tools/Graphview/graph_panel.scala Sat Jan 03 20:51:10 2015 +0100 +++ b/src/Tools/Graphview/graph_panel.scala Sat Jan 03 20:58:33 2015 +0100 @@ -89,14 +89,14 @@ revalidate() } - override def paint(g: Graphics2D) + override def paint(gfx: Graphics2D) { - super.paintComponent(g) - g.setColor(visualizer.background_color) - g.fillRect(0, 0, peer.getWidth, peer.getHeight) - g.transform(Transform()) + super.paintComponent(gfx) + gfx.setColor(visualizer.background_color) + gfx.fillRect(0, 0, peer.getWidth, peer.getHeight) + gfx.transform(Transform()) - visualizer.Drawer.paint_all_visible(g, true) + visualizer.Drawer.paint_all_visible(gfx, true) } } private val paint_panel = new Paint_Panel diff -r 50a3d663333a -r abe4c7cdac0e src/Tools/Graphview/shapes.scala --- a/src/Tools/Graphview/shapes.scala Sat Jan 03 20:51:10 2015 +0100 +++ b/src/Tools/Graphview/shapes.scala Sat Jan 03 20:58:33 2015 +0100 @@ -31,22 +31,22 @@ new Rectangle2D.Double((x - (w / 2)).floor, (y - (h / 2)).floor, w.ceil, h.ceil) } - def paint(g: Graphics2D, visualizer: Visualizer, node: Graph_Display.Node) + def paint(gfx: Graphics2D, visualizer: Visualizer, node: Graph_Display.Node) { - val m = Visualizer.Metrics(g) + val m = Visualizer.Metrics(gfx) val s = shape(m, visualizer, node) val c = visualizer.node_color(node) val bounds = m.string_bounds(node.toString) - g.setColor(c.background) - g.fill(s) + gfx.setColor(c.background) + gfx.fill(s) - g.setColor(c.border) - g.setStroke(default_stroke) - g.draw(s) + gfx.setColor(c.border) + gfx.setStroke(default_stroke) + gfx.draw(s) - g.setColor(c.foreground) - g.drawString(node.toString, + gfx.setColor(c.foreground) + gfx.drawString(node.toString, (s.getCenterX - bounds.getWidth / 2).round.toInt, (s.getCenterY - bounds.getHeight / 2 + m.ascent).round.toInt) } @@ -62,25 +62,25 @@ new Rectangle2D.Double(- w, - w, 2 * w, 2 * w) } - def paint(g: Graphics2D, visualizer: Visualizer, node: Graph_Display.Node): Unit = - paint_transformed(g, visualizer, node, identity) + def paint(gfx: Graphics2D, visualizer: Visualizer, node: Graph_Display.Node): Unit = + paint_transformed(gfx, visualizer, node, identity) - def paint_transformed(g: Graphics2D, visualizer: Visualizer, + def paint_transformed(gfx: Graphics2D, visualizer: Visualizer, node: Graph_Display.Node, at: AffineTransform) { - val m = Visualizer.Metrics(g) + val m = Visualizer.Metrics(gfx) val s = shape(m, visualizer, node) val c = visualizer.node_color(node) - g.setStroke(default_stroke) - g.setColor(c.border) - g.draw(at.createTransformedShape(s)) + gfx.setStroke(default_stroke) + gfx.setColor(c.border) + gfx.draw(at.createTransformedShape(s)) } } object Straight_Edge { - def paint(g: Graphics2D, visualizer: Visualizer, + def paint(gfx: Graphics2D, visualizer: Visualizer, edge: Graph_Display.Edge, head: Boolean, dummies: Boolean) { val (fx, fy) = visualizer.Coordinates(edge._1) @@ -101,17 +101,18 @@ ds.foreach({ case (x, y) => { val at = AffineTransform.getTranslateInstance(x, y) - Dummy.paint_transformed(g, visualizer, Graph_Display.Node.dummy, at) + Dummy.paint_transformed(gfx, visualizer, Graph_Display.Node.dummy, at) } }) } - g.setStroke(default_stroke) - g.setColor(visualizer.edge_color(edge)) - g.draw(path) + gfx.setStroke(default_stroke) + gfx.setColor(visualizer.edge_color(edge)) + gfx.draw(path) if (head) - Arrow_Head.paint(g, path, visualizer.Drawer.shape(Visualizer.Metrics(g), edge._2)) + Arrow_Head.paint(gfx, path, + visualizer.Drawer.shape(Visualizer.Metrics(gfx), edge._2)) } } @@ -119,7 +120,7 @@ { private val slack = 0.1 - def paint(g: Graphics2D, visualizer: Visualizer, + def paint(gfx: Graphics2D, visualizer: Visualizer, edge: Graph_Display.Edge, head: Boolean, dummies: Boolean) { val (fx, fy) = visualizer.Coordinates(edge._1) @@ -131,7 +132,7 @@ visualizer.Coordinates(edge).filter({ case (_, y) => min < y && y < max }) } - if (ds.isEmpty) Straight_Edge.paint(g, visualizer, edge, head, dummies) + if (ds.isEmpty) Straight_Edge.paint(gfx, visualizer, edge, head, dummies) else { val path = new GeneralPath(Path2D.WIND_EVEN_ODD, ds.length + 2) path.moveTo(fx, fy) @@ -160,17 +161,18 @@ ds.foreach({ case (x, y) => { val at = AffineTransform.getTranslateInstance(x, y) - Dummy.paint_transformed(g, visualizer, Graph_Display.Node.dummy, at) + Dummy.paint_transformed(gfx, visualizer, Graph_Display.Node.dummy, at) } }) } - g.setStroke(default_stroke) - g.setColor(visualizer.edge_color(edge)) - g.draw(path) + gfx.setStroke(default_stroke) + gfx.setColor(visualizer.edge_color(edge)) + gfx.draw(path) if (head) - Arrow_Head.paint(g, path, visualizer.Drawer.shape(Visualizer.Metrics(g), edge._2)) + Arrow_Head.paint(gfx, path, + visualizer.Drawer.shape(Visualizer.Metrics(gfx), edge._2)) } } } @@ -231,7 +233,7 @@ } } - def paint(g: Graphics2D, path: GeneralPath, shape: Shape) + def paint(gfx: Graphics2D, path: GeneralPath, shape: Shape) { position(path, shape) match { case None => @@ -243,8 +245,7 @@ arrow.lineTo(-10, -4) arrow.lineTo(0, 0) arrow.transform(at) - - g.fill(arrow) + gfx.fill(arrow) } } } diff -r 50a3d663333a -r abe4c7cdac0e src/Tools/Graphview/visualizer.scala --- a/src/Tools/Graphview/visualizer.scala Sat Jan 03 20:51:10 2015 +0100 +++ b/src/Tools/Graphview/visualizer.scala Sat Jan 03 20:58:33 2015 +0100 @@ -184,18 +184,18 @@ object Drawer { - def apply(g: Graphics2D, node: Graph_Display.Node): Unit = - if (!node.is_dummy) Shapes.Growing_Node.paint(g, visualizer, node) + def apply(gfx: Graphics2D, node: Graph_Display.Node): Unit = + if (!node.is_dummy) Shapes.Growing_Node.paint(gfx, visualizer, node) - def apply(g: Graphics2D, edge: Graph_Display.Edge, head: Boolean, dummies: Boolean): Unit = - Shapes.Cardinal_Spline_Edge.paint(g, visualizer, edge, head, dummies) + def apply(gfx: Graphics2D, edge: Graph_Display.Edge, head: Boolean, dummies: Boolean): Unit = + Shapes.Cardinal_Spline_Edge.paint(gfx, visualizer, edge, head, dummies) - def paint_all_visible(g: Graphics2D, dummies: Boolean) + def paint_all_visible(gfx: Graphics2D, dummies: Boolean) { - g.setFont(font) - g.setRenderingHints(rendering_hints) - model.visible_edges_iterator.foreach(apply(g, _, arrow_heads, dummies)) - model.visible_nodes_iterator.foreach(apply(g, _)) + gfx.setFont(font) + gfx.setRenderingHints(rendering_hints) + model.visible_edges_iterator.foreach(apply(gfx, _, arrow_heads, dummies)) + model.visible_nodes_iterator.foreach(apply(gfx, _)) } def shape(m: Visualizer.Metrics, node: Graph_Display.Node): Shape =