Compare commits
565 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfb65131e2 | ||
|
|
6faa5edd57 | ||
|
|
2f2a9ba9fc | ||
|
|
533a5e9631 | ||
|
|
f31449508e | ||
|
|
b266160e93 | ||
|
|
a44907865c | ||
|
|
2f1d07f008 | ||
|
|
af65142bf4 | ||
|
|
e2be018816 | ||
|
|
36fbcfedb8 | ||
|
|
2b985344dc | ||
|
|
c030bf3a8e | ||
|
|
8150537aa5 | ||
|
|
694d58924c | ||
|
|
2ed6192090 | ||
|
|
5ef716330c | ||
|
|
facebc1334 | ||
|
|
84793dc924 | ||
|
|
dd184a1398 | ||
|
|
b959484185 | ||
|
|
69d80b1f7c | ||
|
|
f8799c06fb | ||
|
|
f20f010cb8 | ||
|
|
048253a9d3 | ||
|
|
8d029fe21c | ||
|
|
60f8b2a9d9 | ||
|
|
66c2b44be6 | ||
|
|
f0d6b04e30 | ||
|
|
6084338525 | ||
|
|
9006588eed | ||
|
|
367daa1eff | ||
|
|
a2af22facb | ||
|
|
abdaa14679 | ||
|
|
8c5f177704 | ||
|
|
00718a1cf2 | ||
|
|
e73c419c55 | ||
|
|
f4cc37a34b | ||
|
|
461b3bd329 | ||
|
|
f56a959720 | ||
|
|
796deadb8c | ||
|
|
2b1c6cf780 | ||
|
|
eed4f7903d | ||
|
|
377db10f13 | ||
|
|
50fb2078b0 | ||
|
|
123a767a75 | ||
|
|
e0e6744c95 | ||
|
|
cfc238af73 | ||
|
|
78e050751f | ||
|
|
81f48ca0b6 | ||
|
|
d97ae9b53a | ||
|
|
2a136b6a07 | ||
|
|
080053765c | ||
|
|
21ab3d5b79 | ||
|
|
8e747e54be | ||
|
|
99899dfc88 | ||
|
|
867eae66f4 | ||
|
|
37d43c8247 | ||
|
|
a704522a63 | ||
|
|
cefc4d2b4b | ||
|
|
222489a316 | ||
|
|
4b949db919 | ||
|
|
c8cbb25f5d | ||
|
|
5653800d47 | ||
|
|
c8d5dd99ae | ||
|
|
6d7e73586f | ||
|
|
12ca633461 | ||
|
|
a715babcd9 | ||
|
|
7b6b8ead65 | ||
|
|
a206625082 | ||
|
|
425550c922 | ||
|
|
e6ecda5471 | ||
|
|
f6f74cd2aa | ||
|
|
d03deace57 | ||
|
|
4dd02649b8 | ||
|
|
9fd3b1cf5b | ||
|
|
9fc42247da | ||
|
|
fb22937864 | ||
|
|
dc432df120 | ||
|
|
a6a52688f2 | ||
|
|
ae7e36f757 | ||
|
|
917d3a64bb | ||
|
|
92ff0073e8 | ||
|
|
3cc01e4f4a | ||
|
|
7043f7253d | ||
|
|
83611c4ecc | ||
|
|
b99b66b87b | ||
|
|
3e7fbeae75 | ||
|
|
839292ad91 | ||
|
|
6ba21c331d | ||
|
|
0cda63cacb | ||
|
|
79fd69503c | ||
|
|
cbf15d9574 | ||
|
|
8667f65e33 | ||
|
|
544b756e70 | ||
|
|
18a0973af4 | ||
|
|
9e37421d6d | ||
|
|
31def99398 | ||
|
|
dbe6fc4e33 | ||
|
|
231c580f7a | ||
|
|
7867853cdb | ||
|
|
39b108626b | ||
|
|
8195650226 | ||
|
|
9310674301 | ||
|
|
2025fd02cc | ||
|
|
55fe2b6795 | ||
|
|
b05b0ecaf7 | ||
|
|
e1489bda27 | ||
|
|
a2805c2a9f | ||
|
|
16fb86c513 | ||
|
|
1cd46940cf | ||
|
|
e9efdf5f24 | ||
|
|
86ec4bbd7d | ||
|
|
d210e22788 | ||
|
|
1cf3af45be | ||
|
|
24be00d28a | ||
|
|
e30f312c6a | ||
|
|
95d5b2b971 | ||
|
|
c0e0063465 | ||
|
|
61a99d47d1 | ||
|
|
6cbabbdf8d | ||
|
|
2a873a78c9 | ||
|
|
0e546bc25c | ||
|
|
4293790ece | ||
|
|
290694c5f1 | ||
|
|
eeb0fd9d57 | ||
|
|
733c0c5920 | ||
|
|
238c00ff46 | ||
|
|
4433d509bb | ||
|
|
0f9cd14036 | ||
|
|
9af14e6015 | ||
|
|
bce08eb6f2 | ||
|
|
dcb8404ae7 | ||
|
|
82fd016590 | ||
|
|
ccbe5968da | ||
|
|
adb8406d4e | ||
|
|
9ab4439f70 | ||
|
|
47c46b5458 | ||
|
|
02253cb645 | ||
|
|
b92e302f8b | ||
|
|
67b97eb331 | ||
|
|
daa1c838b4 | ||
|
|
7228252169 | ||
|
|
27a18659f8 | ||
|
|
f2501f3624 | ||
|
|
2b7d51a5ed | ||
|
|
75faf4ae8c | ||
|
|
06daa4776f | ||
|
|
4b07aa8072 | ||
|
|
8927b78098 | ||
|
|
1f12291398 | ||
|
|
1684068385 | ||
|
|
e929680477 | ||
|
|
f23fc2cbea | ||
|
|
4fa2707add | ||
|
|
7ac5b1efda | ||
|
|
b08174b2ee | ||
|
|
04db410293 | ||
|
|
c5e7ff2884 | ||
|
|
c8521feaf8 | ||
|
|
25a66832a5 | ||
|
|
a55e4cecef | ||
|
|
5c85c56d78 | ||
|
|
c79a98c57d | ||
|
|
81701758d7 | ||
|
|
4b04487a25 | ||
|
|
50c27cf420 | ||
|
|
5526c8f467 | ||
|
|
922a7d1fae | ||
|
|
6ced05278b | ||
|
|
9e6505dfa3 | ||
|
|
86f1b724c7 | ||
|
|
90d50624f6 | ||
|
|
82eb5575ee | ||
|
|
84154fca3a | ||
|
|
3aad682394 | ||
|
|
b5c834fc52 | ||
|
|
1ff84ce3d8 | ||
|
|
c5f7cac9db | ||
|
|
19fef1d4c8 | ||
|
|
28f9f72f07 | ||
|
|
f5250aa2a0 | ||
|
|
d5af8816e9 | ||
|
|
6a2eb27627 | ||
|
|
01e03782c2 | ||
|
|
bb6d887036 | ||
|
|
7b6457b286 | ||
|
|
54d0537f95 | ||
|
|
b781727703 | ||
|
|
4c50eea99a | ||
|
|
a38cd45e2a | ||
|
|
e48264a667 | ||
|
|
12b05f3b73 | ||
|
|
6d37b99c14 | ||
|
|
52291ac10f | ||
|
|
ae5d4a1496 | ||
|
|
d7454345be | ||
|
|
26693e8782 | ||
|
|
e78be7ac9f | ||
|
|
a25c5da5ac | ||
|
|
5ab7deb210 | ||
|
|
9ad503db0d | ||
|
|
5a412cd170 | ||
|
|
644f466696 | ||
|
|
118ae797f5 | ||
|
|
fcaf3ddb49 | ||
|
|
8f026a960e | ||
|
|
b8bb8dc91c | ||
|
|
d824a3b819 | ||
|
|
a5dd8667b9 | ||
|
|
947ae660a0 | ||
|
|
c85432fb48 | ||
|
|
f133e80ce3 | ||
|
|
97577cfd1c | ||
|
|
0cfead72af | ||
|
|
c3124f509e | ||
|
|
d484898ba1 | ||
|
|
bd225edea1 | ||
|
|
608d3ec40f | ||
|
|
c8b9b4d78f | ||
|
|
a9f63f6fab | ||
|
|
3f4e7cb9a9 | ||
|
|
9f3597124d | ||
|
|
f4f79484fa | ||
|
|
3b4add03ee | ||
|
|
32c9713835 | ||
|
|
8e11ecbcf4 | ||
|
|
9f45b1c8ac | ||
|
|
c03538ff34 | ||
|
|
7805122c06 | ||
|
|
61ed9fc497 | ||
|
|
85412af2a6 | ||
|
|
5449c664bd | ||
|
|
b4a00fade2 | ||
|
|
cf1704e872 | ||
|
|
383d505f52 | ||
|
|
cc236c46b6 | ||
|
|
ed695f941d | ||
|
|
a41b697510 | ||
|
|
ebaeff9fad | ||
|
|
973e8aba69 | ||
|
|
7656b60fcf | ||
|
|
1437bbc1bc | ||
|
|
ca11cd3c9a | ||
|
|
0b2677fd06 | ||
|
|
336e56bb51 | ||
|
|
026cd15009 | ||
|
|
f5d9bd5010 | ||
|
|
3d61cd061a | ||
|
|
393bfc9445 | ||
|
|
a64b31001a | ||
|
|
704854e8b5 | ||
|
|
25c8951530 | ||
|
|
e41f434a28 | ||
|
|
0530fc4ddb | ||
|
|
36f36d4100 | ||
|
|
d0beb236ea | ||
|
|
c62e4719ea | ||
|
|
a92a5b6e47 | ||
|
|
56bd05324c | ||
|
|
fcea76f0e9 | ||
|
|
6fd04b1d0a | ||
|
|
6ab7141f64 | ||
|
|
980e64657a | ||
|
|
7267a73cbe | ||
|
|
c9178362cc | ||
|
|
42cf5a5ee4 | ||
|
|
56829cca6b | ||
|
|
e51ef99bc9 | ||
|
|
4a31b52e69 | ||
|
|
20c37c4899 | ||
|
|
07f5eb0449 | ||
|
|
3dec44ada1 | ||
|
|
1d10d1d54b | ||
|
|
1f03552d84 | ||
|
|
2abad808ad | ||
|
|
a540b9e8f2 | ||
|
|
08d46ea8f0 | ||
|
|
e755107fa8 | ||
|
|
37d3e6c4a7 | ||
|
|
81f58c86f9 | ||
|
|
0bf32dc19c | ||
|
|
8ec3a508eb | ||
|
|
71ea1e3a4b | ||
|
|
61e31df157 | ||
|
|
064e8e04c2 | ||
|
|
97a0e38c40 | ||
|
|
0751f50026 | ||
|
|
470a31889a | ||
|
|
90bf334c19 | ||
|
|
12e677607d | ||
|
|
c6ff4862e6 | ||
|
|
bc6e8cd89d | ||
|
|
4780ae7b11 | ||
|
|
b1f3725f71 | ||
|
|
1668731624 | ||
|
|
d6640966c5 | ||
|
|
cf96ac30b8 | ||
|
|
4171b933dc | ||
|
|
c61469476b | ||
|
|
8677ac94ef | ||
|
|
f11cfc804b | ||
|
|
f39aef31d0 | ||
|
|
4a6d4c7043 | ||
|
|
bd21e30f26 | ||
|
|
cc9f8196bc | ||
|
|
9e345ee353 | ||
|
|
7a4a031b1d | ||
|
|
ba5e261c7f | ||
|
|
471d41a600 | ||
|
|
a1ba2f1d7d | ||
|
|
28cd0d0d7f | ||
|
|
437267dcb9 | ||
|
|
559885e22b | ||
|
|
d8ced45a67 | ||
|
|
72cb770861 | ||
|
|
0ae5e7f4ee | ||
|
|
4200ae587d | ||
|
|
f28a4ea924 | ||
|
|
ec37bdcd79 | ||
|
|
7a11e6260e | ||
|
|
b0cdd9bff7 | ||
|
|
698c6ef7fd | ||
|
|
4be4853685 | ||
|
|
36c67ce217 | ||
|
|
cb15a1fefe | ||
|
|
19f4a73119 | ||
|
|
71fc659c79 | ||
|
|
4cb256a30a | ||
|
|
521426ac16 | ||
|
|
987acbad71 | ||
|
|
2e745e690c | ||
|
|
1cec006178 | ||
|
|
cf0952c7c2 | ||
|
|
b0d69bfc2c | ||
|
|
006cf60d17 | ||
|
|
baf516e989 | ||
|
|
5c9c1b8be5 | ||
|
|
d7dcd95278 | ||
|
|
fc7e718b21 | ||
|
|
8e58118ac7 | ||
|
|
99143a8f20 | ||
|
|
34e010f62d | ||
|
|
e8108498ad | ||
|
|
e79d050b12 | ||
|
|
b9fb7d81ce | ||
|
|
563ae51408 | ||
|
|
caa86f446d | ||
|
|
ce669b47d2 | ||
|
|
97d2a0f6fc | ||
|
|
2dce37222d | ||
|
|
a973ab0750 | ||
|
|
ae3ab8f563 | ||
|
|
d5319fc973 | ||
|
|
566af39b0d | ||
|
|
eb3326481a | ||
|
|
b3d4f573f8 | ||
|
|
e494b5294d | ||
|
|
18c3ce0c92 | ||
|
|
5b3896d310 | ||
|
|
f8315700d9 | ||
|
|
6385beec06 | ||
|
|
12c2ebab4e | ||
|
|
e69e08ad15 | ||
|
|
ae000baba4 | ||
|
|
caf9e3e1d9 | ||
|
|
bddf984438 | ||
|
|
6323fd06eb | ||
|
|
fb69ec280d | ||
|
|
dfdbc8d5a9 | ||
|
|
b3a0ddaa68 | ||
|
|
93aaf19f13 | ||
|
|
8345b6c06f | ||
|
|
292035498c | ||
|
|
1f78805f9b | ||
|
|
9d38e1e541 | ||
|
|
121b86a73e | ||
|
|
920c7c798d | ||
|
|
2c54b8d68c | ||
|
|
0ed8dc34ab | ||
|
|
b8f4415825 | ||
|
|
2e244e600f | ||
|
|
32b0554329 | ||
|
|
4f089d8408 | ||
|
|
563c72ffec | ||
|
|
ecdc9f3a4f | ||
|
|
2c32b7d65b | ||
|
|
8dd8ae28d4 | ||
|
|
68036b3c2f | ||
|
|
6a71823885 | ||
|
|
baa681833e | ||
|
|
166945871d | ||
|
|
17d5591146 | ||
|
|
874c6fba06 | ||
|
|
f89470458b | ||
|
|
318900b203 | ||
|
|
584e5bf90c | ||
|
|
436343d170 | ||
|
|
4863ae4d3f | ||
|
|
97807293f9 | ||
|
|
8caf3bdac9 | ||
|
|
2e747fdc89 | ||
|
|
0ca0a516bd | ||
|
|
bb89b67e87 | ||
|
|
ba4b40efab | ||
|
|
dbde18d3f2 | ||
|
|
a15cfc21fc | ||
|
|
9c9a98c738 | ||
|
|
3af4d1778f | ||
|
|
d3c42e70fe | ||
|
|
8870ed1f56 | ||
|
|
b2ae1d75a5 | ||
|
|
f018484556 | ||
|
|
e12d5945ff | ||
|
|
6945eddf5d | ||
|
|
f76a6827f7 | ||
|
|
a2e432d453 | ||
|
|
3e5957b807 | ||
|
|
f66191f136 | ||
|
|
711b16449c | ||
|
|
d7960103ee | ||
|
|
2546355eba | ||
|
|
8864320832 | ||
|
|
3c5bc0a651 | ||
|
|
aa393da53b | ||
|
|
76ebd018bd | ||
|
|
88e7afb8fb | ||
|
|
e92dd0ba2b | ||
|
|
e0f0e38241 | ||
|
|
282d2026ba | ||
|
|
874b0bcd72 | ||
|
|
a9e659fc9f | ||
|
|
2c3314c693 | ||
|
|
8524bb2e89 | ||
|
|
8a4134c52b | ||
|
|
b0e2ad2903 | ||
|
|
8c13a8bf39 | ||
|
|
01b4ac4287 | ||
|
|
4fa6ac7f53 | ||
|
|
1da7f62c95 | ||
|
|
0c042daa1c | ||
|
|
bfc9595d21 | ||
|
|
dd74a97c47 | ||
|
|
4b77102205 | ||
|
|
018a164723 | ||
|
|
061a6fc957 | ||
|
|
ba98b30776 | ||
|
|
ed35c77262 | ||
|
|
09c7817eef | ||
|
|
e79280e470 | ||
|
|
5f4069fcad | ||
|
|
dc6682d7fa | ||
|
|
922f8b2657 | ||
|
|
2999359b01 | ||
|
|
ec63a64248 | ||
|
|
5b13f26dee | ||
|
|
561cca7f5a | ||
|
|
20b6e89781 | ||
|
|
249b40572e | ||
|
|
dc5ddfa90e | ||
|
|
a80aaf3a59 | ||
|
|
454a0ec1a3 | ||
|
|
82d3f08e2d | ||
|
|
72c8a213a1 | ||
|
|
0d0b78f6d0 | ||
|
|
07c76dd385 | ||
|
|
f5fa03b104 | ||
|
|
34d098f188 | ||
|
|
b1ab9f4e8a | ||
|
|
b5defaa581 | ||
|
|
e1448055f5 | ||
|
|
4306372a61 | ||
|
|
a605e1a92e | ||
|
|
e718e3859b | ||
|
|
50c58da035 | ||
|
|
c23344e8ef | ||
|
|
a817d9118a | ||
|
|
fb6dfcdd20 | ||
|
|
7539dd20f6 | ||
|
|
af25d85440 | ||
|
|
4b702bc63b | ||
|
|
5a62ef18dd | ||
|
|
0fb1991240 | ||
|
|
592015b1cd | ||
|
|
9a294930d8 | ||
|
|
33c09581ec | ||
|
|
7fb44f6867 | ||
|
|
98df90b0b2 | ||
|
|
80d5e42c00 | ||
|
|
4b9e6fce66 | ||
|
|
9ff1eb6b09 | ||
|
|
479ed8e7f2 | ||
|
|
59c84f2c09 | ||
|
|
928c6f89a6 | ||
|
|
20735380e5 | ||
|
|
31499adc00 | ||
|
|
2b04ce2306 | ||
|
|
ad4e49f65c | ||
|
|
e9bee87a38 | ||
|
|
8bbe3f0fe9 | ||
|
|
cca49bc9d6 | ||
|
|
cea68e93c9 | ||
|
|
c07ea93176 | ||
|
|
a5b4a2e8f0 | ||
|
|
f959ffc066 | ||
|
|
ed1af0ebbc | ||
|
|
7edd9e7ed0 | ||
|
|
b25e9a0db2 | ||
|
|
a12f364df0 | ||
|
|
ceac07b27b | ||
|
|
664a941976 | ||
|
|
a9c99ed678 | ||
|
|
80bc87922c | ||
|
|
aa448506d7 | ||
|
|
0be9322f66 | ||
|
|
25758cfbd2 | ||
|
|
a265c286eb | ||
|
|
d02393400e | ||
|
|
7548df160d | ||
|
|
a9827b8573 | ||
|
|
5877e307d5 | ||
|
|
ece58798f1 | ||
|
|
7e529f5608 | ||
|
|
29229e457c | ||
|
|
7af5470a8e | ||
|
|
309337f26d | ||
|
|
d902c7401d | ||
|
|
cd7f5b390b | ||
|
|
bbc7794e6b | ||
|
|
d8b51922ac | ||
|
|
6d0bcaeb5c | ||
|
|
c35d5d76bc | ||
|
|
cfa7717bea | ||
|
|
909f9a6dd1 | ||
|
|
6df15465e7 | ||
|
|
c5c34e17dc | ||
|
|
a231b7374d | ||
|
|
b4c3f3644a | ||
|
|
c0fdb466d5 | ||
|
|
dff3cffb00 | ||
|
|
60907b30f7 | ||
|
|
dc5534ae34 | ||
|
|
2a0210326e | ||
|
|
aabe922f8f | ||
|
|
c15ba030bf | ||
|
|
3681daa6f4 | ||
|
|
e6e3544bb7 | ||
|
|
688d2ef847 | ||
|
|
a6e1a70448 | ||
|
|
987997bfb3 | ||
|
|
2e1becbe32 | ||
|
|
803b0c2064 | ||
|
|
fa73f6fb4d | ||
|
|
cab6d9aeeb | ||
|
|
aa79365784 | ||
|
|
7a60ecb60f | ||
|
|
7b1dc88653 | ||
|
|
5b802ea980 | ||
|
|
fc3b750348 | ||
|
|
584a373284 | ||
|
|
0b244ebc00 | ||
|
|
3b180893c7 | ||
|
|
9e3128d4a0 | ||
|
|
85ddd2b787 | ||
|
|
5c63e701e8 |
45
.gitignore
vendored
@@ -19,10 +19,12 @@
|
||||
# Edit at https://www.gitignore.io/?templates=java,maven,eclipse,intellij,visualstudiocode
|
||||
|
||||
### our project ###
|
||||
Client/.idea/
|
||||
Client/.gradle/
|
||||
Server/.idea/
|
||||
Server/.gradle/
|
||||
src/**/.idea/
|
||||
# src/**/.gradle/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Eclipse ###
|
||||
|
||||
@@ -85,9 +87,11 @@ local.properties
|
||||
### Eclipse Patch ###
|
||||
# Eclipse Core
|
||||
.project
|
||||
**/.project
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
**/.classpath
|
||||
|
||||
# Annotation Processing
|
||||
.apt_generated
|
||||
@@ -206,13 +210,36 @@ buildNumber.properties
|
||||
|
||||
### VisualStudioCode ###
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
|
||||
### VisualStudioCode Patch ###
|
||||
# Ignore all local history of files
|
||||
.history
|
||||
|
||||
# End of https://www.gitignore.io/api/java,maven,eclipse,intellij,visualstudiocode
|
||||
# End of https://www.gitignore.io/api/java,maven,eclipse,intellij,visualstudiocode
|
||||
|
||||
### Gradle ###
|
||||
.gradle
|
||||
|
||||
## keep the build directory, as it contains the reports for the ci
|
||||
build/
|
||||
!**/Client/build/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
|
||||
# gradle/wrapper/gradle-wrapper.properties
|
||||
|
||||
### Gradle Patch ###
|
||||
|
||||
## keep the build directory, as it contains the reports for the ci
|
||||
**/build/
|
||||
|
||||
# End of https://www.gitignore.io/api/gradle
|
||||
@@ -2,7 +2,8 @@
|
||||
# This is the Gradle build system for JVM applications
|
||||
# https://gradle.org/
|
||||
# https://github.com/gradle/gradle
|
||||
image: gradle:alpine
|
||||
# image: gradle:alpine
|
||||
image: thijsray/java8-javafx-gradle
|
||||
|
||||
# Disable the Gradle daemon for Continuous Integration servers as correctness
|
||||
# is usually a priority over speed in CI environments. Using a fresh
|
||||
@@ -24,7 +25,6 @@ build:
|
||||
- build
|
||||
- .gradle
|
||||
|
||||
|
||||
test:
|
||||
stage: test
|
||||
script: gradle check
|
||||
@@ -34,4 +34,14 @@ test:
|
||||
paths:
|
||||
- build
|
||||
- .gradle
|
||||
|
||||
|
||||
# Code coverage badge
|
||||
#deploy:
|
||||
# stage: code-coverage
|
||||
# script:
|
||||
# - gradle clean check
|
||||
# after_script:
|
||||
# - awk -F"," '{ instructions += $4 + $5; covered += $5 } END { print covered, "/", instructions, " instructions covered"; print 100*covered/instructions, "% instructrions covered" }' target/site/jacoco/jacoco.csv
|
||||
# - awk -F"," '{ instructions += $6 + $7; covered += $7 } END { print covered, "/", instructions, " branches covered"; print 100*covered/instructions, "% branches covered" }' target/site/jacoco/jacoco.csv
|
||||
# - echo \"$(cat target/site/jacoco/jacoco.csv)% covered\"
|
||||
# coverage: '/(\d+.\d+) % +branches covered/'
|
||||
@@ -1,188 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
|
||||
<!--
|
||||
This configuration file was written by the eclipse-cs plugin configuration editor
|
||||
-->
|
||||
<!--
|
||||
Checkstyle-Configuration: TI1216
|
||||
Description:
|
||||
Checkstyle configurartion that checks the Google coding conventions (https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html).
|
||||
-->
|
||||
<module name="Checker">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="charset" value="UTF-8"/>
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
<module name="TreeWalker">
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="IllegalTokenText">
|
||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||
<property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
|
||||
</module>
|
||||
<module name="LineLength">
|
||||
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||
<property name="max" value="100"/>
|
||||
</module>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="OneTopLevelClass"/>
|
||||
<module name="NoLineWrap"/>
|
||||
<module name="EmptyBlock">
|
||||
<property name="option" value="TEXT"/>
|
||||
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
|
||||
</module>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly"/>
|
||||
<module name="RightCurly">
|
||||
<property name="option" value="alone"/>
|
||||
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="allowEmptyConstructors" value="true"/>
|
||||
<property name="allowEmptyMethods" value="true"/>
|
||||
<property name="allowEmptyTypes" value="true"/>
|
||||
<property name="allowEmptyLoops" value="true"/>
|
||||
<message key="ws.notPreceded" value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
||||
<message key="ws.notFollowed" value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
|
||||
</module>
|
||||
<module name="OneStatementPerLine"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="FallThrough"/>
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="option" value="nl"/>
|
||||
<property name="tokens" value="DOT"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="option" value="EOL"/>
|
||||
<property name="tokens" value="COMMA"/>
|
||||
</module>
|
||||
<module name="PackageName">
|
||||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
||||
<message key="name.invalidPattern" value="Package name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="TypeName">
|
||||
<message key="name.invalidPattern" value="Type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<message key="name.invalidPattern" value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ParameterName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<message key="name.invalidPattern" value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LocalVariableName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<property name="allowOneCharVarInForLoop" value="true"/>
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<message key="name.invalidPattern" value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ClassTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MethodTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="InterfaceTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Interface type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="NoFinalizer"/>
|
||||
<module name="GenericWhitespace">
|
||||
<message key="ws.notPreceded" value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||
<message key="ws.followed" value="GenericWhitespace ''{0}'' is followed by whitespace."/>
|
||||
<message key="ws.preceded" value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
|
||||
<message key="ws.illegalFollow" value="GenericWhitespace ''{0}'' should followed by whitespace."/>
|
||||
</module>
|
||||
<module name="Indentation">
|
||||
<property name="basicOffset" value="4"/>
|
||||
<property name="caseIndent" value="4"/>
|
||||
<property name="arrayInitIndent" value="4"/>
|
||||
</module>
|
||||
<module name="AbbreviationAsWordInName">
|
||||
<property name="allowedAbbreviationLength" value="1"/>
|
||||
<property name="ignoreFinal" value="false"/>
|
||||
</module>
|
||||
<module name="OverloadMethodsDeclarationOrder"/>
|
||||
<module name="VariableDeclarationUsageDistance"/>
|
||||
<module name="CustomImportOrder">
|
||||
<property name="customImportOrderRules" value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
|
||||
<property name="specialImportsRegExp" value="com.google"/>
|
||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||
</module>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="OperatorWrap">
|
||||
<property name="option" value="NL"/>
|
||||
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
||||
</module>
|
||||
<module name="NonEmptyAtclauseDescription"/>
|
||||
<module name="JavadocTagContinuationIndentation"/>
|
||||
<module name="SummaryJavadoc">
|
||||
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
|
||||
</module>
|
||||
<module name="JavadocParagraph"/>
|
||||
<module name="AtclauseOrder">
|
||||
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
|
||||
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
|
||||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<property name="minLineCount" value="2"/>
|
||||
<property name="allowedAnnotations" value="Override, Test"/>
|
||||
<property name="scope" value="public"/>
|
||||
<property name="allowThrowsTagsForSubclasses" value="true"/>
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingThrowsTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
</module>
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||
<message key="name.invalidPattern" value="Method name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="SingleLineJavadoc">
|
||||
<property name="ignoreInlineTags" value="false"/>
|
||||
</module>
|
||||
<module name="EmptyCatchBlock">
|
||||
<property name="exceptionVariableName" value="expected"/>
|
||||
</module>
|
||||
<module name="CommentsIndentation"/>
|
||||
<module name="UnusedImports"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="MethodLength"/>
|
||||
<module name="ParameterNumber"/>
|
||||
<module name="MethodCount">
|
||||
<property name="maxTotal" value="50"/>
|
||||
<property name="maxPrivate" value="50"/>
|
||||
<property name="maxPackage" value="50"/>
|
||||
<property name="maxProtected" value="50"/>
|
||||
<property name="maxPublic" value="50"/>
|
||||
</module>
|
||||
<module name="AvoidNestedBlocks"/>
|
||||
<module name="DeclarationOrder"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="IllegalThrows"/>
|
||||
<module name="IllegalCatch"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="StringLiteralEquality"/>
|
||||
<module name="UnnecessaryParentheses"/>
|
||||
<module name="CyclomaticComplexity"/>
|
||||
</module>
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
<module name="FileLength"/>
|
||||
</module>
|
||||
109
README.md
@@ -1,35 +1,36 @@
|
||||
## Getting your weekly reports
|
||||
# Greenify
|
||||
The easiest way to save CO2 and help the environment! Enter your activities and find out your carbon footprint.
|
||||

