Skip to content

Commit 8713c82

Browse files
committed
Browser UI, work in progress, MAP and ANALYSIS works
1 parent aec7563 commit 8713c82

21 files changed

+580
-67
lines changed

src/main/java/de/isuret/polos/AetherOnePi/domain/AnalysisResult.java

+13
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class AnalysisResult implements Serializable {
1515
private UUID id;
1616
private List<RateObject> rateObjects = new ArrayList<>();
1717
private Integer generalVitality;
18+
private Integer numberOfTrials; // until one of the rates reach the max energetic evaluation threshold
1819

1920
/**
2021
* Make a copy
@@ -82,11 +83,23 @@ public void setGeneralVitality(Integer generalVitality) {
8283
this.generalVitality = generalVitality;
8384
}
8485

86+
public Integer getNumberOfTrials() {
87+
return numberOfTrials;
88+
}
89+
90+
public void setNumberOfTrials(Integer numberOfTrials) {
91+
this.numberOfTrials = numberOfTrials;
92+
}
93+
8594
@Override
8695
public String toString() {
8796
StringBuilder sb = new StringBuilder("--- ANALYSIS ---\n");
8897
sb.append("General Vitality: ").append(generalVitality).append("\n");
8998

99+
if (numberOfTrials != null) {
100+
sb.append("Number of trials: ").append(numberOfTrials).append("\n");
101+
}
102+
90103
for (RateObject rateObject : rateObjects) {
91104
sb.append(rateObject.getNameOrRate());
92105
if (rateObject.getGv() >= generalVitality) {

src/main/java/de/isuret/polos/AetherOnePi/processing2/elements/AnalyseScreen.java

+44-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.text.SimpleDateFormat;
1818
import java.util.Calendar;
1919
import java.util.HashMap;
20+
import java.util.List;
2021
import java.util.Map;
2122

2223
public class AnalyseScreen implements IDrawableElement, MouseClickObserver {
@@ -27,7 +28,9 @@ public class AnalyseScreen implements IDrawableElement, MouseClickObserver {
2728
private boolean mouseClickOccurred = false;
2829
private Long lastMouseClick = null;
2930

31+
private int page = 1;
3032
public final static int MAX_ENTRIES = 21;
33+
public final static int MAX_ENTRIES_INTERNAL = 105;
3134

3235
public AnalyseScreen(AetherOneUI p) {
3336
this.p = p;
@@ -55,7 +58,11 @@ public void draw() {
5558
p.fill(0, 255, 0);
5659
p.text(">> CHECK GENERAL VITALITY <<", 35, 510);
5760
} else {
58-
p.text("GENERAL VITALITY: " + p.getGeneralVitality(), 35, 510);
61+
String trials = "";
62+
if (p.getAnalysisResult().getNumberOfTrials() != null) {
63+
trials = " (runs = " + p.getAnalysisResult().getNumberOfTrials() + ")";
64+
}
65+
p.text("GENERAL VITALITY: " + p.getGeneralVitality() + trials, 35, 510);
5966
}
6067
} else if (p.getAnalysisResult() != null){
6168
p.fill(0, 255, 0);
@@ -132,8 +139,15 @@ public void draw() {
132139
}
133140
}
134141

142+
// Calculate start and end index for the sublist
143+
int startIndex = (page -1) * MAX_ENTRIES;
144+
int endIndex = Math.min(startIndex + MAX_ENTRIES, p.getAnalysisResult().getRateObjects().size());
145+
146+
// Get the sublist based on the paging parameters
147+
List<RateObject> pageList = p.getAnalysisResult().getRateObjects().subList(startIndex, endIndex);
148+
135149
// draw the rate table
136-
for (RateObject rate : p.getAnalysisResult().getRateObjects()) {
150+
for (RateObject rate : pageList) {
137151

138152
// LEVEL
139153
p.fill(255);
@@ -206,7 +220,7 @@ public void draw() {
206220
p.fill(200);
207221
}
208222

209-
p.text(count, 35, y);
223+
p.text(count + ((page - 1) * MAX_ENTRIES), 35, y);
210224
p.text(rate.getEnergeticValue(), 80, y);
211225
p.text(rate.getNameOrRate(), 125, y);
212226
p.text(rate.getGv(), 804, y);
@@ -273,6 +287,33 @@ public void draw() {
273287
if (highestGV != null && highestY != null) {
274288
p.text(highestGV, 764, highestY);
275289
}
290+
291+
// page selection
292+
if (p.getAnalysisResult().getRateObjects().size() > MAX_ENTRIES) {
293+
p.noStroke();
294+
for (int i=0; i < p.getAnalysisResult().getRateObjects().size() / MAX_ENTRIES; i++) {
295+
296+
if (p.mouseX > 930 + ((i) * 22) && p.mouseX < 930 + ((i) * 22) + 22 && p.mouseY > 75 && p.mouseY < 95) {
297+
p.stroke(0,255,0);
298+
if (p.mousePressed) {
299+
page = i + 1;
300+
System.out.println(i);
301+
}
302+
} else {
303+
p.stroke(255);
304+
}
305+
306+
if (page == i + 1) {
307+
p.fill(0, 200, 0);
308+
} else {
309+
p.fill(50, 0, 200);
310+
}
311+
p.rect(930 + (i * 22), 75, 20, 20);
312+
313+
p.fill(255);
314+
p.text(String.valueOf(i+1), 937 + (i * 22), 90);
315+
}
316+
}
276317
}
277318

278319
if (mouseClickOccurred) {

src/main/java/de/isuret/polos/AetherOnePi/processing2/elements/DashboardScreen.java

+28-22
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class DashboardScreen implements IDrawableElement {
1414
private float blinkRate = 0.7f;
1515
private int click = 0;
1616

17+
private boolean showPatreonSection = false;
18+
1719
public DashboardScreen(AetherOneUI p) {
1820
this.p = p;
1921
p.getDataService().init();
@@ -23,6 +25,9 @@ public void run() {
2325
try {
2426
dashboardNews = p.loadStrings(DASHBOARD_NEWS_TXT);
2527
p.saveStrings(TEMPORARY_DASHBOARD_TEXT_TXT, dashboardNews);
28+
if (p.getHotbitsClient().getInteger(0,1000) >= 777) {
29+
showPatreonSection = true;
30+
}
2631
} catch (Exception e) {
2732
dashboardNews = p.loadStrings(TEMPORARY_DASHBOARD_TEXT_TXT);
2833
}
@@ -52,28 +57,29 @@ public void draw() {
5257
click -= 1;
5358
}
5459

55-
blink = blink - blinkRate;
56-
p.stroke(60,179,34,blink);
57-
p.noFill();
58-
p.rect(40,y - 10,400,70);
59-
60-
y += 20;
61-
p.textFont(p.getGuiElements().getFonts().get("default"),32);
62-
p.text("Support me on PATREON", 50, y);
63-
y += 28;
64-
p.textFont(p.getGuiElements().getFonts().get("default"),16);
65-
p.text("and get FREE courses on radionics and homeopathy!", 50, y);
66-
p.fill(60,179,34,blink);
67-
p.text("and get FREE courses on radionics and homeopathy!", 50, y);
68-
y += 20;
69-
if (p.mouseX >= 40 && p.mouseX < 400 && p.mouseY < y && p.mouseY >= y - 70) {
70-
p.noStroke();
71-
p.fill(0,255,0,40f);
72-
p.rect(40, y - 78, 400, 70);
73-
74-
if (p.mousePressed && click == 0) {
75-
click = 100;
76-
p.getAetherOneEventHandler().openWebsiteInDefaultBrowser("https://patreon.com/aetherone");
60+
if (showPatreonSection) {
61+
blink = blink - blinkRate;
62+
p.stroke(60,179,34,blink);
63+
p.noFill();
64+
p.rect(40,y - 10,400,70);
65+
y += 20;
66+
p.textFont(p.getGuiElements().getFonts().get("default"), 32);
67+
p.text("Support me on PATREON", 50, y);
68+
y += 28;
69+
p.textFont(p.getGuiElements().getFonts().get("default"), 16);
70+
p.text("and get FREE courses on radionics and homeopathy!", 50, y);
71+
p.fill(60, 179, 34, blink);
72+
p.text("and get FREE courses on radionics and homeopathy!", 50, y);
73+
y += 20;
74+
if (p.mouseX >= 40 && p.mouseX < 400 && p.mouseY < y && p.mouseY >= y - 70) {
75+
p.noStroke();
76+
p.fill(0, 255, 0, 40f);
77+
p.rect(40, y - 78, 400, 70);
78+
79+
if (p.mousePressed && click == 0) {
80+
click = 100;
81+
p.getAetherOneEventHandler().openWebsiteInDefaultBrowser("https://patreon.com/aetherone");
82+
}
7783
}
7884
}
7985

src/main/java/de/isuret/polos/AetherOnePi/server/AetherOneServer.java

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.databind.DeserializationFeature;
44
import com.fasterxml.jackson.databind.ObjectMapper;
55
import de.isuret.polos.AetherOnePi.domain.*;
6+
import de.isuret.polos.AetherOnePi.processing2.AetherOneConstants;
67
import de.isuret.polos.AetherOnePi.processing2.AetherOneUI;
78
import de.isuret.polos.AetherOnePi.utils.AetherOnePiProcessingConfiguration;
89
import io.javalin.Javalin;
@@ -119,11 +120,14 @@ public void init(Location location) {
119120

120121
app.get("rates", ctx-> ctx.json(p.getDataService().getDatabaseNames()));
121122
app.get("analysis", ctx-> ctx.json(p.getAnalysisResult()));
123+
app.post("analysis", ctx-> ctx.json(p.getAnalyseService().analyseRateList(p.getDataService().findAllBySourceName(p.getSelectedDatabase()))));
124+
app.post("gv", ctx-> ctx.json(String.format("{\"gv\":\"%d\"}",p.checkGeneralVitalityValue())));
122125

123126
app.post("broadcast", ctx -> {
124127
String json = ctx.body();
125128
BroadcastRequest request = objectMapper.readValue(json, BroadcastRequest.class);
126129
p.getAetherOneEventHandler().broadcast(request.getSignature(), request.getSeconds());
130+
p.getGuiElements().selectCurrentTab(AetherOneConstants.BROADCAST);
127131
});
128132

129133
//--- WebSocket

src/main/java/de/isuret/polos/AetherOnePi/service/AnalysisService.java

+7-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public AnalysisResult analyseRateList(Iterable<Rate> rates) {
5959

6060
int max = rateList.size() / 10;
6161
if (max > MAX_RATELIST_SIZE) max = MAX_RATELIST_SIZE;
62-
if (max < 21) max = 21;
62+
if (max < 120) max = 120;
6363
int count = 0;
6464

6565
/**
@@ -84,9 +84,12 @@ public AnalysisResult analyseRateList(Iterable<Rate> rates) {
8484
/**
8585
* Add energetic value
8686
*/
87+
int trials = 0;
88+
8789
while (!analysisFinished) {
8890
for (String rate : ratesValues.keySet()) {
8991

92+
trials++;
9093
Integer energeticValue = ratesValues.get(rate);
9194

9295
energeticValue += hotbitsClient.getInteger(10);
@@ -109,6 +112,8 @@ public AnalysisResult analyseRateList(Iterable<Rate> rates) {
109112
}
110113
}
111114

115+
analysisResult.setNumberOfTrials(trials);
116+
112117
if (piService != null) {
113118
piService.high(AetherOnePins.CONTROL);
114119
}
@@ -117,7 +122,7 @@ public AnalysisResult analyseRateList(Iterable<Rate> rates) {
117122
RateUtils.insertRate(analysisResult, ratesValues, rate);
118123
}
119124

120-
AnalysisResult sortedResult = analysisResult.sort().shorten(AnalyseScreen.MAX_ENTRIES);
125+
AnalysisResult sortedResult = analysisResult.sort().shorten(AnalyseScreen.MAX_ENTRIES_INTERNAL);
121126

122127
// now check the level, from physical to spiritual, 1 to 12
123128
for (RateObject rateObject : sortedResult.getRateObjects()) {

src/main/java/de/isuret/polos/AetherOnePi/service/DataService.java

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import de.isuret.polos.AetherOnePi.domain.Case;
55
import de.isuret.polos.AetherOnePi.domain.DashboardInformations;
66
import de.isuret.polos.AetherOnePi.domain.Rate;
7+
import de.isuret.polos.AetherOnePi.domain.osm.MapDesign;
78
import org.apache.commons.io.FileUtils;
89
import org.apache.commons.logging.Log;
910
import org.apache.commons.logging.LogFactory;
@@ -174,6 +175,11 @@ public void saveCase(Case caseObject) throws IOException {
174175
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy.MM.dd-HHmmss");
175176
caseObject.setName(currentDateTime.format(formatter));
176177
}
178+
if (caseObject.getMapDesign() == null) {
179+
MapDesign mapDesign = new MapDesign();
180+
mapDesign.setUuid(UUID.randomUUID());
181+
caseObject.setMapDesign(mapDesign);
182+
}
177183
if (caseObject.getMapDesign().getUuid() == null) {
178184
caseObject.getMapDesign().setUuid(UUID.randomUUID());
179185
}

0 commit comments

Comments
 (0)