]> granicus.if.org Git - graphviz/commitdiff
Add json0 output to provide layout info comparable to -Tdot but in json.
authorEmden R. Gansner <erg@emdenrg.net>
Sun, 14 Feb 2016 20:10:50 +0000 (15:10 -0500)
committerEmden R. Gansner <erg@emdenrg.net>
Sun, 14 Feb 2016 20:10:50 +0000 (15:10 -0500)
plugin/core/gvrender_core_json.c

index 68c0c33d019e41a06b86cb5be7fe02d704d8f0de..3c348014544e978e797ab8457d586cd1dfbd9f79 100644 (file)
 
 typedef enum {
        FORMAT_JSON,
+       FORMAT_JSON0,
 } format_type;
 
 typedef struct {
     int Level;
-    int isLatin;
-    unsigned char Attrs_not_written_flag;
+    boolean isLatin;
+    boolean Attrs_not_written_flag;
 } state_t;
 
 typedef struct {
@@ -61,10 +62,12 @@ typedef struct {
 
 static void json_begin_graph(GVJ_t *job)
 {
-    GVC_t* gvc = gvCloneGVC (job->gvc); 
-    graph_t *g = job->obj->u.g;
-    gvRender (gvc, g, "xdot", NULL); 
-    gvFreeCloneGVC (gvc);
+    if (job->render.id == FORMAT_JSON) {
+       GVC_t* gvc = gvCloneGVC (job->gvc); 
+       graph_t *g = job->obj->u.g;
+       gvRender (gvc, g, "xdot", NULL); 
+       gvFreeCloneGVC (gvc);
+    }
 }
 
 #define LOCALNAMEPREFIX                '%'
@@ -755,7 +758,7 @@ gvrender_engine_t json_engine = {
     0,                         /* json_library_shape */
 };
 
-gvrender_features_t render_features_json = {
+gvrender_features_t render_features_json0 = {
     GVRENDER_DOES_TRANSFORM,   /* not really - uses raw graph coords */  /* flags */
     0.,                         /* default pad - graph units */
     NULL,                      /* knowncolors */
@@ -763,6 +766,17 @@ gvrender_features_t render_features_json = {
     COLOR_STRING,              /* color_type */
 };
 
+gvrender_features_t render_features_json = {
+    GVRENDER_DOES_TRANSFORM    /* not really - uses raw graph coords */
+       | GVRENDER_DOES_MAPS
+       | GVRENDER_DOES_TARGETS
+       | GVRENDER_DOES_TOOLTIPS, /* flags */
+    0.,                         /* default pad - graph units */
+    NULL,                      /* knowncolors */
+    0,                         /* sizeof knowncolors */
+    COLOR_STRING,              /* color_type */
+};
+
 gvdevice_features_t device_features_json = {
     0,                         /* flags */
     {0.,0.},                   /* default margin - points */
@@ -772,10 +786,12 @@ gvdevice_features_t device_features_json = {
 
 gvplugin_installed_t gvrender_json_types[] = {
     {FORMAT_JSON, "json", 1, &json_engine, &render_features_json},
+    {FORMAT_JSON0, "json0", 1, &json_engine, &render_features_json},
     {0, NULL, 0, NULL, NULL}
 };
 
 gvplugin_installed_t gvdevice_json_types[] = {
     {FORMAT_JSON, "json:json", 1, NULL, &device_features_json},
+    {FORMAT_JSON0, "json0:json0", 1, NULL, &device_features_json},
     {0, NULL, 0, NULL, NULL}
 };