 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.model.gameobject;
22 import java.awt.Dimension;
23 import java.io.BufferedReader;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.io.InputStreamReader;
27 import java.io.LineNumberReader;
28 import java.io.Reader;
35 import org.apache.log4j.Category;
36 import org.apache.log4j.Logger;
37 import org.jetbrains.annotations.NotNull;
55 public static final int Y_DIM = 16;
83 public void load(@NotNull
final ErrorView errorView, @NotNull
final URL url) {
87 try (InputStream inputStream = url.openStream()) {
89 try (BufferedReader bufferedReader =
new BufferedReader(reader)) {
90 try (LineNumberReader lnr =
new LineNumberReader(bufferedReader)) {
94 boolean hasErrors =
false;
96 final String inputLine = lnr.readLine();
97 if (inputLine ==
null) {
100 final String line = inputLine.trim();
101 if (line.isEmpty() || line.startsWith(
"#")) {
109 if (numbers.length != 2) {
114 final Dimension d =
new Dimension();
117 d.width = Integer.parseInt(numbers[0]);
118 }
catch (
final NumberFormatException ignored) {
125 d.height = Integer.parseInt(numbers[1]);
126 }
catch (
final NumberFormatException ignored) {
135 if (yp <
Y_DIM && !hasErrors) {
140 if (
LOG.isInfoEnabled()) {
141 LOG.info(
"Loaded multi-part position data from '" + url +
"'");
147 }
catch (
final IOException ex) {
161 public int getXOffset(
final int shapeID,
final int positionID) {
163 return entry ==
null ? 0 : entry.
getXOffset(positionID);
175 public int getYOffset(
final int shapeID,
final int positionID) {
177 return entry ==
null ? 0 : entry.
getYOffset(positionID);
187 return entry ==
null ? 0 : entry.
getWidth();
197 return entry ==
null ? 0 : entry.
getHeight();
void addWarning(@NotNull final ErrorViewCategory category)
Adds a warning message.
int getXOffset(final int shapeID, final int positionID)
Calculate the x-offset from the leftmost pixel of the big face image and the default x-position (The ...
int getHeight()
Returns the total height of a multi-square image.
Base package of all Gridarta classes.
Provides information about isometric map squares.
static final Category LOG
The Logger for printing log messages.
int getYOffset(final int shapeID, final int positionID)
Calculate the y-offset from the topmost pixel of the big face image and the default y-position (The d...
Interface for classes displaying error messages.
int getYOffset(final int positionID)
Returns the y offset from the left-most pixel of the multi-square image and the default y position.
int getWidth(final int shapeID)
Returns the total width for a multi-square image.
int getHeight(final int shapeID)
Returns the total height for a multi-square image.
Convenience class for adding messages to a ErrorView instance using a fixed category name.
Defines possible error categories for ErrorView instances.
Encapsulated information about a multi-square image.
static final int Y_DIM
Number of rows in the array.
static final Pattern PATTERN_SPACE
The pattern that matches a single space.
void load(@NotNull final ErrorView errorView, @NotNull final URL url)
Load the array-data from file.
Utility class for string manipulation.
int getXOffset(final int positionID)
Returns the x offset from the left-most pixel of the multi-square image and the default x position.
final IsoMapSquareInfo isoMapSquareInfo
The IsoMapSquareInfo to use.
Utility-class for Gridarta's I/O.
The MultiPositionData class stores an array of numbers which is required in order to calculate displa...
final MultiPositionEntry[] data
Array with position data.
MultiPositionData(@NotNull final IsoMapSquareInfo isoMapSquareInfo)
Creates a new instance.
void addError(@NotNull final ErrorViewCategory category)
Adds an error message.
static final String MAP_ENCODING
Encoding to use for maps and other data.
int getWidth()
Returns the total width of a multi-square image.