TileImages: refactor: move readTileImage() to graphics package
This commit is contained in:
parent
d64126f05e
commit
030abc4512
2 changed files with 27 additions and 27 deletions
|
@ -161,4 +161,31 @@ public abstract class TileImage
|
|||
anim.frames = frames.toArray(new SimpleTileImage[0]);
|
||||
return anim;
|
||||
}
|
||||
|
||||
public static TileImage readTileImage(XMLStreamReader in, LoaderContext ctx)
|
||||
throws XMLStreamException
|
||||
{
|
||||
TileImage img = null;
|
||||
|
||||
while (in.nextTag() != XMLStreamConstants.END_ELEMENT) {
|
||||
assert in.isStartElement();
|
||||
if (in.getLocalName().equals("image")) {
|
||||
img = readSimpleImage(in, ctx);
|
||||
}
|
||||
else if (in.getLocalName().equals("animation")) {
|
||||
img = readAnimation(in, ctx);
|
||||
}
|
||||
else {
|
||||
skipToEndElement(in);
|
||||
}
|
||||
}
|
||||
|
||||
if (img == null) {
|
||||
throw new XMLStreamException(
|
||||
"missing image descriptor"
|
||||
);
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,33 +45,6 @@ public class TileImages
|
|||
return "/" + name + "/tiles.png";
|
||||
}
|
||||
|
||||
static TileImage readTileImage(XMLStreamReader in, LoaderContext ctx)
|
||||
throws XMLStreamException
|
||||
{
|
||||
TileImage img = null;
|
||||
|
||||
while (in.nextTag() != XMLStreamConstants.END_ELEMENT) {
|
||||
assert in.isStartElement();
|
||||
if (in.getLocalName().equals("image")) {
|
||||
img = readSimpleImage(in, ctx);
|
||||
}
|
||||
else if (in.getLocalName().equals("animation")) {
|
||||
img = readAnimation(in, ctx);
|
||||
}
|
||||
else {
|
||||
skipToEndElement(in);
|
||||
}
|
||||
}
|
||||
|
||||
if (img == null) {
|
||||
throw new XMLStreamException(
|
||||
"missing image descriptor"
|
||||
);
|
||||
}
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
class MyLoaderContext implements LoaderContext
|
||||
{
|
||||
Map<String,BufferedImage> images = new HashMap<String,BufferedImage>();
|
||||
|
|
Reference in a new issue