-
Notifications
You must be signed in to change notification settings - Fork 0
/
BasicInfo
608 lines (543 loc) · 16.5 KB
/
BasicInfo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
/** Classe que contém as informações e funções básicas dos treinamentos e seus respectivos usuários,
* fazendo a integração entre os dados que foram, ou serão, salvos e as classes que os utilizarão.
*/
import java.awt.BasicStroke;
import java.awt.Color;
import java.util.ArrayList;
public class BasicInfo {
public static final int RANDOM_MODE = 1;
public static final int AGAINST_GROUP_MODE = 2;
public static final int SEQUENCE_MODE = 3;
public static final int UPPER_LIMB = 1;
public static final int LOWER_LIMB = 2;
public static final int RESTED = 0;
public static final int TIRED = 1;
public static final int RIGHT_SIDE = 1;
public static final int LEFT_SIDE = 2;
public static final int BOTH = 0;
public static final int LONG_DISTANCE = 0;
public static final int SHORT_DISTANCE = 1;
public static final int AD = 1;
public static final int AE = 2;
public static final int BD = 3;
public static final int BE = 4;
public static final int VISUALIZAR_INFORMACOES = 1;
public static final int COMPARAR_DISPOSITIVOS = 2;
public static final int COMPARAR_ESTADO_FISICO = 3;
public static final int COMPARAR_MEMBROS = 4;
public static final int COMPARAR_LADO_DO_CORPO = 5;
public static final int COMPARAR_USUARIOS = 6;
ArrayList<String> users = new ArrayList<String> ();
ArrayList<Long> times = new ArrayList<Long> ();
ArrayList<Long> timeUser1 = new ArrayList<Long> ();
ArrayList<Long> timeUser2 = new ArrayList<Long> ();
ArrayList<Long> timeUser3 = new ArrayList<Long> ();
ArrayList<Long> timeUser4 = new ArrayList<Long> ();
ArrayList<Long> timeRested = new ArrayList<Long> ();
ArrayList<Long> timeTired = new ArrayList<Long> ();
ArrayList<Long> timeUpperLimb = new ArrayList<Long> ();
ArrayList<Long> timeLowerLimb = new ArrayList<Long> ();
ArrayList<Long> timeLeftSide = new ArrayList<Long> ();
ArrayList<Long> timeRightSide = new ArrayList<Long> ();
ArrayList<Long> timeBoth = new ArrayList<Long> ();
ArrayList<Long> timeDeviceAD = new ArrayList<Long> (); //alto direita
ArrayList<Long> timeDeviceAE = new ArrayList<Long> (); //alto esquerda
ArrayList<Long> timeDeviceBD = new ArrayList<Long> (); //baixo direita
ArrayList<Long> timeDeviceBE = new ArrayList<Long> (); //baixo esquerda
String currentUser = "";
String user1 = "";
String user2 = "";
String user3 = "";
String user4 = "";
int trainingMode = RANDOM_MODE;
int limb = BOTH;
int physicalCondition = RESTED;
int side = BOTH;
int distance = LONG_DISTANCE;
int positionDevice1 = AD;
int positionDevice2 = AD;
int positionDevice3 = AD;
int positionDevice4 = AD;
int positionDevice5 = AD;
int positionDevice6 = AD;
int positionDevice7 = AD;
//5 linhas (geral, ad, ae, bd, be) e 3 colunas (timeAvg, timeMin, timeMax)
long[][] time = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}};
FileManager fileManager = new FileManager();
// carrega os usuários do arquivo
public void loadUsers(String fileName) {
fileManager.loadUsersFromTxt(fileName, this);
}
// carrega os tempos do arquivo
public void loadTimeHistory(String fileName, int chartType) {
clearTimeLists();
fileManager.loadTimeHistoryFromTxt(fileName, chartType, this);
}
// adiciona um usuário
public void addUser(String line) {
String[] words = line.split("\\s+");
if (!users.contains(words[0])) {
users.add(words[0]);
}
}
// seleciona o usuário
public boolean selectUser(String user) {
if (users.contains(user)) {
currentUser = user;
return true;
}
return false;
}
// verifica o usuário
public boolean verifyUser(String user) {
if (users.contains(user)) {
return true;
}
return false;
}
// cria novo usuário
public boolean createNewUser(String user) {
if (!users.contains(user) && !user.contains("\n") && !user.contains(" ")) {
users.add(user);
currentUser = user;
return true;
}
return false;
}
// seleciona o treinamento
public void setTrainingMode(int trainingMode) {
this.trainingMode = trainingMode;
}
// adiciona os tempos nas listas correspondentes
public void addTimeHistory(String line, int chartType) {
String[] words = line.split("\\s+");
if (chartType == VISUALIZAR_INFORMACOES && checkForInformation(words)) {
times.add(Long.parseLong(words[6]));
times.add(Long.parseLong(words[7]));
times.add(Long.parseLong(words[8]));
} else if (chartType == COMPARAR_DISPOSITIVOS) {
int device = checkForDevices(words);
if (checkForInformation(words)) {
times.add(Long.parseLong(words[6]));
times.add(Long.parseLong(words[7]));
times.add(Long.parseLong(words[8]));
} else if (device == AD) {
timeDeviceAD.add(Long.parseLong(words[6]));
timeDeviceAD.add(Long.parseLong(words[7]));
timeDeviceAD.add(Long.parseLong(words[8]));
} else if (device == AE) {
timeDeviceAE.add(Long.parseLong(words[6]));
timeDeviceAE.add(Long.parseLong(words[7]));
timeDeviceAE.add(Long.parseLong(words[8]));
} else if (device == BD) {
timeDeviceBD.add(Long.parseLong(words[6]));
timeDeviceBD.add(Long.parseLong(words[7]));
timeDeviceBD.add(Long.parseLong(words[8]));
} else if (device == BE) {
timeDeviceBE.add(Long.parseLong(words[6]));
timeDeviceBE.add(Long.parseLong(words[7]));
timeDeviceBE.add(Long.parseLong(words[8]));
}
} else if (chartType == COMPARAR_ESTADO_FISICO) {
int physicalCondition = checkForPhysicalConditions(words);
if (physicalCondition == RESTED) {
timeRested.add(Long.parseLong(words[6]));
timeRested.add(Long.parseLong(words[7]));
timeRested.add(Long.parseLong(words[8]));
} else if (physicalCondition == TIRED) {
timeTired.add(Long.parseLong(words[6]));
timeTired.add(Long.parseLong(words[7]));
timeTired.add(Long.parseLong(words[8]));
}
} else if (chartType == COMPARAR_MEMBROS) {
int limb = checkForLimbs(words);
if (limb == UPPER_LIMB) {
timeUpperLimb.add(Long.parseLong(words[6]));
timeUpperLimb.add(Long.parseLong(words[7]));
timeUpperLimb.add(Long.parseLong(words[8]));
} else if (limb == LOWER_LIMB) {
timeLowerLimb.add(Long.parseLong(words[6]));
timeLowerLimb.add(Long.parseLong(words[7]));
timeLowerLimb.add(Long.parseLong(words[8]));
} else if (limb == BOTH) {
timeBoth.add(Long.parseLong(words[6]));
timeBoth.add(Long.parseLong(words[7]));
timeBoth.add(Long.parseLong(words[8]));
}
} else if(chartType == COMPARAR_LADO_DO_CORPO) {
int side = checkForSides(words);
if (side == LEFT_SIDE) {
timeLeftSide.add(Long.parseLong(words[6]));
timeLeftSide.add(Long.parseLong(words[7]));
timeLeftSide.add(Long.parseLong(words[8]));
} else if (side == RIGHT_SIDE) {
timeRightSide.add(Long.parseLong(words[6]));
timeRightSide.add(Long.parseLong(words[7]));
timeRightSide.add(Long.parseLong(words[8]));
} else if (side == BOTH) {
timeBoth.add(Long.parseLong(words[6]));
timeBoth.add(Long.parseLong(words[7]));
timeBoth.add(Long.parseLong(words[8]));
}
} else if (chartType == COMPARAR_USUARIOS) {
int user = checkForUsers(words);
if (user == 1) {
timeUser1.add(Long.parseLong(words[6]));
timeUser1.add(Long.parseLong(words[7]));
timeUser1.add(Long.parseLong(words[8]));
} else if (user == 2) {
timeUser2.add(Long.parseLong(words[6]));
timeUser2.add(Long.parseLong(words[7]));
timeUser2.add(Long.parseLong(words[8]));
} else if (user == 3) {
timeUser3.add(Long.parseLong(words[6]));
timeUser3.add(Long.parseLong(words[7]));
timeUser3.add(Long.parseLong(words[8]));
} else if (user == 4) {
timeUser4.add(Long.parseLong(words[6]));
timeUser4.add(Long.parseLong(words[7]));
timeUser4.add(Long.parseLong(words[8]));
}
}
}
// verifica a informação da linha
public boolean checkForInformation(String[] words) {
if (words.length == 9 &&
areEqual(user1, words[0]) &&
areEqual(getTrainingModeName(), words[1]) &&
areEqual(getLimbName(), words[2]) &&
areEqual(getPhysicalConditionName(), words[3]) &&
areEqual(getSideName(), words[4]) &&
areEqual(getDistanceName(), words[5])) {
return true;
}
return false;
}
// verifica qual é o dispositivo
public int checkForDevices(String[] words) {
if (words.length == 10 &&
areEqual(user1, words[0]) &&
areEqual(getTrainingModeName(), words[1]) &&
areEqual(getLimbName(), words[2]) &&
areEqual(getPhysicalConditionName(), words[3]) &&
areEqual(getSideName(), words[4]) &&
areEqual(getDistanceName(), words[5])) {
if (areEqual(words[9], "ad")) {
return AD;
} else if (areEqual(words[9], "ae")) {
return AE;
} else if (areEqual(words[9], "bd")) {
return BD;
} else if (areEqual(words[9], "be")) {
return BE;
}
}
return -1;
}
// verifica qual é o estado físico
public int checkForPhysicalConditions(String[] words) {
if (words.length == 9 &&
areEqual(user1, words[0]) &&
areEqual(getTrainingModeName(), words[1]) &&
areEqual(getLimbName(), words[2]) &&
areEqual(getSideName(), words[4]) &&
areEqual(getDistanceName(), words[5])) {
if (areEqual("Descansado", words[3])) {
return RESTED;
} else if (areEqual("Cansado", words[3])) {
return TIRED;
}
}
return -1;
}
// verifica quais são os membros
public int checkForLimbs(String[] words) {
if (words.length == 9 &&
areEqual(user1, words[0]) &&
areEqual(getTrainingModeName(), words[1]) &&
areEqual(getPhysicalConditionName(), words[3]) &&
areEqual(getSideName(), words[4]) &&
areEqual(getDistanceName(), words[5])) {
if (areEqual("Superiores", words[2])) {
return UPPER_LIMB;
} else if (areEqual("Inferiores", words[2])) {
return LOWER_LIMB;
} else if (areEqual("Ambos", words[2])) {
return BOTH;
}
}
return -1;
}
// verifica qual é o lado
public int checkForSides(String[] words) {
if (words.length == 9 &&
areEqual(user1, words[0]) &&
areEqual(getTrainingModeName(), words[1]) &&
areEqual(getLimbName(), words[2]) &&
areEqual(getPhysicalConditionName(), words[3]) &&
areEqual(getDistanceName(), words[5])) {
if (areEqual("Esquerdo", words[4])) {
return LEFT_SIDE;
} else if (areEqual("Direito", words[4])) {
return RIGHT_SIDE;
} else if (areEqual("Ambos", words[4])) {
return BOTH;
}
}
return -1;
}
// verifica qual é o usuário
public int checkForUsers(String[] words) {
if (words.length == 9 &&
areEqual(getTrainingModeName(), words[1]) &&
areEqual(getLimbName(), words[2]) &&
areEqual(getPhysicalConditionName(), words[3]) &&
areEqual(getSideName(), words[4]) &&
areEqual(getDistanceName(), words[5])) {
if (areEqual(user1, words[0])) {
System.out.println("user1");
return 1;
} else if (areEqual(user2, words[0])) {
System.out.println("user2");
return 2;
} else if (areEqual(user3, words[0])) {
System.out.println("user3");
return 3;
} else if (areEqual(user4, words[0])) {
System.out.println("user4");
return 4;
}
}
return -1;
}
// verifica se as strings são iguais
public boolean areEqual(String word1, String word2) {
return word1.equals(word2);
}
// verifica se as strings são iguais
public boolean areEqual(String word1, String word2, String word3) {
if (word1.equals(word2) ||
word1.equals(word3) ||
word2.equals(word3) ) {
return true;
}
return false;
}
// verifica se as strings são iguais
public boolean areEqual(String word1, String word2, String word3, String word4) {
if (word1.equals(word2) ||
word1.equals(word3) ||
word1.equals(word4) ||
word2.equals(word3) ||
word2.equals(word4) ||
word3.equals(word4) ) {
return true;
}
return false;
}
// verifica se os números são iguais
public boolean areEqual(int num1, int num2) {
if (num1 == num2) {
return true;
}
return false;
}
// salva os resultados
public void saveResult(String fileName) {
String text;
for (int i = 0; i < 5; i++) {
text = currentUser + " " +
getTrainingModeName() + " " +
getLimbName() + " " +
getPhysicalConditionName() + " " +
getSideName() + " " +
getDistanceName() + " " +
time[i][0] + " " +
time[i][1] + " " +
time[i][2];
if (i == 1) {
text += " " + "ad";
} else if (i == 2) {
text += " " + "ae";
} else if (i == 3) {
text += " " + "bd";
} else if (i == 4) {
text += " " + "be";
}
fileManager.saveResultsToTxt(fileName, text);
}
}
// retorna o nome do treinamento
public String getTrainingModeName() {
if (trainingMode == AGAINST_GROUP_MODE) {
return "Grupo";
} else if (trainingMode == SEQUENCE_MODE) {
return "Sequencial";
}
return "Aleatório";
}
// retorna o nome dos membros
public String getLimbName() {
if (limb == LOWER_LIMB) {
return "Inferiores";
} else if (limb == UPPER_LIMB) {
return "Superiores";
}
return "Ambos";
}
// retorna o nome do lado
public String getSideName() {
if (side == LEFT_SIDE) {
return "Esquerdo";
} else if (side == RIGHT_SIDE) {
return "Direito";
}
return "Ambos";
}
// retorna o nome do estado físico
public String getPhysicalConditionName() {
if (physicalCondition == TIRED) {
return "Cansado";
}
return "Descansado";
}
// retorna o nome das distâncias entre os dispositivos
public String getDistanceName() {
if (distance == SHORT_DISTANCE) {
return "Curtas";
}
return "Longas";
}
// retorna o módulo de treinamento
public int getTrainingModeNum(String name) {
if (name == "Grupo") {
return AGAINST_GROUP_MODE;
} else if (name == "Sequencial") {
return SEQUENCE_MODE;
}
return RANDOM_MODE;
}
// retorna os membros
public int getLimbNum(String name) {
if (name == "Inferiores") {
return LOWER_LIMB;
} else if (name == "Superiores") {
return UPPER_LIMB;
}
return BOTH;
}
// retorna o lado
public int getSideNum(String name) {
if (name == "Esquerdo") {
return LEFT_SIDE;
} else if (name == "Direito") {
return RIGHT_SIDE;
}
return BOTH;
}
// retorna o estado físico
public int getPhysicalConditionNum(String name) {
if (name == "Cansado") {
return TIRED;
}
return RESTED;
}
// retorna o número do dispositivo
public int getDistanceNum(String name) {
if (name == "Curtas") {
return SHORT_DISTANCE;
}
return LONG_DISTANCE;
}
// define a posição dos dispositivos
public void setPositionDevice(int deviceNum, String altura, String lado) {
if (altura == "Alto") {
if (lado == "Direito") {
if (deviceNum == 1) {
positionDevice1 = AD;
} else if (deviceNum == 2) {
positionDevice2 = AD;
} else if (deviceNum == 3) {
positionDevice3 = AD;
} else if (deviceNum == 4) {
positionDevice4 = AD;
} else if (deviceNum == 5) {
positionDevice5 = AD;
} else if (deviceNum == 6) {
positionDevice6 = AD;
} else if (deviceNum == 7) {
positionDevice7 = AD;
}
} else if (lado == "Esquerdo") {
if (deviceNum == 1) {
positionDevice1 = AE;
} else if (deviceNum == 2) {
positionDevice2 = AE;
} else if (deviceNum == 3) {
positionDevice3 = AE;
} else if (deviceNum == 4) {
positionDevice4 = AE;
} else if (deviceNum == 5) {
positionDevice5 = AE;
} else if (deviceNum == 6) {
positionDevice6 = AE;
} else if (deviceNum == 7) {
positionDevice7 = AE;
}
}
} else if (altura == "Baixo") {
if (lado == "Direito") {
if (deviceNum == 1) {
positionDevice1 = BD;
} else if (deviceNum == 2) {
positionDevice2 = BD;
} else if (deviceNum == 3) {
positionDevice3 = BD;
} else if (deviceNum == 4) {
positionDevice4 = BD;
} else if (deviceNum == 5) {
positionDevice5 = BD;
} else if (deviceNum == 6) {
positionDevice6 = BD;
} else if (deviceNum == 7) {
positionDevice7 = BD;
}
} else if (lado == "Esquerdo") {
if (deviceNum == 1) {
positionDevice1 = BE;
} else if (deviceNum == 2) {
positionDevice2 = BE;
} else if (deviceNum == 3) {
positionDevice3 = BE;
} else if (deviceNum == 4) {
positionDevice4 = BE;
} else if (deviceNum == 5) {
positionDevice5 = BE;
} else if (deviceNum == 6) {
positionDevice6 = BE;
} else if (deviceNum == 7) {
positionDevice7 = BE;
}
}
}
}
// esvazia as listas
public void clearTimeLists() {
times.clear();
timeUser1.clear();
timeUser2.clear();
timeUser3.clear();
timeUser4.clear();
timeRested.clear();
timeTired.clear();
timeUpperLimb.clear();
timeLowerLimb.clear();
timeLeftSide.clear();
timeRightSide.clear();
timeBoth.clear();
timeDeviceAD.clear();
timeDeviceAE.clear();
timeDeviceBD.clear();
timeDeviceBE.clear();
}
}