98 |
- |
1 |
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
|
|
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>DrawMessage</title><link rel="stylesheet" type="text/css" href="phplotdoc.css" /><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="PHPlot Reference Manual" /><link rel="up" href="reference.html" title="PHPlot Function Reference" /><link rel="prev" href="DrawGraph.html" title="DrawGraph" /><link rel="next" href="EncodeImage.html" title="EncodeImage" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">DrawMessage</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="DrawGraph.html">Prev</a> </td><th width="60%" align="center">PHPlot Function Reference</th><td width="20%" align="right"> <a accesskey="n" href="EncodeImage.html">Next</a></td></tr></table><hr /></div><div class="refentry"><a id="DrawMessage"></a><div class="titlepage"></div><div class="refnamediv"><h2><span class="refentrytitle">DrawMessage</span></h2><p>DrawMessage — Draw a text message on the image, discarding the plot</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">$plot->DrawMessage(<em class="parameter"><code>$text</code></em>, [<span class="optional"><em class="parameter"><code>$options</code></em></span>])</pre></div><div class="refsect1"><a id="idp1377641892"></a><h2>Description</h2><p>
|
|
|
3 |
<code class="function">DrawMessage</code> draws a text message on the image,
|
|
|
4 |
effectively replacing the plot with a message. It can be used instead of
|
|
|
5 |
<a class="xref" href="DrawGraph.html" title="DrawGraph"><span class="refentrytitle">DrawGraph</span></a> to handle an application-level error condition,
|
|
|
6 |
for example.
|
|
|
7 |
</p></div><div class="refsect1"><a id="idp1377643356"></a><h2>Parameters</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="replaceable"><code>$text</code></em></span></dt><dd><p>
|
|
|
8 |
The text message to display. This can include newlines, which will result
|
|
|
9 |
in line breaks.
|
|
|
10 |
</p></dd><dt><span class="term"><em class="replaceable"><code>$options</code></em></span></dt><dd><p>
|
|
|
11 |
Optional associative array of settings to control the appearance of the
|
|
|
12 |
message image. If missing or empty, the defaults result in small black
|
|
|
13 |
text on a white background, with word wrapping. If provided, the options
|
|
|
14 |
array may contain the following keys and values:
|
|
|
15 |
</p><div class="informaltable"><table summary="DrawMessage options" border="1"><colgroup><col class="c1" /><col class="c2" /><col class="c3" /></colgroup><thead><tr><th>Option name (array key)</th><th>Default value</th><th>Description</th></tr></thead><tbody><tr><td>draw_background</td><td>False</td><td>If true, draw the image background</td></tr><tr><td>draw_border</td><td>False</td><td>If true, draw the image border</td></tr><tr><td>force_print</td><td>True</td><td>If true, ignore SetPrintImage(False) and always
|
|
|
16 |
output</td></tr><tr><td>reset_font</td><td>True</td><td>If true, reset fonts to standard sizes and type</td></tr><tr><td>text_color</td><td>''</td><td>If not empty, color to use for the text</td></tr><tr><td>text_wrap</td><td>True</td><td>If true, word-wrap the text</td></tr><tr><td>wrap_width</td><td>75</td><td>Width in characters for word-wrapping the text</td></tr></tbody></table></div><p>
|
|
|
17 |
</p></dd></dl></div></div><div class="refsect1"><a id="idp1377655156"></a><h2>Notes</h2><p>
|
|
|
18 |
The default option values are chosen to be appropriate for error messages,
|
|
|
19 |
and are designed to be 'fail-safe'. (For example, resetting fonts to use
|
|
|
20 |
the built-in GD fonts ensures that there will be no error with TrueType
|
|
|
21 |
font files while displaying an error message.)
|
|
|
22 |
</p><p>
|
|
|
23 |
If the <code class="literal">draw_background</code> option is <code class="literal">False</code>
|
|
|
24 |
or defaulted, the image will have a white background.
|
|
|
25 |
If <code class="literal">draw_background</code> is <code class="literal">True</code>,
|
|
|
26 |
then the image will have a background as specified by prior calls to
|
|
|
27 |
<a class="xref" href="SetBackgroundColor.html" title="SetBackgroundColor"><span class="refentrytitle">SetBackgroundColor</span></a> or <a class="xref" href="SetBgImage.html" title="SetBgImage"><span class="refentrytitle">SetBgImage</span></a>.
|
|
|
28 |
If neither of those has been called before <code class="function">DrawMessage</code>,
|
|
|
29 |
then the background will be white regardless of the
|
|
|
30 |
<code class="literal">draw_background</code> option value.
|
|
|
31 |
Note that if an input file was given to the PHPlot constructor to set a
|
|
|
32 |
background, that will not be used with a message image, regardless of the
|
|
|
33 |
options.
|
|
|
34 |
</p><p>
|
|
|
35 |
If the <code class="literal">draw_border</code> option is <code class="literal">False</code>
|
|
|
36 |
or defaulted, no border will be drawn.
|
|
|
37 |
If <code class="literal">draw_border</code> is <code class="literal">True</code>,
|
|
|
38 |
then the the image will have a border as specified by prior calls to
|
|
|
39 |
<a class="xref" href="SetImageBorderType.html" title="SetImageBorderType"><span class="refentrytitle">SetImageBorderType</span></a>, <a class="xref" href="SetImageBorderWidth.html" title="SetImageBorderWidth"><span class="refentrytitle">SetImageBorderWidth</span></a>,
|
|
|
40 |
and <a class="xref" href="SetImageBorderColor.html" title="SetImageBorderColor"><span class="refentrytitle">SetImageBorderColor</span></a>.
|
|
|
41 |
Note that if <code class="function">SetImageBorderType</code> was not used to enable
|
|
|
42 |
a border before <code class="function">DrawMessage</code>, then there will be no border,
|
|
|
43 |
regardless of the <code class="literal">draw_border</code> option value.
|
|
|
44 |
</p><p>
|
|
|
45 |
The message text will be drawn using the PHPlot <code class="literal">generic</code>
|
|
|
46 |
font settings.
|
|
|
47 |
But if the <code class="literal">reset_font</code> option is <code class="literal">True</code>
|
|
|
48 |
or defaulted, all fonts will be reset to defaults first,
|
|
|
49 |
resulting in the use of GD font #2 (a small monospaced font).
|
|
|
50 |
If <code class="literal">reset_font</code> is <code class="literal">False</code>,
|
|
|
51 |
the <code class="literal">generic</code> font settings will be used without reset.
|
|
|
52 |
Use <a class="xref" href="SetFont.html" title="SetFont"><span class="refentrytitle">SetFont</span></a>, <a class="xref" href="SetFontGD.html" title="SetFontGD"><span class="refentrytitle">SetFontGD</span></a>, or
|
|
|
53 |
<a class="xref" href="SetFontTTF.html" title="SetFontTTF"><span class="refentrytitle">SetFontTTF</span></a> in this case to select the font.
|
|
|
54 |
For example, to use a TrueType font for your message, call
|
|
|
55 |
<code class="literal">$plot->SetFontTTF('generic', $font_name, $font_size)</code>,
|
|
|
56 |
then set the <code class="literal">reset_font</code> option to <code class="literal">False</code>
|
|
|
57 |
when calling <code class="function">DrawMessage()</code>.
|
|
|
58 |
</p><p>
|
|
|
59 |
If the <code class="literal">text_color</code> option is empty or defaulted,
|
|
|
60 |
the text will be black. To use a different color for the message text,
|
|
|
61 |
set <code class="literal">text_color</code> to any valid PHPlot color specification,
|
|
|
62 |
such as a color name or "#rrggbb" form
|
|
|
63 |
(see <a class="xref" href="conc-colors.html#conc-colors-forms" title="3.5.1. Color Parameter Forms">Section 3.5.1, “Color Parameter Forms”</a>).
|
|
|
64 |
</p><p>
|
|
|
65 |
If the <code class="literal">force_print</code> option is <code class="literal">True</code> or
|
|
|
66 |
defaulted, the message image will be output after creating it - ignoring
|
|
|
67 |
any setting made with <a class="xref" href="SetPrintImage.html" title="SetPrintImage"><span class="refentrytitle">SetPrintImage</span></a>.
|
|
|
68 |
If <code class="literal">force_print</code> is <code class="literal">False</code>,
|
|
|
69 |
and <code class="function">SetPrintImage(False)</code> was previously called,
|
|
|
70 |
the message image will created but not output.
|
|
|
71 |
This would be appropriate when using <a class="xref" href="PrintImage.html" title="PrintImage"><span class="refentrytitle">PrintImage</span></a> or
|
|
|
72 |
<a class="xref" href="EncodeImage.html" title="EncodeImage"><span class="refentrytitle">EncodeImage</span></a> to output the image.
|
|
|
73 |
Note that if <code class="function">SetPrintImage(False)</code> was not called,
|
|
|
74 |
the image will be output regardless of the <code class="literal">force_print</code>
|
|
|
75 |
option value.
|
|
|
76 |
</p><p>
|
|
|
77 |
The text may contain newlines, which will produce separate lines of text
|
|
|
78 |
in the message image.
|
|
|
79 |
The text will be word-wrapped (unless the <code class="literal">text_wrap</code>
|
|
|
80 |
option is set to <code class="literal">False</code>).
|
|
|
81 |
Each line of text will be left aligned, and the bounding box
|
|
|
82 |
of the text will be centered in the image. PHPlot makes no attempt to make
|
|
|
83 |
sure the text will fit, but the upper left corner will always be visible.
|
|
|
84 |
</p><p>
|
|
|
85 |
After using <code class="function">DrawMessage</code> and automatic or subsequent
|
|
|
86 |
output of the image, the PHPlot object should not be reused.
|
|
|
87 |
</p><p>
|
|
|
88 |
See <a class="xref" href="ex-drawmessage.html" title="5.42. Example - DrawMessage">Section 5.42, “Example - DrawMessage”</a> for an example of this function.
|
|
|
89 |
</p></div><div class="refsect1"><a id="idp1377676692"></a><h2>History</h2><p>
|
|
|
90 |
This function was added in PHPlot-5.7.0.
|
|
|
91 |
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="DrawGraph.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="EncodeImage.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">DrawGraph </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> EncodeImage</td></tr></table></div></body></html>
|