public class AnimatedButton extends Animation
'S' different states and each state is fades in or out in 'F'
frames. 'S' and 'F' represent the two first constructor arguments. The frames of this special animation have to be
ordered to be supported by this class. The states are numbered from 0 to 'S'-1 and the frames order is the following
depending on the layoutType value:FADE_OUT_LAYOUT : S0F0,S0F1,S0F2,S1F0,S1F1,S1F2,S2F0,S2F1,S2F2where
FADE_IN_LAYOUT : S0F2,S0F1,S0F0,S1F2,S1F1,S1F0,S2F2,S2F1,S2F0
FADE_OUT_IN_LAYOUT : S0F0,S0F1,S1F1,S1F0,S1F1,S2F1,S2F0,S2F1,S0F1
S stands for state, F for frame; and where S0F0, S1F0, and S2F0 are the
full states and the others are transition frames. Open the onOff.bmp in the Scape game sample and you will understand ;-) .Control.TranslucentShape| Modifier and Type | Field and Description |
|---|---|
static int |
FADE_IN_LAYOUT
Frames fading in mode.
|
static int |
FADE_OUT_IN_LAYOUT
Frames fading out then fading in mode.
|
static int |
FADE_OUT_LAYOUT
Defines the frames animation order.
|
protected int |
fadeInState |
protected int |
framesPerState |
protected int |
layoutType |
protected int |
maxStates |
protected int |
state
current animated button state
|
protected int[] |
statesIndexes |
background, curFrame, drawOp, eventFinish, eventFrame, eventLoop, eventNone, eventsMask, framePeriod, framesBuffer, isPaused, isPlaying, LOOPS_UNLIMITED, pauseIfNotVisibleAFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y| Constructor and Description |
|---|
AnimatedButton(Image frames,
int states,
int framesPerState,
int layoutType,
int framePeriod)
Animated button constructor.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getState()
Gets the animated button state.
|
protected void |
inc(boolean up)
Increases/decreases the animated button state.
|
void |
onEvent(Event event)
Animated button event handler.
|
void |
setState(int state)
Sets the animated button state.
|
enableEvents, getPreferredHeight, getPreferredWidth, onPaint, pause, resume, setImage, size, start, start, stop_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, clear, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onBoundsChanged, onColorsChanged, onFontChanged, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setEnabled, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboardpublic static final int FADE_OUT_LAYOUT
S states button of F frames per state,
FADE_OUT_LAYOUT means that the frames are a S set of F frames that are fading out the state, which means
the first frame of each set is the full state image.
In the FADE_IN_LAYOUT layout, it's the opposite, namely the last frame of each set represents the state ending position.
Finally the FADE_OUT_IN_LAYOUT is a mix of the two others, because inter-frames represent successively fading out from one state to
fading in to next state.public static final int FADE_IN_LAYOUT
FADE_OUT_LAYOUT,
Constant Field Valuespublic static final int FADE_OUT_IN_LAYOUT
FADE_OUT_LAYOUT,
Constant Field Valuesprotected int state
protected int layoutType
protected int fadeInState
protected int framesPerState
protected int maxStates
protected int[] statesIndexes
public AnimatedButton(Image frames, int states, int framesPerState, int layoutType, int framePeriod) throws ImageException
frames - Button different states frames in multi-frame BMP format.states - Number of states of the button.framesPerState - Number of frames for each state.layoutType - FADE_OUT_LAYOUT, FADE_IN_LAYOUT, or FADE_OUT_IN_LAYOUT.framePeriod - Delay in milliseconds between two frames.ImageException - If an internal method throws it.FADE_OUT_LAYOUT,
FADE_IN_LAYOUT,
FADE_OUT_IN_LAYOUTpublic void setState(int state)
state - Value between 0 and states-1.public int getState()
0 and states-1.public void onEvent(Event event)
protected void inc(boolean up)
up - Boolean with a true value to increase the value; decrease otherwise.