From: Emden Gansner Date: Fri, 10 Jun 2016 20:07:40 +0000 (-0400) Subject: Factor out writing of id and combine with writing class; X-Git-Tag: TRAVIS_CI_BUILD_EXPERIMENTAL~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f9ca1367628120c00bc67909671889b813a9a3e7;p=graphviz Factor out writing of id and combine with writing class; put quote ending class value in svg_print_id_class. --- diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index 6e23584bb..a2e34532a 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -80,15 +80,20 @@ static void svg_bzptarray(GVJ_t * job, pointf * A, int n) #endif } -static void svg_print_class(GVJ_t * job, char* kind, void* obj) +static void svg_print_id_class(GVJ_t * job, char* id, char* idx, char* kind, void* obj) { char* str; + gvputs(job, "obj; - gvputs(job, "u.g); - gvputs(job, "\">\n"); + svg_print_id_class(job, layername, NULL, "layer", obj->u.g); + gvputs(job, ">\n"); } static void svg_end_layer(GVJ_t * job) @@ -242,11 +245,9 @@ static void svg_begin_page(GVJ_t * job) /* its really just a page of the graph, but its still a graph, * and it is the entire graph if we're not currently paging */ - gvputs(job, "id)); - svg_print_class(job, "graph", obj->u.g); + svg_print_id_class(job, obj->id, NULL, "graph", obj->u.g); gvprintf(job, - "\" transform=\"scale(%g %g) rotate(%d) translate(%g %g)\">\n", + " transform=\"scale(%g %g) rotate(%d) translate(%g %g)\">\n", job->scale.x, job->scale.y, -job->rotation, job->translation.x, -job->translation.y); /* default style */ @@ -266,10 +267,8 @@ static void svg_begin_cluster(GVJ_t * job) { obj_state_t *obj = job->obj; - gvputs(job, "id)); - svg_print_class(job, "cluster", obj->u.sg); - gvputs(job, "\">\n"); + svg_print_id_class(job, obj->id, NULL, "cluster", obj->u.sg); + gvputs(job, ">\n"); gvputs(job, ""); gvputs(job, xml_string(agnameof(obj->u.g))); gvputs(job, "\n"); @@ -283,13 +282,14 @@ static void svg_end_cluster(GVJ_t * job) static void svg_begin_node(GVJ_t * job) { obj_state_t *obj = job->obj; + char* idx; - gvputs(job, "id)); if (job->layerNum > 1) - gvprintf (job, "_%s", xml_string(job->gvc->layerIDs[job->layerNum])); - svg_print_class(job, "node", obj->u.n); - gvputs(job, "\">\n"); + idx = job->gvc->layerIDs[job->layerNum]; + else + idx = NULL; + svg_print_id_class(job, obj->id, idx, "node", obj->u.n); + gvputs(job, ">\n"); gvputs(job, ""); gvputs(job, xml_string(agnameof(obj->u.n))); gvputs(job, "\n"); @@ -305,10 +305,8 @@ static void svg_begin_edge(GVJ_t * job) obj_state_t *obj = job->obj; char *ename; - gvputs(job, "id)); - svg_print_class(job, "edge", obj->u.e); - gvputs(job, "\">\n"); + svg_print_id_class(job, obj->id, NULL, "edge", obj->u.e); + gvputs(job, ">\n"); gvputs(job, ""); ename = strdup_and_subst_obj("\\E", (void *) (obj->u.e));