]> granicus.if.org Git - graphviz/commitdiff
Add new shape=plain as shorthand for shape=none width=height=margin=0.
authorEmden R. Gansner <erg@alum.mit.edu>
Tue, 9 Sep 2014 21:27:07 +0000 (17:27 -0400)
committerEmden R. Gansner <erg@alum.mit.edu>
Tue, 9 Sep 2014 21:27:07 +0000 (17:27 -0400)
This is useful for HTML-like labels.

doc/info/shapes.html
doc/infosrc/mkshapes.sh
doc/infosrc/shapelist
doc/infosrc/shapes.2
lib/common/shapes.c

index 2906a526cb3aee82535274b543ff4416711a8a13..a1725077a6d8aabc6a7e29dc2c1c1fb44d432f70 100644 (file)
@@ -58,157 +58,162 @@ The possible polygon-based shapes are displayed below.
   </TR>
   <TR ALIGN=CENTER>
     <TD><IMG SRC=plaintext.gif>
+    <TD><IMG SRC=plain.gif>
     <TD><IMG SRC=diamond.gif>
     <TD><IMG SRC=trapezium.gif>
-    <TD><IMG SRC=parallelogram.gif>
   </TR>
   <TR ALIGN=CENTER>
     <TD><A NAME=d:plaintext>plaintext</A>
+    <TD><A NAME=d:plain>plain</A>
     <TD><A NAME=d:diamond>diamond</A>
     <TD><A NAME=d:trapezium>trapezium</A>
-    <TD><A NAME=d:parallelogram>parallelogram</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=parallelogram.gif>
     <TD><IMG SRC=house.gif>
     <TD><IMG SRC=pentagon.gif>
     <TD><IMG SRC=hexagon.gif>
-    <TD><IMG SRC=septagon.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:parallelogram>parallelogram</A>
     <TD><A NAME=d:house>house</A>
     <TD><A NAME=d:pentagon>pentagon</A>
     <TD><A NAME=d:hexagon>hexagon</A>
-    <TD><A NAME=d:septagon>septagon</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=septagon.gif>
     <TD><IMG SRC=octagon.gif>
     <TD><IMG SRC=doublecircle.gif>
     <TD><IMG SRC=doubleoctagon.gif>
-    <TD><IMG SRC=tripleoctagon.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:septagon>septagon</A>
     <TD><A NAME=d:octagon>octagon</A>
     <TD><A NAME=d:doublecircle>doublecircle</A>
     <TD><A NAME=d:doubleoctagon>doubleoctagon</A>
-    <TD><A NAME=d:tripleoctagon>tripleoctagon</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=tripleoctagon.gif>
     <TD><IMG SRC=invtriangle.gif>
     <TD><IMG SRC=invtrapezium.gif>
     <TD><IMG SRC=invhouse.gif>
-    <TD><IMG SRC=Mdiamond.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:tripleoctagon>tripleoctagon</A>
     <TD><A NAME=d:invtriangle>invtriangle</A>
     <TD><A NAME=d:invtrapezium>invtrapezium</A>
     <TD><A NAME=d:invhouse>invhouse</A>
-    <TD><A NAME=d:Mdiamond>Mdiamond</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=Mdiamond.gif>
     <TD><IMG SRC=Msquare.gif>
     <TD><IMG SRC=Mcircle.gif>
     <TD><IMG SRC=rect.gif>
-    <TD><IMG SRC=rectangle.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:Mdiamond>Mdiamond</A>
     <TD><A NAME=d:Msquare>Msquare</A>
     <TD><A NAME=d:Mcircle>Mcircle</A>
     <TD><A NAME=d:rect>rect</A>
-    <TD><A NAME=d:rectangle>rectangle</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=rectangle.gif>
     <TD><IMG SRC=square.gif>
     <TD><IMG SRC=star.gif>
     <TD><IMG SRC=none.gif>
-    <TD><IMG SRC=underline.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:rectangle>rectangle</A>
     <TD><A NAME=d:square>square</A>
     <TD><A NAME=d:star>star</A>
     <TD><A NAME=d:none>none</A>
