public abstract class TransitionContainer extends StyledComposite implements Animation
Modifier and Type | Field and Description |
---|---|
static int |
DURATION
Default transition duration.
|
EMPTY_ELEMENT_ARRAY
Constructor and Description |
---|
TransitionContainer()
Creates a transition container with a motion factory that creates
QuartEaseOutMotion and a default
duration of 300. |
Modifier and Type | Method and Description |
---|---|
void |
addAnimationStepListener(AnimationStepListener animationStepListener)
Adds an animation step listener.
|
protected void |
cancelAnimation()
Cancels the animation (stops it and resets the context).
|
protected ej.motion.Motion |
createMotion(int start,
int stop)
Creates a motion based on the registered motion factory and duration.
|
int |
getDuration()
Gets the animation duration.
|
ej.motion.MotionFactory |
getMotionFactory()
Gets the motion factory.
|
void |
hideNotify() |
protected void |
notifyAnimationStepListeners(int value)
Notifies the registered animation step listeners with the given values.
|
protected void |
notifyAnimationStepListeners(int start,
int stop,
ej.mwt.Widget from,
ej.mwt.Widget to,
boolean forward)
Notifies the registered animation step listeners with the given values.
|
void |
removeAnimationStepListener(AnimationStepListener animationStepListener)
Removes an animation step listener.
|
protected void |
resetContext()
Cleans up the context after the animation.
|
protected void |
setBoundsContent(Rectangle bounds)
Sets the bounds of this widget by taking into account the border, margin and padding specified in the style.
|
protected void |
setChildBounds()
Sets the bounds of its child if one and only one.
|
void |
setDuration(int duration)
Sets the animation duration.
|
void |
setMotionFactory(ej.motion.MotionFactory motionFactory)
Sets the motion factory to use for the animations.
|
abstract void |
show(ej.mwt.Widget widget,
boolean forward)
Shows a new widget.
|
protected void |
startAnimation(ej.mwt.Widget widget,
ej.mwt.Widget previousWidget,
boolean forward,
int start,
int stop)
Creates a motion and starts an animation.
|
protected void |
stopAnimation()
Stops the animation.
|
boolean |
tick(long currentTimeMillis)
Called by an animator at a fixed rate.
|
protected abstract void |
updateStep(int step)
Updates the current step.
|
Rectangle |
validateContent(Style style,
Rectangle bounds)
Gets the content size of the renderable without the border, margin and padding specified in the style.
|
add, addClassSelector, contains, gainFocus, getAttribute, getChild, getChildrenCount, getChildrenElements, getParentElement, getStyle, hasClassSelector, isInState, isTransparent, lostFocus, mergeStyle, removeAllClassSelectors, removeClassSelector, removeInstanceStyle, render, renderContent, setBounds, setClassSelectors, setEnabled, updateStyle, updateStyleOnly, validate
getFocus, getFocusIndex, getNext, getWidget, getWidgetAt, getWidgets, getWidgetsCount, handleEvent, iterator, remove, removeAllWidgets, requestFocus, requestFocus, requestFocusFrom, showNotify
getAbsoluteX, getAbsoluteX, getAbsoluteY, getAbsoluteY, getEventHandler, getHeight, getPanel, getParent, getPreferredHeight, getPreferredWidth, getRelativeX, getRelativeY, getWidth, getX, getY, hasFocus, invalidate, isEnabled, isShown, isValid, isVisible, repaint, repaint, revalidate, revalidateSubTree, setEventHandler, setLocation, setPreferredSize, setSize, setVisible
public static final int DURATION
public TransitionContainer()
QuartEaseOutMotion
and a default
duration of 300.public void setMotionFactory(ej.motion.MotionFactory motionFactory)
motionFactory
- the motion factory to set.java.lang.NullPointerException
- if the given motion factory is null
.public ej.motion.MotionFactory getMotionFactory()
public void setDuration(int duration)
duration
- the duration to set.public int getDuration()
protected ej.motion.Motion createMotion(int start, int stop)
start
- the start value.stop
- the stop value.setMotionFactory(MotionFactory)
,
setDuration(int)
public void addAnimationStepListener(AnimationStepListener animationStepListener)
animationStepListener
- the listener to add.public void removeAnimationStepListener(AnimationStepListener animationStepListener)
animationStepListener
- the listener to remove.protected void notifyAnimationStepListeners(int start, int stop, ej.mwt.Widget from, ej.mwt.Widget to, boolean forward)
start
- the animation start value.stop
- the animation stop value.from
- the widget before the animation.to
- the widget after the animation.forward
- true
if going forward, false
otherwise.AnimationStepListener.initialize(int, int, Widget, Widget, boolean)
protected void notifyAnimationStepListeners(int value)
value
- the step value.AnimationStepListener.onStep(int)
public abstract void show(ej.mwt.Widget widget, boolean forward)
widget
- the new widget to show.forward
- true
if going forward, false
otherwise.java.lang.IllegalArgumentException
- if the specified widget is already in a hierarchy (already contained in a composite or panel).public void hideNotify()
hideNotify
in interface ej.mwt.Renderable
hideNotify
in class ej.mwt.Composite
protected void startAnimation(ej.mwt.Widget widget, ej.mwt.Widget previousWidget, boolean forward, int start, int stop)
The registered animation step listeners will be notified.
The animation listeners registered to the AnimationListenerRegistry
will also be notified.
The callers of this method must be careful to start the animation if and only if the widget is actually visible.
widget
- the new widget.previousWidget
- the previous widget.forward
- true
if going forward, false
otherwise.start
- the start value of the motion.stop
- the stop value of the motion.protected void stopAnimation()
If no animation is running, nothing changes.
protected void resetContext()
protected void cancelAnimation()
public boolean tick(long currentTimeMillis)
Animation
The given time is based on Util.platformTimeMillis()
which is monotonic.
protected abstract void updateStep(int step)
Called during the animation using the current value of the motion.
step
- the current step.public Rectangle validateContent(Style style, Rectangle bounds)
StyledComposite
Lays out the children of this composite.
validateContent
in interface StyledRenderable
validateContent
in class StyledComposite
style
- the style to use.bounds
- the bounds available for the content. A width or a height equals to MWT.NONE
means no
constraint on this dimension.protected void setBoundsContent(Rectangle bounds)
StyledComposite
setBoundsContent
in class StyledComposite
bounds
- the bounds available for the content.protected void setChildBounds()