Changeset 419 for trunk/Jgraph


Ignore:
Timestamp:
02/27/08 07:09:03 (11 years ago)
Author:
Nicholas Riley
Message:

Jgraph: Debian changes by pzn@…

Location:
trunk/Jgraph
Files:
20 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Jgraph/README

    r418 r419  
    4747
    4848Author: Jim Plank
    49 Email:  jsp@princeton.edu
    50 USmail: Department of Computer Science
    51         Princeton University
    52         35 Olden St.
    53         Princeton, NJ 08544-2087
     49Page:   http://www.cs.utk.edu/~plank
     50Email:  plank@cs.utk.edu
     51USmail: Associate Professor
     52        Department of Computer Science
     53        University of Tennessee
     54        203 Claxton Complex
     55        1122 Volunteer Blvd.
     56        Knoxville, TN 37996-3450
  • trunk/Jgraph/draw.c

    r418 r419  
    99#include <stdio.h>
    1010#include <math.h>
     11#include <stdlib.h> //by pzn@debian.org
     12#include <string.h> //by pzn@debian.org
    1113
    1214static char real_eof = EOF;
     
    315317              }
    316318              for (i = 0; i < 4; i++) {
    317                 if (fscanf(f, "%d", &(bb[i])) != 1) {
     319                if (fscanf(f, "%d", &(bb[i])) == NULL) {
    318320                  fprintf(stderr, "Error: Eps file '%s': eof in %s\n",
    319321                          c->eps, "bounding box");
     
    642644  Graphs gs_p;
    643645  Graph g;
     646  int page_counter=0;
    644647
    645648  for (gs_p = first(gs); gs_p != nil(gs); gs_p = next(gs_p)) {
     649    page_counter++;
    646650    draw_header(gs_p, pp, landscape);
    647651    for (g = first(gs_p->g); g != nil(gs_p->g); g = next(g)) {
     
    649653    }
    650654    draw_footer(gs_p, pp);
     655  }
     656  if (pp) {
     657      printf("\n%%%%Trailer\n");
     658      printf("%%%%Pages: %i\n",page_counter);
     659      printf("%%%%EOF\n");
    651660  }
    652661}
     
    660669  char c;
    661670
    662   if (gs->page == 1) printf("%%!PS-Adobe-2.0 EPSF-1.2\n");
    663   printf("%%%%Page: %d %d\n", gs->page, gs->page);
    664   if (landscape) {
    665     printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[1], gs->bb[0],
    666             gs->bb[3], gs->bb[2]);
     671  if (gs->page == 1) {
     672      if (pp) {
     673          printf("%%!PS-Adobe-3.0\n");
     674          printf("%%%%Pages: (atend)\n");
     675          printf("%%%%Creator: jgraph\n");
     676          printf("%%%%EndComments\n\n");
     677          printf("%%%%BeginProlog\n");
     678          printf("%%%%EndProlog\n");
     679          printf("%%%%BeginSetup\n");
     680          printf("%%%%EndSetup\n");
     681      } else {
     682          printf("%%!PS-Adobe-2.0 EPSF-1.2\n");
     683          printf("%%%%Creator: jgraph\n");
     684      }
     685  }
     686
     687  if (pp) {
     688      printf("\n%%%%Page: %d %d\n", gs->page, gs->page);
     689      printf("%%%%BeginPageSetup\n");
     690      printf("%%%%EndPageSetup\n\n");
     691  }
     692
     693  if ( (gs->page>1) && !pp ) {
     694      /* tring EPS with more than one page */
     695      fprintf(stderr, "Error: 'newpage' token is not allowed"
     696              " without '-P' command line option.\n");
     697      exit(1);
     698  }
     699
     700  /* if (landscape) {
     701      printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[1], gs->bb[0],
     702             gs->bb[3], gs->bb[2]);
    667703  } else {
    668     printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[0], gs->bb[1],
    669             gs->bb[2], gs->bb[3]);
    670   }
    671 
    672   printf("%%%%EndComments\n");
     704      printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[0], gs->bb[1],
     705             gs->bb[2], gs->bb[3]);
     706  }
     707  printf("%%%%EndComments\n"); */
     708
     709  //BEGIN added by pzn@debian.org
     710  { // expands the bounding box to fit characters with tilde, acute,...
     711    // if user has set JGRAPH_BORDER enviroment variable
     712    int expandborder=0;
     713    char *s;                          \
     714    s=(char *)getenv("JGRAPH_BORDER");
     715    if (s!=NULL) {
     716        expandborder=atoi(s);
     717    }
     718   if (!pp) {
     719    if (landscape) {
     720      printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[1]-expandborder,
     721             gs->bb[0]-expandborder, gs->bb[3]+expandborder,
     722             gs->bb[2]+expandborder);
     723    } else {
     724      printf("%%%%BoundingBox: %d %d %d %d\n", gs->bb[0]-expandborder,
     725             gs->bb[1]-expandborder, gs->bb[2]+expandborder,
     726             gs->bb[3]+expandborder);
     727    }
     728    printf("%%%%EndComments\n\n");
     729   }
     730  }
     731
     732  if (gs->page==1)
     733  //reencode fonts to ISOLatin1 or other
     734  {   //NOTE: this is a preliminary version. It will only work with
     735      //      the default fonts, that are Times-Roman and Times-Bold
     736      // "export JGRAPH_ENCODING=ISOLatin1Encoding" will work in sh
     737      char *s;                          \
     738      s=(char *)getenv("JGRAPH_ENCODING");
     739      if ((s!=NULL) && (strlen(s)>0)) {
     740          comment("Setting font encoding by pzn@debian.org");
     741          printf("/Times-Bold findfont\n");
     742          printf("dup length dict begin\n");
     743          printf(" {1 index /FID ne {def} {pop pop} ifelse} forall\n");
     744          printf(" /Encoding %s def\n",s);
     745          printf(" currentdict\n");
     746          printf("end\n");
     747          printf("/Times-Bold exch definefont pop\n");
     748          printf("/Times-Roman findfont\n");
     749          printf("dup length dict begin\n");
     750          printf(" {1 index /FID ne {def} {pop pop} ifelse} forall\n");
     751          printf(" /Encoding %s def\n",s);
     752          printf(" currentdict\n");
     753          printf("end\n");
     754          printf("/Times-Roman exch definefont pop\n");
     755          comment("End of font encoding");
     756          printf("\n");
     757      }
     758  }
     759  //END added by pzn
     760
    673761  if (landscape) {
    674762    printf("-90 rotate\n");
     
    771859  grestore();
    772860  if (pp) printf("showpage\n"); else printf("\n");
    773 }
    774 
     861
     862  if (pp) {
     863      printf("%%%%PageTrailer\n");
     864  }
     865
     866}
     867
  • trunk/Jgraph/ex2.jgr

    r418 r419  
    2626  marktype none linetype solid
    2727  label : N log N / 35000
    28    pts shell : nawk \
     28   pts shell : awk \
    2929     ' $5 != 0 { \
    3030       print $5,  $5 * log($5) / 35000}' \
     
    5353  marktype none linetype solid\
    5454  label : N log N / 35000\
    55    pts shell : nawk \\
     55   pts shell : awk \\
    5656     ' $5 != 0 { \\
    5757       print $5,  $5 * log($5) / 35000}' \\
  • trunk/Jgraph/exit.c

    r418 r419  
    1515**--
    1616**/
    17 #include <varargs.h>
     17#include <stdarg.h>
    1818
    1919exit(va_alist)
  • trunk/Jgraph/jgraph.1

    r418 r419  
    6565function plotting, and pie graphs.  The latter is impossible to do
    6666with the aid of
    67 \fBjgraph, \fR
     67\fBjgraph\fR,
    6868however, the others can be effected with
    6969\fBjgraph \fR
     
    245245error will be flagged.
    246246(copygraph does not copy the values of the
    247 \fB\fIhash_at\fB, \fImhash_at\fB,\fR
     247\fB\fIhash_at\fR, \fImhash_at\fR,\fR
    248248and
    249249\fB\fI\fIhash_label\fB\fR
     
    259259is the same as appending together the output of separate calls of
    260260jgraph on the text before the
    261 \fB\fInewpage,\fB\fR
     261\fB\fInewpage\fR,\fR
    262262and on the text after the
    263 \fB\fInewpage.\fB\fR
     263\fB\fInewpage.\fR
    264264\fB\fINewpage\fB\fR
    265265will most likely produce bizarre results if the
     
    293293\fB\fIbbox\fB\fR
    294294command.  If there's more than one page in the jgraph file,
    295 \fB\fIY,\fB\fR
     295\fB\fIY\fR,\fR
    296296\fB\fIX\fB\fR
    297297and
     
    308308jgraph output.  Its units are the
    309309final postscript units.  It's probably best to use the
    310 \fB\-p\FR
     310\fB\-p\fR
    311311option
    312312to see what the bounding box is that jgraph produces, and then
    313313alter that accordingly with
    314 \fB\fIbbox.\fB\fR
     314\fB\fIbbox.\fR
    315315The main use for this is to change the automatic centering that jgraph
    316316performs:  Usually the center of the bounding box that jgraph computes
     
    334334files (the token specifies the filename) which will be copied directly
    335335into jgraph's output.
    336 The \fIpreamble\fB is included at the beginning of the output
     336The \fIpreamble\fR is included at the beginning of the output
    337337(after some initial postscript to set things up for jgraph),
    338 and the \fIepilogue\fB is included at the end.  A good use for
    339 the \fIpreamble\fB is to set up a postscript dictionary if you're
     338and the \fIepilogue\fR is included at the end.  A good use for
     339the \fIpreamble\fR is to set up a postscript dictionary if you're
    340340using postscript marks.
    341341.PD
     
    365365If the curve doesn't exist, then this command creates it and starts
    366366editing it. 
    367 \fINewcurve\fB
     367\fINewcurve\fR
    368368and
    369 \fIcurve\fB
     369\fIcurve\fR
    370370interact as
    371 \fInewgraph\fB
    372 and
    373 \fIgraph\fB
     371\fInewgraph\fR
     372and
     373\fIgraph\fR
    374374do.
    375375.TP
     
    413413.TP
    414414\fBcopystring \|[\fIinteger\fB\|]\fR
    415 \fIString\fB
    416 and
    417 \fIcopystring\fB
     415\fIString\fR
     416and
     417\fIcopystring\fR
    418418are to
    419 \fInewstring\fB
     419\fInewstring\fR
    420420as
    421 \fIcurve\fB
    422 and
    423 \fIcopycurve\fB
     421\fIcurve\fR
     422and
     423\fIcopycurve\fR
    424424are to
    425 \fInewcurve.\fB
     425\fInewcurve\fR.
    426426.TP
    427427\fBborder\fR
     
    430430.TP
    431431\fBnoborder\fR
    432 \fIBorder\fR\fB
     432\fIBorder\fR
    433433draws a square border around the area defined by the axes.
    434 \fINoborder\fB
     434\fINoborder\fR
    435435specifies no border.
    436 \fINoborder\fB
     436\fINoborder\fR
    437437is the default. 
    438438.TP
     
    442442.TP
    443443\fBnoclip\fR
    444 \fIClip\fB
     444\fIClip\fR
    445445specifies that all curves in the graph will be clipped -- that is,
    446446no points outside of the of axes will be plotted.  Clipping can also be
    447447specified on a per-curve basis.  The default is
    448 \fInoclip.\fB
     448\fInoclip\fR.
    449449.TP
    450450\fBinherit_axes\fR   
    451451This is an old command which is kept for backward compatibility.
    452 \fICopycurve.\fB
     452\fICopycurve\fR.
    453453is equivalent to:
    454454.PP
     
    465465By default, the bottom left-hand corner of each graph is at point
    466466(0,0) (final postscript units).
    467 \fIX_translate\fB
    468 and
    469 \fIY_translate\fB
     467\fIX_translate\fR
     468and
     469\fIY_translate\fR
    470470translate the bottom left-hand corner of the graph
    471471\fB\|[\fIfloat\fB\|] \fR
     
    475475only one graph is drawn, it will always be centered on the page,
    476476regardless of its
    477 \fIX_translate\fB
    478 and
    479 \fIY_translate\fB
     477\fIX_translate\fR
     478and
     479\fIY_translate\fR
    480480values.  These values are used for relative placement of the graphs.
    481481   To change the centering of the graphs, use
    482 \fIbbox.\fB
     482\fIbbox.\fR
    483483.TP
    484484\fBX \|[\fIfloat\fB\|]\fR
     
    488488\fBY \|[\fIfloat\fB\|]\fR   
    489489These are the same as
    490 \fIX\fB
     490\fIX\fR
    491491and
    492 \fIY\fB
     492\fIY\fR
    493493in the
    494494Top-level commands, except that they let the user continue editing
     
    501501These commands act on the current
    502502axis as chosen by
    503 \fIxaxis\fB
     503\fIxaxis\fR
    504504or
    505 \fIyaxis\fB
     505\fIyaxis\fR
    506506(see GRAPH EDITING COMMANDS).
    507507Axis editing terminates when a graph or top-level command is given.
     
    519519default is linear.  If the axis is set to be logarithmic, then values
    520520<= 0.0 will be disallowed, as they are at negative infinity on the
    521 axis.
     521axis. If you are using logarithmic axes and the labels shows 0 0 1 10
     522instead of 0.01 0.1 1 10, then you should read "hash_format" in this
     523section. Hint: xaxis log hash_format g
    522524.TP
    523525\fBmin \|[\fIfloat\fB\|]\fR
     
    532534option.  Unless stated, all units (for example point
    533535plotting, string plotting, etc.) will be in terms of the
    534 \fImin\fB
    535 and
    536 \fImax\fB
     536\fImin\fR
     537and
     538\fImax\fR
    537539values of the x and y axes.
    538540.TP
     
    557559for the value).  By default, each hash mark
    558560will be labeled with its value. 
    559 \fIHash\fB
     561\fIHash\fR
    560562and
    561 \fIshash\fB
     563\fIshash\fR
    562564are ignored if
    563565the axes are logarithmic.
     
    572574= -1.
    573575If
    574 \fIhash\fB
     576\fIhash\fR
    575577is set by the user,
    576 \fIshash\fB
     578\fIshash\fR
    577579is defaulted to the
    578 \fImin\fB
     580\fImin\fR
    579581value of the axis.
    580582.TP
     
    624626Draw the axis line at this point on the other axis.
    625627The default is usually the other axis's
    626 \fImin, \fB
     628\fImin\fR,
    627629however if
    628 \fIhash_scale \fB
     630\fIhash_scale \fR
    629631is positive (see
    630 \fIhash_scale \fB
     632\fIhash_scale \fR
    631633under ADVANCED AXIS EDITING), it will be
    632634the other axis's
    633 \fImax.\fB
     635\fImax\fR.
    634636.TP
    635637\fBnodraw\fR   
     
    637639is useful for plotting points with no axes, and for overlaying graphs
    638640on top of one another with no clashes.  This is equivalent to
    639 \fIno_draw_axis,\fB
    640 \fIno_draw_axis_label,\fB
    641 \fIno_draw_hash_marks,\fB
    642 and
    643 \fIno_draw_hash_labels.\fB
     641\fIno_draw_axis\fR,
     642\fIno_draw_axis_label\fR,
     643\fIno_draw_hash_marks\fR,
     644and
     645\fIno_draw_hash_labels\fR.
    644646.TP
    645647\fBdraw\fR   
    646648Cancels the effect of
    647 \fInodraw.  \fB
     649\fInodraw\fR.
    648650Default =
    649 \fIdraw.\fB
     651\fIdraw\fR
    650652This is
    651653equivalent to
    652 \fIdraw_axis,\fB
    653 \fIdraw_axis_label,\fB
    654 \fIdraw_hash_marks,\fB
     654\fIdraw_axis\fR,
     655\fIdraw_axis_label\fR,
     656\fIdraw_hash_marks\fR,
    655657and
    656 \fIdraw_hash_labels.\fB
     658\fIdraw_hash_labels\fR.
    657659.TP
    658660\fBgrid_lines\fR
     
    661663.TP
    662664\fBno_grid_lines\fR
    663 \fIGrid_lines\fB
     665\fIGrid_lines\fR
    664666specifies to plot a grid line at each major hash
    665667mark on this axis.  The default is
    666 \fIno_grid_lines.\fB
     668\fIno_grid_lines.\fR
    667669.TP
    668670\fBmgrid_lines\fR
     
    671673.TP
    672674\fBno_mgrid_lines\fR
    673 \fIMgrid_lines\fB
     675\fIMgrid_lines\fR
    674676specifies to plot a grid line at each minor hash
    675677mark on this axis.  The default is
    676 \fIno_mgrid_lines.\fB
     678\fIno_mgrid_lines\fR.
    677679.PD
    678680.RE
     
    682684These commands act on the current curve as
    683685chosen by
    684 \fInewcurve\fB
     686\fInewcurve\fR
    685687or
    686 \fIcurve\fB
     688\fIcurve\fR
    687689(see GRAPH EDITING COMMANDS).  Curve
    688690editing terminates when a graph or top-level command is given.
     
    692694This sets the points to plot in this
    693695curve.  The first
    694 \fIfloat\fB
     696\fIfloat\fR
    695697is the x value, and the second
    696 \fIfloat\fB
     698\fIfloat\fR
    697699is the y
    698700value of the point.  Points are plotted in the order specified.
     
    708710This allows the user to specify points and ``confidence values'' (otherwise
    709711known as ``error bars'').  The first two
    710 \fIfloats\fB
     712\fIfloats\fR
    711713specify the x and y values of
    712714the point, as above.  If
    713715\fBx_epts\fR
    714716is specified,  then the second two
    715 \fIfloats\fB
     717\fIfloats\fR
    716718specify range or confidence values
    717719for the x value of the point. 
     
    719721original point's y value)
    720722from the original point.  Similarly,
    721 \fIy_epts\fB
     723\fIy_epts\fR
    722724specifies range or confidence values for the y value of the point.
    723 \fIpts\fB
    724 \fIx_epts\fB
    725 and
    726 \fIy_epts\fB
     725\fIpts\fR
     726\fIx_epts\fR
     727and
     728\fIy_epts\fR
    727729can all be intermixed.
    728730.TP
     
    745747curve points (units are units of the x and y axes).
    746748Default label values are 0 for x and y, and center justification.
    747   \fIPostscript:\fR See the \fIpostscript\fB token below.
    748   \fIEps:\fR See the \fIeps\fB token below.
     749  \fIPostscript\fR: See the \fIpostscript\fR token below.
     750  \fIEps\fR: See the \fIeps\fR token below.
    749751  \fINone\fR means that no mark will be
    750752plotted (this is useful for drawing lines). 
    751753  There are four types of \fIgeneral\fR marks, which work using the
    752 \fIgmarks\fB command described below.  The four marktypes are
     754\fIgmarks\fR command described below.  The four marktypes are
    753755\fIgeneral\fR, \fIgeneral_nf\fR, \fIgeneral_bez\fR, and
    754756\fIgeneral_bez_nf\fR.
     
    782784\fIgray\fR
    783785should be from 0 (black) to 1 (white).  Values for
    784 \fIcolor\fR\fB
     786\fIcolor\fR
    785787should also be from 0 to 1.  They are RGB values, and thus define the
    786788amount of red, green and blue in the curve respectively.  Specifying
    787789color nullifies the gray value, and vice versa.  The default is
    788 \fIgray 0\fB
     790\fIgray 0\fR
    789791.TP
    790792\fBfill \|[\fIfloat\fB\|]\fR   
     
    795797This sets the filling of marks which define an area
    796798to fill (e.g.  \fIbox\fR, \fIcircle\fR, \fIxbar\fR). 
    797 \fIfill\fB
     799\fIfill\fR
    798800defines a gray value, and
    799 \fIcfill\fB
     801\fIcfill\fR
    800802defines a color value (see
    801 \fIgray\fB
    802 and
    803 \fIcolor\fB
     803\fIgray\fR
     804and
     805\fIcolor\fR
    804806above for a description of the units).
    805807The default is
    806 \fIfill 0\fB
     808\fIfill 0\fR
    807809(black).
    808810.TP
     
    838840.TP
    839841\fBppattern \fItoken\fB \|[\fIfloat\fB\|]\fR   
    840 \fIPoly\fB allows the user to make jgraph treat the curve as a
     842\fIPoly\fR allows the user to make jgraph treat the curve as a
    841843closed polygon (or in the case of a bezier, a closed bezier curve).
    842 \fIpfill\fB, \fIpcfill\fB and \fIppattern\fB  specify the
     844\fIpfill\fR, \fIpcfill\fR and \fIppattern\fR  specify the
    843845filling of the polygon,
    844 and work like \fIfill\fB, \fIcfill\fB and \fIpattern\fB above. 
    845 The default is \fInopoly\fB.
     846and work like \fIfill\fR, \fIcfill\fR and \fIpattern\fR above. 
     847The default is \fInopoly\fR.
    846848.TP
    847849\fBgmarks \|[\|{\fIfloat\fB\|} \|{\fIfloat\fB\|}\|]*\fR   
    848 \fIGmarks\fB
     850\fIGmarks\fR
    849851is a way for the user to define custom marks.  For each mark on
    850 \fI(x,y),\fB
     852\fI(x,y)\fR,
    851853Each pair of
    852854\fB\|{\fIfloat_x\fB\|}, \|{\fIfloat_y\fB\|}, \fR
     
    879881be set up so that when the string or file is put to the output, (0, 0) of
    880882the the axes is in the middle of the mark, it is rotated by
    881 \fImrotate\fB degrees, and scaled by
    882 (\fImarksize_x\fB / 2), \fImarksize_y\fB / 2).
     883\fImrotate\fR degrees, and scaled by
     884(\fImarksize_x\fR / 2), \fImarksize_y\fR / 2).
    883885Thus, the \fIbox\fR mark could be defined as:
    884886.PP
     
    888890.fi
    889891.PP
    890 If the \fImarksize_x\fB is defined to be (0, 0), then jgraph does no
     892If the \fImarksize_x\fR is defined to be (0, 0), then jgraph does no
    891893scaling.  This is useful when the postscript has strings, and the
    892894user does not want the strings to be scaled.
     
    895897This allows the user to include an encapsulated postscript file
    896898and treat it as a mark.  It automatically sets the marktype to
    897 \fIeps\fB.  The file will be scaled so that the bounding
     899\fIeps\fR.  The file will be scaled so that the bounding
    898900box is \fImarksize\fR units.  Among other things, this allows the
    899901user to include whole jgraph files as marks.  Please see ad.jgr,
     
    913915.TP
    914916\fBnorarrows\fR
    915 \fIRarrows\fB
     917\fIRarrows\fR
    916918specifies to draw an arrow at the end of every line
    917919segment in the curve. 
    918 \fILarrows\fB
     920\fILarrows\fR
    919921specifies to draw an arrow at the beginning of every line segment.
    920922The size of the arrows can be changed by using
    921 \fIasize.\fB
     923\fIasize.\fR
    922924The default is
    923 \fInolarrows\fB
    924 and
    925 \fInorarrows\fB.
     925\fInolarrows\fR
     926and
     927\fInorarrows\fR.
    926928  Arrows always go exactly to the point specified, with the exception
    927929of when the marktype is ``circle''.  In this case, the arrow goes to
     
    941943.TP
    942944\fBnorarrow\fR
    943 This is analgous to the above, except that with \fIlarrow\fB, the
     945This is analgous to the above, except that with \fIlarrow\fR, the
    944946only arrow drawn is to the beginning of the first segment in the
    945 curve, and with \fIrarrow\fB, the only arrow drawn is to the end
     947curve, and with \fIrarrow\fR, the only arrow drawn is to the end
    946948of the last segment.
    947949.TP
     
    965967\fBapattern \fItoken\fB \|[\fIfloat\fB\|]\fR   
    966968These control the grayness or color of arrowheads. 
    967 \fIAfill\fB,
    968 \fIacfill\fB
     969\fIAfill\fR,
     970\fIacfill\fR
    969971and
    970 \fIapattern\fB
     972\fIapattern\fR
    971973work in the same way as
    972 \fIfill\fB,
    973 \fIcfill\fB
    974 and
    975 \fIpattern\fB
     974\fIfill\fR,
     975\fIcfill\fR
     976and
     977\fIpattern\fR
    976978described above.  The default is
    977 \fIafill 0\fB
     979\fIafill 0\fR
    978980(black).
    979981.TP
     
    984986\fInone\fR.  The default is \fInone\fR.  \fIGeneral\fR lets the user define
    985987his own linetype using the
    986 \fIglines\fB
     988\fIglines\fR
    987989command described below.  Points are connected in the
    988990order in which they are inserted using the
    989 \fIpts\fB
     991\fIpts\fR
    990992command.
    991993.TP
     
    994996is as in postscript -- the first number is the length of the first
    995997dash, the second is the length of the space after the first dash,
    996 etc.  For example, \fIdotdash\fB could be defined as ``\fIglines\fB 5 3
     998etc.  For example, \fIdotdash\fR could be defined as ``\fIglines\fR 5 3
    9979991 3''. 
    9981000.TP
     
    10081010.br
    10091011.ns
    1010 \fIBezier\fB
     1012\fIBezier\fR
    10111013specifies to use the curve's points to define successive bezier curves.
    10121014The first point is the starting point.  The next two are control points
     
    10171019points, where n is at least 1.
    10181020  In bezier curves, marks and arrows only apply to every third point.
    1019 \fINobezier\fB is the default.
     1021\fINobezier\fR is the default.
    10201022
    10211023.TP
     
    10271029This turns off clipping.  If clipping was specified for the
    10281030entire graph, then
    1029 \fInoclip\fB
     1031\fInoclip\fR
    10301032has no effect.
    1031 \fINoclip\fB
     1033\fINoclip\fR
    10321034is the default.
    10331035.TP
     
    10361038drawing a legend.  (see LABEL EDITING COMMANDS and LEGEND EDITING
    10371039COMMANDS).  Unless the legend entry is
    1038 \fIcustom\fB,
     1040\fIcustom\fR,
    10391041setting any label attribute except for the text itself
    10401042will have no effect.
     
    10831085These set the horizontal justification to left,
    10841086center, and right, respectively.  Default =
    1085 \fIhjc.\fB
     1087\fIhjc.\fR
    10861088.TP
    10871089\fBvjt\fR
     
    10961098These set the vertical justification to top
    10971099center, and bottom, respectively.  Default =
    1098 \fIvjb.\fB
     1100\fIvjb.\fR
    10991101.TP
    11001102\fBrotate \|[\fIfloat\fB\|]\fR   
     
    11021104\fB\|[\fIfloat\fB\|] \fR
    11031105degrees.  The point of rotation is defined by the
    1104 \fIvj\fB
     1106\fIvj\fR
    11051107and
    1106 \fIhj\fB
     1108\fIhj\fR
    11071109commands.  For example, to rotate 90 degrees about the center of a string,
    11081110one would use
    1109 \fIvjc hjc rotate 90.\fB
     1111\fIvjc hjc rotate 90.\fR
    11101112.TP
    11111113\fBlgray \|[\fIfloat\fB\|]\fR
     
    11151117\fBlcolor \|[\fIfloat\fB \fIfloat\fB \fIfloat\fB\|]\fR
    11161118These control the color or the grayness of the label.  It works just as
    1117 \fIgray\fB
    1118 and
    1119 \fIcolor\fB
     1119\fIgray\fR
     1120and
     1121\fIcolor\fR
    11201122do for curves and axes.  The default depends on the context.  For example,
    11211123for strings and the title, the default is black.  For axis labels and hash
     
    11391141fontsize to be 18, you had to set it in each entry's curve.  Now,
    11401142default legend entry characteristics are set using the
    1141 \fIdefaults\fB
     1143\fIdefaults\fR
    11421144keyword.  Unless a
    1143 \fIcustom\fB
     1145\fIcustom\fR
    11441146legend is specified, these default values override any values set in
    11451147the entry's curve.  Thus, to get all entries to have a fontsize of
    1146114818, it must be set using
    1147 \fIdefaults fontsize 18.\fB
     1149\fIdefaults fontsize 18\fR.
    11481150
    11491151If legend editing seems cryptic, try the following example:
     
    11691171.ns
    11701172.TP
    1171 \fBoff\R
     1173\fBoff\fR
    11721174These turn printing of the legend on and off.  The default is on
    11731175(but, of course, if there are no curve labels defined, there will
     
    12241226.ns
    12251227.TP
    1226 \fIright\fB
     1228\fIright\fR
    12271229These will automatically produce a legend to the left or
    12281230the right of the graph. 
    1229 \fILeft\fB
     1231\fILeft\fR
    12301232is equivalent to
    1231 \fIdefaults hjr vjc\fB
    1232 and
    1233 \fIright\fB
     1233\fIdefaults hjr vjc\fR
     1234and
     1235\fIright\fR
    12341236is equivalent to
    1235 \fIdefaults hjl vjc.\fB
     1237\fIdefaults hjl vjc\fR.
    12361238.TP
    12371239\fBtop\fR   
     
    12421244These will automatically produce a legend on the top or
    12431245the bottom of the graph. 
    1244 \fITop\fB
     1246\fITop\fR
    12451247is equivalent to
    1246 \fIdefaults hjl vjb\fB
     1248\fIdefaults hjl vjb\fR
    12471249 and
    1248 \fIbottom\fB
     1250\fIbottom\fR
    12491251is equivalent to
    1250 \fIdefaults hjl vjt.\fB
     1252\fIdefaults hjl vjt\fR.
    12511253.TP
    12521254\fBx \|[\fIfloat\fB\|]\fR
     
    12571259These are included mainly for backward compatability to earlier
    12581260versions of jgraph.  Setting
    1259 \fIx\fB
     1261\fIx\fR
    12601262and
    1261 \fIy\fB
     1263\fIy\fR
    12621264is equivalent to ``defaults x
    1263 \fIfloat\fB
     1265\fIfloat\fR
    12641266y
    1265 \fIfloat\fB
     1267\fIfloat\fR
    12661268hjl vjt''
    12671269.TP
     
    12691271This lets the user control where each individual legend
    12701272entry goes.  The values of the
    1271 \fIdefaults\fB
     1273\fIdefaults\fR
    12721274fields are ignored, and instead, the values of the curve's
    12731275labels are used.  All justifications have defined results, except
    12741276for
    1275 \fIhjc\fB.
     1277\fIhjc\fR.
    12761278Similarly, rotation other than 0 is likely to produce bad effects.
    12771279.PD
     
    12931295These specify either the grayness of the axis or its color.  Values
    12941296for
    1295 \fIgray\fB
     1297\fIgray\fR
    12961298should be from 0 (black) to 1 (white).  Values for
    1297 \fIcolor\fB
     1299\fIcolor\fR
    12981300should also be from 0 to 1.  They are RGB values, and thus define the
    12991301amount of red, green and blue in the axis respectively.  Specifying
    13001302color nullifies the gray value, and vice versa.  The default is
    1301 \fIgray 0\fB.
     1303\fIgray 0\fR.
    13021304These values affect every part of the axis:  the label,
    13031305the hash marks and labels, the axis line and the grid lines.
     
    13201322axis lines.
    13211323The default
    1322 \fIgrid_gray\fB
    1323 and
    1324 \fIgrid_color\fB
     1324\fIgrid_gray\fR
     1325and
     1326\fIgrid_color\fR
    13251327is the same as the axis's
    1326 \fIgray\fB
    1327 and
    1328 \fIcolor\fB.
     1328\fIgray\fR
     1329and
     1330\fIcolor\fR.
    13291331The default
    1330 \fImgrid_gray\fB
    1331 and
    1332 \fImgrid_color\fB
     1332\fImgrid_gray\fR
     1333and
     1334\fImgrid_color\fR
    13331335is the same as
    1334 \fIgrid_gray\fB
    1335 and
    1336 \fIgrid_color\fB.
     1336\fIgrid_gray\fR
     1337and
     1338\fIgrid_color\fR.
    13371339.TP
    13381340\fBhash_at \|[\fIfloat\fB\|]\fR   
     
    13501352This is so that the user can change the fontsize, justification,
    13511353etc., of the hash labels.  Editing
    1352 \fIhash_labels \fB
     1354\fIhash_labels \fR
    13531355is just like editing
    13541356normal labels (see LABEL EDITING COMMANDS), except that the
    1355 \fI:,\fB
    1356 \fIx,\fB
    1357 and
    1358 \fIy\fB
     1357\fI:\fR,
     1358\fIx\fR,
     1359and
     1360\fIy\fR
    13591361values are all ignored. Defaults for hash labels are as
    13601362follows: Fontsize=9, Font=``Times-Roman'', Justification is dependent
    13611363on whether it is the x or y axis and whether
    1362 \fIhash_scale\fB
     1364\fIhash_scale\fR
    13631365is positive or negative.
    13641366.TP
     
    13731375either above or below the axis.  This command changes where they are
    13741376drawn. 
    1375 \fIHash_scale\fB
     1377\fIHash_scale\fR
    13761378still determines whether they are drawn above or
    13771379below this point, and their size.
     
    13811383drawn either above or below the hash marks (again, this is dependent
    13821384on
    1383 \fIhash_scale\fB).
     1385\fIhash_scale\fR).
    13841386This command changes where they are drawn.
    13851387Justification and fontsize, etc., can be changed with the
    1386 \fIhash_labels\fB
     1388\fIhash_labels\fR
    13871389command.
    13881390.TP
     
    13961398\fBjgraph \fR
    13971399will automatically create hash marks according to
    1398 \fIhash,\fB
    1399 \fImhash\fB
    1400 and
    1401 \fIshash\fB
     1400\fIhash\fR,
     1401\fImhash\fR
     1402and
     1403\fIshash\fR
    14021404(or
    1403 \fIlog_base\fB
    1404 and
    1405 \fImhash\fB
     1405\fIlog_base\fR
     1406and
     1407\fImhash\fR
    14061408for logarithmic axes).
    14071409The default is
    1408 \fIauto_hash_marks.\fB
     1410\fIauto_hash_marks\fR.
    14091411.TP
    14101412\fBauto_hash_labels\fR
     
    14171419\fBjgraph \fR
    14181420will automatically create hash labels for the
    1419 \fIauto_hash_marks\fB.
     1421\fIauto_hash_marks\fR.
    14201422Default =
    1421 \fIauto_hash_labels\fB.
     1423\fIauto_hash_labels\fR.
    14221424.TP
    14231425\fBdraw_axis\fR
     
    14281430This toggles whether or not the axis
    14291431line is drawn.  Default =
    1430 \fIdraw_axis.\fB
     1432\fIdraw_axis\fR.
    14311433.TP
    14321434\fBdraw_axis_label\fR
     
    14371439This toggles whether or
    14381440not the axis label (as editted by the
    1439 \fIlabel\fB
     1441\fIlabel\fR
    14401442command) is drawn.
    14411443Default =
    1442 \fIdraw_axis_label.\fB
     1444\fIdraw_axis_label\fR.
    14431445.TP
    14441446\fBdraw_hash_marks\fR
     
    14491451This toggles whether or
    14501452not the hash marks (both automatic and those created with
    1451 \fIhash_at\fB
     1453\fIhash_at\fR
    14521454and
    1453 \fImhash_at\fB)
     1455\fImhash_at\fR)
    14541456are drawn.  Default =
    1455 \fIdraw_hash_marks.\fB
     1457\fIdraw_hash_marks\fR.
    14561458.TP
    14571459\fBdraw_hash_labels\fR
     
    14621464This toggles whether or
    14631465not the hash labels are drawn.  Default =
    1464 \fIdraw_hash_labels.\fB
     1466\fIdraw_hash_labels\fR.
    14651467.PD
    14661468.RE
     
    14711473along the appropriate axis.  As a default, they are printed at the
    14721474place denoted by the most recent
    1473 \fIhash_at\fB
     1475\fIhash_at\fR
    14741476or
    1475 \fImhash_at\fB
     1477\fImhash_at\fR
    14761478for this
    14771479axis, but this can be changed by the
    1478 \fIat\fB
     1480\fIat\fR
    14791481command.  If there has been
    14801482no
    1481 \fIhash_at\fB
     1483\fIhash_at\fR
    14821484or
    1483 \fImhash_at,\fB
     1485\fImhash_at\fR,
    14841486then an
    1485 \fIat\fB
     1487\fIat\fR
    14861488command must be given, or
    14871489there will be an error.  Hash editing terminates when either one of
     
    15101512\fBFunction plotting\fR
    15111513With the
    1512 \fIinclude\fB
     1514\fIinclude\fR
    15131515and
    1514 \fIshell\fB
     1516\fIshell\fR
    15151517statement, it's easy to
    15161518create a file of points of a function with a c or awk program, and
     
    15301532a user desires.  To embellish the graph with extra text, axes, lines,
    15311533etc., it is helpful to use
    1532 \fIcopygraph.\fB
     1534\fIcopygraph.\fR
    15331535The following example graphs show a few examples of different features
    1534 of jgraph.  They should be in the directory JGRAPH_DIR.
     1536of jgraph.  They should be in the directory /usr/doc/examples/jgraph.
    15351537.sp
    15361538- acc.jgr is a simple bar graph.  Acc.tex is also included to show
     
    15451547- sin.jgr shows how a sin function can be plotted using a simple c
    15461548program to produce the sin wave.  Moreover, this file shows a use of
    1547 \fIcopygraph\fB
     1549\fIcopygraph\fR
    15481550to plot an extra x and y axis at the 0 point.
    15491551.sp
     
    15711573complicated output graph can be quite concisely and simply stated.
    15721574In this graph, the x axis is a time line.  It shows usage of the
    1573 \fIhash_label\fB
    1574 and
    1575 \fIhash_labels\fB
     1575\fIhash_label\fR
     1576and
     1577\fIhash_labels\fR
    15761578commands, as well as displaying how jgraph lets you extract data from
    15771579output files with awk.
     
    15981600To view these graphs, use jgraph -P, and view the resulting output
    15991601file with
    1600 \fIgs,\fB
     1602\fIgs\fR,
    16011603or a similar postscript viewer.
    16021604To make a hard copy of these graphs, pipe the output of jgraph
    16031605-P directly to
    1604 \fIlpr.\fB
     1606\fIlpr\fR.
    16051607
    16061608.SH USING JGRAPH TO DRAW PICTURES
     
    16081610preprocessor to make drawings.  There are two advantages
    16091611using jgraph to draw pictures instead of using standard drawing tools like
    1610 \fIxfig\fB,
    1611 \fIfigtool\fB,
     1612\fIxfig\fR,
     1613\fIfigtool\fR,
    16121614or
    1613 \fIidraw\fB.
     1615\fIidraw\fR.
    16141616The first is that with jgraph, you know exactly where strings, lines,
    16151617boxes, etc, will end up, because you plot them explicitly.  The second
     
    16251627If you'd like to see some more complex pictures drawn with jgraph, as
    16261628well as some hints to make picture-drawing easier, send me email
    1627 (jsp@princeton.edu).
    1628 
    1629 .SH EMBEDDING THE OUTPUT IN LATEX
    1630 I haven't read the manuals, but the way I've been loading these files
    1631 into LaTeX has been as follows:
    1632 .PP
     1629(plank@cs.utk.edu).
     1630
     1631.SH SUPPORT FOR OTHER FONT ENCODINGS
     1632If you want to use non-english characters to set labels or titles,
     1633set enviroment variable JGRAPH_ENCODING with the font encoding that
     1634you need. This value will be passed directly to the postscript.
     1635
     1636Ex. to use ISO-8859-1 characters, try:
    16331637.nf
    1634 1.  Toward the beginning of my LaTeX file, I've had ``\\input{psfig}''
    1635 2.  Where I've wanted my file, I've put:
    1636 
    1637     \\begin{figure}
    1638     \\centerline{\\psfig{figure=<path-name>/<filename-of-jgraph-output>}}
    1639     \\end{figure}
    1640 
    1641     Some versions of dvips or dvi2ps work without the path-name.  Others
    1642     require that the path-name be present.
    1643 
    1644 3.  After running latex on the file, do
    1645 
    1646     lpr -d file.dvi
    1647 
    1648 4.  If that doesn't work, try dvips-ing the file and printing the postscript.
     1638
     1639   export JGRAPH_ENCODING=ISOLatin1Encoding
    16491640
    16501641.fi
    1651 .PP
     1642Note: that only works with default fonts. if you use 'font' in stdin
     1643to specify another font, it won't work.
     1644
     1645You also have the possibility to expand the bounding box if jgraph
     1646cuts some acute, tilde or special chars near the border; try:
     1647.nf
     1648
     1649   export JGRAPH_BORDER=5
     1650
     1651.fi
     1652This support is currently 'testing' code. Send bugs about it
     1653to pzn@debian.org
     1654
     1655.SH INTEGRATION WITH LATEX
     1656.PP
     1657.nf
     16581. At the top, say
     1659   \\usepackage{graphics}
     1660
     16612. The floating object is done using:
     1662
     1663   \\begin{figure}
     1664   \\begin{center}
     1665   \\includegraphics{a.eps}
     1666   \\end{center}
     1667   \\end{figure}
     1668   
     16693. Now go through dvips as usual and the .ps file will work.
     1670.fi
     1671.PP
     1672.SH INTEGRATION WITH PDFLATEX
     1673
     1674If you are using pdflatex, it requires .pdf files and not .eps
     1675files. In that case, you have to run epstopdf on the .eps file to get
     1676a .pdf file. After that,
     1677.br
     1678   \\includegraphics{a.pdf}
     1679.br
     1680does the trick.
     1681.SH SCALING THE INCLUDED GRAPHICS OBJECT
     1682Sometimes you need to change the size of the included object at LaTeX
     1683time. In that case, you need
     1684.br
     1685   \\usepackage{graphicx}
     1686.br
     1687instead of graphics, and then say something like
     1688
     1689    \\includegraphics[width=7cm]{a.eps}
     1690 or
     1691    \\includegraphics[height=7cm]{a.eps}
     1692
     1693you can also omit the .eps/.pdf suffix:
     1694    \\includegraphics[height=7cm]{a}
     1695
     1696a.eps and a.pdf can both exist, and includegraphics will automatically
     1697choose the correct one for postscript or pdf output, depending if you
     1698are using latex of pdflatex.
     1699
     1700.SH AUTOMATION USING MAKE
     1701You can automate the mapping from .jgr -> .eps or .jgr -> .pdf
     1702in your Makefile using these rules:
     1703.nf
     1704
     1705--------- cut here ---------
     1706%.eps : %.jgr
     1707        jgraph $< > $@
     1708%.pdf : %.jgr
     1709        jgraph $< | epstopdf --filter > $@
     1710--------- cut here ---------
     1711.fi
     1712
     1713jgraph can also return the exit status correctly, so it is also a good
     1714idea to use it in your scripts to prevent bad .eps files if the .jgr
     1715source is bad. The following Makefile can handle its exit status.
     1716.nf
     1717
     1718--------- cut here ---------
     1719%.eps : %.jgr
     1720        jgraph $< > $@; \\
     1721        if [ "$$?" != "0" ]; then \\
     1722          rm -f $@; \\
     1723          exit 1; \\
     1724        fi
     1725%.pdf : %.jgr
     1726        TMP=`tempfile`; jgraph $< > $${TMP}; \\
     1727        if [ "$$?" == "0" ]; then \\
     1728          cat $${TMP} | epstopdf --filter > $@; \\
     1729          rm -f $${TMP}; \\
     1730        else \\
     1731          rm -f $${TMP} $@; \\
     1732          exit 1; \\
     1733        fi;
     1734--------- cut here ---------
     1735.fi
     1736
    16521737.SH BUGS
    16531738Logarithmic axes cannot contain points <= 0.  If I have
     
    16581743own hash labels. 
    16591744.sp
    1660 There may well be loads of other bugs.  Send to jsp@princeton.edu.
     1745There may well be loads of other bugs.  Send to plank@cs.utk.edu.
    16611746.sp
    16621747
  • trunk/Jgraph/makefile

    r418 r419  
    77# jgraph.1 to be the directory containing the example jgraphs.
    88
    9 CC = gcc -LCC
     9CC = cc
    1010
    1111OBJS = draw.o \
    1212                edit.o \
    13                 jgraph.o \
    1413                list.o \
    1514                printline.o \
     
    4342        wortman.jps
    4443
     44LOADLIBES = -lm
    4545
    4646all: jgraph
     
    5858.tex.dvi:
    5959        latex $*.tex
    60 .c.o:
    61         $(CC)  -c -g $*.c
     60#.c.o:
     61#       $(CC)  -c -g $*.c
    6262
    6363
    6464jgraph: $(OBJS)
    65         $(CC) -g $(OBJS) -lm -o jgraph
     65#       $(CC) -g $(OBJS) -lm -o jgraph
    6666
    6767sin:    sin.o
     
    7676sin3.jps: sin3.pts
    7777tree1.jps: tree.awk
    78         ( echo "4 3" | nawk -f tree.awk ; echo "xaxis size 5.4" ) | \
     78        ( echo "4 3" | awk -f tree.awk ; echo "xaxis size 5.4" ) | \
    7979           jgraph -P > tree1.jps
    8080tree2.jps: tree.awk
    81         ( echo "5 2" | nawk -f tree.awk ; echo "xaxis size 5.4" ) | \
     81        ( echo "5 2" | awk -f tree.awk ; echo "xaxis size 5.4" ) | \
    8282           jgraph -P > tree2.jps
    8383
     
    9494token.o: token.c list.h
    9595clean:
    96         rm -f *.o a.out *.jps
     96        rm -f *.o a.out *.jps jgraph
  • trunk/Jgraph/printline.c

    r418 r419  
    88#include "jgraph.h"
    99#include <stdio.h>
     10#include <assert.h> //by pzn@debian.org
    1011
    1112#define LINEWIDTHFACTOR 0.700
     
    229230  float fnl;
    230231  char *s;
     232  unsigned char *s_7bit; // added by pzn@debian.org
    231233
    232234  if (l->label == CNULL) return;
     
    267269
    268270  s = l->label;
     271 
    269272  for (i = 0; i <= nlines; i++) {
    270     printf("(%s) dup stringwidth pop ", s);
     273    // BEGIN added by pzn@debian.org
     274    // converts 8bit ascii chars to octal value;
     275    // 7bit are not converted
     276    {
     277       int i, j=0, len;
     278       len=strlen(s);
     279       s_7bit=malloc(len*4+1);
     280       assert(s_7bit!=NULL);
     281       for (i=0; i<=len; i++) {
     282         if((unsigned char)s[i]<128) {
     283           //char is ascii 7bit
     284           s_7bit[j]=s[i];
     285           j++;
     286         } else {
     287           //char must be converted to octal
     288           sprintf(s_7bit+j,"\\%03o",(unsigned char)s[i]);
     289           j+=4;
     290         }
     291       }
     292       s_7bit[j-1]=0;
     293    }
     294    //printf("(%s) dup stringwidth pop ", s); //disabled by pzn
     295    printf("(%s) dup stringwidth pop ", s_7bit); free(s_7bit);
     296    // END added by pzn
    271297    if (l->hj == 'c') {
    272298      printf("2 div neg 0 moveto\n");
Note: See TracChangeset for help on using the changeset viewer.