Path: blob/trunk/third_party/closure/goog/graphics/ext/element.js
1865 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.1314/**15* @fileoverview A thicker wrapper around the DOM element returned from16* the different draw methods of the graphics implementation, and17* all interfaces that the various element types support.18* @author [email protected] (Robby Walker)19*/2021goog.provide('goog.graphics.ext.Element');2223goog.require('goog.events.EventTarget');24goog.require('goog.functions');25goog.require('goog.graphics.ext.coordinates');26272829/**30* Base class for a wrapper around the goog.graphics wrapper that enables31* more advanced functionality.32* @param {goog.graphics.ext.Group?} group Parent for this element.33* @param {goog.graphics.Element} wrapper The thin wrapper to wrap.34* @constructor35* @extends {goog.events.EventTarget}36*/37goog.graphics.ext.Element = function(group, wrapper) {38goog.events.EventTarget.call(this);39this.wrapper_ = wrapper;40this.graphics_ = group ? group.getGraphics() : this;4142this.xPosition_ = new goog.graphics.ext.Element.Position_(this, true);43this.yPosition_ = new goog.graphics.ext.Element.Position_(this, false);4445// Handle parent / child relationships.46if (group) {47this.parent_ = group;48this.parent_.addChild(this);49}50};51goog.inherits(goog.graphics.ext.Element, goog.events.EventTarget);525354/**55* The graphics object that contains this element.56* @type {goog.graphics.ext.Graphics|goog.graphics.ext.Element}57* @private58*/59goog.graphics.ext.Element.prototype.graphics_;606162/**63* The goog.graphics wrapper this class wraps.64* @type {goog.graphics.Element}65* @private66*/67goog.graphics.ext.Element.prototype.wrapper_;686970/**71* The group or surface containing this element.72* @type {goog.graphics.ext.Group|undefined}73* @private74*/75goog.graphics.ext.Element.prototype.parent_;767778/**79* Whether or not computation of this element's position or size depends on its80* parent's size.81* @type {boolean}82* @private83*/84goog.graphics.ext.Element.prototype.parentDependent_ = false;858687/**88* Whether the element has pending transformations.89* @type {boolean}90* @private91*/92goog.graphics.ext.Element.prototype.needsTransform_ = false;939495/**96* The current angle of rotation, expressed in degrees.97* @type {number}98* @private99*/100goog.graphics.ext.Element.prototype.rotation_ = 0;101102103/**104* Object representing the x position and size of the element.105* @type {goog.graphics.ext.Element.Position_}106* @private107*/108goog.graphics.ext.Element.prototype.xPosition_;109110111/**112* Object representing the y position and size of the element.113* @type {goog.graphics.ext.Element.Position_}114* @private115*/116goog.graphics.ext.Element.prototype.yPosition_;117118119/** @return {goog.graphics.Element} The underlying thin wrapper. */120goog.graphics.ext.Element.prototype.getWrapper = function() {121return this.wrapper_;122};123124125/**126* @return {goog.graphics.ext.Element|goog.graphics.ext.Graphics} The graphics127* surface the element is a part of.128*/129goog.graphics.ext.Element.prototype.getGraphics = function() {130return this.graphics_;131};132133134/**135* Returns the graphics implementation.136* @return {goog.graphics.AbstractGraphics} The underlying graphics137* implementation drawing this element's wrapper.138* @protected139*/140goog.graphics.ext.Element.prototype.getGraphicsImplementation = function() {141return this.graphics_.getImplementation();142};143144145/**146* @return {goog.graphics.ext.Group|undefined} The parent of this element.147*/148goog.graphics.ext.Element.prototype.getParent = function() {149return this.parent_;150};151152153// GENERAL POSITIONING154155156/**157* Internal convenience method for setting position - either as a left/top,158* center/middle, or right/bottom value. Only one should be specified.159* @param {goog.graphics.ext.Element.Position_} position The position object to160* set the value on.161* @param {number|string} value The value of the coordinate.162* @param {goog.graphics.ext.Element.PositionType_} type The type of the163* coordinate.164* @param {boolean=} opt_chain Optional flag to specify this function is part165* of a chain of calls and therefore transformations should be set as166* pending but not yet performed.167* @private168*/169goog.graphics.ext.Element.prototype.setPosition_ = function(170position, value, type, opt_chain) {171position.setPosition(value, type);172this.computeIsParentDependent_(position);173174this.needsTransform_ = true;175if (!opt_chain) {176this.transform();177}178};179180181/**182* Sets the width/height of the element.183* @param {goog.graphics.ext.Element.Position_} position The position object to184* set the value on.185* @param {string|number} size The new width/height value.186* @param {boolean=} opt_chain Optional flag to specify this function is part187* of a chain of calls and therefore transformations should be set as188* pending but not yet performed.189* @private190*/191goog.graphics.ext.Element.prototype.setSize_ = function(192position, size, opt_chain) {193if (position.setSize(size)) {194this.needsTransform_ = true;195196this.computeIsParentDependent_(position);197198if (!opt_chain) {199this.reset();200}201} else if (!opt_chain && this.isPendingTransform()) {202this.reset();203}204};205206207/**208* Sets the minimum width/height of the element.209* @param {goog.graphics.ext.Element.Position_} position The position object to210* set the value on.211* @param {string|number} minSize The minimum width/height of the element.212* @private213*/214goog.graphics.ext.Element.prototype.setMinSize_ = function(position, minSize) {215position.setMinSize(minSize);216this.needsTransform_ = true;217this.computeIsParentDependent_(position);218};219220221// HORIZONTAL POSITIONING222223224/**225* @return {number} The distance from the left edge of this element to the left226* edge of its parent, specified in units of the parent's coordinate system.227*/228goog.graphics.ext.Element.prototype.getLeft = function() {229return this.xPosition_.getStart();230};231232233/**234* Sets the left coordinate of the element. Overwrites any previous value of235* left, center, or right for this element.236* @param {string|number} left The left coordinate.237* @param {boolean=} opt_chain Optional flag to specify this function is part238* of a chain of calls and therefore transformations should be set as239* pending but not yet performed.240*/241goog.graphics.ext.Element.prototype.setLeft = function(left, opt_chain) {242this.setPosition_(243this.xPosition_, left, goog.graphics.ext.Element.PositionType_.START,244opt_chain);245};246247248/**249* @return {number} The right coordinate of the element, in units of the250* parent's coordinate system.251*/252goog.graphics.ext.Element.prototype.getRight = function() {253return this.xPosition_.getEnd();254};255256257/**258* Sets the right coordinate of the element. Overwrites any previous value of259* left, center, or right for this element.260* @param {string|number} right The right coordinate.261* @param {boolean=} opt_chain Optional flag to specify this function is part262* of a chain of calls and therefore transformations should be set as263* pending but not yet performed.264*/265goog.graphics.ext.Element.prototype.setRight = function(right, opt_chain) {266this.setPosition_(267this.xPosition_, right, goog.graphics.ext.Element.PositionType_.END,268opt_chain);269};270271272/**273* @return {number} The center coordinate of the element, in units of the274* parent's coordinate system.275*/276goog.graphics.ext.Element.prototype.getCenter = function() {277return this.xPosition_.getMiddle();278};279280281/**282* Sets the center coordinate of the element. Overwrites any previous value of283* left, center, or right for this element.284* @param {string|number} center The center coordinate.285* @param {boolean=} opt_chain Optional flag to specify this function is part286* of a chain of calls and therefore transformations should be set as287* pending but not yet performed.288*/289goog.graphics.ext.Element.prototype.setCenter = function(center, opt_chain) {290this.setPosition_(291this.xPosition_, center, goog.graphics.ext.Element.PositionType_.MIDDLE,292opt_chain);293};294295296// VERTICAL POSITIONING297298299/**300* @return {number} The distance from the top edge of this element to the top301* edge of its parent, specified in units of the parent's coordinate system.302*/303goog.graphics.ext.Element.prototype.getTop = function() {304return this.yPosition_.getStart();305};306307308/**309* Sets the top coordinate of the element. Overwrites any previous value of310* top, middle, or bottom for this element.311* @param {string|number} top The top coordinate.312* @param {boolean=} opt_chain Optional flag to specify this function is part313* of a chain of calls and therefore transformations should be set as314* pending but not yet performed.315*/316goog.graphics.ext.Element.prototype.setTop = function(top, opt_chain) {317this.setPosition_(318this.yPosition_, top, goog.graphics.ext.Element.PositionType_.START,319opt_chain);320};321322323/**324* @return {number} The bottom coordinate of the element, in units of the325* parent's coordinate system.326*/327goog.graphics.ext.Element.prototype.getBottom = function() {328return this.yPosition_.getEnd();329};330331332/**333* Sets the bottom coordinate of the element. Overwrites any previous value of334* top, middle, or bottom for this element.335* @param {string|number} bottom The bottom coordinate.336* @param {boolean=} opt_chain Optional flag to specify this function is part337* of a chain of calls and therefore transformations should be set as338* pending but not yet performed.339*/340goog.graphics.ext.Element.prototype.setBottom = function(bottom, opt_chain) {341this.setPosition_(342this.yPosition_, bottom, goog.graphics.ext.Element.PositionType_.END,343opt_chain);344};345346347/**348* @return {number} The middle coordinate of the element, in units of the349* parent's coordinate system.350*/351goog.graphics.ext.Element.prototype.getMiddle = function() {352return this.yPosition_.getMiddle();353};354355356/**357* Sets the middle coordinate of the element. Overwrites any previous value of358* top, middle, or bottom for this element359* @param {string|number} middle The middle coordinate.360* @param {boolean=} opt_chain Optional flag to specify this function is part361* of a chain of calls and therefore transformations should be set as362* pending but not yet performed.363*/364goog.graphics.ext.Element.prototype.setMiddle = function(middle, opt_chain) {365this.setPosition_(366this.yPosition_, middle, goog.graphics.ext.Element.PositionType_.MIDDLE,367opt_chain);368};369370371// DIMENSIONS372373374/**375* @return {number} The width of the element, in units of the parent's376* coordinate system.377*/378goog.graphics.ext.Element.prototype.getWidth = function() {379return this.xPosition_.getSize();380};381382383/**384* Sets the width of the element.385* @param {string|number} width The new width value.386* @param {boolean=} opt_chain Optional flag to specify this function is part387* of a chain of calls and therefore transformations should be set as388* pending but not yet performed.389*/390goog.graphics.ext.Element.prototype.setWidth = function(width, opt_chain) {391this.setSize_(this.xPosition_, width, opt_chain);392};393394395/**396* @return {number} The minimum width of the element, in units of the parent's397* coordinate system.398*/399goog.graphics.ext.Element.prototype.getMinWidth = function() {400return this.xPosition_.getMinSize();401};402403404/**405* Sets the minimum width of the element.406* @param {string|number} minWidth The minimum width of the element.407*/408goog.graphics.ext.Element.prototype.setMinWidth = function(minWidth) {409this.setMinSize_(this.xPosition_, minWidth);410};411412413/**414* @return {number} The height of the element, in units of the parent's415* coordinate system.416*/417goog.graphics.ext.Element.prototype.getHeight = function() {418return this.yPosition_.getSize();419};420421422/**423* Sets the height of the element.424* @param {string|number} height The new height value.425* @param {boolean=} opt_chain Optional flag to specify this function is part426* of a chain of calls and therefore transformations should be set as427* pending but not yet performed.428*/429goog.graphics.ext.Element.prototype.setHeight = function(height, opt_chain) {430this.setSize_(this.yPosition_, height, opt_chain);431};432433434/**435* @return {number} The minimum height of the element, in units of the parent's436* coordinate system.437*/438goog.graphics.ext.Element.prototype.getMinHeight = function() {439return this.yPosition_.getMinSize();440};441442443/**444* Sets the minimum height of the element.445* @param {string|number} minHeight The minimum height of the element.446*/447goog.graphics.ext.Element.prototype.setMinHeight = function(minHeight) {448this.setMinSize_(this.yPosition_, minHeight);449};450451452// BOUNDS SHORTCUTS453454455/**456* Shortcut for setting the left and top position.457* @param {string|number} left The left coordinate.458* @param {string|number} top The top coordinate.459* @param {boolean=} opt_chain Optional flag to specify this function is part460* of a chain of calls and therefore transformations should be set as461* pending but not yet performed.462*/463goog.graphics.ext.Element.prototype.setPosition = function(464left, top, opt_chain) {465this.setLeft(left, true);466this.setTop(top, opt_chain);467};468469470/**471* Shortcut for setting the width and height.472* @param {string|number} width The new width value.473* @param {string|number} height The new height value.474* @param {boolean=} opt_chain Optional flag to specify this function is part475* of a chain of calls and therefore transformations should be set as476* pending but not yet performed.477*/478goog.graphics.ext.Element.prototype.setSize = function(479width, height, opt_chain) {480this.setWidth(width, true);481this.setHeight(height, opt_chain);482};483484485/**486* Shortcut for setting the left, top, width, and height.487* @param {string|number} left The left coordinate.488* @param {string|number} top The top coordinate.489* @param {string|number} width The new width value.490* @param {string|number} height The new height value.491* @param {boolean=} opt_chain Optional flag to specify this function is part492* of a chain of calls and therefore transformations should be set as493* pending but not yet performed.494*/495goog.graphics.ext.Element.prototype.setBounds = function(496left, top, width, height, opt_chain) {497this.setLeft(left, true);498this.setTop(top, true);499this.setWidth(width, true);500this.setHeight(height, opt_chain);501};502503504// MAXIMUM BOUNDS505506507/**508* @return {number} An estimate of the maximum x extent this element would have509* in a parent of no width.510*/511goog.graphics.ext.Element.prototype.getMaxX = function() {512return this.xPosition_.getMaxPosition();513};514515516/**517* @return {number} An estimate of the maximum y extent this element would have518* in a parent of no height.519*/520goog.graphics.ext.Element.prototype.getMaxY = function() {521return this.yPosition_.getMaxPosition();522};523524525// RESET526527528/**529* Reset the element. This is called when the element changes size, or when530* the coordinate system changes in a way that would affect pixel based531* rendering532*/533goog.graphics.ext.Element.prototype.reset = function() {534this.xPosition_.resetCache();535this.yPosition_.resetCache();536537this.redraw();538539this.needsTransform_ = true;540this.transform();541};542543544/**545* Overridable function for subclass specific reset.546* @protected547*/548goog.graphics.ext.Element.prototype.redraw = goog.nullFunction;549550551// PARENT DEPENDENCY552553554/**555* Computes whether the element is still parent dependent.556* @param {goog.graphics.ext.Element.Position_} position The recently changed557* position object.558* @private559*/560goog.graphics.ext.Element.prototype.computeIsParentDependent_ = function(561position) {562this.parentDependent_ = position.isParentDependent() ||563this.xPosition_.isParentDependent() ||564this.yPosition_.isParentDependent() || this.checkParentDependent();565};566567568/**569* Returns whether this element's bounds depend on its parents.570*571* This function should be treated as if it has package scope.572* @return {boolean} Whether this element's bounds depend on its parents.573*/574goog.graphics.ext.Element.prototype.isParentDependent = function() {575return this.parentDependent_;576};577578579/**580* Overridable function for subclass specific parent dependency.581* @return {boolean} Whether this shape's bounds depends on its parent's.582* @protected583*/584goog.graphics.ext.Element.prototype.checkParentDependent = goog.functions.FALSE;585586587// ROTATION588589590/**591* Set the rotation of this element.592* @param {number} angle The angle of rotation, in degrees.593*/594goog.graphics.ext.Element.prototype.setRotation = function(angle) {595if (this.rotation_ != angle) {596this.rotation_ = angle;597598this.needsTransform_ = true;599this.transform();600}601};602603604/**605* @return {number} The angle of rotation of this element, in degrees.606*/607goog.graphics.ext.Element.prototype.getRotation = function() {608return this.rotation_;609};610611612// TRANSFORMS613614615/**616* Called by the parent when the parent has transformed.617*618* Should be treated as package scope.619*/620goog.graphics.ext.Element.prototype.parentTransform = function() {621this.needsTransform_ = this.needsTransform_ || this.parentDependent_;622};623624625/**626* @return {boolean} Whether this element has pending transforms.627*/628goog.graphics.ext.Element.prototype.isPendingTransform = function() {629return this.needsTransform_;630};631632633/**634* Performs a pending transform.635* @protected636*/637goog.graphics.ext.Element.prototype.transform = function() {638if (this.isPendingTransform()) {639this.needsTransform_ = false;640641this.wrapper_.setTransformation(642this.getLeft(), this.getTop(), this.rotation_,643(this.getWidth() || 1) / 2, (this.getHeight() || 1) / 2);644645// TODO(robbyw): this._fireEvent('transform', [ this ]);646}647};648649650// PIXEL SCALE651652653/**654* @return {number} Returns the number of pixels per unit in the x direction.655*/656goog.graphics.ext.Element.prototype.getPixelScaleX = function() {657return this.getGraphics().getPixelScaleX();658};659660661/**662* @return {number} Returns the number of pixels per unit in the y direction.663*/664goog.graphics.ext.Element.prototype.getPixelScaleY = function() {665return this.getGraphics().getPixelScaleY();666};667668669// EVENT HANDLING670671672/** @override */673goog.graphics.ext.Element.prototype.disposeInternal = function() {674goog.graphics.ext.Element.superClass_.disposeInternal.call(this);675this.wrapper_.dispose();676};677678679// INTERNAL POSITION OBJECT680681682/**683* Position specification types. Start corresponds to left/top, middle to684* center/middle, and end to right/bottom.685* @enum {number}686* @private687*/688goog.graphics.ext.Element.PositionType_ = {689START: 0,690MIDDLE: 1,691END: 2692};693694695696/**697* Manages a position and size, either horizontal or vertical.698* @param {goog.graphics.ext.Element} element The element the position applies699* to.700* @param {boolean} horizontal Whether the position is horizontal or vertical.701* @constructor702* @private703*/704goog.graphics.ext.Element.Position_ = function(element, horizontal) {705this.element_ = element;706this.horizontal_ = horizontal;707};708709710/**711* @return {!Object} The coordinate value computation cache.712* @private713*/714goog.graphics.ext.Element.Position_.prototype.getCoordinateCache_ = function() {715return this.coordinateCache_ || (this.coordinateCache_ = {});716};717718719/**720* @return {number} The size of the parent's coordinate space.721* @private722*/723goog.graphics.ext.Element.Position_.prototype.getParentSize_ = function() {724var parent = this.element_.getParent();725return this.horizontal_ ? parent.getCoordinateWidth() :726parent.getCoordinateHeight();727};728729730/**731* @return {number} The minimum width/height of the element.732*/733goog.graphics.ext.Element.Position_.prototype.getMinSize = function() {734return this.getValue_(this.minSize_);735};736737738/**739* Sets the minimum width/height of the element.740* @param {string|number} minSize The minimum width/height of the element.741*/742goog.graphics.ext.Element.Position_.prototype.setMinSize = function(minSize) {743this.minSize_ = minSize;744this.resetCache();745};746747748/**749* @return {number} The width/height of the element.750*/751goog.graphics.ext.Element.Position_.prototype.getSize = function() {752return Math.max(this.getValue_(this.size_), this.getMinSize());753};754755756/**757* Sets the width/height of the element.758* @param {string|number} size The width/height of the element.759* @return {boolean} Whether the value was changed.760*/761goog.graphics.ext.Element.Position_.prototype.setSize = function(size) {762if (size != this.size_) {763this.size_ = size;764this.resetCache();765return true;766}767return false;768};769770771/**772* Converts the given x coordinate to a number value in units.773* @param {string|number} v The coordinate to retrieve the value for.774* @param {boolean=} opt_forMaximum Whether we are computing the largest value775* this coordinate would be in a parent of no size.776* @return {number} The correct number of coordinate space units.777* @private778*/779goog.graphics.ext.Element.Position_.prototype.getValue_ = function(780v, opt_forMaximum) {781if (!goog.graphics.ext.coordinates.isSpecial(v)) {782return parseFloat(String(v));783}784785var cache = this.getCoordinateCache_();786var scale = this.horizontal_ ? this.element_.getPixelScaleX() :787this.element_.getPixelScaleY();788789var containerSize;790if (opt_forMaximum) {791containerSize =792goog.graphics.ext.coordinates.computeValue(this.size_ || 0, 0, scale);793} else {794var parent = this.element_.getParent();795containerSize = this.horizontal_ ? parent.getWidth() : parent.getHeight();796}797798return goog.graphics.ext.coordinates.getValue(799v, opt_forMaximum, containerSize, scale, cache);800};801802803/**804* @return {number} The distance from the left/top edge of this element to the805* left/top edge of its parent, specified in units of the parent's806* coordinate system.807*/808goog.graphics.ext.Element.Position_.prototype.getStart = function() {809if (this.cachedValue_ == null) {810var value = this.getValue_(this.distance_);811if (this.distanceType_ == goog.graphics.ext.Element.PositionType_.START) {812this.cachedValue_ = value;813} else if (814this.distanceType_ == goog.graphics.ext.Element.PositionType_.MIDDLE) {815this.cachedValue_ = value + (this.getParentSize_() - this.getSize()) / 2;816} else {817this.cachedValue_ = this.getParentSize_() - value - this.getSize();818}819}820821return this.cachedValue_;822};823824825/**826* @return {number} The middle coordinate of the element, in units of the827* parent's coordinate system.828*/829goog.graphics.ext.Element.Position_.prototype.getMiddle = function() {830return this.distanceType_ == goog.graphics.ext.Element.PositionType_.MIDDLE ?831this.getValue_(this.distance_) :832(this.getParentSize_() - this.getSize()) / 2 - this.getStart();833};834835836/**837* @return {number} The end coordinate of the element, in units of the838* parent's coordinate system.839*/840goog.graphics.ext.Element.Position_.prototype.getEnd = function() {841return this.distanceType_ == goog.graphics.ext.Element.PositionType_.END ?842this.getValue_(this.distance_) :843this.getParentSize_() - this.getStart() - this.getSize();844};845846847/**848* Sets the position, either as a left/top, center/middle, or right/bottom849* value.850* @param {number|string} value The value of the coordinate.851* @param {goog.graphics.ext.Element.PositionType_} type The type of the852* coordinate.853*/854goog.graphics.ext.Element.Position_.prototype.setPosition = function(855value, type) {856this.distance_ = value;857this.distanceType_ = type;858859// Clear cached value.860this.cachedValue_ = null;861};862863864/**865* @return {number} An estimate of the maximum x/y extent this element would866* have in a parent of no width/height.867*/868goog.graphics.ext.Element.Position_.prototype.getMaxPosition = function() {869// TODO(robbyw): Handle transformed or rotated coordinates870// TODO(robbyw): Handle pixel based sizes?871872return this.getValue_(this.distance_ || 0) +873(goog.graphics.ext.coordinates.isSpecial(this.size_) ? 0 :874this.getSize());875};876877878/**879* Resets the caches of position values and coordinate values.880*/881goog.graphics.ext.Element.Position_.prototype.resetCache = function() {882this.coordinateCache_ = null;883this.cachedValue_ = null;884};885886887/**888* @return {boolean} Whether the size or position of this element depends on889* the size of the parent element.890*/891goog.graphics.ext.Element.Position_.prototype.isParentDependent = function() {892return this.distanceType_ != goog.graphics.ext.Element.PositionType_.START ||893goog.graphics.ext.coordinates.isSpecial(this.size_) ||894goog.graphics.ext.coordinates.isSpecial(this.minSize_) ||895goog.graphics.ext.coordinates.isSpecial(this.distance_);896};897898899/**900* The lazy loaded distance from the parent's top/left edge to this element's901* top/left edge expressed in the parent's coordinate system. We cache this902* because it is most freqeuently requested by the element and it is easy to903* compute middle and end values from it.904* @type {?number}905* @private906*/907goog.graphics.ext.Element.Position_.prototype.cachedValue_ = null;908909910/**911* A cache of computed x coordinates.912* @type {Object}913* @private914*/915goog.graphics.ext.Element.Position_.prototype.coordinateCache_ = null;916917918/**919* The minimum width/height of this element, as specified by the caller.920* @type {string|number}921* @private922*/923goog.graphics.ext.Element.Position_.prototype.minSize_ = 0;924925926/**927* The width/height of this object, as specified by the caller.928* @type {string|number}929* @private930*/931goog.graphics.ext.Element.Position_.prototype.size_ = 0;932933934/**935* The coordinate of this object, as specified by the caller. The type of936* coordinate is specified by distanceType_.937* @type {string|number}938* @private939*/940goog.graphics.ext.Element.Position_.prototype.distance_ = 0;941942943/**944* The coordinate type specified by distance_.945* @type {goog.graphics.ext.Element.PositionType_}946* @private947*/948goog.graphics.ext.Element.Position_.prototype.distanceType_ =949goog.graphics.ext.Element.PositionType_.START;950951952