 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.model.resource;
22 import java.io.BufferedReader;
24 import java.io.FileNotFoundException;
25 import java.io.IOException;
26 import java.io.InputStream;
27 import java.io.InputStreamReader;
28 import java.io.Reader;
30 import java.util.HashMap;
31 import java.util.List;
46 import net.
sf.japi.swing.action.ActionBuilder;
47 import net.
sf.japi.swing.action.ActionBuilderFactory;
48 import org.apache.log4j.Category;
49 import org.apache.log4j.Logger;
50 import org.jetbrains.annotations.NotNull;
51 import org.jetbrains.annotations.Nullable;
66 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
127 try (InputStream inputStream = animationsURL.openStream()) {
129 try (Reader bufferedReader =
new BufferedReader(reader)) {
130 animationObjectsReader.loadAnimations(
animationObjects, errorViewCollector, bufferedReader,
"anim ",
null, animations);
134 }
catch (
final IOException ex) {
140 if (
LOG.isInfoEnabled()) {
141 LOG.info(
"Loaded " + (
animationObjects.
size() - animationObjectsSize) +
" animations from '" + animationsURL +
"'.");
143 }
catch (
final FileNotFoundException ex) {
159 archFaceProvider.addInfo(facename, filename);
182 for (
int t = 0; t <
name.length() && secondDot == 0; t++) {
183 if (
name.charAt(t) ==
'.') {
192 if (firstDot != 0 && secondDot != 0) {
193 return name.substring(0, firstDot) +
name.substring(secondDot,
name.length() - 4);
195 return name.substring(0,
name.length() - 4);
199 return name.substring(0,
name.length() - 4);
219 protected static Map<String, String>
loadAnimTree(@NotNull
final URL url)
throws IOException {
220 final Map<String, String> animations;
221 try (InputStream inputStream = url.openStream()) {
223 try (BufferedReader bufferedReader =
new BufferedReader(reader)) {
228 if (
LOG.isInfoEnabled()) {
229 LOG.info(
"Loaded " + animations.size() +
" animations from '" + url +
"'.");
241 private static Map<String, String>
loadAnimTree(@NotNull
final BufferedReader reader)
throws IOException {
242 final Map<String, String> animations =
new HashMap<>();
244 final String line = reader.readLine();
248 final int index = line.lastIndexOf(
'/');
249 final String
name = line.substring(index + 1);
250 animations.put(
name, line);
static URL getResource(@NotNull final File dir, @NotNull final String fileName)
Get the URL of a resource.
This interface represents a lazy loader that provides images on demand.
void addPNGFace(@NotNull final String filename, @NotNull final String path, @NotNull final String name, @NotNull final ErrorView errorView, @NotNull final ArchFaceProvider archFaceProvider)
Loads a png from the file, convert it to IconImage and attach it to the face list.
void loadAnimationsFromCollect(@NotNull final ErrorView errorView, @NotNull final Map< String, String > animations, @NotNull final AbstractAnimationObjectsReader animationObjectsReader)
Loads all animations from the big collected animations file.
Base package of all Gridarta classes.
AbstractResourcesReader(@NotNull final File collectedDirectory, @Nullable final String imageSet, @NotNull final AnimationObjects animationObjects, @NotNull final FaceObjects faceObjects)
Creates a new instance.
String getOriginalFilename()
Get the original filename of this face.
static final Category LOG
The logger for printing log messages.
AnimationObjects is a container for AnimationObjects.
Implementation of FaceProvider which reads images from the arch directory.
FaceObject getDuplicate()
Returns the duplicate that caused this exception.
Abstract base class for archetype set loader classes.
final AnimationObjects animationObjects
The animation objects instance.
Utility class for reading AnimationObjects from files.
int size()
Get the number of objects.
FaceObject getExisting()
Returns the other duplicate that caused this exception.
Interface for classes displaying error messages.
Reflects a game object (object on a map).
Exception thrown to indicate that a face object is not acceptable.
int getLineNumber()
Returns the number of the erroneous line.
final File collectedDirectory
The collected directory.
GameObjects are the objects based on Archetypes found on maps.
Convenience class for adding messages to a ErrorView instance using a fixed category name.
This exception is thrown when parsing an animation definition file (.
Defines possible error categories for ErrorView instances.
final String imageSet
The current image set.
static final ActionBuilder ACTION_BUILDER
Action Builder.
FaceObjects is a container for FaceObjects.
abstract FaceProvider read(@NotNull ErrorView errorView, @NotNull List< G > invObjects)
Reads the resources.
Reading and writing of maps, handling of paths.
String generateFaceName(@NotNull final String name)
Generates the facename for a face.
final FaceObjects faceObjects
The face objects instance.
Utility-class for Gridarta's I/O.
The face is the appearance of an object.
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
String getFaceName()
Get the faceName, which is the name of the face as usable by the "face" attribute.
FaceObject getFaceObject()
Returns the illegal face object.
void addFaceObject(@NotNull String faceName, @NotNull String originalFilename, int offset, int size)
Adds a new face object.
static Map< String, String > loadAnimTree(@NotNull final BufferedReader reader)
Reads Animation Tree from Stream.
Exception that's thrown in case a face name was not unique.
static Map< String, String > loadAnimTree(@NotNull final URL url)
Loads animations from a file.
static final String MAP_ENCODING
Encoding to use for maps and other data.