aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/ui/roundedpanel.js
blob: c8d5a062a150ee2227f116be0e80d38df7f5658c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
// Copyright 2008 The Closure Library Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS-IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/**
 * @fileoverview Class definition for a rounded corner panel.
 * @supported IE 6.0+, Safari 2.0+, Firefox 1.5+, Opera 9.2+.
 * @see ../demos/roundedpanel.html
 */

goog.provide('goog.ui.BaseRoundedPanel');
goog.provide('goog.ui.CssRoundedPanel');
goog.provide('goog.ui.GraphicsRoundedPanel');
goog.provide('goog.ui.RoundedPanel');
goog.provide('goog.ui.RoundedPanel.Corner');

goog.require('goog.dom');
goog.require('goog.dom.classes');
goog.require('goog.graphics');
goog.require('goog.graphics.SolidFill');
goog.require('goog.graphics.Stroke');
goog.require('goog.math.Coordinate');
goog.require('goog.style');
goog.require('goog.ui.Component');
goog.require('goog.userAgent');


/**
 * Factory method that returns an instance of a BaseRoundedPanel.
 * @param {number} radius The radius of the rounded corner(s), in pixels.
 * @param {number} borderWidth The thickness of the border, in pixels.
 * @param {string} borderColor The border color of the panel.
 * @param {string=} opt_backgroundColor The background color of the panel.
 * @param {number=} opt_corners The corners of the panel to be rounded. Any
 *     corners not specified will be rendered as square corners. Will default
 *     to all square corners if not specified.
 * @param {goog.dom.DomHelper=} opt_domHelper The DOM helper object for the
 *     document we want to render in.
 * @return {goog.ui.BaseRoundedPanel} An instance of a
 *     goog.ui.BaseRoundedPanel subclass.
 */
goog.ui.RoundedPanel.create = function(radius,
                                       borderWidth,
                                       borderColor,
                                       opt_backgroundColor,
                                       opt_corners,
                                       opt_domHelper) {
  // This variable checks for the presence of Safari 3.0+ or Gecko 1.9+,
  // which can leverage special CSS styles to create rounded corners.
  var isCssReady = goog.userAgent.WEBKIT && goog.userAgent.isVersion('500') ||
      goog.userAgent.GECKO && goog.userAgent.isVersion('1.9a');

  if (isCssReady) {
    // Safari 3.0+ and Firefox 3.0+ support this instance.
    return new goog.ui.CssRoundedPanel(
        radius,
        borderWidth,
        borderColor,
        opt_backgroundColor,
        opt_corners,
        opt_domHelper);
  } else {
    return new goog.ui.GraphicsRoundedPanel(
        radius,
        borderWidth,
        borderColor,
        opt_backgroundColor,
        opt_corners,
        opt_domHelper);
  }
};


/**
 * Enum for specifying which corners to render.
 * @enum {number}
 */
goog.ui.RoundedPanel.Corner = {
  NONE: 0,
  BOTTOM_LEFT: 2,
  TOP_LEFT: 4,
  LEFT: 6, // BOTTOM_LEFT | TOP_LEFT
  TOP_RIGHT: 8,
  TOP: 12, // TOP_LEFT | TOP_RIGHT
  BOTTOM_RIGHT: 1,
  BOTTOM: 3, // BOTTOM_LEFT | BOTTOM_RIGHT
  RIGHT: 9, // TOP_RIGHT | BOTTOM_RIGHT
  ALL: 15 // TOP | BOTTOM
};


/**
 * CSS class name suffixes for the elements comprising the RoundedPanel.
 * @enum {string}
 * @private
 */
goog.ui.RoundedPanel.Classes_ = {
  BACKGROUND: goog.getCssName('goog-roundedpanel-background'),
  PANEL: goog.getCssName('goog-roundedpanel'),
  CONTENT: goog.getCssName('goog-roundedpanel-content')
};



/**
 * Base class for the hierarchy of RoundedPanel classes. Do not
 * instantiate directly. Instead, call goog.ui.RoundedPanel.create().
 * The HTML structure for the RoundedPanel is:
 * <pre>
 * - div (Contains the background and content. Class name: goog-roundedpanel)
 *   - div (Contains the background/rounded corners. Class name:
 *       goog-roundedpanel-bg)
 *   - div (Contains the content. Class name: goog-roundedpanel-content)
 * </pre>
 * @param {number} radius The radius of the rounded corner(s), in pixels.
 * @param {number} borderWidth The thickness of the border, in pixels.
 * @param {string} borderColor The border color of the panel.
 * @param {string=} opt_backgroundColor The background color of the panel.
 * @param {number=} opt_corners The corners of the panel to be rounded. Any
 *     corners not specified will be rendered as square corners. Will default
 *     to all square corners if not specified.
 * @param {goog.dom.DomHelper=} opt_domHelper The DOM helper object for the
 *     document we want to render in.
 * @extends {goog.ui.Component}
 * @constructor
 */
