def highlight_node(gfx: Graphics2D, graphview: Graphview, node: Graph_Display.Node): Unit = { val metrics = graphview.metrics val extra = metrics.average_width val info = graphview.layout.get_node(node)
def paint_node(gfx: Graphics2D, graphview: Graphview, node: Graph_Display.Node): Unit = { val metrics = graphview.metrics val info = graphview.layout.get_node(node) val c = graphview.node_color(node) val s = shape(info)
val text_width =
info.lines.foldLeft(0.0) { case (w, line) => w max metrics.string_bounds(line).getWidth } val text_height =
(info.lines.length max 1) * metrics.height.ceil val x = (s.getCenterX - text_width / 2).round.toInt var y = (s.getCenterY - text_height / 2 + metrics.ascent).round.toInt for (line <- info.lines) {
gfx.drawString(Word.bidi_override(line), x, y)
y += metrics.height.ceil.toInt
}
}
object Straight_Edge { def paint(gfx: Graphics2D, graphview: Graphview, edge: Graph_Display.Edge): Unit = { val p = graphview.layout.get_node(edge._1) val q = graphview.layout.get_node(edge._2) val ds = { val a = p.y min q.y val b = p.y max q.y
graphview.layout.dummies_iterator(edge).filter(d => a < d.y && d.y < b).toList
} val path = new GeneralPath(Path2D.WIND_EVEN_ODD, ds.length + 2)
def paint(gfx: Graphics2D, graphview: Graphview, edge: Graph_Display.Edge): Unit = { val p = graphview.layout.get_node(edge._1) val q = graphview.layout.get_node(edge._2) val ds = { val a = p.y min q.y val b = p.y max q.y
graphview.layout.dummies_iterator(edge).filter(d => a < d.y && d.y < b).toList
}
if (ds.isEmpty) Straight_Edge.paint(gfx, graphview, edge) else { val path = new GeneralPath(Path2D.WIND_EVEN_ODD, ds.length + 2)
path.moveTo(p.x, p.y)
val coords = p :: ds ::: List(q) val dx = coords(2).x - coords(0).x val dy = coords(2).y - coords(0).y
val (dx2, dy2) =
coords.sliding(3).foldLeft((dx, dy)) { case ((dx, dy), Seq(l, m, r)) => val dx2 = r.x - l.x val dy2 = r.y - l.y
path.curveTo(
l.x + slack * dx, l.y + slack * dy,
m.x - slack * dx2, m.y - slack * dy2,
m.x, m.y)
(dx2, dy2) case (p, _) => p
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.