floodsim.view.util.resource

Members list

Type members

Classlikes

sealed trait Cache[K, A]

A generic cache for resources of type A indexed by keys of type K. This trait defines the core functionality for caching resources and retrieving them by key. Implementations determine how resources are stored and loaded.

A generic cache for resources of type A indexed by keys of type K. This trait defines the core functionality for caching resources and retrieving them by key. Implementations determine how resources are stored and loaded.

Type parameters

A

the type of resources stored in the cache

K

the type of keys used to identify resources

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object Cache

Companion object for Cache providing factory methods.

Companion object for Cache providing factory methods.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
Cache.type
final class ImageCache[K]

A specialized cache for storing and managing images with scaling capabilities. This class maintains a mapping between keys and image paths, and provides functionality to retrieve scaled versions of images on demand.

A specialized cache for storing and managing images with scaling capabilities. This class maintains a mapping between keys and image paths, and provides functionality to retrieve scaled versions of images on demand.

Type parameters

K

the type of keys used to identify images

Value parameters

baseCache

the underlying cache for base images

mapping

the mapping between keys and image file paths

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object ImageCache

Companion object for ImageCache providing factory methods for common image types.

Companion object for ImageCache providing factory methods for common image types.

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
ImageCache.type
object ImageScaler

Default ImageScaler using bilinear interpolation. Produces a new BufferedImage of type TYPE_INT_ARGB, preserving alpha.

Default ImageScaler using bilinear interpolation. Produces a new BufferedImage of type TYPE_INT_ARGB, preserving alpha.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
final class PathBasedImageLoader[K](mapping: Map[K, String]) extends ResourceLoader[K, BufferedImage]

Loads images from classpath resources based on a key-to-path mapping. Uses the current classloader to resolve mapping(key) into a resource stream and decodes it via ImageIO.read, returning detailed ResourceError values on failure. Error semantics:

Loads images from classpath resources based on a key-to-path mapping. Uses the current classloader to resolve mapping(key) into a resource stream and decodes it via ImageIO.read, returning detailed ResourceError values on failure. Error semantics:

Type parameters

K

key type

Value parameters

mapping

association between keys and classpath resource paths

Attributes

Supertypes
trait ResourceLoader[K, BufferedImage]
class Object
trait Matchable
class Any

Domain errors for resource loading.

Domain errors for resource loading.

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
trait ResourceLoader[K, A]

Type class for loading a value A given a key K. Implementations should be pure with respect to K and return deterministic LoadResult values for the same key (to benefit from caching).

Type class for loading a value A given a key K. Implementations should be pure with respect to K and return deterministic LoadResult values for the same key (to benefit from caching).

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
final case class ScaledImageKey[K](original: K, width: Int, height: Int)

Composite key for addressing scaled images derived from a base key.

Composite key for addressing scaled images derived from a base key.

Value parameters

height

target height in pixels

original

the base image key

width

target width in pixels

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
final class ScaledImageLoader[K](baseCache: Cache[K, BufferedImage])(using scaler: Scaler) extends ResourceLoader[ScaledImageKey[K], BufferedImage]

Produces scaled images from a base cache of original images using an ImageScaler. On a cache miss, it:

Produces scaled images from a base cache of original images using an ImageScaler. On a cache miss, it:

  1. retrieves the base java.awt.image.BufferedImage from baseCache
  2. scales it using the in-scope ImageScaler

Type parameters

K

base key type

Value parameters

baseCache

cache providing base (unscaled) images

scaler

the scaling strategy (inferred via given)

Attributes

Supertypes
trait ResourceLoader[ScaledImageKey[K], BufferedImage]
class Object
trait Matchable
class Any

Types

type LoadResult[A] = Either[ResourceError, A]

Result of a loading operation: either an error or a loaded value.

Result of a loading operation: either an error or a loaded value.

Attributes