Path: blob/trunk/third_party/closure/goog/graphics/strokeandfillelement.js
2868 views
// Copyright 2007 The Closure Library Authors. All Rights Reserved.1//2// Licensed under the Apache License, Version 2.0 (the "License");3// you may not use this file except in compliance with the License.4// You may obtain a copy of the License at5//6// http://www.apache.org/licenses/LICENSE-2.07//8// Unless required by applicable law or agreed to in writing, software9// distributed under the License is distributed on an "AS-IS" BASIS,10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.11// See the License for the specific language governing permissions and12// limitations under the License.131415/**16* @fileoverview A thin wrapper around the DOM element for elements with a17* stroke and fill.18* @author [email protected] (Erik Arvidsson)19*/202122goog.provide('goog.graphics.StrokeAndFillElement');2324goog.require('goog.graphics.Element');25262728/**29* Interface for a graphics element with a stroke and fill.30* This is the base interface for ellipse, rectangle and other31* shape interfaces.32* You should not construct objects from this constructor. The graphics33* will return an implementation of this interface for you.34*35* @param {Element} element The DOM element to wrap.36* @param {goog.graphics.AbstractGraphics} graphics The graphics creating37* this element.38* @param {goog.graphics.Stroke?} stroke The stroke to use for this element.39* @param {goog.graphics.Fill?} fill The fill to use for this element.40* @constructor41* @extends {goog.graphics.Element}42* @deprecated goog.graphics is deprecated. It existed to abstract over browser43* differences before the canvas tag was widely supported. See44* http://en.wikipedia.org/wiki/Canvas_element for details.45*/46goog.graphics.StrokeAndFillElement = function(element, graphics, stroke, fill) {47goog.graphics.Element.call(this, element, graphics);48this.setStroke(stroke);49this.setFill(fill);50};51goog.inherits(goog.graphics.StrokeAndFillElement, goog.graphics.Element);525354/**55* The latest fill applied to this element.56* @type {goog.graphics.Fill?}57* @protected58*/59goog.graphics.StrokeAndFillElement.prototype.fill = null;606162/**63* The latest stroke applied to this element.64* @type {goog.graphics.Stroke?}65* @private66*/67goog.graphics.StrokeAndFillElement.prototype.stroke_ = null;686970/**71* Sets the fill for this element.72* @param {goog.graphics.Fill?} fill The fill object.73*/74goog.graphics.StrokeAndFillElement.prototype.setFill = function(fill) {75this.fill = fill;76this.getGraphics().setElementFill(this, fill);77};787980/**81* @return {goog.graphics.Fill?} fill The fill object.82*/83goog.graphics.StrokeAndFillElement.prototype.getFill = function() {84return this.fill;85};868788/**89* Sets the stroke for this element.90* @param {goog.graphics.Stroke?} stroke The stroke object.91*/92goog.graphics.StrokeAndFillElement.prototype.setStroke = function(stroke) {93this.stroke_ = stroke;94this.getGraphics().setElementStroke(this, stroke);95};969798/**99* @return {goog.graphics.Stroke?} stroke The stroke object.100*/101goog.graphics.StrokeAndFillElement.prototype.getStroke = function() {102return this.stroke_;103};104105106/**107* Re-strokes the element to react to coordinate size changes.108*/109goog.graphics.StrokeAndFillElement.prototype.reapplyStroke = function() {110if (this.stroke_) {111this.setStroke(this.stroke_);112}113};114115116