Package com.avrix.ui.widgets
Class RadioButtonWidget
java.lang.Object
com.avrix.ui.widgets.Widget
com.avrix.ui.widgets.RadioButtonWidget
A
Widget
that represents a set of radio buttons.
The radio buttons can be arranged either horizontally or vertically.-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Represents a single radio button within theRadioButtonWidget
. -
Field Summary
-
Constructor Summary
ConstructorDescriptionRadioButtonWidget
(int x, int y, int width, int height, boolean horizontal, BiConsumer<Integer, String> onChangeAction) Constructs aRadioButtonWidget
with the specified position, size, and arrangement. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a new radio button to theRadioButtonWidget
.final NanoColor
Returns the color used to accent the selected radio button.final NanoColor
Returns the color of the circles representing the radio buttons.final int
Returns the radius of the circles representing the radio buttons.final String
Returns the font name used to render the text in the radio buttons.final int
Returns the font size used to render the text in the radio buttons.final int
Returns the offset between radio buttons.final int
Returns the height of each radio button.final int
Returns the width of each radio button.final NanoColor
Returns the color of the text in the radio buttons.final int
Retrieves the index of the currently selected radio button.final List<RadioButtonWidget.RadioValue>
Returns the list ofRadioButtonWidget.RadioValue
objects representing the radio button options.final String
Retrieves the text of the currently selected radio button.final String
getValueText
(int index) Retrieves the text of the radio button at the specified index.void
render()
Renders theWidget
.void
Resizes theRadioButtonWidget
to fit its content based on the arrangement.final void
setAccentColor
(NanoColor accentColor) Sets the color used to accent the selected radio button.final void
setCircleColor
(NanoColor circleColor) Sets the color of the circles representing the radio buttons.final void
setCircleRadius
(int circleRadius) Sets the radius of the circles representing the radio buttons.final void
setFontName
(String fontName) Sets the font name used to render the text in the radio buttons.final void
setFontSize
(int fontSize) Sets the font size used to render the text in the radio buttons.final void
setOffset
(int offset) Sets the offset between radio buttons.final void
setRadioHeight
(int radioHeight) Sets the height of each radio button.final void
setRadioWidth
(int radioWidth) Sets the width of each radio button.final void
setTextColor
(NanoColor textColor) Sets the color of the text in the radio buttons.Methods inherited from class com.avrix.ui.widgets.Widget
addChild, addToScreen, bringToTop, drawArc, drawArc, drawCircle, drawEllipse, drawImage, drawLine, drawRect, drawRectOutline, drawRoundedRect, drawRoundedRectOutline, drawText, getAbsoluteParent, getChildren, getHeight, getMaxScrollX, getMaxScrollY, getParent, getScrollSpeed, getScrollX, getScrollY, getWidth, getX, getXA, getY, getYA, intersectScissor, isAlwaysOnTop, isHovered, isPointOver, isScrollable, isScrollLock, isVisible, isVisibleWithinParent, isVisibleWithinWindow, onInitialize, onKeyPress, onKeyRelease, onKeyRepeat, onLeftMouseDown, onLeftMouseDownOutside, onLeftMouseUp, onLeftMouseUpOutside, onMouseEnter, onMouseExit, onMouseMove, onMouseMoveOutside, onMouseWheel, onRightMouseDown, onRightMouseDownOutside, onRightMouseUp, onRightMouseUpOutside, postRender, preRender, removeChild, removeFromScreen, renderChildren, setAlwaysOnTop, setHeight, setMaxScrollX, setMaxScrollY, setScrollable, setScrollLock, setScrollSpeed, setScrollX, setScrollY, setVisible, setWidth, setX, setXA, setY, setYA, update
-
Constructor Details
-
RadioButtonWidget
public RadioButtonWidget(int x, int y, int width, int height, boolean horizontal, BiConsumer<Integer, String> onChangeAction) Constructs aRadioButtonWidget
with the specified position, size, and arrangement.
-
-
Method Details
-
resizeToContent
public void resizeToContent()Resizes theRadioButtonWidget
to fit its content based on the arrangement. Adjusts the width and height according to the number of radio buttons and their dimensions. -
addRadio
Adds a new radio button to theRadioButtonWidget
.- Parameters:
titleText
- the text to display on the new radio button
-
getValues
Returns the list ofRadioButtonWidget.RadioValue
objects representing the radio button options.- Returns:
- the list of
RadioButtonWidget.RadioValue
objects
-
getValueText
Retrieves the text of the currently selected radio button.- Returns:
- the text of the currently selected radio button, or
null
if no radio button is selected
-
getValueText
Retrieves the text of the radio button at the specified index.- Parameters:
index
- the index of the radio button whose text is to be retrieved- Returns:
- the text of the radio button at the specified index, or
null
if the index is out of bounds
-
getValueIndex
public final int getValueIndex()Retrieves the index of the currently selected radio button.- Returns:
- the index of the currently selected radio button, or
-1
if no radio button is selected
-
getFontName
Returns the font name used to render the text in the radio buttons.- Returns:
- the font name
-
setFontName
Sets the font name used to render the text in the radio buttons.- Parameters:
fontName
- the font name
-
getFontSize
public final int getFontSize()Returns the font size used to render the text in the radio buttons.- Returns:
- the font size
-
setFontSize
public final void setFontSize(int fontSize) Sets the font size used to render the text in the radio buttons.- Parameters:
fontSize
- the font size
-
getOffset
public final int getOffset()Returns the offset between radio buttons.- Returns:
- the offset
-
setOffset
public final void setOffset(int offset) Sets the offset between radio buttons.- Parameters:
offset
- the offset
-
getCircleRadius
public final int getCircleRadius()Returns the radius of the circles representing the radio buttons.- Returns:
- the circle radius
-
setCircleRadius
public final void setCircleRadius(int circleRadius) Sets the radius of the circles representing the radio buttons.- Parameters:
circleRadius
- the circle radius
-
getRadioHeight
public final int getRadioHeight()Returns the height of each radio button.- Returns:
- the radio button height
-
setRadioHeight
public final void setRadioHeight(int radioHeight) Sets the height of each radio button.- Parameters:
radioHeight
- the radio button height
-
getRadioWidth
public final int getRadioWidth()Returns the width of each radio button.- Returns:
- the radio button width
-
setRadioWidth
public final void setRadioWidth(int radioWidth) Sets the width of each radio button.- Parameters:
radioWidth
- the radio button width
-
getTextColor
Returns the color of the text in the radio buttons.- Returns:
- the text color
-
setTextColor
Sets the color of the text in the radio buttons.- Parameters:
textColor
- the text color
-
getAccentColor
Returns the color used to accent the selected radio button.- Returns:
- the accent color
-
setAccentColor
Sets the color used to accent the selected radio button.- Parameters:
accentColor
- the accent color
-
getCircleColor
Returns the color of the circles representing the radio buttons.- Returns:
- the circle color
-
setCircleColor
Sets the color of the circles representing the radio buttons.- Parameters:
circleColor
- the circle color
-
render
public void render()Renders theWidget
. This implementation does not perform rendering; rendering is handled by the nestedRadioButtonWidget.RadioValue
class.
-