Skip to content

Commit ffb3698

Browse files
committed
Moved to gradle 9.2 and JDK25
1 parent 102c346 commit ffb3698

11 files changed

Lines changed: 259 additions & 24 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ jobs:
77
runs-on: [ windows-latest ]
88
steps:
99
- uses: actions/checkout@v3
10-
- name: Set up JDK 17.0.6
10+
- name: Set up JDK 25
1111
uses: actions/setup-java@v3
1212
with:
13-
java-version: 17.0.6
13+
java-version: 25
1414
distribution: 'zulu'
1515
gpg-private-key: ${{ secrets.GPG_KEY }}
1616
gpg-passphrase: PASSPHRASE
@@ -32,10 +32,10 @@ jobs:
3232
runs-on: [ macos-latest ]
3333
steps:
3434
- uses: actions/checkout@v3
35-
- name: Set up JDK 17.0.6
35+
- name: Set up JDK 25
3636
uses: actions/setup-java@v3
3737
with:
38-
java-version: 17.0.6
38+
java-version: 25
3939
distribution: 'zulu'
4040
gpg-private-key: ${{ secrets.GPG_KEY }}
4141
gpg-passphrase: PASSPHRASE
@@ -59,10 +59,10 @@ jobs:
5959
runs-on: [ ubuntu-latest ]
6060
steps:
6161
- uses: actions/checkout@v3
62-
- name: Set up JDK 17.0.6
62+
- name: Set up JDK 25
6363
uses: actions/setup-java@v3
6464
with:
65-
java-version: 17.0.6
65+
java-version: 25
6666
distribution: 'zulu'
6767
gpg-private-key: ${{ secrets.GPG_KEY }}
6868
gpg-passphrase: PASSPHRASE

build.gradle

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ dependencies {
4040
implementation "org.openjfx:javafx-media:${javafxVersion}:${platform}"
4141
}
4242

43-
ext.moduleName = 'eu.hansolo.spacefx'
44-
mainClassName = 'eu.hansolo.spacefx.Launcher'
43+
application {
44+
mainModule = 'eu.hansolo.spacefx'
45+
mainClass = 'eu.hansolo.spacefx.Launcher'
46+
}
4547

