gfdnavi 1.3.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.
Files changed (446) hide show
  1. data/ChangeLog +10949 -0
  2. data/LICENCE.txt +57 -0
  3. data/Makefile +18 -0
  4. data/TODO +132 -0
  5. data/app/controllers/analysis_controller.rb +700 -0
  6. data/app/controllers/application.rb +41 -0
  7. data/app/controllers/draw_method_controller.rb +172 -0
  8. data/app/controllers/explorer_controller.rb +197 -0
  9. data/app/controllers/finder_controller.rb +331 -0
  10. data/app/controllers/function_controller.rb +204 -0
  11. data/app/controllers/group_controller.rb +115 -0
  12. data/app/controllers/keyword_attributes_controller.rb +52 -0
  13. data/app/controllers/knowledge_controller.rb +928 -0
  14. data/app/controllers/nodes_controller.rb +515 -0
  15. data/app/controllers/search_controller.rb +341 -0
  16. data/app/controllers/user_controller.rb +337 -0
  17. data/app/helpers/analysis_helper.rb +2 -0
  18. data/app/helpers/application_helper.rb +105 -0
  19. data/app/helpers/description_helper.rb +2 -0
  20. data/app/helpers/function_helper.rb +2 -0
  21. data/app/helpers/group_helper.rb +2 -0
  22. data/app/helpers/search_helper.rb +3 -0
  23. data/app/helpers/user_helper.rb +2 -0
  24. data/app/helpers/work_flow_helper.rb +92 -0
  25. data/app/models/actual_file.rb +3 -0
  26. data/app/models/analysis.rb +715 -0
  27. data/app/models/analysis_history.rb +42 -0
  28. data/app/models/cross_array.rb +22 -0
  29. data/app/models/cross_result.rb +254 -0
  30. data/app/models/derived_spatial_attribute.rb +3 -0
  31. data/app/models/diagram_cache.rb +16 -0
  32. data/app/models/diagram_cache_datum.rb +4 -0
  33. data/app/models/diagram_cache_session.rb +8 -0
  34. data/app/models/directory.rb +21 -0
  35. data/app/models/draw_method.rb +48 -0
  36. data/app/models/draw_method_attribute.rb +8 -0
  37. data/app/models/draw_parameter.rb +12 -0
  38. data/app/models/explorer_query.rb +354 -0
  39. data/app/models/explorer_result.rb +312 -0
  40. data/app/models/function.rb +75 -0
  41. data/app/models/function_argument.rb +6 -0
  42. data/app/models/function_output.rb +4 -0
  43. data/app/models/group.rb +153 -0
  44. data/app/models/image.rb +20 -0
  45. data/app/models/keyword_attribute.rb +179 -0
  46. data/app/models/knowledge.rb +94 -0
  47. data/app/models/knowledge_backup.rb +32 -0
  48. data/app/models/knowledge_figure.rb +16 -0
  49. data/app/models/knowledge_figure_backup.rb +16 -0
  50. data/app/models/knowledge_parser.rb +392 -0
  51. data/app/models/node.rb +605 -0
  52. data/app/models/node_entity_abstract.rb +112 -0
  53. data/app/models/node_lineage.rb +6 -0
  54. data/app/models/node_relation.rb +4 -0
  55. data/app/models/path_node.rb +60 -0
  56. data/app/models/query.rb +193 -0
  57. data/app/models/query_history.rb +12 -0
  58. data/app/models/results.rb +48 -0
  59. data/app/models/sign_up_user.rb +25 -0
  60. data/app/models/spatial_and_time_attribute.rb +11 -0
  61. data/app/models/user.rb +115 -0
  62. data/app/models/user_mailer.rb +48 -0
  63. data/app/models/value_type.rb +3 -0
  64. data/app/models/variable.rb +70 -0
  65. data/app/models/virtual_node.rb +457 -0
  66. data/app/views/analysis/__help_analysis_tab.en.html +57 -0
  67. data/app/views/analysis/__help_draw_share.en.html +12 -0
  68. data/app/views/analysis/__help_draw_tab.en.html +6 -0
  69. data/app/views/analysis/_analysis_function_settings.rhtml +61 -0
  70. data/app/views/analysis/_analysis_settings.rhtml +28 -0
  71. data/app/views/analysis/_diagram.rhtml +70 -0
  72. data/app/views/analysis/_dimension_option.rhtml +59 -0
  73. data/app/views/analysis/_draw_general_settings.rhtml +217 -0
  74. data/app/views/analysis/_draw_settings.rhtml +73 -0
  75. data/app/views/analysis/_history.rhtml +19 -0
  76. data/app/views/analysis/_popular_diagrams.rhtml +42 -0
  77. data/app/views/analysis/_save_form.rhtml +44 -0
  78. data/app/views/analysis/_variables.rhtml +66 -0
  79. data/app/views/analysis/_variables_order.rhtml +56 -0
  80. data/app/views/analysis/index.rhtml +195 -0
  81. data/app/views/analysis/preview.rhtml +3 -0
  82. data/app/views/analysis/save.rhtml +73 -0
  83. data/app/views/analysis/show_diagram.rhtml +42 -0
  84. data/app/views/cross/_display_map.rhtml +201 -0
  85. data/app/views/cross/_result.rhtml +205 -0
  86. data/app/views/cross/_show_result_tree.rhtml +40 -0
  87. data/app/views/cross/_show_results.rhtml +80 -0
  88. data/app/views/cross/_style.rhtml +21 -0
  89. data/app/views/cross/index.rhtml +271 -0
  90. data/app/views/draw_method/_edit_form.rhtml +110 -0
  91. data/app/views/draw_method/create.rhtml +8 -0
  92. data/app/views/draw_method/details.rhtml +113 -0
  93. data/app/views/draw_method/edit.rhtml +8 -0
  94. data/app/views/draw_method/list.rhtml +80 -0
  95. data/app/views/explorer/_display_map.rhtml +199 -0
  96. data/app/views/explorer/_show_result_tree.rhtml +40 -0
  97. data/app/views/explorer/_show_results.rhtml +101 -0
  98. data/app/views/explorer/_style.rhtml +21 -0
  99. data/app/views/explorer/index.rhtml +214 -0
  100. data/app/views/finder/_children.html.erb +84 -0
  101. data/app/views/finder/_children_details.html.erb +74 -0
  102. data/app/views/finder/_children_details_tr.html.erb +196 -0
  103. data/app/views/finder/create_tree.html.erb +15 -0
  104. data/app/views/finder/flex.html.erb +52 -0
  105. data/app/views/finder/index.html.erb +47 -0
  106. data/app/views/finder/show_details.html.erb +3 -0
  107. data/app/views/finder/show_images.html.erb +3 -0
  108. data/app/views/function/_edit_form.rhtml +106 -0
  109. data/app/views/function/create.rhtml +8 -0
  110. data/app/views/function/details.rhtml +96 -0
  111. data/app/views/function/edit.rhtml +8 -0
  112. data/app/views/function/list.rhtml +80 -0
  113. data/app/views/group/add_member.rhtml +13 -0
  114. data/app/views/group/change_owner.rhtml +15 -0
  115. data/app/views/group/create.rhtml +11 -0
  116. data/app/views/group/delete_member.rhtml +14 -0
  117. data/app/views/group/list.rhtml +63 -0
  118. data/app/views/knowledge/_backup.rhtml +135 -0
  119. data/app/views/knowledge/_category.rhtml +58 -0
  120. data/app/views/knowledge/_category_list.rhtml +34 -0
  121. data/app/views/knowledge/_category_table.rhtml +23 -0
  122. data/app/views/knowledge/_comment.rhtml +64 -0
  123. data/app/views/knowledge/_comment_input_form.rhtml +19 -0
  124. data/app/views/knowledge/_comments.rhtml +84 -0
  125. data/app/views/knowledge/_form.rhtml +139 -0
  126. data/app/views/knowledge/_group_figure_form.rhtml +187 -0
  127. data/app/views/knowledge/_layout_figure.rhtml +61 -0
  128. data/app/views/knowledge/_layout_figures_in_a_row_above_text.rhtml +42 -0
  129. data/app/views/knowledge/_layout_figures_under_text.rhtml +45 -0
  130. data/app/views/knowledge/_layout_one_figure_above_text.rhtml +28 -0
  131. data/app/views/knowledge/_summary.rhtml +21 -0
  132. data/app/views/knowledge/edit.rhtml +37 -0
  133. data/app/views/knowledge/list.rhtml +287 -0
  134. data/app/views/knowledge/new.rhtml +23 -0
  135. data/app/views/knowledge/new_from_analysis.rhtml +21 -0
  136. data/app/views/knowledge/show.rhtml +196 -0
  137. data/app/views/layouts/gfdnavi.rhtml +105 -0
  138. data/app/views/nodes/_ancestors.html.erb +89 -0
  139. data/app/views/nodes/_description_methods_table.html.erb +75 -0
  140. data/app/views/nodes/_mode.html.erb +16 -0
  141. data/app/views/nodes/description.html.erb +181 -0
  142. data/app/views/nodes/description_methods.html.erb +1 -0
  143. data/app/views/nodes/edit.html.erb +73 -0
  144. data/app/views/nodes/index.html.erb +25 -0
  145. data/app/views/nodes/show.html.erb +20 -0
  146. data/app/views/search/_children_details_mapsearch.rhtml +68 -0
  147. data/app/views/search/_children_details_tr.rhtml +205 -0
  148. data/app/views/search/_show_grouplist.rhtml +74 -0
  149. data/app/views/search/_show_results.rhtml +43 -0
  150. data/app/views/search/_show_results_global.rhtml +36 -0
  151. data/app/views/search/_show_results_partial.rhtml +39 -0
  152. data/app/views/search/_show_results_partial_groupbyfile.rhtml +50 -0
  153. data/app/views/search/_show_variablelist.rhtml +28 -0
  154. data/app/views/search/mapsearch.rhtml +176 -0
  155. data/app/views/search/remapsearch.rjs +18 -0
  156. data/app/views/search/show_details.rhtml +3 -0
  157. data/app/views/user/add_user.rhtml +30 -0
  158. data/app/views/user/change_password.rhtml +25 -0
  159. data/app/views/user/edit.html.erb +50 -0
  160. data/app/views/user/index.rhtml +162 -0
  161. data/app/views/user/login.rhtml +41 -0
  162. data/app/views/user/logout.rhtml +4 -0
  163. data/app/views/user/signup.rhtml +36 -0
  164. data/app/views/user/signup_succeeded.rhtml +36 -0
  165. data/app/views/user_mailer/authorization_inform.rhtml +15 -0
  166. data/app/views/user_mailer/signup_accepted.rhtml +12 -0
  167. data/app/views/user_mailer/signup_confirm.rhtml +14 -0
  168. data/app/views/user_mailer/signup_inform.rhtml +13 -0
  169. data/app/views/user_mailer/signup_rejected.rhtml +11 -0
  170. data/app/views/work_flow/_push_wsdls.rhtml +55 -0
  171. data/app/views/work_flow/index.rhtml +46 -0
  172. data/config/database.yml.example +35 -0
  173. data/config/environment.rb +68 -0
  174. data/config/gfdnavi.yml.example +95 -0
  175. data/config/load_config.rb +151 -0
  176. data/config/routes.rb +35 -0
  177. data/consistency_checker.rb +129 -0
  178. data/data/gfdnavi_docs/how_to_draw_multiple_images.knlge +68 -0
  179. data/data/gfdnavi_docs/how_to_knowledge.knlge +138 -0
  180. data/data/gfdnavi_docs/how_to_write_document_about_Gfdnavi.knlge +30 -0
  181. data/data/samples/jmadata.SIGEN +8 -0
  182. data/data/samples/jmadata.yml +6 -0
  183. data/data/samples/jmadata/MSM-P/2006.nc.yml +2 -0
  184. data/data/samples/jmadata/MSM-P/2006.yml +17 -0
  185. data/data/samples/jmadata/MSM-P/2006/0101.nc +0 -0
  186. data/data/samples/jmadata/MSM-P/2006/0101.nc.yml +13 -0
  187. data/data/samples/jmadata/MSM-P/2006/0102.nc +0 -0
  188. data/data/samples/jmadata/MSM-P/2006/0103.nc +0 -0
  189. data/data/samples/jmadata/MSM-P/2006/0104.nc +0 -0
  190. data/data/samples/jmadata/MSM-P/2006/0105.nc +0 -0
  191. data/data/samples/jmadata/MSM-P/2006/010[1-3].nc.yml +2 -0
  192. data/data/samples/jmadata/MSM-P/2006/skip_data.rb +96 -0
  193. data/data/samples/jmadata/MSM-P/2006/skip_data.sh +6 -0
  194. data/data/samples/reanalysis.SIGEN +8 -0
  195. data/data/samples/reanalysis/era40.SIGEN +8 -0
  196. data/data/samples/reanalysis/era40.yml +2 -0
  197. data/data/samples/reanalysis/era40/t.jan.nc +0 -0
  198. data/data/samples/reanalysis/era40/t.jan.nc.yml +1 -0
  199. data/data/samples/reanalysis/ncep.SIGEN +9 -0
  200. data/data/samples/reanalysis/ncep/T.jan.100hPa.png +0 -0
  201. data/data/samples/reanalysis/ncep/T.jan.100hPa.png.yml +43 -0
  202. data/data/samples/reanalysis/ncep/T.jan.nc +0 -0
  203. data/data/samples/reanalysis/ncep/T.jan.zonal_mean.nc +0 -0
  204. data/data/samples/reanalysis/ncep/T.jan.zonal_mean.nc.yml +8 -0
  205. data/data/samples/reanalysis/ncep/T.jan_only_root.nc +0 -0
  206. data/data/samples/reanalysis/ncep/T.jan_only_root.nc.yml +4 -0
  207. data/data/samples/reanalysis/ncep/UV.jan.nc +0 -0
  208. data/data/samples/reanalysis/ncep/UV.jan.nc.yml +10 -0
  209. data/data/samples/reanalysis/ncep/UV.jan.nc.yml.ja +11 -0
  210. data/data/samples/sonde_operational.yml +5 -0
  211. data/data/samples/sonde_operational/std_plev.yml +12 -0
  212. data/data/samples/sonde_operational/std_plev/41256.spl.nc +0 -0
  213. data/data/samples/sonde_operational/std_plev/42410.spl.nc +0 -0
  214. data/data/samples/sonde_operational/std_plev/43333.spl.nc +0 -0
  215. data/data/samples/sonde_operational/std_plev/43346.spl.nc +0 -0
  216. data/data/samples/sonde_operational/std_plev/48698.spl.nc +0 -0
  217. data/data/samples/sonde_operational/std_plev/61641.spl.nc +0 -0
  218. data/data/samples/sonde_operational/std_plev/63741.spl.nc +0 -0
  219. data/data/samples/sonde_operational/std_plev/67083.spl.nc +0 -0
  220. data/data/samples/sonde_operational/std_plev/72261.spl.nc +0 -0
  221. data/data/samples/sonde_operational/std_plev/76805.spl.nc +0 -0
  222. data/data/samples/sonde_operational/std_plev/82193.spl.nc +0 -0
  223. data/data/samples/sonde_operational/std_plev/91165.spl.nc +0 -0
  224. data/data/samples/sonde_operational/std_plev/91610.spl.nc +0 -0
  225. data/data/samples/sonde_operational/std_plev/91948.spl.nc +0 -0
  226. data/data/samples/sonde_operational/std_plev/94294.spl.nc +0 -0
  227. data/db/NetCDFparser.rb +406 -0
  228. data/db/create_derived_spatial_attributes.sql +12 -0
  229. data/db/draw_methods/line.yml +6 -0
  230. data/db/draw_methods/scatter.yml +38 -0
  231. data/db/draw_methods/tone.yml +64 -0
  232. data/db/draw_methods/vector.yml +19 -0
  233. data/db/dump_db.rb +43 -0
  234. data/db/functions/additions.yml +10 -0
  235. data/db/functions/cut.yml +10 -0
  236. data/db/functions/division.yml +10 -0
  237. data/db/functions/mean.yml +28 -0
  238. data/db/functions/multiplication.yml +10 -0
  239. data/db/functions/stddev.yml +28 -0
  240. data/db/functions/subtraction.yml +10 -0
  241. data/db/migrate/001_initial_scheme.rb +289 -0
  242. data/db/migrate/002_add_open_id_authentication_tables.rb +20 -0
  243. data/db/register_directory_tree.rb +760 -0
  244. data/db/restore_db.rb +60 -0
  245. data/gfdnavi-install +828 -0
  246. data/install.rb +828 -0
  247. data/lib/activerecord_gfdnavi.rb +31 -0
  248. data/lib/basic_authorization.rb +50 -0
  249. data/lib/create_activeresources.rb +108 -0
  250. data/lib/execute_analysis.rb +472 -0
  251. data/lib/file_gfdnavi.rb +38 -0
  252. data/lib/gphys_gfdnavi.rb +81 -0
  253. data/lib/localdir.rb +110 -0
  254. data/lib/login_system.rb +110 -0
  255. data/lib/multibytes.rb +20 -0
  256. data/lib/narray_yaml.rb +58 -0
  257. data/lib/no_rdb_base.rb +40 -0
  258. data/lib/opendapdir.rb +171 -0
  259. data/lib/tar.rb +127 -0
  260. data/lib/tasks/clean.rake +65 -0
  261. data/lib/tasks/setup.rake +316 -0
  262. data/lib/tasks/update.rake +62 -0
  263. data/lib/vizshot_gfdnavi.rb +224 -0
  264. data/public/crossdomain.xml +4 -0
  265. data/public/flex/NodeTreeDescriptor.as +55 -0
  266. data/public/flex/TreeNode.as +253 -0
  267. data/public/flex/finder.mxml +304 -0
  268. data/public/flex/finder.swf +0 -0
  269. data/public/flex/gfdnavi.mxml +52 -0
  270. data/public/flex/gfdnavi.swf +0 -0
  271. data/public/images/Help_S-shots/dir_tree_with_add.jpg +0 -0
  272. data/public/images/analyze.gif +0 -0
  273. data/public/images/circle.gif +0 -0
  274. data/public/images/create_from_analysis_button.png +0 -0
  275. data/public/images/delete.png +0 -0
  276. data/public/images/down.png +0 -0
  277. data/public/images/drawbutton.gif +0 -0
  278. data/public/images/gfdnavi_home_logo.png +0 -0
  279. data/public/images/gfdnavi_logo_big.png +0 -0
  280. data/public/images/gfdnavi_logo_med.png +0 -0
  281. data/public/images/gfdnavi_logo_mini.png +0 -0
  282. data/public/images/gfdnavi_logo_nobg_big.png +0 -0
  283. data/public/images/gfdnavi_logo_nobg_med.png +0 -0
  284. data/public/images/gfdnavi_logo_nobg_small.png +0 -0
  285. data/public/images/gfdnavi_logo_small.png +0 -0
  286. data/public/images/gfdnavi_logo_xsmall.png +0 -0
  287. data/public/images/hbar.png +0 -0
  288. data/public/images/helpmark16.png +0 -0
  289. data/public/images/helpmark18.png +0 -0
  290. data/public/images/kikyu_g.gif +0 -0
  291. data/public/images/kikyu_r.gif +0 -0
  292. data/public/images/map_icon_g.gif +0 -0
  293. data/public/images/map_icon_r.gif +0 -0
  294. data/public/images/new_knowledge.png +0 -0
  295. data/public/images/openid.png +0 -0
  296. data/public/images/read_in_the_form.png +0 -0
  297. data/public/images/slider_f.gif +0 -0
  298. data/public/images/slider_f_red.gif +0 -0
  299. data/public/images/star1.gif +0 -0
  300. data/public/images/star2.gif +0 -0
  301. data/public/images/startanim.gif +0 -0
  302. data/public/images/stopanim.gif +0 -0
  303. data/public/images/tree/DL.png +0 -0
  304. data/public/images/tree/anal_viz.png +0 -0
  305. data/public/images/tree/analyze_visualize_checked_items.png +0 -0
  306. data/public/images/tree/binary.png +0 -0
  307. data/public/images/tree/details.png +0 -0
  308. data/public/images/tree/download_checked_items.png +0 -0
  309. data/public/images/tree/folder.png +0 -0
  310. data/public/images/tree/folder_close.gif +0 -0
  311. data/public/images/tree/image2.png +0 -0
  312. data/public/images/tree/knowledge.png +0 -0
  313. data/public/images/tree/knowledges.png +0 -0
  314. data/public/images/tree/last.gif +0 -0
  315. data/public/images/tree/last.png +0 -0
  316. data/public/images/tree/minus.gif +0 -0
  317. data/public/images/tree/minus_simple.gif +0 -0
  318. data/public/images/tree/none.gif +0 -0
  319. data/public/images/tree/none.png +0 -0
  320. data/public/images/tree/plus.gif +0 -0
  321. data/public/images/tree/plus_simple.gif +0 -0
  322. data/public/images/tree/show.png +0 -0
  323. data/public/images/tree/show_checked_items.png +0 -0
  324. data/public/images/tree/t.gif +0 -0
  325. data/public/images/tree/t.png +0 -0
  326. data/public/images/tree/tate.gif +0 -0
  327. data/public/images/tree/tate.png +0 -0
  328. data/public/images/up.png +0 -0
  329. data/public/images/vbar.png +0 -0
  330. data/public/images/white.bmp +0 -0
  331. data/public/images/x.gif +0 -0
  332. data/public/index.html +100 -0
  333. data/public/javascripts/AC_OETags.js +269 -0
  334. data/public/javascripts/analysis.js +751 -0
  335. data/public/javascripts/application.js +29 -0
  336. data/public/javascripts/directory_tree.js +102 -0
  337. data/public/javascripts/draw_method.js +83 -0
  338. data/public/javascripts/excanvas.js +704 -0
  339. data/public/javascripts/function.js +107 -0
  340. data/public/javascripts/gfdnavi.js +175 -0
  341. data/public/javascripts/knowledge.js +384 -0
  342. data/public/javascripts/mapsearch.js +313 -0
  343. data/public/javascripts/progress.js +42 -0
  344. data/public/javascripts/resizable_box.js +164 -0
  345. data/public/javascripts/slider.js +260 -0
  346. data/public/javascripts/tab.js +17 -0
  347. data/public/javascripts/work_flow.js +452 -0
  348. data/public/stylesheets/analysis.css +111 -0
  349. data/public/stylesheets/description.css +71 -0
  350. data/public/stylesheets/gfdnavi.css +141 -0
  351. data/public/stylesheets/knowledge.css +218 -0
  352. data/public/stylesheets/search.css +184 -0
  353. data/public/stylesheets/tree.css +45 -0
  354. data/public/stylesheets/tree_for_ie.css +3 -0
  355. data/public/stylesheets/work_flow.css +78 -0
  356. data/script/cleaner +11 -0
  357. data/script/server_ssl +131 -0
  358. data/test/fixtures/diagram_cache_data.yml +5 -0
  359. data/test/fixtures/diagram_cache_sessions.yml +6 -0
  360. data/test/fixtures/diagram_caches.yml +6 -0
  361. data/test/fixtures/directories.yml +57 -0
  362. data/test/fixtures/draw_parameters.yml +6 -0
  363. data/test/fixtures/function_arguments.yml +15 -0
  364. data/test/fixtures/function_outputs.yml +15 -0
  365. data/test/fixtures/functions.yml +29 -0
  366. data/test/fixtures/group_members.yml +33 -0
  367. data/test/fixtures/groups.yml +25 -0
  368. data/test/fixtures/images.yml +12 -0
  369. data/test/fixtures/keyword_attributes.yml +73 -0
  370. data/test/fixtures/knowledges.yml +10 -0
  371. data/test/fixtures/node_relations.yml +11 -0
  372. data/test/fixtures/nodes.yml +298 -0
  373. data/test/fixtures/sign_up_users.yml +8 -0
  374. data/test/fixtures/spatial_and_time_attributes.yml +29 -0
  375. data/test/fixtures/user_mailer/authorization_inform +11 -0
  376. data/test/fixtures/user_mailer/signup_accepted +10 -0
  377. data/test/fixtures/user_mailer/signup_confirm +17 -0
  378. data/test/fixtures/user_mailer/signup_inform +10 -0
  379. data/test/fixtures/user_mailer/signup_rejected +9 -0
  380. data/test/fixtures/users.yml +31 -0
  381. data/test/fixtures/value_types.yml +10 -0
  382. data/test/fixtures/variables.yml +17 -0
  383. data/test/functional/analysis_controller_test.rb +169 -0
  384. data/test/functional/description_controller_test.rb +18 -0
  385. data/test/functional/function_controller_test.rb +18 -0
  386. data/test/functional/group_controller_test.rb +18 -0
  387. data/test/functional/search_controller_test.rb +83 -0
  388. data/test/functional/user_controller_test.rb +77 -0
  389. data/test/functional/webservice_analysis_api_test.rb +12 -0
  390. data/test/functional/work_flow_controller_test.rb +18 -0
  391. data/test/test_helper.rb +28 -0
  392. data/test/unit/diagram_cache_datum_test.rb +10 -0
  393. data/test/unit/diagram_cache_session_test.rb +10 -0
  394. data/test/unit/diagram_cache_test.rb +10 -0
  395. data/test/unit/directory_test.rb +49 -0
  396. data/test/unit/draw_parameter_test.rb +10 -0
  397. data/test/unit/function_argument_test.rb +10 -0
  398. data/test/unit/function_output_test.rb +10 -0
  399. data/test/unit/function_test.rb +10 -0
  400. data/test/unit/group_test.rb +48 -0
  401. data/test/unit/image_test.rb +13 -0
  402. data/test/unit/keyword_attribute_test.rb +33 -0
  403. data/test/unit/knowledge_test.rb +13 -0
  404. data/test/unit/node_relation_test.rb +20 -0
  405. data/test/unit/node_test.rb +85 -0
  406. data/test/unit/sign_up_user_test.rb +20 -0
  407. data/test/unit/spatial_and_time_attribute_test.rb +29 -0
  408. data/test/unit/user_mailer_test.rb +101 -0
  409. data/test/unit/user_test.rb +134 -0
  410. data/test/unit/value_type_test.rb +10 -0
  411. data/test/unit/variable_test.rb +35 -0
  412. data/vendor/plugins/acts_as_list/README +23 -0
  413. data/vendor/plugins/acts_as_list/init.rb +3 -0
  414. data/vendor/plugins/acts_as_list/lib/active_record/acts/list.rb +256 -0
  415. data/vendor/plugins/acts_as_list/test/list_test.rb +332 -0
  416. data/vendor/plugins/acts_as_tree/README +26 -0
  417. data/vendor/plugins/acts_as_tree/Rakefile +22 -0
  418. data/vendor/plugins/acts_as_tree/init.rb +1 -0
  419. data/vendor/plugins/acts_as_tree/lib/active_record/acts/tree.rb +96 -0
  420. data/vendor/plugins/acts_as_tree/test/abstract_unit.rb +0 -0
  421. data/vendor/plugins/acts_as_tree/test/acts_as_tree_test.rb +219 -0
  422. data/vendor/plugins/acts_as_tree/test/database.yml +0 -0
  423. data/vendor/plugins/acts_as_tree/test/fixtures/mixin.rb +0 -0
  424. data/vendor/plugins/acts_as_tree/test/fixtures/mixins.yml +0 -0
  425. data/vendor/plugins/acts_as_tree/test/schema.rb +0 -0
  426. data/vendor/plugins/will_paginate/CHANGELOG +92 -0
  427. data/vendor/plugins/will_paginate/LICENSE +18 -0
  428. data/vendor/plugins/will_paginate/README.rdoc +131 -0
  429. data/vendor/plugins/will_paginate/Rakefile +62 -0
  430. data/vendor/plugins/will_paginate/examples/apple-circle.gif +0 -0
  431. data/vendor/plugins/will_paginate/examples/index.haml +69 -0
  432. data/vendor/plugins/will_paginate/examples/index.html +92 -0
  433. data/vendor/plugins/will_paginate/examples/pagination.css +90 -0
  434. data/vendor/plugins/will_paginate/examples/pagination.sass +91 -0
  435. data/vendor/plugins/will_paginate/init.rb +1 -0
  436. data/vendor/plugins/will_paginate/lib/will_paginate.rb +86 -0
  437. data/vendor/plugins/will_paginate/lib/will_paginate/array.rb +16 -0
  438. data/vendor/plugins/will_paginate/lib/will_paginate/collection.rb +145 -0
  439. data/vendor/plugins/will_paginate/lib/will_paginate/core_ext.rb +32 -0
  440. data/vendor/plugins/will_paginate/lib/will_paginate/finder.rb +247 -0
  441. data/vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb +132 -0
  442. data/vendor/plugins/will_paginate/lib/will_paginate/named_scope_patch.rb +39 -0
  443. data/vendor/plugins/will_paginate/lib/will_paginate/version.rb +9 -0
  444. data/vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb +373 -0
  445. data/vendor/plugins/will_paginate/will_paginate.gemspec +21 -0
  446. metadata +586 -0
