java.lang.Object
com.github.hanyaeger.core.repositories.ImageRepository
- All Implemented Interfaces:
Destroyable
,ResourceConsumer
An
ImageRepository
provides a central repository for acquiring sprites.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Implement this method and use it to ensure that the maximum number of Objects are eligible for Garbage Collection after this method has been called.javafx.scene.image.Image
Return anImage
with content loaded from the specified url.javafx.scene.image.Image
Construct a newImage
with the specified parameters.void
setFactory
(ImageFactory factory) int
size()
Returns the number of key-value mappings in this map.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.github.hanyaeger.core.ResourceConsumer
createPathForResource
-
Constructor Details
-
ImageRepository
public ImageRepository()
-
-
Method Details
-
get
Return anImage
with content loaded from the specified url.- Parameters:
url
- the string representing the URL to use in fetching the pixel data- Returns:
- an
Image
with content loaded from the specified url
-
get
public javafx.scene.image.Image get(String url, double requestedWidth, double requestedHeight, boolean preserveRatio) Construct a newImage
with the specified parameters.- Parameters:
url
- the string representing the URL to use in fetching the pixel datarequestedWidth
- the image's bounding box widthrequestedHeight
- the image's bounding box heightpreserveRatio
- indicates whether to preserve the aspect ratio of the original image when scaling to fit the image within the specified bounding box- Returns:
- an
Image
with content loaded from the specified url
-
size
public int size()Returns the number of key-value mappings in this map. If the map contains more thanInteger.MAX_VALUE
elements, returnsInteger.MAX_VALUE
.- Returns:
- the number of key-value mappings in this map
-
destroy
public void destroy()Description copied from interface:Destroyable
Implement this method and use it to ensure that the maximum number of Objects are eligible for Garbage Collection after this method has been called.- Specified by:
destroy
in interfaceDestroyable
-
setFactory
- Parameters:
factory
- theImageFactory
to be used
-