taskjuggler 3.1.0 → 3.2.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.
Files changed (410) hide show
  1. data/CHANGELOG +44 -0
  2. data/bin/tj3webd +4 -0
  3. data/data/css/tjreport.css +14 -5
  4. data/data/tjp.vim +22 -7
  5. data/examples/Fedora-20/reports.tji +2 -4
  6. data/examples/Scrum/Product Burndown.csv +26 -0
  7. data/examples/Scrum/Sprint 1 Burndown.csv +26 -0
  8. data/examples/Scrum/Sprint 2 Burndown.csv +26 -0
  9. data/examples/Scrum/Sprint 3 Burndown.csv +26 -0
  10. data/examples/Scrum/scrum.tjp +141 -0
  11. data/examples/Tutorial/tutorial.tjp +13 -7
  12. data/lib/taskjuggler/Attributes.rb +2 -3
  13. data/lib/taskjuggler/HTMLDocument.rb +25 -18
  14. data/lib/taskjuggler/Journal.rb +85 -65
  15. data/lib/taskjuggler/KeywordDocumentation.rb +25 -13
  16. data/lib/taskjuggler/LeaveList.rb +1 -1
  17. data/lib/taskjuggler/Limits.rb +3 -5
  18. data/lib/taskjuggler/MessageHandler.rb +173 -19
  19. data/lib/taskjuggler/Painter.rb +75 -0
  20. data/lib/taskjuggler/Painter/BasicShapes.rb +76 -0
  21. data/lib/taskjuggler/Painter/Color.rb +273 -0
  22. data/lib/taskjuggler/Painter/Element.rb +56 -0
  23. data/lib/taskjuggler/Painter/FontData.rb +221 -0
  24. data/lib/taskjuggler/Painter/FontMetrics.rb +125 -0
  25. data/lib/taskjuggler/Painter/FontMetricsData.rb +151 -0
  26. data/lib/taskjuggler/Painter/Group.rb +77 -0
  27. data/lib/taskjuggler/Painter/Points.rb +47 -0
  28. data/lib/taskjuggler/Painter/Primitives.rb +100 -0
  29. data/lib/taskjuggler/Painter/SVGSupport.rb +36 -0
  30. data/lib/taskjuggler/Painter/Text.rb +36 -0
  31. data/lib/taskjuggler/Project.rb +46 -29
  32. data/lib/taskjuggler/ProjectFileParser.rb +24 -22
  33. data/lib/taskjuggler/ProjectFileScanner.rb +2 -2
  34. data/lib/taskjuggler/PropertyTreeNode.rb +26 -34
  35. data/lib/taskjuggler/Query.rb +8 -5
  36. data/lib/taskjuggler/RealFormat.rb +3 -0
  37. data/lib/taskjuggler/Resource.rb +3 -5
  38. data/lib/taskjuggler/ResourceScenario.rb +19 -7
  39. data/lib/taskjuggler/RichText.rb +4 -6
  40. data/lib/taskjuggler/RichText/FunctionExample.rb +1 -1
  41. data/lib/taskjuggler/RichText/FunctionHandler.rb +5 -6
  42. data/lib/taskjuggler/RichText/Parser.rb +4 -6
  43. data/lib/taskjuggler/RichText/RTFNavigator.rb +1 -1
  44. data/lib/taskjuggler/RichText/RTFQuery.rb +2 -3
  45. data/lib/taskjuggler/RichText/RTFReport.rb +1 -1
  46. data/lib/taskjuggler/RichText/RTFReportLink.rb +1 -2
  47. data/lib/taskjuggler/RichText/RTFWithQuerySupport.rb +1 -1
  48. data/lib/taskjuggler/RichText/Scanner.rb +6 -6
  49. data/lib/taskjuggler/RichText/Snip.rb +1 -2
  50. data/lib/taskjuggler/RuntimeConfig.rb +9 -6
  51. data/lib/taskjuggler/ScenarioData.rb +4 -3
  52. data/lib/taskjuggler/Scoreboard.rb +6 -0
  53. data/lib/taskjuggler/SheetHandlerBase.rb +25 -8
  54. data/lib/taskjuggler/SimpleQueryExpander.rb +14 -5
  55. data/lib/taskjuggler/SyntaxReference.rb +1 -2
  56. data/lib/taskjuggler/TableColumnSorter.rb +84 -0
  57. data/lib/taskjuggler/Task.rb +3 -5
  58. data/lib/taskjuggler/TaskJuggler.rb +36 -29
  59. data/lib/taskjuggler/TaskScenario.rb +154 -66
  60. data/lib/taskjuggler/TextParser.rb +24 -17
  61. data/lib/taskjuggler/TextParser/Scanner.rb +16 -11
  62. data/lib/taskjuggler/TextParser/SourceFileInfo.rb +20 -15
  63. data/lib/taskjuggler/TimeSheets.rb +6 -12
  64. data/lib/taskjuggler/Tj3AppBase.rb +35 -16
  65. data/lib/taskjuggler/Tj3Config.rb +1 -1
  66. data/lib/taskjuggler/TjpSyntaxRules.rb +239 -49
  67. data/lib/taskjuggler/XMLElement.rb +9 -2
  68. data/lib/taskjuggler/apps/Tj3.rb +43 -37
  69. data/lib/taskjuggler/apps/Tj3Client.rb +62 -112
  70. data/lib/taskjuggler/apps/Tj3Daemon.rb +66 -29
  71. data/lib/taskjuggler/apps/Tj3Man.rb +5 -5
  72. data/lib/taskjuggler/apps/Tj3SsReceiver.rb +10 -13
  73. data/lib/taskjuggler/apps/Tj3SsSender.rb +13 -16
  74. data/lib/taskjuggler/apps/Tj3TsReceiver.rb +10 -13
  75. data/lib/taskjuggler/apps/Tj3TsSender.rb +12 -15
  76. data/lib/taskjuggler/apps/Tj3TsSummary.rb +12 -15
  77. data/lib/taskjuggler/apps/Tj3WebD.rb +99 -0
  78. data/lib/taskjuggler/daemon/Daemon.rb +50 -10
  79. data/lib/taskjuggler/daemon/DaemonConnector.rb +127 -0
  80. data/lib/taskjuggler/daemon/ProcessIntercom.rb +36 -21
  81. data/lib/taskjuggler/daemon/ProjectBroker.rb +122 -112
  82. data/lib/taskjuggler/daemon/ProjectServer.rb +78 -46
  83. data/lib/taskjuggler/daemon/ReportServer.rb +52 -28
  84. data/lib/taskjuggler/daemon/ReportServlet.rb +92 -21
  85. data/lib/taskjuggler/daemon/WebServer.rb +75 -22
  86. data/lib/taskjuggler/daemon/WelcomePage.rb +1 -0
  87. data/lib/taskjuggler/reports/AccountListRE.rb +3 -3
  88. data/lib/taskjuggler/reports/CSVFile.rb +9 -2
  89. data/lib/taskjuggler/reports/ChartPlotter.rb +453 -0
  90. data/lib/taskjuggler/reports/Navigator.rb +1 -0
  91. data/lib/taskjuggler/reports/NikuReport.rb +4 -4
  92. data/lib/taskjuggler/reports/Report.rb +6 -18
  93. data/lib/taskjuggler/reports/ReportBase.rb +9 -9
  94. data/lib/taskjuggler/reports/ReportContext.rb +2 -2
  95. data/lib/taskjuggler/reports/StatusSheetReport.rb +6 -6
  96. data/lib/taskjuggler/reports/TableReport.rb +24 -15
  97. data/lib/taskjuggler/reports/TimeSheetReport.rb +5 -5
  98. data/lib/taskjuggler/reports/TraceReport.rb +251 -0
  99. data/lib/tj3webd.rb +17 -0
  100. data/manual/Day_To_Day_Juggling +10 -3
  101. data/manual/Installation +38 -19
  102. data/manual/Software +25 -19
  103. data/manual/Tutorial +119 -110
  104. data/manual/html/Day_To_Day_Juggling.html +7 -5
  105. data/manual/html/Getting_Started.html +4 -4
  106. data/manual/html/How_To_Contribute.html +4 -4
  107. data/manual/html/Installation.html +19 -11
  108. data/manual/html/Intro.html +4 -4
  109. data/manual/html/Reporting_Bugs.html +4 -4
  110. data/manual/html/Rich_Text_Attributes.html +4 -4
  111. data/manual/html/Software.html +15 -11
  112. data/manual/html/TaskJuggler_2x_Migration.html +4 -4
  113. data/manual/html/TaskJuggler_Internals.html +4 -4
  114. data/manual/html/The_TaskJuggler_Syntax.html +4 -4
  115. data/manual/html/Tutorial.html +41 -32
  116. data/manual/html/account.html +4 -4
  117. data/manual/html/account.task.html +4 -4
  118. data/manual/html/accountprefix.html +4 -4
  119. data/manual/html/accountreport.html +27 -9
  120. data/manual/html/accountroot.html +5 -5
  121. data/manual/html/active.html +4 -4
  122. data/manual/html/adopt.task.html +4 -4
  123. data/manual/html/aggregate.html +4 -4
  124. data/manual/html/alert.html +4 -4
  125. data/manual/html/alertlevels.html +4 -4
  126. data/manual/html/allocate.html +5 -5
  127. data/manual/html/alphabet.html +4 -4
  128. data/manual/html/alternative.html +4 -4
  129. data/manual/html/author.html +4 -4
  130. data/manual/html/balance.html +5 -5
  131. data/manual/html/booking.resource.html +4 -4
  132. data/manual/html/booking.task.html +4 -4
  133. data/manual/html/caption.html +5 -5
  134. data/manual/html/cellcolor.column.html +43 -8
  135. data/manual/html/celltext.column.html +4 -4
  136. data/manual/html/center.html +5 -5
  137. data/manual/html/charge.html +4 -4
  138. data/manual/html/chargeset.html +4 -4
  139. data/manual/html/columnid.html +27 -15
  140. data/manual/html/columns.html +5 -5
  141. data/manual/html/complete.html +4 -4
  142. data/manual/html/copyright.html +4 -4
  143. data/manual/html/credits.html +4 -4
  144. data/manual/html/css/tjreport.css +14 -5
  145. data/manual/html/currency.html +4 -4
  146. data/manual/html/currencyformat.html +5 -5
  147. data/manual/html/dailymax.html +5 -5
  148. data/manual/html/dailymin.html +5 -5
  149. data/manual/html/dailyworkinghours.html +4 -4
  150. data/manual/html/date.extend.html +4 -4
  151. data/manual/html/date.html +5 -5
  152. data/manual/html/definitions.html +4 -4
  153. data/manual/html/depends.html +4 -4
  154. data/manual/html/details.html +4 -4
  155. data/manual/html/disabled.html +4 -4
  156. data/manual/html/duration.html +4 -4
  157. data/manual/html/efficiency.html +4 -4
  158. data/manual/html/effort.html +4 -4
  159. data/manual/html/email.html +4 -4
  160. data/manual/html/enabled.html +4 -4
  161. data/manual/html/end.column.html +4 -4
  162. data/manual/html/end.html +4 -4
  163. data/manual/html/end.limit.html +4 -4
  164. data/manual/html/end.report.html +5 -5
  165. data/manual/html/end.timesheet.html +4 -4
  166. data/manual/html/endcredit.html +4 -4
  167. data/manual/html/epilog.html +5 -5
  168. data/manual/html/export.html +4 -4
  169. data/manual/html/extend.html +4 -4
  170. data/manual/html/fail.html +43 -8
  171. data/manual/html/fdl.html +4 -4
  172. data/manual/html/flags.account.html +4 -4
  173. data/manual/html/flags.html +4 -4
  174. data/manual/html/flags.journalentry.html +4 -4
  175. data/manual/html/flags.report.html +5 -5
  176. data/manual/html/flags.resource.html +4 -4
  177. data/manual/html/flags.statussheet.html +4 -4
  178. data/manual/html/flags.task.html +4 -4
  179. data/manual/html/flags.timesheet.html +4 -4
  180. data/manual/html/fontcolor.column.html +43 -8
  181. data/manual/html/footer.html +5 -5
  182. data/manual/html/formats.html +5 -5
  183. data/manual/html/functions.html +4 -4
  184. data/manual/html/gapduration.html +4 -4
  185. data/manual/html/gaplength.html +4 -4
  186. data/manual/html/halign.center.html +4 -4
  187. data/manual/html/halign.column.html +43 -8
  188. data/manual/html/halign.left.html +4 -4
  189. data/manual/html/halign.right.html +4 -4
  190. data/manual/html/hasalert.html +4 -4
  191. data/manual/html/header.html +5 -5
  192. data/manual/html/headline.html +7 -7
  193. data/manual/html/height.html +72 -0
  194. data/manual/html/hideaccount.html +46 -11
  195. data/manual/html/hidejournalentry.html +5 -5
  196. data/manual/html/hidereport.html +43 -8
  197. data/manual/html/hideresource.html +44 -9
  198. data/manual/html/hidetask.html +44 -9
  199. data/manual/html/icalreport.html +4 -4
  200. data/manual/html/include.macro.html +4 -4
  201. data/manual/html/include.project.html +4 -4
  202. data/manual/html/include.properties.html +4 -4
  203. data/manual/html/index.html +2 -1
  204. data/manual/html/inherit.extend.html +4 -4
  205. data/manual/html/interval1.html +4 -4
  206. data/manual/html/interval2.html +4 -4
  207. data/manual/html/interval3.html +4 -4
  208. data/manual/html/interval4.html +4 -4
  209. data/manual/html/isactive.html +4 -4
  210. data/manual/html/ischildof.html +4 -4
  211. data/manual/html/isdependencyof.html +4 -4
  212. data/manual/html/isdutyof.html +4 -4
  213. data/manual/html/isfeatureof.html +4 -4
  214. data/manual/html/isleaf.html +4 -4
  215. data/manual/html/ismilestone.html +4 -4
  216. data/manual/html/isongoing.html +4 -4
  217. data/manual/html/isresource.html +4 -4
  218. data/manual/html/isresponsibilityof.html +4 -4
  219. data/manual/html/istask.html +4 -4
  220. data/manual/html/journalattributes.html +11 -7
  221. data/manual/html/journalentry.html +4 -4
  222. data/manual/html/journalmode.html +5 -5
  223. data/manual/html/leaveallowance.html +5 -5
  224. data/manual/html/leaves.html +5 -6
  225. data/manual/html/left.html +5 -5
  226. data/manual/html/length.html +4 -4
  227. data/manual/html/limits.allocate.html +4 -4
  228. data/manual/html/limits.html +4 -4
  229. data/manual/html/limits.resource.html +4 -4
  230. data/manual/html/limits.task.html +4 -4
  231. data/manual/html/listitem.column.html +4 -4
  232. data/manual/html/listtype.column.html +4 -4
  233. data/manual/html/loadunit.html +5 -5
  234. data/manual/html/logicalexpression.html +8 -44
  235. data/manual/html/logicalflagexpression.html +4 -4
  236. data/manual/html/macro.html +4 -4
  237. data/manual/html/managers.html +4 -4
  238. data/manual/html/mandatory.html +4 -4
  239. data/manual/html/maxend.html +4 -4
  240. data/manual/html/maximum.html +5 -5
  241. data/manual/html/maxstart.html +4 -4
  242. data/manual/html/milestone.html +4 -4
  243. data/manual/html/minend.html +4 -4
  244. data/manual/html/minimum.html +5 -5
  245. data/manual/html/minstart.html +4 -4
  246. data/manual/html/monthlymax.html +5 -5
  247. data/manual/html/monthlymin.html +5 -5
  248. data/manual/html/navbar.html +10 -4
  249. data/manual/html/navigator.html +4 -4
  250. data/manual/html/newtask.html +4 -4
  251. data/manual/html/nikureport.html +4 -4
  252. data/manual/html/note.task.html +4 -4
  253. data/manual/html/now.html +4 -4
  254. data/manual/html/numberformat.html +5 -5
  255. data/manual/html/onend.html +4 -4
  256. data/manual/html/onstart.html +4 -4
  257. data/manual/html/opennodes.html +5 -5
  258. data/manual/html/overtime.booking.html +4 -4
  259. data/manual/html/period.column.html +4 -4
  260. data/manual/html/period.limit.html +4 -4
  261. data/manual/html/period.report.html +5 -5
  262. data/manual/html/period.task.html +4 -4
  263. data/manual/html/persistent.html +4 -4
  264. data/manual/html/precedes.html +4 -4
  265. data/manual/html/priority.html +4 -4
  266. data/manual/html/priority.timesheet.html +4 -4
  267. data/manual/html/project.html +4 -4
  268. data/manual/html/projectid.html +4 -4
  269. data/manual/html/projectid.task.html +4 -4
  270. data/manual/html/projectids.html +4 -4
  271. data/manual/html/projection.html +5 -7
  272. data/manual/html/prolog.html +5 -5
  273. data/manual/html/properties.html +11 -5
  274. data/manual/html/purge.html +5 -5
  275. data/manual/html/rate.html +4 -4
  276. data/manual/html/rate.resource.html +4 -4
  277. data/manual/html/reference.extend.html +4 -4
  278. data/manual/html/remaining.html +4 -4
  279. data/manual/html/replace.html +4 -4
  280. data/manual/html/reportprefix.html +4 -4
  281. data/manual/html/resource.html +4 -10
  282. data/manual/html/resourceattributes.html +4 -4
  283. data/manual/html/resourceprefix.html +4 -4
  284. data/manual/html/resourcereport.html +28 -10
  285. data/manual/html/resourceroot.html +5 -5
  286. data/manual/html/resources.limit.html +4 -4
  287. data/manual/html/responsible.html +4 -4
  288. data/manual/html/richtext.extend.html +4 -4
  289. data/manual/html/right.html +5 -5
  290. data/manual/html/rollupaccount.html +44 -9
  291. data/manual/html/rollupresource.html +44 -9
  292. data/manual/html/rolluptask.html +44 -9
  293. data/manual/html/scale.column.html +4 -4
  294. data/manual/html/scenario.html +4 -22
  295. data/manual/html/scenario.ical.html +4 -4
  296. data/manual/html/scenarios.export.html +4 -4
  297. data/manual/html/scenarios.html +5 -5
  298. data/manual/html/scenariospecific.extend.html +4 -4
  299. data/manual/html/scheduled.html +4 -4
  300. data/manual/html/scheduling.html +4 -4
  301. data/manual/html/select.html +4 -4
  302. data/manual/html/selfcontained.html +5 -5
  303. data/manual/html/shift.allocate.html +4 -4
  304. data/manual/html/shift.html +4 -4
  305. data/manual/html/shift.resource.html +5 -5
  306. data/manual/html/shift.task.html +4 -4
  307. data/manual/html/shift.timesheet.html +4 -4
  308. data/manual/html/shifts.allocate.html +4 -4
  309. data/manual/html/shifts.resource.html +4 -4
  310. data/manual/html/shifts.task.html +4 -4
  311. data/manual/html/shorttimeformat.html +4 -4
  312. data/manual/html/sloppy.booking.html +4 -4
  313. data/manual/html/sloppy.projection.html +5 -5
  314. data/manual/html/sortaccounts.html +5 -5
  315. data/manual/html/sortjournalentries.html +5 -5
  316. data/manual/html/sortresources.html +5 -5
  317. data/manual/html/sorttasks.html +5 -5
  318. data/manual/html/start.column.html +4 -4
  319. data/manual/html/start.html +4 -4
  320. data/manual/html/start.limit.html +4 -4
  321. data/manual/html/start.report.html +5 -5
  322. data/manual/html/startcredit.html +4 -4
  323. data/manual/html/status.statussheet.html +4 -4
  324. data/manual/html/status.timesheet.html +4 -4
  325. data/manual/html/statussheet.html +4 -4
  326. data/manual/html/statussheetreport.html +4 -4
  327. data/manual/html/strict.projection.html +5 -5
  328. data/manual/html/summary.html +4 -4
  329. data/manual/html/supplement.html +4 -4
  330. data/manual/html/supplement.resource.html +4 -10
  331. data/manual/html/supplement.task.html +4 -28
  332. data/manual/html/tagfile.html +4 -4
  333. data/manual/html/task.html +4 -28
  334. data/manual/html/task.statussheet.html +4 -4
  335. data/manual/html/task.timesheet.html +4 -4
  336. data/manual/html/taskattributes.html +4 -4
  337. data/manual/html/taskprefix.html +4 -4
  338. data/manual/html/taskreport.html +28 -10
  339. data/manual/html/taskroot.html +5 -5
  340. data/manual/html/text.extend.html +4 -4
  341. data/manual/html/textreport.html +27 -9
  342. data/manual/html/timeformat.html +5 -5
  343. data/manual/html/timeoff.nikureport.html +4 -4
  344. data/manual/html/timesheet.html +4 -4
  345. data/manual/html/timesheetreport.html +23 -5
  346. data/manual/html/timezone.export.html +4 -4
  347. data/manual/html/timezone.html +4 -4
  348. data/manual/html/timezone.report.html +5 -5
  349. data/manual/html/timezone.shift.html +4 -4
  350. data/manual/html/timingresolution.html +4 -4
  351. data/manual/html/title.column.html +4 -4
  352. data/manual/html/title.html +5 -5
  353. data/manual/html/toc.html +207 -179
  354. data/manual/html/tooltip.column.html +45 -10
  355. data/manual/html/tracereport.html +405 -0
  356. data/manual/html/trackingscenario.html +6 -6
  357. data/manual/html/treelevel.html +4 -4
  358. data/manual/html/vacation.html +4 -4
  359. data/manual/html/vacation.resource.html +4 -4
  360. data/manual/html/vacation.shift.html +4 -4
  361. data/manual/html/warn.html +43 -8
  362. data/manual/html/weeklymax.html +5 -5
  363. data/manual/html/weeklymin.html +5 -5
  364. data/manual/html/weekstartsmonday.html +4 -4
  365. data/manual/html/weekstartssunday.html +6 -6
  366. data/manual/html/width.column.html +6 -6
  367. data/manual/html/width.html +72 -0
  368. data/manual/html/work.html +4 -4
  369. data/manual/html/workinghours.project.html +4 -4
  370. data/manual/html/workinghours.resource.html +4 -4
  371. data/manual/html/workinghours.shift.html +4 -4
  372. data/manual/html/yearlyworkingdays.html +4 -4
  373. data/spec/Color_spec.rb +60 -0
  374. data/spec/ProjectBroker_spec.rb +3 -2
  375. data/spec/StatusSheets_spec.rb +5 -4
  376. data/spec/TableColumnSorter_spec.rb +78 -0
  377. data/spec/TimeSheets_spec.rb +6 -2
  378. data/spec/Tj3Daemon_spec.rb +2 -2
  379. data/spec/TraceReport_spec.rb +117 -0
  380. data/taskjuggler.gemspec +1 -1
  381. data/test/MessageChecker.rb +3 -1
  382. data/test/ReferenceGenerator.rb +1 -1
  383. data/test/TestSuite/CSV-Reports/Leave.tjp +1 -1
  384. data/test/TestSuite/CSV-Reports/refs/resourcereport_with_tasks.csv +3 -0
  385. data/test/TestSuite/CSV-Reports/refs/taskcounter.csv +9 -0
  386. data/test/TestSuite/CSV-Reports/refs/taskreport_with_resources.csv +19 -16
  387. data/test/TestSuite/CSV-Reports/refs/weekly.csv +1 -0
  388. data/test/TestSuite/Export-Reports/refs/LogicalExpression.tjp +14 -2
  389. data/test/TestSuite/Export-Reports/refs/tutorial.tjp +98 -86
  390. data/test/TestSuite/Scheduler/Correct/Leaves.tjp +25 -0
  391. data/test/TestSuite/Syntax/Correct/Leave.tjp +1 -1
  392. data/test/TestSuite/Syntax/Correct/LogicalExpression.tjp +9 -1
  393. data/test/TestSuite/Syntax/Correct/TraceReport.tjp +10 -0
  394. data/test/TestSuite/Syntax/Correct/tutorial.tjp +10 -4
  395. data/test/test_CSV-Reports.rb +3 -3
  396. data/test/test_Export-Reports.rb +91 -86
  397. data/test/test_Journal.rb +15 -12
  398. data/test/test_Limits.rb +3 -3
  399. data/test/test_Project.rb +1 -2
  400. data/test/test_ProjectFileScanner.rb +1 -1
  401. data/test/test_PropertySet.rb +1 -1
  402. data/test/test_Query.rb +5 -6
  403. data/test/test_ReportGenerator.rb +15 -7
  404. data/test/test_RichText.rb +4 -3
  405. data/test/test_Scheduler.rb +19 -7
  406. data/test/test_ShiftAssignments.rb +2 -2
  407. data/test/test_SimpleQueryExpander.rb +29 -2
  408. data/test/test_Syntax.rb +14 -5
  409. metadata +49 -10
  410. data/lib/taskjuggler/LogFile.rb +0 -73
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby -w
2
+ # encoding: UTF-8
3
+ #
4
+ # = Line.rb -- The TaskJuggler III Project Management Software
5
+ #
6
+ # Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012
7
+ # by Chris Schlaeger <chris@linux.com>
8
+ #
9
+ # This program is free software; you can redistribute it and/or modify
10
+ # it under the terms of version 2 of the GNU General Public License as
11
+ # published by the Free Software Foundation.
12
+ #
13
+
14
+ require 'taskjuggler/Painter/SVGSupport'
15
+ require 'taskjuggler/Painter/Primitives'
16
+
17
+ class TaskJuggler
18
+
19
+ class Painter
20
+
21
+ # The base class for all drawable elements.
22
+ class Element
23
+
24
+ include SVGSupport
25
+ include Primitives
26
+
27
+ # Create a new Element. _type_ specifies the type of the element.
28
+ # _attrs_ is a list of the supported attributes. _values_ is a hash of
29
+ # the provided attributes.
30
+ def initialize(type, attrs, values)
31
+ @type = type
32
+ @attributes = attrs
33
+ @values = {}
34
+ @text = nil
35
+
36
+ values.each do |k, v|
37
+ unless @attributes.include?(k)
38
+ raise ArgumentError, "Unsupported attribute #{k}"
39
+ end
40
+ @values[k] = v
41
+ end
42
+ end
43
+
44
+ # Convert the Element into an XMLElement tree using SVG syntax.
45
+ def to_svg
46
+ el = XMLElement.new(@type, valuesToSVG)
47
+ el << XMLText.new(@text) if @text
48
+ el
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+
55
+ end
56
+
@@ -0,0 +1,221 @@
1
+
2
+ class TaskJuggler
3
+ class Painter
4
+ class FontMetrics
5
+ Font_LiberationSans_normal = Painter::FontMetricsData.new('LiberationSans', :normal, 24, 26.088,
6
+ @charWidth = {
7
+ ' ' => 6.648, '!' => 6.648, '"' => 8.496, '#' => 13.344,
8
+ '$' => 13.344, '%' => 21.336, '&' => 15.984, '\'' => 4.560,
9
+ '(' => 7.992, ')' => 7.992, '*' => 9.336, '+' => 13.992,
10
+ ',' => 6.648, '-' => 7.992, '.' => 6.648, '/' => 6.648,
11
+ '0' => 13.344, '1' => 13.344, '2' => 13.344, '3' => 13.344,
12
+ '4' => 13.344, '5' => 13.344, '6' => 13.344, '7' => 13.344,
13
+ '8' => 13.344, '9' => 13.344, ':' => 6.648, ';' => 6.648,
14
+ '<' => 13.992, '=' => 13.992, '>' => 13.992, '?' => 13.344,
15
+ '@' => 24.360, 'A' => 15.984, 'B' => 15.984, 'C' => 17.328,
16
+ 'D' => 17.328, 'E' => 15.984, 'F' => 14.640, 'G' => 18.648,
17
+ 'H' => 17.328, 'I' => 6.648, 'J' => 12.000, 'K' => 15.984,
18
+ 'L' => 13.344, 'M' => 19.992, 'N' => 17.328, 'O' => 18.648,
19
+ 'P' => 15.984, 'Q' => 18.648, 'R' => 17.328, 'S' => 15.984,
20
+ 'T' => 14.640, 'U' => 17.328, 'V' => 15.984, 'W' => 22.632,
21
+ 'X' => 15.984, 'Y' => 15.984, 'Z' => 14.640, '[' => 6.648,
22
+ '\\' => 6.648, ']' => 6.648, '^' => 11.256, '_' => 13.344,
23
+ '`' => 7.992, 'a' => 13.344, 'b' => 13.344, 'c' => 12.000,
24
+ 'd' => 13.344, 'e' => 13.344, 'f' => 6.648, 'g' => 13.344,
25
+ 'h' => 13.344, 'i' => 5.328, 'j' => 5.328, 'k' => 12.000,
26
+ 'l' => 5.328, 'm' => 19.992, 'n' => 13.344, 'o' => 13.344,
27
+ 'p' => 13.344, 'q' => 13.344, 'r' => 7.992, 's' => 12.000,
28
+ 't' => 6.648, 'u' => 13.344, 'v' => 12.000, 'w' => 17.328,
29
+ 'x' => 12.000, 'y' => 12.000, 'z' => 12.000, '{' => 7.992,
30
+ '|' => 6.216, '}' => 7.992, '~' => 13.992,
31
+ },
32
+ @kerningDelta = {
33
+ ' A' => -1.324, ' T' => -0.434, ' Y' => -0.434, '11' => -1.781,
34
+ 'A ' => -1.324, 'AT' => -1.781, 'AV' => -1.781, 'AW' => -0.891,
35
+ 'AY' => -1.781, 'Av' => -0.434, 'Aw' => -0.434, 'Ay' => -0.434,
36
+ 'F,' => -2.660, 'F.' => -2.660, 'FA' => -1.324, 'L ' => -0.891,
37
+ 'LT' => -1.781, 'LV' => -1.781, 'LW' => -1.781, 'LY' => -1.781,
38
+ 'Ly' => -0.891, 'P ' => -0.434, 'P,' => -3.094, 'P.' => -3.094,
39
+ 'PA' => -1.781, 'RT' => -0.434, 'RV' => -0.434, 'RW' => -0.434,
40
+ 'RY' => -0.434, 'T ' => -0.434, 'T,' => -2.660, 'T-' => -1.324,
41
+ 'T.' => -2.660, 'T:' => -2.660, 'T;' => -2.660, 'TA' => -1.781,
42
+ 'TO' => -0.434, 'Ta' => -2.660, 'Tc' => -2.660, 'Te' => -2.660,
43
+ 'Ti' => -0.891, 'To' => -2.660, 'Tr' => -0.891, 'Ts' => -2.660,
44
+ 'Tu' => -0.891, 'Tw' => -1.324, 'Ty' => -1.324, 'V,' => -2.203,
45
+ 'V-' => -1.324, 'V.' => -2.203, 'V:' => -0.891, 'V;' => -0.891,
46
+ 'VA' => -1.781, 'Va' => -1.781, 'Ve' => -1.324, 'Vi' => -0.434,
47
+ 'Vo' => -1.324, 'Vr' => -0.891, 'Vu' => -0.891, 'Vy' => -0.891,
48
+ 'W,' => -1.324, 'W-' => -0.434, 'W.' => -1.324, 'W:' => -0.434,
49
+ 'W;' => -0.434, 'WA' => -0.891, 'Wa' => -0.891, 'We' => -0.434,
50
+ 'Wo' => -0.434, 'Wr' => -0.434, 'Wu' => -0.434, 'Wy' => -0.211,
51
+ 'Y ' => -0.434, 'Y,' => -3.094, 'Y-' => -2.203, 'Y.' => -3.094,
52
+ 'Y:' => -1.324, 'Y;' => -1.559, 'YA' => -1.781, 'Ya' => -1.781,
53
+ 'Ye' => -2.203, 'Yi' => -0.891, 'Yo' => -2.203, 'Yp' => -1.781,
54
+ 'Yq' => -2.203, 'Yu' => -1.324, 'Yv' => -1.324, 'ff' => -0.434,
55
+ 'r,' => -1.324, 'r.' => -1.324, 'v,' => -1.781, 'v.' => -1.781,
56
+ 'w,' => -1.324, 'w.' => -1.324, 'y,' => -1.781, 'y.' => -1.781,
57
+ }
58
+ )
59
+ Font_LiberationSans_italic = Painter::FontMetricsData.new('LiberationSans', :italic, 24, 26.016,
60
+ @charWidth = {
61
+ ' ' => 6.648, '!' => 6.648, '"' => 8.496, '#' => 13.344,
62
+ '$' => 13.344, '%' => 21.336, '&' => 15.984, '\'' => 4.560,
63
+ '(' => 7.992, ')' => 7.992, '*' => 9.336, '+' => 13.992,
64
+ ',' => 6.648, '-' => 7.992, '.' => 6.648, '/' => 6.648,
65
+ '0' => 13.344, '1' => 13.344, '2' => 13.344, '3' => 13.344,
66
+ '4' => 13.344, '5' => 13.344, '6' => 13.344, '7' => 13.344,
67
+ '8' => 13.344, '9' => 13.344, ':' => 6.648, ';' => 6.648,
68
+ '<' => 13.992, '=' => 13.992, '>' => 13.992, '?' => 13.344,
69
+ '@' => 24.360, 'A' => 15.984, 'B' => 15.984, 'C' => 17.328,
70
+ 'D' => 17.328, 'E' => 15.984, 'F' => 14.640, 'G' => 18.648,
71
+ 'H' => 17.328, 'I' => 6.648, 'J' => 12.000, 'K' => 15.984,
72
+ 'L' => 13.344, 'M' => 19.992, 'N' => 17.328, 'O' => 18.648,
73
+ 'P' => 15.984, 'Q' => 18.648, 'R' => 17.328, 'S' => 15.984,
74
+ 'T' => 14.640, 'U' => 17.328, 'V' => 15.984, 'W' => 22.632,
75
+ 'X' => 15.984, 'Y' => 15.984, 'Z' => 14.640, '[' => 6.648,
76
+ '\\' => 6.648, ']' => 6.648, '^' => 11.256, '_' => 13.344,
77
+ '`' => 7.992, 'a' => 13.344, 'b' => 13.344, 'c' => 12.000,
78
+ 'd' => 13.344, 'e' => 13.344, 'f' => 6.648, 'g' => 13.344,
79
+ 'h' => 13.344, 'i' => 5.328, 'j' => 5.328, 'k' => 12.000,
80
+ 'l' => 5.328, 'm' => 19.992, 'n' => 13.344, 'o' => 13.344,
81
+ 'p' => 13.344, 'q' => 13.344, 'r' => 7.992, 's' => 12.000,
82
+ 't' => 6.648, 'u' => 13.344, 'v' => 12.000, 'w' => 17.328,
83
+ 'x' => 12.000, 'y' => 12.000, 'z' => 12.000, '{' => 7.992,
84
+ '|' => 6.216, '}' => 7.992, '~' => 13.992,
85
+ },
86
+ @kerningDelta = {
87
+ ' A' => -0.891, ' Y' => -0.434, '11' => -1.781, 'A ' => -0.891,
88
+ 'AT' => -1.781, 'AV' => -1.324, 'AW' => -0.434, 'AY' => -1.781,
89
+ 'Av' => -0.434, 'Aw' => -0.434, 'Ay' => -0.211, 'F ' => -0.434,
90
+ 'F,' => -3.094, 'F.' => -3.094, 'FA' => -1.781, 'L ' => -0.434,
91
+ 'LT' => -1.781, 'LV' => -1.324, 'LW' => -0.891, 'LY' => -2.203,
92
+ 'Ly' => -0.434, 'P ' => -0.891, 'P,' => -3.094, 'P.' => -3.094,
93
+ 'PA' => -1.781, 'RT' => -0.434, 'RV' => -0.434, 'RW' => -0.434,
94
+ 'RY' => -0.891, 'T,' => -2.203, 'T-' => -2.203, 'T.' => -2.203,
95
+ 'T:' => -1.781, 'T;' => -1.781, 'TA' => -1.781, 'TO' => -0.434,
96
+ 'Ta' => -2.203, 'Tc' => -2.203, 'Te' => -2.203, 'Ti' => -0.211,
97
+ 'To' => -2.203, 'Tr' => -1.781, 'Ts' => -2.203, 'Tu' => -1.781,
98
+ 'Tw' => -1.781, 'Ty' => -1.781, 'V,' => -1.781, 'V-' => -0.891,
99
+ 'V.' => -1.781, 'V:' => -0.434, 'V;' => -0.434, 'VA' => -1.324,
100
+ 'Va' => -0.891, 'Ve' => -0.891, 'Vi' => -0.434, 'Vo' => -0.891,
101
+ 'Vr' => -0.434, 'Vu' => -0.434, 'Vy' => -0.434, 'W,' => -0.891,
102
+ 'W-' => -0.434, 'W.' => -0.891, 'WA' => -0.434, 'Wa' => -0.434,
103
+ 'We' => -0.434, 'Wi' => -0.211, 'Y ' => -0.434, 'Y,' => -2.203,
104
+ 'Y-' => -1.781, 'Y.' => -2.203, 'Y:' => -0.891, 'Y;' => -0.891,
105
+ 'YA' => -1.324, 'Ya' => -1.781, 'Ye' => -1.324, 'Yi' => -0.434,
106
+ 'Yo' => -1.324, 'Yp' => -1.324, 'Yq' => -1.324, 'Yu' => -0.891,
107
+ 'Yv' => -0.891, 'r,' => -1.324, 'r-' => -0.434, 'r.' => -0.891,
108
+ 'v,' => -1.781, 'v.' => -1.781, 'w,' => -1.324, 'w.' => -1.324,
109
+ 'y,' => -1.781, 'y.' => -1.781,
110
+ }
111
+ )
112
+ Font_LiberationSans_bold = Painter::FontMetricsData.new('LiberationSans', :bold, 24, 26.088,
113
+ @charWidth = {
114
+ ' ' => 6.648, '!' => 7.992, '"' => 11.376, '#' => 13.344,
115
+ '$' => 13.344, '%' => 21.336, '&' => 17.328, '\'' => 5.688,
116
+ '(' => 7.992, ')' => 7.992, '*' => 9.336, '+' => 13.992,
117
+ ',' => 6.648, '-' => 7.992, '.' => 6.648, '/' => 6.648,
118
+ '0' => 13.344, '1' => 13.344, '2' => 13.344, '3' => 13.344,
119
+ '4' => 13.344, '5' => 13.344, '6' => 13.344, '7' => 13.344,
120
+ '8' => 13.344, '9' => 13.344, ':' => 7.992, ';' => 7.992,
121
+ '<' => 13.992, '=' => 13.992, '>' => 13.992, '?' => 14.640,
122
+ '@' => 23.400, 'A' => 17.328, 'B' => 17.328, 'C' => 17.328,
123
+ 'D' => 17.328, 'E' => 15.984, 'F' => 14.640, 'G' => 18.648,
124
+ 'H' => 17.328, 'I' => 6.648, 'J' => 13.344, 'K' => 17.328,
125
+ 'L' => 14.640, 'M' => 19.992, 'N' => 17.328, 'O' => 18.648,
126
+ 'P' => 15.984, 'Q' => 18.648, 'R' => 17.328, 'S' => 15.984,
127
+ 'T' => 14.640, 'U' => 17.328, 'V' => 15.984, 'W' => 22.632,
128
+ 'X' => 15.984, 'Y' => 15.984, 'Z' => 14.640, '[' => 7.992,
129
+ '\\' => 6.648, ']' => 7.992, '^' => 13.992, '_' => 13.344,
130
+ '`' => 7.992, 'a' => 13.344, 'b' => 14.640, 'c' => 13.344,
131
+ 'd' => 14.640, 'e' => 13.344, 'f' => 7.992, 'g' => 14.640,
132
+ 'h' => 14.640, 'i' => 6.648, 'j' => 6.648, 'k' => 13.344,
133
+ 'l' => 6.648, 'm' => 21.336, 'n' => 14.640, 'o' => 14.640,
134
+ 'p' => 14.640, 'q' => 14.640, 'r' => 9.336, 's' => 13.344,
135
+ 't' => 7.992, 'u' => 14.640, 'v' => 13.344, 'w' => 18.648,
136
+ 'x' => 13.344, 'y' => 13.344, 'z' => 12.000, '{' => 9.336,
137
+ '|' => 6.696, '}' => 9.336, '~' => 13.992,
138
+ },
139
+ @kerningDelta = {
140
+ ' A' => -0.891, ' Y' => -0.434, '11' => -1.324, 'A ' => -0.891,
141
+ 'AT' => -1.781, 'AV' => -1.781, 'AW' => -1.324, 'AY' => -2.203,
142
+ 'Av' => -0.891, 'Aw' => -0.434, 'Ay' => -0.891, 'F,' => -2.660,
143
+ 'F.' => -2.660, 'FA' => -1.324, 'L ' => -0.434, 'LT' => -1.781,
144
+ 'LV' => -1.781, 'LW' => -1.324, 'LY' => -2.203, 'Ly' => -0.891,
145
+ 'P ' => -0.434, 'P,' => -3.094, 'P.' => -3.094, 'PA' => -1.781,
146
+ 'RV' => -0.434, 'RW' => -0.434, 'RY' => -0.891, 'T,' => -2.660,
147
+ 'T-' => -1.324, 'T.' => -2.660, 'T:' => -2.660, 'T;' => -2.660,
148
+ 'TA' => -1.781, 'TO' => -0.434, 'Ta' => -1.781, 'Tc' => -1.781,
149
+ 'Te' => -1.781, 'Ti' => -0.434, 'To' => -1.781, 'Tr' => -1.324,
150
+ 'Ts' => -1.781, 'Tu' => -1.781, 'Tw' => -1.781, 'Ty' => -1.781,
151
+ 'V,' => -2.203, 'V-' => -1.324, 'V.' => -2.203, 'V:' => -1.324,
152
+ 'V;' => -1.324, 'VA' => -1.781, 'Va' => -1.324, 'Ve' => -1.324,
153
+ 'Vi' => -0.434, 'Vo' => -1.781, 'Vr' => -1.324, 'Vu' => -0.891,
154
+ 'Vy' => -0.891, 'W,' => -1.324, 'W-' => -0.480, 'W.' => -1.324,
155
+ 'W:' => -0.434, 'W;' => -0.434, 'WA' => -1.324, 'Wa' => -0.891,
156
+ 'We' => -0.434, 'Wi' => -0.211, 'Wo' => -0.434, 'Wr' => -0.434,
157
+ 'Wu' => -0.434, 'Wy' => -0.434, 'Y ' => -0.434, 'Y,' => -2.660,
158
+ 'Y-' => -1.324, 'Y.' => -2.660, 'Y:' => -1.781, 'Y;' => -1.781,
159
+ 'YA' => -2.203, 'Ya' => -1.324, 'Ye' => -1.324, 'Yi' => -0.891,
160
+ 'Yo' => -1.781, 'Yp' => -1.324, 'Yq' => -1.781, 'Yu' => -1.324,
161
+ 'Yv' => -1.324, 'r,' => -1.324, 'r.' => -1.324, 'v,' => -1.781,
162
+ 'v.' => -1.781, 'w,' => -0.891, 'w.' => -0.891, 'y,' => -1.781,
163
+ 'y.' => -1.781,
164
+ }
165
+ )
166
+ Font_LiberationSans_bold_italic = Painter::FontMetricsData.new('LiberationSans', :bold_italic, 24, 26.088,
167
+ @charWidth = {
168
+ ' ' => 6.648, '!' => 7.992, '"' => 11.376, '#' => 13.344,
169
+ '$' => 13.344, '%' => 21.336, '&' => 17.328, '\'' => 5.688,
170
+ '(' => 7.992, ')' => 7.992, '*' => 9.336, '+' => 13.992,
171
+ ',' => 6.648, '-' => 7.992, '.' => 6.648, '/' => 6.648,
172
+ '0' => 13.344, '1' => 13.344, '2' => 13.344, '3' => 13.344,
173
+ '4' => 13.344, '5' => 13.344, '6' => 13.344, '7' => 13.344,
174
+ '8' => 13.344, '9' => 13.344, ':' => 7.992, ';' => 7.992,
175
+ '<' => 13.992, '=' => 13.992, '>' => 13.992, '?' => 14.640,
176
+ '@' => 23.400, 'A' => 17.328, 'B' => 17.328, 'C' => 17.328,
177
+ 'D' => 17.328, 'E' => 15.984, 'F' => 14.640, 'G' => 18.648,
178
+ 'H' => 17.328, 'I' => 6.648, 'J' => 13.344, 'K' => 17.328,
179
+ 'L' => 14.640, 'M' => 19.992, 'N' => 17.328, 'O' => 18.648,
180
+ 'P' => 15.984, 'Q' => 18.648, 'R' => 17.328, 'S' => 15.984,
181
+ 'T' => 14.640, 'U' => 17.328, 'V' => 15.984, 'W' => 22.632,
182
+ 'X' => 15.984, 'Y' => 15.984, 'Z' => 14.640, '[' => 7.992,
183
+ '\\' => 6.648, ']' => 7.992, '^' => 13.992, '_' => 13.344,
184
+ '`' => 7.992, 'a' => 13.344, 'b' => 14.640, 'c' => 13.344,
185
+ 'd' => 14.640, 'e' => 13.344, 'f' => 7.992, 'g' => 14.640,
186
+ 'h' => 14.640, 'i' => 6.648, 'j' => 6.648, 'k' => 13.344,
187
+ 'l' => 6.648, 'm' => 21.336, 'n' => 14.640, 'o' => 14.640,
188
+ 'p' => 14.640, 'q' => 14.640, 'r' => 9.336, 's' => 13.344,
189
+ 't' => 7.992, 'u' => 14.640, 'v' => 13.344, 'w' => 18.648,
190
+ 'x' => 13.344, 'y' => 13.344, 'z' => 12.000, '{' => 9.336,
191
+ '|' => 6.696, '}' => 9.336, '~' => 13.992,
192
+ },
193
+ @kerningDelta = {
194
+ ' A' => -0.891, ' Y' => -0.434, '11' => -1.781, 'A ' => -0.891,
195
+ 'AT' => -1.781, 'AV' => -1.781, 'AW' => -1.324, 'AY' => -1.781,
196
+ 'F,' => -2.660, 'F.' => -2.660, 'FA' => -1.324, 'L ' => -0.434,
197
+ 'LT' => -1.781, 'LV' => -1.324, 'LW' => -1.324, 'LY' => -1.781,
198
+ 'P ' => -0.891, 'P,' => -3.094, 'P.' => -3.094, 'PA' => -1.781,
199
+ 'RT' => -0.434, 'RW' => -0.434, 'RY' => -0.434, 'T,' => -1.781,
200
+ 'T-' => -1.324, 'T.' => -1.781, 'T:' => -1.781, 'T;' => -1.781,
201
+ 'TA' => -1.781, 'TO' => -0.434, 'Ta' => -0.891, 'Tc' => -0.891,
202
+ 'Te' => -0.891, 'Ti' => -0.434, 'To' => -0.891, 'Tr' => -0.434,
203
+ 'Ts' => -0.891, 'Tu' => -0.434, 'Tw' => -0.891, 'Ty' => -0.891,
204
+ 'V,' => -2.203, 'V-' => -0.891, 'V.' => -2.203, 'V:' => -0.891,
205
+ 'V;' => -0.891, 'VA' => -1.781, 'Va' => -0.891, 'Ve' => -0.891,
206
+ 'Vi' => -0.891, 'Vo' => -0.891, 'Vr' => -0.434, 'Vu' => -0.434,
207
+ 'Vy' => -0.434, 'W,' => -1.781, 'W-' => -0.891, 'W.' => -1.781,
208
+ 'W:' => -0.891, 'W;' => -0.891, 'WA' => -1.324, 'Wa' => -0.434,
209
+ 'We' => -0.434, 'Wi' => -0.211, 'Wo' => -0.434, 'Wr' => -0.434,
210
+ 'Wu' => -0.434, 'Wy' => -0.434, 'Y ' => -0.434, 'Y,' => -2.203,
211
+ 'Y-' => -1.781, 'Y.' => -2.203, 'Y:' => -1.324, 'Y;' => -1.324,
212
+ 'YA' => -1.781, 'Ya' => -0.891, 'Ye' => -0.891, 'Yi' => -0.891,
213
+ 'Yo' => -0.891, 'Yp' => -0.891, 'Yq' => -0.891, 'Yu' => -0.891,
214
+ 'Yv' => -0.891, 'ff' => -0.434, 'r,' => -1.324, 'r.' => -1.324,
215
+ 'v,' => -1.324, 'v.' => -1.324, 'w,' => -0.891, 'w.' => -0.891,
216
+ 'y,' => -0.891, 'y.' => -0.891,
217
+ }
218
+ )
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/env ruby -w
2
+ # encoding: UTF-8
3
+ #
4
+ # = Painter.rb -- The TaskJuggler III Project Management Software
5
+ #
6
+ # Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012
7
+ # by Chris Schlaeger <chris@linux.com>
8
+ #
9
+ # This program is free software; you can redistribute it and/or modify
10
+ # it under the terms of version 2 of the GNU General Public License as
11
+ # published by the Free Software Foundation.
12
+ #
13
+
14
+ # Set this flag to true to generate FontData.rb. This will require the prawn
15
+ # gem to be installed. For normal operation, this flag must be set to false.
16
+ GeneratorMode = false
17
+
18
+ if GeneratorMode
19
+ # Only required to generate the font metrics data.
20
+ require 'prawn'
21
+ end
22
+
23
+ require 'taskjuggler/Painter/FontMetricsData'
24
+ unless GeneratorMode
25
+ require 'taskjuggler/Painter/FontData'
26
+ end
27
+
28
+ class TaskJuggler
29
+
30
+ class Painter
31
+
32
+ # Class to compute or store the raw data for glyph size and kerning
33
+ # infomation. Developers can use it to generate FontData.rb. This file
34
+ # contains pre-computed font metrics data for some selected fonts. This
35
+ # data can then be used to determine the width and height of a bounding
36
+ # box of a given String.
37
+ #
38
+ # Developers can also use this file to generate FontData.rb using prawn as
39
+ # a back-end. We currently do not want to have prawn as a runtime
40
+ # dependency for TaskJuggler.
41
+ class FontMetrics
42
+
43
+ # Initialize the FontMetrics object.
44
+ def initialize()
45
+ @fonts = {}
46
+ # We currently only support the LiberationSans font which is metric
47
+ # compatible to Arial.
48
+ @fonts['Arial'] = @fonts['LiberationSans'] =
49
+ Font_LiberationSans_normal
50
+ @fonts['Arial-Italic'] = @fonts['LiberationSans-Italic'] =
51
+ Font_LiberationSans_italic
52
+ @fonts['Arial-Bold'] = @fonts['LiberationSans-Bold'] =
53
+ Font_LiberationSans_bold
54
+ @fonts['Arial-BoldItalic'] = @fonts['LiberationSans-BoldItalic'] =
55
+ Font_LiberationSans_bold_italic
56
+ end
57
+
58
+ # Return the height of the _font_ with _ptSize_ points in screen pixels.
59
+ def height(font, ptSize)
60
+ checkFontName(font)
61
+ # Calculate resulting height scaled to the font size and convert to
62
+ # screen pixels instead of points.
63
+ (@fonts[font].height * (ptSize.to_f / @fonts[font].ptSize) *
64
+ (4.0 / 3.0)).to_i
65
+ end
66
+
67
+ # Return the width of the string in screen pixels when using the font
68
+ # _font_ with _ptSize_ points.
69
+ def width(font, ptSize, str)
70
+ checkFontName(font)
71
+ w = 0
72
+ lastC = nil
73
+ str.each_char do |c|
74
+ cw = @fonts[font].glyphWidth(c)
75
+ w += cw || @font[font].averageWidth
76
+ if lastC
77
+ delta = @fonts[font].kerningDelta[lastC + c]
78
+ w += delta if delta
79
+ end
80
+ lastC = c
81
+ end
82
+ # Calculate resulting width scaled to the font size and convert to
83
+ # screen pixels instead of points.
84
+ (w * (ptSize.to_f / @fonts[font].ptSize) * (4.0 / 3.0)).to_i
85
+ end
86
+
87
+ private
88
+
89
+ def checkFontName(font)
90
+ unless @fonts.include?(font)
91
+ raise ArgumentError, "Unknown font '#{font}'!"
92
+ end
93
+ end
94
+ end
95
+
96
+ end
97
+
98
+ if GeneratorMode
99
+ File.open('FontData.rb', 'w') do |f|
100
+ f.puts <<'EOT'
101
+
102
+ class TaskJuggler
103
+ class Painter
104
+ class FontMetrics
105
+ EOT
106
+ font = 'LiberationSans'
107
+ f.puts Painter::FontMetricsData.new(font, :normal).to_ruby
108
+ f.puts Painter::FontMetricsData.new(font, :italic).to_ruby
109
+ f.puts Painter::FontMetricsData.new(font, :bold).to_ruby
110
+ f.puts Painter::FontMetricsData.new(font, :bold_italic).to_ruby
111
+ #font = 'Helvetica'
112
+ #f.puts Painter::FontMetricsData.new(font, :normal).to_ruby
113
+ #f.puts Painter::FontMetricsData.new(font, :italic).to_ruby
114
+ #f.puts Painter::FontMetricsData.new(font, :bold).to_ruby
115
+ #f.puts Painter::FontMetricsData.new(font, :bold_italic).to_ruby
116
+
117
+ f.puts <<'EOT'
118
+ end
119
+ end
120
+ end
121
+ EOT
122
+ end
123
+ end
124
+ end
125
+
@@ -0,0 +1,151 @@
1
+ #!/usr/bin/env ruby -w
2
+ # encoding: UTF-8
3
+ #
4
+ # = Painter.rb -- The TaskJuggler III Project Management Software
5
+ #
6
+ # Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012
7
+ # by Chris Schlaeger <chris@linux.com>
8
+ #
9
+ # This program is free software; you can redistribute it and/or modify
10
+ # it under the terms of version 2 of the GNU General Public License as
11
+ # published by the Free Software Foundation.
12
+ #
13
+
14
+ class TaskJuggler
15
+
16
+ class Painter
17
+
18
+ # The FontMetricsData objects generate and store the font metrics data for
19
+ # a particular font. The glyph set is currently restricted to US ASCII
20
+ # characters.
21
+ class FontMetricsData
22
+
23
+ MIN_GLYPH_INDEX = 32
24
+ MAX_GLYPH_INDEX = 126
25
+
26
+ attr_reader :ptSize, :charWidth, :height, :kerningDelta
27
+
28
+ # The constructor can be used in two different modes. If all font data
29
+ # is supplied, the object just stores the supplied font data. If only
30
+ # the font name is given, the class uses the prawn library to generate
31
+ # the font metrics for the requested font.
32
+ def initialize(fontName, type = :normal, ptSize = 24, height = nil,
33
+ wData = nil, kData = nil)
34
+ @fontName = fontName
35
+ @type = type
36
+ @height = height
37
+ @ptSize = ptSize
38
+ @averageWidth = 0.0
39
+
40
+ if wData && kData
41
+ @charWidth = wData
42
+ @kerningDelta = kData
43
+ else
44
+ generateMetrics
45
+ end
46
+ end
47
+
48
+ # Return the width of the glyph _c_. This must be a single character
49
+ # String. If the glyph is not known, nil is returned.
50
+ def glyphWidth(c)
51
+ return @charWidth[c]
52
+ end
53
+
54
+ # The average with of all glyphs.
55
+ def averageWidth
56
+ return (@averageWidth * (3.0 / 4.0)).to_i
57
+ end
58
+
59
+ # Generate the FontMetricsData initialization code for the particular
60
+ # font. The output will be Ruby syntax.
61
+ def to_ruby
62
+ indent = ' ' * 6
63
+ s = "#{indent}Font_#{@fontName.gsub(/-/, '_')}_#{@type} = " +
64
+ "Painter::FontMetricsData.new('#{@fontName}', :#{@type}, " +
65
+ "#{@ptSize}, #{"%.3f" % @height},\n"
66
+ s << "#{indent} @charWidth = {"
67
+ i = 0
68
+ @charWidth.each do |c, w|
69
+ s << (i % 4 == 0 ? "\n#{indent} " : ' ')
70
+ i += 1
71
+ s << "'#{escapedChars(c)}' => #{"%0.3f" % w},"
72
+ end
73
+ s << "\n#{indent} },\n"
74
+
75
+ s << "#{indent} @kerningDelta = {"
76
+ i = 0
77
+ @kerningDelta.each do |cp, w|
78
+ s << (i % 4 == 0 ? "\n#{indent} " : ' ')
79
+ i += 1
80
+ s << "'#{cp}' => #{"%.3f" % w},"
81
+ end
82
+ s << "\n#{indent} }\n#{indent})\n"
83
+ end
84
+
85
+ private
86
+
87
+ def escapedChars(c)
88
+ c.gsub(/\\/, '\\\\\\\\').gsub(/'/, '\\\\\'')
89
+ end
90
+
91
+ def generateMetrics
92
+ @pdf = Prawn::Document.new
93
+ ttfDir = "/usr/share/fonts/truetype/"
94
+ @pdf.font_families.update(
95
+ "LiberationSans" => {
96
+ :bold => "#{ttfDir}LiberationSans-Bold.ttf",
97
+ :italic => "#{ttfDir}LiberationSans-Italic.ttf",
98
+ :bold_italic => "#{ttfDir}LiberationSans-BoldItalic.ttf",
99
+ :normal => "#{ttfDir}LiberationSans-Regular.ttf"
100
+ }
101
+ )
102
+
103
+ @pdf.font(@fontName, :size => @ptSize, :style => @type)
104
+
105
+ # Determine the height of the font.
106
+ @height = @pdf.height_of("jjggMMWW")
107
+
108
+ @charWidth = {}
109
+ @averageWidth = 0.0
110
+ MIN_GLYPH_INDEX.upto(MAX_GLYPH_INDEX) do |c|
111
+ char = "" << c
112
+ begin
113
+ @charWidth[char] = (w = @pdf.width_of(char))
114
+ rescue
115
+ # the glyph is not in this font.
116
+ end
117
+ @averageWidth += w
118
+ end
119
+ @averageWidth /= (MAX_GLYPH_INDEX - MIN_GLYPH_INDEX)
120
+
121
+ @kerningDelta = {}
122
+ MIN_GLYPH_INDEX.upto(MAX_GLYPH_INDEX) do |c1|
123
+ char1 = "" << c1
124
+ next unless (cw1 = glyphWidth(char1))
125
+
126
+ MIN_GLYPH_INDEX.upto(MAX_GLYPH_INDEX) do |c2|
127
+ char2 = "" << c2
128
+ next unless (cw2 = glyphWidth(char2))
129
+
130
+ chars = char1 + char2
131
+ # The kerneing delta is the difference between the computed width
132
+ # of the combined characters and the sum of the individual
133
+ # character widths.
134
+ delta = @pdf.width_of(chars, :kerning => true) - (cw1 + cw2)
135
+
136
+ # We ususally don't use Strings longer than 100 characters. So we
137
+ # can ignore kerning deltas below a certain threshhold.
138
+ if delta.abs > 0.001
139
+ @kerningDelta[chars] = delta
140
+ end
141
+ end
142
+
143
+ end
144
+ end
145
+
146
+ end
147
+
148
+ end
149
+
150
+ end
151
+