Skip to content

Commit ba090ec

Browse files
committed
Layout labels on edges
Labels alongside edges were centered in respect to each other, this has been changed so it looks a bit cleaner.
1 parent 0b58d58 commit ba090ec

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

src/dotnode.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ static void writeBoxMemberList(TextStream &t,
193193
}
194194
}
195195

196-
QCString DotNode::convertLabel(const QCString &l, bool htmlLike)
196+
QCString DotNode::convertLabel(const QCString &l, bool htmlLike, bool tableLike)
197197
{
198198
QCString bBefore("\\_/<({[: =-+@%#~?$"); // break before character set
199199
QCString bAfter(">]),:;|"); // break after character set
@@ -206,16 +206,30 @@ QCString DotNode::convertLabel(const QCString &l, bool htmlLike)
206206
int sinceLast=0;
207207
int foldLen = Config_getInt(DOT_WRAP_THRESHOLD); // ideal text length
208208
QCString br;
209+
QCString br1;
210+
if (tableLike)
211+
{
212+
result += "<<TABLE CELLBORDER=\"0\" BORDER=\"0\"><TR><TD VALIGN=\"top\" ALIGN=\"LEFT\" CELLPADDING=\"1\" CELLSPACING=\"0\">";
213+
}
209214
if (htmlLike)
215+
{
210216
br = "<BR ALIGN=\"LEFT\"/>";
217+
}
218+
else if (tableLike)
219+
{
220+
br1 = "</TD></TR>\n<TR><TD VALIGN=\"top\" ALIGN=\"LEFT\" CELLPADDING=\"1\" CELLSPACING=\"0\">";
221+
br = br1 + "&nbsp;&nbsp;";
222+
}
211223
else
224+
{
212225
br = "\\l";
226+
}
213227
while (idx < p.length())
214228
{
215229
char c = p[idx++];
216230
char cs[2] = { c, 0 };
217231
const char *replacement = cs;
218-
if (htmlLike)
232+
if (htmlLike || tableLike)
219233
{
220234
switch(c)
221235
{
@@ -246,7 +260,14 @@ QCString DotNode::convertLabel(const QCString &l, bool htmlLike)
246260
// boxes and at the same time prevent ugly breaks
247261
if (c=='\n')
248262
{
249-
result+=replacement;
263+
if (tableLike)
264+
{
265+
result+=br1;
266+
}
267+
else
268+
{
269+
result+=replacement;
270+
}
250271
foldLen = (3*foldLen+sinceLast+2)/4;
251272
sinceLast=1;
252273
}
@@ -284,6 +305,10 @@ QCString DotNode::convertLabel(const QCString &l, bool htmlLike)
284305
{
285306
result = result.stripWhiteSpace();
286307
}
308+
if (tableLike)
309+
{
310+
result += "</TD></TR>\n</TABLE>>";
311+
}
287312
return result;
288313
}
289314

@@ -609,7 +634,7 @@ void DotNode::writeArrow(TextStream &t,
609634
t << ",tooltip=\" \""; // space in tooltip is required otherwise still something like 'Node0 -> Node1' is used
610635
if (!ei->label().isEmpty())
611636
{
612-
t << ",label=\" " << convertLabel(ei->label()) << "\",fontcolor=\"grey\" ";
637+
t << ",label=" << convertLabel(ei->label(),false,true) << " ,fontcolor=\"grey\" ";
613638
}
614639
if (Config_getBool(UML_LOOK) &&
615640
eProps->arrowStyleMap[ei->color()] &&

src/dotnode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class DotNode
6969
public:
7070
static constexpr auto placeholderUrl = "-";
7171
static void deleteNodes(DotNode* node);
72-
static QCString convertLabel(const QCString& , bool htmlLike=false);
72+
static QCString convertLabel(const QCString& , bool htmlLike=false, bool tableLike=false);
7373
DotNode(DotGraph *graph,const QCString &lab,const QCString &tip,const QCString &url,
7474
bool rootNode=FALSE,const ClassDef *cd=nullptr);
7575

0 commit comments

Comments
 (0)