Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/google_input_tools/src/chrome/os/inputview/covariance.js

Issue 674153004: Add third_party/google-input-tools: Take 2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@google_input_tools
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The ChromeOS IME Authors. All Rights Reserved.
2 // limitations under the License.
3 // See the License for the specific language governing permissions and
4 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5 // distributed under the License is distributed on an "AS-IS" BASIS,
6 // Unless required by applicable law or agreed to in writing, software
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // You may obtain a copy of the License at
11 // you may not use this file except in compliance with the License.
12 // Licensed under the Apache License, Version 2.0 (the "License");
13 //
14 goog.provide('i18n.input.chrome.inputview.Covariance');
15
16 goog.require('i18n.input.chrome.inputview.elements.ElementType');
17
18
19 goog.scope(function() {
20 var ElementType = i18n.input.chrome.inputview.elements.ElementType;
21
22
23
24 /**
25 * The covariance used for gaussian model.
26 *
27 * @constructor
28 */
29 i18n.input.chrome.inputview.Covariance = function() {
30 /** @private {number} */
31 this.breakDown_ = 0;
32 };
33 var Covariance = i18n.input.chrome.inputview.Covariance;
34
35
36 /**
37 * The break-down for covariance.
38 *
39 * @enum {number}
40 */
41 Covariance.BreakDown = {
42 A11Y: 1,
43 HORIZONTAL: 2,
44 WIDE_SCREEN: 4
45 };
46
47
48 /**
49 * The key type.
50 *
51 * @type {!Object.<ElementType, number>}
52 */
53 Covariance.ElementTypeMap = goog.object.create(
54 ElementType.CHARACTER_KEY, 0,
55 ElementType.COMPACT_KEY, 1
56 );
57
58
59 /**
60 * The value.
61 * Key: the break down value.
62 * Value: A list - first is the covariance for full keyboard, second is for
63 * compact.
64 *
65 * @private {!Object.<!Array.<number>>}
66 */
67 Covariance.VALUE_ = {
68 0: [120, 160],
69 1: [130, 0],
70 2: [235, 342],
71 3: [162, 0],
72 4: [160, 213],
73 5: [142, 0],
74 6: [230, 332],
75 7: [162, 0]
76 };
77
78
79 /**
80 * Updates the covariance.
81 *
82 * @param {boolean} isWideScreen .
83 * @param {boolean} isHorizontal .
84 * @param {boolean} isA11y .
85 */
86 Covariance.prototype.update = function(isWideScreen, isHorizontal, isA11y) {
87 this.breakDown_ = 0;
88 if (isWideScreen) {
89 this.breakDown_ |= Covariance.BreakDown.WIDE_SCREEN;
90 }
91 if (isHorizontal) {
92 this.breakDown_ |= Covariance.BreakDown.HORIZONTAL;
93 }
94 if (isA11y) {
95 this.breakDown_ |= Covariance.BreakDown.A11Y;
96 }
97 };
98
99
100 /**
101 * Gets the covariance value.
102 *
103 * @param {ElementType} type .
104 */
105 Covariance.prototype.getValue = function(type) {
106 var index = Covariance.ElementTypeMap[type];
107 return Covariance.VALUE_[this.breakDown_][index];
108 };
109
110 }); // goog.scope
111
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698