Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2
<HTML>
3
<HEAD>
4
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=iso-iso-8859-1">
5
<LINK REL="Start" HREF="index.html">
6
<LINK REL="Contents" HREF="toc.html">
7
<LINK REL="Prev" HREF="114Usingacanvasscale.html">
8
<LINK REL="Next" HREF="12AntiSpamChallenges.html">
9
<STYLE TYPE="text/css"><!--
10
BODY { font-family: serif }
11
H1 { font-family: sans-serif }
12
H2 { font-family: sans-serif }
13
H3 { font-family: sans-serif }
14
H4 { font-family: sans-serif }
15
H5 { font-family: sans-serif }
16
H6 { font-family: sans-serif }
17
SUB { font-size: smaller }
18
SUP { font-size: smaller }
19
PRE { font-family: monospace }
20
A { text-decoration: none }
21
--></STYLE>
22
</HEAD>
23
<BODY>
24
<A HREF="toc.html">Contents</A>
25
<A HREF="114Usingacanvasscale.html">Previous</A>
26
<A HREF="12AntiSpamChallenges.html">Next</A>
27
<HR NOSHADE>
28
<H2><A NAME="11_5">11.5 Sample application: Drawing DB schema</A></H2>
29
<P> As a final example we shortly discuss how the canvas type of graph
30
 was used to generate the DB schema for the DDDA architecture.</P>
31
<P> The library php file &quot;utils/misc/imgdbschema.php&quot; included in the
32
 distribution contains some utility classes to make the drawing of table
33
 schemes easier. It contains two basic classes, Class ImgDBTable and
34
 Class ImgDBSchema. The first class understand how to draw an image
35
 illustrating a single table. The second class is responsible for
36
 automatically extract all the relevant information from a DB to draw a
37
 complete DB Schema.</P>
38
<P> Before going into this a little bit more we show what an example of
39
 this might look like.<DIV class="example">
40
<BR> <A href="exframes/frame_dbschemaex1.html" target="blank"><IMG border="0"
41
HEIGHT="750"  src="img/dbschemaex1.png" WIDTH="600"></A>
42
<BR><B>Figure 190:</B> Example of using the canvas graph style together
43
 with the imgdbschema.php library to semi-automatically generate a DB
44
 schema <A href="exframes/frame_dbschemaex1.html" target="blank">[src]</A>
45
&nbsp;
46
<P></P>
47
</DIV></P>
48
<P></P>
49
<P> Before going on it should be noted that the ImgDBSchema assumes that
50
 the DB can be accessed through a DB abstraction layer modeled after the
51
 abstraction layer available in the 'jpdb.php' file in the DDDA
52
 architecture. This abstraction layer assumes a MySQL database in the
53
 bottom. This specific dependency of this particular abstraction layer
54
 is the reason why these classes is not included in the generic canvas
55
 tools file.</P>
56
<P> The second thing to note is that this library does not contain a
57
 complete automatic-layout engine but rather a very simple automatic
58
 system which, if nothing else is specified, just puts the table in a
59
 rectangular grid. A complete graph layout engine would simple be to
60
 much to write in this context. This is also a very difficult
61
 optimization problem and sofar not even any of the available research
62
 programs that tries this can achieve a satisfactory layout without
63
 manual intervention.</P>
