Number: 254
Title: More flexible handling of labels.
Submitter: Eivind Tagseth
Date: Fri Jan 31 12:02:43 2003
Subsys: Dot
Version: 1.8.10
System: *-*-
Severity: minor
Adding my custom shape, the text label is always centered on my shape. Since my shape is doesn't have a white "hole" in it, this didn't work out very well.

Ideally, I'd like to specify "labelloc=b" as with a subgraph(?).
[erg] Rather than going with full user control of label placement, which seems fragile, it would seem better to do the node as a record, with a top cell supplied by a glyph and the bottom by a simple text label. This will avoid having the label overlap other parts of the graph, and seems closer to what is desired here.
Not really sure what I was doing, this patch may be completely wrong or undesired. It's what I ended up with though, and maybe you'll like it or find it useful.

The patch adds a new keyword for poly-style shapes (custom seems to be one of those), "labeloffset".

Adding labeloffset="45,-7" will adjust the label's coordinates relative to the normal placement accordingly.

I've only tested this with gd-output, but if I'm not mistaken it should work for others as well. One bug with it is that the edges may be drawn over the label, but that's ok by me.

diff -ur graphviz-1.8.10-r4/work/graphviz-1.8.10/dotneato/common/shapes.c graphviz-1.8.10-r5/work/graphviz-1.8.10/dotneato/common/shapes.c
--- graphviz-1.8.10-r4/work/graphviz-1.8.10/dotneato/common/shapes.c	2002-09-20 21:07:57.000000000 +0200
+++ graphviz-1.8.10-r5/work/graphviz-1.8.10/dotneato/common/shapes.c	2003-01-31 16:40:29.000000000 +0100
@@ -729,6 +730,14 @@

if (style & AUXLABELS) Mlabel_hack(n); n->u.label->p = n->u.coord; + if (agget(n, "labeloffset")) { + char *str; + point offset; + str = agget(n, "labeloffset"); + if (sscanf(str, "%d,%d", &offset.x, &offset.y) == 2) { + n->u.label->p = add_points(n->u.label->p, offset); + } + } emit_label(n->u.label,n->graph); CodeGen->end_context(); CodeGen->end_node();

Owner: erg
Status: Request