42 #define DEFAULT_BORDER 1
43 #define DEFAULT_CELLPADDING 2
44 #define DEFAULT_CELLSPACING 2
57 static void printCell(
htmlcell_t * cp,
int ind);
101 if (savp->
size >= 0.0)
110 double center_x, left_x, right_x;
117 left_x = center_x - halfwidth_x;
118 right_x = center_x + halfwidth_x;
123 p_.
y = p.
y + (b.
UR.
y - b.
LL.
y) / 2.0;
126 for (i = 0; i < nspans; i++) {
128 switch (spans[i].just) {
133 p.
x = right_x - spans[i].
size;
137 p.
x = center_x - spans[i].
size / 2.0;
143 for (j = 0; j < spans[i].
nitems; j++) {
195 halfwidth_x = ((double) (tp->
box.
UR.
x - tp->
box.
LL.
x)) / 2.0;
203 static void doSide(
GVJ_t * job,
pointf p,
double wd,
double ht)
224 double delta = ((double) border) / 2.0;
249 unsigned short sides;
253 sptr[0] = sptr[1] =
NULL;
266 mkPts (AF+1, b, dp->
border);
323 double delta = ((double) dp->
border) / 2.0;
338 setFill(
GVJ_t * job,
char *color,
int angle,
int style,
char *clrs[2])
397 sprintf(intbuf,
"_%d", anchorId++);
420 if(obj->fld != save->fld) {free(obj->fld); obj->fld = save->fld;}
489 doSide(job, rule_pt, 0, rule_length);
500 else if (nextc && (nextc->
row != cp->
row)) {
511 if (nextc && (nextc->
row != cp->
row)) {
517 doSide(job, rule_pt, rule_length, 0);
534 pushFontInfo(env, tbl->
font, &savef);
542 anchor = initAnchor(job, env, &tbl->
data, pts, &saved);
563 emit_html_cell(job, *cells, env);
572 cells = tbl->
u.
n.cells;
574 while ((cp = *cells++)) {
576 emit_html_rules(job, cp, env, tbl->
data.
pencolor, *cells);
580 doBorder(job, &tbl->
data, pts);
585 endAnchor(job, &saved);
588 if (initAnchor(job, env, &tbl->
data, pts, &saved))
589 endAnchor(job, &saved);
593 popFontInfo(env, &savef);
642 inAnchor = initAnchor(job, env, &cp->
data, pts, &saved);
661 doBorder(job, &cp->
data, pts);
664 emit_html_tbl(job, cp->
child.
u.
tbl, env);
666 emit_html_img(job, cp->
child.
u.
img, env);
668 emit_html_txt(job, cp->
child.
u.
txt, env);
672 endAnchor(job, &saved);
675 if (initAnchor(job, env, &cp->
data, pts, &saved))
676 endAnchor(job, &saved);
686 static void allocObj(
GVJ_t * job)
697 obj->
u.
n = parent->
u.
n;
700 obj->
u.
g = parent->
u.
g;
706 obj->
u.
e = parent->
u.
e;
715 static void freeObj(
GVJ_t * job)
757 p.
y = tp->
pos.
y + (tp->
space.
y - heightOfLbl(lp))/ 2.0 - 1;
760 p.
y = tp->
pos.
y - (tp->
space.
y - heightOfLbl(lp))/ 2.0 - 1;
785 emit_html_tbl(job, tbl, &env);
787 emit_html_txt(job, lp->
u.
txt, &env);
815 for (i = 0; i < t->
nspans; i++) {
817 for (j = 0; j < tl->
nitems; j++) {
849 static void free_html_tbl(
htmltbl_t * tbl)
856 cells = tbl->
u.
n.cells;
861 free_html_cell(*cells);
864 free(tbl->
u.
n.cells);
873 free_html_tbl(lp->
u.
tbl);
912 cells = tp->
u.
n.cells;
913 while ((cp = *cells++)) {
914 if ((rv = portToCell(cp,
id)))
937 tp = portToTbl(lbl->
u.
tbl, pname);
970 info = info->tbls[0];
981 for (i = 0; (t = info->tbls[i]) != 0; i++)
990 b = flip_trans_box(b, ND_coord_i(n));
992 b = move_box(b, ND_coord_i(n));
1009 double mxfsize = 0.0;
1010 double curbline = 0.0;
1016 double maxoffset, mxysize;
1018 double prev_fsize = -1;
1019 char* prev_fname =
NULL;
1021 for (i = 0; i < ftxt->
nspans; i++) {
1044 if (prev_fsize == -1)
1045 prev_fsize = tf.
size;
1046 else if (tf.
size != prev_fsize) {
1050 if (prev_fname ==
NULL)
1051 prev_fname = tf.
name;
1052 else if (strcmp(tf.
name,prev_fname)) {
1059 for (i = 0; i < ftxt->
nspans; i++) {
1061 mxysize = maxoffset = mxfsize = 0;
1102 mxfsize =
MAX(tf.
size, mxfsize);
1103 mxysize =
MAX(sz.
y, mxysize);
1127 ftxt->
spans[i].
lfsize = mxfsize + ysize - curbline - maxoffset;
1130 xsize =
MAX(width, xsize);
1135 ftxt->
box.
UR.
y = mxysize;
1154 if ((b.
UR.
x == -1) && (b.
UR.
y == -1)) {
1157 agerr(
AGERR,
"No or improper image file=\"%s\"\n", img->
src);
1185 if (parent->
cb >= 0)
1194 rv = size_html_tbl(g, cp->
child.
u.
tbl, cp, env);
1197 rv = size_html_img(cp->
child.
u.
img, env);
1205 sz.
x = child_sz.
x + margin;
1206 sz.
y = child_sz.
y + margin;
1211 agerr(
AGWARN,
"cell size too small for content\n");
1218 "fixed cell size with unspecified width or height\n");
1232 int end = cellp->
cspan - 1;
1236 for (c = lastc; c >= col; c--) {
1245 for (j = col; j < col + cellp->
cspan; j++) {
1246 for (i = row; i < row + cellp->
rspan; i++) {
1267 Dt_t *rows = tbl->
u.
p.rows;
1302 rv |= size_html_cell(g, cellp, tbl, env);
1303 c = findCol(ps, r, c, cellp);
1307 n_cols =
MAX(c, n_cols);
1308 n_rows =
MAX(r + cellp->
rspan, n_rows);
1328 #define SPLIT(x,n,s) (((x) - ((s)-1)*((n)-1)) / (n))
1340 int wd, ht, i, x, y;
1345 for (cells = tbl->
u.
n.cells; *cells; cells++) {
1359 for (i = cp->
row; i < cp->row + cp->
rspan; i++) {
1363 for (i = cp->
col; i < cp->col + cp->
cspan; i++) {
1370 static char *nnames[] = {
1371 "0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
1372 "10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
"20",
1380 static char name[100];
1382 if (c <
sizeof(nnames) /
sizeof(
char *))
1385 sprintf(name,
"%d", c);
1408 static void checkChain(
graph_t * g)
1466 for (i = 0; i <= tbl->
cc; i++) {
1479 for (i = 0; i <= tbl->
rc; i++) {
1492 for (cells = tbl->
u.
n.cells; *cells; cells++) {
1552 if ((tbl->
rc == 1) || (tbl->
cc == 1)) {
1569 closeGraphs(rowg, colg);
1587 static void pos_html_txt(
htmltxt_t * ftxt,
char c)
1591 for (i = 0; i < ftxt->
nspans; i++) {
1611 delx = (pos.
UR.
x - pos.
LL.
x) - oldsz.
x;
1615 pos.
UR.
x = pos.
LL.
x + oldsz.
x;
1622 pos.
LL.
x += delx / 2;
1623 pos.
UR.
x -= delx / 2;
1627 dely = (pos.
UR.
y - pos.
LL.
y) - oldsz.
y;
1631 pos.
UR.
y = pos.
LL.
y + oldsz.
y;
1638 pos.
LL.
y += dely / 2;
1639 pos.
UR.
y -= dely / 2;
1654 pos_html_tbl(cp->
child.
u.
tbl, cbox, sides);
1658 delx = (cbox.
UR.
x - cbox.
LL.
x) - oldsz.
x;
1670 dely = (cbox.
UR.
y - cbox.
LL.
y) - oldsz.
y;
1687 delx = (cbox.
UR.
x - cbox.
LL.
x) - oldsz.
x;
1701 cbox.
LL.
x += delx / 2;
1702 cbox.
UR.
x -= delx / 2;
1707 dely = (cbox.
UR.
y - cbox.
LL.
y) - oldsz.
y;
1717 cbox.
LL.
y += dely / 2;
1718 cbox.
UR.
y -= dely / 2;
1737 pos_html_txt(cp->
child.
u.
txt, dfltalign);
1747 static void pos_html_tbl(
htmltbl_t * tbl,
boxf pos,
int sides)
1749 int x, y, delx, dely, oldsz;
1755 if (tbl->
u.
n.parent && tbl->
u.
n.parent->data.pencolor
1760 delx = (pos.
UR.
x - pos.
LL.
x) - oldsz;
1763 dely = (pos.
UR.
y - pos.
LL.
y) - oldsz;
1771 pos.
UR.
x = pos.
LL.
x + oldsz;
1778 pos.
LL.
x += delx / 2;
1779 pos.
UR.
x -= delx / 2;
1787 pos.
UR.
y = pos.
LL.
y + oldsz;
1794 pos.
LL.
y += dely / 2;
1795 pos.
UR.
y -= dely / 2;
1804 extra = delx / (tbl->
cc);
1805 plus =
ROUND(delx - extra * (tbl->
cc));
1806 for (i = 0; i <= tbl->
cc; i++) {
1807 delx = tbl->
widths[i] + extra + (i < plus ? 1 : 0);
1812 extra = dely / (tbl->
rc);
1813 plus =
ROUND(dely - extra * (tbl->
rc));
1814 for (i = 0; i <= tbl->
rc; i++) {
1815 dely = tbl->
heights[i] + extra + (i < plus ? 1 : 0);
1820 while ((cp = *cells++)) {
1836 pos_html_cell(cp, cbox, sides & mask);
1856 pushFontInfo(env, tbl->
font, &savef);
1858 rv = processTbl(g, tbl, env);
1872 for (i = 0; i < tbl->
cc; i++)
1874 for (i = 0; i < tbl->
rc; i++)
1880 agerr(
AGWARN,
"table size too small for content\n");
1886 "fixed table size with unspecified width or height\n");
1894 popFontInfo(env, &savef);
1898 static char *nameOf(
void *obj,
agxbuf * xb)
1925 fprintf(stderr,
" ");
1928 void printBox(
boxf b)
1930 fprintf(stderr,
"(%f,%f)(%f,%f)", b.
LL.
x, b.
LL.
y, b.
UR.
x, b.
UR.
y);
1933 void printImage(
htmlimg_t * ip,
int ind)
1936 fprintf(stderr,
"img: %s\n", ip->
src);
1944 fprintf(stderr,
"txt spans = %d \n", txt->
nspans);
1945 for (i = 0; i < txt->
nspans; i++) {
1947 fprintf(stderr,
"[%d] %d items\n", i, txt->
spans[i].
nitems);
1950 fprintf(stderr,
"[%d] (%f,%f) \"%s\" ",
1955 fprintf(stderr,
"font %s color %s size %f\n",
1960 fprintf(stderr,
"\n");
1967 unsigned char flags = dp->
flags;
1970 fprintf(stderr,
"s%d(%d) ", dp->
space, (flags &
SPACE_SET ? 1 : 0));
1972 fprintf(stderr,
"p%d(%d) ", dp->
pad, (flags &
PAD_SET ? 1 : 0));
1984 fprintf(stderr,
"%c", c);
1996 fprintf(stderr,
"%c ", c);
2004 fprintf(stderr,
"tbl (%p) %d %d ", tbl, tbl->
cc, tbl->
rc);
2005 printData(&tbl->
data);
2006 fputs(
"\n", stderr);
2008 printCell(*cells++, ind + 1);
2011 static void printCell(
htmlcell_t * cp,
int ind)
2014 fprintf(stderr,
"cell %d %d %d %d ", cp->
cspan, cp->
rspan, cp->
col,
2016 printData(&cp->
data);
2017 fputs(
"\n", stderr);
2036 printTbl(lbl->
u.
tbl, 0);
2038 printTxt(lbl->
u.
txt, 0);
2042 static char *getPenColor(
void *obj)
2046 if (((str =
agget(obj,
"pencolor")) != 0) && str[0])
2048 else if (((str =
agget(obj,
"color")) != 0) && str[0])
2092 lp->
text = strdup(nameOf(obj, &xb));
2111 rv |= size_html_tbl(g, lbl->
u.
tbl,
NULL, &env);
2114 box = boxfof(-wd2, -ht2, wd2, ht2);
2119 rv |= size_html_txt(
GD_gvc(g), lbl->
u.
txt, &env);
2122 box = boxfof(-wd2, -ht2, wd2, ht2);
2135 lp->
text = strdup(
"<TABLE>");
void freePS(PointSet *ps)
CGRAPH_API int agobjkind(void *)
void gvrender_box(GVJ_t *job, boxf BF, int filled)
CGRAPH_API Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
CGRAPH_API Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
CDT_API int dtclose(Dt_t *)
#define elist_append(item, L)
char * latin1ToUTF8(char *s)
char * htmlEntityUTF8(char *s, graph_t *g)
boolean findStopColor(char *colorlist, char *clrs[2], float *frac)
CDT_API Dtlink_t * dtflatten(Dt_t *)
int initMapData(GVJ_t *job, char *lbl, char *url, char *tooltip, char *target, char *id, void *gobj)
void gvrender_usershape(GVJ_t *job, char *name, pointf *AF, int n, boolean filled, char *imagescale, char *imagepos)
CGRAPH_API int agisdirected(Agraph_t *g)
size_t agxbput(agxbuf *xb, const char *s)
void sizeArray(htmltbl_t *tbl)
void gvrender_set_fillcolor(GVJ_t *job, char *name)
htmllabel_t * parseHTML(char *txt, int *warn, htmlenv_t *env)
struct htmltbl_t::@12::@13 n
void gvrender_end_label(GVJ_t *job)
int make_html_label(void *obj, textlabel_t *lp)
#define alloc_elist(n, L)
int agerr(agerrlevel_t level, const char *fmt,...)
void gvrender_begin_label(GVJ_t *job, label_type type)
int html_path(node_t *n, port *p, int side, boxf *rv, int *k)
char * strdup_and_subst_obj(char *str, void *obj)
void free_html_text(htmltxt_t *t)
char * agget(void *obj, char *name)
CGRAPH_API Agraph_t * agraphof(void *obj)
CGRAPH_API Agnode_t * agtail(Agedge_t *e)
point gvusershape_size(graph_t *g, char *name)
CGRAPH_API Agdesc_t Agstrictdirected
void pop_obj_state(GVJ_t *job)
void free_html_label(htmllabel_t *lp, int root)
int rank(graph_t *g, int balance, int maxiter)
CGRAPH_API Agnode_t * aghead(Agedge_t *e)
void emit_map_rect(GVJ_t *job, boxf b)
CGRAPH_API int agclose(Agraph_t *g)
CGRAPH_API char * agnameof(void *)
void gvrender_begin_anchor(GVJ_t *job, char *href, char *tooltip, char *target, char *id)
void gvrender_set_pencolor(GVJ_t *job, char *name)
int inIntSet(Dt_t *is, int v)
int isInPS(PointSet *ps, int x, int y)
double yoffset_centerline
PostscriptAlias * postscript_alias
void agxbinit(agxbuf *xb, unsigned int hint, unsigned char *init)
struct htmltbl_t::@12::@14 p
void gvrender_set_style(GVJ_t *job, char **s)
#define DEFAULT_CELLSPACING
void gvrender_set_gradient_vals(GVJ_t *job, char *stopcolor, int angle, float frac)
void makeGraphs(htmltbl_t *tbl, graph_t *rowg, graph_t *colg)
void gvrender_set_penwidth(GVJ_t *job, double penwidth)
if(aagss+aagstacksize-1<=aagssp)
obj_state_t * push_obj_state(GVJ_t *job)
void gvrender_textspan(GVJ_t *job, pointf p, textspan_t *span)
void free_html_data(htmldata_t *dp)
void addPS(PointSet *ps, int x, int y)
char * getObjId(GVJ_t *job, void *obj, agxbuf *xb)
void round_corners(GVJ_t *job, pointf *AF, int sides, int style, int filled)
void emit_html_label(GVJ_t *job, htmllabel_t *lp, textlabel_t *tp)
int strcasecmp(const char *s1, const char *s2)
CGRAPH_API Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
void(* free_layout)(void *layout)
CGRAPH_API void * agbindrec(void *obj, char *name, unsigned int size, int move_to_front)
boxf * html_port(node_t *n, char *pname, int *sides)
void setSizes(htmltbl_t *tbl, graph_t *rowg, graph_t *colg)
pointf textspan_size(GVC_t *gvc, textspan_t *span)
#define agfindedge(g, t, h)
void sizeLinearArray(htmltbl_t *tbl)
void make_simple_label(GVC_t *gvc, textlabel_t *lp)
#define EMIT_CLUSTERS_LAST
void gvrender_end_anchor(GVJ_t *job)
#define DEFAULT_CELLPADDING
void agxbfree(agxbuf *xb)
void free_html_img(htmlimg_t *ip)
void addIntSet(Dt_t *is, int v)
void gvrender_polyline(GVJ_t *job, pointf *AF, int n)