类 AssetsService
java.lang.Object
pkg.exoad.poprock.core.AssetsService
AssetsService - Naive class for loading things from a baked-in assets folder that is
bundled with the Poprock library and program. It can be used to fetch outside of this
baked-in folder, but highly unstable and untested.
All of the methods that try to fetch an object are given 2 tries to find the required
asset where it will first try to search in the pre-baked folder, then outside the
pre-baked folder. If both of those fail for some reason, a final null
is
returned which is highly unlikely if the asset is actually present.
There are plans to migrate to using Optional
's to
allow for better catching of nonexistent assets, but that just introduces overhead as
99.9% of the time, the asset should be there.
- 作者:
- Jack Meng
-
字段概要
修饰符和类型字段说明static String
Set to where this service should search in and append paths after.private static final WeakHashMap<String,
Object> -
构造器概要
-
方法概要
修饰符和类型方法说明static BufferedImage
fetchBufferedImage
(String path) Fetchs an Image object.static File
static ImageIcon
fetchImageIcon
(String path) Fetches an ImageIcon object from the baked in folder.
-
字段详细资料
-
ASSETS_OFFSET
Set to where this service should search in and append paths after. Rarely should this be touched. -
cache
-
-
构造器详细资料
-
AssetsService
private AssetsService()
-
-
方法详细资料
-
fetchImageIcon
Fetches an ImageIcon object from the baked in folder. This is usually used directly with an UI object directly and requires no additional processing by the program. Such as scaling, filtering, etc..Example Usage
UIButtonDelegate .make() .withIcon(AssetsService.fetchImageIcon("assets/icons/home_64x64.png"));
- 参数:
path
- The internal baked-in path to search from- 返回:
- The loaded ImageIcon.
-
fetchBufferedImage
Fetchs an Image object. Similar tofetchImageIcon(String)
, but instead this function is called when we want to modify the image after, such as scaling, filtering, etc..Example Usage
BufferedImage img=AssetsService.fetchBufferedImage("assets/icons/home_64x64.png");
- 参数:
path
- The internal baked-in path to search from- 返回:
- The loaded BufferedImage
-
fetchFile
-