@@ -0,0 +1,29 @@
1
+ // Place your application-specific JavaScript functions and classes here
2
+ // This file is automatically included by javascript_include_tag :defaults
3
+
4
+ function setCookie(name,value,expire){
5
+ if (value) {
6
+ document.cookie = name + '=' + escape(value) + ((expire==null)?'':('; expires='+expire.toGMTString()));
7
+ } else {
8
+ expire = new Date();
9
+ var year = expire.getYear();
10
+ year = year < 1900 ? year + 1900 : year;
11
+ expire.setYear(year - 1);
12
+ document.cookie = name + '=null; expires='+expire.toGMTString();
13
+ }
14
+ }
15
+
16
+ function getCookie(name){
17
+ var search = name + '=';
18
+ if (document.cookie.length>0) {
19
+ offset = document.cookie.indexOf(search);
20
+ if (offset != -1){
21
+ offset += search.length;
22
+ end = document.cookie.indexOf(';',offset);
23
+ if(end == -1)
24
+ end = document.cookie.length;
25
+ return unescape(document.cookie.substring(offset,end));
26
+ }
27
+ }
28
+ return null;
29
+ }
@@ -0,0 +1,102 @@
1
+ var tree;
2
+ var Tree = Class.create();
3
+ Tree.imagefile = new Array(gfdnaviUrlRoot+"/images/tree/plus.gif",
4
+ gfdnaviUrlRoot+"/images/tree/minus.gif");
5
+ Tree.prototype = {
6
+ initialize: function(divId) {
7
+ this.divId = divId;
8
+ this.showDirDetailsAjax = null;
9
+ var imagefile = Tree.imagefile;
10
+ this.image = new Array(imagefile.length);
11
+ for (var count = 0; count < (imagefile.length - 1); count++){
12
+ this.image[count] = new Image();
13
+ this.image[count].src = imagefile[count];
14
+ }
15
+ },
16
+
17
+ create: function(path) {
18
+ var param = {asynchronous: false,
19
+ method: 'get',
20
+ evalScripts: true};
21
+ if (path)
22
+ param.parameters = 'path='+path;
23
+ new Ajax.Updater(this.divId,
24
+ gfdnaviUrlRoot + '/finder/create_tree',
25
+ param
26
+ );
27
+ },
28
+
29
+ open: function(path) {
30
+ new Ajax.Request(gfdnaviUrlRoot + '/finder/open_tree',
31
+ {asynchronous: true,
32
+ evalScripts: true,
33
+ parameters: 'path=' + path,
34
+ method: 'post'});
35
+ },
36
+
37
+ selectedFunction: null,
38
+ previousSelectedPath: null,
39
+
40
+ dirSelected: function(path, notopen) {
41
+ if (!notopen)
42
+ this.dirShow(path,true);
43
+ this.selectedFunction(path);
44
+ if (this.previousSelectedPath)
45
+ Element.removeClassName('dir_name' + this.previousSelectedPath,'selected');
46
+ Element.addClassName('dir_name' + path, 'selected');
47
+ this.previousSelectedPath = path;
48
+ },
49
+
50
+ dirChange: function(path) {
51
+ var dir_id = 'dir'+path;
52
+ var img_id = 'dir_img'+path;
53
+ if( Element.visible(dir_id) ) {
54
+ this.dirHide(path);
55
+ } else {
56
+ this.dirShow(path);
57
+ }
58
+ },
59
+
60
+ dirShow: function(path, selected) {
61
+ var dir_id = 'dir'+path;
62
+ var img_id = 'dir_img'+path;
63
+ $(img_id).src = Tree.imagefile[1];
64
+ Element.show(dir_id);
65
+ this.sendStatus('opened', path, selected);
66
+ },
67
+
68
+ dirHide: function(path) {
69
+ var dir_id = 'dir'+path;
70
+ var img_id = 'dir_img'+path;
71
+ $(img_id).src = Tree.imagefile[0];
72
+ Element.hide(dir_id);
73
+ this.sendStatus('closed', path);
74
+ },
75
+
76
+ sendStatus: function(status, path, selected) {
77
+ param = status + '=' + path;
78
+ if (selected)
79
+ param = param + '&selected=true';
80
+ new Ajax.Request(gfdnaviUrlRoot + '/finder/dir_status',
81
+ {asynchronous: true,
82
+ evalScripts: true,
83
+ parameters: param,
84
+ method: 'post'});
85
+ },
86
+
87
+
88
+ dirDetailsDivId: null,
89
+
90
+ showDirDetails: function(path) {
91
+ if (this.showDirDetailsAjax)
92
+ this.showDirDetailsAjax.transport.abort();
93
+ param = { method: 'get'};
94
+ if (path)
95
+ param.parameters = 'path='+path;
96
+ this.showDirDetailsAjax = new Ajax.Updater(this.dirDetailsDivId,
97
+ gfdnaviUrlRoot + '/finder/show_details',
98
+ param
99
+ );
100
+ }
101
+
102
+ };
@@ -0,0 +1,83 @@
1
+ var numInputs = 1;
2
+ var numAttrs = 0;
3
+
4
+ function changeVars() {
5
+ numInputs = $('draw_method_nvars').selectedIndex + 1;
6
+ var ary = new Array(numAttrs+numInputs);
7
+ for (i=0; i<numInputs; i++) {
8
+ if (i==0)
9
+ ary[i] = 'gphys';
10
+ else
11
+ ary[i] = 'gphys' + i;
12
+ }
13
+ ary[numInputs] = "opt";
14
+ Element.update('vizshot_args', ary.join(", "));
15
+ ary[numInputs] = "newfrm";
16
+ ary[numInputs+1] = "opt";
17
+ Element.update('ggraph_args', ary.join(", "));
18
+ }
19
+
20
+ var numAttrMax=0;
21
+ function changeAttributes() {
22
+ numAttrs = $('attribute_num').selectedIndex;
23
+ changeVars();
24
+
25
+ for (i=0; i<[numAttrs,numAttrMax].min(); i++)
26
+ Element.show('attr_'+i);
27
+ for (i=numAttrs;i<numAttrMax; i++)
28
+ Element.hide('attr_'+i);
29
+
30
+ html = "";
31
+ for (i=numAttrMax; i<numAttrs; i++) {
32
+ html += "<div id='attr_" + i + "'>\n";
33
+ html += "<h4>attribute " + i +"</h4>\n";
34
+ html += "<table>\n";
35
+ html += " <tr>\n";
36
+ html += " <td>\n";
37
+ html += " <label for='attribute_" + i + "_name'>name</label>\n";
38
+ html += " </td>\n";
39
+ html += " <td>\n";
40
+ html += " <input type='text' name='attribute[" + i + "][name]' id='attribute_" + i + "_name'></input>\n";
41
+ html += " </td>\n";
42
+ html += " </tr>\n";
43
+ html += " <tr>\n";
44
+ html += " <td>\n";
45
+ html += " <label for='attribute_" + i + "_default'>default</label>\n";
46
+ html += " </td>\n";
47
+ html += " <td>\n";
48
+ html += " <input type='text' size='10' name='attribute[" + i + "][default]' id='attribute_" + i + "_default'/>\n";
49
+ html += " </td>\n";
50
+ html += " </tr>\n";
51
+ html += " <tr>\n";
52
+ html += " <td>\n";
53
+ html += " <label for='attribute_" + i + "_value_type'>value type</label>\n";
54
+ html += " </td>\n";
55
+ html += " <td>\n";
56
+ html += " <select id='attribute_" + i + "_value_type' name='attribute[" + i + "][value_type]'>\n";
57
+ html += " <option selected>int</option>\n";
58
+ html += " <option>float</option>\n";
59
+ html += " <option>string</option>\n";
60
+ html += " <option>boolean</option>\n";
61
+ html += " <option>array_int</option>\n";
62
+ html += " <option>array_float</option>\n";
63
+ html += " </select>\n";
64
+ html += " </td>\n";
65
+ html += " </tr>\n";
66
+ html += " <tr>\n";
67
+ html += " <td>\n";
68
+ html += " <label for='attribute_" + i + "_parser'>parser</label>\n";
69
+ html += " </td>\n";
70
+ html += " <td>\n";
71
+ html += " <select id='attribute_" + i + "_parser' name='attribute[" + i + "][parser]'>\n";
72
+ html += " <option selected>vizshot</option>\n";
73
+ html += " <option>ggraph</option>\n";
74
+ html += " </select>\n";
75
+ html += " </td>\n";
76
+ html += " </tr>\n";
77
+ html += "</table>\n";
78
+ html += "</div>\n";
79
+ numAttrMax = i+1;
80
+ }
81
+ new Insertion.Bottom('attributes_table', html);
82
+ }
83
+
@@ -0,0 +1,704 @@
1
+ // Copyright 2006 Google Inc.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ // TODO: Patterns
16
+ // TODO: Radial gradient
17
+ // TODO: Clipping paths
18
+ // TODO: Coordsize
19
+ // TODO: Painting mode
20
+ // TODO: Optimize
21
+ // TODO: canvas width/height sets content size in moz, border size in ie
22
+ // TODO: Painting outside the canvas should not be allowed
23
+
24
+ // only add this code if we do not already have a canvas implementation
25
+ if (!window.CanvasRenderingContext2D) {
26
+
27
+ (function () {
28
+
29
+ var G_vmlCanvasManager_ = {
30
+ init: function (opt_doc) {
31
+ var doc = opt_doc || document;
32
+ if (/MSIE/.test(navigator.userAgent) && !window.opera) {
33
+ var self = this;
34
+ doc.attachEvent("onreadystatechange", function () {
35
+ self.init_(doc);
36
+ });
37
+ }
38
+ },
39
+
40
+ init_: function (doc, e) {
41
+ if (doc.readyState == "complete") {
42
+ // create xmlns
43
+ if (!doc.namespaces["g_vml_"]) {
44
+ doc.namespaces.add("g_vml_", "urn:schemas-microsoft-com:vml");
45
+ }
46
+
47
+ // setup default css
48
+ var ss = doc.createStyleSheet();
49
+ ss.cssText = "canvas{display:inline-block;overflow:hidden;" +
50
+ "text-align:left;}" +
51
+ "canvas *{behavior:url(#default#VML)}";
52
+
53
+ // find all canvas elements
54
+ var els = doc.getElementsByTagName("canvas");
55
+ for (var i = 0; i < els.length; i++) {
56
+ if (!els[i].getContext) {
57
+ this.initElement(els[i]);
58
+ }
59
+ }
60
+ }
61
+ },
62
+
63
+ fixElement_: function (el) {
64
+ // in IE before version 5.5 we would need to add HTML: to the tag name
65
+ // but we do not care about IE before version 6
66
+ var outerHTML = el.outerHTML;
67
+ var newEl = document.createElement(outerHTML);
68
+ // if the tag is still open IE has created the children as siblings and
69
+ // it has also created a tag with the name "/FOO"
70
+ if (outerHTML.slice(-2) != "/>") {
71
+ var tagName = "/" + el.tagName;
72
+ var ns;
73
+ // remove content
74
+ while ((ns = el.nextSibling) && ns.tagName != tagName) {
75
+ ns.removeNode();
76
+ }
77
+ // remove the incorrect closing tag
78
+ if (ns) {
79
+ ns.removeNode();
80
+ }
81
+ }
82
+ el.parentNode.replaceChild(newEl, el);
83
+ return newEl;
84
+ },
85
+
86
+ /**
87
+ * Public initializes a canvas element so that it can be used as canvas
88
+ * element from now on. This is called automatically before the page is
89
+ * loaded but if you are creating elements using createElement yuo need to
90
+ * make sure this is called on the element.
91
+ * @param el {HTMLElement} The canvas element to initialize.
92
+ */
93
+ initElement: function (el) {
94
+ el = this.fixElement_(el);
95
+ el.getContext = function () {
96
+ if (this.context_) {
97
+ return this.context_;
98
+ }
99
+ return this.context_ = new CanvasRenderingContext2D_(this);
100
+ };
101
+
102
+ var self = this; //bind
103
+ el.attachEvent("onpropertychange", function (e) {
104
+ // we need to watch changes to width and height
105
+ switch (e.propertyName) {
106
+ case "width":
107
+ case "height":
108
+ // coord size changed?
109
+ break;
110
+ }
111
+ });
112
+
113
+ // if style.height is set
114
+
115
+ var attrs = el.attributes;
116
+ if (attrs.width && attrs.width.specified) {
117
+ // TODO: use runtimeStyle and coordsize
118
+ // el.getContext().setWidth_(attrs.width.nodeValue);
119
+ el.style.width = attrs.width.nodeValue + "px";
120
+ }
121
+ if (attrs.height && attrs.height.specified) {
122
+ // TODO: use runtimeStyle and coordsize
123
+ // el.getContext().setHeight_(attrs.height.nodeValue);
124
+ el.style.height = attrs.height.nodeValue + "px";
125
+ }
126
+ //el.getContext().setCoordsize_()
127
+ }
128
+ };
129
+
130
+ G_vmlCanvasManager_.init();
131
+
132
+ // precompute "00" to "FF"
133
+ var dec2hex = [];
134
+ for (var i = 0; i < 16; i++) {
135
+ for (var j = 0; j < 16; j++) {
136
+ dec2hex[i * 16 + j] = i.toString(16) + j.toString(16);
137
+ }
138
+ }
139
+
140
+ function createMatrixIdentity() {
141
+ return [
142
+ [1, 0, 0],
143
+ [0, 1, 0],
144
+ [0, 0, 1]
145
+ ];
146
+ }
147
+
148
+ function matrixMultiply(m1, m2) {
149
+ var result = createMatrixIdentity();
150
+
151
+ for (var x = 0; x < 3; x++) {
152
+ for (var y = 0; y < 3; y++) {
153
+ var sum = 0;
154
+
155
+ for (var z = 0; z < 3; z++) {
156
+ sum += m1[x][z] * m2[z][y];
157
+ }
158
+
159
+ result[x][y] = sum;
160
+ }
161
+ }
162
+ return result;
163
+ }
164
+
165
+ function copyState(o1, o2) {
166
+ o2.fillStyle = o1.fillStyle;
167
+ o2.lineCap = o1.lineCap;
168
+ o2.lineJoin = o1.lineJoin;
169
+ o2.lineWidth = o1.lineWidth;
170
+ o2.miterLimit = o1.miterLimit;
171
+ o2.shadowBlur = o1.shadowBlur;
172
+ o2.shadowColor = o1.shadowColor;
173
+ o2.shadowOffsetX = o1.shadowOffsetX;
174
+ o2.shadowOffsetY = o1.shadowOffsetY;
175
+ o2.strokeStyle = o1.strokeStyle;
176
+ }
177
+
178
+ function processStyle(styleString) {
179
+ var str, alpha = 1;
180
+
181
+ styleString = String(styleString);
182
+ if (styleString.substring(0, 3) == "rgb") {
183
+ var start = styleString.indexOf("(", 3);
184
+ var end = styleString.indexOf(")", start + 1);
185
+ var guts = styleString.substring(start + 1, end).split(",");
186
+
187
+ str = "#";
188
+ for (var i = 0; i < 3; i++) {
189
+ str += dec2hex[parseInt(guts[i])];
190
+ }
191
+
192
+ if ((guts.length == 4) && (styleString.substr(3, 1) == "a")) {
193
+ alpha = guts[3];
194
+ }
195
+ } else {
196
+ str = styleString;
197
+ }
198
+
199
+ return [str, alpha];
200
+ }
201
+
202
+ function processLineCap(lineCap) {
203
+ switch (lineCap) {
204
+ case "butt":
205
+ return "flat";
206
+ case "round":
207
+ return "round";
208
+ case "square":
209
+ default:
210
+ return "square";
211
+ }
212
+ }
213
+
214
+ /**
215
+ * This class implements CanvasRenderingContext2D interface as described by
216
+ * the WHATWG.
217
+ * @param surfaceElement {HTMLElement} The element that the 2D context should
218
+ * be associated with
219
+ */
220
+ function CanvasRenderingContext2D_(surfaceElement) {
221
+ this.m_ = createMatrixIdentity();
222
+ this.element_ = surfaceElement;
223
+
224
+ this.mStack_ = [];
225
+ this.aStack_ = [];
226
+ this.currentPath_ = [];
227
+
228
+ // Canvas context properties
229
+ this.strokeStyle = "#000";
230
+ this.fillStyle = "#ccc";
231
+
232
+ this.lineWidth = 1;
233
+ this.lineJoin = "miter";
234
+ this.lineCap = "butt";
235
+ this.miterLimit = 10;
236
+ this.globalAlpha = 1;
237
+ };
238
+
239
+ var contextPrototype = CanvasRenderingContext2D_.prototype;
240
+ contextPrototype.clearRect = function() {
241
+ this.element_.innerHTML = "";
242
+ this.currentPath_ = [];
243
+ };
244
+
245
+ contextPrototype.beginPath = function() {
246
+ // TODO: Branch current matrix so that save/restore has no effect
247
+ // as per safari docs.
248
+
249
+ this.currentPath_ = [];
250
+ };
251
+
252
+ contextPrototype.moveTo = function(aX, aY) {
253
+ this.currentPath_.push({type: "moveTo", x: aX, y: aY});
254
+ };
255
+
256
+ contextPrototype.lineTo = function(aX, aY) {
257
+ this.currentPath_.push({type: "lineTo", x: aX, y: aY});
258
+ };
259
+
260
+ contextPrototype.bezierCurveTo = function(aCP1x, aCP1y,
261
+ aCP2x, aCP2y,
262
+ aX, aY) {
263
+ this.currentPath_.push({type: "bezierCurveTo",
264
+ cp1x: aCP1x,
265
+ cp1y: aCP1y,
266
+ cp2x: aCP2x,
267
+ cp2y: aCP2y,
268
+ x: aX,
269
+ y: aY});
270
+ };
271
+
272
+ contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) {
273
+ // VML's qb produces different output to Firefox's
274
+ // FF's behaviour seems to have changed in 1.5.0.1, check this
275
+ this.bezierCurveTo(aCPx, aCPy, aCPx, aCPy, aX, aY);
276
+ };
277
+
278
+ contextPrototype.arc = function(aX, aY, aRadius,
279
+ aStartAngle, aEndAngle, aClockwise) {
280
+ if (!aClockwise) {
281
+ var t = aStartAngle;
282
+ aStartAngle = aEndAngle;
283
+ aEndAngle = t;
284
+ }
285
+
286
+ var xStart = aX + (Math.cos(aStartAngle) * aRadius);
287
+ var yStart = aY + (Math.sin(aStartAngle) * aRadius);
288
+
289
+ var xEnd = aX + (Math.cos(aEndAngle) * aRadius);
290
+ var yEnd = aY + (Math.sin(aEndAngle) * aRadius);
291
+
292
+ this.currentPath_.push({type: "arc",
293
+ x: aX,
294
+ y: aY,
295
+ radius: aRadius,
296
+ xStart: xStart,
297
+ yStart: yStart,
298
+ xEnd: xEnd,
299
+ yEnd: yEnd});
300
+
301
+ };
302
+
303
+ contextPrototype.rect = function(aX, aY, aWidth, aHeight) {
304
+ this.moveTo(aX, aY);
305
+ this.lineTo(aX + aWidth, aY);
306
+ this.lineTo(aX + aWidth, aY + aHeight);
307
+ this.lineTo(aX, aY + aHeight);
308
+ this.closePath();
309
+ };
310
+
311
+ contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) {
312
+ // Will destroy any existing path (same as FF behaviour)
313
+ this.beginPath();
314
+ this.moveTo(aX, aY);
315
+ this.lineTo(aX + aWidth, aY);
316
+ this.lineTo(aX + aWidth, aY + aHeight);
317
+ this.lineTo(aX, aY + aHeight);
318
+ this.closePath();
319
+ this.stroke();
320
+ };
321
+
322
+ contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) {
323
+ // Will destroy any existing path (same as FF behaviour)
324
+ this.beginPath();
325
+ this.moveTo(aX, aY);
326
+ this.lineTo(aX + aWidth, aY);
327
+ this.lineTo(aX + aWidth, aY + aHeight);
328
+ this.lineTo(aX, aY + aHeight);
329
+ this.closePath();
330
+ this.fill();
331
+ };
332
+
333
+ contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) {
334
+ var gradient = new CanvasGradient_("gradient");
335
+ return gradient;
336
+ };
337
+
338
+ contextPrototype.createRadialGradient = function(aX0, aY0,
339
+ aR0, aX1,
340
+ aY1, aR1) {
341
+ var gradient = new CanvasGradient_("gradientradial");
342
+ gradient.radius1_ = aR0;
343
+ gradient.radius2_ = aR1;
344
+ gradient.focus_.x = aX0;
345
+ gradient.focus_.y = aY0;
346
+ return gradient;
347
+ };
348
+
349
+ contextPrototype.drawImage = function (image, var_args) {
350
+ var dx, dy, dw, dh, sx, sy, sw, sh;
351
+ var w = image.width;
352
+ var h = image.height;
353
+
354
+ if (arguments.length == 3) {
355
+ dx = arguments[1];
356
+ dy = arguments[2];
357
+ sx = sy = 0;
358
+ sw = dw = w;
359
+ sh = dh = h;
360
+ } else if (arguments.length == 5) {
361
+ dx = arguments[1];
362
+ dy = arguments[2];
363
+ dw = arguments[3];
364
+ dh = arguments[4];
365
+ sx = sy = 0;
366
+ sw = w;
367
+ sh = h;
368
+ } else if (arguments.length == 9) {
369
+ sx = arguments[1];
370
+ sy = arguments[2];
371
+ sw = arguments[3];
372
+ sh = arguments[4];
373
+ dx = arguments[5];
374
+ dy = arguments[6];
375
+ dw = arguments[7];
376
+ dh = arguments[8];
377
+ } else {
378
+ throw "Invalid number of arguments";
379
+ }
380
+
381
+ var d = this.getCoords_(dx, dy);
382
+
383
+ var w2 = (sw / 2);
384
+ var h2 = (sh / 2);
385
+
386
+ var vmlStr = [];
387
+
388
+ // For some reason that I've now forgotten, using divs didn't work
389
+ vmlStr.push(' <g_vml_:group',
390
+ ' coordsize="100,100"',
391
+ ' coordorigin="0, 0"' ,
392
+ ' style="width:100px;height:100px;position:absolute;');
393
+
394
+ // If filters are necessary (rotation exists), create them
395
+ // filters are bog-slow, so only create them if abbsolutely necessary
396
+ // The following check doesn't account for skews (which don't exist
397
+ // in the canvas spec (yet) anyway.
398
+
399
+ if (this.m_[0][0] != 1 || this.m_[0][1]) {
400
+ var filter = [];
401
+
402
+ // Note the 12/21 reversal
403
+ filter.push("M11='", this.m_[0][0], "',",
404
+ "M12='", this.m_[1][0], "',",
405
+ "M21='", this.m_[0][1], "',",
406
+ "M22='", this.m_[1][1], "',",
407
+ "Dx='", d.x, "',",
408
+ "Dy='", d.y, "'");
409
+
410
+ // Bounding box calculation (need to minimize displayed area so that
411
+ // filters don't waste time on unused pixels.
412
+ var max = d;
413
+ var c2 = this.getCoords_(dx+dw, dy);
414
+ var c3 = this.getCoords_(dx, dy+dh);
415
+ var c4 = this.getCoords_(dx+dw, dy+dh);
416
+
417
+ max.x = Math.max(max.x, c2.x, c3.x, c4.x);
418
+ max.y = Math.max(max.y, c2.y, c3.y, c4.y);
419
+
420
+ vmlStr.push(" padding:0 ", Math.floor(max.x), "px ", Math.floor(max.y),
421
+ "px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",
422
+ filter.join(""), ", sizingmethod='clip');")
423
+ } else {
424
+ vmlStr.push(" top:", d.y, "px;left:", d.x, "px;")
425
+ }
426
+
427
+ vmlStr.push(' ">' ,
428
+ '<g_vml_:image src="', image.src, '"',
429
+ ' style="width:', dw, ';',
430
+ ' height:', dh, ';"',
431
+ ' cropleft="', sx / w, '"',
432
+ ' croptop="', sy / h, '"',
433
+ ' cropright="', (w - sx - sw) / w, '"',
434
+ ' cropbottom="', (h - sy - sh) / h, '"',
435
+ ' />',
436
+ '</g_vml_:group>');
437
+
438
+ this.element_.insertAdjacentHTML("BeforeEnd",
439
+ vmlStr.join(""));
440
+ };
441
+
442
+ contextPrototype.stroke = function(aFill) {
443
+ var lineStr = [];
444
+ var lineOpen = false;
445
+ var a = processStyle(aFill ? this.fillStyle : this.strokeStyle);
446
+ var color = a[0];
447
+ var opacity = a[1] * this.globalAlpha;
448
+
449
+ lineStr.push('<g_vml_:shape',
450
+ ' fillcolor="', color, '"',
451
+ ' filled="', Boolean(aFill), '"',
452
+ ' style="position:absolute;width:10;height:10;"',
453
+ ' coordorigin="0 0" coordsize="10 10"',
454
+ ' stroked="', !aFill, '"',
455
+ ' strokeweight="', this.lineWidth, '"',
456
+ ' strokecolor="', color, '"',
457
+ ' path="');
458
+
459
+ var newSeq = false;
460
+ var min = {x: null, y: null};
461
+ var max = {x: null, y: null};
462
+
463
+ for (var i = 0; i < this.currentPath_.length; i++) {
464
+ var p = this.currentPath_[i];
465
+
466
+ if (p.type == "moveTo") {
467
+ lineStr.push(" m ");
468
+ var c = this.getCoords_(p.x, p.y);
469
+ lineStr.push(Math.floor(c.x), ",", Math.floor(c.y));
470
+ } else if (p.type == "lineTo") {
471
+ lineStr.push(" l ");
472
+ var c = this.getCoords_(p.x, p.y);
473
+ lineStr.push(Math.floor(c.x), ",", Math.floor(c.y));
474
+ } else if (p.type == "close") {
475
+ lineStr.push(" x ");
476
+ } else if (p.type == "bezierCurveTo") {
477
+ lineStr.push(" c ");
478
+ var c = this.getCoords_(p.x, p.y);
479
+ var c1 = this.getCoords_(p.cp1x, p.cp1y);
480
+ var c2 = this.getCoords_(p.cp2x, p.cp2y);
481
+ lineStr.push(Math.floor(c1.x), ",", Math.floor(c1.y), ",",
482
+ Math.floor(c2.x), ",", Math.floor(c2.y), ",",
483
+ Math.floor(c.x), ",", Math.floor(c.y));
484
+ } else if (p.type == "arc") {
485
+ lineStr.push(" ar ");
486
+ var c = this.getCoords_(p.x, p.y);
487
+ var cStart = this.getCoords_(p.xStart, p.yStart);
488
+ var cEnd = this.getCoords_(p.xEnd, p.yEnd);
489
+
490
+ // TODO: FIX (matricies (scale+rotation) now buggered this up)
491
+ // VML arc also doesn't seem able to do rotated non-circular
492
+ // arcs without parent grouping.
493
+ var absXScale = this.m_[0][0];
494
+ var absYScale = this.m_[1][1];
495
+
496
+ lineStr.push(Math.floor(c.x - absXScale * p.radius), ",",
497
+ Math.floor(c.y - absYScale * p.radius), " ",
498
+ Math.floor(c.x + absXScale * p.radius), ",",
499
+ Math.floor(c.y + absYScale * p.radius), " ",
500
+ Math.floor(cStart.x), ",", Math.floor(cStart.y), " ",
501
+ Math.floor(cEnd.x), ",", Math.floor(cEnd.y));
502
+ }
503
+
504
+
505
+ // TODO: Following is broken for curves due to
506
+ // move to proper paths.
507
+
508
+ // Figure out dimensions so we can do gradient fills
509
+ // properly
510
+ if(c) {
511
+ if (min.x == null || c.x < min.x) {
512
+ min.x = c.x;
513
+ }
514
+ if (max.x == null || c.x > max.x) {
515
+ max.x = c.x;
516
+ }
517
+ if (min.y == null || c.y < min.y) {
518
+ min.y = c.y;
519
+ }
520
+ if (max.y == null || c.y > max.y) {
521
+ max.y = c.y;
522
+ }
523
+ }
524
+ }
525
+ lineStr.push(' ">');
526
+
527
+ if (typeof this.fillStyle == "object") {
528
+ var focus = {x: "50%", y: "50%"};
529
+ var width = (max.x - min.x);
530
+ var height = (max.y - min.y);
531
+ var dimension = (width > height) ? width : height;
532
+
533
+ focus.x = Math.floor((this.fillStyle.focus_.x / width) * 100 + 50) + "%";
534
+ focus.y = Math.floor((this.fillStyle.focus_.y / height) * 100 + 50) + "%";
535
+
536
+ var colors = [];
537
+
538
+ // inside radius (%)
539
+ if (this.fillStyle.type_ == "gradientradial") {
540
+ var inside = (this.fillStyle.radius1_ / dimension * 100);
541
+
542
+ // percentage that outside radius exceeds inside radius
543
+ var expansion = (this.fillStyle.radius2_ / dimension * 100) - inside;
544
+ } else {
545
+ var inside = 0;
546
+ var expansion = 100;
547
+ }
548
+
549
+ var insidecolor = {offset: null, color: null};
550
+ var outsidecolor = {offset: null, color: null};
551
+
552
+ // We need to sort 'colors' by percentage, from 0 > 100 otherwise ie
553
+ // won't interpret it correctly
554
+ this.fillStyle.colors_.sort(function (cs1, cs2) {
555
+ return cs1.offset - cs2.offset;
556
+ });
557
+
558
+ for (var i = 0; i < this.fillStyle.colors_.length; i++) {
559
+ var fs = this.fillStyle.colors_[i];
560
+
561
+ colors.push( (fs.offset * expansion) + inside, "% ", fs.color, ",");
562
+
563
+ if (fs.offset > insidecolor.offset || insidecolor.offset == null) {
564
+ insidecolor.offset = fs.offset;
565
+ insidecolor.color = fs.color;
566
+ }
567
+
568
+ if (fs.offset < outsidecolor.offset || outsidecolor.offset == null) {
569
+ outsidecolor.offset = fs.offset;
570
+ outsidecolor.color = fs.color;
571
+ }
572
+ }
573
+ colors.pop();
574
+
575
+ lineStr.push('<g_vml_:fill',
576
+ ' color="', outsidecolor.color, '"',
577
+ ' color2="', insidecolor.color, '"',
578
+ ' type="', this.fillStyle.type_, '"',
579
+ ' focusposition="', focus.x, ', ', focus.y, '"',
580
+ ' colors="', colors.join(""), '"',
581
+ ' opacity="', opacity, '" />');
582
+ } else if (aFill) {
583
+ lineStr.push('<g_vml_:fill color="', color, '" opacity="', opacity, '" />');
584
+ } else {
585
+ lineStr.push(
586
+ '<g_vml_:stroke',
587
+ ' opacity="', opacity,'"',
588
+ ' joinstyle="', this.lineJoin, '"',
589
+ ' miterlimit="', this.miterLimit, '"',
590
+ ' endcap="', processLineCap(this.lineCap) ,'"',
591
+ ' weight="', this.lineWidth, 'px"',
592
+ ' color="', color,'" />'
593
+ );
594
+ }
595
+
596
+ lineStr.push("</g_vml_:shape>");
597
+
598
+ this.element_.insertAdjacentHTML("beforeEnd", lineStr.join(""));
599
+
600
+ this.currentPath_ = [];
601
+ };
602
+
603
+ contextPrototype.fill = function() {
604
+ this.stroke(true);
605
+ }
606
+
607
+ contextPrototype.closePath = function() {
608
+ this.currentPath_.push({type: "close"});
609
+ };
610
+
611
+ /**
612
+ * @private
613
+ */
614
+ contextPrototype.getCoords_ = function(aX, aY) {
615
+ return {
616
+ x: (aX * this.m_[0][0] + aY * this.m_[1][0] + this.m_[2][0]),
617
+ y: (aX * this.m_[0][1] + aY * this.m_[1][1] + this.m_[2][1])
618
+ }
619
+ };
620
+
621
+ contextPrototype.save = function() {
622
+ var o = {};
623
+ copyState(this, o);
624
+ this.aStack_.push(o);
625
+ this.mStack_.push(this.m_);
626
+ this.m_ = matrixMultiply(createMatrixIdentity(), this.m_);
627
+ };
628
+
629
+ contextPrototype.restore = function() {
630
+ copyState(this.aStack_.pop(), this);
631
+ this.m_ = this.mStack_.pop();
632
+ };
633
+
634
+ contextPrototype.translate = function(aX, aY) {
635
+ var m1 = [
636
+ [1, 0, 0],
637
+ [0, 1, 0],
638
+ [aX, aY, 1]
639
+ ];
640
+
641
+ this.m_ = matrixMultiply(m1, this.m_);
642
+ };
643
+
644
+ contextPrototype.rotate = function(aRot) {
645
+ var c = Math.cos(aRot);
646
+ var s = Math.sin(aRot);
647
+
648
+ var m1 = [
649
+ [c, s, 0],
650
+ [-s, c, 0],
651
+ [0, 0, 1]
652
+ ];
653
+
654
+ this.m_ = matrixMultiply(m1, this.m_);
655
+ };
656
+
657
+ contextPrototype.scale = function(aX, aY) {
658
+ var m1 = [
659
+ [aX, 0, 0],
660
+ [0, aY, 0],
661
+ [0, 0, 1]
662
+ ];
663
+
664
+ this.m_ = matrixMultiply(m1, this.m_);
665
+ };
666
+
667
+ /******** STUBS ********/
668
+ contextPrototype.clip = function() {
669
+ // TODO: Implement
670
+ };
671
+
672
+ contextPrototype.arcTo = function() {
673
+ // TODO: Implement
674
+ };
675
+
676
+ contextPrototype.createPattern = function() {
677
+ return new CanvasPattern_;
678
+ };
679
+
680
+ // Gradient / Pattern Stubs
681
+ function CanvasGradient_(aType) {
682
+ this.type_ = aType;
683
+ this.radius1_ = 0;
684
+ this.radius2_ = 0;
685
+ this.colors_ = [];
686
+ this.focus_ = {x: 0, y: 0};
687
+ }
688
+
689
+ CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) {
690
+ aColor = processStyle(aColor);
691
+ this.colors_.push({offset: 1-aOffset, color: aColor});
692
+ };
693
+
694
+ function CanvasPattern_() {}
695
+
696
+ // set up externs
697
+ G_vmlCanvasManager = G_vmlCanvasManager_;
698
+ CanvasRenderingContext2D = CanvasRenderingContext2D_;
699
+ CanvasGradient = CanvasGradient_;
700
+ CanvasPattern = CanvasPattern_;
701
+
702
+ })();
703
+
704
+ } // if