gfx.js.uncompressed.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. require({cache:{
  2. 'dojox/gfx/_base':function(){
  3. define(["dojo/_base/lang", "dojo/_base/html", "dojo/_base/Color", "dojo/_base/sniff", "dojo/_base/window",
  4. "dojo/_base/array","dojo/dom", "dojo/dom-construct","dojo/dom-geometry"],
  5. function(lang, html, Color, has, win, arr, dom, domConstruct, domGeom){
  6. // module:
  7. // dojox/gfx
  8. // summary:
  9. // This module contains common core Graphics API used by different graphics renderers.
  10. var g = lang.getObject("dojox.gfx", true),
  11. b = g._base = {};
  12. /*===== g = dojox.gfx; b = dojox.gfx._base; =====*/
  13. // candidates for dojox.style (work on VML and SVG nodes)
  14. g._hasClass = function(/*DomNode*/node, /*String*/classStr){
  15. // summary:
  16. // Returns whether or not the specified classes are a portion of the
  17. // class list currently applied to the node.
  18. // return (new RegExp('(^|\\s+)'+classStr+'(\\s+|$)')).test(node.className) // Boolean
  19. var cls = node.getAttribute("className");
  20. return cls && (" " + cls + " ").indexOf(" " + classStr + " ") >= 0; // Boolean
  21. };
  22. g._addClass = function(/*DomNode*/node, /*String*/classStr){
  23. // summary:
  24. // Adds the specified classes to the end of the class list on the
  25. // passed node.
  26. var cls = node.getAttribute("className") || "";
  27. if(!cls || (" " + cls + " ").indexOf(" " + classStr + " ") < 0){
  28. node.setAttribute("className", cls + (cls ? " " : "") + classStr);
  29. }
  30. };
  31. g._removeClass = function(/*DomNode*/node, /*String*/classStr){
  32. // summary: Removes classes from node.
  33. var cls = node.getAttribute("className");
  34. if(cls){
  35. node.setAttribute(
  36. "className",
  37. cls.replace(new RegExp('(^|\\s+)' + classStr + '(\\s+|$)'), "$1$2")
  38. );
  39. }
  40. };
  41. // candidate for dojox.html.metrics (dynamic font resize handler is not implemented here)
  42. // derived from Morris John's emResized measurer
  43. b._getFontMeasurements = function(){
  44. // summary:
  45. // Returns an object that has pixel equivilents of standard font
  46. // size values.
  47. var heights = {
  48. '1em': 0, '1ex': 0, '100%': 0, '12pt': 0, '16px': 0, 'xx-small': 0,
  49. 'x-small': 0, 'small': 0, 'medium': 0, 'large': 0, 'x-large': 0,
  50. 'xx-large': 0
  51. };
  52. var p;
  53. if(has("ie")){
  54. // we do a font-size fix if and only if one isn't applied already.
  55. // NOTE: If someone set the fontSize on the HTML Element, this will kill it.
  56. win.doc.documentElement.style.fontSize="100%";
  57. }
  58. // set up the measuring node.
  59. var div = domConstruct.create("div", {style: {
  60. position: "absolute",
  61. left: "0",
  62. top: "-100px",
  63. width: "30px",
  64. height: "1000em",
  65. borderWidth: "0",
  66. margin: "0",
  67. padding: "0",
  68. outline: "none",
  69. lineHeight: "1",
  70. overflow: "hidden"
  71. }}, win.body());
  72. // do the measurements.
  73. for(p in heights){
  74. div.style.fontSize = p;
  75. heights[p] = Math.round(div.offsetHeight * 12/16) * 16/12 / 1000;
  76. }
  77. win.body().removeChild(div);
  78. return heights; //object
  79. };
  80. var fontMeasurements = null;
  81. b._getCachedFontMeasurements = function(recalculate){
  82. if(recalculate || !fontMeasurements){
  83. fontMeasurements = b._getFontMeasurements();
  84. }
  85. return fontMeasurements;
  86. };
  87. // candidate for dojox.html.metrics
  88. var measuringNode = null, empty = {};
  89. b._getTextBox = function( /*String*/ text,
  90. /*Object*/ style,
  91. /*String?*/ className){
  92. var m, s, al = arguments.length;
  93. var i;
  94. if(!measuringNode){
  95. measuringNode = domConstruct.create("div", {style: {
  96. position: "absolute",
  97. top: "-10000px",
  98. left: "0"
  99. }}, win.body());
  100. }
  101. m = measuringNode;
  102. // reset styles
  103. m.className = "";
  104. s = m.style;
  105. s.borderWidth = "0";
  106. s.margin = "0";
  107. s.padding = "0";
  108. s.outline = "0";
  109. // set new style
  110. if(al > 1 && style){
  111. for(i in style){
  112. if(i in empty){ continue; }
  113. s[i] = style[i];
  114. }
  115. }
  116. // set classes
  117. if(al > 2 && className){
  118. m.className = className;
  119. }
  120. // take a measure
  121. m.innerHTML = text;
  122. if(m["getBoundingClientRect"]){
  123. var bcr = m.getBoundingClientRect();
  124. return {l: bcr.left, t: bcr.top, w: bcr.width || (bcr.right - bcr.left), h: bcr.height || (bcr.bottom - bcr.top)};
  125. }else{
  126. return domGeom.getMarginBox(m);
  127. }
  128. };
  129. // candidate for dojo.dom
  130. var uniqueId = 0;
  131. b._getUniqueId = function(){
  132. // summary: returns a unique string for use with any DOM element
  133. var id;
  134. do{
  135. id = dojo._scopeName + "xUnique" + (++uniqueId);
  136. }while(dom.byId(id));
  137. return id;
  138. };
  139. lang.mixin(g, {
  140. // summary:
  141. // defines constants, prototypes, and utility functions for the core Graphics API
  142. // default shapes, which are used to fill in missing parameters
  143. defaultPath: {
  144. // summary:
  145. // Defines the default Path prototype object.
  146. type: "path",
  147. // type: String
  148. // Specifies this object is a Path, default value 'path'.
  149. path: ""
  150. // path: String
  151. // The path commands. See W32C SVG 1.0 specification.
  152. // Defaults to empty string value.
  153. },
  154. defaultPolyline: {
  155. // summary:
  156. // Defines the default PolyLine prototype.
  157. type: "polyline",
  158. // type: String
  159. // Specifies this object is a PolyLine, default value 'polyline'.
  160. points: []
  161. // points: Array
  162. // An array of point objects [{x:0,y:0},...] defining the default polyline's line segments. Value is an empty array [].
  163. },
  164. defaultRect: {
  165. // summary:
  166. // Defines the default Rect prototype.
  167. type: "rect",
  168. // type: String
  169. // Specifies this default object is a type of Rect. Value is 'rect'
  170. x: 0,
  171. // x: Number
  172. // The X coordinate of the default rectangles position, value 0.
  173. y: 0,
  174. // y: Number
  175. // The Y coordinate of the default rectangle's position, value 0.
  176. width: 100,
  177. // width: Number
  178. // The width of the default rectangle, value 100.
  179. height: 100,
  180. // height: Number
  181. // The height of the default rectangle, value 100.
  182. r: 0
  183. // r: Number
  184. // The corner radius for the default rectangle, value 0.
  185. },
  186. defaultEllipse: {
  187. // summary:
  188. // Defines the default Ellipse prototype.
  189. type: "ellipse",
  190. // type: String
  191. // Specifies that this object is a type of Ellipse, value is 'ellipse'
  192. cx: 0,
  193. // cx: Number
  194. // The X coordinate of the center of the ellipse, default value 0.
  195. cy: 0,
  196. // cy: Number
  197. // The Y coordinate of the center of the ellipse, default value 0.
  198. rx: 200,
  199. // rx: Number
  200. // The radius of the ellipse in the X direction, default value 200.
  201. ry: 100
  202. // ry: Number
  203. // The radius of the ellipse in the Y direction, default value 200.
  204. },
  205. defaultCircle: {
  206. // summary:
  207. // An object defining the default Circle prototype.
  208. type: "circle",
  209. // type: String
  210. // Specifies this object is a circle, value 'circle'
  211. cx: 0,
  212. // cx: Number
  213. // The X coordinate of the center of the circle, default value 0.
  214. cy: 0,
  215. // cy: Number
  216. // The Y coordinate of the center of the circle, default value 0.
  217. r: 100
  218. // r: Number
  219. // The radius, default value 100.
  220. },
  221. defaultLine: {
  222. // summary:
  223. // An pbject defining the default Line prototype.
  224. type: "line",
  225. // type: String
  226. // Specifies this is a Line, value 'line'
  227. x1: 0,
  228. // x1: Number
  229. // The X coordinate of the start of the line, default value 0.
  230. y1: 0,
  231. // y1: Number
  232. // The Y coordinate of the start of the line, default value 0.
  233. x2: 100,
  234. // x2: Number
  235. // The X coordinate of the end of the line, default value 100.
  236. y2: 100
  237. // y2: Number
  238. // The Y coordinate of the end of the line, default value 100.
  239. },
  240. defaultImage: {
  241. // summary:
  242. // Defines the default Image prototype.
  243. type: "image",
  244. // type: String
  245. // Specifies this object is an image, value 'image'.
  246. x: 0,
  247. // x: Number
  248. // The X coordinate of the image's position, default value 0.
  249. y: 0,
  250. // y: Number
  251. // The Y coordinate of the image's position, default value 0.
  252. width: 0,
  253. // width: Number
  254. // The width of the image, default value 0.
  255. height: 0,
  256. // height:Number
  257. // The height of the image, default value 0.
  258. src: ""
  259. // src: String
  260. // The src url of the image, defaults to empty string.
  261. },
  262. defaultText: {
  263. // summary:
  264. // Defines the default Text prototype.
  265. type: "text",
  266. // type: String
  267. // Specifies this is a Text shape, value 'text'.
  268. x: 0,
  269. // x: Number
  270. // The X coordinate of the text position, default value 0.
  271. y: 0,
  272. // y: Number
  273. // The Y coordinate of the text position, default value 0.
  274. text: "",
  275. // text: String
  276. // The text to be displayed, default value empty string.
  277. align: "start",
  278. // align: String
  279. // The horizontal text alignment, one of 'start', 'end', 'center'. Default value 'start'.
  280. decoration: "none",
  281. // decoration: String
  282. // The text decoration , one of 'none', ... . Default value 'none'.
  283. rotated: false,
  284. // rotated: Boolean
  285. // Whether the text is rotated, boolean default value false.
  286. kerning: true
  287. // kerning: Boolean
  288. // Whether kerning is used on the text, boolean default value true.
  289. },
  290. defaultTextPath: {
  291. // summary:
  292. // Defines the default TextPath prototype.
  293. type: "textpath",
  294. // type: String
  295. // Specifies this is a TextPath, value 'textpath'.
  296. text: "",
  297. // text: String
  298. // The text to be displayed, default value empty string.
  299. align: "start",
  300. // align: String
  301. // The horizontal text alignment, one of 'start', 'end', 'center'. Default value 'start'.
  302. decoration: "none",
  303. // decoration: String
  304. // The text decoration , one of 'none', ... . Default value 'none'.
  305. rotated: false,
  306. // rotated: Boolean
  307. // Whether the text is rotated, boolean default value false.
  308. kerning: true
  309. // kerning: Boolean
  310. // Whether kerning is used on the text, boolean default value true.
  311. },
  312. // default stylistic attributes
  313. defaultStroke: {
  314. // summary:
  315. // A stroke defines stylistic properties that are used when drawing a path.
  316. // This object defines the default Stroke prototype.
  317. type: "stroke",
  318. // type: String
  319. // Specifies this object is a type of Stroke, value 'stroke'.
  320. color: "black",
  321. // color: String
  322. // The color of the stroke, default value 'black'.
  323. style: "solid",
  324. // style: String
  325. // The style of the stroke, one of 'solid', ... . Default value 'solid'.
  326. width: 1,
  327. // width: Number
  328. // The width of a stroke, default value 1.
  329. cap: "butt",
  330. // cap: String
  331. // The endcap style of the path. One of 'butt', 'round', ... . Default value 'butt'.
  332. join: 4
  333. // join: Number
  334. // The join style to use when combining path segments. Default value 4.
  335. },
  336. defaultLinearGradient: {
  337. // summary:
  338. // An object defining the default stylistic properties used for Linear Gradient fills.
  339. // Linear gradients are drawn along a virtual line, which results in appearance of a rotated pattern in a given direction/orientation.
  340. type: "linear",
  341. // type: String
  342. // Specifies this object is a Linear Gradient, value 'linear'
  343. x1: 0,
  344. // x1: Number
  345. // The X coordinate of the start of the virtual line along which the gradient is drawn, default value 0.
  346. y1: 0,
  347. // y1: Number
  348. // The Y coordinate of the start of the virtual line along which the gradient is drawn, default value 0.
  349. x2: 100,
  350. // x2: Number
  351. // The X coordinate of the end of the virtual line along which the gradient is drawn, default value 100.
  352. y2: 100,
  353. // y2: Number
  354. // The Y coordinate of the end of the virtual line along which the gradient is drawn, default value 100.
  355. colors: [
  356. { offset: 0, color: "black" }, { offset: 1, color: "white" }
  357. ]
  358. // colors: Array
  359. // An array of colors at given offsets (from the start of the line). The start of the line is
  360. // defined at offest 0 with the end of the line at offset 1.
  361. // Default value, [{ offset: 0, color: 'black'},{offset: 1, color: 'white'}], is a gradient from black to white.
  362. },
  363. defaultRadialGradient: {
  364. // summary:
  365. // An object specifying the default properties for RadialGradients using in fills patterns.
  366. type: "radial",
  367. // type: String
  368. // Specifies this is a RadialGradient, value 'radial'
  369. cx: 0,
  370. // cx: Number
  371. // The X coordinate of the center of the radial gradient, default value 0.
  372. cy: 0,
  373. // cy: Number
  374. // The Y coordinate of the center of the radial gradient, default value 0.
  375. r: 100,
  376. // r: Number
  377. // The radius to the end of the radial gradient, default value 100.
  378. colors: [
  379. { offset: 0, color: "black" }, { offset: 1, color: "white" }
  380. ]
  381. // colors: Array
  382. // An array of colors at given offsets (from the center of the radial gradient).
  383. // The center is defined at offest 0 with the outer edge of the gradient at offset 1.
  384. // Default value, [{ offset: 0, color: 'black'},{offset: 1, color: 'white'}], is a gradient from black to white.
  385. },
  386. defaultPattern: {
  387. // summary:
  388. // An object specifying the default properties for a Pattern using in fill operations.
  389. type: "pattern",
  390. // type: String
  391. // Specifies this object is a Pattern, value 'pattern'.
  392. x: 0,
  393. // x: Number
  394. // The X coordinate of the position of the pattern, default value is 0.
  395. y: 0,
  396. // y: Number
  397. // The Y coordinate of the position of the pattern, default value is 0.
  398. width: 0,
  399. // width: Number
  400. // The width of the pattern image, default value is 0.
  401. height: 0,
  402. // height: Number
  403. // The height of the pattern image, default value is 0.
  404. src: ""
  405. // src: String
  406. // A url specifing the image to use for the pattern.
  407. },
  408. defaultFont: {
  409. // summary:
  410. // An object specifying the default properties for a Font used in text operations.
  411. type: "font",
  412. // type: String
  413. // Specifies this object is a Font, value 'font'.
  414. style: "normal",
  415. // style: String
  416. // The font style, one of 'normal', 'bold', default value 'normal'.
  417. variant: "normal",
  418. // variant: String
  419. // The font variant, one of 'normal', ... , default value 'normal'.
  420. weight: "normal",
  421. // weight: String
  422. // The font weight, one of 'normal', ..., default value 'normal'.
  423. size: "10pt",
  424. // size: String
  425. // The font size (including units), default value '10pt'.
  426. family: "serif"
  427. // family: String
  428. // The font family, one of 'serif', 'sanserif', ..., default value 'serif'.
  429. },
  430. getDefault: (function(){
  431. // summary:
  432. // Returns a function used to access default memoized prototype objects (see them defined above).
  433. var typeCtorCache = {};
  434. // a memoized delegate()
  435. return function(/*String*/ type){
  436. var t = typeCtorCache[type];
  437. if(t){
  438. return new t();
  439. }
  440. t = typeCtorCache[type] = new Function();
  441. t.prototype = g[ "default" + type ];
  442. return new t();
  443. }
  444. })(),
  445. normalizeColor: function(/*dojo.Color|Array|string|Object*/ color){
  446. // summary:
  447. // converts any legal color representation to normalized
  448. // dojo.Color object
  449. return (color instanceof Color) ? color : new Color(color); // dojo.Color
  450. },
  451. normalizeParameters: function(existed, update){
  452. // summary:
  453. // updates an existing object with properties from an 'update'
  454. // object
  455. // existed: Object
  456. // the target object to be updated
  457. // update: Object
  458. // the 'update' object, whose properties will be used to update
  459. // the existed object
  460. var x;
  461. if(update){
  462. var empty = {};
  463. for(x in existed){
  464. if(x in update && !(x in empty)){
  465. existed[x] = update[x];
  466. }
  467. }
  468. }
  469. return existed; // Object
  470. },
  471. makeParameters: function(defaults, update){
  472. // summary:
  473. // copies the original object, and all copied properties from the
  474. // 'update' object
  475. // defaults: Object
  476. // the object to be cloned before updating
  477. // update: Object
  478. // the object, which properties are to be cloned during updating
  479. var i = null;
  480. if(!update){
  481. // return dojo.clone(defaults);
  482. return lang.delegate(defaults);
  483. }
  484. var result = {};
  485. for(i in defaults){
  486. if(!(i in result)){
  487. result[i] = lang.clone((i in update) ? update[i] : defaults[i]);
  488. }
  489. }
  490. return result; // Object
  491. },
  492. formatNumber: function(x, addSpace){
  493. // summary: converts a number to a string using a fixed notation
  494. // x: Number
  495. // number to be converted
  496. // addSpace: Boolean
  497. // whether to add a space before a positive number
  498. var val = x.toString();
  499. if(val.indexOf("e") >= 0){
  500. val = x.toFixed(4);
  501. }else{
  502. var point = val.indexOf(".");
  503. if(point >= 0 && val.length - point > 5){
  504. val = x.toFixed(4);
  505. }
  506. }
  507. if(x < 0){
  508. return val; // String
  509. }
  510. return addSpace ? " " + val : val; // String
  511. },
  512. // font operations
  513. makeFontString: function(font){
  514. // summary: converts a font object to a CSS font string
  515. // font: Object: font object (see dojox.gfx.defaultFont)
  516. return font.style + " " + font.variant + " " + font.weight + " " + font.size + " " + font.family; // Object
  517. },
  518. splitFontString: function(str){
  519. // summary:
  520. // converts a CSS font string to a font object
  521. // description:
  522. // Converts a CSS font string to a gfx font object. The CSS font
  523. // string components should follow the W3C specified order
  524. // (see http://www.w3.org/TR/CSS2/fonts.html#font-shorthand):
  525. // style, variant, weight, size, optional line height (will be
  526. // ignored), and family.
  527. // str: String
  528. // a CSS font string
  529. var font = g.getDefault("Font");
  530. var t = str.split(/\s+/);
  531. do{
  532. if(t.length < 5){ break; }
  533. font.style = t[0];
  534. font.variant = t[1];
  535. font.weight = t[2];
  536. var i = t[3].indexOf("/");
  537. font.size = i < 0 ? t[3] : t[3].substring(0, i);
  538. var j = 4;
  539. if(i < 0){
  540. if(t[4] == "/"){
  541. j = 6;
  542. }else if(t[4].charAt(0) == "/"){
  543. j = 5;
  544. }
  545. }
  546. if(j < t.length){
  547. font.family = t.slice(j).join(" ");
  548. }
  549. }while(false);
  550. return font; // Object
  551. },
  552. // length operations
  553. cm_in_pt: 72 / 2.54,
  554. // cm_in_pt: Number
  555. // points per centimeter (constant)
  556. mm_in_pt: 7.2 / 2.54,
  557. // mm_in_pt: Number
  558. // points per millimeter (constant)
  559. px_in_pt: function(){
  560. // summary: returns the current number of pixels per point.
  561. return g._base._getCachedFontMeasurements()["12pt"] / 12; // Number
  562. },
  563. pt2px: function(len){
  564. // summary: converts points to pixels
  565. // len: Number
  566. // a value in points
  567. return len * g.px_in_pt(); // Number
  568. },
  569. px2pt: function(len){
  570. // summary: converts pixels to points
  571. // len: Number
  572. // a value in pixels
  573. return len / g.px_in_pt(); // Number
  574. },
  575. normalizedLength: function(len) {
  576. // summary: converts any length value to pixels
  577. // len: String
  578. // a length, e.g., '12pc'
  579. if(len.length === 0){ return 0; }
  580. if(len.length > 2){
  581. var px_in_pt = g.px_in_pt();
  582. var val = parseFloat(len);
  583. switch(len.slice(-2)){
  584. case "px": return val;
  585. case "pt": return val * px_in_pt;
  586. case "in": return val * 72 * px_in_pt;
  587. case "pc": return val * 12 * px_in_pt;
  588. case "mm": return val * g.mm_in_pt * px_in_pt;
  589. case "cm": return val * g.cm_in_pt * px_in_pt;
  590. }
  591. }
  592. return parseFloat(len); // Number
  593. },
  594. pathVmlRegExp: /([A-Za-z]+)|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g,
  595. // pathVmlRegExp: RegExp
  596. // a constant regular expression used to split a SVG/VML path into primitive components
  597. pathSvgRegExp: /([A-Za-z])|(\d+(\.\d+)?)|(\.\d+)|(-\d+(\.\d+)?)|(-\.\d+)/g,
  598. // pathVmlRegExp: RegExp
  599. // a constant regular expression used to split a SVG/VML path into primitive components
  600. equalSources: function(a /*Object*/, b /*Object*/){
  601. // summary: compares event sources, returns true if they are equal
  602. // a: first event source
  603. // b: event source to compare against a
  604. return a && b && a === b;
  605. },
  606. switchTo: function(renderer/*String|Object*/){
  607. // summary: switch the graphics implementation to the specified renderer.
  608. // renderer:
  609. // Either the string name of a renderer (eg. 'canvas', 'svg, ...) or the renderer
  610. // object to switch to.
  611. var ns = typeof renderer == "string" ? g[renderer] : renderer;
  612. if(ns){
  613. arr.forEach(["Group", "Rect", "Ellipse", "Circle", "Line",
  614. "Polyline", "Image", "Text", "Path", "TextPath",
  615. "Surface", "createSurface", "fixTarget"], function(name){
  616. g[name] = ns[name];
  617. });
  618. }
  619. }
  620. });
  621. return g; // defaults object api
  622. });
  623. },
  624. 'dojox/gfx/renderer':function(){
  625. define("dojox/gfx/renderer", ["./_base","dojo/_base/lang", "dojo/_base/sniff", "dojo/_base/window", "dojo/_base/config"],
  626. function(g, lang, has, win, config){
  627. //>> noBuildResolver
  628. /*=====
  629. dojox.gfx.renderer = {
  630. // summary:
  631. // This module is an AMD loader plugin that loads the appropriate graphics renderer
  632. // implementation based on detected environment and current configuration settings.
  633. };
  634. =====*/
  635. var currentRenderer = null;
  636. has.add("vml", function(global, document, element){
  637. element.innerHTML = "<v:shape adj=\"1\"/>";
  638. var supported = ("adj" in element.firstChild);
  639. element.innerHTML = "";
  640. return supported;
  641. });
  642. return {
  643. load: function(id, require, load){
  644. if(currentRenderer && id != "force"){
  645. load(currentRenderer);
  646. return;
  647. }
  648. var renderer = config.forceGfxRenderer,
  649. renderers = !renderer && (lang.isString(config.gfxRenderer) ?
  650. config.gfxRenderer : "svg,vml,canvas,silverlight").split(","),
  651. silverlightObject, silverlightFlag;
  652. while(!renderer && renderers.length){
  653. switch(renderers.shift()){
  654. case "svg":
  655. // the next test is from https://github.com/phiggins42/has.js
  656. if("SVGAngle" in win.global){
  657. renderer = "svg";
  658. }
  659. break;
  660. case "vml":
  661. if(has("vml")){
  662. renderer = "vml";
  663. }
  664. break;
  665. case "silverlight":
  666. try{
  667. if(has("ie")){
  668. silverlightObject = new ActiveXObject("AgControl.AgControl");
  669. if(silverlightObject && silverlightObject.IsVersionSupported("1.0")){
  670. silverlightFlag = true;
  671. }
  672. }else{
  673. if(navigator.plugins["Silverlight Plug-In"]){
  674. silverlightFlag = true;
  675. }
  676. }
  677. }catch(e){
  678. silverlightFlag = false;
  679. }finally{
  680. silverlightObject = null;
  681. }
  682. if(silverlightFlag){
  683. renderer = "silverlight";
  684. }
  685. break;
  686. case "canvas":
  687. if(win.global.CanvasRenderingContext2D){
  688. renderer = "canvas";
  689. }
  690. break;
  691. }
  692. }
  693. if (renderer === 'canvas' && config.canvasEvents !== false) {
  694. renderer = "canvasWithEvents";
  695. }
  696. if(config.isDebug){
  697. console.log("gfx renderer = " + renderer);
  698. }
  699. function loadRenderer(){
  700. require(["dojox/gfx/" + renderer], function(module){
  701. g.renderer = renderer;
  702. // memorize the renderer module
  703. currentRenderer = module;
  704. // now load it
  705. load(module);
  706. });
  707. }
  708. if(renderer == "svg" && typeof window.svgweb != "undefined"){
  709. window.svgweb.addOnLoad(loadRenderer);
  710. }else{
  711. loadRenderer();
  712. }
  713. }
  714. };
  715. });
  716. }}});
  717. define("dojox/gfx", ["dojo/_base/lang", "./gfx/_base", "./gfx/renderer!"],
  718. function(lang, gfxBase, renderer){
  719. // module:
  720. // dojox/gfx
  721. // summary:
  722. // This the root of the Dojo Graphics package
  723. gfxBase.switchTo(renderer);
  724. return gfxBase;
  725. });