}
/* initial window size */
+//fprintf(stderr,"page=%g,%g dpi=%g,%g zoom=%g\n", pageSize.x, pageSize.y, job->dpi.x, job->dpi.y, job->zoom);
job->width = ROUND((pageSize.x + 2*margin.x) * job->dpi.x / POINTS_PER_INCH);
job->height = ROUND((pageSize.y + 2*margin.y) * job->dpi.y / POINTS_PER_INCH);
/* pagesize */
gvc->graph_sets_pageSize = FALSE;
- P2PF(GD_drawing(g)->page, gvc->pageSize);
- if ((GD_drawing(g)->page.x > 0) && (GD_drawing(g)->page.y > 0))
+ gvc->pageSize = GD_drawing(g)->page;
+ if ((GD_drawing(g)->page.x > 0.001) && (GD_drawing(g)->page.y > 0.001))
gvc->graph_sets_pageSize = TRUE;
/* rotation */
Agnode_t *n;
char *str, *nodename = NULL, *junk = NULL;
-// assert((gvc->bb.LL.x == 0) && (gvc->bb.LL.y == 0));
- P2PF(gvc->bb.UR, UR);
-
+ UR = gvc->bb.UR;
job->bb.LL.x = -job->pad.x; /* job->bb is bb of graph and padding - graph units */
job->bb.LL.y = -job->pad.y;
job->bb.UR.x = UR.x + job->pad.x;
/* start with "natural" size of layout */
Z = 1.0;
- if (GD_drawing(g)->size.x > 0) { /* graph size was given by user... */
- P2PF(GD_drawing(g)->size, size);
+ if (GD_drawing(g)->size.x > 0.001 && GD_drawing(g)->size.y > 0.001) { /* graph size was given by user... */
+ size = GD_drawing(g)->size;
if ((size.x < sz.x) || (size.y < sz.y) /* drawing is too big (in either axi) ... */
|| ((GD_drawing(g)->filled) /* or ratio=filled requested and ... */
&& (size.x > sz.x) && (size.y > sz.y))) /* drawing is too small (in both axis) ... */
static struct {
htmllabel_t* lbl; /* Generated label */
htmltbl_t* tblstack; /* Stack of tables maintained during parsing */
-#ifdef OLD
- Dt_t* paras; /* Dictionary for paras of text */
-#endif
Dt_t* fitemList; /* Dictionary for font text items */
Dt_t* fparaList;
agxbuf* str; /* Buffer for text */
NIL(Dtevent_f)
};
-#ifdef OLD
-typedef struct {
- Dtlink_t link;
- const char* s; /* para of text */
- char c; /* alignment of text */
-} sitem;
-#endif
-
typedef struct {
Dtlink_t link;
textitem_t ti;
htextpara_t lp;
} fpara;
-#ifdef OLD
-static void
-free_sitem(Dt_t* d, sitem* p,Dtdisc_t* ds)
-{
- free (p);
-}
-#endif
-
static void
free_fitem(Dt_t* d, fitem* p, Dtdisc_t* ds)
{
free (p);
}
-#ifdef OLD
-static Dtdisc_t strDisc = {
- offsetof(sitem,s),
- sizeof(char*),
- offsetof(sitem,link),
- NIL(Dtmake_f),
- (Dtfree_f)free_sitem,
- NIL(Dtcompar_f),
- NIL(Dthash_f),
- NIL(Dtmemory_f),
- NIL(Dtevent_f)
-};
-#endif
-
static Dtdisc_t fstrDisc = {
0,
0,
NIL(Dtevent_f)
};
-#ifdef OLD
-static void
-appendStrList(const char* p,int v)
-{
- sitem* sp = NEW(sitem);
- sp->s = strdup(p);
- sp->c = v;
- dtinsert (HTMLstate.paras, sp);
-}
-#endif
-
/* dupFont:
*/
static htmlfont_t *
dtinsert(HTMLstate.fparaList, ln);
}
-#ifdef OLD
-/* mkText:
- * Construct htmltxt_t from list of paras in HTMLstate.paras.
- * lastl is a last, odd para with no <BR>, so we use n by default.
- */
-static htmltxt_t*
-mkText (const char* lastl)
-{
- int cnt;
- textpara_t* lp;
- sitem* sp;
- Dt_t* paras = HTMLstate.paras;
- htmltxt_t* tp = NEW(htmltxt_t);
-
- if (paras)
- cnt = dtsize (paras);
- else
- cnt = 0;
- if (lastl) cnt++;
-
- tp->nparas = cnt;
- tp->para = N_NEW(cnt+1,textpara_t);
-
- lp = tp->para;
- if (paras) {
- sp = (sitem*)dtflatten(paras);
- for (; sp; sp = (sitem*)dtlink(paras,(Dtlink_t*)sp)) {
- lp->str = (char*)(sp->s);
- lp->xshow = NULL;
- lp->just = sp->c;
- lp++;
- }
- }
- if (lastl) {
- lp->str = strdup(lastl);
- lp->just = '\0';
- }
-
- if (paras) dtclear (paras);
-
- return tp;
-}
-#endif
-
static htmltxt_t*
mkText(void)
{
cp->child.u.tbl = (htmltbl_t*)obj;
}
-#ifdef OLD
-/* setFont:
- * Copy in font attributes. fp has the new attributes.
- * curf corresponds to the current font info of the object.
- * From the parser, we are moving out from the object. Since
- * the inmost value is the one used, we only use a new value
- * if the attribute has not already been assigned.
- */
-static htmlfont_t* setFont (htmlfont_t* fp, htmlfont_t* curf)
-{
- if (curf) {
- if (curf->size < 0.0) curf->size = fp->size;
- if (!curf->color) curf->color = fp->color;
- else if (fp->color) free (fp->color);
- if (!curf->name) curf->name = fp->name;
- else if (fp->name) free (fp->name);
- free (fp);
- return curf;
- }
- else
- return fp;
-}
-
-/* fontText:
- * Attach font information to text.
- */
-static void fontText (htmlfont_t* fp, htmltxt_t* cp)
-{
- cp->font = setFont (fp, cp->font);
-}
-
-/* fontTable:
- * Attach font information to table.
- */
-static void fontTable (htmlfont_t* fp, htmltbl_t* cp)
-{
- cp->font = setFont (fp, cp->font);
-}
-#endif
-
/* mkLabel:
* Create label, given body and type.
*/
%%
-#ifdef OLD
-htmllabel_t*
-simpleHTML (char* txt)
-{
- htmltxt_t* tobj = mkText (txt);
- htmllabel_t* l = mkLabel(tobj,HTML_TEXT);
- return l;
-}
-#endif
-
/* parseHTML:
* Return parsed label or NULL if failure.
* Set warn to 0 on success; 1 for warning message; 2 if no expat.
* e.g., CELLGRID=n, which sets CELLBORDER=0 and has the border drawing
* handled correctly by the table.
*/
+
+#include <assert.h>
#include "render.h"
#include "htmltable.h"
#include "agxbuf.h"
#include "pointset.h"
-#include <assert.h>
#define DEFAULT_BORDER 1
#define DEFAULT_CELLPADDING 2
env.finfo.size = tp->fontsize;
env.finfo.size = tp->fontsize;
env.imgscale = agget (job->obj->u.n, "imagescale");
- if ((env.imgscale == NULL) || (*env.imgscale == '\0'))
+ if ((env.imgscale == NULL) || (env.imgscale[0] == '\0'))
env.imgscale = "false";
if (lp->kind == HTML_TBL) {
htmltbl_t *tbl = lp->u.tbl;
/* make_html_label:
* Return non-zero if problem parsing HTML. In this case, use object name.
*/
-int make_html_label(graph_t *g, textlabel_t * lp, void *obj)
+int make_html_label(void *obj, textlabel_t * lp)
{
int rv;
double wd2, ht2;
boxf box;
+ graph_t *g;
htmllabel_t *lbl;
htmlenv_t env;
+ char *s;
env.obj = obj;
switch (agobjkind(obj)) {
env.g = ((Agedge_t *) obj)->head->graph;
break;
}
+ g = env.g->root;
+
env.finfo.size = lp->fontsize;
env.finfo.name = lp->fontname;
env.finfo.color = lp->fontcolor;
agxbinit(&xb, SMALLBUF, buf);
lp->html = FALSE;
lp->text = strdup(nameOf(obj, &xb));
- size_label(env.g, lp);
+ switch (lp->charset) {
+ case CHAR_LATIN1:
+ s = latin1ToUTF8(lp->text);
+ break;
+ default: /* UTF8 */
+ s = htmlEntityUTF8(lp->text);
+ break;
+ }
+ free(lp->text);
+ lp->text = s;
+ make_simple_label(g, lp);
agxbfree(&xb);
return rv;
}
* NOTE: As required, the str field in para is utf-8.
* This translation is done when libexpat scans the input.
*/
-#ifdef OLD
- typedef struct {
- textpara_t *para;
- short nparas;
- box box;
- htmlfont_t *font; /* font info */
- } htmltxt_t;
-#endif
/* atomic unit of text emitted using a single htmlfont_t */
typedef struct {
extern htmllabel_t *parseHTML(char *, int *, int);
- extern int make_html_label(graph_t *g, textlabel_t * lp, void *obj);
+ extern int make_html_label(void *obj, textlabel_t * lp);
extern void emit_html_label(GVJ_t * job, htmllabel_t * lp, textlabel_t *);
extern void free_html_label(htmllabel_t *, int);
sym->fixed = 1;
}
-/* getdoubles2pt:
- * converts a graph attribute to a point.
+/* getdoubles2ptf:
+ * converts a graph attribute to floating graph units (POINTS).
* Returns true if the attribute ends in '!'.
*/
-static boolean getdoubles2pt(graph_t * g, char *name, point * result)
+static boolean getdoubles2ptf(graph_t * g, char *name, pointf * result)
{
char *p;
int i;
setRatio(g);
GD_drawing(g)->filled =
- getdoubles2pt(g, "size", &(GD_drawing(g)->size));
- getdoubles2pt(g, "page", &(GD_drawing(g)->page));
+ getdoubles2ptf(g, "size", &(GD_drawing(g)->size));
+ getdoubles2ptf(g, "page", &(GD_drawing(g)->page));
GD_drawing(g)->centered = mapbool(agget(g, "center"));
*/
void do_graph_label(graph_t * sg)
{
- char *p, *pos, *just;
+ char *str, *pos, *just;
int pos_ix;
/* it would be nice to allow multiple graph labels in the future */
- if ((p = agget(sg, "label"))) {
+ if ((str = agget(sg, "label"))) {
char pos_flag;
- int lbl_kind = LT_NONE;
point dpt;
pointf dimen;
- if (aghtmlstr(p)) lbl_kind = LT_HTML;
GD_has_labels(sg->root) |= GRAPH_LABEL;
- if (lbl_kind) p = strdup (p);
- else p = strdup_and_subst_obj(p, (void*)sg);
- GD_label(sg) = make_label(sg->root, lbl_kind, p,
- late_double(sg,
- agfindattr(sg, "fontsize"),
- DEFAULT_FONTSIZE, MIN_FONTSIZE),
- late_nnstring(sg,
- agfindattr(sg, "fontname"),
- DEFAULT_FONTNAME),
- late_nnstring(sg,
- agfindattr(sg, "fontcolor"),
- DEFAULT_COLOR));
- if (lbl_kind) {
- if (make_html_label(sg->root, GD_label(sg), sg) == 1)
- agerr(AGPREV, "in label of graph %s\n", sg->name);
- }
+ GD_label(sg) = make_label((void*)sg, str, (aghtmlstr(str) ? LT_HTML : LT_NONE),
+ late_double(sg, agfindattr(sg, "fontsize"), DEFAULT_FONTSIZE, MIN_FONTSIZE),
+ late_nnstring(sg, agfindattr(sg, "fontname"), DEFAULT_FONTNAME),
+ late_nnstring(sg, agfindattr(sg, "fontcolor"), DEFAULT_COLOR));
/* set label position */
pos = agget(sg, "labelloc");
lp->dimen.y += size.y;
}
-/* compiles <str> into a label <lp> and returns its bounding box size. */
-static pointf label_size(graph_t * g, textlabel_t * lp)
+/* compiles <str> into a label <lp> */
+void make_simple_label(graph_t * g, textlabel_t * lp)
{
char c, *p, *line, *lineptr, *str = lp->text;
unsigned char byte = 0x00;
- int charset = GD_charset(g);
lp->dimen.x = lp->dimen.y = 0.0;
if (*str == '\0')
- return lp->dimen;
+ return;
line = lineptr = NULL;
p = str;
* the second in 0x40-0x7e or 0xa1-0xfe. We assume that the input
* is well-formed, but check that we don't go past the ending '\0'.
*/
- if ((charset == CHAR_BIG5) && 0xA1 <= byte && byte <= 0xFE) {
+ if ((lp->charset == CHAR_BIG5) && 0xA1 <= byte && byte <= 0xFE) {
*lineptr++ = c;
c = *p++;
*lineptr++ = c;
}
lp->space = lp->dimen;
- return lp->dimen;
-}
-
-/* size_label:
- * Process label text for size and line breaks.
- */
-void
-size_label (graph_t* g, textlabel_t* rv)
-{
- char *s;
-
- switch (GD_charset(g->root)) {
- case CHAR_LATIN1:
- s = latin1ToUTF8(rv->text);
- break;
- default: /* UTF8 */
- s = htmlEntityUTF8(rv->text);
- break;
- }
- free(rv->text);
- rv->text = s;
- label_size(g, rv);
}
/* make_label:
* Assume str is freshly allocated for this instance, so it
* can be freed in free_label.
*/
-textlabel_t *make_label(graph_t *g, int kind, char *str, double fontsize,
- char *fontname, char *fontcolor)
+textlabel_t *make_label(void *obj, char *str, int kind, double fontsize, char *fontname, char *fontcolor)
{
textlabel_t *rv = NEW(textlabel_t);
+ graph_t *g = NULL, *sg = NULL;
+ node_t *n = NULL;
+ edge_t *e = NULL;
+ char *s;
- rv->text = str;
+ switch (agobjkind(obj)) {
+ case AGGRAPH:
+ sg = (graph_t*)obj;
+ g = sg->root;
+ break;
+ case AGNODE:
+ n = (node_t*)obj;
+ g = n->graph->root;
+ break;
+ case AGEDGE:
+ e = (edge_t*)obj;
+ g = e->head->graph->root;
+ break;
+ }
rv->fontname = fontname;
rv->fontcolor = fontcolor;
rv->fontsize = fontsize;
- if (kind & LT_HTML)
+ rv->charset = GD_charset(g);
+ if (kind & LT_RECD) {
+ rv->text = strdup(str);
+ if (kind & LT_HTML) {
+ rv->html = TRUE;
+ }
+ }
+ else if (kind == LT_HTML) {
+ rv->text = strdup(str);
rv->html = TRUE;
- if (kind == LT_NONE)
- size_label(g, rv);
+ if (make_html_label(obj, rv)) {
+ switch (agobjkind(obj)) {
+ case AGGRAPH:
+ agerr(AGPREV, "in label of graph %s\n",sg->name);
+ break;
+ case AGNODE:
+ agerr(AGPREV, "in label of node %s\n", n->name);
+ break;
+ case AGEDGE:
+ agerr(AGPREV, "in label of edge %s %s %s\n",
+ e->tail->name, AG_IS_DIRECTED(g)?"->":"--", e->head->name);
+ break;
+ }
+ }
+ }
+ else {
+ assert(kind == LT_NONE);
+ rv->text = strdup_and_subst_obj(str, obj);
+ switch (rv->charset) {
+ case CHAR_LATIN1:
+ s = latin1ToUTF8(rv->text);
+ break;
+ default: /* UTF8 */
+ s = htmlEntityUTF8(rv->text);
+ break;
+ }
+ free(rv->text);
+ rv->text = s;
+ make_simple_label(g, rv);
+ }
return rv;
}
}
}
-#if 0
-void osize_label(textlabel_t * label, int *b, int *t, int *l, int *r)
-{
- point pt, sz2;
- pointf dimen;
-
- dimen = label->dimen;
- PAD(dimen);
- sz2 = cvt2pt(label->dimen);
- sz2.x /= 2;
- sz2.y /= 2;
- pt = add_points(label->p, sz2);
- if (*r < pt.x)
- *r = pt.x;
- if (*t < pt.y)
- *t = pt.y;
- pt = sub_points(label->p, sz2);
- if (*l > pt.x)
- *l = pt.x;
- if (*b > pt.y)
- *b = pt.y;
-}
-#endif
-
/* place_flip_graph_label:
* Put cluster labels recursively in the flip case.
*/
extern char *xml_url_string(char *s);
extern void makeSelfEdge(path *, edge_t **, int, int, int, int,
splineInfo *);
- extern textlabel_t *make_label(graph_t *g, int html, char *str,
- double fontsize, char *fontname, char *fontcolor);
+ extern textlabel_t *make_label(void *obj, char *str, int kind, double fontsize, char *fontname, char *fontcolor);
extern bezier *new_spline(edge_t * e, int sz);
- extern void osize_label(textlabel_t *, int *, int *, int *, int *);
extern char **parse_style(char *s);
extern void place_graph_label(Agraph_t *);
extern void place_portlabel(edge_t * e, boolean head_p);
extern void setup_graph(GVC_t * gvc, graph_t * g);
extern shape_kind shapeOf(node_t *);
extern void shape_clip(node_t * n, point curve[4]);
- extern void size_label (graph_t* g, textlabel_t* rv);
+ extern void make_simple_label (graph_t* g, textlabel_t* rv);
extern void start_timer(void);
extern pointf textsize(graph_t *g, textpara_t * para, char *fontname, double fontsize);
extern void translate_bb(Agraph_t *, int);
char *tsp, *psp, *hstsp, *hspsp, *sp;
char port[SMALLBUF];
int maxf, cnt, mode, wflag, ishardspace, fi;
- graph_t *sg = n->graph;
textlabel_t *lbl = ND_label(n);
fp = NULL;
tsp - 1 != hstsp && *(tsp - 1) == ' ')
tsp--;
*tsp = '\000';
- fp->lp =
- make_label(sg->root, (lbl->html ? LT_HTML : LT_NONE),
- strdup(text),
+ fp->lp = make_label((void *)n, strdup(text), (lbl->html ? LT_HTML : LT_NONE),
lbl->fontsize,
lbl->fontname,
lbl->fontcolor);
- if (lbl->html) {
- if (make_html_label(sg->root, fp->lp, n))
- agerr(AGPREV, "in label of node %s\n", n->name);
- }
fp->LR = TRUE;
hstsp = tsp = text;
}
typedef struct textlabel_t {
char *text, *fontname, *fontcolor;
+ int charset;
double fontsize;
pointf dimen; /* the diagonal size of the label (estimated by layout) */
pointf space; /* the diagonal size of the space for the label */
double scale;
double ratio; /* set only if ratio_kind == R_VALUE */
double dpi;
- point margin;
- point page;
- point size;
+ pointf margin;
+ pointf page;
+ pointf size;
boolean filled;
boolean landscape;
boolean centered;
void common_init_node(node_t * n)
{
char *str;
- int lbl_kind = LT_NONE;
- graph_t *sg = n->graph;
ND_width(n) =
late_double(n, N_width, DEFAULT_NODEWIDTH, MIN_NODEWIDTH);
ND_height(n) =
late_double(n, N_height, DEFAULT_NODEHEIGHT, MIN_NODEHEIGHT);
+ ND_shape(n) =
+ bind_shape(late_nnstring(n, N_shape, DEFAULT_NODESHAPE), n);
if (N_label == NULL)
str = NODENAME_ESC;
- else {
+ else
str = agxget(n, N_label->index);
- if (aghtmlstr(str)) lbl_kind = LT_HTML;
- }
- if (lbl_kind)
- str = strdup(str);
- else
- str = strdup_and_subst_obj(str, (void*)n);
- ND_shape(n) =
- bind_shape(late_nnstring(n, N_shape, DEFAULT_NODESHAPE), n);
- if (shapeOf(n) == SH_RECORD)
- lbl_kind |= LT_RECD;
- ND_label(n) = make_label(sg->root, lbl_kind, str,
+ ND_label(n) = make_label((void*)n, str,
+ ((aghtmlstr(str) ? LT_HTML : LT_NONE) | ( (shapeOf(n) == SH_RECORD) ? LT_RECD : LT_NONE)),
late_double(n, N_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE),
late_nnstring(n, N_fontname, DEFAULT_FONTNAME),
late_nnstring(n, N_fontcolor, DEFAULT_COLOR));
- if (lbl_kind == LT_HTML) {
- if (make_html_label(sg->root, ND_label(n), n))
- agerr(AGPREV, "in label of node %s\n", n->name);
- }
ND_showboxes(n) = late_int(n, N_showboxes, 0, 0);
ND_shape(n)->fns->initfn(n);
}
-static void edgeError(edge_t * e, char *msg)
-{
- char *edgeop;
-
- if (AG_IS_DIRECTED(e->tail->graph))
- edgeop = "->";
- else
- edgeop = "--";
- agerr(AGPREV, "for %s of edge %s %s %s\n",
- msg, e->tail->name, edgeop, e->head->name);
-}
-
struct fontinfo {
double fontsize;
char *fontname;
static void initFontEdgeAttr(edge_t * e, struct fontinfo *fi)
{
- fi->fontsize =
- late_double(e, E_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE);
+ fi->fontsize = late_double(e, E_fontsize, DEFAULT_FONTSIZE, MIN_FONTSIZE);
fi->fontname = late_nnstring(e, E_fontname, DEFAULT_FONTNAME);
fi->fontcolor = late_nnstring(e, E_fontcolor, DEFAULT_COLOR);
}
initFontLabelEdgeAttr(edge_t * e, struct fontinfo *fi,
struct fontinfo *lfi)
{
- if (!fi->fontname)
- initFontEdgeAttr(e, fi);
- lfi->fontsize =
- late_double(e, E_labelfontsize, fi->fontsize, MIN_FONTSIZE);
+ if (!fi->fontname) initFontEdgeAttr(e, fi);
+ lfi->fontsize = late_double(e, E_labelfontsize, fi->fontsize, MIN_FONTSIZE);
lfi->fontname = late_nnstring(e, E_labelfontname, fi->fontname);
lfi->fontcolor = late_nnstring(e, E_labelfontcolor, fi->fontcolor);
}
/* return true if edge has label */
int common_init_edge(edge_t * e)
{
- char *s;
+ char *str;
int r = 0;
struct fontinfo fi;
struct fontinfo lfi;
graph_t *sg = e->tail->graph;
- int lbl_kind;
fi.fontname = NULL;
lfi.fontname = NULL;
- if (E_label && (s = agxget(e, E_label->index)) && (s[0])) {
+ if (E_label && (str = agxget(e, E_label->index)) && (str[0])) {
r = 1;
- if (aghtmlstr(s)) lbl_kind = LT_HTML;
- else lbl_kind = LT_NONE;
- if (lbl_kind)
- s = strdup(s);
- else
- s = strdup_and_subst_obj(s, (void*)e);
initFontEdgeAttr(e, &fi);
- ED_label(e) = make_label(sg->root, lbl_kind, s,
+ ED_label(e) = make_label((void*)e, str, (aghtmlstr(str) ? LT_HTML : LT_NONE),
fi.fontsize, fi.fontname, fi.fontcolor);
- if (lbl_kind == LT_HTML) {
- if (make_html_label(sg->root, ED_label(e), e) == 1)
- edgeError(e, "label");
- }
GD_has_labels(sg) |= EDGE_LABEL;
ED_label_ontop(e) =
mapbool(late_string(e, E_label_float, "false"));
/* vladimir */
- if (E_headlabel && (s = agxget(e, E_headlabel->index)) && (s[0])) {
- if (aghtmlstr(s)) lbl_kind = LT_HTML;
- else lbl_kind = LT_NONE;
- if (lbl_kind)
- s = strdup(s);
- else
- s = strdup_and_subst_obj(s, (void*)e);
+ if (E_headlabel && (str = agxget(e, E_headlabel->index)) && (str[0])) {
initFontLabelEdgeAttr(e, &fi, &lfi);
- ED_head_label(e) = make_label(sg->root, lbl_kind, s,
+ ED_head_label(e) = make_label((void*)e, str, (aghtmlstr(str) ? LT_HTML : LT_NONE),
lfi.fontsize, lfi.fontname, lfi.fontcolor);
- if (lbl_kind) {
- if (make_html_label(sg->root, ED_head_label(e), e) == 1)
- edgeError(e, "head label");
- }
GD_has_labels(sg) |= HEAD_LABEL;
}
- if (E_taillabel && (s = agxget(e, E_taillabel->index)) && (s[0])) {
- if (aghtmlstr(s)) lbl_kind = LT_HTML;
- else lbl_kind = LT_NONE;
- if (lbl_kind)
- s = strdup(s);
- else
- s = strdup_and_subst_obj(s, (void*)e);
+ if (E_taillabel && (str = agxget(e, E_taillabel->index)) && (str[0])) {
if (!lfi.fontname)
initFontLabelEdgeAttr(e, &fi, &lfi);
- ED_tail_label(e) = make_label(sg->root, lbl_kind, s,
+ ED_tail_label(e) = make_label((void*)e, str, (aghtmlstr(str) ? LT_HTML : LT_NONE),
lfi.fontsize, lfi.fontname, lfi.fontcolor);
- if (lbl_kind) {
- if (make_html_label(sg->root, ED_tail_label(e), e) == 1)
- edgeError(e, "tail label");
- }
GD_has_labels(sg) |= TAIL_LABEL;
}
/* end vladimir */
/* We still accept ports beginning with colons but this is deprecated */
- s = agget(e, TAIL_ID);
- if (s[0])
+ str = agget(e, TAIL_ID);
+ if (str[0])
ND_has_port(e->tail) = TRUE;
- ED_tail_port(e) = chkPort (ND_shape(e->tail)->fns->portfn,e->tail, s);
+ ED_tail_port(e) = chkPort (ND_shape(e->tail)->fns->portfn,e->tail, str);
if (noClip(e, E_tailclip))
ED_tail_port(e).clip = FALSE;
- s = agget(e, HEAD_ID);
- if (s[0])
+ str = agget(e, HEAD_ID);
+ if (str[0])
ND_has_port(e->head) = TRUE;
- ED_head_port(e) = chkPort(ND_shape(e->head)->fns->portfn,e->head, s);
+ ED_head_port(e) = chkPort(ND_shape(e->head)->fns->portfn,e->head, str);
if (noClip(e, E_headclip))
ED_head_port(e).clip = FALSE;
static void compress_graph(graph_t * g)
{
double x;
- point p;
+ pointf p;
if (GD_drawing(g)->ratio_kind != R_COMPRESS)
return;
static boolean idealsize(graph_t * g, double minallowed)
{
double xf, yf, f, R;
- point b, relpage, margin;
+ pointf b, relpage, margin;
/* try for one page */
relpage = GD_drawing(g)->page;
- if (relpage.x == 0)
+ if (relpage.x < 0.001 || relpage.y < 0.001)
return FALSE; /* no page was specified */
margin = GD_drawing(g)->margin;
- relpage = sub_points(relpage, margin);
- relpage = sub_points(relpage, margin);
+ relpage = sub_pointfs(relpage, margin);
+ relpage = sub_pointfs(relpage, margin);
b.x = GD_bb(g).UR.x;
b.y = GD_bb(g).UR.y;
- xf = (double) relpage.x / b.x;
- yf = (double) relpage.y / b.y;
+ xf = relpage.x / b.x;
+ yf = relpage.y / b.y;
if ((xf >= 1.0) && (yf >= 1.0))
return FALSE; /* fits on one page */
pp->kind = 0;
if (sides >= 3) { /* real polygon */
+ verts = N_GNEW(sides, Point);
if (pp->kind == BOX) {
/* To do an additive margin, we rely on knowing that
* the vertices are CCW starting from the UR
else {
for (i = 0; i < sides; i++) {
double h = LEN(poly->vertices[i].x,poly->vertices[i].y);
+fprintf(stderr,"v=%g,%g h=%g\n", poly->vertices[i].x, poly->vertices[i].y, h);
verts[i].x = poly->vertices[i].x * (1.0 + xmargin/h);
verts[i].y = poly->vertices[i].y * (1.0 + ymargin/h);
verts[i].x = PS2INCH(verts[i].x);
cairo_rotate(cr, -job->rotation * M_PI / 180.);
cairo_translate(cr, job->translation.x, -job->translation.y);
- cairo_rectangle(cr,
- job->clip.LL.x,
- - job->clip.LL.y,
- job->clip.UR.x - job->clip.LL.x,
- - (job->clip.UR.y - job->clip.LL.y));
+ cairo_rectangle(cr, job->clip.LL.x, - job->clip.LL.y,
+ job->clip.UR.x - job->clip.LL.x, - (job->clip.UR.y - job->clip.LL.y));
cairo_clip(cr);
}