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.


Nested Class Summary
private static class SimpleZippedAnimation.ImageAnimationEventImpl
           
 
Field Summary
private static java.lang.String ANIMATION_DESCRIPTOR_FILE
           
private  java.util.List<AnimationEvent> events
           
private  int height
           
private  int width
           
 
Constructor Summary
  SimpleZippedAnimation(java.io.InputStream zipStream)
          Creates a new animation from a stream.
private SimpleZippedAnimation(java.util.List<AnimationEvent> events, int width, int height)
           
  SimpleZippedAnimation(java.net.URL url)
          Creates a new animation from a stream generated by the provided URL.
private SimpleZippedAnimation(java.util.zip.ZipInputStream zipStream)
           
 
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANIMATION_DESCRIPTOR_FILE

private static final java.lang.String ANIMATION_DESCRIPTOR_FILE
See Also:
Constant Field Values

events

private final java.util.List<AnimationEvent> events

width

private final int width

height

private final int height
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.

SimpleZippedAnimation

private SimpleZippedAnimation(java.util.List<AnimationEvent> events,
                              int width,
                              int height)

SimpleZippedAnimation

private SimpleZippedAnimation(java.util.zip.ZipInputStream zipStream)
                       throws java.io.IOException
Throws:
java.io.IOException
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.