From dd70aad78ee3bcfc9924a9a5284c6e1fbe838ff3 Mon Sep 17 00:00:00 2001 From: Chris Mitchell Date: Tue, 16 Aug 2011 20:48:22 +0000 Subject: [PATCH] refs #12844 more AMD updates for gfx from wildbill. Thanks! \!strict git-svn-id: http://svn.dojotoolkit.org/src/dojox/trunk@26246 560b804f-0ae3-0310-86f3-f6aa0a117693 --- gfx.js | 2 +- gfx/_base.js | 14 ++++---- gfx/_gfxBidiSupport.js | 8 ++--- gfx/arc.js | 8 ++--- gfx/canvas.js | 10 +++--- gfx/canvasWithEvents.js | 3 +- gfx/decompose.js | 7 ++-- gfx/fx.js | 3 +- gfx/gradutils.js | 11 +++--- gfx/matrix.js | 11 +++--- gfx/path.js | 39 +++++++++++---------- gfx/renderer.js | 6 ++-- gfx/shape.js | 78 ++++++++++++++++++++--------------------- gfx/silverlight.js | 3 +- gfx/svg.js | 2 +- gfx/svg_attach.js | 2 +- gfx/utils.js | 16 ++++----- gfx/vml.js | 3 +- gfx/vml_attach.js | 2 +- 19 files changed, 119 insertions(+), 109 deletions(-) diff --git a/gfx.js b/gfx.js index 74a24d56db..ebb9182734 100644 --- a/gfx.js +++ b/gfx.js @@ -5,5 +5,5 @@ define(["dojo/_base/lang", "./gfx/_base", "./gfx/renderer!"], // summary: // This the root of the Dojo Graphics package gfxBase.switchTo(renderer); - return dojox.gfx; + return gfxBase; }); diff --git a/gfx/_base.js b/gfx/_base.js index b203f52614..dc9cfa4823 100644 --- a/gfx/_base.js +++ b/gfx/_base.js @@ -1,14 +1,14 @@ -define(["dojo/_base/lang", "dojox/main", "dojo/_base/html", "dojo/_base/Color", "dojo/_base/sniff", "dojo/_base/window", +define(["dojo/_base/lang", "dojo/_base/html", "dojo/_base/Color", "dojo/_base/sniff", "dojo/_base/window", "dojo/_base/array","dojo/dom", "dojo/dom-construct","dojo/dom-geometry"], - function(lang, dojox, html, Color, has, win, arr, dom, domConstruct, domGeom){ + function(lang, html, Color, has, win, arr, dom, domConstruct, domGeom){ // module: // dojox/gfx // summary: // This module contains common core Graphics API used by different graphics renderers. - lang.getObject("gfx._base", true, dojox); - - var g = dojox.gfx, b = g._base; - + var g = lang.getObject("dojox.gfx", true), + b = g._base = {}; + /*===== g = dojox.gfx; b = dojox.gfx._base; =====*/ + // candidates for dojox.style (work on VML and SVG nodes) g._hasClass = function(/*DomNode*/node, /*String*/classStr){ // summary: @@ -144,7 +144,7 @@ define(["dojo/_base/lang", "dojox/main", "dojo/_base/html", "dojo/_base/Color", // summary: returns a unique string for use with any DOM element var id; do{ - id = dojox._scopeName + "Unique" + (++uniqueId); + id = dojo._scopeName + "xUnique" + (++uniqueId); }while(dom.byId(id)); return id; }; diff --git a/gfx/_gfxBidiSupport.js b/gfx/_gfxBidiSupport.js index 6ea5dff27b..8b7a6a7e0f 100644 --- a/gfx/_gfxBidiSupport.js +++ b/gfx/_gfxBidiSupport.js @@ -1,8 +1,8 @@ -define(["dojo/_base/lang","dojo/_base/sniff", "dojo/dom", "dojo/_base/html", "dojo/_base/array", +define(["./_base", "dojo/_base/lang","dojo/_base/sniff", "dojo/dom", "dojo/_base/html", "dojo/_base/array", "./utils", "./shape", "dojox/string/BidiEngine"], - function(lang, has, dom, html, arr, utils, shapeLib, BidiEngine){ + function(g, lang, has, dom, html, arr, utils, shapeLib, BidiEngine){ lang.getObject("dojox.gfx._gfxBidiSupport", true); - var g = dojox.gfx; + /*===== g = dojox.gfx; =====*/ switch (g.renderer){ case 'vml': g.isVml = true; @@ -347,7 +347,7 @@ define(["dojo/_base/lang","dojo/_base/sniff", "dojo/dom", "dojo/_base/html", "do extendMethod(g.Group,"createTextPath", textDirPreprocess, null); g.createSurface = function(parentNode, width, height, textDir) { - var s = dojox.gfx[g.renderer].createSurface(parentNode, width, height); + var s = g[g.renderer].createSurface(parentNode, width, height); var tDir = validateTextDir(textDir); if(g.isSvgWeb){ diff --git a/gfx/arc.js b/gfx/arc.js index e2fa4cb166..ca8b672879 100644 --- a/gfx/arc.js +++ b/gfx/arc.js @@ -1,13 +1,13 @@ -define(["dojo/_base/lang", "./matrix"], - function(lang, m){ +define(["./_base", "dojo/_base/lang", "./matrix"], + function(g, lang, m){ /*===== + g = dojox.gfx; dojox.gfx.arc = { // summary: // This module contains the core graphics Arc functions. }; =====*/ - lang.getObject("dojox.gfx.arc", true); var twoPI = 2 * Math.PI, pi4 = Math.PI / 4, pi8 = Math.PI / 8, pi48 = pi4 + pi8, curvePI4 = unitArcAsBezier(pi8); @@ -26,7 +26,7 @@ define(["dojo/_base/lang", "./matrix"], }; } - var arc = dojox.gfx.arc = { + var arc = g.arc = { unitArcAsBezier: unitArcAsBezier, curvePI4: curvePI4, // curvePI4: Object diff --git a/gfx/canvas.js b/gfx/canvas.js index 3ffd4f1757..8a3ba90407 100644 --- a/gfx/canvas.js +++ b/gfx/canvas.js @@ -1,6 +1,6 @@ -define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base/window", "dojo/dom-geometry", +define(["./_base", "dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base/window", "dojo/dom-geometry", "dojo/dom", "./_base", "./shape", "./path", "./arc", "./matrix", "./decompose"], - function(lang, arr, declare, win, domGeom, dom, gfxBase, gs, pathLib, ga, m, decompose ){ + function(g, lang, arr, declare, win, domGeom, dom, gfxBase, gs, pathLib, ga, m, decompose ){ /*===== dojox.gfx.canvas = { // module: @@ -17,6 +17,7 @@ define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base // graphics context between renderer implementations. See dojox.gfx._base switchRenderer // API. }; + g = dojox.gfx; pathLib.Path = dojox.gfx.path.Path; pathLib.TextPath = dojox.gfx.path.TextPath; canvas.Shape = dojox.gfx.canvas.Shape; @@ -31,9 +32,8 @@ define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base gs.Surface = dojox.gfx.shape.Surface; =====*/ - var canvas = lang.getObject("dojox.gfx.canvas", true); - var g = dojox.gfx, - pattrnbuffer = null, + var canvas = g.canvas = {}; + var pattrnbuffer = null, mp = m.multiplyPoint, pi = Math.PI, twoPI = 2 * pi, diff --git a/gfx/canvasWithEvents.js b/gfx/canvasWithEvents.js index 456fbf271e..86dcf7a26e 100644 --- a/gfx/canvasWithEvents.js +++ b/gfx/canvasWithEvents.js @@ -1,7 +1,6 @@ define(["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/connect", "dojo/_base/Color", "dojo/dom", "dojo/dom-geometry", "./_base","./canvas", "./shape", "./matrix"], function(lang, declare, hub, Color, dom, domGeom, g, canvas, shapeLib, m){ - var canvasEvent = lang.getObject("dojox.gfx.canvasWithEvents", true); /*===== dojox.gfx.canvasWithEvents = { // module: @@ -20,6 +19,7 @@ define(["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/connect", "dojo/_ba // graphics context between renderer implementations. See dojox.gfx._base switchRenderer // API. }; + g = dojox.gfx; var canvas.Shape = dojox.gfx.canvas.Shape; var canvas.Group = dojox.gfx.canvas.Group; var canvas.Image = dojox.gfx.canvas.Image; @@ -35,6 +35,7 @@ define(["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/connect", "dojo/_ba var canvasEvent.Shape = dojox.gfx.canvasWithEvents.Shape; =====*/ + var canvasEvent = g.canvasWithEvents = {}; declare("dojox.gfx.canvasWithEvents.Shape", canvas.Shape, { diff --git a/gfx/decompose.js b/gfx/decompose.js index be351e6bbe..590513bf41 100644 --- a/gfx/decompose.js +++ b/gfx/decompose.js @@ -1,5 +1,6 @@ -define(["dojo/_base/lang", "./matrix"], - function (lang, m){ +define(["./_base", "dojo/_base/lang", "./matrix"], + function (g, lang, m){ + /*===== g = dojox.gfx =====*/ function eq(/* Number */ a, /* Number */ b){ // summary: compare two FP numbers for equality return Math.abs(a - b) <= 1e-6 * (Math.abs(a) + Math.abs(b)); // Boolean @@ -91,7 +92,7 @@ define(["dojo/_base/lang", "./matrix"], return result; // Object } - return dojox.gfx.decompose = function(matrix){ + return g.decompose = function(matrix){ // summary: decompose a 2D matrix into translation, scaling, and rotation components // description: this function decompose a matrix into four logical components: // translation, rotation, scaling, and one more rotation using SVD. diff --git a/gfx/fx.js b/gfx/fx.js index 3143590e9c..277ba06e89 100644 --- a/gfx/fx.js +++ b/gfx/fx.js @@ -1,6 +1,7 @@ define(["dojo/_base/lang", "./_base", "./matrix", "dojo/_base/Color", "dojo/_base/array", "dojo/_base/fx", "dojo/_base/connect"], function(lang, g, m, Color, arr, fx, Hub){ - var fxg = lang.getObject("dojox.gfx.fx", true); + /*===== g = dojox.gfx =====*/ + var fxg = g.fx = {}; // Generic interpolators. Should they be moved to dojox.fx? diff --git a/gfx/gradutils.js b/gfx/gradutils.js index 1098f96a0b..03a39ebf9a 100644 --- a/gfx/gradutils.js +++ b/gfx/gradutils.js @@ -1,9 +1,10 @@ // Various generic utilities to deal with a linear gradient -define(["dojo/_base/lang", "./matrix", "dojo/_base/Color"], +define(["./_base", "dojo/_base/lang", "./matrix", "dojo/_base/Color"], function(lang, m, Color){ - gradutils= lang.getObject("dojox.gfx.gradutils", true); - var C = Color; + + /*===== g= dojox.gfx =====*/ + var gradutils = g.gradutils = {}; function findColor(o, c){ if(o <= 0){ @@ -19,7 +20,7 @@ define(["dojo/_base/lang", "./matrix", "dojo/_base/Color"], if(stop.offset >= o){ if(i){ var prev = c[i - 1]; - return C.blendColors(new C(prev.color), new C(stop.color), + return Color.blendColors(new Color(prev.color), new Color(stop.color), (o - prev.offset) / (stop.offset - prev.offset)); } return stop.color; @@ -56,7 +57,7 @@ define(["dojo/_base/lang", "./matrix", "dojo/_base/Color"], return findColor(o, fill.colors); // dojo.Color } // simple color - return new C(fill || [0, 0, 0, 0]); // dojo.Color + return new Color(fill || [0, 0, 0, 0]); // dojo.Color }; gradutils.reverse = function(fill){ diff --git a/gfx/matrix.js b/gfx/matrix.js index 808eb161b8..ef188bc498 100644 --- a/gfx/matrix.js +++ b/gfx/matrix.js @@ -1,6 +1,7 @@ -define(["dojo/_base/lang"], - function(lang){ - var m = lang.getObject("gfx.matrix", true, dojox); +define(["./_base","dojo/_base/lang"], + function(g, lang){ + /*===== g = dojox.gfx =====*/ + var m = g.matrix = {}; // candidates for dojox.math: var _degToRadCache = {}; @@ -23,7 +24,7 @@ define(["dojo/_base/lang"], var matrix = m.normalize(arg[0]); // combine matrices for(var i = 1; i < arg.length; ++i){ - var l = matrix, r = dojox.gfx.matrix.normalize(arg[i]); + var l = matrix, r = m.normalize(arg[i]); matrix = new m.Matrix2D(); matrix.xx = l.xx * r.xx + l.xy * r.yx; matrix.xy = l.xx * r.xy + l.xy * r.yy; @@ -437,7 +438,7 @@ define(["dojo/_base/lang"], }); // propagate Matrix2D up - dojox.gfx.Matrix2D = m.Matrix2D; + g.Matrix2D = m.Matrix2D; return m; }); diff --git a/gfx/path.js b/gfx/path.js index c3f56d25da..349338d3ea 100644 --- a/gfx/path.js +++ b/gfx/path.js @@ -1,21 +1,24 @@ -define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"], - function(lang, declare, matrix, shapeLib){ +define(["./_base", "dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"], + function(g, lang, declare, matrix, shapeLib){ /*===== dojox.gfx.path = { // summary: // This module contains the core graphics Path API. // Path command format follows the W3C SVG 1.0 Path api. }; + g = dojox.gfx; + shape.Shape = dojox.gfx.shape.Shape; =====*/ - declare("dojox.gfx.path.Path", dojox.gfx.shape.Shape, { + var path = g.path = {}; + var Path = declare("dojox.gfx.path.Path", shapeLib.Shape, { // summary: a generalized path shape constructor: function(rawNode){ // summary: a path constructor // rawNode: Node // a DOM node to be used by this path object - this.shape = lang.clone(dojox.gfx.defaultPath); + this.shape = lang.clone(g.defaultPath); this.segments = []; this.tbbox = null; this.absolute = true; @@ -80,15 +83,15 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"], }, // segment interpretation - _updateBBox: function(x, y, matrix){ + _updateBBox: function(x, y, m){ // summary: updates the bounding box of path with new point // x: Number // an x coordinate // y: Number // a y coordinate - if(matrix){ - var t = dojox.gfx.matrix.multiplyPoint(matrix, x, y); + if(m){ + var t = matrix.multiplyPoint(m, x, y); x = t.x; y = t.y; } @@ -201,7 +204,7 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"], // add an SVG path segment var path = [segment.action]; for(i = 0; i < l; ++i){ - path.push(dojox.gfx.formatNumber(n[i], true)); + path.push(g.formatNumber(n[i], true)); } if(typeof this.shape.path == "string"){ this.shape.path += path.join(""); @@ -354,7 +357,7 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"], // summary: forms a path using an SVG path string // path: String // an SVG path string - var p = lang.isArray(path) ? path : path.match(dojox.gfx.pathSvgRegExp); + var p = lang.isArray(path) ? path : path.match(g.pathSvgRegExp); this.segments = []; this.absolute = true; this.bbox = {}; @@ -386,7 +389,7 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"], this.segmented = false; this.segments = []; - if(!dojox.gfx.lazyPathSegmentation){ + if(!g.lazyPathSegmentation){ this._confirmSegmented(); } return this; // self @@ -396,7 +399,7 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"], _2PI: Math.PI * 2 }); - declare("dojox.gfx.path.TextPath", dojox.gfx.path.Path, { + var TextPath = declare("dojox.gfx.path.TextPath", Path, { // summary: a generalized TextPath shape constructor: function(rawNode){ @@ -404,10 +407,10 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"], // rawNode: Node // a DOM node to be used by this TextPath object if(!("text" in this)){ - this.text = lang.clone(dojox.gfx.defaultTextPath); + this.text = lang.clone(g.defaultTextPath); } if(!("fontStyle" in this)){ - this.fontStyle = lang.clone(dojox.gfx.defaultFont); + this.fontStyle = lang.clone(g.defaultFont); } }, getText: function(){ @@ -416,7 +419,7 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"], }, setText: function(newText){ // summary: sets a text to be drawn along the path - this.text = dojox.gfx.makeParameters(this.text, + this.text = g.makeParameters(this.text, typeof newText == "string" ? {text: newText} : newText); this._setText(); return this; // self @@ -428,15 +431,15 @@ define(["dojo/_base/lang","dojo/_base/declare", "./matrix", "./shape"], setFont: function(newFont){ // summary: sets a font for text this.fontStyle = typeof newFont == "string" ? - dojox.gfx.splitFontString(newFont) : - dojox.gfx.makeParameters(dojox.gfx.defaultFont, newFont); + g.splitFontString(newFont) : + g.makeParameters(g.defaultFont, newFont); this._setFont(); return this; // self } }); return { // our hash of newly defined objects - Path: dojox.gfx.path.Path, - TextPath: dojox.gfx.path.TextPath + Path: Path, + TextPath: TextPath }; }); diff --git a/gfx/renderer.js b/gfx/renderer.js index a1e4634f45..5c1d3fcceb 100644 --- a/gfx/renderer.js +++ b/gfx/renderer.js @@ -1,5 +1,5 @@ -define(["dojo/_base/lang", "dojo/_base/sniff", "dojo/_base/window", "dojo/_base/config"], - function(lang, has, win, config){ +define(["./_base","dojo/_base/lang", "dojo/_base/sniff", "dojo/_base/window", "dojo/_base/config"], + function(g, lang, has, win, config){ /*===== dojox.gfx.renderer = { // summary: @@ -71,7 +71,7 @@ define(["dojo/_base/lang", "dojo/_base/sniff", "dojo/_base/window", "dojo/_base/ function loadRenderer(){ require(["dojox/gfx/" + renderer], function(module){ - dojox.gfx.renderer = renderer; + g.renderer = renderer; // memorize the renderer module currentRenderer = module; // now load it diff --git a/gfx/shape.js b/gfx/shape.js index a571cdc73f..36f95a8d2c 100644 --- a/gfx/shape.js +++ b/gfx/shape.js @@ -1,6 +1,6 @@ -define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/window", "dojo/_base/sniff", +define(["./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/window", "dojo/_base/sniff", "dojo/_base/connect", "dojo/_base/array", "dojo/dom-construct", "dojo/_base/Color", "./matrix"], - function(dojox, gfxBase, lang, declare, win, has, events, arr, domConstruct, Color, matrixLib){ + function(g, lang, declare, win, has, events, arr, domConstruct, Color, matrixLib){ /*===== dojox.gfx.shape = { @@ -11,7 +11,7 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi }; =====*/ - var shape = lang.getObject("dojox.gfx.shape", true); + var shape = g.shape = {}; // a set of ids (keys=type) var _ids = {}; // a simple set impl to map shape<->id @@ -198,7 +198,7 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi // dojox.gfx.defaultLine, // or dojox.gfx.defaultImage) // COULD BE RE-IMPLEMENTED BY THE RENDERER! - this.shape = gfxBase.makeParameters(this.shape, shape); + this.shape = g.makeParameters(this.shape, shape); this.bbox = null; return this; // self }, @@ -222,18 +222,18 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi // gradient or pattern switch(fill.type){ case "linear": - f = gfxBase.makeParameters(gfxBase.defaultLinearGradient, fill); + f = g.makeParameters(g.defaultLinearGradient, fill); break; case "radial": - f = gfxBase.makeParameters(gfxBase.defaultRadialGradient, fill); + f = g.makeParameters(g.defaultRadialGradient, fill); break; case "pattern": - f = gfxBase.makeParameters(gfxBase.defaultPattern, fill); + f = g.makeParameters(g.defaultPattern, fill); break; } }else{ // color object - f = gfxBase.normalizeColor(fill); + f = g.normalizeColor(fill); } this.fillStyle = f; return this; // self @@ -254,8 +254,8 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi if(typeof stroke == "string" || lang.isArray(stroke) || stroke instanceof Color){ stroke = {color: stroke}; } - var s = this.strokeStyle = gfxBase.makeParameters(gfxBase.defaultStroke, stroke); - s.color = gfxBase.normalizeColor(s.color); + var s = this.strokeStyle = g.makeParameters(g.defaultStroke, stroke); + s.color = g.normalizeColor(s.color); return this; // self }, setTransform: function(matrix){ @@ -384,7 +384,7 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi // COULD BE RE-IMPLEMENTED BY THE RENDERER! // redirect to fixCallback to normalize events and add the gfxTarget to the event. The latter // is done by dojox.gfx.fixTarget which is defined by each renderer - return events.connect(this.getEventSource(), name, shape.fixCallback(this, gfxBase.fixTarget, object, method)); + return events.connect(this.getEventSource(), name, shape.fixCallback(this, g.fixTarget, object, method)); }, disconnect: function(token){ @@ -598,7 +598,7 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi constructor: function(rawNode){ // rawNode: Node // The underlying graphics system object (typically a DOM Node) - this.shape = gfxBase.getDefault("Rect"); + this.shape = g.getDefault("Rect"); this.rawNode = rawNode; }, getBoundingBox: function(){ @@ -612,7 +612,7 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi constructor: function(rawNode){ // rawNode: Node // a DOM Node - this.shape = gfxBase.getDefault("Ellipse"); + this.shape = g.getDefault("Ellipse"); this.rawNode = rawNode; }, getBoundingBox: function(){ @@ -632,7 +632,7 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi constructor: function(rawNode){ // rawNode: Node // a DOM Node - this.shape = gfxBase.getDefault("Circle"); + this.shape = g.getDefault("Circle"); this.rawNode = rawNode; }, getBoundingBox: function(){ @@ -652,7 +652,7 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi constructor: function(rawNode){ // rawNode: Node // a DOM Node - this.shape = gfxBase.getDefault("Line"); + this.shape = g.getDefault("Line"); this.rawNode = rawNode; }, getBoundingBox: function(){ @@ -676,7 +676,7 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi constructor: function(rawNode){ // rawNode: Node // a DOM Node - this.shape = gfxBase.getDefault("Polyline"); + this.shape = g.getDefault("Polyline"); this.rawNode = rawNode; }, setShape: function(points, closed){ @@ -738,7 +738,7 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi constructor: function(rawNode){ // rawNode: Node // a DOM Node - this.shape = gfxBase.getDefault("Image"); + this.shape = g.getDefault("Image"); this.rawNode = rawNode; }, getBoundingBox: function(){ @@ -761,7 +761,7 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi // rawNode: Node // a DOM Node this.fontStyle = null; - this.shape = gfxBase.getDefault("Text"); + this.shape = g.getDefault("Text"); this.rawNode = rawNode; }, getFont: function(){ @@ -772,8 +772,8 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi // summary: sets a font for text // newFont: Object // a font object (see dojox.gfx.defaultFont) or a font string - this.fontStyle = typeof newFont == "string" ? gfxBase.splitFontString(newFont) : - gfxBase.makeParameters(gfxBase.defaultFont, newFont); + this.fontStyle = typeof newFont == "string" ? g.splitFontString(newFont) : + g.makeParameters(g.defaultFont, newFont); this._setFont(); return this; // self } @@ -787,76 +787,76 @@ define(["..", "./_base", "dojo/_base/lang", "dojo/_base/declare", "dojo/_base/wi // shape: Object // a shape descriptor object switch(shape.type){ - case gfxBase.defaultPath.type: return this.createPath(shape); - case gfxBase.defaultRect.type: return this.createRect(shape); - case gfxBase.defaultCircle.type: return this.createCircle(shape); - case gfxBase.defaultEllipse.type: return this.createEllipse(shape); - case gfxBase.defaultLine.type: return this.createLine(shape); - case gfxBase.defaultPolyline.type: return this.createPolyline(shape); - case gfxBase.defaultImage.type: return this.createImage(shape); - case gfxBase.defaultText.type: return this.createText(shape); - case gfxBase.defaultTextPath.type: return this.createTextPath(shape); + case g.defaultPath.type: return this.createPath(shape); + case g.defaultRect.type: return this.createRect(shape); + case g.defaultCircle.type: return this.createCircle(shape); + case g.defaultEllipse.type: return this.createEllipse(shape); + case g.defaultLine.type: return this.createLine(shape); + case g.defaultPolyline.type: return this.createPolyline(shape); + case g.defaultImage.type: return this.createImage(shape); + case g.defaultText.type: return this.createText(shape); + case g.defaultTextPath.type: return this.createTextPath(shape); } return null; }, createGroup: function(){ // summary: creates a group shape - return this.createObject(gfxBase.Group); // dojox.gfx.Group + return this.createObject(g.Group); // dojox.gfx.Group }, createRect: function(rect){ // summary: creates a rectangle shape // rect: Object // a path object (see dojox.gfx.defaultRect) - return this.createObject(gfxBase.Rect, rect); // dojox.gfx.Rect + return this.createObject(g.Rect, rect); // dojox.gfx.Rect }, createEllipse: function(ellipse){ // summary: creates an ellipse shape // ellipse: Object // an ellipse object (see dojox.gfx.defaultEllipse) - return this.createObject(gfxBase.Ellipse, ellipse); // dojox.gfx.Ellipse + return this.createObject(g.Ellipse, ellipse); // dojox.gfx.Ellipse }, createCircle: function(circle){ // summary: creates a circle shape // circle: Object // a circle object (see dojox.gfx.defaultCircle) - return this.createObject(gfxBase.Circle, circle); // dojox.gfx.Circle + return this.createObject(g.Circle, circle); // dojox.gfx.Circle }, createLine: function(line){ // summary: creates a line shape // line: Object // a line object (see dojox.gfx.defaultLine) - return this.createObject(gfxBase.Line, line); // dojox.gfx.Line + return this.createObject(g.Line, line); // dojox.gfx.Line }, createPolyline: function(points){ // summary: creates a polyline/polygon shape // points: Object // a points object (see dojox.gfx.defaultPolyline) // or an Array of points - return this.createObject(gfxBase.Polyline, points); // dojox.gfx.Polyline + return this.createObject(g.Polyline, points); // dojox.gfx.Polyline }, createImage: function(image){ // summary: creates a image shape // image: Object // an image object (see dojox.gfx.defaultImage) - return this.createObject(gfxBase.Image, image); // dojox.gfx.Image + return this.createObject(g.Image, image); // dojox.gfx.Image }, createText: function(text){ // summary: creates a text shape // text: Object // a text object (see dojox.gfx.defaultText) - return this.createObject(gfxBase.Text, text); // dojox.gfx.Text + return this.createObject(g.Text, text); // dojox.gfx.Text }, createPath: function(path){ // summary: creates a path shape // path: Object // a path object (see dojox.gfx.defaultPath) - return this.createObject(gfxBase.Path, path); // dojox.gfx.Path + return this.createObject(g.Path, path); // dojox.gfx.Path }, createTextPath: function(text){ // summary: creates a text shape // text: Object // a textpath object (see dojox.gfx.defaultTextPath) - return this.createObject(gfxBase.TextPath, {}).setText(text); // dojox.gfx.TextPath + return this.createObject(g.TextPath, {}).setText(text); // dojox.gfx.TextPath }, createObject: function(shapeType, rawShape){ // summary: creates an instance of the passed shapeType class diff --git a/gfx/silverlight.js b/gfx/silverlight.js index 85beb732e7..a7996ef5b2 100644 --- a/gfx/silverlight.js +++ b/gfx/silverlight.js @@ -10,6 +10,7 @@ define(["dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/declare", "dojo/_bas // This the graphics rendering bridge for the Microsoft Silverlight plugin. // Silverlight is a faster implementation on IE6-8 than the default 2d graphics, VML }; + g = dojox.gfx; pathLib.Path = dojox.gfx.path.Path; pathLib.TextPath = dojox.gfx.path.TextPath; sl.Shape = dojox.gfx.canvas.Shape; @@ -24,7 +25,7 @@ define(["dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/declare", "dojo/_bas gs.Surface = dojox.gfx.shape.Surface; =====*/ - var sl = lang.getObject("dojox.gfx.silverlight", true); + var sl = g.silverlight = {}; kernel.experimental("dojox.gfx.silverlight"); var dasharray = { diff --git a/gfx/svg.js b/gfx/svg.js index 9a06937cec..8f11609c4b 100644 --- a/gfx/svg.js +++ b/gfx/svg.js @@ -22,7 +22,7 @@ define(["dojo/_base/lang", "dojo/_base/window", "dojo/dom","dojo/_base/declare", gs.Text = dojox.gfx.shape.Text; gs.Surface = dojox.gfx.shape.Surface; =====*/ - var svg = lang.getObject("dojox.gfx.svg", true); + var svg = g.svg = {}; svg.useSvgWeb = (typeof window.svgweb != "undefined"); // Need to detect iOS in order to workaround bug when diff --git a/gfx/svg_attach.js b/gfx/svg_attach.js index 9f6d49a574..7161c9c9cb 100644 --- a/gfx/svg_attach.js +++ b/gfx/svg_attach.js @@ -1,6 +1,6 @@ define(["dojo/_base/kernel", "dojo/_base/lang", "dojo/_base/array","dojo/_base/Color", "./_base","./svg","./matrix"], function(kernel, lang, arr, Color, g, svg, Matrix){ - lang.getObject("dojox.gfx.svg_attach", true); + kernel.experimental("dojox.gfx.svg_attach"); svg.attachNode = function(node){ diff --git a/gfx/utils.js b/gfx/utils.js index f172cb061a..808558da3b 100644 --- a/gfx/utils.js +++ b/gfx/utils.js @@ -1,7 +1,7 @@ -define(["dojo/_base/kernel","dojox","dojo/_base/lang", ".", "dojo/_base/html","dojo/_base/array", "dojo/_base/window", "dojo/_base/json", +define(["dojo/_base/kernel","dojo/_base/lang","./_base", "dojo/_base/html","dojo/_base/array", "dojo/_base/window", "dojo/_base/json", "dojo/_base/Deferred", "dojo/_base/sniff"], - function(dojo, dojox, lang, gfx, html, arr, win, jsonLib, Deferred, has){ - var gu = lang.getObject("dojox.gfx.utils", true); + function(dojo, lang, g, html, arr, win, jsonLib, Deferred, has){ + var gu = g.utils = {}; lang.mixin(gu, { forEach: function( @@ -10,7 +10,7 @@ define(["dojo/_base/kernel","dojox","dojo/_base/lang", ".", "dojo/_base/html","d ){ o = o || win.global; f.call(o, object); - if(object instanceof gfx.Surface || object instanceof gfx.Group){ + if(object instanceof g.Surface || object instanceof g.Group){ arr.forEach(object.children, function(shape){ gu.forEach(shape, f, o); }); @@ -20,8 +20,8 @@ define(["dojo/_base/kernel","dojox","dojo/_base/lang", ".", "dojo/_base/html","d serialize: function( /* dojox.gfx.Surface || dojox.gfx.Shape */ object ){ - var t = {}, v, isSurface = object instanceof gfx.Surface; - if(isSurface || object instanceof gfx.Group){ + var t = {}, v, isSurface = object instanceof g.Surface; + if(isSurface || object instanceof g.Group){ t.children = arr.map(object.children, gu.serialize); if(isSurface){ return t.children; // Array @@ -105,7 +105,7 @@ define(["dojo/_base/kernel","dojox","dojo/_base/lang", ".", "dojo/_base/html","d //return a deferred that will be called when content has serialized. var deferred = new Deferred(); - if(dojox.gfx.renderer === "svg"){ + if(g.renderer === "svg"){ //If we're already in SVG mode, this is easy and quick. try{ var svg = gu._cleanSvg(gu._innerXML(surface.rawNode)); @@ -119,7 +119,7 @@ define(["dojo/_base/kernel","dojox","dojo/_base/lang", ".", "dojo/_base/html","d if (!gu._initSvgSerializerDeferred) { gu._initSvgSerializer(); } - var jsonForm = dojox.gfx.utils.toJson(surface); + var jsonForm = gu.toJson(surface); var serializer = function(){ try{ var sDim = surface.getDimensions(); diff --git a/gfx/vml.js b/gfx/vml.js index cbc5c7d718..c6488368aa 100644 --- a/gfx/vml.js +++ b/gfx/vml.js @@ -11,6 +11,7 @@ define(["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/array", "dojo/_base // This renderer is very slow. For best performance on IE6-8, use Silverlight plugin. // IE9+ defaults to the standard W3C SVG renderer. }; + g = dojox.gfx; pathLib.Path = dojox.gfx.path.Path; pathLib.TextPath = dojox.gfx.path.TextPath; vml.Shape = dojox.gfx.canvas.Shape; @@ -24,7 +25,7 @@ define(["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/array", "dojo/_base gs.Text = dojox.gfx.shape.Text; gs.Surface = dojox.gfx.shape.Surface; =====*/ - var vml = lang.getObject("dojox.gfx.vml", true); + var vml = g.vml = {}; // dojox.gfx.vml.xmlns: String: a VML's namespace vml.xmlns = "urn:schemas-microsoft-com:vml"; diff --git a/gfx/vml_attach.js b/gfx/vml_attach.js index c6a39362d2..d385d6ca81 100644 --- a/gfx/vml_attach.js +++ b/gfx/vml_attach.js @@ -1,6 +1,6 @@ define(["dojo/_base/kernel", "dojo/_base/lang", "./_base", "./matrix", "./path", "dojo/_base/Color", "./vml"], function (kernel, lang, g, m, pathLib, Color, vml){ - lang.getObject("dojox.gfx.vml_attach", true); + kernel.experimental("dojox.gfx.vml_attach"); vml.attachNode = function(node){