Package pi.resources
Class Resources
java.lang.Object
pi.resources.Resources
Zur Aufbewahrung und Verwaltung verschiedener
Ressourcen.
Diese Klasse ist der Einstiegspunkt für den Zugriff auf alle Arten von
Resourcen. Eine Ressource ist jede nicht-ausführbare Datei, die mit
dem Spiel bereitgestellt wird. Die Resources Klasse bietet Zugriff
auf verschiedene Spezialisierungen von ResourcesContainer und wird
von verschiedenen (Lade-)Mechanismen verwendet, um Ressourcen während der
Laufzeit verfügbar zu machen.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ColorContainerEin Speicher für Farben des DatentypsColor.static final FontContainerEin Speicher für Schriftarten des DatentypsFont.static final ImageContainerEin Speicher für Bilder des DatentypsBufferedImage.static final SoundContainerEin Speicher für Klänge des DatentypsSound. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclearAll()Clears the all resource containers by removing previously loaded resources.static InputStreamGets the specified file as InputStream from either a resource folder or the file system.static InputStreamGets the specified file as InputStream from either a resource folder or the file system.static ImageContainerStellt den Zugriff auf denZwischenspeicher für Bild-Resourcenvom DatentypBufferedImagebereit.static URLgetLocation(String name) Gets the location of the specified resource.static SoundContainerStellt den Zugriff auf denZwischenspeicher für Audio-Resourcenvom DatentypSoundbereit.static StringReads the specified file as String from either a resource folder or the file system.
Since noCharsetis specified with this overload, the implementation uses UTF-8 by default.static StringReads the specified file as String from either a resource folder or the file system.static StringReads the specified file as String from either a resource folder or the file system.
Since noCharsetis specified with this overload, the implementation uses UTF-8 by default.static StringReads the specified file as String from either a resource folder or the file system.
-
Field Details
-
colors
Ein Speicher für Farben des DatentypsColor. -
fonts
Ein Speicher für Schriftarten des DatentypsFont. -
images
Ein Speicher für Bilder des DatentypsBufferedImage. -
sounds
Ein Speicher für Klänge des DatentypsSound.
-
-
Method Details
-
getImages
Stellt den Zugriff auf denZwischenspeicher für Bild-Resourcenvom DatentypBufferedImagebereit.- Returns:
- Ein Zwischenspeicher für Bild-Ressourcen vom Datentyp
BufferedImage.
-
getSounds
Stellt den Zugriff auf denZwischenspeicher für Audio-Resourcenvom DatentypSoundbereit.- Returns:
- Ein
Zwischenspeicher für Audio-Ressourcenvom DatentypSound.
-
clearAll
public static void clearAll()Clears the all resource containers by removing previously loaded resources. -
get
Gets the specified file as InputStream from either a resource folder or the file system.- Parameters:
file- The path to the file.- Returns:
- The contents of the specified file as
InputStream. - See Also:
-
get
Gets the specified file as InputStream from either a resource folder or the file system.- Parameters:
file- The path to the file.- Returns:
- The contents of the specified file as
InputStream. - See Also:
-
read
Reads the specified file as String from either a resource folder or the file system.
Since noCharsetis specified with this overload, the implementation uses UTF-8 by default.- Parameters:
file- The path to the file.- Returns:
- The contents of the specified file as
String
-
read
Reads the specified file as String from either a resource folder or the file system.- Parameters:
file- The path to the file.charset- The charset that is used to read the String from the file.- Returns:
- The contents of the specified file as
String
-
read
Reads the specified file as String from either a resource folder or the file system.
Since noCharsetis specified with this overload, the implementation uses UTF-8 by default.- Parameters:
file- The path to the file.- Returns:
- The contents of the specified file as
String
-
read
Reads the specified file as String from either a resource folder or the file system.- Parameters:
file- The path to the file.charset- The charset that is used to read the String from the file.- Returns:
- The contents of the specified file as
String
-
getLocation
Gets the location of the specified resource. This method attempts to find the resource using the system class loader first. If the resource is not found, it tries to locate it as a file in the file system.- Parameters:
name- The name of the resource.- Returns:
- The URL of the resource, or null if the resource could not be found.
-