goog.ui.BaseRoundedPanel = function(radius,
                                    borderWidth,
                                    borderColor,
                                    opt_backgroundColor,
                                    opt_corners,
                                    opt_domHelper) {
  goog.ui.Component.call(this, opt_domHelper);

  /**
   * The radius of the rounded corner(s), in pixels.
   * @type {number}
   * @private
   */
  this.radius_ = radius;

  /**
   * The thickness of the border, in pixels.
   * @type {number}
   * @private
   */
  this.borderWidth_ = borderWidth;

  /**
   * The border color of the panel.
   * @type {string}
   * @private
   */
  this.borderColor_ = borderColor;

  /**
   * The background color of the panel.
   * @type {?string}
   * @private
   */
  this.backgroundColor_ = opt_backgroundColor || null;

  /**
   * The corners of the panel to be rounded; defaults to
   * goog.ui.RoundedPanel.Corner.NONE
   * @type {number}
   * @private
   */
  this.corners_ = opt_corners || goog.ui.RoundedPanel.Corner.NONE;
};
goog.inherits(goog.ui.BaseRoundedPanel, goog.ui.Component);


/**
 * The element containing the rounded corners and background.
 * @type {Element}
 * @private
 */
goog.ui.BaseRoundedPanel.prototype.backgroundElement_;


/**
 * The element containing the actual content.
 * @type {Element}
 * @private
 */
goog.ui.BaseRoundedPanel.prototype.contentElement_;


/**
 * This method performs all the necessary DOM manipulation to create the panel.
 * Overrides {@link goog.ui.Component#decorateInternal}.
 * @param {Element} element The element to decorate.
 * @protected
 * @override
 */
goog.ui.BaseRoundedPanel.prototype.decorateInternal = function(element) {
  goog.ui.BaseRoundedPanel.superClass_.decorateInternal.call(this, element);
  goog.dom.classes.add(this.getElement(), goog.ui.RoundedPanel.Classes_.PANEL);

  // Create backgroundElement_, and add it to the DOM.
  this.backgroundElement_ = this.getDomHelper().createElement('div');
  this.backgroundElement_.className = goog.ui.RoundedPanel.Classes_.BACKGROUND;
  this.getElement().appendChild(this.backgroundElement_);

  // Set contentElement_ by finding a child node within element_ with the
  // proper class name. If none exists, create it and add it to the DOM.
  this.contentElement_ = goog.dom.getElementsByTagNameAndClass(
      null, goog.ui.RoundedPanel.Classes_.CONTENT, this.getElement())[0];
  if (!this.contentElement_) {
    this.contentElement_ = this.getDomHelper().createDom('div');
    this.contentElement_.className = goog.ui.RoundedPanel.Classes_.CONTENT;
    this.getElement().appendChild(this.contentElement_);
  }
};


/** @override */
goog.ui.BaseRoundedPanel.prototype.disposeInternal = function() {
  if (this.backgroundElement_) {
    this.getDomHelper().removeNode(this.backgroundElement_);
    this.backgroundElement_ = null;
  }
  this.contentElement_ = null;
  goog.ui.BaseRoundedPanel.superClass_.disposeInternal.call(this);
};


/**
 * Returns the DOM element containing the actual content.
 * @return {Element} The element containing the actual content (null if none).
 * @override
 */
goog.ui.BaseRoundedPanel.prototype.getContentElement = function() {
  return this.contentElement_;
};



/**
 * RoundedPanel class specifically for browsers that support CSS attributes
 * for elements with rounded borders (ex. Safari 3.0+, Firefox 3.0+). Do not
 * instantiate directly. Instead, call goog.ui.RoundedPanel.create().
 * @param {number} radius The radius of the rounded corner(s), in pixels.
 * @param {number} borderWidth The thickness of the border, in pixels.
 * @param {string} borderColor The border color of the panel.
 * @param {string=} opt_backgroundColor The background color of the panel.
 * @param {number=} opt_corners The corners of the panel to be rounded. Any
 *     corners not specified will be rendered as square corners. Will
 *     default to all square corners if not specified.
 * @param {goog.dom.DomHelper=} opt_domHelper The DOM helper object for the
 *     document we want to render in.
 * @extends {goog.ui.BaseRoundedPanel}
 * @constructor
 */
