From a3024011a91d3941f81481dd4d600e9684eb0fd4 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Thu, 2 Feb 2012 00:11:51 -0800 Subject: upgrading to Montage v0.6 Signed-off-by: Valerio Virgillito --- .../ui/nearest-neighbor-component-search.js | 458 ++++++++++----------- 1 file changed, 226 insertions(+), 232 deletions(-) (limited to 'node_modules/montage/ui/nearest-neighbor-component-search.js') diff --git a/node_modules/montage/ui/nearest-neighbor-component-search.js b/node_modules/montage/ui/nearest-neighbor-component-search.js index ed247a7a..209d25f8 100644 --- a/node_modules/montage/ui/nearest-neighbor-component-search.js +++ b/node_modules/montage/ui/nearest-neighbor-component-search.js @@ -1,232 +1,226 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -var Montage = require("montage").Montage; - -var NearestNeighborComponentSearch = exports.NearestNeighborComponentSearch = Montage.create(Montage, { - - _componentList: { - enumerable: false, - value: null - }, - - componentList: { - get: function () { - return this._componentList; - }, - set: function (value) { - var i; - - this._componentList=value; - } - }, - - _pointerPosition: { - enumerable: false, - value: null - }, - - pointerPosition: { - get: function () { - return this._pointerPosition; - }, - set: function (value) { - var nearest = null; - - this._pointerPosition=value; - if ((this._componentList)&&(this._componentList.length)) { - var target = value.target, - nearest; - - for (i=0; i1e-10) { - u=q[i+1]*a-q[i]*b; - if (u<0) { - x=q[i]; - y=q[i+1]; - } else if (u>div) { - x=q[i]+b; - y=q[i+1]-a; - } else { - u/=div; - x=q[i]+u*b; - y=q[i+1]-u*a; - } - iDist=x*x+y*y; - if (iDist>1; - point.y=element.offsetHeight>>1; - v=convert(element, point); - iDistance=(pageX-v.x)*(pageX-v.x)+(pageY-v.y)*(pageY-v.y); - if (iDistance < distance) { - distance=iDistance; - //nearest=this._componentList[i]; - nearest=i; - } - } - return nearest; - } - }, - - _nearestNeighborComponent: { - enumerable: false, - value: null - }, - - nearestNeighborComponent: { - get: function () { - return this._nearestNeighborComponent; - }, - set: function (value) { - this._nearestNeighborComponent=value; - } - } -}); \ No newline at end of file +var Montage = require("montage").Montage; + +var NearestNeighborComponentSearch = exports.NearestNeighborComponentSearch = Montage.create(Montage, { + + _componentList: { + enumerable: false, + value: null + }, + + componentList: { + get: function () { + return this._componentList; + }, + set: function (value) { + var i; + + this._componentList=value; + } + }, + + _pointerPosition: { + enumerable: false, + value: null + }, + + pointerPosition: { + get: function () { + return this._pointerPosition; + }, + set: function (value) { + var nearest = null; + + this._pointerPosition=value; + if ((this._componentList)&&(this._componentList.length)) { + var target = value.target, + nearest; + + for (i=0; i1e-10) { + u=q[i+1]*a-q[i]*b; + if (u<0) { + x=q[i]; + y=q[i+1]; + } else if (u>div) { + x=q[i]+b; + y=q[i+1]-a; + } else { + u/=div; + x=q[i]+u*b; + y=q[i+1]-u*a; + } + iDist=x*x+y*y; + if (iDist>1; + point.y=element.offsetHeight>>1; + v=convert(element, point); + iDistance=(pageX-v.x)*(pageX-v.x)+(pageY-v.y)*(pageY-v.y); + if (iDistance < distance) { + distance=iDistance; + //nearest=this._componentList[i]; + nearest=i; + } + } + return nearest; + } + }, + + _nearestNeighborComponent: { + enumerable: false, + value: null + }, + + nearestNeighborComponent: { + get: function () { + return this._nearestNeighborComponent; + }, + set: function (value) { + this._nearestNeighborComponent=value; + } + } +}); -- cgit v1.2.3