void GVEdge::setGVEdgeLabelSize(int width_pixels, int height_pixels) { //update GV l width char label[256]; sprintf(label,"<table width=\"%d\" height=\"%d\"><tr><td>Label</td></tr></table>", width_pixels, height_pixels); #ifdef USE_LIBGRAPH_NOT_LIBCGRAPH char* html = agstrdup_html(label); agsafeset(this->gv_edge, (char*)"label", html, (char*)"html"); agstrfree(html); #else char* html = agstrdup_html(this->layout->getGVGraph(), label); agsafeset(this->gv_edge, (char*)"label", html, (char*)"html"); agstrfree(this->layout->getGVGraph(), html); #endif //DBG() << "(" << width_pixels<< ", " << height_pixels << ") for label '" << agget (this->gv_edge, (char*)"label") << "'"; }
/* copyAttr: * Copy attributes from src to tgt. Overrides currently * defined values. * FIX: we should probably use the default value of the source * graph when initializing the attribute, rather than "". * NOTE: We do not assume src and tgt have the same kind. */ int copyAttr(Agobj_t * src, Agobj_t * tgt) { Agraph_t *srcg; Agraph_t *tgtg; Agsym_t *sym = 0; Agsym_t *tsym = 0; int skind = AGTYPE(src); int tkind = AGTYPE(tgt); char* val; srcg = agraphof(src); tgtg = agraphof(tgt); while ((sym = agnxtattr(srcg, skind, sym))) { tsym = agattrsym(tgt, sym->name); if (!tsym) tsym = agattr(tgtg, tkind, sym->name, sym->defval); val = agxget(src, sym); if (aghtmlstr (val)) { val = agstrdup_html (tgtg, val); agxset(tgt, tsym, val); agstrfree (tgtg, val); } else agxset(tgt, tsym, val); } return 0; }
static void myagxset(void *obj, Agsym_t *a, char *val) { int len; char *hs; if (a->name[0] == 'l' && val[0] == '<' && strcmp(a->name, "label") == 0) { len = strlen(val); if (val[len-1] == '>') { hs = strdup(val+1); *(hs+len-2) = '\0'; val = agstrdup_html(hs); free(hs); } } agxset(obj, a->index, val); }
/* toHtml: * Create a string marked as HTML */ char *toHtml(Agraph_t* g, char *arg) { return agstrdup_html (g, arg); }