64
<P> The critical lines in the code to generate the above graph is<DIV class="phpscript">
65
<CODE><FONT color="#000000"> <FONT color="#0000BB">&nbsp;$tblposadj</FONT><FONT
66
color="#007700">=array(</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">
67
,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
68
color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
69
$tlo</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">2</FONT><FONT
70
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
71
,</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">*</FONT><FONT
72
color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
73
$tlo</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">4</FONT><FONT
74
color="#007700">,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
75
,-</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONT
76
color="#0000BB">16</FONT><FONT color="#007700">,-</FONT><FONT color="#0000BB">
77
1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">16</FONT><FONT
78
color="#007700">);
79
<BR></FONT><FONT color="#0000BB">$dbschema&nbsp;</FONT><FONT color="#007700">
80
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">ImgDBSchema</FONT><FONT color="#007700">
81
(</FONT><FONT color="#DD0000">&quot;jpgraph_doc&quot;</FONT><FONT color="#007700">
82
,</FONT><FONT color="#DD0000">&quot;FormatTblName&quot;</FONT><FONT color="#007700">
83
,</FONT><FONT color="#DD0000">&quot;FormatFldName&quot;</FONT><FONT color="#007700">
84
);
85
<BR></FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
86
-&gt;</FONT><FONT color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT
87
color="#0000BB">$leftm</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
88
$topm</FONT><FONT color="#007700">);
89
<BR></FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
90
-&gt;</FONT><FONT color="#0000BB">SetTableWidth</FONT><FONT color="#007700">
91
(</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">);
92
<BR></FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
93
-&gt;</FONT><FONT color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT
94
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
95
img</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
96
color="#007700">-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">
97
,</FONT><FONT color="#0000BB">$tblposadj</FONT><FONT color="#007700">);</FONT><FONT
98
color="#0000BB"></FONT></FONT></CODE></DIV></P>
99
<P></P>
100
<P> The rest of the code in the file is just to setup the canvas, add an
101
 indented rectangle to group some tables and generate a footer with the
102
 date and time this image was generated.</P>
103
<P> The first line instantiates a new ImgDBSCheme layout engine asking
104
 it to draw an image for the database 'jpgraph_doc'. The following two
105
 arguments specify two callback functions for formatting the text for
106
 header and each field in a table.</P>
107
<P> The next line specify the top left margin where the drawing of the
108
 tables should be started.</P>
109
<P> The third line specify the width of a single table. The final lines
110
 starts the engine and draws all tables in the database to the canvas.
111
 The final argument requires some further explanation. This is an offset
112
 (x,y) from the top left corner how each individual table should be
113
 positioned. If the value is -1 indicates that the default value should
114
 be used. If this array is not specified then the tables will simple
115
 arranged line by line.</P>
116
<P> The full source code for drawing this DB schema example is shown
117
 below.</P>
