| 1 |
lars |
1 |
--TEST--
|
|
|
2 |
Unit test for HTML-like labels
|
|
|
3 |
--FILE--
|
|
|
4 |
<?php
|
|
|
5 |
|
|
|
6 |
/**
|
|
|
7 |
* Test 4: "HTML-like labels"
|
|
|
8 |
*
|
|
|
9 |
* Graph definition taken from GraphViz documentation
|
|
|
10 |
*
|
|
|
11 |
* @category Image
|
|
|
12 |
* @package Image_GraphViz
|
|
|
13 |
* @author Philippe Jausions <jausions@php.net>
|
|
|
14 |
*/
|
|
|
15 |
require_once 'Image/GraphViz.php';
|
|
|
16 |
|
|
|
17 |
$graph = new Image_GraphViz(true, array('rankdir' => 'LR'), 'G', false);
|
|
|
18 |
|
|
|
19 |
$graph->addNode('a', array('shape' => 'plaintext',
|
|
|
20 |
'label' => '<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
|
|
|
21 |
<TR><TD ROWSPAN="3" BGCOLOR="yellow">class</TD></TR>
|
|
|
22 |
<TR><TD PORT="here" BGCOLOR="lightblue">qualifier</TD></TR>
|
|
|
23 |
</TABLE>'));
|
|
|
24 |
|
|
|
25 |
$graph->addNode('b', array('shape' => 'ellipse',
|
|
|
26 |
'style' => 'filled',
|
|
|
27 |
'label' => '<TABLE BGCOLOR="bisque">
|
|
|
28 |
<TR><TD COLSPAN="3">elephant</TD>
|
|
|
29 |
<TD ROWSPAN="2" BGCOLOR="chartreuse"
|
|
|
30 |
VALIGN="bottom" ALIGN="right">two</TD> </TR>
|
|
|
31 |
<TR><TD COLSPAN="2" ROWSPAN="2">
|
|
|
32 |
<TABLE BGCOLOR="grey">
|
|
|
33 |
<TR> <TD>corn</TD> </TR>
|
|
|
34 |
<TR> <TD BGCOLOR="yellow">c</TD> </TR>
|
|
|
35 |
<TR> <TD>f</TD> </TR>
|
|
|
36 |
</TABLE> </TD>
|
|
|
37 |
<TD BGCOLOR="white">penguin</TD>
|
|
|
38 |
</TR>
|
|
|
39 |
<TR> <TD COLSPAN="2" BORDER="4" ALIGN="right" PORT="there">4</TD> </TR>
|
|
|
40 |
</TABLE>
|
|
|
41 |
'), 'subgraph');
|
|
|
42 |
|
|
|
43 |
$graph->addNode('c', array('shape' => 'plaintext',
|
|
|
44 |
'label' => 'long line 1<BR/>line 2<BR ALIGN="LEFT"/>line 3<BR ALIGN="RIGHT"/>'), 'subgraph');
|
|
|
45 |
|
|
|
46 |
$graph->addSubgraph('subgraph', '', array('rank' => 'same'));
|
|
|
47 |
|
|
|
48 |
$graph->addEdge(array('c' => 'b'));
|
|
|
49 |
|
|
|
50 |
$graph->addNode('d', array('shape' => 'triangle'));
|
|
|
51 |
|
|
|
52 |
$graph->addEdge(array('d' => 'c'), array('label' => '<TABLE>
|
|
|
53 |
<TR><TD BGCOLOR="red" WIDTH="10"> </TD>
|
|
|
54 |
<TD>Edge labels<BR/>also</TD>
|
|
|
55 |
<TD BGCOLOR="blue" WIDTH="10"> </TD>
|
|
|
56 |
</TR>
|
|
|
57 |
</TABLE>'));
|
|
|
58 |
|
|
|
59 |
$graph->addEdge(array('a' => 'b'), array('arrowtail' => 'diamond'),
|
|
|
60 |
array('a' => 'here', 'b' => 'there'));
|
|
|
61 |
|
|
|
62 |
echo $graph->parse();
|
|
|
63 |
|
|
|
64 |
?>
|
|
|
65 |
--EXPECT--
|
|
|
66 |
digraph G {
|
|
|
67 |
rankdir=LR;
|
|
|
68 |
a [ shape=plaintext,label=<<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
|
|
|
69 |
<TR><TD ROWSPAN="3" BGCOLOR="yellow">class</TD></TR>
|
|
|
70 |
<TR><TD PORT="here" BGCOLOR="lightblue">qualifier</TD></TR>
|
|
|
71 |
</TABLE>> ];
|
|
|
72 |
d [ shape=triangle ];
|
|
|
73 |
subgraph "subgraph" {
|
|
|
74 |
graph [ rank=same ];
|
|
|
75 |
b [ shape=ellipse,style=filled,label=<<TABLE BGCOLOR="bisque">
|
|
|
76 |
<TR><TD COLSPAN="3">elephant</TD>
|
|
|
77 |
<TD ROWSPAN="2" BGCOLOR="chartreuse"
|
|
|
78 |
VALIGN="bottom" ALIGN="right">two</TD> </TR>
|
|
|
79 |
<TR><TD COLSPAN="2" ROWSPAN="2">
|
|
|
80 |
<TABLE BGCOLOR="grey">
|
|
|
81 |
<TR> <TD>corn</TD> </TR>
|
|
|
82 |
<TR> <TD BGCOLOR="yellow">c</TD> </TR>
|
|
|
83 |
<TR> <TD>f</TD> </TR>
|
|
|
84 |
</TABLE> </TD>
|
|
|
85 |
<TD BGCOLOR="white">penguin</TD>
|
|
|
86 |
</TR>
|
|
|
87 |
<TR> <TD COLSPAN="2" BORDER="4" ALIGN="right" PORT="there">4</TD> </TR>
|
|
|
88 |
</TABLE>
|
|
|
89 |
> ];
|
|
|
90 |
c [ shape=plaintext,label=<long line 1<BR/>line 2<BR ALIGN="LEFT"/>line 3<BR ALIGN="RIGHT"/>> ];
|
|
|
91 |
}
|
|
|
92 |
c -> b;
|
|
|
93 |
d -> c [ label=<<TABLE>
|
|
|
94 |
<TR><TD BGCOLOR="red" WIDTH="10"> </TD>
|
|
|
95 |
<TD>Edge labels<BR/>also</TD>
|
|
|
96 |
<TD BGCOLOR="blue" WIDTH="10"> </TD>
|
|
|
97 |
</TR>
|
|
|
98 |
</TABLE>> ];
|
|
|
99 |
a:here -> b:there [ arrowtail=diamond ];
|
|
|
100 |
}
|