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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()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.ImageReturn anImagewith content loaded from the specified url.javafx.scene.image.ImageConstruct a newImagewith the specified parameters.voidsetFactory(ImageFactory factory) intsize()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, waitMethods inherited from interface com.github.hanyaeger.core.ResourceConsumer
createPathForResource
-
Constructor Details
-
ImageRepository
public ImageRepository()
-
-
Method Details
-
get
Return anImagewith content loaded from the specified url.- Parameters:
url- the string representing the URL to use in fetching the pixel data- Returns:
- an
Imagewith content loaded from the specified url
-
get
public javafx.scene.image.Image get(String url, double requestedWidth, double requestedHeight, boolean preserveRatio) Construct a newImagewith 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
Imagewith 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_VALUEelements, returnsInteger.MAX_VALUE.- Returns:
- the number of key-value mappings in this map
-
destroy
public void destroy()Description copied from interface:DestroyableImplement 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:
destroyin interfaceDestroyable
-
setFactory
- Parameters:
factory- theImageFactoryto be used
-