Package totalcross.ui
Class Spinner
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Spinner
-
- All Implemented Interfaces:
EventHandler,TimerListener,UpdateListener
public class Spinner extends Control implements TimerListener, UpdateListener
Spinner is a control that shows an image indicating that something is running in the background. To start the spin call the start method, and to stop it call the stop method. If you try to run a spinner inside a tight loop, be sure to callspinner.update()or the spinner will not be updated. Without this, it will work in Java but not on devices.- Since:
- TotalCross 1.3
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description static intANDROIDUsed in the type fieldstatic intIPHONEUsed in the type fieldstatic intspinnerTypeDefines the type of spinner for all instances.static intSYNCUsed in the type field-
Fields inherited from class totalcross.ui.Control
AFTER, 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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description intgetTimestep()Gets the timestep used to change imagesbooleanisRunning()Returns if the spin is running.voidonBoundsChanged(boolean screenChanged)Called after a setRect.voidonColorsChanged(boolean changed)Called after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container.voidonPaint(Graphics g)Called to draw the control.voidsetImage(Image anim)Changes the gif image of this SpinnervoidsetTimestep(int timestep)Sets the timestep used to change images.voidsetType(int t)Changes the Spinner to one of the predefined types.voidstart()Starts the spinning thread.voidstop()Stops the spinning thread.voidtimerTriggered(TimerEvent e)A TRIGGERED event was dispatched.voidupdate()voidupdateListenerTriggered(int elapsedMilliseconds)Called regularly by the system.-
Methods inherited from class totalcross.ui.Control
_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, getPreferredHeight, getPreferredWidth, 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, onEvent, 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, willOpenKeyboard
-
-
-
-
Field Detail
-
IPHONE
public static final int IPHONE
Used in the type field- See Also:
- Constant Field Values
-
ANDROID
public static final int ANDROID
Used in the type field- See Also:
- Constant Field Values
-
SYNC
public static final int SYNC
Used in the type field- See Also:
- Constant Field Values
-
spinnerType
public static int spinnerType
Defines the type of spinner for all instances. Defaults for IPHONE when running in iPhone and ANDROID for all other platforms.
-
-
Constructor Detail
-
Spinner
public Spinner()
Creates a spinner with the defined spinnerType.
-
Spinner
public Spinner(int type)
Creates a spinner of the given type.
-
Spinner
public Spinner(Image anim)
Creates a spinner from an animated GIF. You can download additional animations from: here. Change only the given settings:- Image type: GIF
- Transparent background: Yes
- Foreground color: FFFFFF if the animation is only black, 000000 if it has fade.
- Background color: 000000
- Keep size 128 x 128
- Flip image: Hor
- Reverse animation: Yes
-
-
Method Detail
-
setType
public void setType(int t)
Changes the Spinner to one of the predefined types.
-
setImage
public void setImage(Image anim)
Changes the gif image of this Spinner
-
onBoundsChanged
public void onBoundsChanged(boolean screenChanged)
Description copied from class:ControlCalled after a setRect.- Overrides:
onBoundsChangedin classControl- Parameters:
screenChanged- If the bounds were changed due to a screen change (rotation, collapse)
-
onColorsChanged
public void onColorsChanged(boolean changed)
Description copied from class:ControlCalled after a setEnabled, setForeColor and setBackColor and when a control has been added to a Container. If colorsChanged is true, it was called from setForeColor/setBackColor/Container.add; otherwise, it was called from setEnabled- Overrides:
onColorsChangedin classControl
-
onPaint
public void onPaint(Graphics g)
Description copied from class:ControlCalled to draw the control. When this method is called, the graphics object passed has been translated into the coordinate system of the control and the area behind the control has already been painted.
-
start
public void start()
Starts the spinning thread.
-
stop
public void stop()
Stops the spinning thread.
-
isRunning
public boolean isRunning()
Returns if the spin is running.
-
timerTriggered
public void timerTriggered(TimerEvent e)
Description copied from interface:TimerListenerA TRIGGERED event was dispatched.- Specified by:
timerTriggeredin interfaceTimerListener- See Also:
TimerEvent
-
update
@Deprecated public void update()
Updates the spinner; call this when using the spinner inside a loop.
-
getTimestep
public int getTimestep()
Gets the timestep used to change images- Returns:
- time in milliseconds
-
setTimestep
public void setTimestep(int timestep)
Sets the timestep used to change images.- Parameters:
timestep- time in milliseconds
-
updateListenerTriggered
public void updateListenerTriggered(int elapsedMilliseconds)
Description copied from interface:UpdateListenerCalled regularly by the system.- Specified by:
updateListenerTriggeredin interfaceUpdateListener- Parameters:
elapsedMilliseconds- number of milliseconds since the last UpdateListenerTriggered call
-
-