mirror of
https://github.com/MistWeatherMedia/WeatherSTAR-3000-Java.git
synced 2026-11-28 14:38:08 -08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ecfc3c965 | ||
|
|
7396be94c9 | ||
|
|
e501a99559 | ||
|
|
604fedab47 | ||
|
|
8b50b3b60c | ||
|
|
116a409b6d | ||
|
|
5eb6fade7f | ||
|
|
6c608360d1 | ||
|
|
bca69d3ab1 |
No files matched your search
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>WS3000</groupId>
|
<groupId>WS3000</groupId>
|
||||||
<artifactId>weatherstar3000</artifactId>
|
<artifactId>weatherstar3000</artifactId>
|
||||||
<version>1.2.3</version>
|
<version>1.5.0</version>
|
||||||
|
|
||||||
<name>weatherstar3000</name>
|
<name>weatherstar3000</name>
|
||||||
<url>https://github.com/MistWeatherMedia/WeatherSTAR-3000-Java</url>
|
<url>https://github.com/MistWeatherMedia/WeatherSTAR-3000-Java</url>
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 19 KiB |
@@ -13,6 +13,7 @@ public class DataRunner extends Thread {
|
|||||||
Main.outlook = new Outlook();
|
Main.outlook = new Outlook();
|
||||||
Main.travelForecast = new TravelForecast();
|
Main.travelForecast = new TravelForecast();
|
||||||
Main.bulletin = new Bulletin();
|
Main.bulletin = new Bulletin();
|
||||||
|
Main.tides = new Tides();
|
||||||
|
|
||||||
Main.currentConditions.start();
|
Main.currentConditions.start();
|
||||||
Main.hourlyObservations.start();
|
Main.hourlyObservations.start();
|
||||||
@@ -24,6 +25,7 @@ public class DataRunner extends Thread {
|
|||||||
Main.outlook.start();
|
Main.outlook.start();
|
||||||
Main.travelForecast.start();
|
Main.travelForecast.start();
|
||||||
Main.bulletin.start();
|
Main.bulletin.start();
|
||||||
|
Main.tides.start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Main.currentConditions.join();
|
Main.currentConditions.join();
|
||||||
@@ -36,6 +38,7 @@ public class DataRunner extends Thread {
|
|||||||
Main.outlook.join();
|
Main.outlook.join();
|
||||||
Main.travelForecast.join();
|
Main.travelForecast.join();
|
||||||
Main.bulletin.join();
|
Main.bulletin.join();
|
||||||
|
Main.tides.join();
|
||||||
LoadingScreen.dataFinish = true;
|
LoadingScreen.dataFinish = true;
|
||||||
SlidesRunner.collectingData = false;
|
SlidesRunner.collectingData = false;
|
||||||
//ystem.out.println("data finished, destroying thread");
|
//ystem.out.println("data finished, destroying thread");
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ public class LocalForecast extends Thread {
|
|||||||
JSONArray alertData = JSONResponse.getJSONArray("alerts");
|
JSONArray alertData = JSONResponse.getJSONArray("alerts");
|
||||||
StringBuilder fullText = new StringBuilder();
|
StringBuilder fullText = new StringBuilder();
|
||||||
|
|
||||||
|
fullText.setLength(0);
|
||||||
|
|
||||||
for (int i = 0; i < alertData.length(); i++) {
|
for (int i = 0; i < alertData.length(); i++) {
|
||||||
if (utl.isHeadline(alertData.getJSONObject(i).getString("eventDescription"))) {
|
if (utl.isHeadline(alertData.getJSONObject(i).getString("eventDescription"))) {
|
||||||
if (!fullText.isEmpty()) {fullText.append(" *NEWLINE* ");}
|
if (!fullText.isEmpty()) {fullText.append(" *NEWLINE* ");}
|
||||||
@@ -80,9 +82,15 @@ public class LocalForecast extends Thread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] splitwords = fullText.toString().split("\\s+");
|
words.clear();
|
||||||
|
|
||||||
words.addAll(Arrays.asList(splitwords));
|
if (!fullText.isEmpty()) {
|
||||||
|
String[] splitwords = fullText.toString().split("\\s+");
|
||||||
|
|
||||||
|
words.addAll(Arrays.asList(splitwords));
|
||||||
|
} else {
|
||||||
|
words.add("NOBULLETIN");
|
||||||
|
}
|
||||||
|
|
||||||
return words;
|
return words;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -94,6 +94,10 @@ public class RegionalForecast extends Thread {
|
|||||||
ArrayList<String> regForIcaos = new ArrayList<>();
|
ArrayList<String> regForIcaos = new ArrayList<>();
|
||||||
regForIcaos.addAll(Main.regForIcaos);
|
regForIcaos.addAll(Main.regForIcaos);
|
||||||
String key = Main.key;
|
String key = Main.key;
|
||||||
|
Main.regionalForecast.locName.clear();
|
||||||
|
Main.regionalForecast.condition.clear();
|
||||||
|
Main.regionalForecast.low.clear();
|
||||||
|
Main.regionalForecast.high.clear();
|
||||||
for (int i = 0; i < regForIcaos.size(); i++) {
|
for (int i = 0; i < regForIcaos.size(); i++) {
|
||||||
Main.regionalForecast.locName.add(getLocName(regForNames.get(i)));
|
Main.regionalForecast.locName.add(getLocName(regForNames.get(i)));
|
||||||
Main.regionalForecast.condition.add(getCondition(regForIcaos.get(i), key));
|
Main.regionalForecast.condition.add(getCondition(regForIcaos.get(i), key));
|
||||||
|
|||||||
@@ -94,6 +94,9 @@ public class SlidesRunner extends Scene {
|
|||||||
ArrayList<String> olMainLines = new ArrayList<>();
|
ArrayList<String> olMainLines = new ArrayList<>();
|
||||||
private GameObject[] olPool = new GameObject[288];
|
private GameObject[] olPool = new GameObject[288];
|
||||||
|
|
||||||
|
ArrayList<String> tiMainLines = new ArrayList<>();
|
||||||
|
private GameObject[] tiPool = new GameObject[288];
|
||||||
|
|
||||||
ArrayList<String> travelMainLines = new ArrayList<>();
|
ArrayList<String> travelMainLines = new ArrayList<>();
|
||||||
private GameObject[] tfPool = new GameObject[864];
|
private GameObject[] tfPool = new GameObject[864];
|
||||||
|
|
||||||
@@ -113,9 +116,11 @@ public class SlidesRunner extends Scene {
|
|||||||
private boolean poolsInit = false;
|
private boolean poolsInit = false;
|
||||||
private boolean slideInit = false;
|
private boolean slideInit = false;
|
||||||
|
|
||||||
|
private int tinterval = 0;
|
||||||
|
|
||||||
GameObject tBanner;
|
GameObject tBanner;
|
||||||
TravelForecast tfData;
|
TravelForecast tfData;
|
||||||
int travelOffset = 0;
|
float travelOffset = 0.0f;
|
||||||
boolean travelDataInit = false;
|
boolean travelDataInit = false;
|
||||||
boolean travelForecastActive = false;
|
boolean travelForecastActive = false;
|
||||||
|
|
||||||
@@ -141,7 +146,8 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
float slideLength = 600.0f;//length in frames
|
float slideLength = 600.0f;//length in frames
|
||||||
int slideIdx = 0;
|
int slideIdx = 0;
|
||||||
String[] slideLineup;
|
ArrayList<String> slideLineup;
|
||||||
|
ArrayList<Float> slideDurations;
|
||||||
boolean loop;
|
boolean loop;
|
||||||
boolean ending = false;
|
boolean ending = false;
|
||||||
int slideRounds = 0;
|
int slideRounds = 0;
|
||||||
@@ -160,7 +166,23 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
crawlingText = Main.adCrawl + " ";
|
crawlingText = Main.adCrawl + " ";
|
||||||
loop = Main.loopSlides;
|
loop = Main.loopSlides;
|
||||||
slideLineup = Main.slidesList;
|
|
||||||
|
try {
|
||||||
|
slideLineup = utl.loadSegments(Main.selectedFlavor);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Exception loading flavor segments");
|
||||||
|
System.exit(100);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
slideDurations = utl.loadDurations(Main.selectedFlavor);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Exception loading flavor durations");
|
||||||
|
System.exit(101);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
if (Main.greenScreen) {
|
if (Main.greenScreen) {
|
||||||
backgroundColor = greenScreen;
|
backgroundColor = greenScreen;
|
||||||
}
|
}
|
||||||
@@ -284,6 +306,11 @@ public class SlidesRunner extends Scene {
|
|||||||
olPool[i] = new GameObject("alPool" + i, new Transform(new Vector2f()), 0);
|
olPool[i] = new GameObject("alPool" + i, new Transform(new Vector2f()), 0);
|
||||||
olPool[i].addComponent(new SpriteRenderer(new Vector4f(1,1,1,1)));
|
olPool[i].addComponent(new SpriteRenderer(new Vector4f(1,1,1,1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < tiPool.length; i++) {
|
||||||
|
tiPool[i] = new GameObject("tiPool" + i, new Transform(new Vector2f()), 0);
|
||||||
|
tiPool[i].addComponent(new SpriteRenderer(new Vector4f(1,1,1,1)));
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < tfPool.length; i++) {
|
for (int i = 0; i < tfPool.length; i++) {
|
||||||
tfPool[i] = new GameObject("tfPool" + i, new Transform(new Vector2f()), 0);
|
tfPool[i] = new GameObject("tfPool" + i, new Transform(new Vector2f()), 0);
|
||||||
@@ -291,12 +318,12 @@ public class SlidesRunner extends Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < dtPool.length; i++) {
|
for (int i = 0; i < dtPool.length; i++) {
|
||||||
dtPool[i] = new GameObject("tfPool" + i, new Transform(new Vector2f()), 2);
|
dtPool[i] = new GameObject("dtPool" + i, new Transform(new Vector2f()), 2);
|
||||||
dtPool[i].addComponent(new SpriteRenderer(new Vector4f(1,1,1,1)));
|
dtPool[i].addComponent(new SpriteRenderer(new Vector4f(1,1,1,1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < ctPool.length; i++) {
|
for (int i = 0; i < ctPool.length; i++) {
|
||||||
ctPool[i] = new GameObject("tfPool" + i, new Transform(new Vector2f()), 2);
|
ctPool[i] = new GameObject("ctPool" + i, new Transform(new Vector2f()), 2);
|
||||||
ctPool[i].addComponent(new SpriteRenderer(new Vector4f(1,1,1,1)));
|
ctPool[i].addComponent(new SpriteRenderer(new Vector4f(1,1,1,1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,20 +392,13 @@ public class SlidesRunner extends Scene {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Window.slidesSecFrameCount % slideLength == 0) {
|
if (Window.slidesSecFrameCount % slideLength == 0) {
|
||||||
|
|
||||||
if (ending && !bulletinActive) {
|
|
||||||
System.exit(0);
|
|
||||||
audioManager.close();
|
|
||||||
//glfwSetWindowShouldClose(Window.getGLFWWindow(), true);
|
|
||||||
//Main.settingsWindow.setVisible(true);
|
|
||||||
}
|
|
||||||
travelForecastActive = false;
|
travelForecastActive = false;
|
||||||
travelDataInit = false;
|
travelDataInit = false;
|
||||||
slideInit = false;
|
slideInit = false;
|
||||||
round++;
|
round++;
|
||||||
if (round >= slideRounds) {
|
if (round >= slideRounds) {
|
||||||
slideIdx++;
|
slideIdx++;
|
||||||
if (slideIdx >= slideLineup.length) {
|
if (slideIdx >= slideLineup.size()) {
|
||||||
slideIdx = 0;
|
slideIdx = 0;
|
||||||
if (!loop) {
|
if (!loop) {
|
||||||
ending = true;
|
ending = true;
|
||||||
@@ -397,9 +417,26 @@ public class SlidesRunner extends Scene {
|
|||||||
round = 0;
|
round = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ending && !bulletinActive) {
|
||||||
|
System.exit(0);
|
||||||
|
audioManager.close();
|
||||||
|
//glfwSetWindowShouldClose(Window.getGLFWWindow(), true);
|
||||||
|
//Main.settingsWindow.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
slideLength = slideDurations.get(slideIdx);
|
||||||
slideChooser();
|
slideChooser();
|
||||||
|
|
||||||
if (travelForecastActive) {
|
if (travelForecastActive) {
|
||||||
if (Window.secFrameCount % 2 == 0) travelOffset--;
|
if (Window.secFrameCount % 2 == 0) {
|
||||||
|
travelOffset--;
|
||||||
|
tinterval++;
|
||||||
|
if (tinterval == 3) {
|
||||||
|
travelOffset--;
|
||||||
|
tinterval = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
travelForecast();
|
travelForecast();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -587,7 +624,6 @@ public class SlidesRunner extends Scene {
|
|||||||
}
|
}
|
||||||
public void currentConditions() {
|
public void currentConditions() {
|
||||||
slideRounds = 0;
|
slideRounds = 0;
|
||||||
slideLength = 600.0f;
|
|
||||||
this.addGameObjectToScene(bg);
|
this.addGameObjectToScene(bg);
|
||||||
|
|
||||||
if (!slideInit) {
|
if (!slideInit) {
|
||||||
@@ -638,7 +674,6 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
public void hourlyObservations() {
|
public void hourlyObservations() {
|
||||||
slideRounds = 0;
|
slideRounds = 0;
|
||||||
slideLength = 600.0f;
|
|
||||||
this.addGameObjectToScene(bg);
|
this.addGameObjectToScene(bg);
|
||||||
|
|
||||||
if (!slideInit) {
|
if (!slideInit) {
|
||||||
@@ -687,7 +722,6 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
public void regionalConditions() {
|
public void regionalConditions() {
|
||||||
slideRounds = 0;
|
slideRounds = 0;
|
||||||
slideLength = 600.0f;
|
|
||||||
this.addGameObjectToScene(bg);
|
this.addGameObjectToScene(bg);
|
||||||
|
|
||||||
if (!slideInit) {
|
if (!slideInit) {
|
||||||
@@ -737,7 +771,6 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
public void localForecast() {
|
public void localForecast() {
|
||||||
slideRounds = 3;
|
slideRounds = 3;
|
||||||
slideLength = 600.0f;
|
|
||||||
this.addGameObjectToScene(bg);
|
this.addGameObjectToScene(bg);
|
||||||
|
|
||||||
if (!slideInit) {
|
if (!slideInit) {
|
||||||
@@ -751,7 +784,7 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
if (lfData.bulletin.get(0) == "NOBULLETIN") {
|
if (!lfData.bulletin.get(0).equals("NOBULLETIN")) {
|
||||||
for (int i = 0; i <= lfData.bulletin.size()-1; i++) {
|
for (int i = 0; i <= lfData.bulletin.size()-1; i++) {
|
||||||
if (lfData.bulletin.get(i).equals("*NEWLINE*")) {
|
if (lfData.bulletin.get(i).equals("*NEWLINE*")) {
|
||||||
lfbMainLines.add("*" + utl.cjust(sb.toString(), 30, " ") + "*");
|
lfbMainLines.add("*" + utl.cjust(sb.toString(), 30, " ") + "*");
|
||||||
@@ -771,7 +804,7 @@ public class SlidesRunner extends Scene {
|
|||||||
lfbMainLines.add("*" + utl.cjust(sb.toString(), 30, " ") + "*");
|
lfbMainLines.add("*" + utl.cjust(sb.toString(), 30, " ") + "*");
|
||||||
sb.setLength(0);
|
sb.setLength(0);
|
||||||
} else {
|
} else {
|
||||||
lfbMainLines.add(utl.ljust("", 32, " "));
|
lfbMainLines.add("NOTHING");
|
||||||
}
|
}
|
||||||
sb.setLength(0);
|
sb.setLength(0);
|
||||||
|
|
||||||
@@ -818,15 +851,25 @@ public class SlidesRunner extends Scene {
|
|||||||
sb.setLength(0);
|
sb.setLength(0);
|
||||||
|
|
||||||
int linesPassed = 0;
|
int linesPassed = 0;
|
||||||
if (lfbMainLines.get(0) == " " || forecastOneLines.size() > 7) {
|
|
||||||
for (int i = 0; i <= lfbMainLines.size()-1; i++) {
|
if (lfbMainLines.get(0).equals("NOTHING") && forecastOneLines.size() < 8) {
|
||||||
lfMainLines.add(lfbMainLines.get(i));
|
|
||||||
linesPassed++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lfMainLines.add(utl.ljust("", 32, " "));
|
lfMainLines.add(utl.ljust("", 32, " "));
|
||||||
linesPassed++;
|
linesPassed++;
|
||||||
|
} else {
|
||||||
|
if (!lfbMainLines.get(0).equals("NOTHING")) {
|
||||||
|
for (int i = 0; i <= lfbMainLines.size()-1; i++) {
|
||||||
|
lfMainLines.add(lfbMainLines.get(i));
|
||||||
|
linesPassed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forecastOneLines.size() < 7 - linesPassed) {
|
||||||
|
lfMainLines.add(utl.ljust("", 32, " "));
|
||||||
|
linesPassed++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//then add first forecast
|
||||||
for (int i = 0; i <= forecastOneLines.size()-1; i++) {
|
for (int i = 0; i <= forecastOneLines.size()-1; i++) {
|
||||||
lfMainLines.add(forecastOneLines.get(i));
|
lfMainLines.add(forecastOneLines.get(i));
|
||||||
linesPassed++;
|
linesPassed++;
|
||||||
@@ -835,6 +878,8 @@ public class SlidesRunner extends Scene {
|
|||||||
lfMainLines.add(utl.ljust("", 32, " "));
|
lfMainLines.add(utl.ljust("", 32, " "));
|
||||||
linesPassed++;
|
linesPassed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//next screen
|
||||||
lfMainLines.add(utl.ljust("", 32, " "));
|
lfMainLines.add(utl.ljust("", 32, " "));
|
||||||
linesPassed++;
|
linesPassed++;
|
||||||
for (int i = 0; i <= forecastTwoLines.size()-1; i++) {
|
for (int i = 0; i <= forecastTwoLines.size()-1; i++) {
|
||||||
@@ -913,7 +958,6 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
public void almanac() {
|
public void almanac() {
|
||||||
slideRounds = 0;
|
slideRounds = 0;
|
||||||
slideLength = 600.0f;
|
|
||||||
this.addGameObjectToScene(bg);
|
this.addGameObjectToScene(bg);
|
||||||
|
|
||||||
if (!slideInit) {
|
if (!slideInit) {
|
||||||
@@ -966,7 +1010,6 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
public void regionalForecast() {
|
public void regionalForecast() {
|
||||||
slideRounds = 0;
|
slideRounds = 0;
|
||||||
slideLength = 600.0f;
|
|
||||||
this.addGameObjectToScene(bg);
|
this.addGameObjectToScene(bg);
|
||||||
|
|
||||||
if (!slideInit) {
|
if (!slideInit) {
|
||||||
@@ -1016,7 +1059,6 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
public void extendedForecast() {
|
public void extendedForecast() {
|
||||||
slideRounds = 0;
|
slideRounds = 0;
|
||||||
slideLength = 600.0f;
|
|
||||||
this.addGameObjectToScene(bg);
|
this.addGameObjectToScene(bg);
|
||||||
|
|
||||||
if (!slideInit) {
|
if (!slideInit) {
|
||||||
@@ -1068,7 +1110,6 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
public void outlook() {
|
public void outlook() {
|
||||||
slideRounds = 0;
|
slideRounds = 0;
|
||||||
slideLength = 600.0f;
|
|
||||||
this.addGameObjectToScene(bg);
|
this.addGameObjectToScene(bg);
|
||||||
|
|
||||||
if (!slideInit) {
|
if (!slideInit) {
|
||||||
@@ -1128,10 +1169,81 @@ public class SlidesRunner extends Scene {
|
|||||||
textY += lineHeight;
|
textY += lineHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void tides() {
|
||||||
|
slideRounds = 0;
|
||||||
|
this.addGameObjectToScene(bg);
|
||||||
|
|
||||||
|
if (!slideInit) {
|
||||||
|
Tides tiData = Main.tides;
|
||||||
|
|
||||||
|
tiMainLines.clear();
|
||||||
|
|
||||||
|
tiMainLines.add(" LOCAL TIDE INFORMATION ");
|
||||||
|
tiMainLines.add(utl.ljust(" ", 32, " "));//half space
|
||||||
|
tiMainLines.add(tiData.locName.get(0));
|
||||||
|
tiMainLines.add("HIGHS: " + tiData.highTide.get(0));
|
||||||
|
tiMainLines.add("LOWS: " + tiData.lowTide.get(0));
|
||||||
|
tiMainLines.add(tiData.locName.get(1));
|
||||||
|
tiMainLines.add("HIGHS: " + tiData.highTide.get(1));
|
||||||
|
tiMainLines.add("LOWS: " + tiData.lowTide.get(1));
|
||||||
|
tiMainLines.add(" SUNRISE" + tiData.sunrise + " SET" + tiData.sunset + " ");
|
||||||
|
|
||||||
|
slideInit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int textX = 81;
|
||||||
|
int textY = 44;
|
||||||
|
int poolIdx = 0;
|
||||||
|
|
||||||
|
for (int row = 0; row < tiMainLines.size(); row++) {
|
||||||
|
int lineHeight = row == 1 ? 22 : 40;
|
||||||
|
String line = tiMainLines.get(row);
|
||||||
|
for (int i = 0; i < line.length(); i ++) {
|
||||||
|
if (poolIdx >= tiPool.length) break;
|
||||||
|
|
||||||
|
char c = line.charAt(i);
|
||||||
|
|
||||||
|
GameObject go = tiPool[poolIdx++];
|
||||||
|
go.transform.position.set(textX, textY);
|
||||||
|
go.transform.scale.set(18, 32);
|
||||||
|
|
||||||
|
SpriteRenderer sr = go.getComponent(SpriteRenderer.class);
|
||||||
|
sr.setSprite(sprites.getSprite(utl.getMainChar(c)));
|
||||||
|
|
||||||
|
|
||||||
|
this.addGameObjectToScene(go);
|
||||||
|
|
||||||
|
if (i % 2 != 0) textX++;
|
||||||
|
textX += 17;
|
||||||
|
}
|
||||||
|
|
||||||
|
textX = 81;
|
||||||
|
textY += lineHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void airQuality() {
|
||||||
|
slideRounds = 0;
|
||||||
|
this.addGameObjectToScene(bg);
|
||||||
|
|
||||||
|
if (!slideInit) {
|
||||||
|
slideInit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void airportDelays() {
|
||||||
|
slideRounds = 0;
|
||||||
|
this.addGameObjectToScene(bg);
|
||||||
|
|
||||||
|
if (!slideInit) {
|
||||||
|
slideInit = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void travelForecast() {
|
public void travelForecast() {
|
||||||
slideLength = 3600.0f;
|
|
||||||
travelForecastActive = true;
|
travelForecastActive = true;
|
||||||
this.addGameObjectToScene(travelBg);
|
this.addGameObjectToScene(travelBg);
|
||||||
|
|
||||||
if (!travelDataInit) {
|
if (!travelDataInit) {
|
||||||
tfData = Main.travelForecast;
|
tfData = Main.travelForecast;
|
||||||
@@ -1250,7 +1362,7 @@ public class SlidesRunner extends Scene {
|
|||||||
|
|
||||||
public void slideChooser() {
|
public void slideChooser() {
|
||||||
//draw slide
|
//draw slide
|
||||||
String slide = slideLineup[slideIdx];
|
String slide = slideLineup.get(slideIdx);
|
||||||
//System.out.println(slide);
|
//System.out.println(slide);
|
||||||
switch (slide) {
|
switch (slide) {
|
||||||
case "currentConditions":
|
case "currentConditions":
|
||||||
@@ -1266,7 +1378,11 @@ public class SlidesRunner extends Scene {
|
|||||||
localForecast();
|
localForecast();
|
||||||
break;
|
break;
|
||||||
case "almanac":
|
case "almanac":
|
||||||
almanac();
|
if (Main.tidesEnabled) {
|
||||||
|
tides();
|
||||||
|
} else {
|
||||||
|
almanac();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "regionalForecast":
|
case "regionalForecast":
|
||||||
regionalForecast();
|
regionalForecast();
|
||||||
|
|||||||
@@ -0,0 +1,121 @@
|
|||||||
|
package WS3000.weatherstar3000;
|
||||||
|
|
||||||
|
import util.Utilities;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.http.HttpClient;
|
||||||
|
import java.net.http.HttpRequest;
|
||||||
|
import java.net.http.HttpResponse;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class Tides extends Thread {
|
||||||
|
Utilities utl = new Utilities();
|
||||||
|
ArrayList<String> locName = new ArrayList<>();
|
||||||
|
ArrayList<String> highTide = new ArrayList<>();
|
||||||
|
ArrayList<String> lowTide = new ArrayList<>();
|
||||||
|
String sunrise;
|
||||||
|
String sunset;
|
||||||
|
|
||||||
|
DateTimeFormatter tideDateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
|
||||||
|
DateTimeFormatter tideTimeFormatter = DateTimeFormatter.ofPattern("h:mma E", Locale.ENGLISH);
|
||||||
|
|
||||||
|
String getLocName(String displayName) {
|
||||||
|
return utl.cjust(displayName, 32, " ").substring(0, 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
String getTides(String station, String tide) {
|
||||||
|
try {
|
||||||
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
|
HttpRequest Request = HttpRequest.newBuilder()
|
||||||
|
.uri(URI.create("https://api.tidesandcurrents.noaa.gov/api/prod/datagetter?begin_date=" + LocalDate.now().format(tideDateFormatter) + "&end_date=" + LocalDate.now().plusDays(1).format(tideDateFormatter) + "&station=" + station + "&product=predictions&datum=MLLW&time_zone=lst_ldt&interval=hilo&units=english&application=DataAPI_Sample&format=json"))
|
||||||
|
.GET()
|
||||||
|
.header("Accept", "application/json")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
||||||
|
if (Response.statusCode() != 200) {
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
String ResponseBody = Response.body();
|
||||||
|
JSONArray predictions = new JSONObject(ResponseBody).getJSONArray("predictions");
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
int j = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < predictions.length(); i++) {
|
||||||
|
if (predictions.getJSONObject(i).getString("type").equals(tide)) {
|
||||||
|
sb.append(utl.rjust(LocalDateTime.parse(predictions.getJSONObject(i).getString("t"), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm")).format(tideTimeFormatter).toUpperCase(Locale.ENGLISH), 11, " "));
|
||||||
|
if (j < 1) sb.append(" ");
|
||||||
|
j++;
|
||||||
|
if (j == 2) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String getSunData(String icaoCode, String key, String type) {
|
||||||
|
HttpClient Client = HttpClient.newBuilder().build();
|
||||||
|
HttpRequest Request = HttpRequest.newBuilder()
|
||||||
|
.uri(URI.create("https://api.weather.com/v3/wx/forecast/daily/7day?icaoCode=" + icaoCode + "&units=e&language=en-US&format=json&apiKey=" + key))
|
||||||
|
.GET()
|
||||||
|
.header("Accept", "application/json")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try {
|
||||||
|
HttpResponse<String> Response = Client.send(Request, HttpResponse.BodyHandlers.ofString());
|
||||||
|
if (Response.statusCode() != 200) {
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
String ResponseBody = Response.body();
|
||||||
|
JSONObject JSONResponse = new JSONObject(ResponseBody);
|
||||||
|
String time = JSONResponse.getJSONArray(type).getString(0);
|
||||||
|
|
||||||
|
int hour = Integer.parseInt(time.substring(11, 13));
|
||||||
|
int dispHour = hour > 12 ? hour - 12 : hour;
|
||||||
|
String minutes = time.substring(14, 16);
|
||||||
|
String part = hour < 12 ? "AM" : "PM";
|
||||||
|
|
||||||
|
return utl.rjust(dispHour + ":" + minutes + part, 7, " ");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
ArrayList<String> tideIDs = new ArrayList<>();
|
||||||
|
tideIDs.addAll(Main.tideIDs);
|
||||||
|
ArrayList<String> tideNames = new ArrayList<>();
|
||||||
|
tideNames.addAll(Main.tideNames);
|
||||||
|
String key = Main.key;
|
||||||
|
Main.tides.highTide.clear();
|
||||||
|
Main.tides.lowTide.clear();
|
||||||
|
for (int i = 0; i < tideIDs.size(); i++) {
|
||||||
|
Main.tides.locName.add(getLocName(Main.tideNames.get(i)));
|
||||||
|
Main.tides.highTide.add(getTides(Main.tideIDs.get(i), "H"));
|
||||||
|
Main.tides.lowTide.add(getTides(Main.tideIDs.get(i), "L"));
|
||||||
|
}
|
||||||
|
Main.tides.sunrise = getSunData(Main.mainIcao, key, "sunriseTimeLocal");
|
||||||
|
Main.tides.sunset = getSunData(Main.mainIcao, key, "sunsetTimeLocal");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import java.io.FileReader;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.json.*;
|
import org.json.*;
|
||||||
@@ -13,24 +14,6 @@ import org.joml.Vector4f;
|
|||||||
public class Utilities {
|
public class Utilities {
|
||||||
public static Map<Character, Integer> mainFontMap = new HashMap<>();
|
public static Map<Character, Integer> mainFontMap = new HashMap<>();
|
||||||
public static Map<Character, Integer> smallFontMap = new HashMap<>();
|
public static Map<Character, Integer> smallFontMap = new HashMap<>();
|
||||||
public static String[] testFlavor = {"outlook","travelForecast", "localForecast", "outlook"};
|
|
||||||
public static String[] flavorA = {"currentConditions","localForecast","hourlyObservations"};
|
|
||||||
public static String[] flavorB = {"hourlyObservations", "almanac", "extendedForecast", "regionalConditions"};
|
|
||||||
public static String[] flavorC = {"regionalConditions", "localForecast", "currentConditions"};
|
|
||||||
public static String[] flavorD = {"hourlyObservations", "almanac", "localForecast", "regionalConditions"};
|
|
||||||
public static String[] flavorE = {"localForecast", "extendedForecast","hourlyObservations"};
|
|
||||||
public static String[] flavorF = {"currentConditions", "regionalConditions", "localForecast", "almanac"};
|
|
||||||
public static String[] flavorG = {"localForecast"};
|
|
||||||
public static String[] flavorH = {"localForecast", "regionalforecast", "almanac", "hourlyObservations"};
|
|
||||||
public static String[] flavorI = {"currentConditions", "hourlyObservations", "regionalConditions"};
|
|
||||||
public static String[] flavorJ = {"currentConditions", "hourlyObservations", "regionalConditions", "localForecast", "almanac", "regionalForecast", "travelForecast", "extendedForecast", "outlook"};
|
|
||||||
public static String[] flavorK = {"currentConditions", "almanac", "regionalForecast", "localForecast", "extendedForecast", "hourlyObservations"};
|
|
||||||
public static String[] flavorL = {"currentConditions", "hourlyObservations", "regionalConditions", "regionalForecast", "almanac", "localForecast", "extendedForecast"};
|
|
||||||
public static String[] flavorM = {"currentConditions", "localForecast", "extendedForecast", "travelForecast"};
|
|
||||||
public static String[] flavorN = {"currentConditions", "hourlyObservations", "regionalConditions", "localForecast", "almanac", "regionalForecast", "travelForecast", "extendedForecast", "outlook", "currentConditions", "localForecast", "extendedForecast", "travelForecast"};
|
|
||||||
public static String[] flavorO = {"currentConditions", "hourlyObservations", "regionalConditions", "localForecast", "almanac", "regionalForecast", "travelForecast", "extendedForecast", "outlook", "currentConditions", "hourlyObservations", "regionalConditions", "localForecast", "almanac", "regionalForecast", "travelForecast", "extendedForecast", "outlook"};
|
|
||||||
public static String[] flavorP = {"localForecast", "extendedForecast", "currentConditions"};
|
|
||||||
public static String[] flavorQ = {"currentConditions", "almanac", "localForecast", "regionalConditions"};
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
mainFontMap.put(' ', 0);
|
mainFontMap.put(' ', 0);
|
||||||
@@ -400,4 +383,34 @@ public class Utilities {
|
|||||||
public void printThirtyTwoLine() {
|
public void printThirtyTwoLine() {
|
||||||
System.out.println("--------------------------------");
|
System.out.println("--------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<String> loadSegments(String flavor) throws IOException {
|
||||||
|
String json = readJsonFromResource("/resources/json/SlidesManager.json");
|
||||||
|
JSONObject jsonObject = new JSONObject(json);
|
||||||
|
|
||||||
|
JSONArray fl = jsonObject.getJSONArray(flavor);
|
||||||
|
|
||||||
|
ArrayList<String> segments = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < fl.length(); i++) {
|
||||||
|
segments.add(fl.getJSONObject(i).getString("segment"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return segments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<Float> loadDurations(String flavor) throws IOException {
|
||||||
|
String json = readJsonFromResource("/resources/json/SlidesManager.json");
|
||||||
|
JSONObject jsonObject = new JSONObject(json);
|
||||||
|
|
||||||
|
JSONArray fl = jsonObject.getJSONArray(flavor);
|
||||||
|
|
||||||
|
ArrayList<Float> segments = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < fl.length(); i++) {
|
||||||
|
segments.add(fl.getJSONObject(i).getFloat("duration"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return segments;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
{
|
||||||
|
"A": [
|
||||||
|
{"segment":"currentConditions", "duration": 600.0},
|
||||||
|
{"segment":"localForecast", "duration": 600.0},
|
||||||
|
{"segment":"hourlyObservations", "duration": 600.0}
|
||||||
|
],
|
||||||
|
"B": [
|
||||||
|
{"segment":"hourlyObservations", "duration": 600.0},
|
||||||
|
{"segment":"almanac", "duration": 600.0},
|
||||||
|
{"segment":"extendedForecast", "duration": 1200.0},
|
||||||
|
{"segment":"regionalConditions", "duration": 600.0}
|
||||||
|
],
|
||||||
|
"C": [
|
||||||
|
{"segment":"regionalConditions", "duration": 600.0},
|
||||||
|
{"segment":"localForecast", "duration": 600.0},
|
||||||
|
{"segment":"regionalForecast", "duration": 600.0}
|
||||||
|
],
|
||||||
|
"D": [
|
||||||
|
{"segment":"hourlyObservations", "duration": 600.0},
|
||||||
|
{"segment":"almanac", "duration": 600.0},
|
||||||
|
{"segment":"localForecast", "duration": 600.0},
|
||||||
|
{"segment":"regionalConditions", "duration": 600.0}
|
||||||
|
],
|
||||||
|
"E": [
|
||||||
|
{"segment":"localForecast", "duration": 600.0},
|
||||||
|
{"segment":"extendedForecast", "duration": 1200.0},
|
||||||
|
{"segment":"hourlyObservations", "duration": 600.0}
|
||||||
|
],
|
||||||
|
"F": [
|
||||||
|
{"segment":"currentConditions", "duration": 600.0},
|
||||||
|
{"segment":"regionalConditions", "duration": 600.0},
|
||||||
|
{"segment":"localForecast", "duration": 600.0},
|
||||||
|
{"segment":"almanac", "duration": 600.0}
|
||||||
|
],
|
||||||
|
"G": [
|
||||||
|
{"segment":"localForecast", "duration": 600.0}
|
||||||
|
],
|
||||||
|
"H": [
|
||||||
|
{"segment":"localForecast", "duration": 600.0},
|
||||||
|
{"segment":"regionalForecast", "duration": 600.0},
|
||||||
|
{"segment":"almanac", "duration": 600.0},
|
||||||
|
{"segment":"regionalConditions", "duration": 600.0}
|
||||||
|
],
|
||||||
|
"I": [
|
||||||
|
{"segment":"currentConditions", "duration": 600.0},
|
||||||
|
{"segment":"hourlyObservations", "duration": 600.0},
|
||||||
|
{"segment":"regionalConditions", "duration": 600.0}
|
||||||
|
],
|
||||||
|
"J": [
|
||||||
|
{"segment":"currentConditions", "duration": 720.0},
|
||||||
|
{"segment":"hourlyObservations", "duration": 720.0},
|
||||||
|
{"segment":"regionalConditions", "duration": 720.0},
|
||||||
|
{"segment":"localForecast", "duration": 720.0},
|
||||||
|
{"segment":"almanac", "duration": 720.0},
|
||||||
|
{"segment":"regionalForecast", "duration": 720.0},
|
||||||
|
{"segment":"travelForecast", "duration": 2880.0},
|
||||||
|
{"segment":"extendedForecast", "duration": 1440.0},
|
||||||
|
{"segment":"outlook", "duration": 720.0}
|
||||||
|
],
|
||||||
|
"K": [
|
||||||
|
{"segment":"currentConditions", "duration": 600.0},
|
||||||
|
{"segment":"almanac", "duration": 600.0},
|
||||||
|
{"segment":"regionalForecast", "duration": 600.0},
|
||||||
|
{"segment":"localForecast", "duration": 600.0},
|
||||||
|
{"segment":"extendedForecast", "duration": 1200.0},
|
||||||
|
{"segment":"hourlyObservations", "duration": 600.0}
|
||||||
|
],
|
||||||
|
"L": [
|
||||||
|
{"segment":"currentConditions", "duration": 720.0},
|
||||||
|
{"segment":"hourlyObservations", "duration": 720.0},
|
||||||
|
{"segment":"regionalConditions", "duration": 720.0},
|
||||||
|
{"segment":"regionalForecast", "duration": 720.0},
|
||||||
|
{"segment":"almanac", "duration": 720.0},
|
||||||
|
{"segment":"localForecast", "duration": 720.0},
|
||||||
|
{"segment":"extendedForecast", "duration": 1440.0}
|
||||||
|
],
|
||||||
|
"M": [
|
||||||
|
{"segment":"currentConditions", "duration": 720.0},
|
||||||
|
{"segment":"localForecast", "duration": 720.0},
|
||||||
|
{"segment":"extendedForecast", "duration": 1440.0},
|
||||||
|
{"segment":"travelForecast", "duration": 2880.0}
|
||||||
|
],
|
||||||
|
"N": [
|
||||||
|
{"segment":"currentConditions", "duration": 720.0},
|
||||||
|
{"segment":"hourlyObservations", "duration": 720.0},
|
||||||
|
{"segment":"regionalConditions", "duration": 720.0},
|
||||||
|
{"segment":"localForecast", "duration": 720.0},
|
||||||
|
{"segment":"almanac", "duration": 720.0},
|
||||||
|
{"segment":"regionalForecast", "duration": 720.0},
|
||||||
|
{"segment":"travelForecast", "duration": 2880.0},
|
||||||
|
{"segment":"extendedForecast", "duration": 1440.0},
|
||||||
|
{"segment":"outlook", "duration": 720.0},
|
||||||
|
{"segment":"currentConditions", "duration": 720.0},
|
||||||
|
{"segment":"localForecast", "duration": 720.0},
|
||||||
|
{"segment":"extendedForecast", "duration": 1440.0},
|
||||||
|
{"segment":"travelForecast", "duration": 2880.0}
|
||||||
|
],
|
||||||
|
"O": [
|
||||||
|
{"segment":"currentConditions", "duration": 720.0},
|
||||||
|
{"segment":"hourlyObservations", "duration": 720.0},
|
||||||
|
{"segment":"regionalConditions", "duration": 720.0},
|
||||||
|
{"segment":"localForecast", "duration": 720.0},
|
||||||
|
{"segment":"almanac", "duration": 720.0},
|
||||||
|
{"segment":"regionalForecast", "duration": 720.0},
|
||||||
|
{"segment":"travelForecast", "duration": 2880.0},
|
||||||
|
{"segment":"extendedForecast", "duration": 1440.0},
|
||||||
|
{"segment":"outlook", "duration": 720.0},
|
||||||
|
{"segment":"currentConditions", "duration": 720.0},
|
||||||
|
{"segment":"hourlyObservations", "duration": 720.0},
|
||||||
|
{"segment":"regionalConditions", "duration": 720.0},
|
||||||
|
{"segment":"localForecast", "duration": 720.0},
|
||||||
|
{"segment":"almanac", "duration": 720.0},
|
||||||
|
{"segment":"regionalForecast", "duration": 720.0},
|
||||||
|
{"segment":"travelForecast", "duration": 2880.0},
|
||||||
|
{"segment":"extendedForecast", "duration": 1440.0},
|
||||||
|
{"segment":"outlook", "duration": 720.0}
|
||||||
|
],
|
||||||
|
"P": [
|
||||||
|
{"segment":"localForecast", "duration": 600.0},
|
||||||
|
{"segment":"extendedForecast", "duration": 1200.0},
|
||||||
|
{"segment":"currentConditions", "duration": 600.0}
|
||||||
|
],
|
||||||
|
"Q": [
|
||||||
|
{"segment":"currentConditions", "duration": 600.0},
|
||||||
|
{"segment":"almanac", "duration": 600.0},
|
||||||
|
{"segment":"localForecast", "duration": 600.0},
|
||||||
|
{"segment":"regionalConditions", "duration": 600.0}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in new issue
Block a user