net.sf.freecol.common.io.sza
Class SimpleZippedAnimation

java.lang.Object
  extended by net.sf.freecol.common.io.sza.SimpleZippedAnimation
All Implemented Interfaces:
java.lang.Iterable<AnimationEvent>

public final class SimpleZippedAnimation
extends java.lang.Object
implements java.lang.Iterable<AnimationEvent>

An animation made from images stored in a zip-file.


Constructor Summary
SimpleZippedAnimation(java.io.InputStream zipStream)
          Creates a new animation from a stream.
SimpleZippedAnimation(java.net.URL url)
          Creates a new animation from a stream generated by the provided URL.
 
Method Summary
 SimpleZippedAnimation createScaledVersion(double scale)
          Creates a scaled animation based on this object.
 int getHeight()
          Gets the height of the animation.
 int getWidth()
          Gets the width of the animation.
 java.util.Iterator<AnimationEvent> iterator()
          Returns all of the animation events.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleZippedAnimation

public SimpleZippedAnimation(java.net.URL url)
                      throws java.io.IOException
Creates a new animation from a stream generated by the provided URL.

Parameters:
url - The URL to read a zip-file from.
Throws:
java.io.IOException - if the file cannot be opened, or is invalid.

SimpleZippedAnimation

public SimpleZippedAnimation(java.io.InputStream zipStream)
                      throws java.io.IOException
Creates a new animation from a stream.

Parameters:
zipStream - An InputStream to a zip-file.
Throws:
java.io.IOException - if the file cannot be opened, or is invalid.
Method Detail

getWidth

public int getWidth()
Gets the width of the animation.

Returns:
The largest width of all the frames in this animation.

getHeight

public int getHeight()
Gets the height of the animation.

Returns:
The largest height of all the frames in this animation.

iterator

public java.util.Iterator<AnimationEvent> iterator()
Returns all of the animation events.

Specified by:
iterator in interface java.lang.Iterable<AnimationEvent>
Returns:
An Iterator with all the images and other resources (support for sound may be added later).

createScaledVersion

public SimpleZippedAnimation createScaledVersion(double scale)
Creates a scaled animation based on this object.

Parameters:
scale - The scaling factor (with 1 being normal size, 2 twice the size, 0.5 half the size etc).
Returns:
The scaled animation.