Class OrdinalImageStorage
java.lang.Object
jfxutils.images.OrdinalImageStorage
- All Implemented Interfaces:
ImageStorage<Integer>
An implementation of the
The code will search for
ImageStorage
interface that associates PNG
images with a consecutive sequence of ints starting from 0. The images
representing the integers are loaded via the classloader of the class
specified.
Consider, for example, the following code:
ImageStorage<Integer> imageStorage = new OrdinalImageStorage(chess.game.PuzzleState.class,
"none.png",
"white_knight.png",
"black_knight.png"
);
none.png
, white_knight.png
, and
black_knight.png
in the chess.game
package, respectively.
Thus, in the case of an Apache Maven project, the images should be kept
under the
src/main/resources/chess/game
directory.-
Constructor Summary
ConstructorsConstructorDescriptionOrdinalImageStorage
(Class<?> c, String... resourceNames) Creates aOrdinalImageStorage
instance to associate the image resources specified with the integers 0, 1, 2, …. -
Method Summary
-
Constructor Details
-
OrdinalImageStorage
-
-
Method Details
-
get
Description copied from interface:ImageStorage
Returns anOptional
describing the image associated with the key specified, or an empty optional if no image is associated with the key.- Specified by:
get
in interfaceImageStorage<Integer>
- Parameters:
index
- a key for which the associated image should be returned- Returns:
- an
Optional
describing the image associated with the key specified, or an empty optional if no image is associated with the key
-