Refactor ResourceManager
This commit is contained in:
parent
da885fd5f2
commit
dc27cc9428
|
@ -1,12 +1,12 @@
|
|||
package net.filebot;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import static java.util.stream.Collectors.*;
|
||||
|
||||
import java.awt.Image;
|
||||
import java.awt.Toolkit;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.ImageIcon;
|
||||
|
@ -49,21 +49,21 @@ public final class ResourceManager {
|
|||
}
|
||||
|
||||
public static List<Image> getApplicationIcons() {
|
||||
return getApplicationIconURLs().stream().map(ResourceManager::getImage).collect(Collectors.toList());
|
||||
return Stream.of("window.icon.large", "window.icon.medium", "window.icon.small").map(ResourceManager::getImage).collect(toList());
|
||||
}
|
||||
|
||||
public static List<URL> getApplicationIconURLs() {
|
||||
URL[] images = new URL[3];
|
||||
images[0] = ResourceManager.getImageResource("window.icon.small");
|
||||
images[1] = ResourceManager.getImageResource("window.icon.medium");
|
||||
images[2] = ResourceManager.getImageResource("window.icon.large");
|
||||
return asList(images);
|
||||
public static List<javafx.scene.image.Image> getApplicationIconsFX() {
|
||||
return Stream.of("window.icon.large", "window.icon.medium", "window.icon.small").map(r -> new javafx.scene.image.Image(r.toString())).collect(toList());
|
||||
}
|
||||
|
||||
public static Icon getFlagIcon(String languageCode) {
|
||||
return getIcon("flags/" + languageCode);
|
||||
}
|
||||
|
||||
public static Image getImage(String name) {
|
||||
return getImage(getImageResource(name));
|
||||
}
|
||||
|
||||
private static Image getImage(URL resource) {
|
||||
// load sun.awt.image.ToolkitImage or sun.awt.image.MultiResolutionToolkitImage (via @2x convention)
|
||||
return Toolkit.getDefaultToolkit().getImage(resource);
|
||||
|
|
|
@ -8,7 +8,6 @@ import java.lang.reflect.Field;
|
|||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.KeyFrame;
|
||||
|
@ -19,7 +18,6 @@ import javafx.scene.Scene;
|
|||
import javafx.scene.control.Alert;
|
||||
import javafx.scene.control.Alert.AlertType;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.web.WebEngine;
|
||||
import javafx.scene.web.WebView;
|
||||
|
@ -66,7 +64,7 @@ public class GettingStartedStage {
|
|||
// Windows / Linux specific configuration
|
||||
stage.initStyle(StageStyle.UTILITY);
|
||||
stage.initModality(Modality.NONE);
|
||||
stage.getIcons().addAll(ResourceManager.getApplicationIconURLs().stream().map((url) -> new Image(url.toString())).collect(Collectors.toList()));
|
||||
stage.getIcons().addAll(ResourceManager.getApplicationIconsFX());
|
||||
}
|
||||
|
||||
return new GettingStartedStage(stage);
|
||||
|
|
Loading…
Reference in New Issue