author | wenzelm |
Mon, 04 Nov 2024 21:05:11 +0100 | |
changeset 81343 | b5b0c398cdec |
parent 81340 | 30f7eb65d679 |
permissions | -rw-r--r-- |
59290 | 1 |
/* Title: Tools/Graphview/metrics.scala |
2 |
Author: Makarius |
|
3 |
||
4 |
Physical metrics for layout and painting. |
|
5 |
*/ |
|
6 |
||
7 |
package isabelle.graphview |
|
8 |
||
9 |
||
10 |
import isabelle._ |
|
11 |
||
81340 | 12 |
import java.awt.Font |
59290 | 13 |
|
14 |
||
75393 | 15 |
object Metrics { |
59290 | 16 |
def apply(font: Font): Metrics = new Metrics(font) |
81340 | 17 |
val default: Metrics = apply(Font_Metric.default.font) |
59290 | 18 |
} |
19 |
||
81340 | 20 |
class Metrics private(font: Font) extends Font_Metric(font = font) { |
21 |
val ascent: Double = font.getLineMetrics("", context).getAscent |
|
59290 | 22 |
|
81340 | 23 |
def gap: Double = (average_width * 3).ceil |
59302
4d985afc0565
explict layout graph structure, with dummies and coordinates;
wenzelm
parents:
59293
diff
changeset
|
24 |
|
81340 | 25 |
def dummy_size2: Double = (average_width / 2).ceil |
59384 | 26 |
|
27 |
def node_width2(lines: List[String]): Double = |
|
81340 | 28 |
((lines.foldLeft(0.0)({ case (w, s) => w max string_width(s) }) + 2 * average_width) / 2).ceil |
59302
4d985afc0565
explict layout graph structure, with dummies and coordinates;
wenzelm
parents:
59293
diff
changeset
|
29 |
|
59384 | 30 |
def node_height2(num_lines: Int): Double = |
81340 | 31 |
((height.ceil * (num_lines max 1) + average_width) / 2).ceil |
59384 | 32 |
|
33 |
def level_height2(num_lines: Int, num_edges: Int): Double = |
|
34 |
(node_height2(num_lines) + gap) max (node_height2(1) * (num_edges max 5)) |
|
59290 | 35 |
} |