Merge branch 'master' of https://source.jalview.org/git/jalviewjs.git
[jalviewjs.git] / site / j2s / java / awt / Event.js
1 Clazz.declarePackage ("java.awt");
2 c$ = Clazz.decorateAsClass (function () {
3 this.target = null;
4 this.when = 0;
5 this.id = 0;
6 this.x = 0;
7 this.y = 0;
8 this.key = 0;
9 this.modifiers = 0;
10 this.clickCount = 0;
11 this.arg = null;
12 this.evt = null;
13 this.consumed = false;
14 Clazz.instantialize (this, arguments);
15 }, java.awt, "Event");
16 Clazz.makeConstructor (c$, 
17 function (target, when, id, x, y, key, modifiers, arg) {
18 this.target = target;
19 this.when = when;
20 this.id = id;
21 this.x = x;
22 this.y = y;
23 this.key = key;
24 this.modifiers = modifiers;
25 this.arg = arg;
26 this.clickCount = 0;
27 switch (id) {
28 case 1001:
29 case 201:
30 case 203:
31 case 204:
32 case 205:
33 case 601:
34 case 602:
35 case 603:
36 case 604:
37 case 605:
38 case 606:
39 case 607:
40 case 701:
41 case 702:
42 this.consumed = true;
43 break;
44 default:
45 }
46 }, "~O,~N,~N,~N,~N,~N,~N,~O");
47 Clazz.makeConstructor (c$, 
48 function (target, when, id, x, y, key, modifiers) {
49 this.construct (target, when, id, x, y, key, modifiers, null);
50 }, "~O,~N,~N,~N,~N,~N,~N");
51 Clazz.makeConstructor (c$, 
52 function (target, id, arg) {
53 this.construct (target, 0, id, 0, 0, 0, 0, arg);
54 }, "~O,~N,~O");
55 Clazz.defineMethod (c$, "translate", 
56 function (dx, dy) {
57 this.x += dx;
58 this.y += dy;
59 }, "~N,~N");
60 Clazz.defineMethod (c$, "shiftDown", 
61 function () {
62 return (this.modifiers & 1) != 0;
63 });
64 Clazz.defineMethod (c$, "controlDown", 
65 function () {
66 return (this.modifiers & 2) != 0;
67 });
68 Clazz.defineMethod (c$, "metaDown", 
69 function () {
70 return (this.modifiers & 4) != 0;
71 });
72 Clazz.defineMethod (c$, "consume", 
73 function () {
74 switch (this.id) {
75 case 401:
76 case 402:
77 case 403:
78 case 404:
79 this.consumed = true;
80 break;
81 default:
82 }
83 });
84 Clazz.defineMethod (c$, "isConsumed", 
85 function () {
86 return this.consumed;
87 });
88 c$.getOldEventKey = Clazz.defineMethod (c$, "getOldEventKey", 
89 function (e) {
90 var keyCode = e.getKeyCode ();
91 for (var i = 0; i < java.awt.Event.actionKeyCodes.length; i++) {
92 if (java.awt.Event.actionKeyCodes[i][0] == keyCode) {
93 return java.awt.Event.actionKeyCodes[i][1];
94 }}
95 return e.getKeyChar ();
96 }, "java.awt.event.KeyEvent");
97 Clazz.defineMethod (c$, "getKeyEventChar", 
98 function () {
99 for (var i = 0; i < java.awt.Event.actionKeyCodes.length; i++) {
100 if (java.awt.Event.actionKeyCodes[i][1] == this.key) {
101 return '\uffff';
102 }}
103 return String.fromCharCode (this.key);
104 });
105 Clazz.defineMethod (c$, "paramString", 
106 function () {
107 var str = "id=" + this.id + ",x=" + this.x + ",y=" + this.y;
108 if (this.key != 0) {
109 str += ",key=" + this.key;
110 }if (this.shiftDown ()) {
111 str += ",shift";
112 }if (this.controlDown ()) {
113 str += ",control";
114 }if (this.metaDown ()) {
115 str += ",meta";
116 }if (this.target != null) {
117 str += ",target=" + this.target;
118 }if (this.arg != null) {
119 str += ",arg=" + this.arg;
120 }return str;
121 });
122 Clazz.overrideMethod (c$, "toString", 
123 function () {
124 return this.getClass ().getName () + "[" + this.paramString () + "]";
125 });
126 Clazz.defineStatics (c$,
127 "SHIFT_MASK", 1,
128 "CTRL_MASK", 2,
129 "META_MASK", 4,
130 "ALT_MASK", 8,
131 "HOME", 1000,
132 "END", 1001,
133 "PGUP", 1002,
134 "PGDN", 1003,
135 "UP", 1004,
136 "DOWN", 1005,
137 "LEFT", 1006,
138 "RIGHT", 1007,
139 "F1", 1008,
140 "F2", 1009,
141 "F3", 1010,
142 "F4", 1011,
143 "F5", 1012,
144 "F6", 1013,
145 "F7", 1014,
146 "F8", 1015,
147 "F9", 1016,
148 "F10", 1017,
149 "F11", 1018,
150 "F12", 1019,
151 "PRINT_SCREEN", 1020,
152 "SCROLL_LOCK", 1021,
153 "CAPS_LOCK", 1022,
154 "NUM_LOCK", 1023,
155 "PAUSE", 1024,
156 "INSERT", 1025,
157 "ENTER", '\n',
158 "BACK_SPACE", '\b',
159 "TAB", '\t',
160 "ESCAPE", 27,
161 "DELETE", 127,
162 "WINDOW_EVENT", 200,
163 "WINDOW_DESTROY", 201,
164 "WINDOW_EXPOSE", 202,
165 "WINDOW_ICONIFY", 203,
166 "WINDOW_DEICONIFY", 204,
167 "WINDOW_MOVED", 205,
168 "KEY_EVENT", 400,
169 "KEY_PRESS", 401,
170 "KEY_RELEASE", 402,
171 "KEY_ACTION", 403,
172 "KEY_ACTION_RELEASE", 404,
173 "MOUSE_EVENT", 500,
174 "MOUSE_DOWN", 501,
175 "MOUSE_UP", 502,
176 "MOUSE_MOVE", 503,
177 "MOUSE_ENTER", 504,
178 "MOUSE_EXIT", 505,
179 "MOUSE_DRAG", 506,
180 "SCROLL_EVENT", 600,
181 "SCROLL_LINE_UP", 601,
182 "SCROLL_LINE_DOWN", 602,
183 "SCROLL_PAGE_UP", 603,
184 "SCROLL_PAGE_DOWN", 604,
185 "SCROLL_ABSOLUTE", 605,
186 "SCROLL_BEGIN", 606,
187 "SCROLL_END", 607,
188 "LIST_EVENT", 700,
189 "LIST_SELECT", 701,
190 "LIST_DESELECT", 702,
191 "MISC_EVENT", 1000,
192 "ACTION_EVENT", 1001,
193 "LOAD_FILE", 1002,
194 "SAVE_FILE", 1003,
195 "GOT_FOCUS", 1004,
196 "LOST_FOCUS", 1005,
197 "actionKeyCodes",  Clazz.newArray (-1, [ Clazz.newIntArray (-1, [36, 1000]),  Clazz.newIntArray (-1, [35, 1001]),  Clazz.newIntArray (-1, [33, 1002]),  Clazz.newIntArray (-1, [34, 1003]),  Clazz.newIntArray (-1, [38, 1004]),  Clazz.newIntArray (-1, [40, 1005]),  Clazz.newIntArray (-1, [37, 1006]),  Clazz.newIntArray (-1, [39, 1007]),  Clazz.newIntArray (-1, [112, 1008]),  Clazz.newIntArray (-1, [113, 1009]),  Clazz.newIntArray (-1, [114, 1010]),  Clazz.newIntArray (-1, [115, 1011]),  Clazz.newIntArray (-1, [116, 1012]),  Clazz.newIntArray (-1, [117, 1013]),  Clazz.newIntArray (-1, [118, 1014]),  Clazz.newIntArray (-1, [119, 1015]),  Clazz.newIntArray (-1, [120, 1016]),  Clazz.newIntArray (-1, [121, 1017]),  Clazz.newIntArray (-1, [122, 1018]),  Clazz.newIntArray (-1, [123, 1019]),  Clazz.newIntArray (-1, [154, 1020]),  Clazz.newIntArray (-1, [145, 1021]),  Clazz.newIntArray (-1, [20, 1022]),  Clazz.newIntArray (-1, [144, 1023]),  Clazz.newIntArray (-1, [19, 1024]),  Clazz.newIntArray (-1, [155, 1025])]));