From 4e98f614282aae1518e8e7a8436fc227c10773f0 Mon Sep 17 00:00:00 2001 From: "Emden R. Gansner" Date: Wed, 17 Sep 2014 12:32:26 -0400 Subject: [PATCH] Add note concerning HTML strings in language description --- doc/info/lang.html | 5 +++- doc/infosrc/lang.2 | 5 +++- lib/pack/pack.c | 68 ++++++++++++++++++++++++++-------------------- 3 files changed, 47 insertions(+), 31 deletions(-) diff --git a/doc/info/lang.html b/doc/info/lang.html index cfb1abf73..fc852b26e 100644 --- a/doc/info/lang.html +++ b/doc/info/lang.html @@ -122,7 +122,7 @@ digits ([0-9]), not beginning with a digit;
  • a numeral [-]?(.[0-9]+ | [0-9]+(.[0-9]*)? );
  • any double-quoted string ("...") possibly containing escaped quotes (\")1; -
  • an HTML string (<...>). +
  • an HTML string (<...>). An ID is just a string; the lack of quote characters in the first two forms is just for simplicity. There is no semantic difference between @@ -134,6 +134,9 @@ characters are allowed. In addition, the content must be legal XML, so that the special XML escape sequences for ", &, <, and > may be necessary in order to embed these characters in attribute values or raw text. +As an ID, an HTML string can be any legal XML string. However, if used +as a label attribute, it is interpreted specially and must follow the syntax +for HTML-like labels.

    Both quoted strings and HTML strings are scanned as a unit, so any embedded comments will be treated as part of the strings. diff --git a/doc/infosrc/lang.2 b/doc/infosrc/lang.2 index 4b6175c1f..188765c00 100644 --- a/doc/infosrc/lang.2 +++ b/doc/infosrc/lang.2 @@ -13,7 +13,7 @@ digits ([0-9]), not beginning with a digit;

  • a numeral [-]?(.[0-9]+ | [0-9]+(.[0-9]*)? );
  • any double-quoted string ("...") possibly containing escaped quotes (\")1; -
  • an HTML string (<...>). +
  • an HTML string (<...>). An ID is just a string; the lack of quote characters in the first two forms is just for simplicity. There is no semantic difference between @@ -25,6 +25,9 @@ characters are allowed. In addition, the content must be legal XML, so that the special XML escape sequences for ", &, <, and > may be necessary in order to embed these characters in attribute values or raw text. +As an ID, an HTML string can be any legal XML string. However, if used +as a label attribute, it is interpreted specially and must follow the syntax +for HTML-like labels.

    Both quoted strings and HTML strings are scanned as a unit, so any embedded comments will be treated as part of the strings. diff --git a/lib/pack/pack.c b/lib/pack/pack.c index 229857b45..a60f43442 100644 --- a/lib/pack/pack.c +++ b/lib/pack/pack.c @@ -462,14 +462,16 @@ fits(int x, int y, ginfo * info, PointSet * ps, point * place, int step, boxf* b * graph is constructed where it will be. */ static void -placeFixed(ginfo * info, PointSet * ps, point * place, point center) +placeFixed(ginfo * info, PointSet * ps, point * place) { point *cells = info->cells; int n = info->nc; int i; - place->x = -center.x; - place->y = -center.y; + /* place->x = -center.x; */ + /* place->y = -center.y; */ + place->x = 0; + place->y = 0; for (i = 0; i < n; i++) { insertPS(ps, *cells++); @@ -487,22 +489,22 @@ placeFixed(ginfo * info, PointSet * ps, point * place, point center) * First graph (i == 0) is centered on the origin if possible. */ static void -placeGraph(int i, ginfo * info, PointSet * ps, point * place, int step, - int margin, boxf* bbs) +placeGraph(int tryCenter, ginfo * info, PointSet * ps, point * place, int step, + int margin, boxf* bbs, int cx, int cy) { int x, y; int W, H; int bnd; boxf bb = bbs[info->index]; - if (i == 0) { + if (tryCenter) { W = GRID(bb.UR.x - bb.LL.x + 2 * margin, step); H = GRID(bb.UR.y - bb.LL.y + 2 * margin, step); if (fits(-W / 2, -H / 2, info, ps, place, step, bbs)) return; } - if (fits(0, 0, info, ps, place, step, bbs)) + if (fits(cx, cy, info, ps, place, step, bbs)) return; W = ceil(bb.UR.x - bb.LL.x); H = ceil(bb.UR.y - bb.LL.y); @@ -511,19 +513,19 @@ placeGraph(int i, ginfo * info, PointSet * ps, point * place, int step, x = 0; y = -bnd; for (; x < bnd; x++) - if (fits(x, y, info, ps, place, step, bbs)) + if (fits(cx+x, cy+y, info, ps, place, step, bbs)) return; for (; y < bnd; y++) - if (fits(x, y, info, ps, place, step, bbs)) + if (fits(cx+x, cy+y, info, ps, place, step, bbs)) return; for (; x > -bnd; x--) - if (fits(x, y, info, ps, place, step, bbs)) + if (fits(cx+x, cy+y, info, ps, place, step, bbs)) return; for (; y > -bnd; y--) - if (fits(x, y, info, ps, place, step, bbs)) + if (fits(cx+x, cy+y, info, ps, place, step, bbs)) return; for (; x < 0; x++) - if (fits(x, y, info, ps, place, step, bbs)) + if (fits(cx+x, cy+y, info, ps, place, step, bbs)) return; } } else { @@ -531,19 +533,19 @@ placeGraph(int i, ginfo * info, PointSet * ps, point * place, int step, y = 0; x = -bnd; for (; y > -bnd; y--) - if (fits(x, y, info, ps, place, step, bbs)) + if (fits(cx+x, cy+y, info, ps, place, step, bbs)) return; for (; x < bnd; x++) - if (fits(x, y, info, ps, place, step, bbs)) + if (fits(cx+x, cy+y, info, ps, place, step, bbs)) return; for (; y < bnd; y++) - if (fits(x, y, info, ps, place, step, bbs)) + if (fits(cx+x, cy+y, info, ps, place, step, bbs)) return; for (; x > -bnd; x--) - if (fits(x, y, info, ps, place, step, bbs)) + if (fits(cx+x, cy+y, info, ps, place, step, bbs)) return; for (; y > 0; y--) - if (fits(x, y, info, ps, place, step, bbs)) + if (fits(cx+x, cy+y, info, ps, place, step, bbs)) return; } } @@ -762,8 +764,8 @@ polyRects(int ng, boxf* gs, pack_info * pinfo) ps = newPS(); places = N_NEW(ng, point); for (i = 0; i < ng; i++) - placeGraph(i, sinfo[i], ps, places + (sinfo[i]->index), - stepSize, pinfo->margin, gs); + placeGraph(i==0, sinfo[i], ps, places + (sinfo[i]->index), + stepSize, pinfo->margin, gs, 0, 0); free(sinfo); for (i = 0; i < ng; i++) @@ -864,10 +866,18 @@ polyGraphs(int ng, Agraph_t ** gs, Agraph_t * root, pack_info * pinfo) info = N_NEW(ng, ginfo); for (i = 0; i < ng; i++) { Agraph_t *g = gs[i]; + point ctr; info[i].index = i; + + if (fixed && fixed[i]) { + ctr.x = ROUND(GD_bb(g).LL.x); + ctr.y = ROUND(GD_bb(g).LL.y); + } + else + ctr = center; if (pinfo->mode == l_graph) - genBox(GD_bb(g), info + i, stepSize, pinfo->margin, center, agnameof(g)); - else if (genPoly(root, gs[i], info + i, stepSize, pinfo, center)) { + genBox(GD_bb(g), info + i, stepSize, pinfo->margin, ctr, agnameof(g)); + else if (genPoly(root, gs[i], info + i, stepSize, pinfo, ctr)) { return 0; } } @@ -882,20 +892,20 @@ polyGraphs(int ng, Agraph_t ** gs, Agraph_t * root, pack_info * pinfo) ps = newPS(); places = N_NEW(ng, point); if (fixed) { + CELL(center,stepSize); for (i = 0; i < ng; i++) { - if (fixed[i]) - placeFixed(sinfo[i], ps, places + (sinfo[i]->index), - center); + if (fixed[sinfo[i]->index]) + placeFixed(sinfo[i], ps, places + (sinfo[i]->index)); } for (i = 0; i < ng; i++) { - if (!fixed[i]) - placeGraph(i, sinfo[i], ps, places + (sinfo[i]->index), - stepSize, pinfo->margin, bbs); + if (!fixed[sinfo[i]->index]) + placeGraph(0, sinfo[i], ps, places + (sinfo[i]->index), + stepSize, pinfo->margin, bbs, center.x, center.y); } } else { for (i = 0; i < ng; i++) - placeGraph(i, sinfo[i], ps, places + (sinfo[i]->index), - stepSize, pinfo->margin, bbs); + placeGraph(i==0, sinfo[i], ps, places + (sinfo[i]->index), + stepSize, pinfo->margin, bbs, 0, 0); } free(sinfo); -- 2.40.0