From: <aki...@us...> - 2008-08-15 20:02:01
|
Revision: 4856 http://gridarta.svn.sourceforge.net/gridarta/?rev=4856&view=rev Author: akirschbaum Date: 2008-08-15 20:02:05 +0000 (Fri, 15 Aug 2008) Log Message: ----------- Move code to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2008-08-15 19:46:53 UTC (rev 4855) +++ trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2008-08-15 20:02:05 UTC (rev 4856) @@ -25,9 +25,7 @@ import java.io.IOException; import java.io.Reader; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import net.sf.gridarta.gameobject.anim.AbstractAnimationObjects; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; @@ -52,38 +50,11 @@ @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"}) private final List<AnimationObject> animObjects = new ArrayList<AnimationObject>(); - /** - * This Map holds (anim object name, path to arc file) pairs. The object - * name is included in the path. - */ - private final Map<String, String> animMap = new HashMap<String, String>(); - /** {@inheritDoc} */ public void addAnimationObject(final String animName, final String list) throws DuplicateAnimationException { addAnimationObject(animName, list, null); } - /** - * Adds a new animation object. If <code>path == null</code> path will be - * read from {@link #animMap}. - * @param animName name of the animation object to add - * @param list String with animation list data - * @param path Path relative to the arch directory - * @throws DuplicateAnimationException in case the animation was not unique - */ - public void addAnimationObject(final String animName, final String list, @Nullable final String path) throws DuplicateAnimationException { - final AnimationObject animationObject; - if (path == null) { - animationObject = new AnimationObject(animName, list, animMap.get(animName)); - } else { - animationObject = new AnimationObject(animName, list, path + '/' + animName); - } - if (containsKey(animName)) { - throw new DuplicateAnimationException(animationObject); - } - put(animationObject); - } - /** {@inheritDoc} */ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"}) public void loadAnims(final Reader reader, @Nullable final String path) throws IOException, AnimationParseException, DuplicateAnimationException { @@ -127,13 +98,15 @@ } /** {@inheritDoc} */ - public void addAnimPath(final String name, final String path) { - animMap.put(name, path); + public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + // TODO } /** {@inheritDoc} */ - public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - // TODO + @NotNull + @Override + protected AnimationObject newAnimationObject(@NotNull final String animName, @NotNull final String animList, @NotNull final String path) { + return new AnimationObject(animName, animList, path); } } // class AnimationObjects Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2008-08-15 19:46:53 UTC (rev 4855) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2008-08-15 20:02:05 UTC (rev 4856) @@ -30,8 +30,6 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Reader; -import java.util.HashMap; -import java.util.Map; import net.sf.gridarta.gameobject.anim.AbstractAnimationObjects; import net.sf.gridarta.gameobject.anim.AnimationParseException; import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; @@ -53,38 +51,11 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - /** - * This Map holds (anim object name, path to arc file) pairs. The object - * name is included in the path. - */ - private final Map<String, String> animMap = new HashMap<String, String>(); - /** {@inheritDoc} */ public void addAnimationObject(final String animName, final String list) throws DuplicateAnimationException { addAnimationObject(animName, list, null); } - /** - * Adds a new animation object. If <code>path == null</code> path will be - * read from {@link #animMap}. - * @param animName name of the animation object to add - * @param list String with animation list data - * @param path Path relative to the arch directory - * @throws DuplicateAnimationException in case the animation was not unique - */ - public void addAnimationObject(final String animName, final String list, @Nullable final String path) throws DuplicateAnimationException { - final AnimationObject animationObject; - if (path == null) { - animationObject = new AnimationObject(animName, list, animMap.get(animName)); - } else { - animationObject = new AnimationObject(animName, list, path + '/' + animName); - } - if (containsKey(animName)) { - throw new DuplicateAnimationException(animationObject); - } - put(animationObject); - } - /** {@inheritDoc} */ @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"}) public void loadAnims(final Reader reader, @Nullable final String path) throws IOException, AnimationParseException, DuplicateAnimationException { @@ -133,20 +104,7 @@ } } - /** {@inheritDoc} */ - public void addAnimPath(final String name, final String path) { - animMap.put(name, path); - } - /** - * Returns Animation Path Tree. - * @return <var>animHashTable</var> - */ - public Map<String, String> getAnimPathTree() { - return animMap; - } - - /** * Reads Animation Tree from Stream. * @param reader Input stream * @throws IOException in case of I/O errors @@ -219,4 +177,11 @@ } } + /** {@inheritDoc} */ + @NotNull + @Override + protected AnimationObject newAnimationObject(@NotNull final String animName, @NotNull final String animList, @NotNull final String path) { + return new AnimationObject(animName, animList, path); + } + } // class AnimationObjects Modified: trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-08-15 19:46:53 UTC (rev 4855) +++ trunk/src/app/net/sf/gridarta/gameobject/anim/AbstractAnimationObjects.java 2008-08-15 20:02:05 UTC (rev 4856) @@ -25,10 +25,14 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; +import java.util.HashMap; +import java.util.Map; import net.sf.gridarta.data.AbstractNamedObjects; import net.sf.gridarta.io.IOUtils; import net.sf.gridarta.io.PathManager; import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Abstract base implementation of {@link AnimationObjects}. @@ -39,6 +43,12 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + /** + * This Map holds (anim object name, path to arc file) pairs. The object + * name is included in the path. + */ + private final Map<String, String> animMap = new HashMap<String, String>(); + /** Create an AnimationObjects instance. */ protected AbstractAnimationObjects() { super(ACTION_FACTORY.getString("nameOfAnimationObject")); @@ -55,4 +65,48 @@ } } + /** + * Adds a new animation object. If <code>path == null</code> path will be + * read from {@link #animMap}. + * @param animName name of the animation object to add + * @param list String with animation list data + * @param path Path relative to the arch directory + * @throws DuplicateAnimationException in case the animation was not unique + */ + public void addAnimationObject(final String animName, final String list, @Nullable final String path) throws DuplicateAnimationException { + final E animationObject; + if (path == null) { + animationObject = newAnimationObject(animName, list, animMap.get(animName)); + } else { + animationObject = newAnimationObject(animName, list, path + '/' + animName); + } + if (containsKey(animName)) { + throw new DuplicateAnimationException(animationObject); + } + put(animationObject); + } + + /** + * Creates a new {@link AnimationObject} instance. + * @param animName the animation name + * @param animList the list of animations + * @param path the path name + * @return the anmation object instance + */ + @NotNull + protected abstract E newAnimationObject(@NotNull final String animName, @NotNull final String animList, @NotNull final String path); + + /** {@inheritDoc} */ + public void addAnimPath(final String name, final String path) { + animMap.put(name, path); + } + + /** + * Returns Animation Path Tree. + * @return <var>animHashTable</var> + */ + public Map<String, String> getAnimPathTree() { + return animMap; + } + } // class AbstractAnimationObjects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |