54#define DEFAULT_BORDER 1
55#define DEFAULT_CELLPADDING 2
56#define DEFAULT_CELLSPACING 2
69static void printCell(
htmlcell_t * cp,
int ind);
111 if (savp->
size >= 0.0)
119 double center_x, left_x, right_x;
126 left_x = center_x - halfwidth_x;
127 right_x = center_x + halfwidth_x;
132 p_.
y = p.
y + (b.
UR.
y - b.
LL.
y) / 2.0;
135 for (
size_t i = 0; i < nspans; i++) {
137 switch (spans[i].just) {
142 p.
x = right_x - spans[i].
size;
146 p.
x = center_x - spans[i].
size / 2.0;
152 for (
size_t j = 0; j < spans[i].
nitems; j++) {
232 const double delta = border / 2.0;
256 unsigned short sides;
260 sptr[0] = sptr[1] =
NULL;
419 if(obj->fld != save->fld) {free(obj->fld); obj->fld = save->fld;}
485 doSide(job, rule_pt, 0, rule_length);
496 else if (nextc && nextc->
row != cp->
row) {
507 if (nextc && nextc->
row != cp->
row) {
513 doSide(job, rule_pt, rule_length, 0);
571 while ((cp = *cells++)) {
812 for (
size_t i = 0; i < t->
nspans; i++) {
814 for (
size_t j = 0; j < tl->
nitems; j++) {
848 rows_free(&tbl->
u.
p.
rows);
906 while ((cp = *cells++)) {
920 assert(pname !=
NULL && !
streq(pname,
""));
942 double mxfsize = 0.0;
943 double curbline = 0.0;
948 double maxoffset, mxysize = 0.0;
950 double prev_fsize = -1;
951 char* prev_fname =
NULL;
953 for (
size_t i = 0; i < ftxt->
nspans; i++) {
977 prev_fsize = tf.
size;
978 else if (tf.
size != prev_fsize) {
982 if (prev_fname ==
NULL)
983 prev_fname = tf.
name;
984 else if (strcmp(tf.
name,prev_fname)) {
991 for (
size_t i = 0; i < ftxt->
nspans; i++) {
993 mxysize = maxoffset = mxfsize = 0;
994 for (
size_t j = 0; j < ftxt->
spans[i].
nitems; j++) {
1034 mxfsize =
MAX(tf.
size, mxfsize);
1035 mxysize =
MAX(sz.
y, mxysize);
1059 ftxt->
spans[i].
lfsize = mxfsize + ysize - curbline - maxoffset;
1062 xsize =
MAX(width, xsize);
1067 ftxt->
box.
UR.
y = mxysize;
1083 if (b.
UR.
x == -1 && b.
UR.
y == -1) {
1086 agerrorf(
"No or improper image file=\"%s\"\n", img->
src);
1112 if (
parent->cellborder >= 0)
1132 sz.
x = child_sz.
x + margin;
1133 sz.
y = child_sz.
y + margin;
1138 agwarningf(
"cell size too small for content\n");
1145 "fixed cell size with unspecified width or height\n");
1162 for (c = lastc; c >= col; c--) {
1171 for (j = col; j < col + cellp->
colspan; j++) {
1177 return (uint16_t)col;
1196 for (uint16_t r = 0; r < rows_size(&
rows); ++r) {
1198 cnt += cells_size(&rp->
rp);
1205 for (uint16_t r = 0; r < rows_size(&
rows); ++r) {
1208 for (
size_t i = 0; i < cells_size(&rp->
rp); ++i) {
1216 n_cols =
MAX(c, n_cols);
1255 assert(
table->widths ==
NULL &&
"table widths computed twice");
1265 if (
cell.colspan > 1) {
1268 assert(
cell.col <
table->column_count &&
"out of range cell");
1278 if (
cell.colspan == 1) {
1283 double span_width = 0;
1285 "cell spans wider than containing table");
1286 for (
size_t j = 0; j <
cell.colspan; ++j) {
1287 span_width +=
table->widths[
cell.col + j];
1291 const double spacing = (
cell.colspan - 1) *
table->data.space;
1292 if (span_width + spacing <
cell.data.box.UR.x) {
1293 const double widen_by =
1294 (
cell.data.box.UR.x - spacing - span_width) /
cell.colspan;
1295 for (
size_t j = 0; j <
cell.colspan; ++j) {
1296 table->widths[
cell.col + j] += widen_by;
1306 double min_width = 0;
1308 "cell spans wider than containing table");
1309 for (
size_t j = 0; j <
cell->colspan; ++j) {
1310 min_width +=
table->widths[
cell->col + j];
1314 const double spacing = (
cell->colspan - 1) *
table->data.space;
1315 cell->data.box.UR.x = fmax(
cell->data.box.UR.x, min_width + spacing);
1326 assert(
table->heights ==
NULL &&
"table heights computed twice");
1331 if (
cell.rowspan > 1) {
1334 assert(
cell.row <
table->row_count &&
"out of range cell");
1341 if (
cell.rowspan == 1) {
1345 double span_height = 0;
1347 "cell spans higher than containing table");
1348 for (
size_t j = 0; j <
cell.rowspan; ++j) {
1349 span_height +=
table->heights[
cell.row + j];
1352 const double spacing = (
cell.rowspan - 1) *
table->data.space;
1353 if (span_height + spacing <
cell.data.box.UR.y) {
1354 const double heighten_by =
1355 (
cell.data.box.UR.y - spacing - span_height) /
cell.rowspan;
1356 for (
size_t j = 0; j <
cell.rowspan; ++j) {
1357 table->heights[
cell.row + j] += heighten_by;
1365 double min_height = 0;
1367 "cell spans higher than containing table");
1368 for (
size_t j = 0; j <
cell->rowspan; ++j) {
1369 min_height +=
table->heights[
cell->row + j];
1372 const double spacing = (
cell->rowspan - 1) *
table->data.space;
1373 cell->data.box.UR.y = fmax(
cell->data.box.UR.y, min_height + spacing);
1391 for (
size_t i = 0; i < ftxt->
nspans; i++) {
1408 delx = pos.
UR.
x - pos.
LL.
x - oldsz.
x;
1412 pos.
UR.
x = pos.
LL.
x + oldsz.
x;
1419 pos.
LL.
x += delx / 2;
1420 pos.
UR.
x -= delx / 2;
1424 dely = pos.
UR.
y - pos.
LL.
y - oldsz.
y;
1428 pos.
UR.
y = pos.
LL.
y + oldsz.
y;
1435 pos.
LL.
y += dely / 2;
1436 pos.
UR.
y -= dely / 2;
1455 delx = cbox.
UR.
x - cbox.
LL.
x - oldsz.
x;
1469 dely = cbox.
UR.
y - cbox.
LL.
y - oldsz.
y;
1488 delx = cbox.
UR.
x - cbox.
LL.
x - oldsz.
x;
1501 cbox.
LL.
x += delx / 2;
1502 cbox.
UR.
x -= delx / 2;
1507 dely = cbox.
UR.
y - cbox.
LL.
y - oldsz.
y;
1517 cbox.
LL.
y += dely / 2;
1518 cbox.
UR.
y -= dely / 2;
1557 double delx = fmax(pos.
UR.
x - pos.
LL.
x - oldsz, 0);
1559 double dely = fmax(pos.
UR.
y - pos.
LL.
y - oldsz, 0);
1566 pos.
UR.
x = pos.
LL.
x + oldsz;
1573 pos.
LL.
x += delx / 2;
1574 pos.
UR.
x -= delx / 2;
1582 pos.
UR.
y = pos.
LL.
y + oldsz;
1586 pos.
UR.
y = pos.
LL.
y + oldsz;
1589 pos.
LL.
y += dely / 2;
1590 pos.
UR.
y -= dely / 2;
1603 delx = tbl->
widths[i] + extra + ((i <= INT_MAX && (int)i < plus) ? 1 : 0);
1611 for (
size_t i = 0; i <= tbl->
row_count; i++) {
1612 dely = tbl->
heights[i] + extra + ((i <= INT_MAX && (int)i < plus) ? 1 : 0);
1617 while ((cp = *cells++)) {
1618 unsigned char mask = 0;
1672 for (
size_t i = 0; i < tbl->
row_count; i++)
1678 agwarningf(
"table size too small for content\n");
1685 "fixed table size with unspecified width or height\n");
1724 fprintf(stderr,
" ");
1727void printBox(
boxf b)
1729 fprintf(stderr,
"(%f,%f)(%f,%f)", b.
LL.
x, b.
LL.
y, b.
UR.
x, b.
UR.
y);
1735 fprintf(stderr,
"img: %s\n", ip->
src);
1742 for (
size_t i = 0; i < txt->
nspans; i++) {
1746 for (
size_t j = 0; j < txt->
spans[i].
nitems; j++) {
1748 fprintf(stderr,
"[%" PRISIZE_T "] (%f,%f) \"%s\" ",
1753 fprintf(stderr,
"font %s color %s size %f\n",
1758 fprintf(stderr,
"\n");
1782 fprintf(stderr,
"%c", c);
1794 fprintf(stderr,
"%c ", c);
1804 fputs(
"\n", stderr);
1806 printCell(*cells++, ind + 1);
1809static void printCell(
htmlcell_t * cp,
int ind)
1812 fprintf(stderr,
"cell %" PRIu16
" %" PRIu16
" %" PRIu16
" %" PRIu16
" ", cp->
colspan,
1815 fputs(
"\n", stderr);
1834 printTbl(lbl->
u.
tbl, 0);
1836 printTxt(lbl->
u.
txt, 0);
1844 if ((
str =
agget(obj,
"pencolor")) != 0 &&
str[0])
1846 else if ((
str =
agget(obj,
"color")) != 0 &&
str[0])
1913 boxf b = {{-wd2, -ht2}, {wd2, ht2}};
1921 boxf b = {{-wd2, -ht2}, {wd2, ht2}};
static void agxbfree(agxbuf *xb)
free any malloced resources
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
static WUR char * agxbuse(agxbuf *xb)
Memory allocation wrappers that exit on failure.
static char * gv_strdup(const char *original)
static void * gv_calloc(size_t nmemb, size_t size)
API for compacted arrays of booleans.
static bitarray_t bitarray_new(size_t size_bits)
create an array of the given element length
static bool bitarray_get(bitarray_t self, size_t index)
get the value of the given element
static void bitarray_set(bitarray_t *self, size_t index, bool value)
set or clear the value of the given element
static void bitarray_reset(bitarray_t *self)
free underlying resources and leave a bit array empty
char * latin1ToUTF8(char *s)
Converts string from Latin1 encoding to utf8. Also translates HTML entities.
char * htmlEntityUTF8(char *s, graph_t *g)
int initMapData(GVJ_t *job, char *lbl, char *url, char *tooltip, char *target, char *id, void *gobj)
bool findStopColor(const char *colorlist, char *clrs[2], double *frac)
obj_state_t * push_obj_state(GVJ_t *job)
void emit_map_rect(GVJ_t *job, boxf b)
void pop_obj_state(GVJ_t *job)
char * getObjId(GVJ_t *job, void *obj, agxbuf *xb)
Use id of root graph if any, plus kind and internal id of object.
static pointf scale(double c, pointf p)
static int cnt(Dict_t *d, Dtlink_t **set)
char * agget(void *obj, char *name)
void agwarningf(const char *fmt,...)
void agerrorf(const char *fmt,...)
int agisdirected(Agraph_t *g)
Agraph_t * agraphof(void *obj)
char * agnameof(void *)
returns a string descriptor for the object.
static void indent(int ix)
Arithmetic helper functions.
#define EMIT_CLUSTERS_LAST
static void color(Agraph_t *g)
void gvrender_end_label(GVJ_t *job)
void gvrender_usershape(GVJ_t *job, char *name, pointf *AF, size_t n, bool filled, char *imagescale, char *imagepos)
void gvrender_set_style(GVJ_t *job, char **s)
void gvrender_set_fillcolor(GVJ_t *job, char *name)
void gvrender_polyline(GVJ_t *job, pointf *AF, size_t n)
point gvusershape_size(graph_t *g, char *name)
void gvrender_box(GVJ_t *job, boxf BF, int filled)
void gvrender_set_gradient_vals(GVJ_t *job, char *stopcolor, int angle, double frac)
void gvrender_begin_anchor(GVJ_t *job, char *href, char *tooltip, char *target, char *id)
void gvrender_end_anchor(GVJ_t *job)
void gvrender_textspan(GVJ_t *job, pointf p, textspan_t *span)
void gvrender_begin_label(GVJ_t *job, label_type type)
void gvrender_set_penwidth(GVJ_t *job, double penwidth)
void gvrender_set_pencolor(GVJ_t *job, char *name)
htmllabel_t * parseHTML(char *txt, int *warn, htmlenv_t *env)
textitem scanner parser str
static void free_html_img(htmlimg_t *ip)
static void endAnchor(GVJ_t *job, htmlmap_data_t *save)
static int size_html_tbl(graph_t *g, htmltbl_t *tbl, htmlcell_t *parent, htmlenv_t *env)
static void pos_html_cell(htmlcell_t *cp, boxf pos, unsigned char sides)
static void pushFontInfo(htmlenv_t *env, textfont_t *fp, textfont_t *savp)
static void pos_html_txt(htmltxt_t *ftxt, char c)
Set default alignment.
static void set_cell_widths(htmltbl_t *table)
static char * nameOf(void *obj, agxbuf *xb)
static void allocObj(GVJ_t *job)
boxf * html_port(node_t *n, char *pname, unsigned char *sides)
static void pos_html_tbl(htmltbl_t *, boxf, unsigned char)
static double heightOfLbl(htmllabel_t *lp)
int make_html_label(void *obj, textlabel_t *lp)
Return non-zero if problem parsing HTML. In this case, use object name.
static void emit_html_img(GVJ_t *job, htmlimg_t *cp, htmlenv_t *env)
static void pos_html_img(htmlimg_t *cp, boxf pos)
#define DEFAULT_CELLSPACING
#define DEFAULT_CELLPADDING
static int size_html_cell(graph_t *g, htmlcell_t *cp, htmltbl_t *parent, htmlenv_t *env)
static void doBorder(GVJ_t *job, htmldata_t *dp, boxf b)
static void set_cell_heights(htmltbl_t *table)
static pointf * mkPts(pointf *AF, boxf b, int border)
static void freeObj(GVJ_t *job)
static int processTbl(graph_t *g, htmltbl_t *tbl, htmlenv_t *env)
static htmldata_t * portToTbl(htmltbl_t *, char *)
static void emit_html_txt(GVJ_t *job, htmltxt_t *tp, htmlenv_t *env)
static htmldata_t * portToCell(htmlcell_t *cp, char *id)
void free_html_text(htmltxt_t *t)
static void free_html_cell(htmlcell_t *cp)
static void emit_html_tbl(GVJ_t *job, htmltbl_t *tbl, htmlenv_t *env)
static void popFontInfo(htmlenv_t *env, textfont_t *savp)
static int size_html_txt(GVC_t *gvc, htmltxt_t *ftxt, htmlenv_t *env)
void free_html_label(htmllabel_t *lp, int root)
static void emit_html_cell(GVJ_t *job, htmlcell_t *cp, htmlenv_t *env)
static uint16_t findCol(PointSet *ps, int row, int col, htmlcell_t *cellp)
void emit_html_label(GVJ_t *job, htmllabel_t *lp, textlabel_t *tp)
static void emit_htextspans(GVJ_t *job, size_t nspans, htextspan_t *spans, pointf p, double halfwidth_x, textfont_t finfo, boxf b, int simple)
static int initAnchor(GVJ_t *job, htmlenv_t *env, htmldata_t *data, boxf b, htmlmap_data_t *save)
void free_html_data(htmldata_t *dp)
static int setFill(GVJ_t *job, char *color, int angle, htmlstyle_t style, char *clrs[2])
static void doSide(GVJ_t *job, pointf p, double wd, double ht)
static void emit_html_rules(GVJ_t *job, htmlcell_t *cp, htmlenv_t *env, char *color, htmlcell_t *nextc)
static void free_html_tbl(htmltbl_t *tbl)
static int size_html_img(htmlimg_t *img, htmlenv_t *env)
static char * getPenColor(void *obj)
char * strdup_and_subst_obj(char *str, void *obj)
void make_simple_label(GVC_t *gvc, textlabel_t *lp)
static int table[NTYPES][NTYPES]
void addPS(PointSet *ps, double x, double y)
void freePS(PointSet *ps)
int isInPS(PointSet *ps, double x, double y)
point containers PointSet and PointMap
static void printData(object_t *objs, size_t n_objs, xlabel_t *lbls, size_t n_lbls, label_params_t *params)
#define PRISIZE_T
PRIu64 alike for printing size_t
void round_corners(GVJ_t *job, pointf *AF, size_t sides, graphviz_polygon_style_t style, int filled)
Handle some special graphical cases, such as rounding the shape, adding diagonals at corners,...
pointf textspan_size(GVC_t *gvc, textspan_t *span)
Estimates size of a textspan, in points.
platform abstraction for case-insensitive string functions
static bool streq(const char *a, const char *b)
are a and b equal?
Agraph_t * root
subgraphs - ancestors
result of partitioning available space, part of maze
bool vruled
vertically ruled?
bool hruled
horizontally ruled?
size_t row_count
number of rows
struct htmltbl_t::@73::@75 p
double * widths
widths of the columns
double * heights
heights of the rows
size_t column_count
number of columns
struct htmltbl_t::@73::@74 n
unsigned explicit_tooltip
PostscriptAlias * postscript_alias
double yoffset_centerline
void(* free_layout)(void *layout)