|
||||

|
||||
|
||||
**Jacoco**:
|
||||
Run `maven install` ([Intellij](https://www.jetbrains.com/help/idea/2016.3/getting-started-with-maven.html#execute_maven_goal)/[Eclipse](http://imgur.com/a/6q7pV))
|
||||
## Badges
|
||||
[](https://gitlab.ewi.tudelft.nl/cse1105/2018-2019/oopp-group-43/template)
|
||||
|
||||
**Checkstyle**:
|
||||
Run `maven site`
|
||||
## Getting started
|
||||
To start Greenify:
|
||||
|
||||
# Daan Sneep (4849515, dsneep)
|
||||
```
|
||||
cd <FILE-LOCATION>/greenify/src/Client/build/libs
|
||||
java -Dserver.address="https://greenify43.herokuapp.com" -jar greenify-1.0.0.jar
|
||||
```
|
||||
|
||||

|
||||
## Running the tests
|
||||
The tests cover all non-GUI code:
|
||||
|
||||
## Personal Development Plan
|
||||
```
|
||||
cd <FILE-LOCATION>/greenify
|
||||
gradle check
|
||||
```
|
||||
|
||||
My Core Quadrant is visible 
|
||||
## Licence
|
||||
GNU General Public License v3.0
|
||||
|
||||
### G – Goal
|
||||
After completing this project, I want to be able to work on a programming project efficiently with other people. I have never attempted anything of this scale and find that it is a core requirement of becoming a good programmer, as in most companies programming is done within teams, not alone.
|
||||
## Contributors
|
||||
|
||||
### R – Reality
|
||||
With this project I hope to work towards this goal. I have never programmed as a team on this scale, so this project will be the first step towards my goal.
|
||||
### Merel Steenbergen (masteenbergen)
|
||||
<img src="https://user-images.githubusercontent.com/47633984/55274602-13cc1200-52da-11e9-9bd7-686d84929b83.jpg" width="100"/>
|
||||
|
||||
### O – Options
|
||||
During this quarter the project will be my only option towards achieving this goal. If I am unhappy with my progress towards my goal by the end of this quarter, I must try to implement the same structure of teamwork in my next projects, and try to learn from the mistakes I made when working as a team in this project.
|
||||
|
||||
### W – Will
|
||||
I will try to make sure to adhere to the structure we establish as a group which describes how we will work together. This way, we all do the work we are supposed to do, and none of us will be overloaded with work. I will also try to make use of all the tools available to us which can improve the quality of programming together (scrum, git, GitLab etc.).
|
||||
|
||||
# Merel Steenbergen (masteenbergen)
|
||||

|
||||
|
||||
## Personal Development Plan
|
||||
#### Personal Development Plan
|
||||
|
||||
My strong points:
|
||||
1. I’m a natural leader. I like to know how everyone is doing, if
|
||||
@@ -39,37 +40,37 @@ everyone is keeping on track and if not, why is someone slacking?
|
||||
What are two of your weaker points?
|
||||
1. I’m a bit of a control freak. Sometimes I find it hard to let other people do things and to mind my own business.
|
||||
2. I’m competitive. This can be a good thing, because I’m very passionate and really give it 100% if I like something, but it can also lead to hurt feelings when I’m not paying attention.
|
||||
|
||||

|
||||
|
||||
### G - Goal
|
||||
<img src="https://user-images.githubusercontent.com/47633984/55274622-2d6d5980-52da-11e9-8be0-ac1ef545f7d9.png" width="700"/>
|
||||
|
||||
##### G - Goal
|
||||
I want to improve on letting other people handle things that I actually want to do myself. I also want to improve my programming and am aiming to not make it a competition, but to really make it a group project. This is important, because you almost never work alone in software developing, which is what I want to do after the studies.
|
||||
|
||||
### R - Reality (Your current situation)
|
||||
##### R - Reality (Your current situation)
|
||||
I’ve already been working on my teamwork skills since high school. I had a subject that had only projects. I’ve also worked with Scrum before, which really helps you focus on your development without letting your project out of sight. I’m better at working together and listening to tips than I was before.
|
||||
|
||||
### O - Options (Look at possible options)
|
||||
##### O - Options (Look at possible options)
|
||||
Actively watching myself and letting my teammates know that they need to be clear with me if they don’t like something I say or do are the best ways for me to improve. I would rather improve by myself, but for my goals it is better to let my team guide me. It’s about teamwork after all.
|
||||
|
||||
### W - Will (Motivation, plan of action)
|
||||
##### W - Will (Motivation, plan of action)
|
||||
I’m just going to keep working on myself and hope my teammates will work with me. It also helps to work in different teams to get a much more diverse experience. Every team is different, so I’m just going to wait what this team will bring me and how I will have to adjust myself to make the team efficient.
|
||||
|
||||
# Sem van der Hoeven (4896726, semvanderhoeve)
|
||||

|
||||
### Sem van der Hoeven (4896726, semvanderhoeve)
|
||||
<img src="https://user-images.githubusercontent.com/47633984/55274658-d6b44f80-52da-11e9-9404-a4ae9a210b72.jpg" width="100"/>
|
||||
|
||||
## Personal development plan
|
||||

|
||||
#### Personal development plan
|
||||
<img src="https://user-images.githubusercontent.com/47633984/55274673-0a8f7500-52db-11e9-8d83-e1acbf22aeed.png" width="700"/>
|
||||
|
||||
### G - Goal
|
||||
##### G - Goal
|
||||
My goal with this project is most of all to be able to efficiently work with a group of people. This is important to me because I have not worked on a (development) project with a (big) group of people before. I believe I have succeeded in this goal when our project is finished and we have got a passing grade.
|
||||
|
||||
### R - Reality
|
||||
##### R - Reality
|
||||
With this project I am already setting the first step towards reaching my goal, as we have already started working as a group.
|
||||
|
||||
### O - Options
|
||||
##### O - Options
|
||||
The options I have to reach my goal are basically this project, as this is the only big project we will be doing as a team in this year. I want to obviously try to learn as much as I can during this project, especially abour working in a group. The only thing I think would be stopping this is if members of the group had different opinions on how things should be done. but so far everyone is on the same track :D.
|
||||
|
||||
### W - Will
|
||||
##### W - Will
|
||||
I am going to try my hardest to follow the rules we have set up, and to deliver everything I am supposed to. I will try to do this everytime I get the chance to do so. Right now the first step I can take is to work on this personal development plan, so that I already have my part of what we needed to do finished. My teammates can help me achieve this goal by helping if I have questions or don't understand something/am getting stuck with something.
|
||||
action plan:
|
||||
⋅⋅* finish my part of the readme that we have to finish
|
||||
@@ -77,13 +78,11 @@ action plan:
|
||||
⋅⋅* don't be hesitant on asking people for help
|
||||
⋅⋅* deliver things I need to do on time
|
||||
|
||||
# Ceren Ugurlu (4851609, cugurlu)
|
||||
### Ceren Ugurlu (4851609, cugurlu)
|
||||
<img src="https://user-images.githubusercontent.com/47633984/55274734-10398a80-52dc-11e9-9fce-5059ac2b3f3b.jpeg" width="100"/>
|
||||
|
||||

|
||||
|
||||
## Personal Development Plan:
|
||||
|
||||
- This is my core quadrant: 
|
||||
#### Personal Development Plan:
|
||||
<img src="https://user-images.githubusercontent.com/47633984/55274694-4296b800-52db-11e9-9cee-b8d1d5c58e6f.png" width="700"/>
|
||||
|
||||
My strong points:
|
||||
- I am an ambitious person in order to achieve my goal I can study a lot
|
||||
@@ -93,7 +92,7 @@ My strong points:
|
||||
My weaker points:
|
||||
- Sometimes I can be a stressed and anxious person. If we have a difficulty about time management etc. I can get stressed. But if we work efficiently as a team, I do not think this is going to be a problem
|
||||
|
||||
### G – Goal
|
||||
##### G – Goal
|
||||
My goals in this project:
|
||||
- Developing my Java skills
|
||||
- Learning how to work effectively as a team
|
||||
@@ -101,13 +100,13 @@ My goals in this project:
|
||||
|
||||
I am aiming to successfully finish the parts that belong to me in our project. To achieve this, I should develop my Java skills. I want to contribute to my group and to learn new things from my teammates. When we finish our project, I will be achieved my goal.
|
||||
|
||||
### R – Reality
|
||||
##### R – Reality
|
||||
This is my first team project. I have never experienced this before. I have done some similar programs in different languages but this is the first one in Java. This is both exciting and hard. There are many things I need to do but I like to study and develop myself.
|
||||
|
||||
### O – Options
|
||||
##### O – Options
|
||||
There are two options to achieve and not to achieve but I do not want to count the second one as an option because we are a team. And teamwork means that many different perspectives and a lot of human power. Therefore, I can say that there is not any reason for an unsuccessful result. If it happens, it is also not a problem. It shows that I need to develop myself. I would try to learn new things from my mistakes.
|
||||
|
||||
### W – Will
|
||||
##### W – Will
|
||||
I will try to do my best to be successful in our project and I am going to start right now for this. The first step I can take is creating a plan with my group mates and to start our project according to this plan.
|
||||
|
||||
Action Plan:
|
||||
@@ -117,11 +116,11 @@ Action Plan:
|
||||
- Starting to code (informing each other about the steps we have took)
|
||||
- While everyone is working on their part, to inform each other about the progress is very important because some parts can be connected. When two people's parts are connected they should act according to that otherwise it can lead problems or a non-compiling code)
|
||||
|
||||
# Mika Wauben (4834739, mlwauben)
|
||||

|
||||
### Mika Wauben (4834739, mlwauben)
|
||||
<img src="https://user-images.githubusercontent.com/47633984/55274742-29423b80-52dc-11e9-804d-69feec6d28e0.jpg" width="100"/>
|
||||
|
||||
## Personal Development Plan
|
||||

|
||||
#### Personal Development Plan
|
||||
<img src="https://user-images.githubusercontent.com/47633984/55274719-c18bf080-52db-11e9-9d3f-018ba68dd1f0.jpg" width="700"/>
|
||||
|
||||
My strong points:
|
||||
1. I am observing and think before I speak.
|
||||
@@ -131,14 +130,14 @@ Action Plan:
|
||||
1. I like to do things alone. I rather figure something out myself instead of asking for help, even if this takes way too long.
|
||||
2. I tend to stay quiet if I'm not absolutely sure my contribution is right or useful.
|
||||
|
||||
### G - Goal
|
||||
##### G - Goal
|
||||
My goal during this course is getting more experienced in working with things like github, libraries, scrumboard, etc. and asking for help if I need it, since being stuck on something isn’t going to help my groupmates.
|
||||
|
||||
### R - Reality
|
||||
##### R - Reality
|
||||
Every minute that we’re working on the project, I’m also actively working on my goal.
|
||||
|
||||
### O - Options
|
||||
##### O - Options
|
||||
By working on the project with the chosen programs, I’ll get more experienced in using them. Using those programs for other projects as well will only improve my knowledge. By being active in the groupchat and during the meetings, asking stuff will be easier.
|
||||
|
||||
### W - Will
|
||||
##### W - Will
|
||||
I will reach my goal by working actively together with my teammates using lots of the useful programs given.
|
||||
|
||||
41
build.gradle
@@ -1,9 +1,13 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url "https://plugins.gradle.org/m2/"
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE")
|
||||
classpath("org.openjfx:javafx-plugin:0.0.7")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,22 +16,22 @@ apply plugin: 'eclipse'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
apply plugin: 'jacoco'
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'application'
|
||||
|
||||
application {
|
||||
mainClassName = 'greenify.server.Application'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
//client bootjar
|
||||
|
||||
bootJar {
|
||||
baseName = 'gs-consuming-rest'
|
||||
version = '0.1.0'
|
||||
enabled = false
|
||||
}
|
||||
|
||||
//server bootjar
|
||||
bootJar {
|
||||
baseName = 'gs-rest-service'
|
||||
version = '0.1.0'
|
||||
jar {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
@@ -40,4 +44,21 @@ dependencies {
|
||||
compile("org.springframework.boot:spring-boot-starter-web")
|
||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||
testCompile("junit:junit")
|
||||
}
|
||||
compileOnly 'org.projectlombok:lombok:1.18.6'
|
||||
compile("org.springframework.boot:spring-boot-starter-data-jpa")
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.6'
|
||||
testCompile(
|
||||
'junit:junit:4.12',
|
||||
'org.junit.jupiter:junit-jupiter-api:5.4.0'
|
||||
)
|
||||
testRuntime(
|
||||
'org.junit.jupiter:junit-jupiter-engine:5.4.0',
|
||||
'org.junit.vintage:junit-vintage-engine:5.4.0'
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 861 KiB |
|
Before Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 156 KiB |
|
Before Width: | Height: | Size: 26 KiB |
@@ -29,6 +29,7 @@ Score schema + register ideas
|
||||
+ Password
|
||||
### Add activities
|
||||
+ Eating a vegetarian meal
|
||||
+ -Since different types of meat have different emission rates, I've calculated an average. On peace of meat (100 gram) costs about 150 grams of CO2. That means you save about 225 grams of CO2 by eating a vegetarian meal. (Based on an average of 150 gr meat and 150 gr CO2 per 100 gr meat.)
|
||||
+ Buying local produce
|
||||
> What did you buy? |
|
||||
> (What season is it? Calendar)
|
||||
@@ -70,3 +71,49 @@ Score schema + register ideas
|
||||
> Other things
|
||||
+ Everything perfect?
|
||||
> Happy animals
|
||||
|
||||
|
||||
|
||||
• The average passenger vehicle emits about 404 grams of CO2 per mile (+- 250 g/km)
|
||||
https://www.epa.gov/greenvehicles/greenhouse-gas-emissions-typical-passenger-vehicle
|
||||
|
||||
The study of British people’s diets was conducted by University of Oxford scientists and found that meat-rich diets - defined as more than 100g per day - resulted in 7.2kg of carbon dioxide emissions. In contrast, both vegetarian and fish-eating diets caused about 3.8kg of CO2 per day, while vegan diets produced only 2.9kg. The research analysed the food eaten by 30,000 meat eaters, 16,000 vegetarians, 8,000 fish eaters and 2,000 vegans.
|
||||
https://www.theguardian.com/environment/2014/jul/21/giving-up-beef-reduce-carbon-footprint-more-than-cars
|
||||
|
||||
Rank Food CO2 Kilos Equivalent
|
||||
1 Lamb 39.2
|
||||
2 Beef 27.0
|
||||
3 Cheese 13.5
|
||||
4 Pork 12.1
|
||||
5 Turkey 10.9
|
||||
6 Chicken 6.9
|
||||
7 Tuna 6.1
|
||||
8 Eggs 4.8
|
||||
|
||||
http://www.greeneatz.com/foods-carbon-footprint.html
|
||||
|
||||
Maybe some nice hints/tips:
|
||||
The carbon footprint of a vegetarian diet is about half that of a meat-lover’s diet. (nice tip?)
|
||||
Over 3.5 million people get sick from eating ‘dirty’ meat every year in the US.
|
||||
Vegetarians live longer than meat-eaters. Vegetarians are slimmer than meat-eaters. Vegetarians have a lower risk of getting heart disease, high blood pressure, diabetes and cancer.
|
||||
Green Fact: 70% of the deforestation of the Amazon is to provide land for cattle ranches.
|
||||
Did you know that a gas oven only uses 6% of its energy to cook? And an electric oven is not much better at 12%. If you use the oven on a warm day, you will also heat up the room and need to turn on a fan or air-conditioning. In fact, the most efficient cooking method is simmering on the stove-top.
|
||||
• eat more raw foods that do not need cooking
|
||||
• use the stove-top whenever possible
|
||||
• next best is the microwave as it uses 50% less energy than an oven
|
||||
• use the oven sparingly and smartly…reduce preheating, cook multiple foods, turn off early
|
||||
• use electric kettles to boil water for cooking or drinking.
|
||||
|
||||
http://www.greeneatz.com/foods-carbon-footprint.html
|
||||
|
||||
https://www.energuide.be/en/questions-answers/how-much-co2-does-my-home-emit/68/
|
||||
The amount of CO2 emissions resulting from such uses varies according to the quantity of energy you consume and the type of fuel used:
|
||||
• natural gas: 0.198 kg of CO2 per kWh
|
||||
• electricity: 0.23 kg of CO2 per kWh (this rate varies between countries and over time because it is calculated on the basis of the composition of the production portfolio)
|
||||
• heating oil: 0.264 kg of CO2 per kWh
|
||||
|
||||
https://ec.europa.eu/clima/sites/campaign/pdf/table_appliances_en.pdf
|
||||
VERY GOOD!
|
||||
https://www.ovoenergy.com/guides/energy-guides/how-much-heating-energy-do-you-use.html
|
||||
|
||||
|
||||
|
||||
47
doc/meetings/week5/20190311_agenda.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Meeting 3
|
||||
|
||||
## Opening
|
||||
> Check if everyone is present:
|
||||
- ~~Nivard Jansen~~
|
||||
- ~~Kristin Peneva~~
|
||||
- [x] Daan Sneep
|
||||
- [x] Merel SteenBergen
|
||||
- [x] Ceren Uğurlu
|
||||
- [x] Mika Wauben
|
||||
- [x] Sem van der Hoeven
|
||||
|
||||
-Chair: Merel Steenbergen
|
||||
-Secretary: Sem van der Hoeven
|
||||
|
||||
## Points of action
|
||||
|
||||
- First of all, discuss problems we have faced and if somebody is halted because of a problem
|
||||
- if so, try to work out the problem
|
||||
|
||||
### pre/during meeting
|
||||
- Discuss what we did last week (see scrumboard)
|
||||
- Does anyone have blocking issues?
|
||||
|
||||
- Gitlab
|
||||
- CI
|
||||
-Got branches and merge right
|
||||
-Also cleaned the repo
|
||||
-Gradle file fixed?
|
||||
-Do we finally have a name for our application?
|
||||
-Next week is all about the vegetarian meal feature. We now did all the preparations and can work on the activity
|
||||
-Kristin in README
|
||||
|
||||
### post meeting
|
||||
To be done.
|
||||
|
||||
|
||||
## Any other business
|
||||
> If anybody has something that should be discussed but came up with that after the agenda was finalized, he/she should bring that up now so that it can be discussed after all.
|
||||
|
||||
## Question round
|
||||
- Questions for the TA
|
||||
- questions that were already present
|
||||
- questions that rose during the meeting
|
||||
|
||||
## Closing
|
||||
**Let's focus on the vegetarian meal option --> No more distractions!!**
|
||||
BIN
doc/meetings/week5/20190311_notes.pdf
Normal file
53
doc/meetings/week6/20190318_agenda.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# Meeting 5
|
||||
|
||||
## Opening
|
||||
> Check if everyone is present:
|
||||
- ~~Nivard Jansen~~
|
||||
- ~~Kristin Peneva~~
|
||||
- [x] Daan Sneep
|
||||
- [x] Merel SteenBergen
|
||||
- [x] Ceren Ugurlu
|
||||
- [x] Mika Wauben
|
||||
- [x] Sem van der Hoeven
|
||||
|
||||
- Chair: Ceren Ugurlu
|
||||
- Secretary: Mika Wauben
|
||||
|
||||
## Points of action
|
||||
|
||||
- First of all, discuss problems we have faced and if somebody is halted because of a problem
|
||||
- if so, try to work out the problem
|
||||
|
||||
### pre/during meeting
|
||||
- Discuss what we did last week (see scrumboard)
|
||||
- Does anyone have blocking issues?
|
||||
- Gitlab
|
||||
- CI
|
||||
- Coverage reports
|
||||
- Checkstyle reports
|
||||
- Make sure that demo 2 is ready and all requirements is provided
|
||||
- Demo 2 (full workflow "Eating a vegetarian meal")
|
||||
- Make sure add vegetarian meal button is working
|
||||
- Make sure when user clicked to button counter is increasing
|
||||
- Make sure client sends request to the server
|
||||
- Make sure database stores and persists the data
|
||||
- Make sure coverage report is uploaded
|
||||
- Make sure checkstyle report is uploaded
|
||||
|
||||
### post meeting
|
||||
- Focus on demo 3
|
||||
- Complete the GUI
|
||||
- Add all features
|
||||
- Create a calculator
|
||||
|
||||
## Any other business
|
||||
> If anybody has something that should be discussed but came up with that after the agenda was finalized, he/she should bring that up now so that it can be discussed after all.
|
||||
|
||||
## Question round
|
||||
- Questions for the TA
|
||||
- questions that were already present
|
||||
- questions that rose during the meeting
|
||||
|
||||
## Closing
|
||||
> Demo 2 is done, good job guys!
|
||||
> Let's focus on demo 3!
|
||||
BIN
doc/meetings/week6/20190318_notes.pdf
Normal file
50
doc/meetings/week7/20190325_agenda.md
Normal file
@@ -0,0 +1,50 @@
|
||||
# Meeting 6
|
||||
|
||||
## Opening
|
||||
> Check if everyone is present:
|
||||
- ~~Nivard Jansen~~
|
||||
- ~~Kristin Peneva~~
|
||||
- ~~Daan Sneep~~
|
||||
- [x] Merel SteenBergen
|
||||
- [x] Ceren Ugurlu
|
||||
- [x] Mika Wauben
|
||||
- [x] Sem van der Hoeven
|
||||
|
||||
- Chair: Sem van der Hoeven
|
||||
- Secretary: Merel Steenbergen
|
||||
|
||||
## Points of action
|
||||
|
||||
- First of all, discuss problems we have faced and if somebody is halted because of a problem
|
||||
- if so, try to work out the problem
|
||||
|
||||
### pre/during meeting
|
||||
- Discuss what we did last week (see scrumboard)
|
||||
- Does anyone have blocking issues?
|
||||
- Gitlab
|
||||
- CI
|
||||
- Coverage reports
|
||||
- Checkstyle reports
|
||||
- Make sure that demo 3 is ready and all requirements is provided
|
||||
- Demo 3 (4 of the 6 minimal features are implemented)
|
||||
- the full workflow of 'tracking the co2 you have saved and comparing it to your friends' is implemented
|
||||
- user has an overview of the co2 they have saved
|
||||
- user has an overview of the co2 their friends have saved
|
||||
|
||||
### post meeting
|
||||
- Focus on demo 3
|
||||
- Complete the GUI
|
||||
- Add all features
|
||||
- Complete friends features
|
||||
- Create/finish the calculator
|
||||
|
||||
## Any other business
|
||||
> If anybody has something that should be discussed but came up with that after the agenda was finalized, he/she should bring that up now so that it can be discussed after all.
|
||||
|
||||
## Question round
|
||||
- Questions for the TA
|
||||
- questions that were already present
|
||||
- questions that rose during the meeting
|
||||
|
||||
## Closing
|
||||
> Let's focus on demo 3!
|
||||
BIN
doc/meetings/week7/20190325_notes.pdf
Normal file
47
doc/meetings/week8/20190401_agenda.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# Meeting 7
|
||||
|
||||
## Opening
|
||||
> Check if everyone is present:
|
||||
- ~~Nivard Jansen~~
|
||||
- ~~Kristin Peneva~~
|
||||
- ~~Daan Sneep~~
|
||||
- [x] Merel SteenBergen
|
||||
- [x] Ceren Ugurlu
|
||||
- [x] Mika Wauben
|
||||
- [x] Sem van der Hoeven
|
||||
|
||||
- Chair: Mika Wauben
|
||||
- Secretary: Ceren Ugurlu
|
||||
|
||||
## Points of action
|
||||
|
||||
- First of all, discuss problems we have faced and if somebody is halted because of a problem
|
||||
- if so, try to work out the problem
|
||||
|
||||
### pre/during meeting
|
||||
- Discuss what we did last week (see scrumboard)
|
||||
- Does anyone have blocking issues?
|
||||
- Gitlab
|
||||
- CI
|
||||
- Coverage reports
|
||||
- Checkstyle reports
|
||||
- Show demo 3 to the TA
|
||||
- Discuss about the presentation
|
||||
- Discuss about final things that need to be done
|
||||
|
||||
### post meeting
|
||||
- Focus on the presentation
|
||||
- Focus on the final report
|
||||
- Focus on things we get points for according to the rubric
|
||||
|
||||
## Any other business
|
||||
> If anybody has something that should be discussed but came up with that after the agenda was finalized, he/she should bring that up now so that it can be discussed after all.
|
||||
|
||||
## Question round
|
||||
- Questions for the TA
|
||||
- questions that were already present
|
||||
- Ask about custom CI (do we have it already?)
|
||||
- questions that rose during the meeting
|
||||
|
||||
## Closing
|
||||
> We're almost finished!
|
||||
BIN
doc/meetings/week8/20190401_notes.pdf
Normal file
43
doc/meetings/week9/20190408_agenda.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# Meeting 8
|
||||
|
||||
## Opening
|
||||
> Check if everyone is present:
|
||||
- ~~Nivard Jansen~~
|
||||
- ~~Kristin Peneva~~
|
||||
- ~~Daan Sneep~~
|
||||
- [x] Merel SteenBergen
|
||||
- [x] Ceren Ugurlu
|
||||
- [x] Mika Wauben
|
||||
- [x] Sem van der Hoeven
|
||||
|
||||
- Chair: Merel Steenbergen
|
||||
- Secretary: Sem van der Hoeven
|
||||
|
||||
## Points of action
|
||||
|
||||
- First of all, discuss problems we have faced and if somebody is halted because of a problem
|
||||
- if so, try to work out the problem
|
||||
|
||||
### pre/during meeting
|
||||
- Discuss what we did last week (see scrumboard)
|
||||
- Does anyone have blocking issues?
|
||||
- Coverage reports
|
||||
- Checkstyle reports
|
||||
- Show demo to the TA, since Mitchell isn't here, a different TA will visit us, so we'll show him the entire application.
|
||||
- Discuss about the presentation
|
||||
- Discuss about final things that need to be done
|
||||
|
||||
### post meeting
|
||||
- Focus on the presentation
|
||||
- Focus on the final report
|
||||
- Focus on things we get points for according to the rubric
|
||||
|
||||
## Any other business
|
||||
> If anybody has something that should be discussed but came up with that after the agenda was finalized, he/she should bring that up now so that it can be discussed after all.
|
||||
|
||||
## Question round
|
||||
- Questions for the TA
|
||||
- How to get the code coverage badge, since we use Gradle and we've got the Maven code.
|
||||
|
||||
## Closing
|
||||
> We're almost finished!
|
||||
BIN
doc/meetings/week9/20190408_notes.pdf
Normal file
|
Before Width: | Height: | Size: 208 KiB After Width: | Height: | Size: 208 KiB |
BIN
doc/reports/checkstyle/20190311_checkstyle.JPG
Normal file
|
After Width: | Height: | Size: 45 KiB |
BIN
doc/reports/checkstyle/20190318_checkstyle.JPG
Normal file
|
After Width: | Height: | Size: 1.9 MiB |
BIN
doc/reports/checkstyle/20190325_checkstyle.jpg
Normal file
|
After Width: | Height: | Size: 396 KiB |
BIN
doc/reports/checkstyle/20190401_checkstyle.png
Normal file
|
After Width: | Height: | Size: 257 KiB |
BIN
doc/reports/checkstyle/20190408_checkstyle.jpg
Normal file
|
After Width: | Height: | Size: 774 KiB |
BIN
doc/reports/checkstyle/20190415_checkstyle.jpg
Normal file
|
After Width: | Height: | Size: 793 KiB |
@@ -1,5 +0,0 @@
|
||||
# Checkstyle folder
|
||||
|
||||
At the end of the week, please commit a readable screenshot that shows the Checkstyle results.
|
||||
Make sure that the file follows the naming convention; `20190213_checkstyle.xyz` for February 13th.
|
||||
`.xyz` can be either `.jpg` or `.png`.
|
||||
BIN
doc/reports/coverage/20190311_coverage.jpg
Normal file
|
After Width: | Height: | Size: 87 KiB |
BIN
doc/reports/coverage/20190318_coverage.png
Normal file
|
After Width: | Height: | Size: 211 KiB |
BIN
doc/reports/coverage/20190325_coverage.png
Normal file
|
After Width: | Height: | Size: 190 KiB |
BIN
doc/reports/coverage/20190401_coverage.png
Normal file
|
After Width: | Height: | Size: 210 KiB |
BIN
doc/reports/coverage/20190408_coverage.jpg
Normal file
|
After Width: | Height: | Size: 176 KiB |
BIN
doc/reports/coverage/20190415_coverage.jpg
Normal file
|
After Width: | Height: | Size: 189 KiB |
BIN
doc/reports/final-report/20190401_draft_final_report.pdf
Normal file
BIN
doc/reports/final-report/20190411_final_report.pdf
Normal file
12
doc/reports/sprint-reviews/20190225_sprint_review.md
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
# Sprint Review
|
||||
|
||||
## Main problems Encountered
|
||||
|
||||
We have no problems so far. Everyone arrives on time and does the tasks assigned to them.
|
||||
|
||||
## Adjustments from previous sprints
|
||||
Since this is the first review, there are no previous sprints yet
|
||||
|
||||
## Adjustments for next sprint
|
||||
- Keep up the good work!
|
||||
14
doc/reports/sprint-reviews/20190311_sprint_review.md
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
# Sprint Review
|
||||
|
||||
## Main problems Encountered
|
||||
|
||||
### Problem 1: Kristin left the group
|
||||
Kristin does not continue CSE and left our group. We'll work with five people from now on.
|
||||
|
||||
## Adjustments from previous sprints
|
||||
We created the backlog before the sprint, which helps making clear what we're working on.
|
||||
|
||||
## Adjustments for next sprint
|
||||
- Group made out of five
|
||||
- Backlogs ready on time
|
||||
16
doc/reports/sprint-reviews/20190318_sprint_review.md
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
# Sprint Review
|
||||
|
||||
## Main problems Encountered
|
||||
|
||||
### Problem 1: Daan will quit CSE
|
||||
Since Daan will quit the study, we'll work with four people from now on
|
||||
|
||||
## Adjustments from previous sprints
|
||||
If we start working on the demo a bit earlier and do a little less research, we'll have
|
||||
a little less stress in the end.
|
||||
|
||||
## Adjustments for next sprint
|
||||
- Group made out of four
|
||||
- Start implemention a bit earlier
|
||||
|
||||
13
doc/reports/sprint-reviews/20190325_sprint_review.md
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
# Sprint Review
|
||||
|
||||
## Main problems Encountered
|
||||
|
||||
### Problem 1: Database won't grow
|
||||
It is difficult to add new columns to the database, but together we will fix this problem.
|
||||
|
||||
## Adjustments from previous sprints
|
||||
We're doing great with starting on time for the demo.
|
||||
|
||||
## Adjustments for next sprint
|
||||
- Speficy tasks a bit more, that way they are easier to follow
|
||||
14
doc/reports/sprint-reviews/20190401_sprint_review.md
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
# Sprint Review
|
||||
|
||||
## Main problems Encountered
|
||||
|
||||
### Problem 1: We had some bugs
|
||||
because of some bugs in the server, things did not work as intended. Ceren fixed it.
|
||||
|
||||
## Adjustments from previous sprints
|
||||
Write all we still need to do down, even if the things are not necessarily assigned to a specific person yet.
|
||||
|
||||
## Adjustments for next sprint
|
||||
- Write down all other necessary tasks.
|
||||
|
||||
14
doc/reports/sprint-reviews/20190408_sprint_review.md
Normal file
@@ -0,0 +1,14 @@
|
||||
|
||||
# Sprint Review
|
||||
|
||||
## Main problems Encountered
|
||||
|
||||
### Problem 1:
|
||||
|
||||
## Adjustments from previous sprints
|
||||
There were no big problems this week. We made some last minute changes and added some extra features. Next week we're going to focus on our other exams, so we're
|
||||
not really working on the project anymore.
|
||||
|
||||
## Adjustments for next sprint
|
||||
|
||||
|
||||
13
doc/reports/sprint-reviews/20190415_sprint_review.md
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
# Sprint Review
|
||||
|
||||
## Main problems Encountered
|
||||
|
||||
### Problem 1:
|
||||
|
||||
## Adjustments from previous sprints
|
||||
Our project is completely finished and we're very happy with the result.
|
||||
|
||||
## Adjustments for next sprint
|
||||
This is the last sprint for this project!
|
||||
|
||||
BIN
doc/sprints/sprint1/20190225_scrumboard.png
Normal file
|
After Width: | Height: | Size: 81 KiB |
BIN
doc/sprints/sprint2/20190311_scrumboard.png
Normal file
|
After Width: | Height: | Size: 88 KiB |
BIN
doc/sprints/sprint2/retrospective_sprint2.pdf
Normal file
BIN
doc/sprints/sprint3/20190318_scrumboard.png
Normal file
|
After Width: | Height: | Size: 110 KiB |
BIN
doc/sprints/sprint3/backlog_sprint3.pdf
Normal file
BIN
doc/sprints/sprint3/retrospective_sprint3.pdf
Normal file
BIN
doc/sprints/sprint4/20190325_scrumboard.png
Normal file
|
After Width: | Height: | Size: 96 KiB |
BIN
doc/sprints/sprint4/backlog_sprint4.pdf
Normal file
BIN
doc/sprints/sprint4/retrospective_sprint4.pdf
Normal file
BIN
doc/sprints/sprint5/20190401_scrumboard.png
Normal file
|
After Width: | Height: | Size: 94 KiB |
BIN
doc/sprints/sprint5/backlog_sprint5.pdf
Normal file
BIN
doc/sprints/sprint5/retrospective_sprint5.pdf
Normal file
BIN
doc/sprints/sprint6/20190408_scrumboard.png
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
doc/sprints/sprint6/backlog_sprint6.pdf
Normal file
BIN
doc/sprints/sprint6/retrospective_sprint6.pdf
Normal file
BIN
doc/sprints/sprint7/20190415_scrumboard.png
Normal file
|
After Width: | Height: | Size: 107 KiB |
BIN
doc/sprints/sprint7/backlog_sprint7.pdf
Normal file
BIN
doc/sprints/sprint7/retrospective_sprint7.pdf
Normal file
188
quality/checkstyle/checkstyle.xml
Normal file
@@ -0,0 +1,188 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
|
||||
<!--
|
||||
This configuration file was written by the eclipse-cs plugin configuration editor
|
||||
-->
|
||||
<!--
|
||||
Checkstyle-Configuration: TI1216
|
||||
Description:
|
||||
Checkstyle configurartion that checks the Google coding conventions (https://google-styleguide.googlecode.com/svn-history/r130/trunk/javaguide.html).
|
||||
-->
|
||||
<module name="Checker">
|
||||
<property name="severity" value="warning"/>
|
||||
<property name="charset" value="UTF-8"/>
|
||||
<property name="fileExtensions" value="java, properties, xml"/>
|
||||
<module name="TreeWalker">
|
||||
<module name="OuterTypeFilename"/>
|
||||
<module name="IllegalTokenText">
|
||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||
<property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
|
||||
</module>
|
||||
<module name="LineLength">
|
||||
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||
<property name="max" value="100"/>
|
||||
</module>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="OneTopLevelClass"/>
|
||||
<module name="NoLineWrap"/>
|
||||
<module name="EmptyBlock">
|
||||
<property name="option" value="TEXT"/>
|
||||
<property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, LITERAL_SWITCH"/>
|
||||
</module>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="LeftCurly"/>
|
||||
<module name="RightCurly"/>
|
||||
<module name="RightCurly">
|
||||
<property name="option" value="alone"/>
|
||||
<property name="tokens" value="CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="allowEmptyConstructors" value="true"/>
|
||||
<property name="allowEmptyMethods" value="true"/>
|
||||
<property name="allowEmptyTypes" value="true"/>
|
||||
<property name="allowEmptyLoops" value="true"/>
|
||||
<message key="ws.notPreceded" value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
||||
<message key="ws.notFollowed" value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
|
||||
</module>
|
||||
<module name="OneStatementPerLine"/>
|
||||
<module name="MultipleVariableDeclarations"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="FallThrough"/>
|
||||
<module name="ModifierOrder"/>
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="option" value="nl"/>
|
||||
<property name="tokens" value="DOT"/>
|
||||
</module>
|
||||
<module name="SeparatorWrap">
|
||||
<property name="option" value="EOL"/>
|
||||
<property name="tokens" value="COMMA"/>
|
||||
</module>
|
||||
<module name="PackageName">
|
||||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
||||
<message key="name.invalidPattern" value="Package name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="TypeName">
|
||||
<message key="name.invalidPattern" value="Type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MemberName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<message key="name.invalidPattern" value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ParameterName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<message key="name.invalidPattern" value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="LocalVariableName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||
<property name="allowOneCharVarInForLoop" value="true"/>
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<message key="name.invalidPattern" value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="ClassTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="MethodTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="InterfaceTypeParameterName">
|
||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||
<message key="name.invalidPattern" value="Interface type name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="NoFinalizer"/>
|
||||
<module name="GenericWhitespace">
|
||||
<message key="ws.notPreceded" value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||
<message key="ws.followed" value="GenericWhitespace ''{0}'' is followed by whitespace."/>
|
||||
<message key="ws.preceded" value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
|
||||
<message key="ws.illegalFollow" value="GenericWhitespace ''{0}'' should followed by whitespace."/>
|
||||
</module>
|
||||
<module name="Indentation">
|
||||
<property name="basicOffset" value="4"/>
|
||||
<property name="caseIndent" value="4"/>
|
||||
<property name="arrayInitIndent" value="4"/>
|
||||
</module>
|
||||
<module name="AbbreviationAsWordInName">
|
||||
<property name="allowedAbbreviationLength" value="1"/>
|
||||
<property name="ignoreFinal" value="false"/>
|
||||
</module>
|
||||
<module name="OverloadMethodsDeclarationOrder"/>
|
||||
<module name="VariableDeclarationUsageDistance"/>
|
||||
<module name="CustomImportOrder">
|
||||
<property name="customImportOrderRules" value="STATIC###SPECIAL_IMPORTS###THIRD_PARTY_PACKAGE###STANDARD_JAVA_PACKAGE"/>
|
||||
<property name="specialImportsRegExp" value="com.google"/>
|
||||
<property name="sortImportsInGroupAlphabetically" value="true"/>
|
||||
</module>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="OperatorWrap">
|
||||
<property name="option" value="NL"/>
|
||||
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||
</module>
|
||||
<module name="AnnotationLocation">
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
||||
</module>
|
||||
<module name="NonEmptyAtclauseDescription"/>
|
||||
<module name="JavadocTagContinuationIndentation"/>
|
||||
<module name="SummaryJavadoc">
|
||||
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
|
||||
</module>
|
||||
<module name="JavadocParagraph"/>
|
||||
<module name="AtclauseOrder">
|
||||
<property name="target" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF, VARIABLE_DEF"/>
|
||||
<property name="tagOrder" value="@param, @return, @throws, @deprecated"/>
|
||||
</module>
|
||||
<module name="JavadocMethod">
|
||||
<property name="minLineCount" value="2"/>
|
||||
<property name="allowedAnnotations" value="Override, Test"/>
|
||||
<property name="scope" value="public"/>
|
||||
<property name="allowThrowsTagsForSubclasses" value="true"/>
|
||||
<property name="allowMissingParamTags" value="true"/>
|
||||
<property name="allowMissingThrowsTags" value="true"/>
|
||||
<property name="allowMissingReturnTag" value="true"/>
|
||||
</module>
|
||||
<module name="MethodName">
|
||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||
<message key="name.invalidPattern" value="Method name ''{0}'' must match pattern ''{1}''."/>
|
||||
</module>
|
||||
<module name="SingleLineJavadoc">
|
||||
<property name="ignoreInlineTags" value="false"/>
|
||||
</module>
|
||||
<module name="EmptyCatchBlock">
|
||||
<property name="exceptionVariableName" value="expected"/>
|
||||
</module>
|
||||
<module name="CommentsIndentation"/>
|
||||
<module name="UnusedImports"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="MethodLength"/>
|
||||
<module name="ParameterNumber"/>
|
||||
<module name="MethodCount">
|
||||
<property name="maxTotal" value="50"/>
|
||||
<property name="maxPrivate" value="50"/>
|
||||
<property name="maxPackage" value="50"/>
|
||||
<property name="maxProtected" value="50"/>
|
||||
<property name="maxPublic" value="50"/>
|
||||
</module>
|
||||
<module name="AvoidNestedBlocks"/>
|
||||
<module name="DeclarationOrder"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="IllegalThrows"/>
|
||||
<module name="IllegalCatch"/>
|
||||
<module name="MissingSwitchDefault"/>
|
||||
<module name="StringLiteralEquality"/>
|
||||
<module name="UnnecessaryParentheses"/>
|
||||
<module name="CyclomaticComplexity"/>
|
||||
</module>
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
<module name="FileLength"/>
|
||||
</module>
|
||||
@@ -1 +1,5 @@
|
||||
rootProject.name = 'OOPP'
|
||||
rootProject.name = 'OOPP'
|
||||
|
||||
include ':src:Client'
|
||||
include ':src:Common'
|
||||
include ':src:Server'
|
||||
198
src/Client/.gitignore
vendored
@@ -1,198 +0,0 @@
|
||||
|
||||
# Created by https://www.gitignore.io/api/java,gradle,eclipse,intellij
|
||||
# Edit at https://www.gitignore.io/?templates=java,gradle,eclipse,intellij
|
||||
|
||||
### Eclipse ###
|
||||
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
.recommenders
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# PyDev specific (Python IDE for Eclipse)
|
||||
*.pydevproject
|
||||
|
||||
# CDT-specific (C/C++ Development Tooling)
|
||||
.cproject
|
||||
|
||||
# CDT- autotools
|
||||
.autotools
|
||||
|
||||
# Java annotation processor (APT)
|
||||
.factorypath
|
||||
|
||||
# PDT-specific (PHP Development Tools)
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# Tern plugin
|
||||
.tern-project
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
|
||||
# Code Recommenders
|
||||
.recommenders/
|
||||
|
||||
# Annotation Processing
|
||||
.apt_generated/
|
||||
|
||||
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||
.cache-main
|
||||
.scala_dependencies
|
||||
.worksheet
|
||||
|
||||
### Eclipse Patch ###
|
||||
# Eclipse Core
|
||||
.project
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# Annotation Processing
|
||||
.apt_generated
|
||||
|
||||
.sts4-cache/
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
### Intellij Patch ###
|
||||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
||||
|
||||
# *.iml
|
||||
# modules.xml
|
||||
# .idea/misc.xml
|
||||
# *.ipr
|
||||
|
||||
# Sonarlint plugin
|
||||
.idea/sonarlint
|
||||
|
||||
### Java ###
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
### Gradle ###
|
||||
.gradle
|
||||
build/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
|
||||
# gradle/wrapper/gradle-wrapper.properties
|
||||
|
||||
### Gradle Patch ###
|
||||
**/build/
|
||||
|
||||
# End of https://www.gitignore.io/api/java,gradle,eclipse,intellij
|
||||
16
src/Client/.idea/checkstyle-idea.xml
generated
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CheckStyle-IDEA">
|
||||
<option name="configuration">
|
||||
<map>
|
||||
<entry key="checkstyle-version" value="8.16" />
|
||||
<entry key="copy-libs" value="true" />
|
||||
<entry key="location-0" value="BUNDLED:(bundled):Sun Checks" />
|
||||
<entry key="location-1" value="BUNDLED:(bundled):Google Checks" />
|
||||
<entry key="scan-before-checkin" value="false" />
|
||||
<entry key="scanscope" value="JavaOnly" />
|
||||
<entry key="suppress-errors" value="false" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
9
src/Client/.idea/compiler.xml
generated
@@ -1,9 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel>
|
||||
<module name="com.bettercoding.jfx.Client.main" target="1.8" />
|
||||
<module name="com.bettercoding.jfx.Client.test" target="1.8" />
|
||||
</bytecodeTargetLevel>
|
||||
</component>
|
||||
</project>
|
||||
4
src/Client/.idea/encodings.xml
generated
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
|
||||
</project>
|
||||
7
src/Client/.idea/misc.xml
generated
@@ -1,7 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_10" project-jdk-name="10" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
10
src/Client/.idea/modules.xml
generated
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/Client.main.iml" filepath="$PROJECT_DIR$/.idea/modules/Client.main.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/Client.test.iml" filepath="$PROJECT_DIR$/.idea/modules/Client.test.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/src/main/resources.iml" filepath="$PROJECT_DIR$/src/main/resources.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
2
src/Client/.idea/modules/Client.iml
generated
@@ -1,2 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="Client" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4" />
|
||||
48
src/Client/.idea/modules/Client.main.iml
generated
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="Client:main" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/../../out/production/classes" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/../../src/main">
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../src/main/java" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter-web:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter-json:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter-tomcat:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.hibernate.validator:hibernate-validator:6.0.12.Final" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-webmvc:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-web:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-autoconfigure:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter-logging:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: javax.annotation:javax.annotation-api:1.3.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-context:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-aop:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-beans:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-expression:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-core:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.6" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.yaml:snakeyaml:1.19" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-databind:2.9.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.34" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.tomcat.embed:tomcat-embed-core:8.5.34" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.tomcat.embed:tomcat-embed-el:8.5.34" level="project" />
|
||||
<orderEntry type="library" name="Gradle: javax.validation:validation-api:2.0.1.Final" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml:classmate:1.3.4" level="project" />
|
||||
<orderEntry type="library" name="Gradle: ch.qos.logback:logback-classic:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.logging.log4j:log4j-to-slf4j:2.10.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.slf4j:jul-to-slf4j:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-jcl:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-core:2.9.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: ch.qos.logback:logback-core:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.logging.log4j:log4j-api:2.10.0" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
75
src/Client/.idea/modules/Client.test.iml
generated
@@ -1,75 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module external.linked.project.id="Client:test" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="GRADLE" external.system.module.group="" external.system.module.type="sourceSet" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output-test url="file://$MODULE_DIR$/../../out/test/classes" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$/../../src/test">
|
||||
<sourceFolder url="file://$MODULE_DIR$/../../src/test/java" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="Client.main" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter-web:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter-test:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: junit:junit:4.12" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.junit.jupiter:junit-jupiter-api:5.4.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter-json:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.junit.vintage:junit-vintage-engine:5.4.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter-tomcat:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.junit.jupiter:junit-jupiter-engine:5.4.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.hibernate.validator:hibernate-validator:6.0.12.Final" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-webmvc:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-web:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-test-autoconfigure:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-test:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.jayway.jsonpath:json-path:2.4.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.assertj:assertj-core:3.9.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.mockito:mockito-core:2.15.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-library:1.3" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.skyscreamer:jsonassert:1.5.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-test:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-autoconfigure:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-context:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-expression:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-aop:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-beans:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-core:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.xmlunit:xmlunit-core:2.5.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.junit.platform:junit-platform-commons:1.4.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apiguardian:apiguardian-api:1.0.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.opentest4j:opentest4j:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework.boot:spring-boot-starter-logging:2.0.5.RELEASE" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.junit.platform:junit-platform-engine:1.4.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: javax.annotation:javax.annotation-api:1.3.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-databind:2.9.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.tomcat.embed:tomcat-embed-websocket:8.5.34" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.tomcat.embed:tomcat-embed-core:8.5.34" level="project" />
|
||||
<orderEntry type="library" scope="RUNTIME" name="Gradle: org.yaml:snakeyaml:1.19" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.tomcat.embed:tomcat-embed-el:8.5.34" level="project" />
|
||||
<orderEntry type="library" name="Gradle: javax.validation:validation-api:2.0.1.Final" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml:classmate:1.3.4" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.minidev:json-smart:2.3" level="project" />
|
||||
<orderEntry type="library" name="Gradle: ch.qos.logback:logback-classic:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.logging.log4j:log4j-to-slf4j:2.10.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.slf4j:jul-to-slf4j:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.bytebuddy:byte-buddy:1.7.11" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.bytebuddy:byte-buddy-agent:1.7.11" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.objenesis:objenesis:2.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.vaadin.external.google:android-json:0.0.20131108.vaadin1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.springframework:spring-jcl:5.0.9.RELEASE" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-core:2.9.6" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.minidev:accessors-smart:1.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: ch.qos.logback:logback-core:1.2.3" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.logging.log4j:log4j-api:2.10.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.ow2.asm:asm:5.0.4" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
6
src/Client/.idea/vcs.xml
generated
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -13,22 +13,67 @@ apply plugin: 'idea'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
apply plugin: 'jacoco'
|
||||
apply plugin: 'checkstyle'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
def configDir = "${project.rootDir}/quality"
|
||||
|
||||
checkstyle {
|
||||
toolVersion '7.8.1'
|
||||
configFile file("$configDir/checkstyle/checkstyle.xml")
|
||||
configProperties.checkstyleSuppressionsPath = file("$configDir/checkstyle/suppressions.xml").absolutePath
|
||||
}
|
||||
|
||||
checkstyleMain {
|
||||
source ='src/main/java'
|
||||
}
|
||||
|
||||
checkstyleTest {
|
||||
source ='src/test/java'
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
bootJar {
|
||||
baseName = 'gs-consuming-rest'
|
||||
version = '0.1.0'
|
||||
baseName = 'greenify'
|
||||
version = '1.0.0'
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
||||
dependencies {
|
||||
compile "org.bouncycastle:bcprov-jdk16:1.46", "org.bouncycastle:bcpg-jdk16:1.46", "org.bouncycastle:bcmail-jdk16:1.46", "org.bouncycastle:bctsp-jdk16:1.46"
|
||||
compile("org.springframework.boot:spring-boot-starter")
|
||||
compile("org.springframework:spring-web")
|
||||
compile("com.fasterxml.jackson.core:jackson-databind")
|
||||
testCompile("junit:junit")
|
||||
compile project(':src:Common')
|
||||
testCompile('org.springframework.boot:spring-boot-starter-test')
|
||||
testCompile(
|
||||
'junit:junit:4.12',
|
||||
'org.junit.jupiter:junit-jupiter-api:5.4.0'
|
||||
)
|
||||
testRuntime(
|
||||
'org.junit.jupiter:junit-jupiter-engine:5.4.0',
|
||||
'org.junit.vintage:junit-vintage-engine:5.4.0'
|
||||
)
|
||||
}
|
||||
|
||||
jacoco {
|
||||
toolVersion = "0.8.3"
|
||||
reportsDir = file("$buildDir/customJacocoReportDir")
|
||||
}
|
||||
|
||||
jacocoTestReport {
|
||||
reports {
|
||||
xml.enabled false
|
||||
csv.enabled false
|
||||
html.destination file("${buildDir}/jacocoHtml")
|
||||
}
|
||||
}
|
||||
70
src/Client/src/main/java/greenify/client/Application.java
Normal file
@@ -0,0 +1,70 @@
|
||||
package greenify.client;
|
||||
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
public class Application extends javafx.application.Application {
|
||||
private static ConfigurableApplicationContext springContext;
|
||||
|
||||
/**
|
||||
* This (main) method starts launch.
|
||||
* @param args the arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method takes an url and return a parent.
|
||||
* @param url which is being loaded.
|
||||
* @return parent object.
|
||||
*/
|
||||
public static Parent load(java.net.URL url) throws IOException {
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
loader.setControllerFactory(springContext::getBean);
|
||||
loader.setLocation(url);
|
||||
return loader.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method initializes the application.
|
||||
*/
|
||||
@Override
|
||||
public void init() {
|
||||
springContext = SpringApplication.run(Application.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method opens the login window.
|
||||
* @param primaryStage the login window
|
||||
* @throws Exception in case fxml file is not found
|
||||
*/
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws Exception {
|
||||
Parent rootNode = load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/LoginWindow.fxml"));
|
||||
primaryStage.setTitle("Greenify");
|
||||
Scene scene = new Scene(rootNode);
|
||||
scene.getStylesheets().add(getClass().getClassLoader().getResource(
|
||||
"stylesheets/LoginWindowStyle.css").toExternalForm());
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method stops the application.
|
||||
*/
|
||||
@Override
|
||||
public void stop() {
|
||||
springContext.stop();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,533 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import greenify.client.Application;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import javafx.util.Duration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
@Controller
|
||||
public class CalculatorController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Autowired
|
||||
DashBoardController controller;
|
||||
|
||||
@Autowired
|
||||
ExtraActivityController extraActivityController;
|
||||
|
||||
//navigation panes
|
||||
@FXML
|
||||
private AnchorPane getStartedPane;
|
||||
@FXML
|
||||
private AnchorPane travelPane;
|
||||
@FXML
|
||||
private AnchorPane homePane;
|
||||
@FXML
|
||||
private ScrollPane foodPane;
|
||||
@FXML
|
||||
private AnchorPane shoppingPane;
|
||||
|
||||
//'get started' pane
|
||||
@FXML
|
||||
private Slider peopleInHouseholdSlider;
|
||||
@FXML
|
||||
private Label peopleInHouseHoldLabel;
|
||||
@FXML
|
||||
private Slider annualIncomeSlider;
|
||||
@FXML
|
||||
private Label annualIncomeLabel;
|
||||
@FXML
|
||||
private Button saveButton;
|
||||
|
||||
//travel pane
|
||||
@FXML
|
||||
private TextField publicTransitField;
|
||||
@FXML
|
||||
private TextField airplaneTravelField;
|
||||
@FXML
|
||||
private TextField carTravelGasolineField;
|
||||
@FXML
|
||||
private Slider carTravelGasolineSlider;
|
||||
@FXML
|
||||
private Label carTravelGasolineLabel;
|
||||
@FXML
|
||||
private TextField carTravelDieselField;
|
||||
@FXML
|
||||
private Slider carTravelDieselSlider;
|
||||
@FXML
|
||||
private Label carTravelDieselLabel;
|
||||
@FXML
|
||||
private TextField carTravelElectricField;
|
||||
@FXML
|
||||
private Slider carTravelElectricSlider;
|
||||
@FXML
|
||||
private Label carTravelElectricLabel;
|
||||
|
||||
//home pane
|
||||
@FXML
|
||||
private TextField electricityField;
|
||||
@FXML
|
||||
private Slider cleanEnergyPurchasedSlider;
|
||||
@FXML
|
||||
private Label cleanEnergyPurchasedLabel;
|
||||
@FXML
|
||||
private TextField naturalGasField;
|
||||
@FXML
|
||||
private TextField heatingOilField;
|
||||
@FXML
|
||||
private TextField livingSpaceField;
|
||||
@FXML
|
||||
private Slider waterUsageSlider;
|
||||
@FXML
|
||||
private Label waterUsageLabel;
|
||||
|
||||
//food pane
|
||||
@FXML
|
||||
private Slider meatFishEggsSlider;
|
||||
@FXML
|
||||
private Label meatFishEggsLabel;
|
||||
@FXML
|
||||
private Slider grainsBakedGoodsSlider;
|
||||
@FXML
|
||||
private Label grainsBakedGoodsLabel;
|
||||
@FXML
|
||||
private Slider dairySlider;
|
||||
@FXML
|
||||
private Label dairyLabel;
|
||||
@FXML
|
||||
private Slider fruitsVegetablesSlider;
|
||||
@FXML
|
||||
private Label fruitsVegetablesLabel;
|
||||
@FXML
|
||||
private Slider snacksDrinksSlider;
|
||||
@FXML
|
||||
private Label snacksDrinksLabel;
|
||||
|
||||
//shopping pane
|
||||
@FXML
|
||||
private Text goodsField;
|
||||
@FXML
|
||||
private Text servicesField;
|
||||
@FXML
|
||||
private Slider goodsSlider;
|
||||
@FXML
|
||||
private Label goodsLabel;
|
||||
@FXML
|
||||
private Slider servicesSlider;
|
||||
@FXML
|
||||
private Label servicesLabel;
|
||||
|
||||
//extra pane
|
||||
@FXML
|
||||
private AnchorPane extraPane;
|
||||
|
||||
/**
|
||||
* initializes the window, performs some actions before loading all other things.
|
||||
* it sets the sliders to snap to the ticks.
|
||||
* it adds listeners to all the sliders for updating the label they are associated with.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void initialize() {
|
||||
peopleInHouseholdSlider.setSnapToTicks(true);
|
||||
//add listener to slider for amount of people in household
|
||||
peopleInHouseholdSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
peopleInHouseHoldLabel.setText("" + newValue.intValue());
|
||||
}
|
||||
});
|
||||
|
||||
//add listener to slider for annual income
|
||||
annualIncomeSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
annualIncomeLabel.setText("" + (newValue.intValue() * 1000));
|
||||
}
|
||||
});
|
||||
|
||||
addSliderListenerCarUsage(carTravelGasolineSlider, carTravelGasolineLabel, " km/L");
|
||||
addSliderListenerCarUsage(carTravelDieselSlider, carTravelDieselLabel, " km/L");
|
||||
addSliderListenerCarUsage(carTravelElectricSlider, carTravelElectricLabel, " km/Le");
|
||||
|
||||
cleanEnergyPurchasedSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
cleanEnergyPurchasedLabel.setText(newValue.intValue() + " %");
|
||||
}
|
||||
});
|
||||
|
||||
waterUsageSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
waterUsageLabel.setText(newValue.intValue() + "% of similar households");
|
||||
}
|
||||
});
|
||||
|
||||
addSliderListenerDailyServing(meatFishEggsSlider, meatFishEggsLabel);
|
||||
addSliderListenerDailyServing(grainsBakedGoodsSlider, grainsBakedGoodsLabel);
|
||||
addSliderListenerDailyServing(dairySlider, dairyLabel);
|
||||
addSliderListenerDailyServing(fruitsVegetablesSlider, fruitsVegetablesLabel);
|
||||
addSliderListenerDailyServing(snacksDrinksSlider, snacksDrinksLabel);
|
||||
|
||||
addSliderListenerGoodsServices(goodsSlider, goodsLabel);
|
||||
addSliderListenerGoodsServices(servicesSlider, servicesLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* adds the listener to the given slider and displays it's output on a given label.
|
||||
* @param slider the slider to attach the listener to.
|
||||
* @param label the label to display the slider output on.
|
||||
*/
|
||||
private void addSliderListenerCarUsage(Slider slider, Label label, String unit) {
|
||||
slider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
label.setText(newValue.intValue() + unit);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
private void addSliderListenerDailyServing(Slider slider, Label label) {
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
slider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
label.setText(df.format(newValue.doubleValue()) + " daily servings per person");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addSliderListenerGoodsServices(Slider slider, Label label) {
|
||||
slider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
label.setText(newValue.intValue() + "€ / month");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a fade transition to the given node.
|
||||
* @param node the node to add the transition to
|
||||
*/
|
||||
public void addFadeTransAnimation(Node node) {
|
||||
FadeTransition fade = new FadeTransition(Duration.millis(350), node);
|
||||
fade.setFromValue(0);
|
||||
fade.setToValue(1.0);
|
||||
TranslateTransition trans = new TranslateTransition(Duration.millis(350), node);
|
||||
trans.setFromY(800);
|
||||
trans.setToY(0);
|
||||
ParallelTransition par = new ParallelTransition();
|
||||
par.setNode(travelPane);
|
||||
par.getChildren().addAll(fade, trans);
|
||||
par.play();
|
||||
}
|
||||
|
||||
private void addSlideInAnimation(Node node) {
|
||||
Timeline timeline = new Timeline();
|
||||
KeyValue keyValue = new KeyValue(node.translateXProperty(), 0, Interpolator.EASE_OUT);
|
||||
KeyFrame keyFrame = new KeyFrame(Duration.millis(600), keyValue);
|
||||
timeline.getKeyFrames().add(keyFrame);
|
||||
timeline.play();
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'get started' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayGetStarted(ActionEvent event) {
|
||||
addFadeTransAnimation(getStartedPane);
|
||||
getStartedPane.setVisible(true);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
extraPane.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'travel' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayTravel(ActionEvent event) {
|
||||
addFadeTransAnimation(travelPane);
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(true);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
extraPane.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'home' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayHome(ActionEvent event) {
|
||||
addFadeTransAnimation(homePane);
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(true);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
extraPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'food' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayFood(ActionEvent event) {
|
||||
addFadeTransAnimation(foodPane);
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(true);
|
||||
shoppingPane.setVisible(false);
|
||||
extraPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'shopping' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayShopping(ActionEvent event) {
|
||||
addFadeTransAnimation(shoppingPane);
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(true);
|
||||
extraPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'Extra' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayExtra(ActionEvent event) throws IOException {
|
||||
addFadeTransAnimation(extraPane);
|
||||
extraPane.getChildren().setAll((Node) Application.load(this.getClass()
|
||||
.getClassLoader().getResource("fxml/extraActivities.fxml")));
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
extraPane.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* The method saves the calculation.
|
||||
* @param event user clicks to button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void saveCalc(ActionEvent event) throws InterruptedException {
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
if (!annualIncomeLabel.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(), "input_income",
|
||||
annualIncomeLabel.getText());
|
||||
}
|
||||
if (!peopleInHouseHoldLabel.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(), "input_size",
|
||||
peopleInHouseHoldLabel.getText());
|
||||
}
|
||||
checkTransportLabels();
|
||||
checkHousingLabels();
|
||||
checkFoodLabels();
|
||||
if (!goodsLabel.getText().replace(" € / month", "").equals("1520")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_goods_total",
|
||||
goodsLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
if (!servicesLabel.getText().replace(" € / month", "").equals("3428")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_services_total",
|
||||
servicesLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
try {
|
||||
extraActivityController.updateExtras();
|
||||
} catch (NullPointerException ex) {
|
||||
System.out.println("continue");
|
||||
}
|
||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||
Window owner = saveButton.getScene().getWindow();
|
||||
controller.updateLeaderboard();
|
||||
controller.updateAchievements();
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION,
|
||||
owner, "Footprint saved!", "Your footprint is saved!");
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the food labels.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
private void checkFoodLabels() {
|
||||
if (!meatFishEggsLabel.getText().replace(" daily servings per person", "").equals("2.6")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_meatfisheggs",
|
||||
meatFishEggsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!grainsBakedGoodsLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("4.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_cereals",
|
||||
grainsBakedGoodsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!dairyLabel.getText().replace(" daily servings per person", "").equals("2.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_dairy",
|
||||
dairyLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!fruitsVegetablesLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("3.9")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_fruitvegetables",
|
||||
fruitsVegetablesLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!snacksDrinksLabel.getText().replace(" daily servings per person", "").equals("3.7")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_otherfood",
|
||||
snacksDrinksLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the house labels.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
private void checkHousingLabels() {
|
||||
if (!electricityField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_electricity_dollars",
|
||||
electricityField.getText());
|
||||
}
|
||||
if (!cleanEnergyPurchasedLabel.getText().replace(" %", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_gco2_per_kwh",
|
||||
cleanEnergyPurchasedLabel.getText().replace(" %", ""));
|
||||
}
|
||||
if (!naturalGasField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_naturalgas_dollars",
|
||||
naturalGasField.getText());
|
||||
}
|
||||
if (!heatingOilField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_heatingoil_dollars",
|
||||
heatingOilField.getText());
|
||||
}
|
||||
if (!livingSpaceField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_squarefeet",
|
||||
livingSpaceField.getText());
|
||||
}
|
||||
if (!waterUsageLabel.getText().replace("% of similar households", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_watersewage",
|
||||
waterUsageLabel.getText().replace("% of similar households", ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the transport labels.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
private void checkTransportLabels() {
|
||||
if (!publicTransitField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_publictrans",
|
||||
publicTransitField.getText());
|
||||
}
|
||||
if (!airplaneTravelField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_airtotal",
|
||||
airplaneTravelField.getText());
|
||||
}
|
||||
if (!carTravelGasolineField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_miles1",
|
||||
carTravelGasolineField.getText());
|
||||
}
|
||||
if (!carTravelGasolineLabel.getText().replace(" km/L", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_mpg1",
|
||||
carTravelGasolineLabel.getText().replace(" km/L", ""));
|
||||
}
|
||||
if (!carTravelDieselField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_miles2",
|
||||
carTravelDieselField.getText());
|
||||
}
|
||||
if (!carTravelDieselLabel.getText().replace(" km/L", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_mpg2",
|
||||
carTravelDieselLabel.getText().replace(" km/L", ""));
|
||||
}
|
||||
if (!carTravelElectricField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_miles3",
|
||||
carTravelElectricField.getText());
|
||||
}
|
||||
if (!carTravelElectricLabel.getText().replace(" km/Le", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_mpg3",
|
||||
carTravelElectricLabel.getText().replace(" km/Le", ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,804 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||
import greenify.client.Application;
|
||||
import greenify.client.features.Friend;
|
||||
import greenify.client.features.Hints;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.PathTransition;
|
||||
import javafx.animation.ScaleTransition;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.chart.PieChart;
|
||||
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.scene.control.TableView;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.control.cell.PropertyValueFactory;
|
||||
import javafx.scene.effect.ColorAdjust;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.shape.Line;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import javafx.util.Duration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Class that controls the dashboard fxml file (the GUI Screen).
|
||||
*/
|
||||
@Controller
|
||||
public class DashBoardController {
|
||||
public static ObservableList<Friend> data = FXCollections.observableArrayList();
|
||||
public ObservableList<Friend> friendLeaderData = FXCollections.observableArrayList();
|
||||
public ObservableList<Friend> globalLeaderData = FXCollections.observableArrayList();
|
||||
public ObservableList<Friend> developmentData = FXCollections.observableArrayList();
|
||||
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
Hints hints = new Hints();
|
||||
|
||||
private FadeTransition fadeTrans; //transition for switching between the different panels
|
||||
|
||||
@FXML
|
||||
private AnchorPane dashboardPane;
|
||||
@FXML
|
||||
private AnchorPane userPane;
|
||||
@FXML
|
||||
private AnchorPane activitiesPane;
|
||||
@FXML
|
||||
private AnchorPane friendsPane;
|
||||
@FXML
|
||||
private Label welcomebacktext;
|
||||
@FXML
|
||||
private Button dashboardButton;
|
||||
@FXML
|
||||
private Button activitiesButton;
|
||||
@FXML
|
||||
private Button userButton;
|
||||
@FXML
|
||||
private Button friendsButton;
|
||||
@FXML
|
||||
private Button logOutButton;
|
||||
@FXML
|
||||
private Line pathLine;
|
||||
@FXML
|
||||
private AnchorPane menuBar;
|
||||
@FXML
|
||||
private Button calculateFootPrintButton;
|
||||
@FXML
|
||||
private Label footprintLabel;
|
||||
@FXML
|
||||
private Label firstFootprintLabel;
|
||||
@FXML
|
||||
private Label differenceLabel;
|
||||
@FXML
|
||||
private Button addFriendButton;
|
||||
@FXML
|
||||
private Button addFriend;
|
||||
@FXML
|
||||
private Button removeFriend;
|
||||
@FXML
|
||||
private Button addExtraActivityButton;
|
||||
@FXML
|
||||
private Button addExtraActivityButton2;
|
||||
@FXML
|
||||
private TableView<Friend> friendsTable;
|
||||
@FXML
|
||||
private TableColumn<Friend, String> friendsColumn;
|
||||
@FXML
|
||||
private TableColumn<Friend, Float> scoreColumn;
|
||||
@FXML
|
||||
private TableView<Friend> globalLeaderboard;
|
||||
@FXML
|
||||
private TableColumn<Friend, Integer> globalPlace;
|
||||
@FXML
|
||||
private TableColumn<Friend, String> globalUser;
|
||||
@FXML
|
||||
private TableColumn<Friend, Float> globalScore;
|
||||
@FXML
|
||||
private TableView<Friend> developmentLeaderboard;
|
||||
@FXML
|
||||
private TableColumn<Friend, Integer> developmentPlace;
|
||||
@FXML
|
||||
private TableColumn<Friend, String> developmentUser;
|
||||
@FXML
|
||||
private TableColumn<Friend, Float> developmentScore;
|
||||
@FXML
|
||||
private TableView<Friend> friendLeaderboard;
|
||||
@FXML
|
||||
private TableColumn<Friend, Integer> friendPlace;
|
||||
@FXML
|
||||
private TableColumn<Friend, String> friendUser;
|
||||
@FXML
|
||||
private TableColumn<Friend, Float> friendScore;
|
||||
@FXML
|
||||
private PieChart pieChart;
|
||||
@FXML
|
||||
private Label usernameLabel;
|
||||
@FXML
|
||||
private Label peopleNumber;
|
||||
@FXML
|
||||
private Label income;
|
||||
@FXML
|
||||
private Label electricityUsage;
|
||||
@FXML
|
||||
private Label cleanEnergy;
|
||||
@FXML
|
||||
private Label naturalGasUsage;
|
||||
@FXML
|
||||
private Label heatingOilUsage;
|
||||
@FXML
|
||||
private Label waterUsage;
|
||||
@FXML
|
||||
private Label livingSpace;
|
||||
@FXML
|
||||
private Label gasolineMiles;
|
||||
@FXML
|
||||
private Label gasolineMpg;
|
||||
@FXML
|
||||
private Label dieselMiles;
|
||||
@FXML
|
||||
private Label dieselMpg;
|
||||
@FXML
|
||||
private Label electricMiles;
|
||||
@FXML
|
||||
private Label electricMpg;
|
||||
@FXML
|
||||
private Label publicTransportation;
|
||||
@FXML
|
||||
private Label airPlane;
|
||||
@FXML
|
||||
private Label goodShopping;
|
||||
@FXML
|
||||
private Label serviceShopping;
|
||||
@FXML
|
||||
private Label meat;
|
||||
@FXML
|
||||
private Label grains;
|
||||
@FXML
|
||||
private Label dairy;
|
||||
@FXML
|
||||
private Label fruits;
|
||||
@FXML
|
||||
private Label snacks;
|
||||
@FXML
|
||||
private ImageView achieve1;
|
||||
@FXML
|
||||
private ImageView achieve2;
|
||||
@FXML
|
||||
private ImageView achieve3;
|
||||
@FXML
|
||||
private ImageView achieve4;
|
||||
@FXML
|
||||
private ImageView achieve5;
|
||||
@FXML
|
||||
private ImageView achieve6;
|
||||
@FXML
|
||||
private Label hintText;
|
||||
@FXML
|
||||
private Label veganMeal;
|
||||
@FXML
|
||||
private Label localProduce;
|
||||
@FXML
|
||||
private Label bike;
|
||||
@FXML
|
||||
private Label publicTrans;
|
||||
@FXML
|
||||
private Label loweringTemp;
|
||||
@FXML
|
||||
private Label solarPanels;
|
||||
@FXML
|
||||
private Button achiev1Tip;
|
||||
@FXML
|
||||
private Button achiev2Tip;
|
||||
@FXML
|
||||
private Button achiev3Tip;
|
||||
@FXML
|
||||
private Button achiev4Tip;
|
||||
@FXML
|
||||
private Button achiev5Tip;
|
||||
@FXML
|
||||
private Button achiev6Tip;
|
||||
|
||||
/**
|
||||
* Loads the the necessary things before anything else.
|
||||
* @throws InterruptedException exception if interrupted
|
||||
*/
|
||||
public void initialize() throws InterruptedException {
|
||||
|
||||
|
||||
hintText.setWrapText(true);
|
||||
hintText.setText(hints.randomHint());
|
||||
//set the dashboardPane to visible
|
||||
dashboardPane.setVisible(true);
|
||||
userPane.setVisible(false);
|
||||
activitiesPane.setVisible(false);
|
||||
friendsPane.setVisible(false);
|
||||
//sets the text of the 'welcome back' text to include the username
|
||||
welcomebacktext.setText("Welcome back, " + userService.currentUser.getName() + "!");
|
||||
//adds the slide transition to the menu bar
|
||||
addSlideTransition(menuBar, pathLine);
|
||||
//adds animations to the navigation buttons
|
||||
dashboardButton.setSkin(new MyButtonSkin(dashboardButton));
|
||||
activitiesButton.setSkin(new MyButtonSkin(activitiesButton));
|
||||
userButton.setSkin(new MyButtonSkin(userButton));
|
||||
friendsButton.setSkin(new MyButtonSkin(friendsButton));
|
||||
logOutButton.setSkin(new MyButtonSkin(logOutButton));
|
||||
friendsColumn.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||
scoreColumn.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||
globalPlace.setCellValueFactory(new PropertyValueFactory<>("Place"));
|
||||
globalUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||
globalScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||
developmentUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||
developmentPlace.setCellValueFactory(new PropertyValueFactory<>("Place"));
|
||||
developmentScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||
friendPlace.setCellValueFactory(new PropertyValueFactory<>("Place"));
|
||||
friendUser.setCellValueFactory(new PropertyValueFactory<>("Friend"));
|
||||
friendScore.setCellValueFactory(new PropertyValueFactory<>("Score"));
|
||||
List<String> friendList = userService.getFriendNames(userService.currentUser.getName());
|
||||
for (int i = 0; i < friendList.size(); i++) {
|
||||
Friend friend = new Friend(i, friendList.get(i),
|
||||
userService.getFootprint(friendList.get(i)));
|
||||
data.add(friend);
|
||||
}
|
||||
friendsTable.setItems(data);
|
||||
updateLeaderboard();
|
||||
updateAchievements();
|
||||
updatePiechart();
|
||||
calculateFootPrintButton.setSkin(new ClickButtonSkin(calculateFootPrintButton));
|
||||
addFriendButton.setSkin(new ClickButtonSkin(addFriendButton));
|
||||
addExtraActivityButton.setSkin(new ClickButtonSkin(addExtraActivityButton));
|
||||
addExtraActivityButton2.setSkin(new ClickButtonSkin(addExtraActivityButton2));
|
||||
addFriend.setSkin(new ClickButtonSkin(addFriend));
|
||||
removeFriend.setSkin(new ClickButtonSkin(removeFriend));
|
||||
addRandomHints();
|
||||
|
||||
Tooltip tooltip = new Tooltip("tip");
|
||||
hackTooltipStartTiming(tooltip);
|
||||
|
||||
addToolTip(achiev1Tip, "Starting off \n You did your first green activity!");
|
||||
addToolTip(achiev2Tip, "Social Butterfly \n You added three friends");
|
||||
addToolTip(achiev3Tip, "Green Saver \n You saved 20 tonnes of CO2");
|
||||
addToolTip(achiev4Tip, "Animal Friend \n You have eaten 10 vegetarian meals");
|
||||
addToolTip(achiev5Tip, "Tom Dumoulin \n You have biked 15 km");
|
||||
addToolTip(achiev6Tip, "Let it shine \n You installed solar panels");
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a tooltip to the button.
|
||||
* @param button the button to add the tooltip to.
|
||||
* @param message the message to be displayed in the tooltip.
|
||||
*/
|
||||
private void addToolTip(Button button, String message) {
|
||||
button.setTooltip(new Tooltip(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* changes the delay time between hovering over something with a tooltip and when the
|
||||
* tooltip is displayed.
|
||||
* @param tooltip the tooltip to change the delay of
|
||||
*/
|
||||
private static void hackTooltipStartTiming(Tooltip tooltip) {
|
||||
|
||||
try {
|
||||
Field fieldBehavior = tooltip.getClass().getDeclaredField("BEHAVIOR");
|
||||
fieldBehavior.setAccessible(true);
|
||||
Object objBehavior = fieldBehavior.get(tooltip);
|
||||
|
||||
Field fieldTimer = objBehavior.getClass().getDeclaredField("activationTimer");
|
||||
fieldTimer.setAccessible(true);
|
||||
Timeline objTimer = (Timeline) fieldTimer.get(objBehavior);
|
||||
|
||||
objTimer.getKeyFrames().clear();
|
||||
objTimer.getKeyFrames().add(new KeyFrame(new Duration(150)));
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
e.getMessage();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.getMessage();
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the scores of users.
|
||||
* @param users the list of users
|
||||
*/
|
||||
public void sortScores(List<String> users) throws InterruptedException {
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
for (int j = 0; j < users.size(); j++) {
|
||||
Double first = userService.getFootprint(users.get(i));
|
||||
Double second = userService.getFootprint(users.get(j));
|
||||
if (i < j && (first.compareTo(second) < 0)) {
|
||||
String temp = users.get(i);
|
||||
users.set(i, users.get(j));
|
||||
users.set(j, temp);
|
||||
}
|
||||
if (i > j && (first.compareTo(second) > 0)) {
|
||||
String temp = users.get(i);
|
||||
users.set(i, users.get(j));
|
||||
users.set(j, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sorts the scores of users.
|
||||
* @param users the list of users
|
||||
*/
|
||||
public List<String> sortDiffScores(List<String> users) throws InterruptedException {
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
for (int j = 0; j < users.size(); j++) {
|
||||
Double firstDiff = userService.getFirstFootprint(users.get(i)) - userService
|
||||
.getFootprint(users.get(i));
|
||||
Double secondDiff = userService.getFirstFootprint(users.get(j)) - userService
|
||||
.getFootprint(users.get(j));
|
||||
if (i < j && firstDiff < secondDiff) {
|
||||
String temp = users.get(i);
|
||||
users.set(i, users.get(j));
|
||||
users.set(j, temp);
|
||||
}
|
||||
if (i > j && firstDiff > secondDiff) {
|
||||
String temp = users.get(i);
|
||||
users.set(i, users.get(j));
|
||||
users.set(j, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a fade transition for switching between the different panes.
|
||||
* @param node the node on which the transition needs to act
|
||||
*/
|
||||
public void addFadeTransition(Node node) {
|
||||
fadeTrans = new FadeTransition(Duration.millis(400), node);
|
||||
fadeTrans.setFromValue(0);
|
||||
fadeTrans.setToValue(1.0);
|
||||
fadeTrans.play();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Displays the dashboard pane.
|
||||
* @param event the event (clicking the button)
|
||||
*/
|
||||
public void displayDashboard(ActionEvent event) throws InterruptedException {
|
||||
addFadeTransition(dashboardPane);
|
||||
System.out.println("display dashboard");
|
||||
dashboardPane.setVisible(true);
|
||||
userPane.setVisible(false);
|
||||
activitiesPane.setVisible(false);
|
||||
friendsPane.setVisible(false);
|
||||
updateLeaderboard();
|
||||
updateAchievements();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the activities pane.
|
||||
* @param event the event (clicking the button)
|
||||
*/
|
||||
public void displayActivities(ActionEvent event) {
|
||||
addFadeTransition(activitiesPane);
|
||||
System.out.println("display activities");
|
||||
dashboardPane.setVisible(false);
|
||||
userPane.setVisible(false);
|
||||
activitiesPane.setVisible(true);
|
||||
friendsPane.setVisible(false);
|
||||
Map<String, String> inputMap = userService.getInputs(userService.currentUser.getName());
|
||||
peopleNumber.setText(inputMap.get("input_size"));
|
||||
income.setText(inputMap.get("input_income") + " €/yr");
|
||||
electricityUsage.setText(inputMap.get("input_footprint_housing_electricity_dollars")
|
||||
+ " €/yr");
|
||||
cleanEnergy.setText(inputMap.get("input_footprint_housing_gco2_per_kwh"));
|
||||
naturalGasUsage.setText(inputMap.get("input_footprint_housing_naturalgas_dollars")
|
||||
+ " €/yr");
|
||||
heatingOilUsage.setText(inputMap.get("input_footprint_housing_heatingoil_dollars")
|
||||
+ " €/yr");
|
||||
waterUsage.setText(inputMap.get("input_footprint_housing_watersewage") + " €/yr");
|
||||
livingSpace.setText(inputMap.get("input_footprint_housing_squarefeet") + " m²");
|
||||
gasolineMiles.setText(inputMap.get("input_footprint_transportation_miles1"));
|
||||
gasolineMpg.setText(inputMap.get("input_footprint_transportation_mpg1"));
|
||||
dieselMiles.setText(inputMap.get("input_footprint_transportation_miles2"));
|
||||
dieselMpg.setText(inputMap.get("input_footprint_transportation_mpg2"));
|
||||
electricMiles.setText(inputMap.get("input_footprint_transportation_miles3"));
|
||||
electricMpg.setText(inputMap.get("input_footprint_transportation_mpg3"));
|
||||
publicTransportation.setText(inputMap.get("input_footprint_transportation_publictrans")
|
||||
+ " km/yr");
|
||||
airPlane.setText(inputMap.get("input_footprint_transportation_airtotal") + " km/yr");
|
||||
goodShopping.setText(inputMap.get("input_footprint_shopping_goods_total") + " €/mo");
|
||||
serviceShopping.setText(inputMap.get("input_footprint_shopping_services_total") + " €/mo");
|
||||
meat.setText(inputMap.get("input_footprint_shopping_food_meatfisheggs"));
|
||||
grains.setText(inputMap.get("input_footprint_shopping_food_cereals"));
|
||||
dairy.setText(inputMap.get("input_footprint_shopping_food_dairy"));
|
||||
fruits.setText(inputMap.get("input_footprint_shopping_food_fruitvegetables"));
|
||||
snacks.setText(inputMap.get("input_footprint_shopping_food_otherfood"));
|
||||
Map<String, String> extraMap = userService
|
||||
.getExtraInputs(userService.currentUser.getName());
|
||||
veganMeal.setText(extraMap.get("vegan"));
|
||||
localProduce.setText(extraMap.get("local_produce"));
|
||||
bike.setText(extraMap.get("bike"));
|
||||
publicTrans.setText(extraMap.get("public_transport"));
|
||||
loweringTemp.setText(extraMap.get("temperature"));
|
||||
solarPanels.setText(extraMap.get("solar_panels"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the user profile pane.
|
||||
* @param event the event (clicking the button)
|
||||
*/
|
||||
public void displayUser(ActionEvent event) throws InterruptedException {
|
||||
System.out.println(userService.currentUser.getName());
|
||||
System.out.println(userService.getFootprint(userService.currentUser.getName()));
|
||||
footprintLabel.setText("" + userService.getFootprint(userService.currentUser.getName()));
|
||||
firstFootprintLabel.setText("" + userService
|
||||
.getFirstFootprint(userService.currentUser.getName()));
|
||||
Double diff = userService.getFirstFootprint(userService.currentUser.getName()) - userService
|
||||
.getFootprint(userService.currentUser.getName());
|
||||
differenceLabel.setText( "" + Math.round(diff * 10) / 10.0);
|
||||
usernameLabel.setText("" + userService.currentUser.getName());
|
||||
addFadeTransition(userPane);
|
||||
System.out.println("display user");
|
||||
dashboardPane.setVisible(false);
|
||||
userPane.setVisible(true);
|
||||
activitiesPane.setVisible(false);
|
||||
friendsPane.setVisible(false);
|
||||
updatePiechart();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the friends pane.
|
||||
* @param event the event (clicking the button)
|
||||
*/
|
||||
public void displayFriends(ActionEvent event) throws InterruptedException {
|
||||
addFadeTransition(friendsPane);
|
||||
System.out.println("display friends");
|
||||
dashboardPane.setVisible(false);
|
||||
userPane.setVisible(false);
|
||||
activitiesPane.setVisible(false);
|
||||
friendsPane.setVisible(true);
|
||||
updateFriends();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Logs out the user.
|
||||
* @param event the event (clicking the button)
|
||||
* @throws IOException if the Application doesn't load.
|
||||
*/
|
||||
public void logOut(ActionEvent event) throws IOException {
|
||||
//get the current window
|
||||
Window owner = logOutButton.getScene().getWindow();
|
||||
Stage current = (Stage) owner;
|
||||
//close current window (log out)
|
||||
current.close();
|
||||
System.out.println("User is logged out");
|
||||
|
||||
//global leaderboard
|
||||
globalLeaderboard.getItems().clear();
|
||||
globalLeaderData.removeAll();
|
||||
//development leaderboard
|
||||
developmentLeaderboard.getItems().clear();
|
||||
developmentData.removeAll();
|
||||
//friends leaderboard
|
||||
friendLeaderboard.getItems().clear();
|
||||
friendLeaderData.removeAll();
|
||||
|
||||
//load the fxml file
|
||||
Parent dash = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/LoginWindow.fxml"));
|
||||
Scene scene = new Scene(dash);
|
||||
//add the stylesheet for the CSS
|
||||
scene.getStylesheets().add(Objects.requireNonNull(getClass().getClassLoader()
|
||||
.getResource("stylesheets/LoginWindowStyle.css")).toExternalForm());
|
||||
Stage appStage = new Stage();
|
||||
appStage.setScene(scene);
|
||||
//set the title
|
||||
appStage.setTitle("Greenify");
|
||||
appStage.show();
|
||||
}
|
||||
|
||||
//sets the slide in transition for startup
|
||||
public void addSlideTransition(Node node, Line path1) {
|
||||
PathTransition pathTrans = new PathTransition(Duration.millis(1100), path1, node);
|
||||
pathTrans.play();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the calculator.
|
||||
* @throws IOException if the Application doesn't load.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void openCalculator() throws IOException, InterruptedException {
|
||||
Parent calc = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/calculator.fxml"));
|
||||
Scene scene = new Scene(calc);
|
||||
scene.getStylesheets().add(getClass().getClassLoader()
|
||||
.getResource("stylesheets/calculatorStyle.css").toExternalForm());
|
||||
Stage calcStage = new Stage();
|
||||
|
||||
calcStage.setScene(scene);
|
||||
calcStage.setTitle("Calculate CO2 footprint - " + userService.currentUser.getName());
|
||||
calcStage.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a random hint to the side bar.
|
||||
*/
|
||||
public void addRandomHints() {
|
||||
FadeTransition fadeOut = new FadeTransition(Duration.millis(400), hintText);
|
||||
fadeOut.setFromValue(1.0);
|
||||
fadeOut.setToValue(0.0);
|
||||
fadeOut.play();
|
||||
hintText.setWrapText(true);
|
||||
hintText.setText(hints.randomHint());
|
||||
FadeTransition fadeIn = new FadeTransition(Duration.millis(400), hintText);
|
||||
fadeIn.setFromValue(0.0);
|
||||
fadeIn.setToValue(1.0);
|
||||
fadeIn.play();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens extra activities.
|
||||
* @param event the event (clicking the button)
|
||||
* @throws IOException if the Application doesn't load.
|
||||
*/
|
||||
public void openExtraActivities(ActionEvent event) throws IOException {
|
||||
Parent extra = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/extraActivities.fxml"));
|
||||
Scene scene = new Scene(extra);
|
||||
Stage extraStage = new Stage();
|
||||
extraStage.setScene(scene);
|
||||
extraStage.setTitle("Add extra activity - " + userService.currentUser.getName());
|
||||
extraStage.show();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* method opens addFriend scene.
|
||||
* @throws IOException when file is not found
|
||||
*/
|
||||
public void openAddFriend() throws IOException {
|
||||
Parent calc = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/AddFriend.fxml"));
|
||||
Scene scene = new Scene(calc);
|
||||
Stage calcStage = new Stage();
|
||||
calcStage.setScene(scene);
|
||||
calcStage.setTitle("Add a new friend - " + userService.currentUser.getName());
|
||||
calcStage.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* method opens removeFriend scene.
|
||||
* @throws IOException when file is not found
|
||||
*/
|
||||
public void openRemoveFriend() throws IOException {
|
||||
Parent calc = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/RemoveFriend.fxml"));
|
||||
Scene scene = new Scene(calc);
|
||||
Stage calcStage = new Stage();
|
||||
calcStage.setScene(scene);
|
||||
calcStage.setTitle("Remove your friend - " + userService.currentUser.getName());
|
||||
calcStage.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Leaderboard is updating.
|
||||
* @throws InterruptedException throws exception
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void updateLeaderboard() throws InterruptedException {
|
||||
//global leaderboard
|
||||
globalLeaderboard.getItems().clear();
|
||||
globalLeaderData.removeAll();
|
||||
//development leaderboard
|
||||
developmentLeaderboard.getItems().clear();
|
||||
developmentData.removeAll();
|
||||
List<String> userList = userService.getAllUsers();
|
||||
sortScores(userList);
|
||||
for (int i = userList.size() - 1; i >= 0; i--) {
|
||||
Friend user = new Friend(userList.size() - i, userList.get(i),
|
||||
userService.getFootprint(userList.get(i)));
|
||||
globalLeaderData.add(user);
|
||||
}
|
||||
List<String> secondList = sortDiffScores(userList);
|
||||
for (int j = 0; j < userList.size(); j++) {
|
||||
double diff = Math.round((userService.getFirstFootprint(secondList.get(j))
|
||||
- userService.getFootprint(secondList.get(j))) * 10) / 10.0;
|
||||
Friend diffUser = new Friend(j + 1, secondList.get(j), diff);
|
||||
developmentData.add(diffUser);
|
||||
}
|
||||
globalLeaderboard.setItems(globalLeaderData);
|
||||
developmentLeaderboard.setItems(developmentData);
|
||||
}
|
||||
|
||||
/**
|
||||
* The method updating piechart.
|
||||
* @throws InterruptedException exception
|
||||
*/
|
||||
public void updatePiechart() throws InterruptedException {
|
||||
Map<String, String> resultMap = userService.getResults(userService.currentUser.getName());
|
||||
if (pieChart != null) {
|
||||
ObservableList<PieChart.Data> pieChartData =
|
||||
FXCollections.observableArrayList(
|
||||
new PieChart.Data("Transport",
|
||||
Double.parseDouble(resultMap.get("transport"))),
|
||||
new PieChart.Data("Housing",
|
||||
Double.parseDouble(resultMap.get("housing"))),
|
||||
new PieChart.Data("Food",
|
||||
Double.parseDouble(resultMap.get("food"))),
|
||||
new PieChart.Data("Goods",
|
||||
Double.parseDouble(resultMap.get("goods"))),
|
||||
new PieChart.Data("Services",
|
||||
Double.parseDouble(resultMap.get("services")))
|
||||
);
|
||||
pieChart.setTitle("FOOTPRINT DISTRIBUTION");
|
||||
pieChart.setMaxSize(1000, 1000);
|
||||
pieChart.setData(pieChartData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Friends tables are updating.
|
||||
* @throws InterruptedException throws exception
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void updateFriends() throws InterruptedException {
|
||||
List<String> wholeList = userService.getFriendNames(userService.currentUser.getName());
|
||||
wholeList.add(userService.currentUser.getName());
|
||||
//friend list
|
||||
friendsTable.getItems().clear();
|
||||
data.removeAll();
|
||||
List<String> friendList = userService.getFriendNames(userService.currentUser.getName());
|
||||
sortScores(friendList);
|
||||
//friends leaderboard
|
||||
friendLeaderboard.getItems().clear();
|
||||
friendLeaderData.removeAll();
|
||||
sortDiffScores(wholeList);
|
||||
for (int i = friendList.size() - 1; i >= 0 ; i--) {
|
||||
Friend user = new Friend(i, friendList.get(i), userService
|
||||
.getFootprint(friendList.get(i)));
|
||||
data.add(user);
|
||||
}
|
||||
for (int j = 0; j < wholeList.size(); j++) {
|
||||
double diff = Math.round((userService.getFirstFootprint(wholeList.get(j))
|
||||
- userService.getFootprint(wholeList.get(j))) * 10) / 10.0;
|
||||
Friend diffUser = new Friend(j + 1, wholeList.get(j), diff);
|
||||
friendLeaderData.add(diffUser);
|
||||
}
|
||||
friendsTable.setItems(data);
|
||||
friendLeaderboard.setItems(friendLeaderData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the achievements.
|
||||
*/
|
||||
public void updateAchievements() {
|
||||
Map achievements = userService.getAchievements(userService.currentUser.getName());
|
||||
ColorAdjust desaturate = new ColorAdjust();
|
||||
desaturate.setSaturation(-0.75);
|
||||
if ((Boolean)achievements.get("Starting off")) {
|
||||
achieve1.setOpacity(1);
|
||||
} else {
|
||||
achieve1.setEffect(desaturate);
|
||||
achieve1.setOpacity(0.3);
|
||||
}
|
||||
if ((Boolean)achievements.get("Social butterfly")) {
|
||||
achieve2.setOpacity(1);
|
||||
} else {
|
||||
achieve2.setEffect(desaturate);
|
||||
achieve2.setOpacity(0.3);
|
||||
}
|
||||
if ((Boolean)achievements.get("Green saver")) {
|
||||
achieve3.setOpacity(1);
|
||||
} else {
|
||||
achieve3.setEffect(desaturate);
|
||||
achieve3.setOpacity(0.3);
|
||||
}
|
||||
if ((Boolean)achievements.get("Animal friend")) {
|
||||
achieve4.setOpacity(1);
|
||||
} else {
|
||||
achieve4.setEffect(desaturate);
|
||||
achieve4.setOpacity(0.3);
|
||||
}
|
||||
if ((Boolean)achievements.get("Tom Dumoulin")) {
|
||||
achieve5.setOpacity(1);
|
||||
} else {
|
||||
achieve5.setEffect(desaturate);
|
||||
achieve5.setOpacity(0.3);
|
||||
}
|
||||
if ((Boolean)achievements.get("Let it shine")) {
|
||||
achieve6.setOpacity(1);
|
||||
} else {
|
||||
achieve6.setEffect(desaturate);
|
||||
achieve6.setOpacity(0.3);
|
||||
}
|
||||
}
|
||||
|
||||
//class for the animations on the navigation buttons
|
||||
private class MyButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
* adds a skin and scale animation to a button.
|
||||
* the scale transition is for hovering over it so it then scales up
|
||||
* and scales down when you stop hovering over it.
|
||||
* @param button the button to add the animation to
|
||||
*/
|
||||
private MyButtonSkin(Button button) {
|
||||
//inherit the button properties
|
||||
super(button);
|
||||
//transition to scale up on hover
|
||||
final ScaleTransition scaleUp = new ScaleTransition(Duration.millis(100));
|
||||
//add the node and the position to scale to
|
||||
scaleUp.setNode(button);
|
||||
scaleUp.setToX(1.1);
|
||||
//play the transition when hovered over the button
|
||||
button.setOnMouseEntered(e -> scaleUp.playFromStart());
|
||||
|
||||
final ScaleTransition scaleDown = new ScaleTransition(Duration.millis(100));
|
||||
scaleDown.setNode(button);
|
||||
scaleDown.setToX(1.0);
|
||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
private class ClickButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
* button skin for the 'add activity' buttons.
|
||||
* adds scale animations on entering, clicking and exiting the button
|
||||
* @param button the button to set the skin of
|
||||
*/
|
||||
private ClickButtonSkin(Button button) {
|
||||
super(button);
|
||||
|
||||
//transition to scale up on hover
|
||||
final ScaleTransition scaleUp = new ScaleTransition(Duration.millis(100));
|
||||
//add the node and the position to scale to
|
||||
scaleUp.setNode(button);
|
||||
scaleUp.setToX(1.1);
|
||||
scaleUp.setToY(1.1);
|
||||
//play the transition when hovered over the button
|
||||
button.setOnMouseEntered(e -> scaleUp.playFromStart());
|
||||
|
||||
final ScaleTransition scaleMiddleDown = new ScaleTransition(Duration.millis(50));
|
||||
scaleMiddleDown.setNode(button);
|
||||
scaleMiddleDown.setToX(1.05);
|
||||
scaleMiddleDown.setToY(1.05);
|
||||
|
||||
button.setOnMousePressed(e -> scaleMiddleDown.playFromStart());
|
||||
|
||||
final ScaleTransition scaleMiddleUp = new ScaleTransition(Duration.millis(50));
|
||||
scaleMiddleUp.setNode(button);
|
||||
scaleMiddleUp.setToX(1.1);
|
||||
scaleMiddleUp.setToY(1.1);
|
||||
button.setOnMouseReleased(e -> scaleMiddleUp.playFromStart());
|
||||
|
||||
final ScaleTransition scaleDown = new ScaleTransition(Duration.millis(100));
|
||||
scaleDown.setNode(button);
|
||||
scaleDown.setToX(1.0);
|
||||
scaleDown.setToY(1.0);
|
||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,372 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.ScaleTransition;
|
||||
import javafx.animation.TranslateTransition;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.util.Duration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
@Controller
|
||||
public class ExtraActivityController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Autowired
|
||||
CalculatorController calculatorController;
|
||||
|
||||
@Autowired
|
||||
DashBoardController controller;
|
||||
|
||||
@FXML
|
||||
private AnchorPane veganMealPane;
|
||||
@FXML
|
||||
private AnchorPane bikePane;
|
||||
@FXML
|
||||
private AnchorPane temperaturePane;
|
||||
@FXML
|
||||
private AnchorPane solarPanelPane;
|
||||
@FXML
|
||||
private AnchorPane localProducePane;
|
||||
@FXML
|
||||
private AnchorPane publicTransportPane;
|
||||
@FXML
|
||||
private Button displayVeganMealButton;
|
||||
@FXML
|
||||
private Button displayBikeButton;
|
||||
@FXML
|
||||
private Button displayTemperatureButton;
|
||||
@FXML
|
||||
private Button displaySolarPanelButton;
|
||||
@FXML
|
||||
private Button displayLocalProduceButton;
|
||||
@FXML
|
||||
private Button displayPublicTransportButton;
|
||||
|
||||
@FXML
|
||||
private Button addVeganMealButton;
|
||||
@FXML
|
||||
private Button addBikeButton;
|
||||
@FXML
|
||||
private Button addTemperatureButton;
|
||||
@FXML
|
||||
private Button addSolarPanelsButton;
|
||||
@FXML
|
||||
private Button addLocalProduceButton;
|
||||
@FXML
|
||||
private Button addPublicTransportButton;
|
||||
@FXML
|
||||
private Slider bikeSlider;
|
||||
@FXML
|
||||
private Label bikeLabel;
|
||||
@FXML
|
||||
private Slider temperatureSlider;
|
||||
@FXML
|
||||
private Label temperatureLabel;
|
||||
@FXML
|
||||
private Slider solarPanelsSlider;
|
||||
@FXML
|
||||
private Label solarPanelsLabel;
|
||||
@FXML
|
||||
private Label publicTransportLabel;
|
||||
@FXML
|
||||
private Slider publicTransportSlider;
|
||||
|
||||
|
||||
/**
|
||||
* initializes the sliders and labels before loading.
|
||||
* sets the labels to display the outputs of the designated sliders.
|
||||
*/
|
||||
public void initialize() {
|
||||
coupleSliderToLabel(bikeSlider, bikeLabel, " km", false);
|
||||
coupleSliderToLabel(temperatureSlider, temperatureLabel, " Degrees", true);
|
||||
coupleSliderToLabel(solarPanelsSlider, solarPanelsLabel, "", true);
|
||||
coupleSliderToLabel(publicTransportSlider, publicTransportLabel, " km", false);
|
||||
|
||||
addVeganMealButton.setSkin(new ActivityButtonSkin(addVeganMealButton));
|
||||
addBikeButton.setSkin(new ActivityButtonSkin(addBikeButton));
|
||||
addTemperatureButton.setSkin(new ActivityButtonSkin(addTemperatureButton));
|
||||
addSolarPanelsButton.setSkin(new ActivityButtonSkin(addSolarPanelsButton));
|
||||
addLocalProduceButton.setSkin(new ActivityButtonSkin(addLocalProduceButton));
|
||||
addPublicTransportButton.setSkin(new ActivityButtonSkin(addPublicTransportButton));
|
||||
|
||||
displayVeganMealButton.setSkin(new TranslateButtonSkin(displayVeganMealButton));
|
||||
displayBikeButton.setSkin(new TranslateButtonSkin(displayBikeButton));
|
||||
displayTemperatureButton.setSkin(new TranslateButtonSkin(displayTemperatureButton));
|
||||
displaySolarPanelButton.setSkin(new TranslateButtonSkin(displaySolarPanelButton));
|
||||
displayLocalProduceButton.setSkin(new TranslateButtonSkin(displayLocalProduceButton));
|
||||
displayPublicTransportButton.setSkin(new TranslateButtonSkin(displayPublicTransportButton));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the label to display the value of the designated slider.
|
||||
* sets the text to be displayed after the value of the slider.
|
||||
* sets whether the slider should snap to ticks
|
||||
* @param slider the slider to read the value from
|
||||
* @param label the label to display the value of the slider
|
||||
* @param string the string to be placed after the outputted value of the slider
|
||||
* @param snapToTicks whether the slider should snap to ticks or not
|
||||
*/
|
||||
private void coupleSliderToLabel(Slider slider, Label label, String string,
|
||||
boolean snapToTicks) {
|
||||
slider.setSnapToTicks(snapToTicks);
|
||||
slider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
label.setText(newValue.intValue() + string);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* add transition animation.
|
||||
* @param node adding animation
|
||||
*/
|
||||
public void addFadeTransAnimation(Node node) {
|
||||
FadeTransition fade = new FadeTransition(Duration.millis(350), node);
|
||||
fade.setFromValue(0);
|
||||
fade.setToValue(1.0);
|
||||
TranslateTransition trans = new TranslateTransition(Duration.millis(350), node);
|
||||
trans.setFromX(-800);
|
||||
trans.setToX(0);
|
||||
ParallelTransition par = new ParallelTransition();
|
||||
par.setNode(node);
|
||||
par.getChildren().addAll(fade, trans);
|
||||
par.play();
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the vegetarian meal section.
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
public void displayVeganMeal(ActionEvent event) {
|
||||
// System.out.println("display vm");
|
||||
addFadeTransAnimation(veganMealPane);
|
||||
veganMealPane.setVisible(true);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
solarPanelPane.setVisible(false);
|
||||
localProducePane.setVisible(false);
|
||||
publicTransportPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the bike section.
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
public void displayBike(ActionEvent event) {
|
||||
// System.out.println("display b");
|
||||
addFadeTransAnimation(bikePane);
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(true);
|
||||
temperaturePane.setVisible(false);
|
||||
solarPanelPane.setVisible(false);
|
||||
localProducePane.setVisible(false);
|
||||
publicTransportPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the temperature section.
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
public void displayTemperature(ActionEvent event) {
|
||||
// System.out.println("display t");
|
||||
addFadeTransAnimation(temperaturePane);
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(true);
|
||||
solarPanelPane.setVisible(false);
|
||||
localProducePane.setVisible(false);
|
||||
publicTransportPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the solar panels section.
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
public void displaySolarPanel(ActionEvent event) {
|
||||
// System.out.println("display sp");
|
||||
addFadeTransAnimation(solarPanelPane);
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
solarPanelPane.setVisible(true);
|
||||
localProducePane.setVisible(false);
|
||||
publicTransportPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the local produce section.
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
public void displayLocalProduce(ActionEvent event) {
|
||||
addFadeTransAnimation(localProducePane);
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
solarPanelPane.setVisible(false);
|
||||
localProducePane.setVisible(true);
|
||||
publicTransportPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the public transport section.
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
public void displayPublicTransport(ActionEvent event) {
|
||||
addFadeTransAnimation(publicTransportPane);
|
||||
veganMealPane.setVisible(false);
|
||||
bikePane.setVisible(false);
|
||||
temperaturePane.setVisible(false);
|
||||
solarPanelPane.setVisible(false);
|
||||
localProducePane.setVisible(false);
|
||||
publicTransportPane.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* The method updates the values.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void save(ActionEvent event) {
|
||||
try {
|
||||
updateExtras();
|
||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||
controller.updateLeaderboard();
|
||||
controller.updateAchievements();
|
||||
} catch (InterruptedException ex) {
|
||||
System.out.println("continue");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The method updates the values of extras.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void updateExtras() throws InterruptedException {
|
||||
if (!bikeLabel.getText().replace(" km", "").equals("0")) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"bike",
|
||||
bikeLabel.getText().replace(" km", ""));
|
||||
}
|
||||
if (!solarPanelsLabel.getText().equals("0")) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"solar_panels",
|
||||
solarPanelsLabel.getText());
|
||||
}
|
||||
if (!temperatureLabel.getText().replace(" Degrees", "").equals("0")) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"temperature",
|
||||
temperatureLabel.getText().replace(" Degrees", ""));
|
||||
}
|
||||
if (!publicTransportLabel.getText().replace(" km", "").equals("0")) {
|
||||
userService.updateExtraInput(userService.currentUser.getName(),
|
||||
"public_transport",
|
||||
publicTransportLabel.getText().replace(" km", ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The method updates the values of extras.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void updateExtraVegan() throws InterruptedException {
|
||||
try {
|
||||
userService.updateExtraInput(userService.currentUser.getName(), "vegan", "1");
|
||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||
controller.updateAchievements();
|
||||
controller.updateLeaderboard();
|
||||
} catch (NullPointerException ex) {
|
||||
System.out.println("continue");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The method updates the values of extras.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void updateExtraLocal() throws InterruptedException {
|
||||
try {
|
||||
userService.updateExtraInput(userService.currentUser.getName(), "local_produce", "1");
|
||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||
controller.updateAchievements();
|
||||
controller.updateLeaderboard();
|
||||
} catch (NullPointerException ex) {
|
||||
System.out.println("continue");
|
||||
}
|
||||
}
|
||||
|
||||
public class TranslateButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
* button skin that sets a translate animation on entering and exiting the button.
|
||||
* @param button the button to set the animation for
|
||||
*/
|
||||
private TranslateButtonSkin(Button button) {
|
||||
super(button);
|
||||
|
||||
TranslateTransition transEnter = new TranslateTransition(Duration.millis(50));
|
||||
transEnter.setNode(button);
|
||||
transEnter.setToX(10);
|
||||
button.setOnMouseEntered(e -> transEnter.playFromStart());
|
||||
|
||||
TranslateTransition transExit = new TranslateTransition(Duration.millis(50));
|
||||
transExit.setNode(button);
|
||||
transExit.setToX(1.0);
|
||||
button.setOnMouseExited(e -> transExit.playFromStart());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
private class ActivityButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
* button skin for the 'add activity' buttons.
|
||||
* adds scale animations on entering, clicking and exiting the button
|
||||
* @param button the button to set the skin of
|
||||
*/
|
||||
private ActivityButtonSkin(Button button) {
|
||||
super(button);
|
||||
|
||||
//transition to scale up on hover
|
||||
final ScaleTransition scaleUp = new ScaleTransition(Duration.millis(100));
|
||||
//add the node and the position to scale to
|
||||
scaleUp.setNode(button);
|
||||
scaleUp.setToX(1.1);
|
||||
scaleUp.setToY(1.1);
|
||||
//play the transition when hovered over the button
|
||||
button.setOnMouseEntered(e -> scaleUp.playFromStart());
|
||||
|
||||
final ScaleTransition scaleMiddleDown = new ScaleTransition(Duration.millis(50));
|
||||
scaleMiddleDown.setNode(button);
|
||||
scaleMiddleDown.setToX(1.05);
|
||||
scaleMiddleDown.setToY(1.05);
|
||||
|
||||
button.setOnMousePressed(e -> scaleMiddleDown.playFromStart());
|
||||
|
||||
final ScaleTransition scaleMiddleUp = new ScaleTransition(Duration.millis(50));
|
||||
scaleMiddleUp.setNode(button);
|
||||
scaleMiddleUp.setToX(1.1);
|
||||
scaleMiddleUp.setToY(1.1);
|
||||
button.setOnMouseReleased(e -> scaleMiddleUp.playFromStart());
|
||||
|
||||
final ScaleTransition scaleDown = new ScaleTransition(Duration.millis(100));
|
||||
scaleDown.setNode(button);
|
||||
scaleDown.setToX(1.0);
|
||||
scaleDown.setToY(1.0);
|
||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
|
||||
@Controller
|
||||
public class FriendController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Autowired
|
||||
DashBoardController dashBoardController;
|
||||
|
||||
@FXML
|
||||
private Button addButton;
|
||||
@FXML
|
||||
private TextField userNameText;
|
||||
@FXML
|
||||
private Button removeButton;
|
||||
@FXML
|
||||
private TextField removeUserNameText;
|
||||
|
||||
/**
|
||||
* Add a new friend.
|
||||
* @param event the click of the sign up button
|
||||
*/
|
||||
@FXML
|
||||
public void addFriend(ActionEvent event) throws InterruptedException {
|
||||
//set the window to the current window (for displaying the alerts)
|
||||
Window owner = addButton.getScene().getWindow();
|
||||
//check if the username field is empty
|
||||
if (userNameText.getText().isEmpty()) {
|
||||
//if so, display an alert
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
|
||||
"Please enter a username!");
|
||||
return;
|
||||
} else if (userNameText.getText().equals(userService.currentUser.getName())) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||
"Cannot add yourself as a friend!");
|
||||
return;
|
||||
} else if (userService.getFriendNames(userService.currentUser.getName())
|
||||
.contains(userNameText.getText())) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||
"Cannot add a friend twice!");
|
||||
return;
|
||||
} else if (!userService.getAllUsers().contains(userNameText.getText())) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||
"The user does not exist!");
|
||||
return;
|
||||
}
|
||||
//add friend to the current user
|
||||
userService.addFriend(userService.currentUser.getName(), userNameText.getText());
|
||||
//close the register window after the user has entered all the credentials
|
||||
String friendName = userNameText.getText();
|
||||
Stage current = (Stage) owner;
|
||||
dashBoardController.updateAchievements();
|
||||
dashBoardController.updateFriends();
|
||||
current.close();
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Friend added!",
|
||||
userNameText.getText() + " is now your friend!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes one of the friends of the user.
|
||||
* @param event the click of the sign up button
|
||||
*/
|
||||
@FXML
|
||||
public void removeFriend(ActionEvent event) throws InterruptedException {
|
||||
//set the window to the current window (for displaying the alerts)
|
||||
Window owner = removeButton.getScene().getWindow();
|
||||
//check if the username field is empty
|
||||
if (removeUserNameText.getText().isEmpty()) {
|
||||
//if so, display an alert
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
|
||||
"Please enter a username!");
|
||||
return;
|
||||
} else if (removeUserNameText.getText().equals(userService.currentUser.getName())) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||
"You are not your friend!");
|
||||
return;
|
||||
} else if (!userService.getFriendNames(userService.currentUser.getName())
|
||||
.contains(removeUserNameText.getText())) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||
"You do not have a friend with this username!");
|
||||
return;
|
||||
} else if (!userService.getAllUsers().contains(removeUserNameText.getText())) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Error!",
|
||||
"The user does not exist!");
|
||||
return;
|
||||
}
|
||||
//add friend to the current user
|
||||
userService.removeFriend(userService.currentUser.getName(), removeUserNameText.getText());
|
||||
//close the register window after the user has entered all the credentials
|
||||
Stage current = (Stage) owner;
|
||||
dashBoardController.updateFriends();
|
||||
dashBoardController.updateAchievements();
|
||||
current.close();
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION, owner, "Friend removed!",
|
||||
removeUserNameText.getText() + " is not your friend anymore!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,675 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||
import greenify.client.Application;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.FadeTransition;
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.ParallelTransition;
|
||||
import javafx.animation.ScaleTransition;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.animation.TranslateTransition;
|
||||
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.ScrollPane;
|
||||
import javafx.scene.control.Slider;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import javafx.util.Duration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Class that controls the actions for the register window.
|
||||
*/
|
||||
@Controller
|
||||
public class RegisterWindowController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@Autowired
|
||||
ExtraActivityController extraActivityController;
|
||||
|
||||
@FXML
|
||||
private Text explainText;
|
||||
//navigation panes
|
||||
@FXML
|
||||
private AnchorPane getStartedPane;
|
||||
@FXML
|
||||
private AnchorPane travelPane;
|
||||
@FXML
|
||||
private AnchorPane homePane;
|
||||
@FXML
|
||||
private ScrollPane foodPane;
|
||||
@FXML
|
||||
private AnchorPane shoppingPane;
|
||||
|
||||
//'get started' pane
|
||||
@FXML
|
||||
private Slider peopleInHouseholdSlider;
|
||||
@FXML
|
||||
private Label peopleInHouseHoldLabel;
|
||||
@FXML
|
||||
private Slider annualIncomeSlider;
|
||||
@FXML
|
||||
private Label annualIncomeLabel;
|
||||
@FXML
|
||||
private Button saveButton;
|
||||
|
||||
//travel pane
|
||||
@FXML
|
||||
private TextField publicTransitField;
|
||||
@FXML
|
||||
private TextField airplaneTravelField;
|
||||
@FXML
|
||||
private TextField carTravelGasolineField;
|
||||
@FXML
|
||||
private Slider carTravelGasolineSlider;
|
||||
@FXML
|
||||
private Label carTravelGasolineLabel;
|
||||
@FXML
|
||||
private TextField carTravelDieselField;
|
||||
@FXML
|
||||
private Slider carTravelDieselSlider;
|
||||
@FXML
|
||||
private Label carTravelDieselLabel;
|
||||
@FXML
|
||||
private TextField carTravelElectricField;
|
||||
@FXML
|
||||
private Slider carTravelElectricSlider;
|
||||
@FXML
|
||||
private Label carTravelElectricLabel;
|
||||
|
||||
//home pane
|
||||
@FXML
|
||||
private TextField electricityField;
|
||||
@FXML
|
||||
private Slider cleanEnergyPurchasedSlider;
|
||||
@FXML
|
||||
private Label cleanEnergyPurchasedLabel;
|
||||
@FXML
|
||||
private TextField naturalGasField;
|
||||
@FXML
|
||||
private TextField heatingOilField;
|
||||
@FXML
|
||||
private TextField livingSpaceField;
|
||||
@FXML
|
||||
private Slider waterUsageSlider;
|
||||
@FXML
|
||||
private Label waterUsageLabel;
|
||||
|
||||
//food pane
|
||||
@FXML
|
||||
private Slider meatFishEggsSlider;
|
||||
@FXML
|
||||
private Label meatFishEggsLabel;
|
||||
@FXML
|
||||
private Slider grainsBakedGoodsSlider;
|
||||
@FXML
|
||||
private Label grainsBakedGoodsLabel;
|
||||
@FXML
|
||||
private Slider dairySlider;
|
||||
@FXML
|
||||
private Label dairyLabel;
|
||||
@FXML
|
||||
private Slider fruitsVegetablesSlider;
|
||||
@FXML
|
||||
private Label fruitsVegetablesLabel;
|
||||
@FXML
|
||||
private Slider snacksDrinksSlider;
|
||||
@FXML
|
||||
private Label snacksDrinksLabel;
|
||||
|
||||
//shopping pane
|
||||
@FXML
|
||||
private Text goodsField;
|
||||
@FXML
|
||||
private Text servicesField;
|
||||
@FXML
|
||||
private Slider goodsSlider;
|
||||
@FXML
|
||||
private Label goodsLabel;
|
||||
@FXML
|
||||
private Slider servicesSlider;
|
||||
@FXML
|
||||
private Label servicesLabel;
|
||||
|
||||
//extra pane
|
||||
@FXML
|
||||
private AnchorPane extraPane;
|
||||
@FXML
|
||||
private TextField userNameText;
|
||||
@FXML
|
||||
private PasswordField passwordField;
|
||||
@FXML
|
||||
private PasswordField passwordField2;
|
||||
@FXML
|
||||
private Button signUpButton;
|
||||
|
||||
|
||||
//@FXML
|
||||
//private Line uNamePathLine;
|
||||
|
||||
/**
|
||||
* Initializes the animation.
|
||||
* @throws InterruptedException exception when interrupted
|
||||
*/
|
||||
public void initialize() throws InterruptedException {
|
||||
addSlideAnimation(1100, userNameText, -300);
|
||||
addSlideAnimation(1100, passwordField, 300);
|
||||
TimeUnit.MILLISECONDS.sleep(300);
|
||||
addSlideAnimation(1100, passwordField2, -420);
|
||||
|
||||
signUpButton.setSkin(new RegisterButtonSkin(signUpButton));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the slide animation.
|
||||
* @param duration the duration
|
||||
* @param node the node
|
||||
* @param from from where
|
||||
*/
|
||||
private void addSlideAnimation(int duration, Node node, int from) {
|
||||
TranslateTransition slideIn = new TranslateTransition(Duration.millis(duration), node);
|
||||
slideIn.setFromX(from);
|
||||
slideIn.setToX(0);
|
||||
slideIn.play();
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows an explanation of the application.
|
||||
* @param event the click of the question mark button
|
||||
*/
|
||||
public void showExplanation(ActionEvent event) {
|
||||
if (explainText.isVisible()) {
|
||||
explainText.setVisible(false);
|
||||
} else {
|
||||
explainText.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs up the user.
|
||||
* @param event the click of the sign up button
|
||||
*/
|
||||
@FXML
|
||||
public void handleSignUpButton(ActionEvent event) throws IOException, NoSuchAlgorithmException {
|
||||
//set the window to the current window (for displaying the alerts)
|
||||
Window owner = signUpButton.getScene().getWindow();
|
||||
//check if the username field is empty
|
||||
if (userNameText.getText().isEmpty()) {
|
||||
//if so, display an alert
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
|
||||
"Please enter a username!");
|
||||
return;
|
||||
}
|
||||
|
||||
//check if the password field is empty
|
||||
if (passwordField.getText().isEmpty()) {
|
||||
//if so, display an alert
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Password Error!",
|
||||
"Please enter a password!");
|
||||
return;
|
||||
}
|
||||
|
||||
//check if the two password fields are equal
|
||||
if (!passwordField.getText().equals(passwordField2.getText())) {
|
||||
//if not, display an alert
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Password Error!",
|
||||
"Please make sure the passwords entered are the same!");
|
||||
return;
|
||||
}
|
||||
|
||||
//register the user with the provided username and password
|
||||
try {
|
||||
userService.registerUser(userNameText.getText(), passwordField.getText());
|
||||
} catch (HttpClientErrorException ex) {
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Username Error!",
|
||||
"This username has already been taken!");
|
||||
return;
|
||||
}
|
||||
//close the register window after the user has entered all the credentials
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
|
||||
Parent calc = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/FirstCalculator.fxml"));
|
||||
Scene scene = new Scene(calc);
|
||||
scene.getStylesheets().add(getClass().getClassLoader()
|
||||
.getResource("stylesheets/calculatorStyle.css").toExternalForm());
|
||||
Stage calcStage = new Stage();
|
||||
|
||||
calcStage.setScene(scene);
|
||||
calcStage.setTitle("Calculate CO2 footprint - " + userService.currentUser.getName());
|
||||
calcStage.show();
|
||||
|
||||
peopleInHouseholdSlider.setSnapToTicks(true);
|
||||
//add listener to slider for amount of people in household
|
||||
peopleInHouseholdSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
peopleInHouseHoldLabel.setText("" + newValue.intValue());
|
||||
}
|
||||
});
|
||||
|
||||
//add listener to slider for annual income
|
||||
annualIncomeSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
annualIncomeLabel.setText("" + (newValue.intValue() * 1000));
|
||||
}
|
||||
});
|
||||
|
||||
addSliderListenerCarUsage(carTravelGasolineSlider, carTravelGasolineLabel, " km/L");
|
||||
addSliderListenerCarUsage(carTravelDieselSlider, carTravelDieselLabel, " km/L");
|
||||
addSliderListenerCarUsage(carTravelElectricSlider, carTravelElectricLabel, " km/Le");
|
||||
|
||||
cleanEnergyPurchasedSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
cleanEnergyPurchasedLabel.setText(newValue.intValue() + " %");
|
||||
}
|
||||
});
|
||||
|
||||
waterUsageSlider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
waterUsageLabel.setText(newValue.intValue() + "% of similar households");
|
||||
}
|
||||
});
|
||||
|
||||
addSliderListenerDailyServing(meatFishEggsSlider, meatFishEggsLabel);
|
||||
addSliderListenerDailyServing(grainsBakedGoodsSlider, grainsBakedGoodsLabel);
|
||||
addSliderListenerDailyServing(dairySlider, dairyLabel);
|
||||
addSliderListenerDailyServing(fruitsVegetablesSlider, fruitsVegetablesLabel);
|
||||
addSliderListenerDailyServing(snacksDrinksSlider, snacksDrinksLabel);
|
||||
|
||||
addSliderListenerGoodsServices(goodsSlider, goodsLabel);
|
||||
addSliderListenerGoodsServices(servicesSlider, servicesLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* adds the listener to the given slider and displays it's output on a given label.
|
||||
* @param slider the slider to attach the listener to.
|
||||
* @param label the label to display the slider output on.
|
||||
*/
|
||||
private void addSliderListenerCarUsage(Slider slider, Label label, String unit) {
|
||||
slider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
label.setText(newValue.intValue() + unit);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
private void addSliderListenerDailyServing(Slider slider, Label label) {
|
||||
DecimalFormat df = new DecimalFormat("0.0");
|
||||
slider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
label.setText(df.format(newValue.doubleValue()) + " daily servings per person");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addSliderListenerGoodsServices(Slider slider, Label label) {
|
||||
slider.valueProperty().addListener(new ChangeListener<Number>() {
|
||||
@Override
|
||||
public void changed(ObservableValue<? extends Number> observable,
|
||||
Number oldValue, Number newValue) {
|
||||
label.setText(newValue.intValue() + "€ / month");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* adds a fade transition to the given node.
|
||||
* @param node the node to add the transition to
|
||||
*/
|
||||
public void addFadeTransAnimation(Node node) {
|
||||
FadeTransition fade = new FadeTransition(Duration.millis(350), node);
|
||||
fade.setFromValue(0);
|
||||
fade.setToValue(1.0);
|
||||
TranslateTransition trans = new TranslateTransition(Duration.millis(350), node);
|
||||
trans.setFromY(800);
|
||||
trans.setToY(0);
|
||||
ParallelTransition par = new ParallelTransition();
|
||||
par.setNode(travelPane);
|
||||
par.getChildren().addAll(fade, trans);
|
||||
par.play();
|
||||
}
|
||||
|
||||
private void addSlideInAnimation(Node node) {
|
||||
Timeline timeline = new Timeline();
|
||||
KeyValue keyValue = new KeyValue(node.translateXProperty(), 0, Interpolator.EASE_OUT);
|
||||
KeyFrame keyFrame = new KeyFrame(Duration.millis(600), keyValue);
|
||||
timeline.getKeyFrames().add(keyFrame);
|
||||
timeline.play();
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'get started' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayGetStarted(ActionEvent event) {
|
||||
addFadeTransAnimation(getStartedPane);
|
||||
getStartedPane.setVisible(true);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
extraPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'travel' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayTravel(ActionEvent event) {
|
||||
addFadeTransAnimation(travelPane);
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(true);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
extraPane.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'home' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayHome(ActionEvent event) {
|
||||
addFadeTransAnimation(homePane);
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(true);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
extraPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'food' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayFood(ActionEvent event) {
|
||||
addFadeTransAnimation(foodPane);
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(true);
|
||||
shoppingPane.setVisible(false);
|
||||
extraPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'shopping' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayShopping(ActionEvent event) {
|
||||
addFadeTransAnimation(shoppingPane);
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(true);
|
||||
extraPane.setVisible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* displays the 'Extra' section of the calculator.
|
||||
* Activated when the designated button (navigation button) is clicked
|
||||
* @param event the click of the designated button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void displayExtra(ActionEvent event) throws IOException {
|
||||
addFadeTransAnimation(extraPane);
|
||||
extraPane.getChildren().setAll((Node) Application.load(this.getClass()
|
||||
.getClassLoader().getResource("fxml/extraActivities.fxml")));
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
extraPane.setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The method saves the calculation.
|
||||
* @param event user clicks to button
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void saveCalc(ActionEvent event) throws InterruptedException {
|
||||
getStartedPane.setVisible(false);
|
||||
travelPane.setVisible(false);
|
||||
homePane.setVisible(false);
|
||||
foodPane.setVisible(false);
|
||||
shoppingPane.setVisible(false);
|
||||
if (!annualIncomeLabel.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(), "input_income",
|
||||
annualIncomeLabel.getText());
|
||||
}
|
||||
if (!peopleInHouseHoldLabel.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(), "input_size",
|
||||
peopleInHouseHoldLabel.getText());
|
||||
}
|
||||
checkTransportLabels();
|
||||
checkHousingLabels();
|
||||
checkFoodLabels();
|
||||
if (!goodsLabel.getText().replace(" € / month", "").equals("1520")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_goods_total",
|
||||
goodsLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
if (!servicesLabel.getText().replace(" € / month", "").equals("3428")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_services_total",
|
||||
servicesLabel.getText().replace("€ / month", ""));
|
||||
}
|
||||
try {
|
||||
extraActivityController.updateExtras();
|
||||
} catch (NullPointerException ex) {
|
||||
System.out.println("Continue");
|
||||
}
|
||||
Float firstFootprint = userService.saveFirstFootprint(userService.currentUser.getName());
|
||||
Float footprint = userService.saveFootprint(userService.currentUser.getName());
|
||||
Window owner = saveButton.getScene().getWindow();
|
||||
Stage current = (Stage) owner;
|
||||
current.close();
|
||||
UserController.AlertHelper.showAlert(Alert.AlertType.CONFIRMATION,
|
||||
owner, "Footprint saved!", "Your footprint is saved!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the food labels.
|
||||
*/
|
||||
public void checkFoodLabels() {
|
||||
if (!meatFishEggsLabel.getText().replace(" daily servings per person", "").equals("2.6")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_meatfisheggs",
|
||||
meatFishEggsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!grainsBakedGoodsLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("4.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_cereals",
|
||||
grainsBakedGoodsLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!dairyLabel.getText().replace(" daily servings per person", "").equals("2.4")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_dairy",
|
||||
dairyLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!fruitsVegetablesLabel.getText()
|
||||
.replace(" daily servings per person", "").equals("3.9")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_fruitvegetables",
|
||||
fruitsVegetablesLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
if (!snacksDrinksLabel.getText().replace(" daily servings per person", "").equals("3.7")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_shopping_food_otherfood",
|
||||
snacksDrinksLabel.getText().replace(" daily servings per person", ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the housing labels.
|
||||
*/
|
||||
public void checkHousingLabels() {
|
||||
if (!electricityField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_electricity_dollars",
|
||||
electricityField.getText());
|
||||
}
|
||||
if (!cleanEnergyPurchasedLabel.getText().replace(" %", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_gco2_per_kwh",
|
||||
cleanEnergyPurchasedLabel.getText().replace(" %", ""));
|
||||
}
|
||||
if (!naturalGasField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_naturalgas_dollars",
|
||||
naturalGasField.getText());
|
||||
}
|
||||
if (!heatingOilField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_heatingoil_dollars",
|
||||
heatingOilField.getText());
|
||||
}
|
||||
if (!livingSpaceField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_squarefeet",
|
||||
livingSpaceField.getText());
|
||||
}
|
||||
if (!waterUsageLabel.getText().replace("% of similar households", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_housing_watersewage",
|
||||
waterUsageLabel.getText().replace("% of similar households", ""));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the transport labels.
|
||||
*/
|
||||
public void checkTransportLabels() {
|
||||
if (!publicTransitField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_publictrans",
|
||||
publicTransitField.getText());
|
||||
}
|
||||
if (!airplaneTravelField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_airtotal",
|
||||
airplaneTravelField.getText());
|
||||
}
|
||||
if (!carTravelGasolineField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_miles1",
|
||||
carTravelGasolineField.getText());
|
||||
}
|
||||
if (!carTravelGasolineLabel.getText().replace(" km/L", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_mpg1",
|
||||
carTravelGasolineLabel.getText().replace(" km/L", ""));
|
||||
}
|
||||
if (!carTravelDieselField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_miles2",
|
||||
carTravelDieselField.getText());
|
||||
}
|
||||
if (!carTravelDieselLabel.getText().replace(" km/L", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_mpg2",
|
||||
carTravelDieselLabel.getText().replace(" km/L", ""));
|
||||
}
|
||||
if (!carTravelElectricField.getText().equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_miles3",
|
||||
carTravelElectricField.getText());
|
||||
}
|
||||
if (!carTravelElectricLabel.getText().replace(" km/Le", "").equals("0")) {
|
||||
userService.updateInput(userService.currentUser.getName(),
|
||||
"input_footprint_transportation_mpg3",
|
||||
carTravelElectricLabel.getText().replace(" km/Le", ""));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
public class RegisterButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
* registers button skins.
|
||||
* @param button clicking
|
||||
*/
|
||||
public RegisterButtonSkin(Button button) {
|
||||
super(button);
|
||||
|
||||
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
|
||||
scaleUp.setToX(1.2);
|
||||
scaleUp.setToY(1.2);
|
||||
scaleUp.setNode(button);
|
||||
button.setOnMouseEntered(e -> scaleUp.playFromStart());
|
||||
|
||||
ScaleTransition scaleMiddleDown = new ScaleTransition(Duration.millis(50));
|
||||
|
||||
scaleMiddleDown.setToX(1.1);
|
||||
scaleMiddleDown.setToY(1.1);
|
||||
scaleMiddleDown.setNode(button);
|
||||
button.setOnMousePressed(e -> scaleMiddleDown.playFromStart());
|
||||
|
||||
ScaleTransition scaleMiddleUp = new ScaleTransition(Duration.millis(50));
|
||||
|
||||
scaleMiddleUp.setToX(1.2);
|
||||
scaleMiddleUp.setToY(1.2);
|
||||
scaleMiddleUp.setNode(button);
|
||||
button.setOnMouseReleased(e -> scaleMiddleUp.playFromStart());
|
||||
|
||||
ScaleTransition scaleDown = new ScaleTransition(Duration.millis(200));
|
||||
scaleDown.setToX(1.0);
|
||||
scaleDown.setToY(1.0);
|
||||
scaleDown.setNode(button);
|
||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package greenify.client.controller;
|
||||
|
||||
import com.sun.javafx.scene.control.skin.ButtonSkin;
|
||||
import greenify.client.Application;
|
||||
import greenify.client.rest.UserService;
|
||||
import javafx.animation.ScaleTransition;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.PasswordField;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
import javafx.util.Duration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Class that controls the actions for the login screen.
|
||||
*/
|
||||
@Controller
|
||||
public class UserController {
|
||||
@Autowired
|
||||
UserService userService;
|
||||
|
||||
@FXML
|
||||
private TextField usernameField;
|
||||
@FXML
|
||||
private PasswordField passwordField;
|
||||
@FXML
|
||||
private Button loginButton;
|
||||
@FXML
|
||||
private Button signUpButton;
|
||||
|
||||
public void initialize() {
|
||||
loginButton.setSkin(new LoginButtonSkin(loginButton));
|
||||
signUpButton.setSkin(new LoginButtonSkin(signUpButton));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles when the user clicks on the login button.
|
||||
* it checks if the username and password fields are filled
|
||||
* and gives alerts if they aren't filled in.
|
||||
* @param event the click of the login button
|
||||
* @throws IOException an exception for logging in the user
|
||||
*/
|
||||
@FXML
|
||||
protected void handleLoginButtonAction(ActionEvent event)
|
||||
throws IOException, NoSuchAlgorithmException {
|
||||
Window owner = loginButton.getScene().getWindow(); //get the current window
|
||||
if (usernameField.getText().isEmpty()) {
|
||||
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!",
|
||||
"Please enter your username");
|
||||
//checks if the username field is filled,
|
||||
// and gives an alert if it is not
|
||||
return;
|
||||
} else {
|
||||
System.out.println("Username is " + usernameField.getText());
|
||||
}
|
||||
if (passwordField.getText().isEmpty()) {
|
||||
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!",
|
||||
"Please enter a password");
|
||||
//checks if the password field is filled,
|
||||
// and gives an alert if it is not.
|
||||
return;
|
||||
} else {
|
||||
System.out.println("Password is " + passwordField.getText());
|
||||
}
|
||||
//log the user in with the userService method
|
||||
try {
|
||||
userService.loginUser(usernameField.getText(), passwordField.getText());
|
||||
} catch (HttpClientErrorException ex) {
|
||||
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!",
|
||||
"Your username or password is incorrect!");
|
||||
return;
|
||||
}
|
||||
Stage current = (Stage) owner;
|
||||
//after logging in, close the login window
|
||||
current.close();
|
||||
//open the other dashboard window
|
||||
openDashboard();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the dashboard stage.
|
||||
* @throws IOException exception if fxml file can't be found
|
||||
* @author sem
|
||||
*/
|
||||
private void openDashboard() throws IOException {
|
||||
//load the fxml file
|
||||
Parent dash = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/dashboard.fxml"));
|
||||
Scene scene = new Scene(dash);
|
||||
//add the stylesheet for the CSS
|
||||
scene.getStylesheets().add(Objects.requireNonNull(getClass().getClassLoader()
|
||||
.getResource("stylesheets/dashboardStyle.css")).toExternalForm());
|
||||
Stage appStage = new Stage();
|
||||
appStage.setScene(scene);
|
||||
//set the title
|
||||
appStage.setTitle("Greenify - " + usernameField.getText());
|
||||
appStage.show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for showing the alerts.
|
||||
*/
|
||||
static class AlertHelper {
|
||||
/**
|
||||
* alerts for the login screen.
|
||||
* @param alertType the type of alert
|
||||
* @param owner the owner (window) of the alert
|
||||
* @param title the title given to the displayed alert
|
||||
* @param message the message displayed in the alert
|
||||
*/
|
||||
static void showAlert(Alert.AlertType alertType,
|
||||
Window owner,
|
||||
String title,
|
||||
String message) {
|
||||
Alert alert = new Alert(alertType);
|
||||
alert.setTitle(title);
|
||||
alert.setHeaderText(null);
|
||||
alert.setContentText(message);
|
||||
alert.initOwner(owner);
|
||||
alert.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The method handles the clicking of the register button.
|
||||
* it then opens the register window where the user can register
|
||||
* (handled by RegisterWindowController)
|
||||
* @param event User clicks on the button
|
||||
* @throws Exception when the fxml file couldn't be found
|
||||
*/
|
||||
public void handleRegisterButtonAction(ActionEvent event) throws Exception {
|
||||
Parent registerWindow = Application.load(this.getClass().getClassLoader()
|
||||
.getResource("fxml/RegisterWindow.fxml"));
|
||||
Scene registerScene = new Scene(registerWindow);
|
||||
registerScene.getStylesheets().add(this.getClass().getClassLoader()
|
||||
.getResource("stylesheets/registerWindowStyle.css").toExternalForm());
|
||||
Stage registerStage = new Stage();
|
||||
registerStage.setScene(registerScene);
|
||||
registerStage.setTitle("Enter register credentials");
|
||||
registerStage.show();
|
||||
}
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
public class LoginButtonSkin extends ButtonSkin {
|
||||
/**
|
||||
* method for the skin of login button.
|
||||
* @param button clicking
|
||||
*/
|
||||
public LoginButtonSkin(Button button) {
|
||||
super(button);
|
||||
ScaleTransition scaleUp = new ScaleTransition(Duration.millis(140));
|
||||
scaleUp.setToX(1.1);
|
||||
scaleUp.setToY(1.1);
|
||||
scaleUp.setNode(button);
|
||||
button.setOnMouseEntered(e -> scaleUp.playFromStart());
|
||||
|
||||
ScaleTransition scaleMiddleDown = new ScaleTransition(Duration.millis(50));
|
||||
scaleMiddleDown.setFromX(1.1);
|
||||
scaleMiddleDown.setFromY(1.1);
|
||||
scaleMiddleDown.setToX(1.05);
|
||||
scaleMiddleDown.setToY(1.05);
|
||||
scaleMiddleDown.setNode(button);
|
||||
button.setOnMousePressed(e -> scaleMiddleDown.playFromStart());
|
||||
|
||||
ScaleTransition scaleMiddleUp = new ScaleTransition(Duration.millis(50));
|
||||
scaleMiddleUp.setFromX(1.05);
|
||||
scaleMiddleUp.setFromY(1.05);
|
||||
scaleMiddleUp.setToX(1.1);
|
||||
scaleMiddleUp.setToY(1.1);
|
||||
scaleMiddleUp.setNode(button);
|
||||
button.setOnMouseReleased(e -> scaleMiddleUp.playFromStart());
|
||||
|
||||
ScaleTransition scaleDown = new ScaleTransition(Duration.millis(200));
|
||||
scaleDown.setToX(1.0);
|
||||
scaleDown.setToY(1.0);
|
||||
scaleDown.setNode(button);
|
||||
button.setOnMouseExited(e -> scaleDown.playFromStart());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package greenify.client.features;
|
||||
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.property.SimpleIntegerProperty;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
|
||||
public class Friend {
|
||||
|
||||
private SimpleIntegerProperty place;
|
||||
private SimpleStringProperty friend;
|
||||
private SimpleDoubleProperty score;
|
||||
|
||||
/**
|
||||
* Constructor for a friend.
|
||||
* @param place place in the leaderboard
|
||||
* @param friend name of the user
|
||||
* @param friendScore score of the user
|
||||
*/
|
||||
public Friend(Integer place, String friend, Double friendScore) {
|
||||
this.place = new SimpleIntegerProperty(place);
|
||||
this.friend = new SimpleStringProperty(friend);
|
||||
this.score = new SimpleDoubleProperty(friendScore);
|
||||
}
|
||||
|
||||
public Integer getPlace() {
|
||||
return place.get();
|
||||
}
|
||||
|
||||
public void setPlace(Integer place) {
|
||||
this.place = new SimpleIntegerProperty(place);
|
||||
}
|
||||
|
||||
public String getFriend() {
|
||||
return friend.get();
|
||||
}
|
||||
|
||||
public void setFriend(String name) {
|
||||
this.friend = new SimpleStringProperty(name);
|
||||
}
|
||||
|
||||
public Double getScore() {
|
||||
return score.get();
|
||||
}
|
||||
|
||||
public void setScore(Double score) {
|
||||
this.score = new SimpleDoubleProperty(score);
|
||||
}
|
||||
}
|
||||
92
src/Client/src/main/java/greenify/client/features/Hints.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package greenify.client.features;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
public class Hints {
|
||||
public ArrayList<String> hints;
|
||||
|
||||
public Hints() {
|
||||
this.hints = new ArrayList<String>();
|
||||
initHints();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds all the Strings to the array list.
|
||||
*/
|
||||
private void initHints() {
|
||||
this.hints.add("Buying local produce will not only decrease your carbon "
|
||||
+ "footprint, but it will also help your local economy: A win-win!");
|
||||
this.hints.add("Did you know that a gas oven only uses 6% of its energy "
|
||||
+ "to cook? And an electric oven is not much better at 12%!");
|
||||
this.hints.add("70% of the deforestation of the Amazon rainforest is to provide land "
|
||||
+ "for cattle ranches.");
|
||||
this.hints.add("Research shows that reducing meat consumption can "
|
||||
+ "increase your life span by 3,6 years");
|
||||
this.hints.add("Vegetarians have a lower risk of getting: Heart disease, high blood "
|
||||
+ "pressure, diabetes and cancer than meat eaters.");
|
||||
this.hints.add("The carbon footprint of a vegetarian diet is about half "
|
||||
+ "that of a meat-lover’s diet!");
|
||||
this.hints.add("Cycling is good for the environment and for your body, "
|
||||
+ "so why not grab your bike instead of your car?");
|
||||
this.hints.add("If we could capture all of the sun’s energy shining on the Earth for just "
|
||||
+ "one hour, we could power the entire world for one whole year!");
|
||||
this.hints.add("27,000 trees are cut down every day so we can have toilet paper.");
|
||||
this.hints.add("Recycle glass bottles! A glass bottle made now will take "
|
||||
+ "more than 4,000 years to decompose.");
|
||||
this.hints.add("Don't forget to turn off the lights and heating in rooms"
|
||||
+ " you're not using at the moment. Save some energy!");
|
||||
this.hints.add("Did you know that about 4,5% of the Dutch population does not eat meat?");
|
||||
this.hints.add("Reuse your bags when you go grocery shopping. You will save "
|
||||
+ "plastic bags and won't have a lot of unused bags at home!");
|
||||
this.hints.add("An estimated 250 million trees can be saved each year "
|
||||
+ "if every published newspaper would be recycled!");
|
||||
this.hints.add("About 88,000 jobs were created in 2015 through the wind power sector. "
|
||||
+ "That is a lot of jobs");
|
||||
this.hints.add("You can use LED lights in your home to save energy! "
|
||||
+ "They make light from about 85% of their energy");
|
||||
this.hints.add("If you isolate your home well, it will be warmer, "
|
||||
+ "and you'll save energy as well! No need to wear sweaters anymore");
|
||||
this.hints.add("Do you have leftovers? Donate them to food kitchens."
|
||||
+ " This way you won't waste"
|
||||
+ " food, and you'll help a lot of people at the same time!");
|
||||
this.hints.add("A lot of coffee places give you a discount if you bring your own cup. "
|
||||
+ "Get rid of disposable cups!");
|
||||
this.hints.add("When shopping, look for products with minimal to no packaging, "
|
||||
+ "or packaging made from recycled items. ");
|
||||
this.hints.add("If you order food, you can ask the restaurant to not include "
|
||||
+ "utensils and napkins, it saves plastic and paper!");
|
||||
this.hints.add("It takes about 66 days to form a new habit, keep going, you'll get there!");
|
||||
this.hints.add("Get yourself a nice reusable water bottle! It's cheaper and better for "
|
||||
+ "the environment to refill than to buy one every time it's empty.");
|
||||
this.hints.add("Only 1% of our planet’s water supply can be used a drinkwater."
|
||||
+ " 97% is ocean water and 2% is frozen solid in the Arctic, for now.");
|
||||
this.hints.add("For every two million tons of paper and glass, collected in "
|
||||
+ "the Netherlands, close to 90% gets recycled and used to make new products");
|
||||
this.hints.add("In the Netherlands: Whenever you purchase any new, electronic or household "
|
||||
+ "equipment, you will automatically be charged a ‘recycling tax’ on it. This is "
|
||||
+ "also known as ‘removal tax’, or ‘verwijderingsbijdrage’ in Dutch");
|
||||
this.hints.add("Second only to Germany, the Netherlands leads the world in recycling"
|
||||
+ ", with 65 percent of all waste recycled.");
|
||||
this.hints.add("If tbe back of your fridge is dusty, it can increase "
|
||||
+ "energy consumption by 30 per cent.");
|
||||
this.hints.add("Underinflated tyres decrease fuel economy by up to three percent and"
|
||||
+ " lead to increased pollution and higher greenhouse gas emissions.");
|
||||
this.hints.add("Meat production is extremely resource-intensive. "
|
||||
+ "If you gave it up just once a week, you would save the 840 gallons "
|
||||
+ "of fresh water it takes to produce a single serving.");
|
||||
this.hints.add("Plastic bad, very bad.");
|
||||
}
|
||||
|
||||
/**
|
||||
* This seeks out a random hint from the list of strings.
|
||||
* @return the random string hint.
|
||||
*/
|
||||
public String randomHint() {
|
||||
Random rand = new Random();
|
||||
int index = rand.nextInt(this.hints.size());
|
||||
return this.hints.get(index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
394
src/Client/src/main/java/greenify/client/rest/UserService.java
Normal file
@@ -0,0 +1,394 @@
|
||||
package greenify.client.rest;
|
||||
|
||||
import greenify.common.UserDto;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.http.HttpEntity;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class UserService {
|
||||
public UserDto currentUser;
|
||||
|
||||
@Value( "${server.address:http://localhost:8080}" )
|
||||
String serverAddress = "http://localhost:8080";
|
||||
|
||||
@Autowired
|
||||
RestTemplate restTemplate;
|
||||
|
||||
@Bean
|
||||
RestTemplate restTemplate(RestTemplateBuilder builder) {
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the user.
|
||||
* @param name the username of the user
|
||||
* @param password the password of the user
|
||||
* @return a userDTO
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
//this suppressWarnings is to get rid of the errors of duplicate code
|
||||
//because the methods are very similar
|
||||
public UserDto registerUser(String name, String password) throws NoSuchAlgorithmException {
|
||||
//headers for http
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
//set the accept header in JSON value
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
//connect to the server with the needed url
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/registerUser")
|
||||
.queryParam("name", name)
|
||||
//getting the name from the database
|
||||
.queryParam("password", hashPassword(password));
|
||||
//getting the password from the database
|
||||
|
||||
//create a http entity to be sent
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
|
||||
//the result to be sent is a userDto
|
||||
//encodes the userDTO object to a Uri so the database can work with it
|
||||
UserDto result = this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), UserDto.class);
|
||||
this.currentUser = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Signs in the user.
|
||||
* @param name the username of the user
|
||||
* @param password the password of the user
|
||||
* @return a userDTO
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public UserDto loginUser(String name, String password) throws NoSuchAlgorithmException {
|
||||
//this method is almost the same as the registerUser one, but with a different link
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/loginUser")
|
||||
.queryParam("name", name)
|
||||
.queryParam("password", hashPassword(password));
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
UserDto result = this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), UserDto.class);
|
||||
this.currentUser = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the input of the user.
|
||||
* @param name name of the user
|
||||
* @param inputName name of the input
|
||||
* @param value value of the input
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void updateInput(String name, String inputName, String value) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(serverAddress + "/setInput")
|
||||
.queryParam("name", name)
|
||||
.queryParam("inputName", inputName)
|
||||
.queryParam("value",value);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
ResponseEntity<String> authenticateResponse = this.restTemplate.getForEntity(builder.build()
|
||||
.encode().toUri(), String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the extra input of the user.
|
||||
* @param name name of the user
|
||||
* @param inputName name of the input
|
||||
* @param value value of the input
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void updateExtraInput(String name, String inputName, String value) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/setExtraInput")
|
||||
.queryParam("name", name)
|
||||
.queryParam("inputName", inputName)
|
||||
.queryParam("value", value);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
ResponseEntity<String> authenticateResponse = this.restTemplate.getForEntity(builder.build()
|
||||
.encode().toUri(), String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the footprint of the user.
|
||||
* @param name name of the user
|
||||
* @return returns the footprint score
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public double getFootprint(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getFootprint")
|
||||
.queryParam("name", name);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
Float footprint = this.restTemplate.getForObject(builder
|
||||
.build().encode().toUri(), Float.class);
|
||||
double result = Math.round(footprint * 10) / 10.0;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first footprint of the user.
|
||||
* @param name name of the user
|
||||
* @return returns the footprint score
|
||||
*/
|
||||
public double getFirstFootprint(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(serverAddress + "/getFirst")
|
||||
.queryParam("name", name);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
Float footprint = this.restTemplate.getForObject(builder
|
||||
.build().encode().toUri(), Float.class);
|
||||
double result = Math.round(footprint * 10) / 10.0;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the footprint of the user.
|
||||
* @param name name of the user
|
||||
* @return returns the footprint score
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public Float saveFootprint(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/saveFootprint")
|
||||
.queryParam("name", name);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
Float result = this.restTemplate.getForObject(builder
|
||||
.build().encode().toUri(), Float.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Saves the first footprint of the user.
|
||||
* @param name name of the user
|
||||
* @return returns the footprint score
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public Float saveFirstFootprint(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/saveFirstFootprint")
|
||||
.queryParam("name", name);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
Float result = this.restTemplate.getForObject(builder
|
||||
.build().encode().toUri(), Float.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the friend list of the user.
|
||||
* @param name name of the user
|
||||
* @return returns the friend list
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public List<String> getFriendNames(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getFriends")
|
||||
.queryParam("name", name);
|
||||
new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
List<String> result = this.restTemplate.getForObject(builder
|
||||
.build().encode().toUri(), List.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a friend to the user.
|
||||
* @param name the username of the current user.
|
||||
* @param friend the username of the friend you want to add.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void addFriend(String name, String friend) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/addFriend")
|
||||
.queryParam("name", name)
|
||||
.queryParam("friend",friend);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
ResponseEntity<String> authenticateResponse = this.restTemplate.getForEntity(builder.build()
|
||||
.encode().toUri(), String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a friend from the friendslist of the user.
|
||||
* @param name the username of the current user.
|
||||
* @param friend the username of the friend you want to remove.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void removeFriend(String name, String friend) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/removeFriend")
|
||||
.queryParam("name", name)
|
||||
.queryParam("friend",friend);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
ResponseEntity<String> authenticateResponse = this.restTemplate.getForEntity(builder.build()
|
||||
.encode().toUri(), String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the footprint inputs of the user.
|
||||
* @param name the username of the current user.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public Map<String, String> getInputs(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getInputs")
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
Map<String, String> result = this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), Map.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the footprint inputs of the user.
|
||||
* @param name the username of the current user.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public Map<String, String> getExtraInputs(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getExtraInputs")
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
Map<String, String> result = this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), Map.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the achievements of a user.
|
||||
* @param name name of the user
|
||||
* @return Map with all achievements
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public Map getAchievements(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getAchievements")
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
return this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), Map.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the results of a user.
|
||||
* @param name name of the user
|
||||
* @return Map with all results
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public Map<String, String> getResults(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getResults")
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
return this.restTemplate.getForObject(builder.build()
|
||||
.encode().toUri(), Map.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of all users.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public List<String> getAllUsers() {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/getAllUsers");
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
List<String> result = this.restTemplate.getForObject(builder
|
||||
.build().encode().toUri(), List.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a user from the database.
|
||||
* @param name the username of the current user.
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
public void deleteAccount(String name) {
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
|
||||
UriComponentsBuilder builder = UriComponentsBuilder
|
||||
.fromHttpUrl(serverAddress + "/deleteAccount")
|
||||
.queryParam("name", name);
|
||||
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||
System.out.println(builder.build().encode().toUri());
|
||||
ResponseEntity<String> authenticateResponse = this.restTemplate.getForEntity(builder.build()
|
||||
.encode().toUri(), String.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hashes the password of a user.
|
||||
* @param password password of the user
|
||||
* @return hashed password
|
||||
* @throws NoSuchAlgorithmException when there is no such algorithm
|
||||
*/
|
||||
public String hashPassword(String password)
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] encodedHash = digest.digest(password.getBytes(StandardCharsets.UTF_8));
|
||||
StringBuffer hexString = new StringBuffer();
|
||||
for (int i = 0; i < encodedHash.length; i++) {
|
||||
String hex = Integer.toHexString(0xff & encodedHash[i]);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
package main.java.hello;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/*
|
||||
Application that connects to the server
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class Application {
|
||||
private static final Logger log = LoggerFactory.getLogger(Application.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate(RestTemplateBuilder builder) {
|
||||
return builder.build();
|
||||
}
|
||||
@Bean
|
||||
public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
|
||||
return args -> {
|
||||
Message message = restTemplate.getForObject("http://localhost:8080/greeting?name=Ceren", Message.class);
|
||||
log.info(message.toString());
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package main.java.hello;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class Message {
|
||||
|
||||
private long id;
|
||||
private String content;
|
||||
|
||||
public Message() {
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Message{"
|
||||
+ "id='" + id + '\''
|
||||
+ ", content=" + content
|
||||
+ '}';
|
||||
}
|
||||
}
|
||||
1
src/Client/src/main/resources/application.properties
Normal file
@@ -0,0 +1 @@
|
||||
logging.level.org.springframework.beans.factory=DEBUG
|
||||
39
src/Client/src/main/resources/fxml/AddFriend.fxml
Normal file
@@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.scene.control.Button?>
|
||||
<?import javafx.scene.control.TextField?>
|
||||
<?import javafx.scene.image.Image?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
<AnchorPane prefHeight="287.0" prefWidth="187.0" style="-fx-background-color: #e2f0c8;" xmlns="http://javafx.com/javafx/10.0.1" xmlns:fx="http://javafx.com/fxml/1" fx:controller="greenify.client.controller.FriendController">
|
||||
<children>
|
||||
<Text fill="#00650d" layoutX="114.0" layoutY="64.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Add Friend" textAlignment="CENTER" wrappingWidth="234.96600341796875">
|
||||
<font>
|
||||
<Font size="36.0" />
|
||||
</font>
|
||||
</Text>
|
||||
<TextField fx:id="userNameText" layoutX="140.0" layoutY="100.0" prefHeight="35.0" prefWidth="183.0" promptText="Username">
|
||||
<font>
|
||||
<Font size="13.0" />
|
||||
</font>
|
||||
</TextField>
|
||||
<Button fx:id="addButton" layoutX="206.0" layoutY="154.0" mnemonicParsing="false" onAction="#addFriend" style="-fx-background-color: #005e07;" text="Add!" textFill="#c4eec9">
|
||||
<font>
|
||||
<Font name="Corbel Bold" size="14.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<ImageView fitHeight="80.0" fitWidth="349.0" layoutY="211.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/grass.png"/>
|
||||
</image>
|
||||
</ImageView>
|
||||
<ImageView fitHeight="150.0" fitWidth="200.0" layoutY="43.0" pickOnBounds="true" preserveRatio="true">
|
||||
<image>
|
||||
<Image url="@../icons/friends.png" />
|
||||
</image>
|
||||
</ImageView>
|
||||
</children>
|
||||
</AnchorPane>
|
||||