diff options
author | Valerio Virgillito | 2012-02-02 00:11:51 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-02-02 15:33:42 -0800 |
commit | a3024011a91d3941f81481dd4d600e9684eb0fd4 (patch) | |
tree | 084b4856910f1db53973dd11617f7ffa03a6dd46 /node_modules/montage/ui/nearest-neighbor-component-search.js | |
parent | 97255032921178bdfbc25512ddf3e0867e353f7a (diff) | |
download | ninja-a3024011a91d3941f81481dd4d600e9684eb0fd4.tar.gz |
upgrading to Montage v0.6
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'node_modules/montage/ui/nearest-neighbor-component-search.js')
-rw-r--r-- | node_modules/montage/ui/nearest-neighbor-component-search.js | 458 |
1 files changed, 226 insertions, 232 deletions
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 @@ | |||
1 | /* <copyright> | 1 | var Montage = require("montage").Montage; |
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | 2 | |
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | 3 | var NearestNeighborComponentSearch = exports.NearestNeighborComponentSearch = Montage.create(Montage, { |
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | 4 | |
5 | </copyright> */ | 5 | _componentList: { |
6 | 6 | enumerable: false, | |
7 | var Montage = require("montage").Montage; | 7 | value: null |
8 | 8 | }, | |
9 | var NearestNeighborComponentSearch = exports.NearestNeighborComponentSearch = Montage.create(Montage, { | 9 | |
10 | 10 | componentList: { | |
11 | _componentList: { | 11 | get: function () { |
12 | enumerable: false, | 12 | return this._componentList; |
13 | value: null | 13 | }, |
14 | }, | 14 | set: function (value) { |
15 | 15 | var i; | |
16 | componentList: { | 16 | |
17 | get: function () { | 17 | this._componentList=value; |
18 | return this._componentList; | 18 | } |
19 | }, | 19 | }, |
20 | set: function (value) { | 20 | |
21 | var i; | 21 | _pointerPosition: { |
22 | 22 | enumerable: false, | |
23 | this._componentList=value; | 23 | value: null |
24 | } | 24 | }, |
25 | }, | 25 | |
26 | 26 | pointerPosition: { | |
27 | _pointerPosition: { | 27 | get: function () { |
28 | enumerable: false, | 28 | return this._pointerPosition; |
29 | value: null | 29 | }, |
30 | }, | 30 | set: function (value) { |
31 | 31 | var nearest = null; | |
32 | pointerPosition: { | 32 | |
33 | get: function () { | 33 | this._pointerPosition=value; |
34 | return this._pointerPosition; | 34 | if ((this._componentList)&&(this._componentList.length)) { |
35 | }, | 35 | var target = value.target, |
36 | set: function (value) { | 36 | nearest; |
37 | var nearest = null; | 37 | |
38 | 38 | for (i=0; i<this._componentList.length; i++) { | |
39 | this._pointerPosition=value; | 39 | this._componentList[i]._element.setAttribute("data-nn-index", i); |
40 | if ((this._componentList)&&(this._componentList.length)) { | 40 | } |
41 | var target = value.target, | 41 | while ((target.tagName !== "BODY")&&!(nearest = target.getAttribute("data-nn-index"))) { |
42 | nearest; | 42 | target = target.parentNode; |
43 | 43 | } | |
44 | for (i=0; i<this._componentList.length; i++) { | 44 | for (i=0; i<this._componentList.length; i++) { |
45 | this._componentList[i]._element.setAttribute("data-nn-index", i); | 45 | this._componentList[i]._element.removeAttribute("data-nn-index", i); |
46 | } | 46 | } |
47 | while ((target.tagName !== "BODY")&&!(nearest = target.getAttribute("data-nn-index"))) { | 47 | } |
48 | target = target.parentNode; | 48 | if (nearest) { |
49 | } | 49 | this.nearestNeighborComponent = Number(nearest); |
50 | for (i=0; i<this._componentList.length; i++) { | 50 | } else { |
51 | this._componentList[i]._element.removeAttribute("data-nn-index", i); | 51 | if (value && this._hasNearestNeighborComponentSearch && this._componentList) { |
52 | } | 52 | if (this._nearestNeighborComponentSearchMethod==="precise") { |
53 | } | 53 | this.nearestNeighborComponent=this._searchPreciseNearestNeighborComponent(); |
54 | if (nearest) { | 54 | } else { |
55 | this.nearestNeighborComponent = Number(nearest); | 55 | this.nearestNeighborComponent=this._searchMidpointNearestNeighborComponent(); |
56 | } else { | 56 | } |
57 | if (value && this._hasNearestNeighborComponentSearch && this._componentList) { | 57 | } else { |
58 | if (this._nearestNeighborComponentSearchMethod==="precise") { | 58 | this.nearestNeighborComponent=null; |
59 | this.nearestNeighborComponent=this._searchPreciseNearestNeighborComponent(); | 59 | } |
60 | } else { | 60 | } |
61 | this.nearestNeighborComponent=this._searchMidpointNearestNeighborComponent(); | 61 | } |
62 | } | 62 | }, |
63 | } else { | 63 | |
64 | this.nearestNeighborComponent=null; | 64 | _hasNearestNeighborComponentSearch: { |
65 | } | 65 | enumerable: false, |
66 | } | 66 | value: true |
67 | } | 67 | }, |
68 | }, | 68 | |
69 | 69 | hasNearestNeighborComponentSearch: { | |
70 | _hasNearestNeighborComponentSearch: { | 70 | get: function () { |
71 | enumerable: false, | 71 | return this._hasNearestNeighborComponentSearch; |
72 | value: true | 72 | }, |
73 | }, | 73 | set: function (value) { |
74 | 74 | if (value===true) { | |
75 | hasNearestNeighborComponentSearch: { | 75 | this._hasNearestNeighborComponentSearch=true; |
76 | get: function () { | 76 | } else { |
77 | return this._hasNearestNeighborComponentSearch; | 77 | this._hasNearestNeighborComponentSearch=false; |
78 | }, | 78 | } |
79 | set: function (value) { | 79 | } |
80 | if (value===true) { | 80 | }, |
81 | this._hasNearestNeighborComponentSearch=true; | 81 | |
82 | } else { | 82 | _nearestNeighborComponentSearchMethod: { |
83 | this._hasNearestNeighborComponentSearch=false; | 83 | enumerable: false, |
84 | } | 84 | value: "precise" |
85 | } | 85 | }, |
86 | }, | 86 | |
87 | 87 | nearestNeighborComponentSearchMethod: { | |
88 | _nearestNeighborComponentSearchMethod: { | 88 | get: function () { |
89 | enumerable: false, | 89 | return this._nearestNeighborComponentSearchMethod; |
90 | value: "precise" | 90 | }, |
91 | }, | 91 | set: function (vale) { |
92 | 92 | if (value==="midpoint") { | |
93 | nearestNeighborComponentSearchMethod: { | 93 | this._nearestNeighborComponentSearchMethod=value; |
94 | get: function () { | 94 | } else { |
95 | return this._nearestNeighborComponentSearchMethod; | 95 | this._nearestNeighborComponentSearchMethod="precise"; |
96 | }, | 96 | } |
97 | set: function (vale) { | 97 | } |
98 | if (value==="midpoint") { | 98 | }, |
99 | this._nearestNeighborComponentSearchMethod=value; | 99 | |
100 | } else { | 100 | _pointToQuadSquaredDistance: { |
101 | this._nearestNeighborComponentSearchMethod="precise"; | 101 | enumerable: false, |
102 | } | 102 | value: function (pX, pY, q) { |
103 | } | 103 | var dist, iDist, |
104 | }, | 104 | i, j, u, x, y, div, |
105 | 105 | dist=1e20, a, b; | |
106 | _pointToQuadSquaredDistance: { | 106 | |
107 | enumerable: false, | 107 | q[0]-=pX; q[1]-=pY; q[2]-=pX; q[3]-=pY; |
108 | value: function (pX, pY, q) { | 108 | q[4]-=pX; q[5]-=pY; q[6]-=pX; q[7]-=pY; |
109 | var dist, iDist, | 109 | for (i=0; i<8; i+=2) { |
110 | i, j, u, x, y, div, | 110 | j=(i+2)%8; |
111 | dist=1e20, a, b; | 111 | a=q[i+1]-q[j+1]; |
112 | 112 | b=q[j]-q[i]; | |
113 | q[0]-=pX; q[1]-=pY; q[2]-=pX; q[3]-=pY; | 113 | div=a*a+b*b; |
114 | q[4]-=pX; q[5]-=pY; q[6]-=pX; q[7]-=pY; | 114 | if (div>1e-10) { |
115 | for (i=0; i<8; i+=2) { | 115 | u=q[i+1]*a-q[i]*b; |
116 | j=(i+2)%8; | 116 | if (u<0) { |
117 | a=q[i+1]-q[j+1]; | 117 | x=q[i]; |
118 | b=q[j]-q[i]; | 118 | y=q[i+1]; |
119 | div=a*a+b*b; | 119 | } else if (u>div) { |
120 | if (div>1e-10) { | 120 | x=q[i]+b; |
121 | u=q[i+1]*a-q[i]*b; | 121 | y=q[i+1]-a; |
122 | if (u<0) { | 122 | } else { |
123 | x=q[i]; | 123 | u/=div; |
124 | y=q[i+1]; | 124 | x=q[i]+u*b; |
125 | } else if (u>div) { | 125 | y=q[i+1]-u*a; |
126 | x=q[i]+b; |