pdf-writer 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +44 -0
- data/LICENCE +118 -0
- data/README +32 -0
- data/bin/loader +54 -0
- data/bin/manual +22 -0
- data/bin/manual.bat +2 -0
- data/demo/chunkybacon.rb +28 -0
- data/demo/code.rb +63 -0
- data/demo/colornames.rb +843 -0
- data/demo/demo.rb +65 -0
- data/demo/gettysburg.rb +58 -0
- data/demo/hello.rb +18 -0
- data/demo/individual-i.rb +81 -0
- data/demo/pac.rb +62 -0
- data/demo/pagenumber.rb +67 -0
- data/demo/qr-language.rb +573 -0
- data/demo/qr-library.rb +371 -0
- data/images/chunkybacon.jpg +0 -0
- data/images/chunkybacon.png +0 -0
- data/images/pdfwriter-icon.jpg +0 -0
- data/images/pdfwriter-small.jpg +0 -0
- data/lib/pdf/charts.rb +13 -0
- data/lib/pdf/charts/stddev.rb +431 -0
- data/lib/pdf/grid.rb +135 -0
- data/lib/pdf/math.rb +108 -0
- data/lib/pdf/quickref.rb +330 -0
- data/lib/pdf/simpletable.rb +946 -0
- data/lib/pdf/techbook.rb +890 -0
- data/lib/pdf/writer.rb +2661 -0
- data/lib/pdf/writer/arc4.rb +63 -0
- data/lib/pdf/writer/fontmetrics.rb +201 -0
- data/lib/pdf/writer/fonts/Courier-Bold.afm +342 -0
- data/lib/pdf/writer/fonts/Courier-BoldOblique.afm +342 -0
- data/lib/pdf/writer/fonts/Courier-Oblique.afm +342 -0
- data/lib/pdf/writer/fonts/Courier.afm +342 -0
- data/lib/pdf/writer/fonts/Helvetica-Bold.afm +2827 -0
- data/lib/pdf/writer/fonts/Helvetica-BoldOblique.afm +2827 -0
- data/lib/pdf/writer/fonts/Helvetica-Oblique.afm +3051 -0
- data/lib/pdf/writer/fonts/Helvetica.afm +3051 -0
- data/lib/pdf/writer/fonts/MustRead.html +1 -0
- data/lib/pdf/writer/fonts/Symbol.afm +213 -0
- data/lib/pdf/writer/fonts/Times-Bold.afm +2588 -0
- data/lib/pdf/writer/fonts/Times-BoldItalic.afm +2384 -0
- data/lib/pdf/writer/fonts/Times-Italic.afm +2667 -0
- data/lib/pdf/writer/fonts/Times-Roman.afm +2419 -0
- data/lib/pdf/writer/fonts/ZapfDingbats.afm +225 -0
- data/lib/pdf/writer/graphics.rb +727 -0
- data/lib/pdf/writer/graphics/imageinfo.rb +365 -0
- data/lib/pdf/writer/lang.rb +43 -0
- data/lib/pdf/writer/lang/en.rb +77 -0
- data/lib/pdf/writer/object.rb +23 -0
- data/lib/pdf/writer/object/action.rb +40 -0
- data/lib/pdf/writer/object/annotation.rb +42 -0
- data/lib/pdf/writer/object/catalog.rb +39 -0
- data/lib/pdf/writer/object/contents.rb +68 -0
- data/lib/pdf/writer/object/destination.rb +40 -0
- data/lib/pdf/writer/object/encryption.rb +53 -0
- data/lib/pdf/writer/object/font.rb +76 -0
- data/lib/pdf/writer/object/fontdescriptor.rb +34 -0
- data/lib/pdf/writer/object/fontencoding.rb +39 -0
- data/lib/pdf/writer/object/image.rb +168 -0
- data/lib/pdf/writer/object/info.rb +55 -0
- data/lib/pdf/writer/object/outline.rb +30 -0
- data/lib/pdf/writer/object/outlines.rb +30 -0
- data/lib/pdf/writer/object/page.rb +195 -0
- data/lib/pdf/writer/object/pages.rb +115 -0
- data/lib/pdf/writer/object/procset.rb +46 -0
- data/lib/pdf/writer/object/viewerpreferences.rb +74 -0
- data/lib/pdf/writer/ohash.rb +58 -0
- data/lib/pdf/writer/oreader.rb +25 -0
- data/lib/pdf/writer/state.rb +48 -0
- data/lib/pdf/writer/strokestyle.rb +138 -0
- data/manual.pwd +5151 -0
- metadata +147 -0
data/demo/qr-library.rb
ADDED
@@ -0,0 +1,371 @@
|
|
1
|
+
#--
|
2
|
+
# PDF::Writer for Ruby.
|
3
|
+
# http://rubyforge.org/projects/ruby-pdf/
|
4
|
+
# Copyright 2003 - 2005 Austin Ziegler.
|
5
|
+
#
|
6
|
+
# This Quick Reference card program is copyright 2003�2005 Ryan
|
7
|
+
# Davis and is licensed under the Creative Commons Attribution
|
8
|
+
# NonCommercial
|
9
|
+
# ShareAlike[http://creativecommons.org/licenses/by-nc-sa/2.0/] licence.
|
10
|
+
#
|
11
|
+
# See LICENCE in the main distribution for full licensing information.
|
12
|
+
#
|
13
|
+
# $Id: qr-library.rb,v 1.4 2005/06/02 21:20:35 austin Exp $
|
14
|
+
#++
|
15
|
+
load '../bin/loader'
|
16
|
+
ClassLoader.new 'pdf/writer'
|
17
|
+
|
18
|
+
require 'pdf/quickref'
|
19
|
+
|
20
|
+
if ARGV[0].nil?
|
21
|
+
paper = "LETTER"
|
22
|
+
else
|
23
|
+
if PDF::Writer::PAGE_SIZES.has_key?(ARGV[0])
|
24
|
+
paper = ARGV[0]
|
25
|
+
else
|
26
|
+
puts <<-EOS
|
27
|
+
usage: #{File.basename($0)} [paper-size]
|
28
|
+
|
29
|
+
paper-size must be one of the standard PDF::Writer page sizes.
|
30
|
+
Default paper-size is LETTER.
|
31
|
+
EOS
|
32
|
+
exit 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
PDF::QuickRef.make(paper, 3) do
|
37
|
+
pdf.info.author = "Ryan Davis"
|
38
|
+
pdf.info.title = "Ruby Library Quick Reference"
|
39
|
+
pdf.info.subject = "The Ruby Standard Library"
|
40
|
+
|
41
|
+
self.title_font_size = 13
|
42
|
+
self.h1_font_size = 10
|
43
|
+
self.h2_font_size = 8
|
44
|
+
self.h3_font_size = 7
|
45
|
+
self.h4_font_size = 6
|
46
|
+
self.body_font_size = 5
|
47
|
+
|
48
|
+
enc = {
|
49
|
+
:encoding => 'WinAnsiEncoding',
|
50
|
+
:differences => {
|
51
|
+
148 => "copyright",
|
52
|
+
}
|
53
|
+
}
|
54
|
+
self.title_font_encoding = enc
|
55
|
+
self.heading_font_encoding = enc
|
56
|
+
self.body_font_encoding = enc
|
57
|
+
self.code_font_encoding = enc
|
58
|
+
|
59
|
+
title "Ruby Standard Library QuickRef"
|
60
|
+
h1 "Class Hierarchy"
|
61
|
+
pairs <<-'EOS'
|
62
|
+
Object The parent object class. Includes <b>Kernel</b>.
|
63
|
+
Array Ordered integer-indexed collection of any object. Includes <b>Enumerable</b>.
|
64
|
+
Hash An unordered associative collection; keys may be any object. Includes <b>Enumerable</b>.
|
65
|
+
String Holds and manipulates an arbitrary sequence of bytes, typically representing characters. Includes <b>Comparable</b> and <b>Enumerable</b>.
|
66
|
+
Symbol Names in the ruby interpreter.
|
67
|
+
IO Base input/output class for Ruby. Includes <b>Enumerable</b>.
|
68
|
+
File An abstraction of a file object for IO purposes.
|
69
|
+
File::Stat Encapsulates File status information. Includes <b>Comparable</b>.
|
70
|
+
Continuation Holds a return address and execution context, allowing for nonlocal returns to the execution context.
|
71
|
+
Exception The root exception class. StandardError The parent of exceptions that can be rescued without an exception specification. Children are: LocalJumpError, SystemStackError, ZeroDivisionError, RangeError (FloatDomainError), SecurityError, ThreadError, IOError (EOFError), ArgumentError, IndexError, RuntimeError, TypeError, SystemCallError (Errno::*), and RegexpError.
|
72
|
+
SignalException An exception raised from an OS signal.
|
73
|
+
Interrupt An interrupt exception.
|
74
|
+
NoMemoryError The interpreter is out of memory.
|
75
|
+
ScriptError Various script errors. Children are: LoadError, NameError, SyntaxError, and NotImplementedError.
|
76
|
+
SystemExit This exception is raised when Kernel#exit is called.
|
77
|
+
Proc Blocks of code bound to a set of local variables.
|
78
|
+
Numeric The base class that numbers are based on. Includes <b>Comparable</b>.
|
79
|
+
Float Real numbers using the native architecture�s double-precision floating point representation. Includes <b>Precision</b>
|
80
|
+
Integer The abstract class for the two whole number classes, Bignum and Fixnum. Includes <b>Precision</b>.
|
81
|
+
Bignum Holds large integers outside of Fixnum�s range. Autoconverts on overflow and underflow.
|
82
|
+
Fixnum Integer values that can fit in a native word (less one bit). Includes <b>Precision</b>.
|
83
|
+
Regexp Regular expression objects.
|
84
|
+
Module A collection of methods and constants that may be used as a namespace or mixed in to objects, other modules, or classes.
|
85
|
+
Class The base class for object classes.
|
86
|
+
Thread Encapsulates Ruby�s green threads.
|
87
|
+
ThreadGroup Allows the tracking of multiple threads as a group.
|
88
|
+
Method An instance of a method bound to a particular object. Calls are against that object.
|
89
|
+
UnboundMethod An method unassociated with an object, but can be bound against an object.
|
90
|
+
Struct A convenient way to bundle a number of attributes together, using accessor methods, without having to write an explicit class.
|
91
|
+
Time A class for encapsulating the concept of a moment in Time.
|
92
|
+
Dir Directory streams representing directories in the underlying file system.
|
93
|
+
Binding Encapsulate the execution context at some particular place in the code and retain this context for future use.
|
94
|
+
Range Represents an interval (a set of values with a start and an end).
|
95
|
+
MatchData A match for a regular expression. Returned by Regexp#match.
|
96
|
+
TrueClass The class of the global value <b>true</b>.
|
97
|
+
FalseClass The class of the global value <b>false</b>.
|
98
|
+
NilClass The class of the global value <b>nil</b>.
|
99
|
+
EOS
|
100
|
+
|
101
|
+
h1 "Modules"
|
102
|
+
pairs <<-'EOS'
|
103
|
+
Comparable Used by classes whose objects may be ordered. Requires the definition of the <b><=></b> operator for useful.
|
104
|
+
Enumerable Provides collection classes with traversal, search, and sort methods. Must provide <b>each</b>; for some methods, contained objects must implement <b><=></b>.
|
105
|
+
Errno Errno is created by the Ruby runtime to map operating system errors to Ruby classes. Each error will be a subclass of SystemCallError in the Errno namespace.
|
106
|
+
FileTest Implements file test operations similar to those used in File::Stat. It exists as a standalone module, and its methods are also insinuated into the File class.
|
107
|
+
GC Provides an interface to Ruby�s mark and sweep garbage collection mechanism.
|
108
|
+
Kernel Implements a whole host of useful methods that don�t quite belong to any object.
|
109
|
+
Marshal Converts Ruby objects into a byte stream, allowing them to be stored outside the currently active script. This data may subsequently be read and the original objects reconstituted.
|
110
|
+
Math Contains module functions for basic trigonometric and transcendental functions.
|
111
|
+
ObjectSpace Contains a number of routines that interact with the garbage collection facility and allow you to traverse all living objects with an iterator.
|
112
|
+
Precision A mixin for concrete numeric classes with precision; the fineness of approximation of a real number.
|
113
|
+
Process A collection of methods used to manipulate processes.
|
114
|
+
EOS
|
115
|
+
|
116
|
+
h1 "Standard Library"
|
117
|
+
pairs <<-'EOS'
|
118
|
+
English Include to allow for alternate, less-cryptic global variables names.
|
119
|
+
Env, importenv Imports environment variables as global variables.
|
120
|
+
Win32API Access to the Win32API directly.
|
121
|
+
abbrev Provides Abbrev::abbrev, to calculate the set of unique abbreviations for a given set of strings.
|
122
|
+
base64 Provides conversion to and from base64 in the Base64 module. Top-level usage of base64 conversions is deprecated.
|
123
|
+
benchmark Provides methods for benchmarking Ruby code.
|
124
|
+
bigdecimal Large number arbitrary precision floating point support. Analagous to Bignum.
|
125
|
+
bigdecimal/jacobian Computes Jacobian matrix of f at x.
|
126
|
+
bigdecimal/ludcmp Provides LUSolve#ludecomp and #lusolve.
|
127
|
+
bigdecimal/math Provides BigMath module.
|
128
|
+
bigdecimal/newton Solves nonlinear algebraic equation system f = 0 by Newton�s method.
|
129
|
+
bigdecimal/nlsolve Solving nonlinear algebraic equation system.
|
130
|
+
bigdecimal/util BigDecimal utilities.
|
131
|
+
cgi-lib CGI support library implemented as a delegator. Deprecated.
|
132
|
+
cgi CGI support library.
|
133
|
+
cgi/session Implements session support for CGI.
|
134
|
+
cgi/session/pstore Implements session support for CGI using PStore.
|
135
|
+
complex Implements the Complex class for complex numbers.
|
136
|
+
csv CSV class for generating and parsing delimited data.
|
137
|
+
date Provides Date and DateTime classes.
|
138
|
+
date/format Provides date formatting utilities.
|
139
|
+
delegate Delegation pattern; provides DelegateClass and SimpleDelegator.
|
140
|
+
dl Dynamic definition of Ruby interfaces to dynamically loaded libraries. Also uses dl/import, dl/struct, dl/types, and dl/win32.
|
141
|
+
drb �Distributed Ruby�. Has several other modules (drb/*).
|
142
|
+
e2mmap Exception2MessageMapper module.
|
143
|
+
erb Tiny �eRuby� embedded Ruby class.
|
144
|
+
eregex Proof of concept extensions to regular expressions.
|
145
|
+
fileutils Namespace for file utility methods: copying, moving, deleting, etc.
|
146
|
+
finalize Finalizer wrapper methods.
|
147
|
+
find Find module to for top-down traversal (and processing) of a set of file paths.
|
148
|
+
forwardable Simple delegation of individual methods.
|
149
|
+
ftools Extra tools for the file class. Deprecated, use fileutils.
|
150
|
+
generator Convert an internal iterator to an external one.
|
151
|
+
getoptlong Parses command-line options like the GNU getopt_long().
|
152
|
+
getopts Obsolete option parser. getoptlong or optparse is preferred.
|
153
|
+
gserver Implements a generic server.
|
154
|
+
digest Cryptographic digest support: Digest::MD5 (digest/md5), Digest::RMD160 (digest/rmd160), Digest::SHA1 (digest/sha1), and Digest::SHA2 (digest/sha2) are all supported.
|
155
|
+
enumerator Similar to Generator, creates an external enumerator from an enumerable method on an object.
|
156
|
+
etc Provides access to user/group information. Called /etc because this information is traditionally in /etc/passwd on Unix.
|
157
|
+
fcntl File control constants in the Fcntl namespace.
|
158
|
+
nkf Network Kanji conversion filter.
|
159
|
+
racc Ruby YACC. Only the runtime may be present in some installations.
|
160
|
+
rbconfig Ruby compile-time configuration configuration constants.
|
161
|
+
sdbm Ruby interface to SDBM.
|
162
|
+
socket Socket support.
|
163
|
+
stringio StringIO support; neither a String nor an IO, but a little of both.
|
164
|
+
strscan Fast Ruby string scanner.
|
165
|
+
syck Fast YAML parser.
|
166
|
+
tcltklib Tcl/Tk support.
|
167
|
+
tktul Tk utilities.
|
168
|
+
win32ole Access to Win32�s OLE controls.
|
169
|
+
ipaddr IPAddr class to manipulate IP addresses.
|
170
|
+
jcode Helps handle Japanese (EUC/SJIS) strings.
|
171
|
+
kconv Helps with Kanji conversion between JIS, SJIS, UTF-8, and UTF-16.
|
172
|
+
logger Logger is a simple logging utility.
|
173
|
+
mailread Reads a mail file and presents it as a class.
|
174
|
+
mathn Extends Ruby with complex, rational, and matrix behaviour with additional behaviour.
|
175
|
+
matrix Implements Matrix and Vector classes.
|
176
|
+
md5 Deprecated. Use digest/md5 instead.
|
177
|
+
mkmf Used to create Makefile for extension modules. Use with <b>ruby -r mkmf extconf.rb</b>.
|
178
|
+
monitor An extensible module to monitor an object for changes.
|
179
|
+
multi-tk Support for multiple Tk interpreters.
|
180
|
+
mutex_m Allows a random object to be treated as a Mutex.
|
181
|
+
net/ftp FTP client library.
|
182
|
+
net/http HTTP client library.
|
183
|
+
net/imap IMAP client library.
|
184
|
+
net/pop POP3 client library.
|
185
|
+
net/smtp SMTP client library.
|
186
|
+
net/telnet Telnet client library.
|
187
|
+
observer An implementation of the Observer or Publish/Subscribe pattern.
|
188
|
+
open-uri A wrapper for Kernel#open to allow http:// and ftp:// URIs as arguments.
|
189
|
+
open3 Spawns a program like popen, but with stderr.
|
190
|
+
optparse Command-line option analysis. Preferred option parser in the standard library.
|
191
|
+
ostruct OpenStruct, creates a Struct-like object with arbitrary attributes.
|
192
|
+
parsearg Argument parser. Deprecated, uses getopts.
|
193
|
+
parsedate Provides a parser for dates.
|
194
|
+
pathname Represents a pathname to locate a file in a Unix filesystem. It does not represent the file, but the path name.
|
195
|
+
ping A simple implementation of a ping-like utility using Ruby�s native socket support.
|
196
|
+
pp Pretty printer for Ruby objects. Usable in place of #inspect.
|
197
|
+
prettyprint Implementation of pretty printing algorithm.
|
198
|
+
profile Ruby-based profiler. Use as <b>ruby -rprofile ...</b>.
|
199
|
+
profiler The Ruby profiler implementation.
|
200
|
+
pstore A filesystem �database� using Marshal formatting for storage.
|
201
|
+
rational Implements rational numbers for Ruby (2 / 3 is 2 / 3, not 0.66 repeating).
|
202
|
+
readbytes Adds IO#readbytes, reads fixed sized data and guarantees read data size.
|
203
|
+
remote-tk Supports control of remote Tk interpreters.
|
204
|
+
resolv-replace Replaces resolver behaviour on socket classes.
|
205
|
+
resolv A resolver library written in Ruby.
|
206
|
+
rexml/document Ruby Electric XML (REXML) parser.
|
207
|
+
rinda/rinda A Ruby implementation of the Linda distributed computing paradigm. Uses drb.
|
208
|
+
rss/* RSS 0.9 (rss/0.9), 1.0 (rss/1.0), or 2.0 (rss/2.0) interpreter.
|
209
|
+
rss/maker/* RSS 0.9 (rss/maker/0.9), 1.0 (rss/maker/1.0), or 2.0 (rss/maker/2.0) maker.
|
210
|
+
rubyunit Deprecated. Provides a wrapper for older RUnit classes to work as if they were Test::Unit classes.
|
211
|
+
scanf scanf for Ruby.
|
212
|
+
set An implementation of a Set calss for Ruby. A collection of unordered values with no duplicates.
|
213
|
+
sha1 Deprecated. Use digest/sha1 instead.
|
214
|
+
shell Provides shell-like interaction. (?)
|
215
|
+
shellwords Splits text into an array of tokens like Unix shells do.
|
216
|
+
singleton A module to implement the Singleton pattern.
|
217
|
+
soap/soap Native Ruby SOAP library. wsdl/* provides for service discovery.
|
218
|
+
sync A two-phase lock with counter.
|
219
|
+
tcltk Direct manipulation of Tcl/Tk utilities in a namespace.
|
220
|
+
tempfile Manipulates temporary files (that will be deleted when the need for them goes away).
|
221
|
+
test/unit Native unit testing library, Test::Unit.
|
222
|
+
thread Thread support classes.
|
223
|
+
thwait Thread synchronization classes.
|
224
|
+
time Extensions to the Time class to support RFC2822 and RFC2616 formats, as well as others.
|
225
|
+
timeout An execution timeout.
|
226
|
+
tk An interface to Tk.
|
227
|
+
tkextlib/* Support for various Tk extensions (ICONS, bwidtget, itcl, itk, etc.).
|
228
|
+
tmpdir Retrieve the temporary directory path.
|
229
|
+
tracer Tracing Ruby programs
|
230
|
+
tsort Support for topological sorting.
|
231
|
+
un Replacements for common Unix commands. <b>ruby -run -e cp -- ...</b>, etc.
|
232
|
+
uri Libraries for interpreting uniform resource indicators (URIs).
|
233
|
+
weakref A Weak reference class that is not garbage collected.
|
234
|
+
webrick Webserver toolkit.
|
235
|
+
win32/registry Access to the Win32 Regsitry.
|
236
|
+
win32/resolv An interface to DNS and DHCP on Win32.
|
237
|
+
xmlrpc/* Support for XML-RPC clients and servers.
|
238
|
+
xsd/* XML instance parser.
|
239
|
+
yaml YAML support.
|
240
|
+
EOS
|
241
|
+
|
242
|
+
h1 "ruby"
|
243
|
+
h2 "Command-Line Options"
|
244
|
+
pairs <<-'EOS'
|
245
|
+
-0[octal] specify record separator (\0, if no argument).
|
246
|
+
-a autosplit mode with -n or -p (splits $_ into $F).
|
247
|
+
-c check syntax only.
|
248
|
+
-Cdirectory cd to directory, before executing your script.
|
249
|
+
--copyright print the copyright and exit.
|
250
|
+
-d set debugging flags (set $DEBUG to true).
|
251
|
+
-e 'command' one line of script. Several -e�s allowed.
|
252
|
+
-F regexp split() pattern for autosplit (-a).
|
253
|
+
-h prints summary of the options.
|
254
|
+
-i[extension] edit ARGV files in place (make backup if extension supplied).
|
255
|
+
-Idirectory specify $LOAD_PATH directory (may be used more than once).
|
256
|
+
-Kkcode specifies KANJI (Japanese) code-set.
|
257
|
+
-l enable line ending processing.
|
258
|
+
-n assume �while gets(); ... end� loop around your script.
|
259
|
+
-p assume loop like -n but print line also like sed.
|
260
|
+
-rlibrary require the library, before executing your script.
|
261
|
+
-s enable some switch parsing for switches after script name.
|
262
|
+
-S look for the script using PATH environment variable.
|
263
|
+
-T[level] turn on tainting checks.
|
264
|
+
-v print version number, then turn on verbose mode.
|
265
|
+
--version print the version and exit.
|
266
|
+
-w turn warnings on for your script.
|
267
|
+
-x[directory] strip off text before #! line and perhaps cd to directory.
|
268
|
+
-X directory causes Ruby to switch to the directory.
|
269
|
+
-y turns on compiler debug mode.
|
270
|
+
EOS
|
271
|
+
|
272
|
+
h2 "Environment Variables"
|
273
|
+
pairs <<-'EOS'
|
274
|
+
DLN_LIBRARY_PATH Search path for dynamically loaded modules.
|
275
|
+
RUBYLIB Additional search paths.
|
276
|
+
RUBYLIB_PREFIX Add this prefix to each item in RUBYLIB. Windows only.
|
277
|
+
RUBYOPT Additional command line options.
|
278
|
+
RUBYPATH With -S, searches PATH, or this value for ruby programs.
|
279
|
+
RUBYSHELL Shell to use when spawning.
|
280
|
+
EOS
|
281
|
+
|
282
|
+
h1 "irb"
|
283
|
+
pre "irb [options] [script [args]]"
|
284
|
+
|
285
|
+
h2 "irb Command-Line Options"
|
286
|
+
pairs <<-'EOS'
|
287
|
+
-f Prevents the loading of ~/.irb.rc. Version 1.1 has a bug that swallows the next argument.
|
288
|
+
-m Math mode. Overrides --inspect. Requires �mathn�.
|
289
|
+
-d Sets $DEBUG to true. Same as �ruby -d ...�
|
290
|
+
-r module Loads a module. Same as �ruby -r module ...�
|
291
|
+
--inspect Turns on inspect mode. Default.
|
292
|
+
--noinspect Turns off inspect mode.
|
293
|
+
--readline Turns on readline support. Default.
|
294
|
+
--noreadline Turns off readline support.
|
295
|
+
--prompt[-mode] prompt Sets the prompt. �prompt� must be one of �default�, �xmp�, �simple�, or �inf-ruby�.
|
296
|
+
--noprompt Turns off the prompt.
|
297
|
+
--inf-ruby-mode Turns on emacs support and turns off readline.
|
298
|
+
--sample-book-mode, --simple-prompt Same as �--prompt simple�
|
299
|
+
--tracer Turns on trace mode. Version 1.1 has a fatal bug with this flag.
|
300
|
+
--back-trace-limit Sets the amount of backtrace to display in trace mode.
|
301
|
+
--context-mode Sets the context mode (0-3) for multiple contexts. Defaults to 3. Not very clear how/why they differ.
|
302
|
+
--single-irb Turns off multiple bindings (disables the irb command below), I think.
|
303
|
+
--irb_debug level Sets internal debug level. For irb only.
|
304
|
+
-v, --version Prints the version and exits.
|
305
|
+
EOS
|
306
|
+
|
307
|
+
h2 "irb commands"
|
308
|
+
body <<-'EOS'
|
309
|
+
irb accepts arbitrary Ruby commands and the special commands described
|
310
|
+
below.
|
311
|
+
EOS
|
312
|
+
pairs <<-'EOS'
|
313
|
+
irb_exit Exits the current session, or the program if there are no other sessions.
|
314
|
+
fork block forks and runs the given block.
|
315
|
+
irb_change_binding args Changes to a secified binding.
|
316
|
+
source file Loads a ruby file into the session.
|
317
|
+
irb [obj] Starts a new session, with obj as self, if specified.
|
318
|
+
conf[.key[= val]] Access the configuration of the session. May read and write single values.
|
319
|
+
jobs Lists the known sessions.
|
320
|
+
fg (session#|thread-id|obj|self) Switches to the specifed session.
|
321
|
+
kill session Kills a specified session. Session may be specified the same as �fg�.
|
322
|
+
xmp eval-string Evaluates the string and prints the string and result in a nice manner suitable for cut/paste operations. Only available with <b>require �irb/xmp�</b>.
|
323
|
+
EOS
|
324
|
+
|
325
|
+
h1 "Ruby Debugger"
|
326
|
+
pre "ruby -r debug ..."
|
327
|
+
|
328
|
+
h2 "Commands"
|
329
|
+
pairs <<-'EOS'
|
330
|
+
b[reak] [file:]line Set breakpoint at given line in file (default current file).
|
331
|
+
b[reak] [file:]name Set breakpoint at method in file.
|
332
|
+
b[reak] Display breakpoints and watchpoints.
|
333
|
+
wat[ch] expr Break when expression becomes true.
|
334
|
+
del[ete] [nnn] Delete breakpoint nnn (default all).
|
335
|
+
disp[lay] expr Display value of nnn every time debugger gets control.
|
336
|
+
disp[lay] Show current displays.
|
337
|
+
undisp[lay] [nnn] Remove display (default all).
|
338
|
+
c[ont] Continue execution.
|
339
|
+
s[tep] nnn=1 Execute next nnn lines, stepping into methods.
|
340
|
+
n[ext] nnn=1 Execute next nnn lines, stepping over methods.
|
341
|
+
fi[nish] Finish execution of the current function.
|
342
|
+
q[uit] Exit the debugger.
|
343
|
+
w[here] Display current stack frame.
|
344
|
+
f[rame] Synonym for where.
|
345
|
+
l[ist] [start--end] List source lines from start to end.
|
346
|
+
up nnn=1 Move up nnn levels in the stack frame.
|
347
|
+
down nnn=1 Move down nnn levels in the stack frame.
|
348
|
+
v[ar] g[lobal] Display global variables.
|
349
|
+
v[ar] l[ocal] Display local variables.
|
350
|
+
v[ar] i[nstance] obj Display instance variables of obj.
|
351
|
+
v[ar] c[onst] Name Display constants in class or module name.
|
352
|
+
m[ethod] i[nstance] obj Display instance methods of obj.
|
353
|
+
m[ethod] Name Display instance methods of the class or module name.
|
354
|
+
th[read] l[ist] List all threads.
|
355
|
+
th[read] [c[ur[rent]]] Display status of current thread.
|
356
|
+
th[read] [c[ur[rent]]] nnn Make thread nnn current and stop it.
|
357
|
+
th[read] stop nnn Make thread nnn current and stop it.
|
358
|
+
th[read] resume nnn Resume thread nnn.
|
359
|
+
[p] expr Evaluate expr in the current context. expr may include assignment to variables and method invocations.
|
360
|
+
empty A null command repeats the last command.
|
361
|
+
EOS
|
362
|
+
|
363
|
+
x = pdf.absolute_right_margin + pdf.font_height(5)
|
364
|
+
y = pdf.absolute_bottom_margin
|
365
|
+
memo = %Q(Copyright � 2005 Ryan Davis with Austin Ziegler. PDF version by Austin Ziegler. Licensed under the <c:alink uri="http://creativecommons.org/licenses/by-nc-sa/2.0/">Creative Commons Attribution-NonCommercial-ShareAlike</c:alink> Licence. The original HTML version is at <c:alink uri="http://www.zenspider.com/Languages/Ruby/QuickRef.html">Zen Spider</c:alink>. Generated by <c:alink uri="http://rubyforge.org/projects/ruby-pdf/">PDF::Writer</c:alink> #{PDF::Writer::VERSION} and PDF::QuickRef #{PDF::QuickRef::VERSION}.)
|
366
|
+
pdf.add_text(x, y, 5, memo, -90)
|
367
|
+
x = pdf.absolute_right_margin - 32
|
368
|
+
y = pdf.absolute_bottom_margin + 24
|
369
|
+
|
370
|
+
save_as "Ruby-Library-QuickRef.pdf"
|
371
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/pdf/charts.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#--
|
2
|
+
# PDF::Writer for Ruby.
|
3
|
+
# http://rubyforge.org/projects/ruby-pdf/
|
4
|
+
# Copyright 2003 - 2005 Austin Ziegler.
|
5
|
+
#
|
6
|
+
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
7
|
+
# for full licensing information.
|
8
|
+
#
|
9
|
+
# $Id: charts.rb,v 1.2 2005/05/16 03:59:21 austin Exp $
|
10
|
+
#++
|
11
|
+
# A namespace for charts that can be drawn on PDF::Writer canvases.
|
12
|
+
module PDF::Charts
|
13
|
+
end
|
@@ -0,0 +1,431 @@
|
|
1
|
+
#--
|
2
|
+
# PDF::Writer for Ruby.
|
3
|
+
# http://rubyforge.org/projects/ruby-pdf/
|
4
|
+
# Copyright 2003 - 2005 Austin Ziegler.
|
5
|
+
#
|
6
|
+
# Licensed under a MIT-style licence. See LICENCE in the main distribution
|
7
|
+
# for full licensing information.
|
8
|
+
#
|
9
|
+
# $Id: stddev.rb,v 1.5 2005/06/08 22:18:05 austin Exp $
|
10
|
+
#++
|
11
|
+
require 'pdf/writer'
|
12
|
+
require 'pdf/charts'
|
13
|
+
require 'ostruct'
|
14
|
+
|
15
|
+
# Creates a standard deviation chart. This is a type of chart that is
|
16
|
+
# effective for the display of survey results or other data that can
|
17
|
+
# easily be measured in terms of the average and the standard deviation
|
18
|
+
# from that average.
|
19
|
+
#
|
20
|
+
# The scale of responses is the vertical scale; the average data points
|
21
|
+
# and standard deviation values are the horizontal scale.
|
22
|
+
class PDF::Charts::StdDev
|
23
|
+
VERSION = '1.0.0'
|
24
|
+
|
25
|
+
# A data element.
|
26
|
+
DataPoint = Struct.new(:label, :average, :stddev)
|
27
|
+
|
28
|
+
# A label for displaying the scale (vertical) of data in the dataset or
|
29
|
+
# the data set identifiers.
|
30
|
+
class Label
|
31
|
+
def initialize
|
32
|
+
yield self if block_given?
|
33
|
+
end
|
34
|
+
|
35
|
+
# The height of the label, in PDF user units. Ignored for scale
|
36
|
+
# labels.
|
37
|
+
attr_accessor :height
|
38
|
+
# The background color of the label. Ignored for scale labels.
|
39
|
+
attr_accessor :background_color
|
40
|
+
# The text color of the label.
|
41
|
+
attr_accessor :text_color
|
42
|
+
# The text size, in points, of the label.
|
43
|
+
attr_accessor :text_size
|
44
|
+
# The padding of the label. Only used for scale labels.
|
45
|
+
attr_accessor :pad
|
46
|
+
# The decimal precision of the label. Only used for scale labels.
|
47
|
+
attr_accessor :decimal_precision
|
48
|
+
end
|
49
|
+
|
50
|
+
# The scale of the dataset.
|
51
|
+
class Scale
|
52
|
+
def initialize(args = { })
|
53
|
+
@range = args[:range]
|
54
|
+
@step = args[:step]
|
55
|
+
@style = args[:style]
|
56
|
+
@show_labels = false
|
57
|
+
|
58
|
+
yield self if block_given?
|
59
|
+
|
60
|
+
raise TypeError, PDF::Lange[:charts_stddev_scale_norange] if @range.nil?
|
61
|
+
raise TypeError, PDF::Lange[:charts_stddev_scale_nostep] if @step.nil?
|
62
|
+
end
|
63
|
+
|
64
|
+
# Range of the scale. This should be a Range object.
|
65
|
+
attr_accessor :range
|
66
|
+
# The lower end of the range of the scale. The scale range may be
|
67
|
+
# modified by changing this value.
|
68
|
+
attr_accessor :first
|
69
|
+
def first #:nodoc:
|
70
|
+
@range.first
|
71
|
+
end
|
72
|
+
def first=(ff) #:nodoc:
|
73
|
+
@range = (ff..@range.last)
|
74
|
+
end
|
75
|
+
# The upper end of the range of the scale. The scale range may be
|
76
|
+
# modified by changing this value.
|
77
|
+
attr_accessor :last
|
78
|
+
def last #:nodoc:
|
79
|
+
@range.last
|
80
|
+
end
|
81
|
+
def last=(ll) #:nodoc:
|
82
|
+
@range = (@range.first..ll)
|
83
|
+
end
|
84
|
+
# Defines the step of the scale. Each step represents a vertical
|
85
|
+
# position on the chart.
|
86
|
+
attr_accessor :step
|
87
|
+
# Defines the line style for the scale on the chart. If this is unset
|
88
|
+
# (+nil+), there will be no horizontal marks across the chart for the
|
89
|
+
# steps of the scale.
|
90
|
+
attr_accessor :style
|
91
|
+
# Shows the scale labels if +true+.
|
92
|
+
attr_accessor :show_labels
|
93
|
+
# Defines the label options.
|
94
|
+
attr_accessor :label
|
95
|
+
end
|
96
|
+
|
97
|
+
# This is any line that will be drawn; this is a combination of the line
|
98
|
+
# style (which must be a PDF::Writer::StrokeStyle object) and a color.
|
99
|
+
class Marker
|
100
|
+
def initialize
|
101
|
+
yield self if block_given?
|
102
|
+
end
|
103
|
+
|
104
|
+
# The stroke style of the marker.
|
105
|
+
attr_accessor :style
|
106
|
+
# The stroke color of the marker.
|
107
|
+
attr_accessor :color
|
108
|
+
end
|
109
|
+
|
110
|
+
def initialize
|
111
|
+
@data = []
|
112
|
+
|
113
|
+
@scale = Scale.new do |scale|
|
114
|
+
scale.range = 0..6
|
115
|
+
scale.step = 1
|
116
|
+
scale.style = PDF::Writer::StrokeStyle.new(0.25)
|
117
|
+
scale.show_labels = false
|
118
|
+
scale.label = Label.new do |label|
|
119
|
+
label.text_size = 8
|
120
|
+
label.text_color = Color::Black
|
121
|
+
label.pad = 2
|
122
|
+
label.decimal_precision = 1
|
123
|
+
end
|
124
|
+
end
|
125
|
+
@leading_gap = 10
|
126
|
+
@show_labels = true
|
127
|
+
@label = Label.new do |label|
|
128
|
+
label.height = 25
|
129
|
+
label.background_color = Color::Black
|
130
|
+
label.text_color = Color::White
|
131
|
+
label.text_size = 12
|
132
|
+
end
|
133
|
+
|
134
|
+
@outer_borders = Marker.new do |marker|
|
135
|
+
marker.style = PDF::Writer::StrokeStyle.new(1.5)
|
136
|
+
marker.color = Color::Black
|
137
|
+
end
|
138
|
+
@inner_borders = nil
|
139
|
+
|
140
|
+
@dot = Marker.new do |marker|
|
141
|
+
marker.style = PDF::Writer::StrokeStyle.new(5)
|
142
|
+
marker.color = Color::Black
|
143
|
+
end
|
144
|
+
@bar = Marker.new do |marker|
|
145
|
+
marker.style = PDF::Writer::StrokeStyle.new(0.5)
|
146
|
+
marker.color = Color::Black
|
147
|
+
end
|
148
|
+
@upper_crossbar = Marker.new do |marker|
|
149
|
+
marker.style = PDF::Writer::StrokeStyle.new(1)
|
150
|
+
marker.color = Color::Black
|
151
|
+
end
|
152
|
+
@lower_crossbar = Marker.new do |marker|
|
153
|
+
marker.style = PDF::Writer::StrokeStyle.new(1)
|
154
|
+
marker.color = Color::Black
|
155
|
+
end
|
156
|
+
|
157
|
+
@height = 200
|
158
|
+
@maximum_width = 500
|
159
|
+
@datapoint_width = 35
|
160
|
+
|
161
|
+
yield self if block_given?
|
162
|
+
end
|
163
|
+
|
164
|
+
# The data used to generate the standard deviation chart. This is an
|
165
|
+
# array of DataPoint objects, each containing a +label+, an +average+,
|
166
|
+
# and the +stddev+ (standard deviation) from that average.
|
167
|
+
attr_reader :data
|
168
|
+
# The scale of the chart. All values must be within this range. This
|
169
|
+
# will be a Scale object. It defaults to a scale of 0..6 with a step of
|
170
|
+
# 1.
|
171
|
+
attr_accessor :scale
|
172
|
+
|
173
|
+
# The minimum gap between the chart and the bottom of the page, in
|
174
|
+
# PDF user units.
|
175
|
+
attr_accessor :leading_gap
|
176
|
+
|
177
|
+
# This will be +true+ if labels are to be displayed.
|
178
|
+
attr_accessor :show_labels
|
179
|
+
# The label style of the labels if they are displayed. This must be a
|
180
|
+
# PDF::Charts::StdDev::Label object.
|
181
|
+
attr_accessor :label
|
182
|
+
|
183
|
+
# The inner border style. If +nil+, no inner borders are drawn. This is
|
184
|
+
# a PDF::Charts::StdDev::Marker object.
|
185
|
+
attr_accessor :inner_borders
|
186
|
+
# The outer border style. If +nil+, no inner borders are drawn. This is
|
187
|
+
# a PDF::Charts::StdDev::Marker object.
|
188
|
+
attr_accessor :outer_borders
|
189
|
+
|
190
|
+
# The dot marker. A filled circle will be drawn with this information.
|
191
|
+
# If +nil+, the dot will not be drawn. This is a
|
192
|
+
# PDF::Charts::StdDev::Marker object.
|
193
|
+
attr_accessor :dot
|
194
|
+
# The standard deviation bar. A line will be drawn through the dot
|
195
|
+
# marker (if drawn) from the upper to lower standard deviation.
|
196
|
+
# If +nil+, the line will not be drawn. This is a
|
197
|
+
# PDF::Charts::StdDev::Marker object.
|
198
|
+
attr_accessor :bar
|
199
|
+
# The upper crossbar. A line will be drawn across the top of the
|
200
|
+
# standard deviation bar to the width of the dot marker. If #dot is
|
201
|
+
# +nil+, then the line will be twice as wide as it is thick. If +nil+,
|
202
|
+
# the upper crossbar will not be drawn. This is a
|
203
|
+
# PDF::Charts::StdDev::Marker object.
|
204
|
+
attr_accessor :upper_crossbar
|
205
|
+
# The lower crossbar. A line will be drawn across the bottom of the
|
206
|
+
# standard deviation bar to the width of the dot marker. If #dot is
|
207
|
+
# +nil+, then the line will be twice as wide as it is thick. If +nil+,
|
208
|
+
# the lower crossbar will not be drawn. This is a
|
209
|
+
# PDF::Charts::StdDev::Marker object.
|
210
|
+
attr_accessor :lower_crossbar
|
211
|
+
|
212
|
+
# The height of the chart in PDF user units. Default 200 units.
|
213
|
+
attr_accessor :height
|
214
|
+
# The maximum width of the chart in PDF user units. Default 500 units.
|
215
|
+
attr_accessor :maximum_width
|
216
|
+
# The width of a single datapoint.
|
217
|
+
attr_accessor :datapoint_width
|
218
|
+
|
219
|
+
# Draw the standard deviation chart on the supplied PDF document.
|
220
|
+
def render_on(pdf)
|
221
|
+
raise TypeError, PDF::Writer::Lang[:charts_stddev_data_empty] if @data.empty?
|
222
|
+
data = @data.dup
|
223
|
+
leftover_data = nil
|
224
|
+
|
225
|
+
loop do
|
226
|
+
# Set up the scale information.
|
227
|
+
scale = []
|
228
|
+
|
229
|
+
(@scale.first + @scale.step).step(@scale.last, @scale.step) do |ii|
|
230
|
+
scale << "%01.#{@scale.label.decimal_precision}f" % ii
|
231
|
+
end
|
232
|
+
|
233
|
+
scales = PDF::Writer::OHash.new
|
234
|
+
scale.each_with_index do |gg, ii|
|
235
|
+
scales[ii] = OpenStruct.new
|
236
|
+
scales[ii].value = gg
|
237
|
+
end
|
238
|
+
|
239
|
+
# Add information about the scales' locations to the scales
|
240
|
+
# hash. Note that the count is one smaller than it should be, so we're
|
241
|
+
# increasing it. The first scale is the bottom of the chart.
|
242
|
+
scale_count = scale.size + 1
|
243
|
+
|
244
|
+
label_height_adjuster = 0
|
245
|
+
label_height_adjuster = @label.height if @show_labels
|
246
|
+
|
247
|
+
chart_area_height = @height - label_height_adjuster
|
248
|
+
scale_height = chart_area_height / scale_count.to_f
|
249
|
+
|
250
|
+
scales.each_key do |index|
|
251
|
+
this_height = scale_height * (index + 1) + @label.height
|
252
|
+
scales[index].line_height = this_height
|
253
|
+
if @scale.show_labels
|
254
|
+
scales[index].label_height = this_height -
|
255
|
+
(@scale.label.text_size / 3.0)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
# How many sections do we need in this chart, and how wide will it
|
260
|
+
# need to be?
|
261
|
+
chunk_width = @datapoint_width
|
262
|
+
num_chunks = data.size
|
263
|
+
widest_scale_label = 0
|
264
|
+
|
265
|
+
if @scale.show_labels
|
266
|
+
scales.each_value do |scale|
|
267
|
+
this_width = pdf.text_width(@scale.label.text_size, scale.value)
|
268
|
+
widest_scale_label = this_width if this_width > widest_scale_label
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
chart_width = chunk_width * num_chunks
|
273
|
+
total_width = chart_width + widest_scale_label + @scale.label.pad
|
274
|
+
|
275
|
+
# What happens if the projected width of the chart is too big?
|
276
|
+
# Figure out how to break the chart in pieces.
|
277
|
+
if total_width > @maximum_width
|
278
|
+
max_column_count = 0
|
279
|
+
base_width = widest_scale_label + @scale.label.pad
|
280
|
+
(1..(num_chunks + 1)).each do |ii|
|
281
|
+
if (base_width + (ii * chunk_width)) > @maximum_width
|
282
|
+
break
|
283
|
+
else
|
284
|
+
max_column_count += 1
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
leftover_data = data.slice!(max_column_count, -1)
|
289
|
+
|
290
|
+
num_chunks = data.size
|
291
|
+
chart_width = chunk_width * num_chunks
|
292
|
+
total_width = chart_width + widest_scale_label + @scale.label.pad
|
293
|
+
end
|
294
|
+
|
295
|
+
chart_y = pdf.y - @height + @leading_gap
|
296
|
+
chart_y += (@outer_borders.style.width * 2.0) if @outer_borders
|
297
|
+
|
298
|
+
if chart_y < pdf.bottom_margin
|
299
|
+
pdf.start_new_page
|
300
|
+
chart_y = pdf.y - @height
|
301
|
+
chart_y += (@outer_borders.style.width * 2.0) if @outer_borders
|
302
|
+
end
|
303
|
+
|
304
|
+
chart_x = pdf.absolute_x_middle - (total_width / 2.0) + widest_scale_label
|
305
|
+
|
306
|
+
# Add labels, if needed.
|
307
|
+
if @show_labels
|
308
|
+
pdf.save_state
|
309
|
+
pdf.fill_color! @label.background_color
|
310
|
+
# Draw a rectangle for each label
|
311
|
+
num_chunks.times do |ii|
|
312
|
+
this_x = chart_x + ii * chunk_width
|
313
|
+
pdf.rectangle(this_x, chart_y, chunk_width, @label.height).fill
|
314
|
+
end
|
315
|
+
|
316
|
+
# Add a border above the label rectangle.
|
317
|
+
if @outer_borders
|
318
|
+
pdf.stroke_style! @outer_borders.style
|
319
|
+
pdf.line(chart_x, chart_y + @label.height, chart_x + chart_width, chart_y + @label.height).stroke
|
320
|
+
end
|
321
|
+
pdf.fill_color! @label.text_color
|
322
|
+
|
323
|
+
data.each_with_index do |datum, ii|
|
324
|
+
label = datum.label.to_s
|
325
|
+
label_width = pdf.text_width(@label.text_size, label)
|
326
|
+
this_x = chart_x + (ii * chunk_width) + (chunk_width / 2.0) - (label_width / 2.0)
|
327
|
+
this_y = chart_y + (@label.height / 2.0) - (@label.text_size / 3.0)
|
328
|
+
pdf.add_text(this_x, this_y, @label.text_size, label)
|
329
|
+
end
|
330
|
+
pdf.restore_state
|
331
|
+
end
|
332
|
+
|
333
|
+
if @inner_borders
|
334
|
+
pdf.save_state
|
335
|
+
pdf.stroke_color! @inner_borders.color
|
336
|
+
pdf.stroke_style! @inner_borders.style
|
337
|
+
(num_chunks - 1).times do |ii|
|
338
|
+
this_x = chart_x + (ii * chunk_width) + chunk_width
|
339
|
+
pdf.line(this_x, chart_y, this_x, chart_y + @height).stroke
|
340
|
+
end
|
341
|
+
pdf.restore_state
|
342
|
+
end
|
343
|
+
|
344
|
+
pdf.save_state
|
345
|
+
if @outer_borders
|
346
|
+
pdf.stroke_color! @outer_borders.color
|
347
|
+
pdf.stroke_style! @outer_borders.style
|
348
|
+
pdf.rectangle(chart_x, chart_y, chart_width, @height).stroke
|
349
|
+
end
|
350
|
+
|
351
|
+
if @scale.style
|
352
|
+
pdf.save_state
|
353
|
+
pdf.stroke_style! @scale.style
|
354
|
+
scales.each_value do |scale|
|
355
|
+
this_y = chart_y + scale.line_height
|
356
|
+
pdf.line(chart_x, this_y, chart_x + chart_width, this_y).stroke
|
357
|
+
end
|
358
|
+
pdf.restore_state
|
359
|
+
end
|
360
|
+
|
361
|
+
if @scale.show_labels
|
362
|
+
pdf.save_state
|
363
|
+
scales.each_value do |scale|
|
364
|
+
this_y = chart_y + scale.label_height
|
365
|
+
label_width = pdf.text_width(@scale.label.text_size, scale.value)
|
366
|
+
this_x = chart_x - label_width - @scale.label.pad
|
367
|
+
pdf.fill_color! @scale.label.text_color
|
368
|
+
pdf.add_text(this_x, this_y, @scale.label.text_size, scale.value)
|
369
|
+
end
|
370
|
+
pdf.restore_state
|
371
|
+
end
|
372
|
+
|
373
|
+
data.each_with_index do |datum, ii|
|
374
|
+
avg_height = datum.average * scale_height
|
375
|
+
stddev_height = datum.stddev * scale_height
|
376
|
+
this_y = chart_y + label_height_adjuster + avg_height
|
377
|
+
this_x = chart_x + (ii * chunk_width) + (chunk_width / 2.0)
|
378
|
+
line_top_y = this_y + (stddev_height / 2.0)
|
379
|
+
line_bot_y = this_y - (stddev_height / 2.0)
|
380
|
+
|
381
|
+
# Plot the dot
|
382
|
+
if @dot
|
383
|
+
pdf.stroke_color! @dot.color
|
384
|
+
pdf.stroke_style! @dot.style
|
385
|
+
pdf.circle_at(this_x, this_y, (@dot.style.width / 2.0)).fill
|
386
|
+
end
|
387
|
+
|
388
|
+
# Plot the bar
|
389
|
+
if @bar
|
390
|
+
pdf.stroke_color! @bar.color
|
391
|
+
pdf.stroke_style! @bar.style
|
392
|
+
pdf.line(this_x, line_top_y, this_x, line_bot_y).stroke
|
393
|
+
end
|
394
|
+
|
395
|
+
# Plot the crossbars
|
396
|
+
if @upper_crossbar
|
397
|
+
if @dot
|
398
|
+
cb_width = @dot.style.width
|
399
|
+
else
|
400
|
+
cb_width = @upper_crossbar.style.width
|
401
|
+
end
|
402
|
+
pdf.stroke_color! @upper_crossbar.color
|
403
|
+
pdf.stroke_style! @upper_crossbar.style
|
404
|
+
pdf.line(this_x - cb_width, line_top_y, this_x + cb_width, line_top_y).stroke
|
405
|
+
end
|
406
|
+
if @lower_crossbar
|
407
|
+
if @dot
|
408
|
+
cb_width = @dot.style.width
|
409
|
+
else
|
410
|
+
cb_width = @lower_crossbar.style.width
|
411
|
+
end
|
412
|
+
pdf.stroke_color! @lower_crossbar.color
|
413
|
+
pdf.stroke_style! @lower_crossbar.style
|
414
|
+
|
415
|
+
pdf.line(this_x - cb_width, line_bot_y, this_x + cb_width, line_bot_y).stroke
|
416
|
+
end
|
417
|
+
end
|
418
|
+
|
419
|
+
pdf.restore_state
|
420
|
+
|
421
|
+
pdf.y = chart_y
|
422
|
+
|
423
|
+
break if leftover_data.nil?
|
424
|
+
|
425
|
+
data = leftover_data
|
426
|
+
leftover_data = nil
|
427
|
+
end
|
428
|
+
|
429
|
+
pdf.y
|
430
|
+
end
|
431
|
+
end
|