Debian Codegraph @

closure-library/closure/goog/graphics/ext/image.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 images.
18 * @author [email protected] (Robby Walker)
19 */
20
21
22 goog.provide('goog.graphics.ext.Image');
23
24 goog.require('goog.graphics.ext.Element');
25
26
27
28 /**
29 * Wrapper for a graphics image element.
30 * @param {goog.graphics.ext.Group} group Parent for this element.
31 * @param {string} src The path to the image to display.
32 * @constructor
33 * @extends {goog.graphics.ext.Element}
34 * @final
35 */
36 goog.graphics.ext.Image = function(group, src) {
37 // Initialize with some stock values.
38 var wrapper = group.getGraphicsImplementation().drawImage(
39 0, 0, 1, 1, src, group.getWrapper());
40 goog.graphics.ext.Element.call(this, group, wrapper);
41 };
42 goog.inherits(goog.graphics.ext.Image, goog.graphics.ext.Element);
43
44
45 /**
46 * Redraw the image. Called when the coordinate system is changed.
47 * @protected
48 * @override
49 */
50 goog.graphics.ext.Image.prototype.redraw = function() {
51 goog.graphics.ext.Image.superClass_.redraw.call(this);
52
53 // Our position is already handled bu transform_.
54 this.getWrapper().setSize(this.getWidth(), this.getHeight());
55 };
56
57
58 /**
59 * Update the source of the image.
60 * @param {string} src Source of the image.
61 */
62 goog.graphics.ext.Image.prototype.setSource = function(src) {
63 this.getWrapper().setSource(src);
64 };