/* 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; } } });