From 030abc45124c6d0447d5e74b7e067a10444e5cc2 Mon Sep 17 00:00:00 2001 From: Jason Long Date: Sat, 10 Jan 2015 12:45:51 -0500 Subject: [PATCH] TileImages: refactor: move readTileImage() to graphics package --- src/micropolisj/graphics/TileImage.java | 27 +++++++++++++++++++++++++ src/micropolisj/gui/TileImages.java | 27 ------------------------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/micropolisj/graphics/TileImage.java b/src/micropolisj/graphics/TileImage.java index f50758d..dbc91b8 100644 --- a/src/micropolisj/graphics/TileImage.java +++ b/src/micropolisj/graphics/TileImage.java @@ -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; + } } diff --git a/src/micropolisj/gui/TileImages.java b/src/micropolisj/gui/TileImages.java index 04e67d1..cc64a56 100644 --- a/src/micropolisj/gui/TileImages.java +++ b/src/micropolisj/gui/TileImages.java @@ -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 images = new HashMap();