示例#1
0
static void tkgen_canvas(GVJ_t * job)
{
   if (job->external_context) 
	gvputs(job, job->imagedata);
   else
	gvputs(job, "$c");
}
示例#2
0
static void svg_grstyle(GVJ_t * job, int filled, int gid)
{
    obj_state_t *obj = job->obj;

    gvputs(job, " fill=\"");
    if (filled == GRADIENT) {
	gvprintf(job, "url(#l_%d)", gid);
    } else if (filled == RGRADIENT) {
	gvprintf(job, "url(#r_%d)", gid);
    } else if (filled) {
	svg_print_color(job, obj->fillcolor);
	if (obj->fillcolor.type == RGBA_BYTE
	    && obj->fillcolor.u.rgba[3] > 0
	    && obj->fillcolor.u.rgba[3] < 255)
	    gvprintf(job, "\" fill-opacity=\"%f",
		     ((float) obj->fillcolor.u.rgba[3] / 255.0));
    } else {
	gvputs(job, "none");
    }
    gvputs(job, "\" stroke=\"");
    svg_print_color(job, obj->pencolor);
    if (obj->penwidth != PENWIDTH_NORMAL)
	gvprintf(job, "\" stroke-width=\"%g", obj->penwidth);
    if (obj->pen == PEN_DASHED) {
	gvprintf(job, "\" stroke-dasharray=\"%s", sdasharray);
    } else if (obj->pen == PEN_DOTTED) {
	gvprintf(job, "\" stroke-dasharray=\"%s", sdotarray);
    }
    if (obj->pencolor.type == RGBA_BYTE && obj->pencolor.u.rgba[3] > 0
	&& obj->pencolor.u.rgba[3] < 255)
	gvprintf(job, "\" stroke-opacity=\"%f",
		 ((float) obj->pencolor.u.rgba[3] / 255.0));

    gvputs(job, "\"");
}
示例#3
0
static void svg_begin_layer(GVJ_t * job, char *layername, int layerNum,
			    int numLayers)
{
    gvputs(job, "<g id=\"");
    gvputs(job, xml_string(layername));
    gvputs(job, "\" class=\"layer\">\n");
}
示例#4
0
static void write_xdots (char * val, GVJ_t * job, state_t* sp)
{
    xdot* cmds;
    int i;
    int not_first = 0;

    if (!val || (*val == '\0')) return;

    cmds = parseXDot(val);
    if (!cmds) {
	agerr(AGWARN, "Could not parse xdot \"%s\"\n", val);
	return;
    }

    gvputs(job, "\n");
    indent(job, sp->Level++);
    gvputs(job, "[\n");
    for (i = 0; i < cmds->cnt; i++) {
	if (not_first) 
	    gvputs(job, ",\n");
	else
	    not_first = 1;
	write_xdot (cmds->ops+i, job, sp);
    }
    sp->Level--;
    gvputs(job, "\n");
    indent(job, sp->Level);
    gvputs(job, "]");
    freeXDot(cmds);
}
	void Char::Print(GVJ_t* job) const
	{
		gvputs(job, "<Char>\n");
		gvprintf(job, "<Color>#%02X%02X%02X</Color>\n", _red, _green, _blue);
		gvprintf(job, "<Size>%f</Size>\n", _size * job->scale.x * INCHES_PER_POINT);	/* scale font size, VDX uses inches */
		gvputs(job, "</Char>\n");
	}
