home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Boot Disc 13
/
boot-disc-1997-09.iso
/
HyprWire
/
DATA.Z
/
UpperLeftTransition.java
< prev
next >
Wrap
Text File
|
1997-01-21
|
5KB
|
106 lines
package kinetix.hyperc1.transitions;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Point;
/* This sample TransitionPlugIn will slide the module */
/* to/from the upper left corner of the parent container. */
public class UpperLeftTransition extends UserTransition
{
Image m_image;
boolean m_show;
Point m_offpos = new Point(0, 0);
Point m_offset = new Point(0, 0);
/* Constructor */
public UpperLeftTransition()
{
}
/* void init(Image image, Rectangle drawRect, Rectangle parentRect, */
/* Rectangle clipRect, int nFrames, int nMilliseconds, boolean show) */
/* */
/* Will be called at the start of each transition. */
/* image = an image of the module (the background is transparent). */
/* drawRect = the position of the image on the applet. */
/* parentRect = the position of the parent container. */
/* clipRect = the clipping rectangle for the transition, is equal */
/* to the entire window on entry. */
/* nFrames = the number of frames to be drawn. */
/* nMilliseconds = the duration of the transition. */
/* show = true for show, false for hide. */
/* */
/* drawRect and clipRect may be modified by changing the members. */
/* drawRect may also be modified in the calls to getFrame(...). */
/* */
/* You cannot call getGraphics() on the image passed in because it */
/* is created with java.awt.image.MemoryImageSource and has a */
/* transparent background. */
public void init(Image image, Rectangle drawRect, Rectangle parentRect,
Rectangle clipRect, int nFrames, int nMilliseconds, boolean show)
{
m_image = image;
m_show = show;
/* Set the clipRect for the transition to the parent container */
clipRect.x = parentRect.x;
clipRect.y = parentRect.y;
clipRect.width = parentRect.width;
clipRect.height = parentRect.height;
/* Calculate the position of the module when outside the container */
m_offpos.x = parentRect.x - drawRect.width;
m_offpos.y = parentRect.y - drawRect.height;
/* Calculate the offset between successive frames */
m_offset.x = (m_offpos.x - drawRect.x) / (nFrames + 1);
m_offset.y = (m_offpos.y - drawRect.y) / (nFrames + 1);
}
/* Image getFrame(int iframe, Rectangle srcRect, Rectangle drawRect) */
/* */
/* Will be called once for each frame to be drawn. */
/* A modified image may be returned on each call. */
/* */
/* srcRect = The portion of the returned image to be drawn. */
/* drawRect = The location for this frame on the applet window. */
/* The source image will be stretched to fit drawRect. */
/* */
/* srcRect will be the size of the original image on the first */
/* frame (iframe = 0). */
/* Both of the rectangles may be modified by changing the members. */
/* Any changes to the rectangles will be retained on successive */
/* calls to getFrame(). */
public Image getFrame(int iframe, Rectangle srcRect, Rectangle drawRect)
{
if (iframe == 0) /* First frame */
{
if (m_show) /* if showing, start outside the container */
{
drawRect.x = m_offpos.x;
drawRect.y = m_offpos.y;
m_offset.x = -m_offset.x;
m_offset.y = -m_offset.y;
}
}
drawRect.x += m_offset.x; /* Move the image on each frame */
drawRect.y += m_offset.y;
return m_image;
}
public void reset() /* Release images, memory, etc. */
{
m_image = null;
}
}