goog.ui.CssRoundedPanel = function(radius,
                                   borderWidth,
                                   borderColor,
                                   opt_backgroundColor,
                                   opt_corners,
                                   opt_domHelper) {
  goog.ui.BaseRoundedPanel.call(this,
                                radius,
                                borderWidth,
                                borderColor,
                                opt_backgroundColor,
                                opt_corners,
                                opt_domHelper);
};
goog.inherits(goog.ui.CssRoundedPanel, goog.ui.BaseRoundedPanel);


/**
 * This method performs all the necessary DOM manipulation to create the panel.
 * Overrides {@link goog.ui.Component#decorateInternal}.
 * @param {Element} element The element to decorate.
 * @protected
 * @override
 */
goog.ui.CssRoundedPanel.prototype.decorateInternal = function(element) {
  goog.ui.CssRoundedPanel.superClass_.decorateInternal.call(this, element);

  // Set the border width and background color, if needed.
  this.backgroundElement_.style.border = this.borderWidth_ +
      'px solid ' +
      this.borderColor_;
  if (this.backgroundColor_) {
    this.backgroundElement_.style.backgroundColor = this.backgroundColor_;
  }

  // Set radii of the appropriate rounded corners.
  if (this.corners_ == goog.ui.RoundedPanel.Corner.ALL) {
    var styleName = this.getStyle_(goog.ui.RoundedPanel.Corner.ALL);
    this.backgroundElement_.style[styleName] = this.radius_ + 'px';
  } else {
    var topLeftRadius =
        this.corners_ & goog.ui.RoundedPanel.Corner.TOP_LEFT ?
        this.radius_ :
        0;
    var cornerStyle = this.getStyle_(goog.ui.RoundedPanel.Corner.TOP_LEFT);
    this.backgroundElement_.style[cornerStyle] = topLeftRadius + 'px';
    var topRightRadius =
        this.corners_ & goog.ui.RoundedPanel.Corner.TOP_RIGHT ?
        this.radius_ :
        0;
    cornerStyle = this.getStyle_(goog.ui.RoundedPanel.Corner.TOP_RIGHT);
    this.backgroundElement_.style[cornerStyle] = topRightRadius + 'px';
    var bottomRightRadius =
        this.corners_ & goog.ui.RoundedPanel.Corner.BOTTOM_RIGHT ?
        this.radius_ :
        0;
    cornerStyle = this.getStyle_(goog.ui.RoundedPanel.Corner.BOTTOM_RIGHT);
    this.backgroundElement_.style[cornerStyle] = bottomRightRadius + 'px';
    var bottomLeftRadius =
        this.corners_ & goog.ui.RoundedPanel.Corner.BOTTOM_LEFT ?
        this.radius_ :
        0;
    cornerStyle = this.getStyle_(goog.ui.RoundedPanel.Corner.BOTTOM_LEFT);
    this.backgroundElement_.style[cornerStyle] = bottomLeftRadius + 'px';
  }
};


/**
 * This method returns the CSS style based on the corner of the panel, and the
 * user-agent.
 * @param {number} corner The corner whose style name to retrieve.
 * @private
 * @return {string} The CSS style based on the specified corner.
 */
goog.ui.CssRoundedPanel.prototype.getStyle_ = function(corner) {
  // Determine the proper corner to work with.
  var cssCorner, suffixLeft, suffixRight;
  if (goog.userAgent.WEBKIT) {
    suffixLeft = 'Left';
    suffixRight = 'Right';
  } else {
    suffixLeft = 'left';
    suffixRight = 'right';
  }
  switch (corner) {
    case goog.ui.RoundedPanel.Corner.ALL:
      cssCorner = '';
      break;
    case goog.ui.RoundedPanel.Corner.TOP_LEFT:
      cssCorner = 'Top' + suffixLeft;
      break;
    case goog.ui.RoundedPanel.Corner.TOP_RIGHT:
      cssCorner = 'Top' + suffixRight;
      break;
    case goog.ui.RoundedPanel.Corner.BOTTOM_LEFT:
      cssCorner = 'Bottom' + suffixLeft;
      break;
    case goog.ui.RoundedPanel.Corner.BOTTOM_RIGHT:
      cssCorner = 'Bottom' + suffixRight;
      break;
  }

  return goog.userAgent.WEBKIT ?
      'WebkitBorder' + cssCorner + 'Radius' :
      'MozBorderRadius' + cssCorner;
};



