add eye tracking benchmark.
[IRC.git] / Robust / src / Benchmarks / SSJava / EyeTracking / Deviation.java
1 /*
2  * Copyright 2009 (c) Florian Frankenberger (darkblue.de)
3  * 
4  * This file is part of LEA.
5  * 
6  * LEA is free software: you can redistribute it and/or modify it under the
7  * terms of the GNU Lesser General Public License as published by the Free
8  * Software Foundation, either version 3 of the License, or (at your option) any
9  * later version.
10  * 
11  * LEA is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13  * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
14  * details.
15  * 
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with LEA. If not, see <http://www.gnu.org/licenses/>.
18  */
19
20
21 /**
22  * Representing an eyes deviation
23  * 
24  * @author Florian Frankenberger
25  */
26 public enum Deviation {
27         LEFT_UP(+1, -1),
28         UP(0, -1),
29         RIGHT_UP(-1, -1),
30         LEFT(+1, 0),
31         NONE(0, 0),
32         RIGHT(-1, 0),
33         LEFT_DOWN(+1, +1),
34         DOWN(0, +1),
35         RIGHT_DOWN(-1, +1);
36
37         int directionX, directionY;
38         Deviation(int directionX, int directionY) {
39             this.directionX = directionX;
40             this.directionY = directionY;
41         }
42
43         private boolean concurs(int directionX, int directionY) {
44             return (directionX == this.directionX && directionY == this.directionY);
45         }
46
47
48         public static Deviation getDirectionFor(int directionX, int directionY) {
49             for (Deviation direction: Deviation.values()) {
50                 if (direction.concurs(directionX, directionY)) {
51                     return direction;
52                 }
53             }
54
55             return null;
56         }
57   }