2
YUI 3.10.3 (build 2fb5187)
3
Copyright 2013 Yahoo! Inc. All rights reserved.
4
Licensed under the BSD License.
5
http://yuilibrary.com/license/
8
YUI.add('graphics-group', function (Y, NAME) {
11
* The graphics-group submodule allows from drawing a shape multiple times within a single instance.
14
* @submodule graphics-group
24
* Abstract class for creating groups of shapes with the same styles and dimensions.
28
* @submodule graphics-group
31
ShapeGroup = function()
33
ShapeGroup.superclass.constructor.apply(this, arguments);
36
ShapeGroup.NAME = "shapeGroup";
38
Y.extend(ShapeGroup, Y.Path, {
47
var xvalues = this.get("xvalues"),
48
yvalues = this.get("yvalues"),
55
dimensions = this.get("dimensions"),
56
width = dimensions.width,
57
height = dimensions.height,
58
radius = dimensions.radius,
59
yRadius = dimensions.yRadius,
60
widthIsArray = Y_Lang.isArray(width),
61
heightIsArray = Y_Lang.isArray(height),
62
radiusIsArray = Y_Lang.isArray(radius),
63
yRadiusIsArray = Y_Lang.isArray(yRadius);
64
if(xvalues && yvalues && xvalues.length > 0)
73
xRad = radiusIsArray ? radius[i] : radius;
74
yRad = yRadiusIsArray ? yRadius[i] : yRadius;
75
if(!isNaN(x) && !isNaN(y) && !isNaN(xRad))
80
width: widthIsArray ? width[i] : width,
81
height: heightIsArray ? height[i] : height,
93
* Parses and array of lengths into radii
95
* @method _getRadiusCollection
96
* @param {Array} val Array of lengths
100
_getRadiusCollection: function(val)
107
radii[i] = val[i] * 0.5;
113
ShapeGroup.ATTRS = Y.merge(Y.Path.ATTRS, {
117
var dimensions = this._dimensions,
122
if(dimensions.hasOwnProperty("radius"))
128
width = dimensions.width;
129
height = dimensions.height;
130
radius = Y_Lang.isArray(width) ? this._getRadiusCollection(width) : (width * 0.5);
131
yRadius = Y_Lang.isArray(height) ? this._getRadiusCollection(height) : (height * 0.5);
141
setter: function(val)
143
this._dimensions = val;
150
return this._xvalues;
152
setter: function(val)
160
return this._yvalues;
162
setter: function(val)
168
Y.ShapeGroup = ShapeGroup;
170
* Abstract class for creating groups of circles with the same styles and dimensions.
174
* @submodule graphics-group
176
CircleGroup = function()
178
CircleGroup.superclass.constructor.apply(this, arguments);
181
CircleGroup.NAME = "circleGroup";
183
Y.extend(CircleGroup, Y.ShapeGroup, {
185
* Algorithm for drawing shape.
188
* @param {Object} cfg Parameters used to draw the shape.
190
drawShape: function(cfg)
192
this.drawCircle(cfg.x, cfg.y, cfg.radius);
196
CircleGroup.ATTRS = Y.merge(Y.ShapeGroup.ATTRS, {
200
var dimensions = this._dimensions,
205
if(dimensions.hasOwnProperty("radius"))
211
width = dimensions.width;
212
height = dimensions.height;
213
radius = Y_Lang.isArray(width) ? this._getRadiusCollection(width) : (width * 0.5);
226
CircleGroup.ATTRS = Y.ShapeGroup.ATTRS;
227
Y.CircleGroup = CircleGroup;
229
* Abstract class for creating groups of rects with the same styles and dimensions.
233
* @submodule graphics-group
235
RectGroup = function()
237
RectGroup.superclass.constructor.apply(this, arguments);
240
RectGroup.NAME = "rectGroup";
242
Y.extend(RectGroup, Y.ShapeGroup, {
249
drawShape: function(cfg)
251
this.drawRect(cfg.x, cfg.y, cfg.width, cfg.height);
255
RectGroup.ATTRS = Y.ShapeGroup.ATTRS;
256
Y.RectGroup = RectGroup;
258
* Abstract class for creating groups of diamonds with the same styles and dimensions.
260
* @class GroupDiamond
262
* @submodule graphics-group
264
DiamondGroup = function()
266
DiamondGroup.superclass.constructor.apply(this, arguments);
269
DiamondGroup.NAME = "diamondGroup";
271
Y.extend(DiamondGroup, Y.ShapeGroup, {
273
* Updates the diamond.
278
drawShape: function(cfg)
280
this.drawDiamond(cfg.x, cfg.y, cfg.width, cfg.height);
284
DiamondGroup.ATTRS = Y.ShapeGroup.ATTRS;
285
Y.DiamondGroup = DiamondGroup;
287
* Abstract class for creating groups of ellipses with the same styles and dimensions.
289
* @class EllipseGroup
291
* @submodule graphics-group
293
EllipseGroup = function()
295
EllipseGroup.superclass.constructor.apply(this, arguments);
298
EllipseGroup.NAME = "ellipseGroup";
300
Y.extend(EllipseGroup, Y.ShapeGroup, {
302
* Updates the ellipse.
307
drawShape: function(cfg)
309
this.drawEllipse(cfg.x, cfg.y, cfg.width, cfg.height);
313
EllipseGroup.ATTRS = Y.ShapeGroup.ATTRS;
314
Y.EllipseGroup = EllipseGroup;
317
}, '3.10.3', {"requires": ["graphics"]});