Package org.eclipse.nebula.effects.stw
Class Transition
- java.lang.Object
-
- org.eclipse.nebula.effects.stw.Transition
-
- Direct Known Subclasses:
CubicRotationTransition
,FadeTransition
,SlideTransition
public abstract class Transition extends java.lang.Object
An abstract class handling the basic actions required for whatever transition effect. These actions are like the transition loop.
To implement a new transition effect, this class should be extended by the new transition class and only the three methodsinitTransition(Image, Image, GC, double)
,stepTransition(long, Image, Image, GC, double)
andendTransition(Image, Image, GC, double)
must be implemented.
The transition loop:
ThexitionImgGC.drawImage(from, 0, 0); initTransition(from, to, xitionImgGC, direction); render(xitionImgGC); while(t <= T) { if(t <= T) { stepTransition(t, from, to, xitionImgGC, direction); } else { xitionImgGC.drawImage(to, 0, 0); endTransition(from, to, xitionImgGC, direction); } render(xitionImgGC); t += dt; }
initTransition
method initializes the transition variables and draws the initial/first frame of the transition effect at time 0. ThestepTransition
method calculates the new transition variables values based on the time parametert
and draws the transition effect at time instance t. Finally, theendTransition
method finalizes the transition and draws the last frame at instance T.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
Transition.TransitionPainter
Listener to paint the canvas object, where the transition is visualized.
-
Field Summary
Fields Modifier and Type Field Description private long
_dt
protected long
_fps
private long
_t
protected long
_T
protected TransitionManager
_transitionManager
static long
DEFAULT_FPS
The default fps (frames per second) is 60static long
DEFAULT_T
The default transition time is 1000 msstatic double
DIR_DOWN
The Down direction, 270 degreesstatic double
DIR_LEFT
The Left direction, 180 degreesstatic double
DIR_RIGHT
The Right direction, 0 degreesstatic double
DIR_UP
The Up direction, 90 degreesprotected static boolean
IS_LINUX_OS
Flag to indicate if this OS is a Linux OS or not.protected static boolean
IS_MAC_OS
Flag to indicate if this OS is a MacOS X or not.
-
Constructor Summary
Constructors Constructor Description Transition(TransitionManager transitionManager)
This constructor is similar to new Transition(transitionManager,DEFAULT_FPS
,DEFAULT_T
)Transition(TransitionManager transitionManager, long fps, long T)
Constructs a new transition object
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
doEvents()
protected abstract void
endTransition(org.eclipse.swt.graphics.Image from, org.eclipse.swt.graphics.Image to, org.eclipse.swt.graphics.GC gc, double direction)
long
getFPS()
Returns the maximum number of frames per seconddouble
getTotalTransitionTime()
Returns the total time of the transition effect in millisecondprotected abstract void
initTransition(org.eclipse.swt.graphics.Image from, org.eclipse.swt.graphics.Image to, org.eclipse.swt.graphics.GC gc, double direction)
void
setFPS(long fps)
Sets the maximum fps (number of frames per second) for the transition.void
setTotalTransitionTime(long T)
Sets the total time of the transition effect in milliseconds.void
start(org.eclipse.swt.graphics.Image from, org.eclipse.swt.graphics.Image to, org.eclipse.swt.widgets.Canvas canvas, double direction)
Starts the transition from the from image to the to image drawing the effect on the graphics context object gc.protected abstract void
stepTransition(long t, org.eclipse.swt.graphics.Image from, org.eclipse.swt.graphics.Image to, org.eclipse.swt.graphics.GC gc, double direction)
-
-
-
Field Detail
-
DEFAULT_FPS
public static final long DEFAULT_FPS
The default fps (frames per second) is 60- See Also:
- Constant Field Values
-
DEFAULT_T
public static final long DEFAULT_T
The default transition time is 1000 ms- See Also:
- Constant Field Values
-
DIR_RIGHT
public static final double DIR_RIGHT
The Right direction, 0 degrees- See Also:
- Constant Field Values
-
DIR_UP
public static final double DIR_UP
The Up direction, 90 degrees- See Also:
- Constant Field Values
-
DIR_LEFT
public static final double DIR_LEFT
The Left direction, 180 degrees- See Also:
- Constant Field Values
-
DIR_DOWN
public static final double DIR_DOWN
The Down direction, 270 degrees- See Also:
- Constant Field Values
-
IS_MAC_OS
protected static final boolean IS_MAC_OS
Flag to indicate if this OS is a MacOS X or not.
-
IS_LINUX_OS
protected static final boolean IS_LINUX_OS
Flag to indicate if this OS is a Linux OS or not.
-
_transitionManager
protected TransitionManager _transitionManager
-
_fps
protected long _fps
-
_T
protected long _T
-
_dt
private long _dt
-
_t
private long _t
-
-
Constructor Detail
-
Transition
public Transition(TransitionManager transitionManager, long fps, long T)
Constructs a new transition object- Parameters:
transitionManager
- the transition manager to be used to manage transitionsfps
- number of frames per secondT
- the total time the transition effect will take
-
Transition
public Transition(TransitionManager transitionManager)
This constructor is similar to new Transition(transitionManager,DEFAULT_FPS
,DEFAULT_T
)- Parameters:
transitionManager
- the transition manager to be used to manage transitions
-
-
Method Detail
-
setFPS
public final void setFPS(long fps)
Sets the maximum fps (number of frames per second) for the transition. The actual number of frames displayed will vary depending on the current workload on the machine.- Parameters:
fps
- maximum number of frames per second
-
getFPS
public final long getFPS()
Returns the maximum number of frames per second- Returns:
- the maximum number of frames per second
-
setTotalTransitionTime
public final void setTotalTransitionTime(long T)
Sets the total time of the transition effect in milliseconds.- Parameters:
T
- total time of the transition effect in milliseconds
-
getTotalTransitionTime
public final double getTotalTransitionTime()
Returns the total time of the transition effect in millisecond- Returns:
- the total time of the transition effect in millisecond
-
start
public final void start(org.eclipse.swt.graphics.Image from, org.eclipse.swt.graphics.Image to, org.eclipse.swt.widgets.Canvas canvas, double direction)
Starts the transition from the from image to the to image drawing the effect on the graphics context object gc. The direction parameter determines the direction of the transition in degrees starting from 0 as the right direction and increasing in counter clock wise direction.- Parameters:
from
- is the image to start the transition fromto
- is the image to end the transition tocanvas
- is the canvas object to draw the transition ondirection
- determines the direction of the transition in degrees
-
doEvents
protected void doEvents()
-
initTransition
protected abstract void initTransition(org.eclipse.swt.graphics.Image from, org.eclipse.swt.graphics.Image to, org.eclipse.swt.graphics.GC gc, double direction)
-
stepTransition
protected abstract void stepTransition(long t, org.eclipse.swt.graphics.Image from, org.eclipse.swt.graphics.Image to, org.eclipse.swt.graphics.GC gc, double direction)
-
endTransition
protected abstract void endTransition(org.eclipse.swt.graphics.Image from, org.eclipse.swt.graphics.Image to, org.eclipse.swt.graphics.GC gc, double direction)
-
-