Package gui
Class ResourceLoader
java.lang.Object
gui.ResourceLoader
Utility class for loading resource files (icon images, stylesheets, etc.).
Resource files are stored in the `res` directory. However, when the project is built as a JAR file, the res directory is included and resources should be loaded from the JAR file rather than from an external file.
Additionally, there is a common setup process for loading images of the same type, etc. which is implemented by this class to avoid duplication elsewhere.
-
Method Summary
Modifier and TypeMethodDescriptionstatic URL
getResourceURL
(String path) Return a URL for the resource at the given path.static javafx.scene.Node
loadBitmapIcon
(String path, int width, int height) Load a bitmap image as an icon with the given dimensions and colour.static javafx.scene.Node
loadSVGicon
(String path, int width, int height) static javafx.scene.Node
loadSVGicon
(String path, int width, int height, javafx.scene.paint.Color colour) Load an SVG image as an icon with the given dimensions and colour.
-
Method Details
-
getResourceURL
Return a URL for the resource at the given path.The path is expected to be relative to the resource directory. The returned URL will either be for a file in the external `res` directory, or a JAR entry in the internal `res` directory, depending on how/where the program is run.
-
loadSVGicon
public static javafx.scene.Node loadSVGicon(String path, int width, int height, javafx.scene.paint.Color colour) Load an SVG image as an icon with the given dimensions and colour.- Parameters:
path
- The path to the SVG image relative to the `res` directory.
-
loadSVGicon
-
loadBitmapIcon
Load a bitmap image as an icon with the given dimensions and colour.The formats supported by JavaFX are: BMP, GIF, JPEG and PNG.
- Parameters:
path
- The path to the bitmap image relative to the `res` directory.
-