CanvasShape.js revision c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4e
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp/**
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * Base class for creating shapes.
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp *
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp * @class CanvasShape
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp */
828c58761d90445b8b9d20a82d85dc1479317f71TrippCanvasShape = function(cfg)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp{
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp CanvasShape.superclass.constructor.apply(this, arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp};
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
828c58761d90445b8b9d20a82d85dc1479317f71TrippCanvasShape.NAME = "canvasShape";
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTrippY.extend(CanvasShape, Y.BaseGraphic, Y.mix(Y.CanvasDrawing.prototype, {
e7c7565d9550eaa87043aef0df77125ada996deaTripp /**
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @private
e7c7565d9550eaa87043aef0df77125ada996deaTripp */
e7c7565d9550eaa87043aef0df77125ada996deaTripp init: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this.initializer.apply(this, arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Initializes the shape
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _initialize
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp initializer: function(cfg)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var host = this;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp host._initProps();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp host.createNode();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp host._graphic = cfg.graphic;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp host._xcoords = [0];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp host._ycoords = [0];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp host._updateHandler();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Add a class name to each node.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method addClass
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {String} className the class name to add to the node's class attribute
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp addClass: function(className)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = Y.one(this.get("node"));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.addClass(className);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Removes a class name from each node.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method removeClass
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {String} className the class name to remove from the node's class attribute
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp removeClass: function(className)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = Y.one(this.get("node"));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.removeClass(className);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Gets the current position of the node in page coordinates.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method getXY
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return Array The XY position of the shape.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp getXY: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var graphic = this.get("graphic"),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp parentXY = graphic.getXY(),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp x = this.get("x"),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp y = this.get("y");
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return [parentXY[0] + x, parentXY[1] + y];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Set the position of the shape in page coordinates, regardless of how the node is positioned.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method setXY
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Array} Contains X & Y values for new position (coordinates are page-based)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp setXY: function(xy)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var graphic = this.get("graphic"),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp parentXY = graphic.getXY(),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp x = xy[0] - parentXY[0],
828c58761d90445b8b9d20a82d85dc1479317f71Tripp y = xy[1] - parentXY[1];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._set("x", x);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._set("y", y);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._updateNodePosition(x, y);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Determines whether the node is an ancestor of another HTML element in the DOM hierarchy.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method contains
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {CanvasShape | HTMLElement} needle The possible node or descendent
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return Boolean Whether or not this shape is the needle or its ancestor.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp contains: function(needle)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return needle === Y.one(this.node);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Test if the supplied node matches the supplied selector.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method test
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {String} selector The CSS selector to test against.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return Boolean Wheter or not the shape matches the selector.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp test: function(selector)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return Y.one(this.get("node")).test(selector);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp //return Y.Selector.test(this.node, selector);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Compares nodes to determine if they match.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Node instances can be compared to each other and/or HTMLElements.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method compareTo
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {HTMLElement | Node} refNode The reference node to compare to the node.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return {Boolean} True if the nodes match, false if they do not.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp compareTo: function(refNode) {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = this.node;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return node === refNode;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Value function for fill attribute
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _getDefaultFill
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return Object
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _getDefaultFill: function() {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp type: "solid",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp cx: 0.5,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp cy: 0.5,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp fx: 0.5,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp fy: 0.5,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp r: 0.5
828c58761d90445b8b9d20a82d85dc1479317f71Tripp };
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Value function for stroke attribute
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _getDefaultStroke
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return Object
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _getDefaultStroke: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp weight: 1,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp dashstyle: "none",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp color: "#000",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp opacity: 1.0
828c58761d90445b8b9d20a82d85dc1479317f71Tripp };
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Left edge of the path
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _left: 0,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Right edge of the path
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _right: 0,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Top edge of the path
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _top: 0,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Bottom edge of the path
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _bottom: 0,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Creates the dom node for the shape.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @return HTMLElement
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp createNode: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = Y.config.doc.createElement('canvas'),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp id = this.get("id");
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._context = node.getContext('2d');
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp node.setAttribute("overflow", "visible");
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp node.style.overflow = "visible";
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp node.setAttribute("class", "yui3-" + SHAPE);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.setAttribute("class", "yui3-" + this.name);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.setAttribute("id", id);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp id = "#" + id;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this.node = node;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp isMouseEvent: function(type)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(type.indexOf('mouse') > -1 || type.indexOf('click') > -1)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return true;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return false;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp before: function(type, fn)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(this.isMouseEvent(type))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return Y.before(type, fn, "#" + this.get("id"));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return Y.on.apply(this, arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp on: function(type, fn)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(this.isMouseEvent(type))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return Y.on(type, fn, "#" + this.get("id"));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return Y.on.apply(this, arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp after: function(type, fn)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(this.isMouseEvent(type))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return Y.after(type, fn, "#" + this.get("id"));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return Y.on.apply(this, arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Adds a stroke to the shape node.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _strokeChangeHandler
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _setStrokeProps: function(stroke)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var color = stroke.color,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp weight = stroke.weight,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp opacity = stroke.opacity,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp linejoin = stroke.linejoin || "round",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp linecap = stroke.linecap || "butt",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp dashstyle = stroke.dashstyle;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._miterlimit = null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._dashstyle = (dashstyle && Y.Lang.isArray(dashstyle) && dashstyle.length > 1) ? dashstyle : null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._strokeWeight = weight;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if (weight)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._stroke = 1;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._stroke = 0;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if (opacity) {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._strokeStyle = this._2RGBA(color, opacity);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._strokeStyle = color;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._linecap = linecap;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(linejoin == "round" || linejoin == "square")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._linejoin = linejoin;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp linejoin = parseInt(linejoin, 10);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(Y.Lang.isNumber(linejoin))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._miterlimit = Math.max(linejoin, 1);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._linejoin = "miter";
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
e7c7565d9550eaa87043aef0df77125ada996deaTripp /**
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @private
e7c7565d9550eaa87043aef0df77125ada996deaTripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp set: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var host = this,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp val = arguments[0];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp AttributeLite.prototype.set.apply(host, arguments);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(host.initialized && val != "x" && val != "y")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp host._updateHandler();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Adds a fill to the shape node.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _fillChangeHandler
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _setFillProps: function(fill)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var isNumber = Y.Lang.isNumber,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp color = fill.color,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp opacity,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp type = fill.type;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(type == "linear" || type == "radial")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._fillType = type;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else if(color)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp opacity = fill.opacity;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if (isNumber(opacity))
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp opacity = Math.max(0, Math.min(1, opacity));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp color = this._2RGBA(color, opacity);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp color = this._2RGB(color);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._fillColor = color;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._fillType = 'solid';
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._fillColor = null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Applies translate transformation.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method translate
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} x The x-coordinate
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} y The y-coordinate
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @protected
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp translate: function(x, y)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var translate = "translate(" + x + "px, " + y + "px)";
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._updateTransform("translate", /translate\(.*\)/, translate);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Applies a skew to the x-coordinate
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method skewX:q
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} x x-coordinate
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp skewX: function(x)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Applies a skew to the x-coordinate
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method skewX:q
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} x x-coordinate
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp skewY: function(y)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _rotation: 0,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Applies a rotation.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method rotate
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp rotate: function(deg)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var rotate = "rotate(" + deg + "deg)";
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._rotation = deg;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._updateTransform("rotate", /rotate\(.*\)/, rotate);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * An array of x, y values which indicates the transformOrigin in which to rotate the shape. Valid values range between 0 and 1 representing a
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * fraction of the shape's corresponding bounding box dimension. The default value is [0.5, 0.5].
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute transformOrigin
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Array
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _transformOrigin: function(x, y)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = this.get("node");
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.MozTransformOrigin = (100 * x) + "% " + (100 * y) + "%";
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Applies a scale transform
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method scale
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} val
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp scale: function(val)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Applies a matrix transformation
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method matrix
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp matrix: function(a, b, c, d, e, f)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _updateTransform: function(type, test, val)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = this.get("node"),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp transform = node.style.MozTransform || node.style.webkitTransform || node.style.msTransform || node.style.OTransform,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp transformOrigin = this.get("transformOrigin");
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(transform && transform.length > 0)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(transform.indexOf(type) > -1)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp transform = transform.replace(test, val);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp transform += " " + val;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp transform = val;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp transformOrigin = (100 * transformOrigin[0]) + "% " + (100 * transformOrigin[1]) + "%";
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.MozTransformOrigin = transformOrigin;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.webkitTransformOrigin = transformOrigin;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.msTransformOrigin = transformOrigin;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.OTransformOrigin = transformOrigin;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.MozTransform = transform;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.webkitTransform = transform;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.msTransform = transform;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.style.OTransform = transform;
a89ad754cce3cfc8aee71760e10217b54020360dTripp this._graphic.addToRedrawQueue(this);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _updateHandler: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._draw();
a89ad754cce3cfc8aee71760e10217b54020360dTripp this._graphic.addToRedrawQueue(this);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _draw: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this.clear();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._paint();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Completes a shape or drawing
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _paint
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _paint: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(!this._methods)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var node = this.get("node"),
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp w = this._right - this._left,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp h = this._bottom - this._top,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context = this._context,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp methods = [],
828c58761d90445b8b9d20a82d85dc1479317f71Tripp cachedMethods = this._methods.concat(),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp i = 0,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp j,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp method,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp argsLen,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp len = 0;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._context.clearRect(0, 0, node.width, node.height);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(this._methods)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp len = cachedMethods.length;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(!len || len < 1)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp return;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp for(; i < len; ++i)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp methods[i] = cachedMethods[i].concat();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args = methods[i];
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp argsLen = args[0] == "quadraticCurveTo" ? args.length : 3;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp for(j = 1; j < argsLen; ++j)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(j % 2 === 0)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args[j] = args[j] - this._top;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args[j] = args[j] - this._left;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp node.setAttribute("width", w);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node.setAttribute("height", h);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.beginPath();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp for(i = 0; i < len; ++i)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args = methods[i].concat();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(args && args.length > 0)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp method = args.shift();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(method)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(method && method == "lineTo" && this._dashstyle)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp args.unshift(this._xcoords[i] - this._left, this._ycoords[i] - this._top);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._drawDashedLine.apply(this, args);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp else
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp context[method].apply(context, args);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if (this._fillType)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(this._fillType == "linear")
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.fillStyle = this._getLinearGradient();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else if(this._fillType == "radial")
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.fillStyle = this._getRadialGradient();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.fillStyle = this._fillColor;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.closePath();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.fill();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if (this._stroke) {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(this._strokeWeight)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.lineWidth = this._strokeWeight;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.lineCap = this._linecap;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.lineJoin = this._linejoin;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(this._miterlimit)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.miterLimit = this._miterlimit;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.strokeStyle = this._strokeStyle;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.stroke();
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._drawingComplete = true;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._clearAndUpdateCoords();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._updateNodePosition();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._methods = cachedMethods;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Draws a dashed line between two points.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method _drawDashedLine
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} xStart The x position of the start of the line
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} yStart The y position of the start of the line
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} xEnd The x position of the end of the line
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @param {Number} yEnd The y position of the end of the line
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @private
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp _drawDashedLine: function(xStart, yStart, xEnd, yEnd)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var context = this._context,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp dashsize = this._dashstyle[0],
828c58761d90445b8b9d20a82d85dc1479317f71Tripp gapsize = this._dashstyle[1],
828c58761d90445b8b9d20a82d85dc1479317f71Tripp segmentLength = dashsize + gapsize,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp xDelta = xEnd - xStart,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp yDelta = yEnd - yStart,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp delta = Math.sqrt(Math.pow(xDelta, 2) + Math.pow(yDelta, 2)),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp segmentCount = Math.floor(Math.abs(delta / segmentLength)),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp radians = Math.atan2(yDelta, xDelta),
828c58761d90445b8b9d20a82d85dc1479317f71Tripp xCurrent = xStart,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp yCurrent = yStart,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp i;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp xDelta = Math.cos(radians) * segmentLength;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp yDelta = Math.sin(radians) * segmentLength;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp for(i = 0; i < segmentCount; ++i)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.moveTo(xCurrent, yCurrent);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.lineTo(xCurrent + Math.cos(radians) * dashsize, yCurrent + Math.sin(radians) * dashsize);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp xCurrent += xDelta;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp yCurrent += yDelta;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.moveTo(xCurrent, yCurrent);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp delta = Math.sqrt((xEnd - xCurrent) * (xEnd - xCurrent) + (yEnd - yCurrent) * (yEnd - yCurrent));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(delta > dashsize)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.lineTo(xCurrent + Math.cos(radians) * dashsize, yCurrent + Math.sin(radians) * dashsize);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp else if(delta > 0)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.lineTo(xCurrent + Math.cos(radians) * delta, yCurrent + Math.sin(radians) * delta);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp context.moveTo(xEnd, yEnd);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Clears the graphics object.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @method clear
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp clear: function() {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp var w = this._width, //this.get("width"),
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp h = this._height; //this.get("height");
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._initProps();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(this.node)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._context.clearRect(0, 0, this.node.width, this.node.height);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return this;
a89ad754cce3cfc8aee71760e10217b54020360dTripp },
a89ad754cce3cfc8aee71760e10217b54020360dTripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp /**
a89ad754cce3cfc8aee71760e10217b54020360dTripp * Returns the bounds for a shape.
a89ad754cce3cfc8aee71760e10217b54020360dTripp *
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @method getBounds
a89ad754cce3cfc8aee71760e10217b54020360dTripp * @return Object
a89ad754cce3cfc8aee71760e10217b54020360dTripp */
a89ad754cce3cfc8aee71760e10217b54020360dTripp getBounds: function()
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp var rotation = this.get("rotation"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp radCon = Math.PI/180,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp sinRadians = parseFloat(parseFloat(Math.sin(rotation * radCon)).toFixed(8)),
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp cosRadians = parseFloat(parseFloat(Math.cos(rotation * radCon)).toFixed(8)),
a89ad754cce3cfc8aee71760e10217b54020360dTripp w = this.get("width"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp h = this.get("height"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp stroke = this.get("stroke"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp x = this.get("x"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp y = this.get("y"),
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp right = x + w,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bottom = y + h,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp tlx,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp tly,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp blx,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bly,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp brx,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bry,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp trx,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp trY,
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp wt = 0,
a89ad754cce3cfc8aee71760e10217b54020360dTripp tx = this.get("translateX"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp ty = this.get("translateY"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp bounds = {},
a89ad754cce3cfc8aee71760e10217b54020360dTripp transformOrigin = this.get("transformOrigin"),
a89ad754cce3cfc8aee71760e10217b54020360dTripp tox = transformOrigin[0],
a89ad754cce3cfc8aee71760e10217b54020360dTripp toy = transformOrigin[1];
a89ad754cce3cfc8aee71760e10217b54020360dTripp if(stroke && stroke.weight)
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp wt = stroke.weight;
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(rotation !== 0)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp tox = x + (tox * w);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp toy = y + (toy * h);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp tlx = this._getRotatedCornerX(x, y, tox, toy, cosRadians, sinRadians);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp tly = this._getRotatedCornerY(x, y, tox, toy, cosRadians, sinRadians);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp blx = this._getRotatedCornerX(x, bottom, tox, toy, cosRadians, sinRadians);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bly = this._getRotatedCornerY(x, bottom, tox, toy, cosRadians, sinRadians);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp brx = this._getRotatedCornerX(right, bottom, tox, toy, cosRadians, sinRadians);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bry = this._getRotatedCornerY(right, bottom, tox, toy, cosRadians, sinRadians);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp trx = this._getRotatedCornerX(right, y, tox, toy, cosRadians, sinRadians);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp trY = this._getRotatedCornerY(right, y, tox, toy, cosRadians, sinRadians);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bounds.left = Math.min(tlx, Math.min(blx, Math.min(brx, trx)));
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bounds.right = Math.max(tlx, Math.max(blx, Math.max(brx, trx)));
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bounds.top = Math.min(tly, Math.min(bly, Math.min(bry, trY)));
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bounds.bottom = Math.max(tly, Math.max(bly, Math.max(bry, trY)));
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp else
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bounds.left = x - wt + tx;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bounds.top = y - wt + ty;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bounds.right = x + w + wt + tx;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp bounds.bottom = y + h + wt + ty;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
a89ad754cce3cfc8aee71760e10217b54020360dTripp return bounds;
a89ad754cce3cfc8aee71760e10217b54020360dTripp },
a89ad754cce3cfc8aee71760e10217b54020360dTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Returns the x coordinate for a bounding box's corner based on the corner's original x/y coordinates, rotation and transform origin of the rotation.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method _getRotatedCornerX
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} x original x-coordinate of corner
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} y original y-coordinate of corner
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} tox transform origin x-coordinate of rotation
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} toy transform origin y-coordinate of rotation
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} cosRadians cosine (in radians) of rotation
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} sinRadians sin (in radians) or rotation
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @return Number
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @private
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp _getRotatedCornerX: function(x, y, tox, toy, cosRadians, sinRadians)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return (tox + (x - tox) * cosRadians + (y - toy) * sinRadians);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp /**
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * Returns the y coordinate for a bounding box's corner based on the corner's original x/y coordinates, rotation and transform origin of the rotation.
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp *
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @method _getRotatedCornerY
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} x original x-coordinate of corner
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} y original y-coordinate of corner
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} tox transform origin x-coordinate of rotation
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} toy transform origin y-coordinate of rotation
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} cosRadians cosine (in radians) of rotation
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @param {Number} sinRadians sin (in radians) or rotation
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @return Number
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp * @private
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp _getRotatedCornerY: function(x, y, tox, toy, cosRadians, sinRadians)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return (toy - (x - tox) * sinRadians + (y - toy) * cosRadians);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
a89ad754cce3cfc8aee71760e10217b54020360dTripp destroy: function()
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp var node = this.node,
a89ad754cce3cfc8aee71760e10217b54020360dTripp context = this._context,
a89ad754cce3cfc8aee71760e10217b54020360dTripp w = this.get("width") || 0,
a89ad754cce3cfc8aee71760e10217b54020360dTripp h = this.get("height") || 0;
a89ad754cce3cfc8aee71760e10217b54020360dTripp if(node)
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
a89ad754cce3cfc8aee71760e10217b54020360dTripp if(context)
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp context.clearRect(0, 0, node.width, node.height);
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(this._graphic && this._graphic._node)
a89ad754cce3cfc8aee71760e10217b54020360dTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp this._graphic._node.removeChild(this.node);
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
a89ad754cce3cfc8aee71760e10217b54020360dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp}));
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71TrippCanvasShape.ATTRS = {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * An array of x, y values which indicates the transformOrigin in which to rotate the shape. Valid values range between 0 and 1 representing a
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * fraction of the shape's corresponding bounding box dimension. The default value is [0.5, 0.5].
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute transformOrigin
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Array
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp transformOrigin: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp valueFn: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return [0.5, 0.5];
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * The rotation (in degrees) of the shape.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute rotation
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp rotation: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp setter: function(val)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this.rotate(val);
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp },
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp getter: function()
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return this._rotation;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Dom node of the shape
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute node
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type HTMLElement
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @readOnly
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp node: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp readOnly: true,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp getter: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return this.node;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Unique id for class instance.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute id
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type String
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp id: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp valueFn: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return Y.guid();
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp setter: function(val)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp var node = this.node;
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp if(node)
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp node.setAttribute("id", val);
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp }
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp return val;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
e7c7565d9550eaa87043aef0df77125ada996deaTripp * Indicates the width of the shape
e7c7565d9550eaa87043aef0df77125ada996deaTripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute width
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp width: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp value: 0
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
e7c7565d9550eaa87043aef0df77125ada996deaTripp * Indicates the height of the shape
e7c7565d9550eaa87043aef0df77125ada996deaTripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute height
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp height: {
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp value: 0
c7ba96d16d58075a9ab8d5c1e46c6c83ce11cb4eTripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
e7c7565d9550eaa87043aef0df77125ada996deaTripp * Indicates the x position of shape.
e7c7565d9550eaa87043aef0df77125ada996deaTripp *
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @attribute x
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp x: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp value: 0
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
e7c7565d9550eaa87043aef0df77125ada996deaTripp * Indicates the y position of shape.
e7c7565d9550eaa87043aef0df77125ada996deaTripp *
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @attribute y
e7c7565d9550eaa87043aef0df77125ada996deaTripp * @type Number
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp y: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp value: 0
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Indicates whether the shape is visible.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute visible
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Boolean
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp visible: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp value: true,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp setter: function(val){
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var visibility = val ? "visible" : "hidden";
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this.get("node").style.visibility = visibility;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return val;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Contains information about the fill of the shape.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dl>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>color</dt><dd>The color of the fill.</dd>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the fill. The default value is 1.</dd>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dt>type</dt><dd>Type of fill.
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dl>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dt>solid</dt><dd>Solid single color fill. (default)</dd>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dt>linear</dt><dd>Linear gradient fill.</dd>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dt>radial</dt><dd>Radial gradient fill.</dd>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * </dl>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * </dd>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * </dl>
e7c7565d9550eaa87043aef0df77125ada996deaTripp *
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <p>If a gradient (linear or radial) is specified as the fill type. The following properties are used:
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dl>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dt>stops</dt><dd>An array of objects containing the following properties:
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dl>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dt>color</dt><dd>The color of the stop.</dd>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stop. The default value is 1. Note: No effect for IE <= 8</dd>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dt>offset</dt><dd>Number between 0 and 1 indicating where the color stop is positioned.</dd>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * </dl>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * </dd>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dt></dt><dd></dd>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dt></dt><dd></dd>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * <dt></dt><dd></dd>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * </dl>
e7c7565d9550eaa87043aef0df77125ada996deaTripp * </p>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute fill
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Object
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp fill: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp valueFn: "_getDefaultFill",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp setter: function(val)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var fill,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp tmpl = this.get("fill") || this._getDefaultFill();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp fill = (val) ? Y.merge(tmpl, val) : null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(fill && fill.color)
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp if(fill.color === undefined || fill.color == "none")
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp fill.color = null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._setFillProps(fill);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return fill;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Contains information about the stroke of the shape.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dl>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>color</dt><dd>The color of the stroke.</dd>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>weight</dt><dd>Number that indicates the width of the stroke.</dd>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>opacity</dt><dd>Number between 0 and 1 that indicates the opacity of the stroke. The default value is 1.</dd>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * <dt>dashstyle</dt>Indicates whether to draw a dashed stroke. When set to "none", a solid stroke is drawn. When set to an array, the first index indicates the
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * length of the dash. The second index indicates the length of gap.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * </dl>
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute stroke
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Object
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp stroke: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp valueFn: "_getDefaultStroke",
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp setter: function(val)
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp var tmpl = this.get("stroke") || this._getDefaultStroke();
828c58761d90445b8b9d20a82d85dc1479317f71Tripp val = (val) ? Y.merge(tmpl, val) : null;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp this._setStrokeProps(val);
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return val;
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Indicates whether or not the instance will size itself based on its contents.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute autoSize
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Boolean
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp autoSize: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp value: false
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Determines whether the instance will receive mouse events.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute pointerEvents
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type string
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp pointerEvents: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp value: "visiblePainted"
828c58761d90445b8b9d20a82d85dc1479317f71Tripp },
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp /**
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * Reference to the container Graphic.
828c58761d90445b8b9d20a82d85dc1479317f71Tripp *
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @attribute graphic
828c58761d90445b8b9d20a82d85dc1479317f71Tripp * @type Graphic
828c58761d90445b8b9d20a82d85dc1479317f71Tripp */
828c58761d90445b8b9d20a82d85dc1479317f71Tripp graphic: {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp readOnly: true,
828c58761d90445b8b9d20a82d85dc1479317f71Tripp
828c58761d90445b8b9d20a82d85dc1479317f71Tripp getter: function()
828c58761d90445b8b9d20a82d85dc1479317f71Tripp {
828c58761d90445b8b9d20a82d85dc1479317f71Tripp return this._graphic;
09688ec5ffb8b9cf9883a770e2f9ebd60b28888dTripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp }
828c58761d90445b8b9d20a82d85dc1479317f71Tripp};
828c58761d90445b8b9d20a82d85dc1479317f71TrippY.CanvasShape = CanvasShape;