Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.png filter=lfs diff=lfs merge=lfs -text
*.icns filter=lfs diff=lfs merge=lfs -text
*.ico filter=lfs diff=lfs merge=lfs -text
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
src/main/resources/images/icons/app.iconset/

# Compiled class file
*.class

Expand Down Expand Up @@ -107,4 +109,4 @@ Backups.backupdb
.MobileBackups
.MobileBackups.trash
MobileBackups.trash
tmbootpicker.efi
tmbootpicker.efi
21 changes: 20 additions & 1 deletion src/main/java/com/DesktopApplicationClientJava/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
import com.DesktopApplicationClientJava.session.Session;
import com.DesktopApplicationClientJava.utils.ControllerWiring;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.stage.Stage;

public class Program extends Application {
Expand All @@ -20,6 +23,9 @@ public class Program extends Application {
private static final double WINDOW_WIDTH = 800.0;
private static final double WINDOW_HEIGHT = 600.0;

private static final String ICON_BASE = "/images/icons/png/app-";
private static final List<Integer> ICON_SIZES = List.of(16, 32, 48, 64, 128, 256);

private final Session session = new Session();
private final ApiClient apiClient = new ApiClient(session);
private final ServiceRegistry services = createServices();
Expand All @@ -43,9 +49,10 @@ public void start(Stage stage) throws IOException {
Parent root = loader.load();
Scene scene = new Scene(root);
loadStyleSheet(scene, "/styles.css");
loadIcons(stage);

stage.setScene(scene);
stage.setTitle("JavaFX Application" + (MOCK_DATA ? " [MOCK]" : ""));
stage.setTitle("Госхрон" + (MOCK_DATA ? " [MOCK]" : ""));
stage.setWidth(WINDOW_WIDTH);
stage.setHeight(WINDOW_HEIGHT);
stage.centerOnScreen();
Expand All @@ -65,4 +72,16 @@ private void loadStyleSheet(Scene scene, String path) {
scene.getStylesheets().add(url.toExternalForm());
}
}

private void loadIcons(Stage stage) {
for (int size : ICON_SIZES) {
try (InputStream in = getClass().getResourceAsStream(ICON_BASE + size + ".png")) {
if (in != null) {
stage.getIcons().add(new Image(in));
}
} catch (IOException e) {
System.err.println(e);
}
}
}
}
3 changes: 3 additions & 0 deletions src/main/resources/images/app.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/main/resources/images/icons/app.icns
Git LFS file not shown
3 changes: 3 additions & 0 deletions src/main/resources/images/icons/app.ico
Git LFS file not shown
3 changes: 3 additions & 0 deletions src/main/resources/images/icons/png/app-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/main/resources/images/icons/png/app-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/main/resources/images/icons/png/app-256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/main/resources/images/icons/png/app-32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/main/resources/images/icons/png/app-48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/main/resources/images/icons/png/app-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions tools/make-icons.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail

SRC="${1:-src/main/resources/images/app.png}"
OUT="${2:-src/main/resources/images/icons}"

[[ -f "$SRC" ]] || { echo "source not found: $SRC" >&2; exit 1; }

mkdir -p "$OUT/png" "$OUT/app.iconset"

# PNG set
for size in 16 32 48 64 128 256; do
magick "$SRC" -resize "${size}x${size}" "$OUT/png/app-${size}.png"
done

# ICO
magick "$SRC" -define icon:auto-resize=256,128,64,48,32,16 "$OUT/app.ico"

# ICNS
magick "$SRC" -resize 16x16 "$OUT/app.iconset/icon_16x16.png"
magick "$SRC" -resize 32x32 "$OUT/app.iconset/icon_16x16@2x.png"
magick "$SRC" -resize 32x32 "$OUT/app.iconset/icon_32x32.png"
magick "$SRC" -resize 64x64 "$OUT/app.iconset/icon_32x32@2x.png"
magick "$SRC" -resize 128x128 "$OUT/app.iconset/icon_128x128.png"
magick "$SRC" -resize 256x256 "$OUT/app.iconset/icon_128x128@2x.png"
magick "$SRC" -resize 256x256 "$OUT/app.iconset/icon_256x256.png"
magick "$SRC" -resize 512x512 "$OUT/app.iconset/icon_256x256@2x.png"
magick "$SRC" -resize 512x512 "$OUT/app.iconset/icon_512x512.png"
magick "$SRC" -resize 1024x1024 "$OUT/app.iconset/icon_512x512@2x.png"

iconutil -c icns "$OUT/app.iconset" -o "$OUT/app.icns"
rm -rf "$OUT/app.iconset"

echo "done: $OUT"
Loading