/**
 * RoundedPanel class that uses goog.graphics to create the rounded corners.
 * Do not instantiate directly. Instead, call goog.ui.RoundedPanel.create().
 * @param {number} radius The radius of the rounded corner(s), in pixels.
 * @param {number} borderWidth The thickness of the border, in pixels.
 * @param {string} borderColor The border color of the panel.
 * @param {string=} opt_backgroundColor The background color of the panel.
 * @param {number=} opt_corners The corners of the panel to be rounded. Any
 *     corners not specified will be rendered as square corners. Will
 *     default to all square corners if not specified.
 * @param {goog.dom.DomHelper=} opt_domHelper The DOM helper object for the
 *     document we want to render in.
 * @extends {goog.ui.BaseRoundedPanel}
 * @constructor
 */
goog.ui.GraphicsRoundedPanel = function(radius,
                                        borderWidth,
                                        borderColor,
                                        opt_backgroundColor,
                                        opt_corners,
                                        opt_domHelper) {
  goog.ui.BaseRoundedPanel.call(this,
                                radius,
                                borderWidth,
                                borderColor,
                                opt_backgroundColor,
                                opt_corners,
                                opt_domHelper);
};
goog.inherits(goog.ui.GraphicsRoundedPanel, goog.ui.BaseRoundedPanel);


/**
 * A 4-element array containing the circle centers for the arcs in the
 * bottom-left, top-left, top-right, and bottom-right corners, respectively.
 * @type {Array.<goog.math.Coordinate>}
 * @private
 */
goog.ui.GraphicsRoundedPanel.prototype.arcCenters_;


/**
 * A 4-element array containing the start coordinates for rendering the arcs
 * in the bottom-left, top-left, top-right, and bottom-right corners,
 * respectively.
 * @type {Array.<goog.math.Coordinate>}
 * @private
 */
goog.ui.GraphicsRoundedPanel.prototype.cornerStarts_;


/**
 * A 4-element array containing the arc end angles for the bottom-left,
 * top-left, top-right, and bottom-right corners, respectively.
 * @type {Array.<number>}
 * @private
 */
goog.ui.GraphicsRoundedPanel.prototype.endAngles_;


/**
 * Graphics object for rendering the background.
 * @type {goog.graphics.AbstractGraphics}
 * @private
 */
goog.ui.GraphicsRoundedPanel.prototype.graphics_;


/**
 * A 4-element array containing the rounded corner radii for the bottom-left,
 * top-left, top-right, and bottom-right corners, respectively.
 * @type {Array.<number>}
 * @private
 */
goog.ui.GraphicsRoundedPanel.prototype.radii_;


/**
 * A 4-element array containing the arc start angles for the bottom-left,
 * top-left, top-right, and bottom-right corners, respectively.
 * @type {Array.<number>}
 * @private
 */
goog.ui.GraphicsRoundedPanel.prototype.startAngles_;


/**
 * Thickness constant used as an offset to help determine where to start
 * rendering.
 * @type {number}
 * @private
 */
goog.ui.GraphicsRoundedPanel.BORDER_WIDTH_FACTOR_ = 1 / 2;


/**
 * This method performs all the necessary DOM manipulation to create the panel.
 * Overrides {@link goog.ui.Component#decorateInternal}.
 * @param {Element} element The element to decorate.
 * @protected
 * @override
 */
goog.ui.GraphicsRoundedPanel.prototype.decorateInternal =
    function(element) {
  goog.ui.GraphicsRoundedPanel.superClass_.decorateInternal.call(this,
                                                                 element);

  // Calculate the points and angles for creating the rounded corners. Then
  // instantiate a Graphics object for drawing purposes.
  var elementSize = goog.style.getSize(this.getElement());
  this.calculateArcParameters_(elementSize);
  this.graphics_ = goog.graphics.createGraphics(
      /** @type {number} */ (elementSize.width),
      /** @type {number} */ (elementSize.height),
      /** @type {number} */ (elementSize.width),
      /** @type {number} */ (elementSize.height),
      this.getDomHelper());
  this.graphics_.createDom();

  // Create the path, starting from the bottom-right corner, moving clockwise.
  // End with the top-right corner.
  var path = new goog.graphics.Path();
  for (var i = 0; i < 4; i++) {
    if (this.radii_[i]) {
      // If radius > 0, draw an arc, moving to the first point and drawing
      // a line to the others.
      var cx = this.arcCenters_[i].x;
      var cy = this.arcCenters_[i].y;
      var rx = this.radii_[i];
      var ry = rx;
      var fromAngle = this.startAngles_[i];
      var extent = this.endAngles_[i] - fromAngle;
      var startX = cx + goog.math.angleDx(fromAngle, rx);
      var startY = cy + goog.math.angleDy(fromAngle, ry);
      if (i > 0) {
        var currentPoint = path.getCurrentPoint();
        if (!currentPoint || startX != currentPoint[0] ||
            startY != currentPoint[1]) {
          path.lineTo(startX, startY);
        }
      } else {
        path.moveTo(startX, startY);
      }
      path.arcTo(rx, ry, fromAngle, extent);
    } else if (i == 0) {
      // If we're just starting out (ie. i == 0), move to the starting point.
      path.moveTo(this.cornerStarts_[i].x,
                  this.cornerStarts_[i].y);
    } else {
      // Otherwise, draw a line to the starting point.
      path.lineTo(this.cornerStarts_[i].x,
                  this.cornerStarts_[i].y);
    }
  }

  // Close the path, create a stroke object, and fill the enclosed area, if
  // needed. Then render the path.
  path.close();
  var stroke = this.borderWidth_ ?
      new goog.graphics.Stroke(this.borderWidth_, this.borderColor_) :
      null;
  var fill = this.backgroundColor_ ?
      new goog.graphics.SolidFill(this.backgroundColor_, 1) :
      null;
  this.graphics_.drawPath(path, stroke, fill);
  this.graphics_.render(this.backgroundElement_);
};


