org.haphazard.gui.engine
Class Frame

java.lang.Object
  extended byorg.haphazard.gui.engine.Frame
All Implemented Interfaces:
java.lang.Cloneable

public class Frame
extends java.lang.Object
implements java.lang.Cloneable

A frame contains an image of an animation


Field Summary
 java.lang.String name
           
 
Constructor Summary
Frame(long displayTime)
          A constructor for frame
Frame(java.util.Vector images, long displayTime)
          A constructor for frame
 
Method Summary
 void addFrameImage(FrameImage image)
          Adds an image to the frame image buffer.
 java.lang.Object clone()
           
 Frame combine(Frame frameToBeInFront)
          Combine this frame with the Frame that is sent in.
 Frame flipHorizontally()
          Flips a new frame horizontally (copy of this frame)
 Frame flipVertically()
          Flips a new frame vertically (copy of this frame)
 java.awt.Rectangle getBoundingBox(java.awt.Point middleTileCoordinate)
          Return the bounding box on the screen of this image.
 long getDisplayTime()
          Returns the display time of this frame in milliseconds
 java.util.Vector getFrameImages()
          Returns the array of FrameImage that this Frame contains.
 void optimize()
          Optimizes the clipping box for all images in this frame
 void paintComponent(java.awt.Graphics2D g, java.awt.Point point)
          Paint this component
 void setDisplayTime(long time)
          Gets the height of the image
 void setFrameImages(java.util.Vector images)
          Sets the images in this frame
 java.lang.String toString()
          Turns this frame into a string notation
 java.lang.String toXML(int indent)
          Transforms this object into XML-notation
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

public java.lang.String name
Constructor Detail

Frame

public Frame(java.util.Vector images,
             long displayTime)
A constructor for frame

Parameters:
images - the array of images.
displayTime - the time in milliseconds that this frame should be diplayed

Frame

public Frame(long displayTime)
A constructor for frame

Parameters:
displayTime - the time in milliseconds that this frame should be diplayed
Method Detail

setFrameImages

public void setFrameImages(java.util.Vector images)
Sets the images in this frame

Parameters:
images - The images to set

addFrameImage

public void addFrameImage(FrameImage image)
Adds an image to the frame image buffer. These images will be drawn on top of eachother, the first added will be drawn first.

Parameters:
image - The image to add

getFrameImages

public java.util.Vector getFrameImages()
Returns the array of FrameImage that this Frame contains.

Returns:
the array of FrameImage that this Frame contains. The returned array is NOT a copy.

setDisplayTime

public void setDisplayTime(long time)
Gets the height of the image

Returns:
The height of the image, -1 if not loaded

getDisplayTime

public long getDisplayTime()
Returns the display time of this frame in milliseconds

Returns:
The time this frame should be displayed in milliseconds

getBoundingBox

public java.awt.Rectangle getBoundingBox(java.awt.Point middleTileCoordinate)
Return the bounding box on the screen of this image.

Parameters:
middleTileCoordinate - The middle coordinate of the tile the character is residing on
Returns:
the Rectangle with the bounding box

flipVertically

public Frame flipVertically()
Flips a new frame vertically (copy of this frame)

Returns:
A new flipped frame

flipHorizontally

public Frame flipHorizontally()
Flips a new frame horizontally (copy of this frame)

Returns:
A new flipped frame

combine

public Frame combine(Frame frameToBeInFront)
Combine this frame with the Frame that is sent in. This does not change either of the frames.

Parameters:
frameToBeInFront - the frame that is in front of this frame
Returns:
the new frame that contains all the FrameImages from the both Frames.

optimize

public void optimize()
Optimizes the clipping box for all images in this frame


paintComponent

public void paintComponent(java.awt.Graphics2D g,
                           java.awt.Point point)
Paint this component

Parameters:
g - the Graphics where to be drawn
point - the coordinate where the sprite is

toXML

public java.lang.String toXML(int indent)
Transforms this object into XML-notation

Parameters:
indent - The level of indentation to use
Returns:
The object in a String notation

toString

public java.lang.String toString()
Turns this frame into a string notation

Returns:
This Frame as a string notation

clone

public java.lang.Object clone()