Debian Codegraph @

closure-library/closure/goog/graphics/ext/ellipse.js

raw
1 // Copyright 2007 The Closure Library Authors. All Rights Reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS-IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15
16 /**
17 * @fileoverview A thick wrapper around ellipses.
18 * @author [email protected] (Robby Walker)
19 */
20
21
22 goog.provide('goog.graphics.ext.Ellipse');
23
24 goog.require('goog.graphics.ext.StrokeAndFillElement');
25
26
27
28 /**
29 * Wrapper for a graphics ellipse element.
30 * @param {goog.graphics.ext.Group} group Parent for this element.
31 * @constructor
32 * @extends {goog.graphics.ext.StrokeAndFillElement}
33 * @final
34 */
35 goog.graphics.ext.Ellipse = function(group) {
36 // Initialize with some stock values.
37 var wrapper = group.getGraphicsImplementation().drawEllipse(
38 1, 1, 2, 2, null, null, group.getWrapper());
39 goog.graphics.ext.StrokeAndFillElement.call(this, group, wrapper);
40 };
41 goog.inherits(
42 goog.graphics.ext.Ellipse, goog.graphics.ext.StrokeAndFillElement);
43
44
45 /**
46 * Redraw the ellipse. Called when the coordinate system is changed.
47 * @protected
48 * @override
49 */
50 goog.graphics.ext.Ellipse.prototype.redraw = function() {
51 goog.graphics.ext.Ellipse.superClass_.redraw.call(this);
52
53 // Our position is already transformed in transform_, but because this is an
54 // ellipse we need to position the center.
55 var xRadius = this.getWidth() / 2;
56 var yRadius = this.getHeight() / 2;
57 var wrapper = this.getWrapper();
58 wrapper.setCenter(xRadius, yRadius);
59 wrapper.setRadius(xRadius, yRadius);
60 };