Module hanyaeger

Class ImageRepository

java.lang.Object
com.github.hanyaeger.core.repositories.ImageRepository
All Implemented Interfaces:
Destroyable, ResourceConsumer

public class ImageRepository extends Object implements ResourceConsumer, Destroyable
An ImageRepository provides a central repository for acquiring sprites.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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
    get(String url)
    Return an Image with content loaded from the specified url.
    javafx.scene.image.Image
    get(String url, double requestedWidth, double requestedHeight, boolean preserveRatio)
    Construct a new Image with the specified parameters.
    void
     
    int
    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

      public javafx.scene.image.Image get(String url)
      Return an Image 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 new Image with the specified parameters.
      Parameters:
      url - the string representing the URL to use in fetching the pixel data
      requestedWidth - the image's bounding box width
      requestedHeight - the image's bounding box height
      preserveRatio - 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 than Integer.MAX_VALUE elements, returns Integer.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 interface Destroyable
    • setFactory

      @Inject public void setFactory(ImageFactory factory)
      Parameters:
      factory - the ImageFactory to be used