Package com.prineside.tdi2.scene2d.ui
Class ProgressBar
java.lang.Object
com.prineside.tdi2.scene2d.Actor
com.prineside.tdi2.scene2d.ui.Widget
com.prineside.tdi2.scene2d.ui.ProgressBar
- All Implemented Interfaces:
Disableable,Layout
- Direct Known Subclasses:
Slider
A progress bar is a widget that visually displays the progress of some activity or a value within given range. The progress
bar has a range (min, max) and a stepping between each value it represents. The percentage of completeness typically starts out
as an empty progress bar and gradually becomes filled in as the task or variable value progresses.
ChangeListener.ChangeEvent is fired when the progress bar knob is moved. Cancelling the event will move the knob to where it was
previously.
For a horizontal progress bar, its preferred height is determined by the larger of the knob and background, and the preferred width is 140, a relatively arbitrary size. These parameters are reversed for a vertical progress bar.
- Author:
- mzechner, Nathan Sweet
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionProgressBar(float min, float max, float stepSize, boolean vertical, ProgressBar.ProgressBarStyle style) Creates a new progress bar. -
Method Summary
Modifier and TypeMethodDescriptionvoidact(float delta) Updates the actor based on time.voidIf this method is overridden, the super method orWidget.validate()should be called to ensure the widget is laid out.floatfloatfloatfloatfloatfloatgetStyle()Returns the progress bar's style.floatgetValue()floatfloatIfanimatingthe progress bar value, this returns the value current displayed.booleanbooleanbooleanTrue if the progress bar is vertical, false if it is horizontal.voidsetAnimateDuration(float duration) If > 0, changes to the progress bar value viasetValue(float)will happen over this duration in seconds.voidsetAnimateInterpolation(Interpolation animateInterpolation) Sets the interpolation to use forsetAnimateDuration(float).voidsetDisabled(boolean disabled) voidsetProgrammaticChangeEvents(boolean programmaticChangeEvents) If false,setValue(float)will not fireChangeListener.ChangeEvent.voidsetRange(float min, float max) Sets the range of this progress bar.voidsetRound(boolean round) If true (the default), inner Drawable positions and sizes are rounded to integers.voidsetStepSize(float stepSize) voidbooleansetValue(float value) Sets the progress bar position, rounded to the nearest step size and clamped to the minimum and maximum values.voidsetVisualInterpolation(Interpolation interpolation) Sets the interpolation to use for display.voidSets the visual value equal to the actual value.Methods inherited from class com.prineside.tdi2.scene2d.ui.Widget
getMaxHeight, getMaxHeightValue, getMaxWidth, getMaxWidthValue, getMinHeight, getMinHeightValue, getMinWidth, getMinWidthValue, getPrefHeightValue, getPrefWidthValue, invalidate, invalidateHierarchy, layout, needsLayout, pack, setFillParent, setLayoutEnabled, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setPrefHeight, setPrefHeight, setPrefWidth, setPrefWidth, validateMethods inherited from class com.prineside.tdi2.scene2d.Actor
addAction, addCaptureListener, addListener, ancestorsVisible, ascendantsVisible, clear, clearActions, clearListeners, clipBegin, clipBegin, clipEnd, debug, drawDebug, fire, firstAscendant, getActions, getCaptureListeners, getColor, getDebug, getHeight, getListeners, getName, getOriginX, getOriginY, getParent, getRight, getRotation, getScaleX, getScaleY, getStage, getTop, getTouchable, getUserObject, getWidth, getX, getX, getY, getY, getZIndex, hasActions, hasKeyboardFocus, hasParent, hasScrollFocus, hit, isAscendantOf, isDescendantOf, isTouchable, isTouchFocusListener, isTouchFocusTarget, isVisible, localToActorCoordinates, localToAscendantCoordinates, localToParentCoordinates, localToScreenCoordinates, localToStageCoordinates, moveBy, notify, parentToLocalCoordinates, remove, removeAction, removeCaptureListener, removeListener, rotateBy, scaleBy, scaleBy, screenToLocalCoordinates, setBounds, setColor, setColor, setDebug, setHeight, setName, setOrigin, setOrigin, setOriginX, setOriginY, setPosition, setPosition, setRotation, setScale, setScale, setScaleX, setScaleY, setSize, setTouchable, setUserObject, setVisible, setWidth, setX, setX, setY, setY, setZIndex, sizeBy, sizeBy, stageToLocalCoordinates, toBack, toFront, toString
-
Constructor Details
-
ProgressBar
public ProgressBar(float min, float max, float stepSize, boolean vertical, ProgressBar.ProgressBarStyle style) Creates a new progress bar. If horizontal, its width is determined by the prefWidth parameter, and its height is determined by the maximum of the height of either the progress barNinePatchor progress bar handleTextureRegion. The min and max values determine the range the values of this progress bar can take on, the stepSize parameter specifies the distance between individual values.E.g. min could be 4, max could be 10 and stepSize could be 0.2, giving you a total of 30 values, 4.0 4.2, 4.4 and so on.
- Parameters:
min- the minimum valuemax- the maximum valuestepSize- the step size between valuesstyle- theProgressBar.ProgressBarStyle
-
-
Method Details
-
setStyle
-
getStyle
Returns the progress bar's style. Modifying the returned style may not have an effect untilsetStyle(ProgressBarStyle)is called. -
act
public void act(float delta) Description copied from class:ActorUpdates the actor based on time. Typically this is called each frame byStage.act(float).The default implementation calls
Action.act(float)on each action and removes actions that are complete. -
draw
Description copied from class:WidgetIf this method is overridden, the super method orWidget.validate()should be called to ensure the widget is laid out. -
getValue
public float getValue() -
getVisualValue
public float getVisualValue()Ifanimatingthe progress bar value, this returns the value current displayed. -
updateVisualValue
public void updateVisualValue()Sets the visual value equal to the actual value. This can be used to set the value without animating. -
getPercent
public float getPercent() -
getVisualPercent
public float getVisualPercent() -
setValue
public boolean setValue(float value) Sets the progress bar position, rounded to the nearest step size and clamped to the minimum and maximum values.clamp(float)can be overridden to allow values outside of the progress bar's min/max range.- Returns:
- false if the value was not changed because the progress bar already had the value or it was canceled by a listener.
-
setRange
public void setRange(float min, float max) Sets the range of this progress bar. The progress bar's current value is clamped to the range. -
setStepSize
public void setStepSize(float stepSize) -
getPrefWidth
public float getPrefWidth()- Specified by:
getPrefWidthin interfaceLayout- Overrides:
getPrefWidthin classWidget
-
getPrefHeight
public float getPrefHeight()- Specified by:
getPrefHeightin interfaceLayout- Overrides:
getPrefHeightin classWidget
-
getMinValue
public float getMinValue() -
getMaxValue
public float getMaxValue() -
getStepSize
public float getStepSize() -
setAnimateDuration
public void setAnimateDuration(float duration) If > 0, changes to the progress bar value viasetValue(float)will happen over this duration in seconds. -
setAnimateInterpolation
Sets the interpolation to use forsetAnimateDuration(float). -
setVisualInterpolation
Sets the interpolation to use for display. -
setRound
public void setRound(boolean round) If true (the default), inner Drawable positions and sizes are rounded to integers. -
setDisabled
public void setDisabled(boolean disabled) - Specified by:
setDisabledin interfaceDisableable
-
isAnimating
public boolean isAnimating() -
isDisabled
public boolean isDisabled()- Specified by:
isDisabledin interfaceDisableable
-
isVertical
public boolean isVertical()True if the progress bar is vertical, false if it is horizontal. -
setProgrammaticChangeEvents
public void setProgrammaticChangeEvents(boolean programmaticChangeEvents) If false,setValue(float)will not fireChangeListener.ChangeEvent. The event will only be fired when the user changes the slider.
-