static void psgen_begin_job(GVJ_t * job)
{
    gvputs(job, "%!PS-Adobe-3.0");
    if (job->render.id == FORMAT_EPS)
	gvputs(job, " EPSF-3.0\n");
    else
	gvputs(job, "\n");
    gvprintf(job, "%%%%Creator: %s version %s (%s)\n",
	    job->common->info[0], job->common->info[1], job->common->info[2]);
}
示例#7
0
static void svg_begin_cluster(GVJ_t * job)
{
    obj_state_t *obj = job->obj;

    svg_print_id_class(job, obj->id, NULL, "cluster", obj->u.sg);
    gvputs(job, ">\n");
    gvputs(job, "<title>");
    gvputs(job, xml_string(agnameof(obj->u.g)));
    gvputs(job, "</title>\n");
}
示例#8
0
static void tkgen_polygon(GVJ_t * job, pointf * A, int n, int filled)
{
    obj_state_t *obj = job->obj;

    if (obj->pen != PEN_NONE) {
        tkgen_canvas(job);
        gvputs(job, " create polygon ");
        gvprintpointflist(job, A, n);
        gvputs(job, " -fill ");
        if (filled)
            tkgen_print_color(job, obj->fillcolor);
        else if (first_periphery)
            /* tk polygons default to black fill, some fill
	     * is necessary else "canvas find overlapping" doesn't
	     * work as expected, use white instead */
            gvputs(job, "white");
        else
            gvputs(job, "\"\"");
	if (first_periphery == 1) 
	    first_periphery = 0;
        gvputs(job, " -width ");
        gvprintdouble(job, obj->penwidth);
        gvputs(job, " -outline ");
	tkgen_print_color(job, obj->pencolor);
        if (obj->pen == PEN_DASHED)
	    gvputs(job, " -dash 5");
        if (obj->pen == PEN_DOTTED)
	    gvputs(job, " -dash 2");
        tkgen_print_tags(job);
        gvputs(job, "\n");
    }
}
示例#9
0
static void tkgen_begin_graph(GVJ_t * job)
{
    obj_state_t *obj = job->obj;

    gvputs(job, "#");
    if (agnameof(obj->u.g)[0]) {
        gvputs(job, " Title: ");
	gvputs(job, tkgen_string(agnameof(obj->u.g)));
    }
    gvprintf(job, " Pages: %d\n", job->pagesArraySize.x * job->pagesArraySize.y);
}
示例#10
0
static void svg_polyline(GVJ_t * job, pointf * A, int n)
{
    int i;

    gvputs(job, "<polyline");
    svg_grstyle(job, 0, 0);
    gvputs(job, " points=\"");
    for (i = 0; i < n; i++)
	gvprintf(job, "%g,%g ", A[i].x, -A[i].y);
    gvputs(job, "\"/>\n");
}
示例#11
0
static void vrml_begin_page(GVJ_t *job)
{
    Scale = (double) DEFAULT_DPI / POINTS_PER_INCH;
    gvputs(job,   "#VRML V2.0 utf8\n");

    Saw_skycolor = FALSE;
    MinZ = MAXDOUBLE;
    gvputs(job,   "Group { children [\n");
    gvputs(job,   "  Transform {\n");
    gvprintf(job, "    scale %.3f %.3f %.3f\n", .0278, .0278, .0278);
    gvputs(job,   "    children [\n");
}
示例#12
0
static void vml_grfill(GVJ_t * job, int filled)
{
    obj_state_t *obj = job->obj;

    if (filled){
        gvputs(job, " filled=\"true\" fillcolor=\"");
	vml_print_color(job, obj->fillcolor);
        gvputs(job, "\" ");
    }else{
	gvputs(job, " filled=\"false\" ");
    }
}
示例#13
0
static void mif_style(GVJ_t * job, int filled)
{
    obj_state_t *obj = job->obj;

    gvputs(job, "style=\"fill:");
    if (filled)
	mif_color(job->obj->fillcolor);
    else
        gvputs(job, "none");

    gvputs(job, ";stroke:");
     


    while ((line = *s++)) {
	if (streq(line, "solid"))
	    pen = P_SOLID;
	else if (streq(line, "dashed"))
	    pen = P_DASHED;
	else if (streq(line, "dotted"))
	    pen = P_DOTTED;
	else if (streq(line, "invis"))
	    pen = P_NONE;
	else if (streq(line, "bold"))
	    penwidth = WIDTH_BOLD;
	else if (streq(line, "filled"))
	    fill = P_SOLID;
	else if (streq(line, "unfilled"))
	    fill = P_NONE;
	else {
	    agerr(AGERR,
		  "mif_style: unsupported style %s - ignoring\n",
		  line);
	}
    }

    fw = fa = "Regular";
    switch (cp->fontopt) {
    case BOLD:
	fw = "Bold";
	break;
    case ITALIC:
	fa = "Italic";
	break;
    }
    gvprintf(job, 
	    "<Font <FFamily `%s'> <FSize %.1f pt> <FWeight %s> <FAngle %s>>\n",
	    cp->fontfam, job->scale.x * cp->fontsz, fw, fa);

    gvprintf(job, "<Pen %d> <Fill %d> <PenWidth %d>\n",
	    job->pen, job->fill, job->penwidth);
}
static void psgen_end_job(GVJ_t * job)
{
    gvputs(job, "%%Trailer\n");
    if (job->render.id != FORMAT_EPS)
        gvprintf(job, "%%%%Pages: %d\n", job->common->viewNum);
    if (job->common->show_boxes == NULL)
        if (job->render.id != FORMAT_EPS)
	    gvprintf(job, "%%%%BoundingBox: %d %d %d %d\n",
	        job->boundingBox.LL.x, job->boundingBox.LL.y,
	        job->boundingBox.UR.x, job->boundingBox.UR.y);
    gvputs(job, "end\nrestore\n");
    gvputs(job, "%%EOF\n");
}
static void psgen_end_page(GVJ_t * job)
{
    if (job->common->show_boxes) {
	gvputs(job, "0 0 0 edgecolor\n");
	cat_libfile(job, NULL, job->common->show_boxes + 1);
    }
    /* the showpage is really a no-op, but at least one PS processor
     * out there needs to see this literal token.  endpage does the real work.
     */
    gvputs(job, "endpage\nshowpage\ngrestore\n");
    gvputs(job, "%%PageTrailer\n");
    gvprintf(job, "%%%%EndPage: %d\n", job->common->viewNum);
}
	/* output the hyperlink */
	void Hyperlink::Print(GVJ_t* job, unsigned int id, bool isDefault) const
	{
		gvprintf(job, "<Hyperlink ID='%d'>\n", id);
		if (_description)
			gvprintf(job, "<Description>%s</Description>\n", _description);
		if (_address)
			gvprintf(job, "<Address>%s</Address>\n", _address);
		if (_frame)
			gvprintf(job, "<Frame>%s</Frame>\n", _frame);
		if (isDefault)
			gvputs(job, "<Default>1</Default>\n");
		gvputs(job, "</Hyperlink>\n");
	}