118
<P><DIV class="phpscript">(File: dbschemaex1.php)
119
<BR><CODE><FONT color="#000000"> <FONT color="#0000BB">&lt;?php
120
<BR></FONT><FONT color="#FF8000">
121
/*=======================================================================
122
<BR>//&nbsp;File:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DBSCHEMAEX1.PHP
123
<BR>//&nbsp;Description:&nbsp;&nbsp;&nbsp;&nbsp;Draw&nbsp;a&nbsp;DB&nbsp;schema&nbsp;of&nbsp;the&nbsp;DDDA&nbsp;architecture
124
<BR>//&nbsp;Created:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2002-08-25
125
<BR>
126
//&nbsp;Ver:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$Id:&nbsp;dbschemaex1.php,v&nbsp;1.1&nbsp;2002/08/27&nbsp;20:08:57&nbsp;aditus&nbsp;Exp&nbsp;$
127
<BR>//
128
<BR>//&nbsp;License:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;code&nbsp;is&nbsp;released&nbsp;under&nbsp;QPL
129
<BR>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Copyright&nbsp;(C)&nbsp;2001,2002&nbsp;Johan&nbsp;Persson
130
<BR>
131
//&nbsp;Note:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;actual&nbsp;drawing&nbsp;of&nbsp;the&nbsp;tables&nbsp;are&nbsp;semi-automatically
132
<BR>
133
//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;but&nbsp;you&nbsp;can&nbsp;easily&nbsp;adjust&nbsp;the&nbsp;individual&nbsp;tables&nbsp;position
134
<BR>//&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;the&nbsp;'tblposadj'&nbsp;array.&nbsp;
135
<BR>//
136
<BR>
137
//========================================================================
138
<BR>*/
139
<BR></FONT><FONT color="#007700">include&nbsp;</FONT><FONT color="#DD0000">
140
&quot;../jpgraph.php&quot;</FONT><FONT color="#007700">;
141
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvas.php&quot;</FONT><FONT
142
color="#007700">;
143
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpgraph_canvtools.php&quot;</FONT><FONT
144
color="#007700">;
145
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../imgdbschema.inc&quot;</FONT><FONT
146
color="#007700">;
147
<BR>include&nbsp;</FONT><FONT color="#DD0000">&quot;../jpdb.php&quot;</FONT><FONT color="#007700">
148
;
149
<BR>
150
<BR>
151
<BR></FONT><FONT color="#FF8000">
152
//&nbsp;Global&nbsp;callback&nbsp;to&nbsp;format&nbsp;the&nbsp;table&nbsp;header&nbsp;names
153
<BR></FONT><FONT color="#007700">function&nbsp;</FONT><FONT color="#0000BB">
154
FormatTblName</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
155
$aName</FONT><FONT color="#007700">)&nbsp;{
156
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
157
//&nbsp;We&nbsp;want&nbsp;to&nbsp;replace&nbsp;any&nbsp;specifi&nbsp;references&nbsp;to&nbsp;the
158
<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;'JpGraph'&nbsp;project&nbsp;with&nbsp;the&nbsp;generic&nbsp;'&lt;project&gt;'
159
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#007700">return&nbsp;</FONT><FONT color="#0000BB">
160
str_replace</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
161
'JpGraph'</FONT><FONT color="#007700">,</FONT><FONT color="#DD0000">
162
'&lt;project&gt;'</FONT><FONT color="#007700">,&nbsp;</FONT><FONT color="#0000BB">
163
$aName</FONT><FONT color="#007700">);
164
<BR>}
165
<BR>
166
<BR></FONT><FONT color="#FF8000">
167
//&nbsp;Global&nbsp;callback&nbsp;to&nbsp;format&nbsp;each&nbsp;field&nbsp;name&nbsp;in&nbsp;the&nbsp;table
168
<BR></FONT><FONT color="#007700">function&nbsp;</FONT><FONT color="#0000BB">
169
FormatFldName</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
170
$aName</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$aTable</FONT><FONT
171
color="#007700">)&nbsp;{
172
<BR>&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</FONT><FONT color="#0000BB">$aName</FONT><FONT color="#007700">
173
;
174
<BR>}
175
<BR>
176
<BR>
177
<BR>class&nbsp;</FONT><FONT color="#0000BB">Driver&nbsp;</FONT><FONT color="#007700">
178
{
179
<BR>
180
<BR>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</FONT><FONT color="#0000BB">$ig</FONT><FONT color="#007700">
181
,&nbsp;</FONT><FONT color="#0000BB">$img</FONT><FONT color="#007700">,&nbsp;</FONT><FONT
182
color="#0000BB">$iscale</FONT><FONT color="#007700">,&nbsp;</FONT><FONT color="#0000BB">
183
$ishape</FONT><FONT color="#007700">;
184
<BR>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</FONT><FONT color="#0000BB">$iymax</FONT><FONT color="#007700">
185
,</FONT><FONT color="#0000BB">$ixmax</FONT><FONT color="#007700">;
186
<BR>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;</FONT><FONT color="#0000BB">$iwidth</FONT><FONT color="#007700">
187
,</FONT><FONT color="#0000BB">$iheight</FONT><FONT color="#007700">;
188
<BR>
189
<BR>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</FONT><FONT color="#0000BB">Driver</FONT><FONT color="#007700">
190
()&nbsp;{
191
<BR>
192
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
193
//&nbsp;Define&nbsp;Image&nbsp;size&nbsp;and&nbsp;coordinate&nbsp;grid&nbsp;space&nbsp;to&nbsp;work&nbsp;within
194
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
195
-&gt;</FONT><FONT color="#0000BB">iwidth&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
196
color="#0000BB">600</FONT><FONT color="#007700">;
197
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
198
-&gt;</FONT><FONT color="#0000BB">iheight</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
199
color="#0000BB">750</FONT><FONT color="#007700">;
200
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
201
-&gt;</FONT><FONT color="#0000BB">iymax&nbsp;&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
202
color="#0000BB">50</FONT><FONT color="#007700">;
203
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
204
-&gt;</FONT><FONT color="#0000BB">ixmax&nbsp;&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
205
color="#0000BB">55</FONT><FONT color="#007700">;
206
<BR>
207
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Setup&nbsp;a&nbsp;basic&nbsp;canvas
208
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
209
-&gt;</FONT><FONT color="#0000BB">ig&nbsp;</FONT><FONT color="#007700">=&nbsp;new&nbsp;</FONT><FONT
210
color="#0000BB">CanvasGraph</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
211
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">iwidth</FONT><FONT
212
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
213
-&gt;</FONT><FONT color="#0000BB">iheight</FONT><FONT color="#007700">,</FONT><FONT
214
color="#DD0000">'auto'</FONT><FONT color="#007700">);
215
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
216
-&gt;</FONT><FONT color="#0000BB">img&nbsp;</FONT><FONT color="#007700">=&nbsp;</FONT><FONT
217
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
218
ig</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
219
color="#007700">;
220
<BR>
221
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Define&nbsp;the&nbsp;scale&nbsp;to&nbsp;be&nbsp;used
222
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
223
-&gt;</FONT><FONT color="#0000BB">iscale&nbsp;</FONT><FONT color="#007700">
224
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">CanvasScale</FONT><FONT color="#007700">
225
(</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT
226
color="#0000BB">ig</FONT><FONT color="#007700">);
227
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
228
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">-&gt;</FONT><FONT
229
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
230
0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
231
color="#007700">-&gt;</FONT><FONT color="#0000BB">ixmax</FONT><FONT color="#007700">
232
,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
233
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
234
iymax</FONT><FONT color="#007700">);
235
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
236
-&gt;</FONT><FONT color="#0000BB">ishape&nbsp;</FONT><FONT color="#007700">
237
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">Shape</FONT><FONT color="#007700">(</FONT><FONT
238
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
239
ig</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
240
color="#007700">-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">
241
);
242
<BR>
243
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;A&nbsp;small&nbsp;frame&nbsp;around&nbsp;the&nbsp;canvas
244
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
245
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
246
color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
247
2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">3</FONT><FONT
248
color="#007700">,</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">
249
,</FONT><FONT color="#0000BB">3</FONT><FONT color="#007700">);
250
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
251
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
252
color="#0000BB">SetMarginColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
253
&quot;teal&quot;</FONT><FONT color="#007700">);
254
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
255
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
256
color="#0000BB">InitFrame</FONT><FONT color="#007700">();
257
<BR>
258
<BR>&nbsp;&nbsp;&nbsp;&nbsp;}
259
<BR>
260
<BR>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</FONT><FONT color="#0000BB">Run</FONT><FONT color="#007700">
261
()&nbsp;{
262
<BR>
263
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$leftm</FONT><FONT color="#007700">
264
=</FONT><FONT color="#0000BB">1.5</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT
265
color="#FF8000">//&nbsp;Left&nbsp;margin&nbsp;(for&nbsp;table&nbsp;schemes)&nbsp;
266
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$topm</FONT><FONT color="#007700">=</FONT><FONT
267
color="#0000BB">5</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
268
//&nbsp;Top&nbsp;margin&nbsp;(for&nbsp;table&nbsp;schemes)&nbsp;
269
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">
270
=</FONT><FONT color="#0000BB">15</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT
271
color="#FF8000">//&nbsp;Individual&nbsp;table&nbsp;width
272
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">=</FONT><FONT
273
color="#0000BB">1</FONT><FONT color="#007700">;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
274
//&nbsp;Offset&nbsp;for&nbsp;top&nbsp;line
275
<BR>
276
<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Add&nbsp;the&nbsp;background&nbsp;color&nbsp;for&nbsp;the&nbsp;project&nbsp;specific&nbsp;tables
277
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
278
-&gt;</FONT><FONT color="#0000BB">ishape</FONT><FONT color="#007700">-&gt;</FONT><FONT
279
color="#0000BB">IndentedRectangle</FONT><FONT color="#007700">(</FONT><FONT
280
color="#0000BB">$leftm</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
281
$topm</FONT><FONT color="#007700">-</FONT><FONT color="#0000BB">1</FONT><FONT
282
color="#007700">,</FONT><FONT color="#0000BB">3</FONT><FONT color="#007700">
283
*</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT
284
color="#0000BB">$tlo</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
285
6</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">45</FONT><FONT
286
color="#007700">,
287
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">
288
+</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">*</FONT><FONT
289
color="#0000BB">$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
290
2</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">30</FONT><FONT
291
color="#007700">,</FONT><FONT color="#0000BB">CORNER_BOTTOMLEFT</FONT><FONT
292
color="#007700">,
293
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#DD0000">'lightblue'</FONT><FONT
294
color="#007700">);
295
<BR>
296
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">
297
//&nbsp;Stroke&nbsp;the&nbsp;tables&nbsp;(series&nbsp;of&nbsp;x,y&nbsp;offsets,&nbsp;If&nbsp;=-1&nbsp;then&nbsp;use&nbsp;the
298
<BR>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;automtic&nbsp;positioning
299
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tblposadj</FONT><FONT color="#007700">
300
=array(</FONT><FONT color="#0000BB">$tlo</FONT><FONT color="#007700">,</FONT><FONT
301
color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
302
$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">$tlo</FONT><FONT
303
color="#007700">+</FONT><FONT color="#0000BB">2</FONT><FONT color="#007700">
304
,</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">,</FONT><FONT
305
color="#0000BB">2</FONT><FONT color="#007700">*</FONT><FONT color="#0000BB">
306
$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">$tlo</FONT><FONT
307
color="#007700">+</FONT><FONT color="#0000BB">4</FONT><FONT color="#007700">
308
,
309
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">0</FONT><FONT color="#007700">
310
,-</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONT
311
color="#0000BB">16</FONT><FONT color="#007700">,-</FONT><FONT color="#0000BB">
312
1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">16</FONT><FONT
313
color="#007700">);
314
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema&nbsp;</FONT><FONT color="#007700">
315
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">ImgDBSchema</FONT><FONT color="#007700">
316
(</FONT><FONT color="#DD0000">'jpgraph_doc'</FONT><FONT color="#007700">
317
,</FONT><FONT color="#DD0000">'FormatTblName'</FONT><FONT color="#007700">
318
,</FONT><FONT color="#DD0000">'FormatFldName'</FONT><FONT color="#007700">
319
);
320
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
321
-&gt;</FONT><FONT color="#0000BB">SetMargin</FONT><FONT color="#007700">(</FONT><FONT
322
color="#0000BB">$leftm</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
323
$topm</FONT><FONT color="#007700">);
324
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
325
-&gt;</FONT><FONT color="#0000BB">SetTableWidth</FONT><FONT color="#007700">
326
(</FONT><FONT color="#0000BB">$tblwidth</FONT><FONT color="#007700">);
327
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$dbschema</FONT><FONT color="#007700">
328
-&gt;</FONT><FONT color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT
329
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
330
img</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT
331
color="#007700">-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">
332
,</FONT><FONT color="#0000BB">$tblposadj</FONT><FONT color="#007700">);
333
<BR>
334
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt&nbsp;</FONT><FONT color="#007700">
335
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">CanvasRectangleText</FONT><FONT color="#007700">
336
();
337
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
338
color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
339
''</FONT><FONT color="#007700">);
340
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
341
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
342
''</FONT><FONT color="#007700">);
343
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
344
color="#0000BB">SetFontColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
345
'navy'</FONT><FONT color="#007700">);
346
<BR>
347
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;explanation
348
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
349
color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
350
FF_ARIAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
351
FS_NORMAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">12</FONT><FONT
352
color="#007700">);
353
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
354
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
355
'Project&nbsp;specific&nbsp;tables'</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
356
$tblwidth</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">
357
$leftm</FONT><FONT color="#007700">+</FONT><FONT color="#0000BB">3</FONT><FONT
358
color="#007700">,</FONT><FONT color="#0000BB">16</FONT><FONT color="#007700">
359
,</FONT><FONT color="#0000BB">15</FONT><FONT color="#007700">);
360
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
361
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
362
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
363
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
364
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">);
365
<BR>
366
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;title
367
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
368
color="#0000BB">SetColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
369
''</FONT><FONT color="#007700">);
370
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
371
color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
372
FF_VERDANA</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
373
FS_BOLD</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">26</FONT><FONT
374
color="#007700">);
375
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
376
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
377
'DDDA&nbsp;-&nbsp;DB&nbsp;Schema'</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
378
9</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">0.5</FONT><FONT
379
color="#007700">,</FONT><FONT color="#0000BB">30</FONT><FONT color="#007700">
380
);
381
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
382
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
383
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
384
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
385
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">);
386
<BR>
387
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#FF8000">//&nbsp;Add&nbsp;a&nbsp;version&nbsp;and&nbsp;date
388
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
389
color="#0000BB">SetFillColor</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
390
'yellow'</FONT><FONT color="#007700">);
391
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
392
color="#0000BB">SetFont</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
393
FF_FONT1</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">
394
FS_NORMAL</FONT><FONT color="#007700">,</FONT><FONT color="#0000BB">10</FONT><FONT
395
color="#007700">);
396
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
397
color="#0000BB">Set</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">
398
&quot;Generated:&nbsp;&quot;</FONT><FONT color="#007700">.</FONT><FONT color="#0000BB">
399
date</FONT><FONT color="#007700">(</FONT><FONT color="#DD0000">&quot;ymd&nbsp;H:i&quot;</FONT><FONT
400
color="#007700">,</FONT><FONT color="#0000BB">time</FONT><FONT color="#007700">
401
()),</FONT><FONT color="#0000BB">1</FONT><FONT color="#007700">,</FONT><FONT
402
color="#0000BB">$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">
403
iymax</FONT><FONT color="#007700">*</FONT><FONT color="#0000BB">0.96</FONT><FONT
404
color="#007700">,</FONT><FONT color="#0000BB">15</FONT><FONT color="#007700">
405
);&nbsp;
406
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$tt</FONT><FONT color="#007700">-&gt;</FONT><FONT
407
color="#0000BB">Stroke</FONT><FONT color="#007700">(</FONT><FONT color="#0000BB">
408
$this</FONT><FONT color="#007700">-&gt;</FONT><FONT color="#0000BB">img</FONT><FONT
409
color="#007700">,</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
410
-&gt;</FONT><FONT color="#0000BB">iscale</FONT><FONT color="#007700">);
411
<BR>
412
<BR>&nbsp;&nbsp;&nbsp;&nbsp;</FONT><FONT color="#0000BB">$this</FONT><FONT color="#007700">
413
-&gt;</FONT><FONT color="#0000BB">ig</FONT><FONT color="#007700">-&gt;</FONT><FONT
414
color="#0000BB">Stroke</FONT><FONT color="#007700">();
415
<BR>&nbsp;&nbsp;&nbsp;&nbsp;}
416
<BR>}
417
<BR>
418
<BR></FONT><FONT color="#0000BB">$driver&nbsp;</FONT><FONT color="#007700">
419
=&nbsp;new&nbsp;</FONT><FONT color="#0000BB">Driver</FONT><FONT color="#007700">
420
();
421
<BR></FONT><FONT color="#0000BB">$driver</FONT><FONT color="#007700">-&gt;</FONT><FONT
422
color="#0000BB">Run</FONT><FONT color="#007700">();
423
<BR>
424
<BR></FONT><FONT color="#0000BB">?&gt;
425
<BR></FONT>
426
<BR></FONT></CODE></DIV></P>
427
<HR NOSHADE>
428
<A HREF="toc.html">Contents</A>
429
<A HREF="114Usingacanvasscale.html">Previous</A>
430
<A HREF="12AntiSpamChallenges.html">Next</A>
431
</BODY>
432
</HTML>