Skip to content

Commit d959319

Browse files
committed
dock image
1 parent 7c90db5 commit d959319

File tree

1 file changed

+48
-31
lines changed

1 file changed

+48
-31
lines changed

src/main/java/com/neuronrobotics/bowlerstudio/PsudoSplash.java

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@ public class PsudoSplash implements GitLogProgressMonitor {
4949
private static int logX = 15;
5050
private static PsudoSplash singelton = null;
5151
private static URL resource = PsudoSplash.class.getResource("splash.png");
52-
private static URL resource2;
52+
private static URL dockIcon;
5353
private static Color TextColor = Color.WHITE;
54-
55-
54+
5655
// Class Variables
57-
private long timeOfLastUpdate=0;
56+
private long timeOfLastUpdate = 0;
5857
private String message = "";
5958
private String log = "";
6059
private Stage popupStage;
@@ -67,19 +66,18 @@ public class PsudoSplash implements GitLogProgressMonitor {
6766
private double setWidth;
6867
private double scale;
6968

70-
7169
public static boolean isInitialized() {
7270
return singelton != null;
7371
}
7472

7573
public static PsudoSplash get() {
7674
if (singelton == null)
7775
singelton = new PsudoSplash();
78-
if(!singelton.isVisableSplash()) {
76+
if (!singelton.isVisableSplash()) {
7977
Platform.runLater(() -> {
8078
singelton.popupStage.show();
8179
});
82-
//new Exception("Opening Splash").printStackTrace();
80+
// new Exception("Opening Splash").printStackTrace();
8381
}
8482
return singelton;
8583
}
@@ -93,7 +91,7 @@ public static void close() {
9391
public void onUpdate(String update, Exception e) {
9492
// e.printStackTrace(System.err);
9593
log = update;
96-
if(isVisableSplash())
94+
if (isVisableSplash())
9795
updateSplash();
9896
}
9997

@@ -146,11 +144,11 @@ private PsudoSplash() {
146144
imageView = new ImageView(image);
147145
double height = image.getHeight();
148146
double width = image.getWidth();
149-
147+
150148
setWidth = 500;
151-
152-
scale = setWidth/width;
153-
double caclulatedHeight = scale*height;
149+
150+
scale = setWidth / width;
151+
double caclulatedHeight = scale * height;
154152
imageView.setFitWidth(setWidth);
155153
imageView.setFitHeight(caclulatedHeight);
156154

@@ -178,6 +176,17 @@ private PsudoSplash() {
178176
popupStage.setX(event.getScreenX() - xOffset[0]);
179177
popupStage.setY(event.getScreenY() - yOffset[0]);
180178
});
179+
try {
180+
// CADoodle-Icon.png
181+
if (dockIcon != null) {
182+
Image loadAsset = new Image(dockIcon.toString());
183+
popupStage.getIcons().add(loadAsset);
184+
185+
}
186+
187+
} catch (Exception e) {
188+
e.printStackTrace();
189+
}
181190
popupStage.show();
182191
updateSplash();
183192
});
@@ -187,11 +196,11 @@ private PsudoSplash() {
187196
// TODO Auto-generated catch block
188197
e.printStackTrace();
189198
}
190-
FontSizeManager.addListener(fontNum->{
191-
double tmp =FontSizeManager.getImageScale()*14;
192-
mesL.setStyle("-fx-font-size: "+((int)tmp)+"pt");
193-
logL.setStyle("-fx-font-size: "+((int)tmp)+"pt");
194-
verL.setStyle("-fx-font-size: "+((int)tmp)+"pt");
199+
FontSizeManager.addListener(fontNum -> {
200+
double tmp = FontSizeManager.getImageScale() * 14;
201+
mesL.setStyle("-fx-font-size: " + ((int) tmp) + "pt");
202+
logL.setStyle("-fx-font-size: " + ((int) tmp) + "pt");
203+
verL.setStyle("-fx-font-size: " + ((int) tmp) + "pt");
195204
});
196205
}
197206

@@ -205,33 +214,33 @@ private void closeSplashLocal() {
205214
Platform.runLater(() -> {
206215
popupStage.hide();
207216
});
208-
//new Exception("Closing Splash").printStackTrace();
217+
// new Exception("Closing Splash").printStackTrace();
209218
}
210219

211220
void updateSplash() {
212-
if(System.currentTimeMillis()-timeOfLastUpdate<100) {
221+
if (System.currentTimeMillis() - timeOfLastUpdate < 100) {
213222
return;
214223
}
215-
timeOfLastUpdate=System.currentTimeMillis();
224+
timeOfLastUpdate = System.currentTimeMillis();
216225
if (popupScene != null) {
217-
//System.out.println("Updating Splash "+imageView.getFitWidth());
226+
// System.out.println("Updating Splash "+imageView.getFitWidth());
218227
Platform.runLater(() -> {
219-
228+
220229
popupScene.setFill(null);
221230
popupScene.getStylesheets().clear();
222231
// Explicitly set an empty style
223232
popupRoot.setStyle("-fx-background-color: transparent;");
224-
logL.setLayoutX(logX*scale);
225-
logL.setLayoutY(logY*scale);
226-
mesL.setLayoutX(messageX*scale);
227-
mesL.setLayoutY(messageY*scale);
228-
verL.setLayoutX(versionX*scale);
229-
verL.setLayoutY(versionY*scale);
230-
233+
logL.setLayoutX(logX * scale);
234+
logL.setLayoutY(logY * scale);
235+
mesL.setLayoutX(messageX * scale);
236+
mesL.setLayoutY(messageY * scale);
237+
verL.setLayoutX(versionX * scale);
238+
verL.setLayoutY(versionY * scale);
239+
231240
logL.setTextFill(TextColor);
232241
mesL.setTextFill(TextColor);
233242
verL.setTextFill(TextColor);
234-
243+
235244
logL.setText(log);
236245
mesL.setText(message);
237246
verL.setText(StudioBuildInfo.getVersion());
@@ -304,7 +313,15 @@ public static void setLogX(int logX) {
304313
}
305314

306315
public static void setTrayIcon(URL resource2) {
307-
PsudoSplash.resource2 = resource2;
316+
PsudoSplash.setDockIconResource(resource2);
317+
}
318+
319+
public static URL getDockIconResource() {
320+
return dockIcon;
321+
}
322+
323+
public static void setDockIconResource(URL resource2) {
324+
PsudoSplash.dockIcon = resource2;
308325
}
309326

310327
}

0 commit comments

Comments
 (0)