static void
psgen_bezier(GVJ_t * job, pointf * A, int n, int arrow_at_start,
	     int arrow_at_end, int filled)
{
    int j;

    if (filled && job->obj->fillcolor.u.HSVA[3] > .5) {
	ps_set_color(job, &(job->obj->fillcolor));
	gvputs(job, "newpath ");
	gvprintpointf(job, A[0]);
	gvputs(job, " moveto\n");
	for (j = 1; j < n; j += 3) {
	    gvprintpointflist(job, &A[j], 3);
	    gvputs(job, " curveto\n");
	}
	gvputs(job, "closepath fill\n");
    }
    if (job->obj->pencolor.u.HSVA[3] > .5) {
        ps_set_pen_style(job);
        ps_set_color(job, &(job->obj->pencolor));
	gvputs(job, "newpath ");
	gvprintpointf(job, A[0]);
	gvputs(job, " moveto\n");
	for (j = 1; j < n; j += 3) {
	    gvprintpointflist(job, &A[j], 3);
	    gvputs(job, " curveto\n");
	}
        gvputs(job, "stroke\n");
    }
}
示例#18
0
static void svg_begin_edge(GVJ_t * job)
{
    obj_state_t *obj = job->obj;
    char *ename;

    svg_print_id_class(job, obj->id, NULL, "edge", obj->u.e);
    gvputs(job, ">\n");

    gvputs(job, "<title>");
    ename = strdup_and_subst_obj("\\E", (void *) (obj->u.e));
    gvputs(job, xml_string(ename));
    free(ename);
    gvputs(job, "</title>\n");
}
static void psgen_polygon(GVJ_t * job, pointf * A, int n, int filled)
{
    int j;

    if (filled && job->obj->fillcolor.u.HSVA[3] > .5) {
	ps_set_color(job, &(job->obj->fillcolor));
	gvputs(job, "newpath ");
	gvprintpointf(job, A[0]);
	gvputs(job, " moveto\n");
	for (j = 1; j < n; j++) {
	    gvprintpointf(job, A[j]);
	    gvputs(job, " lineto\n");
        }
	gvputs(job, "closepath fill\n");
    }
    if (job->obj->pencolor.u.HSVA[3] > .5) {
        ps_set_pen_style(job);
        ps_set_color(job, &(job->obj->pencolor));
	gvputs(job, "newpath ");
	gvprintpointf(job, A[0]);
	gvputs(job, " moveto\n");
        for (j = 1; j < n; j++) {
	    gvprintpointf(job, A[j]);
	    gvputs(job, " lineto\n");
	}
        gvputs(job, "closepath stroke\n");
    }
}
示例#20
0
static void mif_color_declaration(GVJ_t * job, char *str, int CMYK[4])
{
    gvputs(job, " <Color \n");
    gvprintf(job, "  <ColorTag `%s'>\n", str);
    gvprintf(job, "  <ColorCyan  %d.000000>\n", CMYK[0]);
    gvprintf(job, "  <ColorMagenta  %d.000000>\n", CMYK[1]);
    gvprintf(job, "  <ColorYellow  %d.000000>\n", CMYK[2]);
    gvprintf(job, "  <ColorBlack  %d.000000>\n", CMYK[3]);
    if (isupper(str[0])) {
        gvprintf(job, "  <ColorAttribute ColorIs%s>\n", str);
        gvputs(job, "  <ColorAttribute ColorIsReserved>\n");
    }
    gvputs(job, " > # end of Color\n");
}
示例#21
0
static void svg_print_id_class(GVJ_t * job, char* id, char* idx, char* kind, void* obj)
{
    char* str;

    gvputs(job, "<g id=\"");
    gvputs(job, xml_string(id));
    if (idx)
	gvprintf (job, "_%s", xml_string(idx));
    gvprintf(job, "\" class=\"%s", kind);
    if ((str = agget(obj, "class")) && *str) {
	gvputs(job, " ");
	gvputs(job, xml_string(str));
    }
    gvputs(job, "\"");
}
static void psgen_begin_anchor(GVJ_t *job, char *url, char *tooltip, char *target, char *id)
{
    obj_state_t *obj = job->obj;

    if (url && obj->url_map_p) {
        gvputs(job, "[ /Rect [ ");
	gvprintpointflist(job, obj->url_map_p, 2);
        gvputs(job, " ]\n");
        gvprintf(job, "  /Border [ 0 0 0 ]\n"
		"  /Action << /Subtype /URI /URI %s >>\n"
		"  /Subtype /Link\n"
		"/ANN pdfmark\n",
		ps_string(url, isLatin1));
    }
}
示例#23
0
static void svg_begin_node(GVJ_t * job)
{
    obj_state_t *obj = job->obj;
    char* idx;

    if (job->layerNum > 1)
	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, "<title>");
    gvputs(job, xml_string(agnameof(obj->u.n)));
    gvputs(job, "</title>\n");
}
示例#24
0
static void vml_grstroke(GVJ_t * job, int filled)
{
    obj_state_t *obj = job->obj;

    gvputs(job, "<v:stroke color=\"");
    vml_print_color(job, obj->pencolor);
    if (obj->penwidth != PENWIDTH_NORMAL)
	gvprintf(job, "\" weight=\"%.0fpt", obj->penwidth);
    if (obj->pen == PEN_DASHED) {
	gvputs(job, "\" dashstyle=\"dash");
    } else if (obj->pen == PEN_DOTTED) {
	gvputs(job, "\" dashstyle=\"dot");
    }
    gvputs(job, "\" />");
}
static void psgen_begin_graph(GVJ_t * job)
{
    obj_state_t *obj = job->obj;

    setupLatin1 = FALSE;

    if (job->common->viewNum == 0) {
        gvprintf(job, "%%%%Title: %s\n", agnameof(obj->u.g));
    	if (job->render.id != FORMAT_EPS)
            gvputs(job, "%%Pages: (atend)\n");
	else
	    gvputs(job, "%%Pages: 1\n");
        if (job->common->show_boxes == NULL) {
    	    if (job->render.id != FORMAT_EPS)
                gvputs(job, "%%BoundingBox: (atend)\n");
	    else
	        gvprintf(job, "%%%%BoundingBox: %d %d %d %d\n",
	            job->pageBoundingBox.LL.x, job->pageBoundingBox.LL.y,
	            job->pageBoundingBox.UR.x, job->pageBoundingBox.UR.y);
	}
        gvputs(job, "%%EndComments\nsave\n");
        /* include shape library */
        cat_libfile(job, job->common->lib, ps_txt);
	/* include epsf */
        epsf_define(job);
        if (job->common->show_boxes) {
            const char* args[2];
            args[0] = job->common->show_boxes[0];
            args[1] = NULL;
            cat_libfile(job, NULL, args);
        }
    }
    isLatin1 = (GD_charset(obj->u.g) == CHAR_LATIN1);
    /* We always setup Latin1. The charset info is always output,
     * and installing it is cheap. With it installed, we can then
     * rely on ps_string to convert UTF-8 characters whose encoding
     * is in the range of Latin-1 into the Latin-1 equivalent and
     * get the expected PostScript output.
     */
    if (!setupLatin1) {
	gvputs(job, "setupLatin1\n");	/* as defined in ps header */
	setupLatin1 = TRUE;
    }
    /*  Set base URL for relative links (for Distiller >= 3.0)  */
    if (obj->url)
	gvprintf(job, "[ {Catalog} << /URI << /Base (%s) >> >>\n"
		"/PUT pdfmark\n", obj->url);
}
示例#26
0
static void svg_polygon(GVJ_t * job, pointf * A, int n, int filled)
{
    int i, gid = 0;
    if (filled == GRADIENT) {
	gid = svg_gradstyle(job, A, n);
    } else if (filled == (RGRADIENT)) {
	gid = svg_rgradstyle(job, A, n);
    }
    gvputs(job, "<polygon");
    svg_grstyle(job, filled, gid);
    gvputs(job, " points=\"");
    for (i = 0; i < n; i++)
	gvprintf(job, "%g,%g ", A[i].x, -A[i].y);
    gvprintf(job, "%g,%g", A[0].x, -A[0].y);	/* because Adobe SVG is broken */
    gvputs(job, "\"/>\n");
}
static void
ps_set_pen_style(GVJ_t *job)
{
    double penwidth = job->obj->penwidth;
    char *p, *line, **s = job->obj->rawstyle;

    gvprintdouble(job, penwidth);
    gvputs(job," setlinewidth\n");

    while (s && (p = line = *s++)) {
	if (strcmp(line, "setlinewidth") == 0)
	    continue;
	while (*p)
	    p++;
	p++;
	while (*p) {
            gvprintf(job,"%s ", p);
	    while (*p)
		p++;
	    p++;
	}
	if (strcmp(line, "invis") == 0)
	    job->obj->penwidth = 0;
	gvprintf(job, "%s\n", line);
    }
}
static void psgen_textspan(GVJ_t * job, pointf p, textspan_t * span)
{
    char *str;

    if (job->obj->pencolor.u.HSVA[3] < .5)
	return;  /* skip transparent text */

    ps_set_color(job, &(job->obj->pencolor));
    gvprintdouble(job, span->font->size);
    gvprintf(job, " /%s set_font\n", span->font->name);
    str = ps_string(span->str,isLatin1);
    switch (span->just) {
    case 'r':
        p.x -= span->size.x;
        break;
    case 'l':
        p.x -= 0.0;
        break;
    case 'n':
    default:
        p.x -= span->size.x / 2.0;
        break;
    }
    p.y += span->yoffset_centerline;
    gvprintpointf(job, p);
    gvputs(job, " moveto ");
    gvprintdouble(job, span->size.x);
    gvprintf(job, " %s alignedtext\n", str);
}
示例#29
0
static void svg_print_color(GVJ_t * job, gvcolor_t color)
{
    switch (color.type) {
    case COLOR_STRING:
	gvputs(job, color.u.string);
	break;
    case RGBA_BYTE:
	if (color.u.rgba[3] == 0)	/* transparent */
	    gvputs(job, "transparent");
	else
	    gvprintf(job, "#%02x%02x%02x",
		     color.u.rgba[0], color.u.rgba[1], color.u.rgba[2]);
	break;
    default:
	assert(0);		/* internal error */
    }
}
示例#30
0
static void svg_ellipse(GVJ_t * job, pointf * A, int filled)
{
    int gid = 0;

    /* A[] contains 2 points: the center and corner. */
    if (filled == GRADIENT) {
	gid = svg_gradstyle(job, A, 2);
    } else if (filled == (RGRADIENT)) {
	gid = svg_rgradstyle(job, A, 2);
    }
    gvputs(job, "<ellipse");
    svg_grstyle(job, filled, gid);
    gvprintf(job, " cx=\"%g\" cy=\"%g\"", A[0].x, -A[0].y);
    gvprintf(job, " rx=\"%g\" ry=\"%g\"",
	     A[1].x - A[0].x, A[1].y - A[0].y);
    gvputs(job, "/>\n");
}