-    <TD><A NAME=d:underline>underline</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=underline.gif>
     <TD><IMG SRC=note.gif>
     <TD><IMG SRC=tab.gif>
     <TD><IMG SRC=folder.gif>
-    <TD><IMG SRC=box3d.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:underline>underline</A>
     <TD><A NAME=d:note>note</A>
     <TD><A NAME=d:tab>tab</A>
     <TD><A NAME=d:folder>folder</A>
-    <TD><A NAME=d:box3d>box3d</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=box3d.gif>
     <TD><IMG SRC=component.gif>
     <TD><IMG SRC=promoter.gif>
     <TD><IMG SRC=cds.gif>
-    <TD><IMG SRC=terminator.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:box3d>box3d</A>
     <TD><A NAME=d:component>component</A>
     <TD><A NAME=d:promoter>promoter</A>
     <TD><A NAME=d:cds>cds</A>
-    <TD><A NAME=d:terminator>terminator</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=terminator.gif>
     <TD><IMG SRC=utr.gif>
     <TD><IMG SRC=primersite.gif>
     <TD><IMG SRC=restrictionsite.gif>
-    <TD><IMG SRC=fivepoverhang.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:terminator>terminator</A>
     <TD><A NAME=d:utr>utr</A>
     <TD><A NAME=d:primersite>primersite</A>
     <TD><A NAME=d:restrictionsite>restrictionsite</A>
-    <TD><A NAME=d:fivepoverhang>fivepoverhang</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=fivepoverhang.gif>
     <TD><IMG SRC=threepoverhang.gif>
     <TD><IMG SRC=noverhang.gif>
     <TD><IMG SRC=assembly.gif>
-    <TD><IMG SRC=signature.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:fivepoverhang>fivepoverhang</A>
     <TD><A NAME=d:threepoverhang>threepoverhang</A>
     <TD><A NAME=d:noverhang>noverhang</A>
     <TD><A NAME=d:assembly>assembly</A>
-    <TD><A NAME=d:signature>signature</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=signature.gif>
     <TD><IMG SRC=insulator.gif>
     <TD><IMG SRC=ribosite.gif>
     <TD><IMG SRC=rnastab.gif>
-    <TD><IMG SRC=proteasesite.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:signature>signature</A>
     <TD><A NAME=d:insulator>insulator</A>
     <TD><A NAME=d:ribosite>ribosite</A>
     <TD><A NAME=d:rnastab>rnastab</A>
-    <TD><A NAME=d:proteasesite>proteasesite</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=proteasesite.gif>
     <TD><IMG SRC=proteinstab.gif>
     <TD><IMG SRC=rpromoter.gif>
     <TD><IMG SRC=rarrow.gif>
-    <TD><IMG SRC=larrow.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:proteasesite>proteasesite</A>
     <TD><A NAME=d:proteinstab>proteinstab</A>
     <TD><A NAME=d:rpromoter>rpromoter</A>
     <TD><A NAME=d:rarrow>rarrow</A>
-    <TD><A NAME=d:larrow>larrow</A>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><IMG SRC=larrow.gif>
     <TD><IMG SRC=lpromoter.gif>
   </TR>
   <TR ALIGN=CENTER>
+    <TD><A NAME=d:larrow>larrow</A>
     <TD><A NAME=d:lpromoter>lpromoter</A>
   </TR>
 </TABLE>
 As the figures suggest, the shapes <TT>rect</TT> and <TT>rectangle</TT> are synonyms for <TT>box</TT>, and <TT>none</TT> is a synonym for <TT>plaintext</TT>.
-Also, unlike the rest, we have shown these last two 
+The shape <TT>plain</TT> is similar to these two, except that it also enforces 
+<TT>width=0 height=0 margin=0</TT>, which guarantees that the actual size of the node is entirely determined by the label.
+This is useful, for example, when using <A HREF=shapes.html#html>HTML-like labels</A>.
+Also, unlike the rest, we have shown these three, as well as <TT>underline</TT>,
 without <TT>style=filled</TT>
 to indicate the normal use. If fill were turned on, the label text would
 appear in a filled rectangle.
