graphics.js revision f49cd0540857456c2f91f0b5c08649f0f8ae39e8
/**
* The Graphics widget provides an api for basic drawing operations.
*
* @module graphics
*/
var SETTER = "setter",
VALUE = "value",
VALUEFN = "valueFn",
READONLY = "readOnly",
STR = "string",
WRITE_ONCE = "writeOnce",
/**
* Matrix is a class that allows for the manipulation of a transform matrix.
* This class is a work in progress.
*
* @class Matrix
* @constructor
*/
};
/**
* Used as value for the _rounding method.
*
* @property _rounder
* @private
*/
_rounder: 100000,
/**
* Updates the matrix.
*
* @method multiple
* @param {Number} a
* @param {Number} b
* @param {Number} c
* @param {Number} d
* @param {Number} dx
* @param {Number} dy
*/
var matrix = this,
return this;
},
/**
* Parses a string and updates the matrix.
*
* @method applyCSSText
* @param {String} val A css transform string
*/
applyCSSText: function(val) {
args,
m;
if (typeof this[m[1]] === 'function') {
}
}
},
/**
* Parses a string and returns an array of transform arrays.
*
* @method applyCSSText
* @param {String} val A css transform string
* @return Array
*/
getTransformArray: function(val) {
transforms = [],
args,
m;
if (typeof this[m[1]] === 'function') {
}
}
return transforms;
},
/**
* Default values for the matrix
*
* @property _defaults
* @private
*/
_defaults: {
a: 1,
b: 0,
c: 0,
d: 1,
dx: 0,
dy: 0
},
/**
* Rounds values
*
* @method _round
* @private
*/
return val;
},
/**
* Initializes a matrix.
*
* @method init
* @param {Object} config Specified key value pairs for matrix properties. If a property is not explicitly defined in the config argument,
* the default value will be used.
*/
prop;
{
}
}
},
/**
* Applies a scale transform
*
* @method scale
* @param {Number} val
*/
scale: function(x, y) {
return this;
},
/**
* Applies a skew transformation.
*
* @method skew
* @param {Number} x The value to skew on the x-axis.
* @param {Number} y The value to skew on the y-axis.
*/
skew: function(x, y) {
x = x || 0;
y = y || 0;
if (x !== undefined) { // null or undef
}
if (y !== undefined) { // null or undef
}
return this;
},
/**
* Applies a skew to the x-coordinate
*
* @method skewX
* @param {Number} x x-coordinate
*/
skewX: function(x) {
this.skew(x);
return this;
},
/**
* Applies a skew to the y-coordinate
*
* @method skewY
* @param {Number} y y-coordinate
*/
skewY: function(y) {
this.skew(null, y);
return this;
},
/**
* Returns a string of text that can be used to populate a the css transform property of an element.
*
* @method toCSSText
* @return String
*/
toCSSText: function() {
var matrix = this,
text = 'matrix(';
dx += 'px';
}
dy += 'px';
}
}
matrix.b + ',' +
matrix.c + ',' +
matrix.d + ',' +
dx + ',' +
dy;
text += ')';
return text;
},
/**
* Returns a string that can be used to populate the css filter property of an element.
*
* @method toFilterText
* @return String
*/
toFilterText: function() {
var matrix = this,
text = 'progid:DXImageTransform.Microsoft.Matrix(';
'sizingMethod="auto expand")';
text += '';
return text;
},
/**
* Converts a radian value to a degree.
*
* @method rad2deg
* @param {Number} rad Radian value to be converted.
* @return Number
*/
return deg;
},
/**
* Converts a degree value to a radian.
*
* @method deg2rad
* @param {Number} deg Degree value to be converted to radian.
* @return Number
*/
return rad;
},
} else { // default to deg
}
return val;
},
/**
* Applies a rotate transform.
*
* @method rotate
* @param {Number} deg The degree of the rotation.
*/
var matrix = [],
return this;
},
/**
* Applies translate transformation.
*
* @method translate
* @param {Number} x The value to transate on the x-axis.
* @param {Number} y The value to translate on the y-axis.
*/
translate: function(x, y) {
return this;
}
};
/**
* AttributeLite provides Attribute-like getters and setters for shape classes in the Graphics module. It provides a get/set API without the event infastructure.
* This class is temporary and a work in progress.
*
* @class AttributeLite
* @constructor
*/
AttributeLite = function()
{
var host = this; // help compression
// Perf tweak - avoid creating event literals if not required.
host._ATTR_E_FACADE = {};
};
/**
* Initializes the attributes for a shape. If an attribute config is passed into the constructor of the host,
* the initial values will be overwritten.
*
* @method addAttrs
* @param {Object} cfg Optional object containing attributes key value pairs to be set.
*/
{
var host = this,
attr,
i,
fn,
for(i in attrConfig)
{
if(attrConfig.hasOwnProperty(i))
{
attr = attrConfig[i];
{
}
{
{
}
else
{
}
}
}
}
for(i in attrConfig)
{
if(attrConfig.hasOwnProperty(i))
{
attr = attrConfig[i];
{
continue;
}
{
}
{
{
}
else
{
}
}
}
}
},
/**
* For a given item, returns the value of the property requested, or undefined if not found.
*
* @method get
* @param name {String} The name of the item
* @return {Any} The value of the supplied property.
*/
{
var host = this,
{
if(getter)
{
{
}
}
}
return null;
},
/**
* Sets the value of an attribute.
*
* @method set
* @param {String|Object} name The name of the attribute. Alternatively, an object of key value pairs can
* be passed in to set multiple attributes at once.
* @param {Any} value The value to set the attribute to. This value is ignored if an object is received as
* the name param.
*/
{
var i;
{
for(i in attr)
{
if(attr.hasOwnProperty(i))
{
}
}
}
else
{
}
},
/**
* Provides setter logic. Used by `set`.
*
* @method _set
* @param {String|Object} name The name of the attribute. Alternatively, an object of key value pairs can
* be passed in to set multiple attributes at once.
* @param {Any} value The value to set the attribute to. This value is ignored if an object is received as
* the name param.
* @protected
*/
{
var host = this,
args,
{
if(setter)
{
{
}
else
{
}
}
}
}
};
/**
* BaseGraphic serves as the base class for the graphic layer. It serves the same purpose as
* This class is temporary and a work in progress.
*
* @class BaseGraphic
* @constructor
* @param {Object} cfg Key value pairs for attributes
*/
BaseGraphic = function(cfg)
{
var host = this,
}
if (host._initPlugins) {
// Need to initPlugins manually, to handle constructor parsing, static Plug parsing
}
host.initialized = true;
};
BaseGraphic.prototype = {
/**
* Init method, invoked during construction.
* Fires an init event after calling `initializer` on implementers.
*
* @method init
* @protected
*/
init: function()
{
this.publish("init", {
fireOnce:true
});
}
};
//Straightup augment, no wrapper functions
Y.BaseGraphic = BaseGraphic;