Number: 372
Title: labeldistance does not affect normal labels in dot
Submitter: Andrew Sadler
Date: Tue Oct 28 07:50:39 2003
Subsys: Dot
Version: 1.10
System: *-*-
Severity: minor
Problem:
The manual states that the labeldistance property of an edge can be used to specify the distance of the label from the edge.

It infact only(?) affects the port labels.

I'd like to use this feature to make my labels in dot graphs appear closer to their edges. (especialy useful if your edge labels are actual LaTeX formulas which will not be as wide when printed as they appear to "dot").
Input:

digraph partition {
        edge [labeldistance=10000.0];
        z1 [label="$X$"];
        subgraph{rank=same;
                z2 [label="$Y$"];
                z3 [label="$Z$"];
        };
        alpha [label="$\Alpha$"];

        alpha -> alpha [label="$\{7\}$"];
        z1 -> z1  [label="$\{1,4\}$"];
        z2 -> z2  [label="$\{2,3\}$"];
        z3 -> z3  [label="$\{5,6\}$"];

        z1 -> z2  [label="$\{1\}$"];
        z2 -> z1  [label="$\{2,3\}$"];
        alpha -> z3  [label="$\{7\}$"];
        z1 -> alpha [label="$\{1,4\}$"];
        z2 -> alpha [label="$\{2,3\}$"];
        z3 -> alpha [label="$\{5,6\}$"];
}
Comments:
I've hijacked the labeldistance attribute and used it as an absolute value to be added to the label position.

I'll add the changes to grappa when I get a moment.
Fix:


--- dotsplines.c.orig   Tue Oct 28 12:50:41 2003
+++ dotsplines.c        Tue Oct 28 12:51:49 2003
@@ -376,7 +376,7 @@
        for (e = ND_out(n).list[0]; ED_edge_type(e) != NORMAL; e = ED_to_orig(e));
        dimen = ED_label(e)->dimen;
        width = GD_left_to_right(n->graph)? dimen.y : dimen.x;
-       ED_label(e)->p.x = ND_coord_i(n).x + POINTS(width/2.0);
+       ED_label(e)->p.x = ND_coord_i(n).x + POINTS(width/2.0) + late_double(e,E_labeldistance,0.0,-1000000.0);
        ED_label(e)->p.y = ND_coord_i(n).y;
 }

@@ -551,7 +551,7 @@ width = ED_label(e)->dimen.x; height = ED_label(e)->dimen.y; } - ED_label(e)->p.x = ND_coord_i(n).x + dx + POINTS(width/2.0); + ED_label(e)->p.x = ND_coord_i(n).x + dx + POINTS(width/2.0) + late_double(e,E_labeldistance,0.0,-1000000.0); ED_label(e)->p.y = ND_coord_i(n).y; if (POINTS (width) > stepx) dx += POINTS(width) - stepx; @@ -595,7 +595,7 @@ width = ED_label(e)->dimen.y; else width = ED_label(e)->dimen.x; - ED_label(e)->p.x = maxx + POINTS(width/2.0); + ED_label(e)->p.x = maxx + POINTS(width/2.0) + late_double(e,E_labeldistance,0.0,-1000000.0); ED_label(e)->p.y = ND_coord_i(n).y; if (POINTS (width) > stepx) dx += POINTS (width) - stepx;


Owner: *
Status: Request