@@ -453,6 +458,11 @@ The horizontal and vertical rules </EM>(<TT>&lt;HR&gt;</TT> and <TT>&lt;VR&gt;</
 later than 8 July 2011.
 </EM>
 <P>
+<B>NOTE:</B><EM>For releases later than 9 September 2014, one can use <TT>shape=plain</TT> so that the size
+of the node is totally determined by the label. Otherwise, the node's margin, width and height values may cause the
+node to be larger, so that edges are clipped away from the label. In effect, <TT>shape=plain</TT> is shorthand
+for <TT>shape=none width=0 height=0 margin=0</TT>.
+<P>
 If the value of a label attribute
 (<A HREF=attrs.html#d:label><TT>label</TT></A> for nodes, edges, clusters, and
 graphs, and the
@@ -550,11 +560,6 @@ Note that, as in HTML, element and attribute names are case-insensitive.
   <TD ALIGN=LEFT>|</TD>
   <TD ALIGN=LEFT><B>&lt;U&gt;</B> <I>text</I> <B>&lt;/U&gt</B></TD>
 </TR>
-<TR>
-  <TD ALIGN=RIGHT></TD>
-  <TD ALIGN=LEFT>|</TD>
-  <TD ALIGN=LEFT><B>&lt;O&gt;</B> <I>text</I> <B>&lt;/O&gt</B></TD>
-</TR>
 <TR>
   <TD ALIGN=RIGHT></TD>
   <TD ALIGN=LEFT>|</TD>
@@ -741,17 +746,11 @@ Attribute values must appear in double quotes.
 &gt;
 </PRE>
 <P>
-  &lt;!-- Underline text --&gt;
+  &lt;!-- Underlined text --&gt;
 <PRE>&lt;U
   &lt;!-- No attributes --&gt;
 &gt;
 </PRE>
-<P>
-  &lt;!-- Overline text --&gt;
-<PRE>&lt;O
-  &lt;!-- No attributes --&gt;
-&gt;
-</PRE>
 <P>
   &lt;!-- Subscript text --&gt;
 <PRE>&lt;SUB
index 69bbd59846d2ff9e955455e8e6380ba4dcdd2421..be0c5ed10212ce305338e946d04f913e89e1846c 100755 (executable)
@@ -7,7 +7,7 @@ do
   F=$s.dot
   exec 3> $F
   echo "digraph G {" >&3
-  if [[ $s == "plaintext" || $s == "none" || $s == "underline" ]]
+  if [[ $s == "plaintext" || $s == "none" || $s == "underline" || $s == "plain" ]]
   then
     echo " node [shape=$s];" >&3
   else
index 54a62f43389960df1a0deff4becb4db0fe14e446..26294c242a8011ce8c3edf509eb6ffb8769326e3 100644 (file)
@@ -7,6 +7,7 @@ point
 egg
 triangle
 plaintext
+plain
 diamond
 trapezium
 parallelogram
index 7ec4318778e3ff4c90fda164b1840731d4a2d0f0..aa46f8a63e252e73fba5601856328419ad44cd0a 100644 (file)
@@ -1,6 +1,9 @@
 </TABLE>
 As the figures suggest, the shapes <TT>rect</TT> and <TT>rectangle</TT> are synonyms for <TT>box</TT>, and <TT>none</TT> is a synonym for <TT>plaintext</TT>.
-Also, unlike the rest, we have shown these last two 
+The shape <TT>plain</TT> is similar to these two, except that it also enforces 
+<TT>width=0 height=0 margin=0</TT>, which guarantees that the actual size of the node is entirely determined by the label.
+This is useful, for example, when using <A HREF=shapes.html#html>HTML-like labels</A>.
+Also, unlike the rest, we have shown these three, as well as <TT>underline</TT>,
 without <TT>style=filled</TT>
 to indicate the normal use. If fill were turned on, the label text would
 appear in a filled rectangle.
index 000734f29511296fe3acad2dd0e3e6f7730374cc..e0c484f532165ee1460e0af51171048a87de91e7 100644 (file)
@@ -83,6 +83,7 @@ static polygon_t p_triangle = { FALSE, 1, 3, 0., 0., 0. };
 static polygon_t p_box = { FALSE, 1, 4, 0., 0., 0. };
 static polygon_t p_square = { TRUE, 1, 4, 0., 0., 0. };
 static polygon_t p_plaintext = { FALSE, 0, 4, 0., 0., 0. };
+static polygon_t p_plain = { FALSE, 0, 4, 0., 0., 0. };
 static polygon_t p_diamond = { FALSE, 1, 4, 45., 0., 0. };
 static polygon_t p_trapezium = { FALSE, 1, 4, 0., -.4, 0. };
 static polygon_t p_parallelogram = { FALSE, 1, 4, 0., 0., .6 };
@@ -139,6 +140,7 @@ static polygon_t p_larrow = { FALSE, 1, 4, 0., 0., 0., LARROW};
 static polygon_t p_lpromoter = { FALSE, 1, 4, 0., 0., 0., LPROMOTER};
 
 #define IS_BOX(n) (ND_shape(n)->polygon == &p_box)
+#define IS_PLAIN(n) (ND_shape(n)->polygon == &p_plain)
 
 /* True if style requires processing through round_corners. */
 #define SPECIAL_CORNERS(style) ((style) & (ROUNDED | DIAGONALS | SHAPE_MASK))
@@ -221,6 +223,7 @@ static shape_desc Shapes[] = {      /* first entry is default for no such shape */
     {"triangle", &poly_fns, &p_triangle},
     {"none", &poly_fns, &p_plaintext},
     {"plaintext", &poly_fns, &p_plaintext},
+    {"plain", &poly_fns, &p_plain},
     {"diamond", &poly_fns, &p_diamond},
     {"trapezium", &poly_fns, &p_trapezium},
     {"parallelogram", &poly_fns, &p_parallelogram},
@@ -1831,6 +1834,7 @@ static void poly_init(node_t * n)
     int regular, peripheries, sides;
     int i, j, isBox, outp;
     polygon_t *poly = NEW(polygon_t);
+    boolean isPlain = IS_PLAIN(n);
 
     regular = ND_shape(n)->polygon->regular;
     peripheries = ND_shape(n)->polygon->peripheries;
@@ -1847,7 +1851,10 @@ static void poly_init(node_t * n)
      *   Else use minimum default value.
      * If node is not regular, use the current width and height.
      */
-    if (regular) {
+    if (isPlain) {
+       width = height = 0;
+    }
+    else if (regular) {
        double sz = userSize(n);
        if (sz > 0.0)
            width = height = sz;
@@ -1875,23 +1882,25 @@ static void poly_init(node_t * n)
     /* minimal whitespace around label */
     if ((dimen.x > 0) || (dimen.y > 0)) {
        /* padding */
-       if ((p = agget(n, "margin"))) {
-           marginx = marginy = 0;
-           i = sscanf(p, "%lf,%lf", &marginx, &marginy);
-           if (marginx < 0)
-               marginx = 0;
-           if (marginy < 0)
-               marginy = 0;
-           if (i > 0) {
-               dimen.x += 2 * POINTS(marginx);
-               if (i > 1)
-                   dimen.y += 2 * POINTS(marginy);
-               else
-                   dimen.y += 2 * POINTS(marginx);
+       if (!isPlain) {
+           if ((p = agget(n, "margin"))) {
+               marginx = marginy = 0;
+               i = sscanf(p, "%lf,%lf", &marginx, &marginy);
+               if (marginx < 0)
+                   marginx = 0;
+               if (marginy < 0)
+                   marginy = 0;
+               if (i > 0) {
+                   dimen.x += 2 * POINTS(marginx);
+                   if (i > 1)
+                       dimen.y += 2 * POINTS(marginy);
+                   else
+                       dimen.y += 2 * POINTS(marginx);
+               } else
+                   PAD(dimen);
            } else
                PAD(dimen);
-       } else
-           PAD(dimen);
+       }
     }
     spacex = dimen.x - ND_label(n)->dimen.x;