|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.animation.CustomAnimation
public class CustomAnimation
A class implements custom animations.
Currently we support three kinds of animations - fly, zoom and fade - we call it effect. They all can be used during entrance and exit animation type. There are a lot of options you can control how the animation looks like. Those options include speed, smoothness (how many frames. The more the smoother), and location. In the case of fly effect animation, you also have options such as direction, start location, end location, function x and function y. Function x and function y here are just like function in the maths. Both functions together will define the path of the fly in or fly out. In the case of fade effect animation, you only have the option of end location as it stays at the same location. However you do have a function to control the fade speed at different stage. For example, if you choose FUNC_POW_HALF, it will fade faster at the beginning and slower at the end. If you choose FUNC_POW2 or FUNC_POW3, it will be the opposite. Please note, each component should have it's ownCustomAnimation
and should not share the same instance
with other components. If you want the same setting of a CustomAnimation
, you can call clone()
method to clone one.
Nested Class Summary | |
---|---|
static interface |
CustomAnimation.Callback
|
Field Summary | |
---|---|
static int |
BOTTOM
|
static int |
BOTTOM_LEFT
|
static int |
BOTTOM_RIGHT
|
static int |
CENTER
|
static int |
EFFECT_FADE
|
static int |
EFFECT_FLY
|
static int |
EFFECT_ZOOM
|
static Function |
FUNC_BOUNCE
|
static Function |
FUNC_LINEAR
|
static Function |
FUNC_LOG
|
static Function |
FUNC_POW_HALF
|
static Function |
FUNC_POW2
|
static Function |
FUNC_POW3
|
static Function |
FUNC_VIBRATE
|
static int |
HORIZONTAL
|
static int |
IN
|
static int |
LEFT
|
static int |
LEFT_DOWN
|
static int |
LEFT_UP
|
static int |
OUT
|
static int |
RIGHT
|
static int |
RIGHT_DOWN
|
static int |
RIGHT_UP
|
static int |
SMOOTHNESS_MEDIUM
|
static int |
SMOOTHNESS_ROUGH
|
static int |
SMOOTHNESS_SMOOTH
|
static int |
SMOOTHNESS_VERY_ROUGH
|
static int |
SMOOTHNESS_VERY_SMOOTH
|
static int |
SPEED_FAST
|
static int |
SPEED_MEDIUM
|
static int |
SPEED_SLOW
|
static int |
SPEED_VERY_FAST
|
static int |
SPEED_VERY_SLOW
|
static int |
TOP
|
static int |
TOP_LEFT
|
static int |
TOP_RIGHT
|
static int |
TYPE_ENTRANCE
|
static int |
TYPE_EXIT
|
static int |
VERTICAL
|
Constructor Summary | |
---|---|
CustomAnimation()
Creates a CustomAnimation. |
|
CustomAnimation(int type,
int effect,
int smoothness,
int speed)
Creates a CustomAnimation with several parameters. |
Method Summary | |
---|---|
void |
addAnimatorListener(AnimatorListener listener)
Adds an AnimatorListener to this CustomAnimation. |
Object |
clone()
Clone the CustomAnimation . |
protected void |
customizeAnimator(Animator animator)
Customizes the animator. |
AnimatorListener |
getAnimatorListener()
Gets the animator listener. |
AnimatorListener[] |
getAnimatorListeners()
Returns an array of all the AnimatorListener s added to this CustomAnimation with
addAnimatorListener(). |
CustomAnimation.Callback |
getCallback()
Sets the call back. |
int |
getDirection()
Gets the direction of the animation. |
int |
getEffect()
Gets the effect of the animation. |
Point |
getEndLocation()
Gets the end location of the animation. |
Function |
getFunctionFade()
Sets the function for fading effect. |
Function |
getFunctionX()
Gets the function used to calculate the x coord. |
Function |
getFunctionY()
Gets the function used to calculate the y coord. |
Function |
getFunctionZoom()
Gets the function for zooming effect. |
int |
getInitDelay()
Gets the initial delay, in milliseconds. |
protected double |
getPercentFade(int step,
int totalStep)
|
protected double |
getPercentX(int step,
int totalStep)
|
protected double |
getPercentY(int step,
int totalStep)
|
protected double |
getPercentZoom(int step,
int totalStep)
|
Image |
getScreenImage()
Gets the screen image. |
int |
getSecondaryDirection()
Gets the secondary direction. |
int |
getSmoothness()
Gets the smoothness of the animation. |
int |
getSpeed()
Gets the speed. |
Point |
getStartLocation()
Gets the start location of the animation. |
int |
getType()
Gets the type of the animation. |
Rectangle |
getVisibleBounds()
Gets the visible bounds. |
boolean |
isRunning()
Checks if the animation is running. |
void |
removeAnimatorListener(AnimatorListener listener)
Removes an AnimatorListener from this CustomAnimation. |
void |
setAnimatorListener(AnimatorListener animatorListener)
Sets the animator listener. |
void |
setCallback(CustomAnimation.Callback callback)
Callback which will be called when animation ends. |
void |
setDirection(int direction)
Sets the direction of the animation. |
void |
setEffect(int effect)
Sets the effect of animation. |
void |
setEndLocation(Point endLocation)
Sets the end location of the animation. |
void |
setFunctionFade(Function functionFade)
Sets the function for fading effect. |
void |
setFunctionX(Function functionX)
Sets the function used to calculate the x coord. |
void |
setFunctionY(Function functionY)
Sets the function used to calculate the x coord. |
void |
setFunctionZoom(Function functionZoom)
Sets the function for zooming effect. |
void |
setInitDelay(int initDelay)
Sets the initial delay. |
void |
setScreenImage(Image screenImage)
Sets the screen image. |
void |
setSecondaryDirection(int secondaryDirection)
Sets the secondary direction. |
void |
setSmoothness(int smoothness)
Sets the smoothness. |
void |
setSpeed(int speed)
Sets the speed. |
void |
setStartLocation(Point startLocation)
Sets the start location of the animation. |
void |
setType(int type)
Sets the type of the animation. |
void |
setVisibleBounds(Rectangle visibleBounds)
Sets the visible bounds. |
void |
start(Component source)
Starts the animation. |
void |
stop()
Stops the animation. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TYPE_ENTRANCE
public static final int TYPE_EXIT
public static final int EFFECT_FLY
public static final int EFFECT_ZOOM
public static final int EFFECT_FADE
public static final int SMOOTHNESS_VERY_SMOOTH
public static final int SMOOTHNESS_SMOOTH
public static final int SMOOTHNESS_MEDIUM
public static final int SMOOTHNESS_ROUGH
public static final int SMOOTHNESS_VERY_ROUGH
public static final int SPEED_VERY_SLOW
public static final int SPEED_SLOW
public static final int SPEED_MEDIUM
public static final int SPEED_FAST
public static final int SPEED_VERY_FAST
public static final int IN
public static final int OUT
public static final int HORIZONTAL
public static final int VERTICAL
public static final int CENTER
public static final int BOTTOM
public static final int LEFT
public static final int RIGHT
public static final int TOP
public static final int BOTTOM_LEFT
public static final int BOTTOM_RIGHT
public static final int TOP_LEFT
public static final int TOP_RIGHT
public static final int LEFT_DOWN
public static final int LEFT_UP
public static final int RIGHT_DOWN
public static final int RIGHT_UP
public static Function FUNC_LINEAR
public static Function FUNC_POW_HALF
public static Function FUNC_POW2
public static Function FUNC_POW3
public static Function FUNC_LOG
public static Function FUNC_BOUNCE
public static Function FUNC_VIBRATE
Constructor Detail |
---|
public CustomAnimation()
public CustomAnimation(int type, int effect, int smoothness, int speed)
type
- TYPE_ENTRANCE
or TYPE_EXIT
.effect
- EFFECT_FADE
or EFFECT_FLY
or EFFECT_ZOOM
smoothness
- any positive integer. We also predefined a few values, SMOOTHNESS_VERY_ROUGH
(5),
SMOOTHNESS_ROUGH
(10), SMOOTHNESS_MEDIUM
(25), SMOOTHNESS_SMOOTH
(50), and SMOOTHNESS_VERY_SMOOTH
(100). The large the value is, the smoothier the
animation.speed
- any positive integer. We also predefined a few values, SPEED_VERY_SLOW
(200), SPEED_SLOW
(100), SPEED_MEDIUM
(50), SPEED_FAST
(25), and SPEED_VERY_FAST
(10). The large the value is, the slower the animation.Method Detail |
---|
public int getType()
TYPE_ENTRANCE
and TYPE_EXIT
.
public void setType(int type)
TYPE_ENTRANCE
and TYPE_EXIT
.
type
- TYPE_ENTRANCE
or TYPE_EXIT
.getType()
public int getEffect()
EFFECT_FLY
, EFFECT_FADE
and EFFECT_ZOOM
.
public void setEffect(int effect)
EFFECT_FLY
, EFFECT_FADE
and EFFECT_ZOOM
.
effect
- EFFECT_FADE
or EFFECT_FLY
or EFFECT_ZOOM
public int getInitDelay()
public void setInitDelay(int initDelay)
initDelay
- the initial delay, in milliseconds.getInitDelay()
public int getSmoothness()
public void setSmoothness(int smoothness)
SMOOTHNESS_VERY_SMOOTH
, SMOOTHNESS_SMOOTH
, SMOOTHNESS_MEDIUM
,SMOOTHNESS_ROUGH
and
SMOOTHNESS_VERY_ROUGH
. We recommend you to use those predefined values although you can use any positive
integer value as parameter. We called it speed, but it's actually the number of milliseconds delay between two
steps. So the smaller the number, the fast the animation.
smoothness
- the smoothness.public int getSpeed()
public void setSpeed(int speed)
SPEED_VERY_FAST
, SPEED_FAST
, SPEED_MEDIUM
,SPEED_SLOW
and SPEED_VERY_SLOW
.
We recommend you to use those predefined values although you can use any positive integer value as parameter.
speed
- the speed.public int getDirection()
public void setDirection(int direction)
direction
- the direction. The valid values are TOP
, TOP_LEFT
, LEFT
, TOP_RIGHT
, RIGHT
, BOTTOM
, BOTTOM_LEFT
, and BOTTOM_RIGHT
.public int getSecondaryDirection()
public void setSecondaryDirection(int secondaryDirection)
secondaryDirection
- the secondary direction.public Point getStartLocation()
public void setStartLocation(Point startLocation)
startLocation
- the start location.public Point getEndLocation()
public void setEndLocation(Point endLocation)
endLocation
- the end location.public Rectangle getVisibleBounds()
public void setVisibleBounds(Rectangle visibleBounds)
visibleBounds
- the visible bounds of the screen.public void start(Component source)
source
- the component which will animate.public AnimatorListener getAnimatorListener()
public void setAnimatorListener(AnimatorListener animatorListener)
animatorListener
- the animation listener.public void addAnimatorListener(AnimatorListener listener)
AnimatorListener
to this CustomAnimation. Please use this method if you wish to receive
notification that the animation is about to start or has just ended.
listener
- the AnimatorListener
to be addedpublic void removeAnimatorListener(AnimatorListener listener)
AnimatorListener
from this CustomAnimation.
listener
- the listener to be removedpublic AnimatorListener[] getAnimatorListeners()
AnimatorListener
s added to this CustomAnimation with
addAnimatorListener().
AnimatorListener
s added or an empty array if no listeners have been addedprotected void customizeAnimator(Animator animator)
AnimatorListener
to do the
animation using Animator.addAnimatorListener(com.jidesoft.swing.AnimatorListener)
method. If you have any
new effect, you can override this method to provide your own AnimatorListener.
animator
- the Animator
.public void stop()
protected double getPercentX(int step, int totalStep)
protected double getPercentY(int step, int totalStep)
protected double getPercentFade(int step, int totalStep)
protected double getPercentZoom(int step, int totalStep)
public Image getScreenImage()
setScreenImage(java.awt.Image)
public void setScreenImage(Image screenImage)
screenImage
- the screen image.public CustomAnimation.Callback getCallback()
public void setCallback(CustomAnimation.Callback callback)
callback
- the callback.public Function getFunctionX()
public void setFunctionX(Function functionX)
functionX
- the function for X direction.public Function getFunctionY()
setFunctionY(Function)
,
setFunctionX(Function)
public void setFunctionY(Function functionY)
functionY
- the function for Y direction.getFunctionY()
,
setFunctionX(Function)
public Function getFunctionFade()
public void setFunctionFade(Function functionFade)
functionFade
- the function for fading calculation.public Function getFunctionZoom()
public void setFunctionZoom(Function functionZoom)
functionZoom
- the function for zooming calculation.public Object clone()
CustomAnimation
. Since CustomAnimation
cannot be shared among several
components, it is recommended to clone a CustomAnimation
when using it.
clone
in class Object
CustomAnimation
.public boolean isRunning()
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |