Class StandardMediaLoader
java.lang.Object
nl.colorize.multimedialib.renderer.java2d.StandardMediaLoader
- All Implemented Interfaces:
MediaLoader
- Direct Known Subclasses:
HeadlessMediaLoader
Uses APIs from the Java standard library to load media files: Java2D and ImageIO
for loading images, Java Sound for loading audio clips, and AWT for loading fonts.
These APIs are available on server and desktop platforms, but not on headless
server environments and not on Android.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates aStandardMediaLoader
that will look for resource files in the classpath, with a fallback to the local file system.StandardMediaLoader
(File resourceDir) Creates aStandardMediaLoader
that will only look for resource files in the specified directory. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether the specified resource file is available.protected File
getApplicationDataFile
(String appName) Provides access to aGeometryBuilder
instance that can be used to create simple 3D geometry in a programmatic way.loadApplicationData
(String appName) Loads the application data for the application with the specified name.loadAudio
(FilePointer file) Loads an audio clip from a file.loadFont
(FilePointer file, String family, FontStyle style) Loads a TrueType or FreeType font and converts it to a format that can be used by the renderer.loadImage
(FilePointer file) Loads an image from a file.loadModel
(FilePointer file) Loads a polygon model from the specified file.loadText
(FilePointer file) Loads a text-based resource file using UTF-8 encoding.void
saveApplicationData
(String appName, Properties data) Saves the application data for the application with the specified name.nl.colorize.util.ResourceFile
toResourceFile
(FilePointer file) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface nl.colorize.multimedialib.renderer.MediaLoader
loadAtlas, loadDefaultFont, loadProperties, loadTextLines, loadTranslationBundle
-
Field Details
-
fontFamilies
-
fontCache
-
-
Constructor Details
-
StandardMediaLoader
public StandardMediaLoader()Creates aStandardMediaLoader
that will look for resource files in the classpath, with a fallback to the local file system. -
StandardMediaLoader
Creates aStandardMediaLoader
that will only look for resource files in the specified directory. This can be used for testing, where files are located in a temporary directory and not on the classpath.
-
-
Method Details
-
loadImage
Description copied from interface:MediaLoader
Loads an image from a file. Images in JPEG and PNG format are supported by all renderers.- Specified by:
loadImage
in interfaceMediaLoader
-
loadAudio
Description copied from interface:MediaLoader
Loads an audio clip from a file. MP3 files are supported by all renderers.- Specified by:
loadAudio
in interfaceMediaLoader
-
loadFont
Description copied from interface:MediaLoader
Loads a TrueType or FreeType font and converts it to a format that can be used by the renderer. The loaded font will be attached to the font family name specified in the font style.- Specified by:
loadFont
in interfaceMediaLoader
-
loadText
Description copied from interface:MediaLoader
Loads a text-based resource file using UTF-8 encoding.- Specified by:
loadText
in interfaceMediaLoader
-
loadModel
Description copied from interface:MediaLoader
Loads a polygon model from the specified file. Only the GLTF format is guaranteed to be supported, other file formats are only supported by specific renderers.- Specified by:
loadModel
in interfaceMediaLoader
-
getGeometryBuilder
Description copied from interface:MediaLoader
Provides access to aGeometryBuilder
instance that can be used to create simple 3D geometry in a programmatic way.- Specified by:
getGeometryBuilder
in interfaceMediaLoader
-
containsResourceFile
Description copied from interface:MediaLoader
Returns whether the specified resource file is available.- Specified by:
containsResourceFile
in interfaceMediaLoader
-
getApplicationDataFile
-
loadApplicationData
Description copied from interface:MediaLoader
Loads the application data for the application with the specified name. Application data is limited to key/value properties, as this type of data is supported by all platforms. Returns an emptyProperties
when no application data exists.- Specified by:
loadApplicationData
in interfaceMediaLoader
-
saveApplicationData
Description copied from interface:MediaLoader
Saves the application data for the application with the specified name. Application data is limited to key/value properties, as this type of data is supported by all platforms.- Specified by:
saveApplicationData
in interfaceMediaLoader
-
toResourceFile
-