/** @override */
goog.ui.GraphicsRoundedPanel.prototype.disposeInternal = function() {
  goog.ui.GraphicsRoundedPanel.superClass_.disposeInternal.call(this);
  this.graphics_.dispose();
  delete this.graphics_;
  delete this.radii_;
  delete this.cornerStarts_;
  delete this.arcCenters_;
  delete this.startAngles_;
  delete this.endAngles_;
};


/**
 * Calculates the start coordinates, circle centers, and angles, for the rounded
 * corners at each corner of the panel.
 * @param {goog.math.Size} elementSize The size of element_.
 * @private
 */
goog.ui.GraphicsRoundedPanel.prototype.calculateArcParameters_ =
    function(elementSize) {
  // Initialize the arrays containing the key points and angles.
  this.radii_ = [];
  this.cornerStarts_ = [];
  this.arcCenters_ = [];
  this.startAngles_ = [];
  this.endAngles_ = [];

  // Set the start points, circle centers, and angles for the bottom-right,
  // bottom-left, top-left and top-right corners, in that order.
  var angleInterval = 90;
  var borderWidthOffset = this.borderWidth_ *
      goog.ui.GraphicsRoundedPanel.BORDER_WIDTH_FACTOR_;
  var radius, xStart, yStart, xCenter, yCenter, startAngle, endAngle;
  for (var i = 0; i < 4; i++) {
    var corner = Math.pow(2, i);  // Determines which corner we're dealing with.
    var isLeft = corner & goog.ui.RoundedPanel.Corner.LEFT;
    var isTop = corner & goog.ui.RoundedPanel.Corner.TOP;

    // Calculate the radius and the start coordinates.
    radius = corner & this.corners_ ? this.radius_ : 0;
    switch (corner) {
      case goog.ui.RoundedPanel.Corner.BOTTOM_LEFT:
        xStart = borderWidthOffset + radius;
        yStart = elementSize.height - borderWidthOffset;
        break;
      case goog.ui.RoundedPanel.Corner.TOP_LEFT:
        xStart = borderWidthOffset;
        yStart = radius + borderWidthOffset;
        break;
      case goog.ui.RoundedPanel.Corner.TOP_RIGHT:
        xStart = elementSize.width - radius - borderWidthOffset;
        yStart = borderWidthOffset;
        break;
      case goog.ui.RoundedPanel.Corner.BOTTOM_RIGHT:
        xStart = elementSize.width - borderWidthOffset;
        yStart = elementSize.height - radius - borderWidthOffset;
        break;
    }

    // Calculate the circle centers and start/end angles.
    xCenter = isLeft ?
        radius + borderWidthOffset :
        elementSize.width - radius - borderWidthOffset;
    yCenter = isTop ?
        radius + borderWidthOffset :
        elementSize.height - radius - borderWidthOffset;
    startAngle = angleInterval * i;
    endAngle = startAngle + angleInterval;

    // Append the radius, angles, and coordinates to their arrays.
    this.radii_[i] = radius;
    this.cornerStarts_[i] = new goog.math.Coordinate(xStart, yStart);
    this.arcCenters_[i] = new goog.math.Coordinate(xCenter, yCenter);
    this.startAngles_[i] = startAngle;
    this.endAngles_[i] = endAngle;
  }
};