4648
jar {
4749
from {
@@ -81,8 +83,15 @@ tasks.withType(JavaExec) {
8183
*/
8284

8385
// start the from gradle
84-
task Main(type: JavaExec) {
85-
main = "eu.hansolo.spacefx.Launcher"
86+
tasks.register('Main', JavaExec) {
87+
mainClass = "eu.hansolo.spacefx.Launcher"
88+
classpath = sourceSets.main.runtimeClasspath
89+
}
90+
91+
92+
93+
tasks.register('StarField', JavaExec) {
94+
mainClass = "eu.hansolo.spacefx.StarFieldLauncher"
8695
classpath = sourceSets.main.runtimeClasspath
8796
}
8897

build_app_linux.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
# PROJECT_VERSION: version used in pom.xml, e.g. 1.0-SNAPSHOT
2626
# APP_VERSION: the application version, e.g. 1.0.0, shown in "about" dialog
2727

28-
JAVA_VERSION=17
29-
MAIN_JAR="SpaceFX-17.0.0.jar"
30-
APP_VERSION=17.0.0
28+
JAVA_VERSION=25
29+
MAIN_JAR="SpaceFX-25.jar"
30+
APP_VERSION=25
3131

3232
echo "java home: $JAVA_HOME"
3333
echo "project version: $PROJECT_VERSION"

build_app_macos.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
# PROJECT_VERSION: version used in pom.xml, e.g. 1.0-SNAPSHOT
1010
# APP_VERSION: the application version, e.g. 1.0.0, shown in "about" dialog
1111

12-
JAVA_VERSION=17
13-
MAIN_JAR="SpaceFX-17.0.0.jar"
14-
APP_VERSION=17.0.0
12+
JAVA_VERSION=25
13+
MAIN_JAR="SpaceFX-25.jar"
14+
APP_VERSION=25
1515

1616
echo "java home: $JAVA_HOME"
1717
echo "project version: $PROJECT_VERSION"

build_app_windows.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ rem
99
rem PROJECT_VERSION: version used in pom.xml, e.g. 1.0-SNAPSHOT
1010
rem APP_VERSION: the application version, e.g. 1.0.0, shown in "about" dialog
1111

12-
set JAVA_VERSION=17
13-
set MAIN_JAR=SpaceFX-17.0.0.jar
14-
set APP_VERSION=17.0.0
12+
set JAVA_VERSION=25
13+
set MAIN_JAR=SpaceFX-25.jar
14+
set APP_VERSION=25
1515

1616
rem ------ SETUP DIRECTORIES AND FILES ----------------------------------------
1717
rem Remove previously generated java runtime and installers. Copy all required

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
# limitations under the License.
1515
#
1616

17-
sourceCompatibility = 21
18-
targetCompatibility = 21
17+
sourceCompatibility = 25
18+
targetCompatibility = 25
1919

2020
group = eu.hansolo.spacefx
21-
version = 21.0.0
22-
javafxVersion = 21.0.2
21+
version = 25
22+
javafxVersion = 25
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

resources/background.afphoto

16 KB
Binary file not shown.
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
/*
2+
* Copyright (c) 2025 by Gerrit Grunwald
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package eu.hansolo.spacefx;
18+
19+
import javafx.animation.AnimationTimer;
20+
import javafx.beans.DefaultProperty;
21+
import javafx.geometry.Insets;
22+
import javafx.scene.canvas.Canvas;
23+
import javafx.scene.canvas.GraphicsContext;
24+
import javafx.scene.layout.Background;
25+
import javafx.scene.layout.BackgroundFill;
26+
import javafx.scene.layout.CornerRadii;
27+
import javafx.scene.layout.Pane;
28+
import javafx.scene.layout.Region;
29+
import javafx.scene.paint.Color;
30+
31+
import java.util.Arrays;
32+
import java.util.Random;
33+
34+
35+
@DefaultProperty("children")
36+
public class StarField extends Region {
37+
private static final double WIDTH = 1920;
38+
private static final double HEIGHT = 1080;
39+
private static final Random RND = new Random();
40+
public static final int NO_OF_STARS = 200;
41+
public static final long FPS_60 = 0_016_666_666l;
42+
private Canvas canvas;
43+
private GraphicsContext ctx;
44+
private Pane pane;
45+
private Star[] stars = new Star[NO_OF_STARS];
46+
private long deltaTime = FPS_60;
47+
private long lastTimerCall;
48+
private AnimationTimer timer;
49+
50+
51+
// ******************** Constructors **************************************
52+
public StarField() {
53+
for (int i = 0; i < NO_OF_STARS; i++) {
54+
Star star = new Star();
55+
star.x = RND.nextDouble() * WIDTH;
56+
stars[i] = star;
57+
}
58+
59+
timer = new AnimationTimer() {
60+
@Override public void handle(final long now) {
61+
if (now > lastTimerCall) {
62+
lastTimerCall = now + deltaTime;
63+
redraw();
64+
}
65+
}
66+
};
67+
68+
initGraphics();
69+
registerListeners();
70+
}
71+
72+
73+
// ******************** Initialization ************************************
74+
private void initGraphics() {
75+
canvas = new Canvas(WIDTH, HEIGHT);
76+
ctx = canvas.getGraphicsContext2D();
77+
pane = new Pane(canvas);
78+
pane.setPrefSize(WIDTH, HEIGHT);
79+
pane.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
80+
81+
getChildren().setAll(pane);
82+
83+
setPrefSize(WIDTH, HEIGHT);
84+
}
85+
86+
private void registerListeners() {
87+
//widthProperty().addListener(o -> resize());
88+
//heightProperty().addListener(o -> resize());
89+
}
90+
91+
92+
// ******************** Methods *******************************************
93+
public void start() { this.timer.start(); }
94+
public void stop() { this.timer.stop(); }
95+
96+
private void redraw() {
97+
ctx.clearRect(0, 0, WIDTH, HEIGHT);
98+
ctx.setFill(Color.rgb(255, 255, 255, 0.9));
99+
Arrays.stream(stars).forEach(star -> {
100+
star.update();
101+
ctx.fillOval(star.x, star.y, star.size, star.size);
102+
});
103+
}
104+
105+
106+
// ******************** Inner Classes ************************************
107+
private class Star {
108+
private final Random rnd = new Random();
109+
private final double yVariation = 0;
110+
private final double minSpeedX = 4;
111+
private double x;
112+
private double y;
113+
private double size;
114+
private double vX;
115+
private double vY;
116+
private double vXVariation;
117+
118+
119+
public Star() {
120+
// Random size
121+
size = rnd.nextInt(2) + 1;
122+
123+
// Position
124+
x = -size;
125+
y = (int)(rnd.nextDouble() * HEIGHT);
126+
127+
// Random Speed
128+
vXVariation = (rnd.nextDouble() * 0.5) + 0.2;
129+
130+
// Velocity
131+
vX = (int) (Math.round(((rnd.nextDouble() * 1.5) + minSpeedX) * vXVariation));
132+
vY = (int) (Math.round((rnd.nextDouble() * yVariation) - yVariation * 0.5));
133+
}
134+
135+
136+
private void respawn() {
137+
x = -size;
138+
y = (int) (RND.nextDouble() * HEIGHT);
139+
}
140+
141+
private void update() {
142+
x += vX;
143+
y += vY;
144+
145+
// Respawn star
146+
if (x > WIDTH + size) {
147+
respawn();
148+
}
149+
}
150+
}
151+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2025 by Gerrit Grunwald
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package eu.hansolo.spacefx;
18+
19+
public class StarFieldLauncher {
20+
public static void main(String[] args) {
21+
StarFieldView.main(args);
22+
}
23+
}

0 commit comments

Comments
 (0)