Class RadioButtonWidget

java.lang.Object
com.avrix.ui.widgets.Widget
com.avrix.ui.widgets.RadioButtonWidget

public class RadioButtonWidget extends Widget
A Widget that represents a set of radio buttons. The radio buttons can be arranged either horizontally or vertically.
  • Constructor Details

    • RadioButtonWidget

      public RadioButtonWidget(int x, int y, int width, int height, boolean horizontal, BiConsumer<Integer,String> onChangeAction)
      Constructs a RadioButtonWidget with the specified position, size, and arrangement.
      Parameters:
      x - the x-coordinate of the Widget
      y - the y-coordinate of the Widget
      width - the width of the Widget
      height - the height of the Widget
      horizontal - whether the radio buttons are arranged horizontally
      onChangeAction - the action to perform when the selected radio button changes
  • Method Details

    • resizeToContent

      public void resizeToContent()
      Resizes the RadioButtonWidget to fit its content based on the arrangement. Adjusts the width and height according to the number of radio buttons and their dimensions.
    • addRadio

      public void addRadio(String titleText)
      Adds a new radio button to the RadioButtonWidget.
      Parameters:
      titleText - the text to display on the new radio button
    • getValues

      public final List<RadioButtonWidget.RadioValue> getValues()
      Returns the list of RadioButtonWidget.RadioValue objects representing the radio button options.
      Returns:
      the list of RadioButtonWidget.RadioValue objects
    • getValueText

      public final String 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

      public final String getValueText(int index)
      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

      public final String getFontName()
      Returns the font name used to render the text in the radio buttons.
      Returns:
      the font name
    • setFontName

      public final void setFontName(String fontName)
      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

      public final NanoColor getTextColor()
      Returns the color of the text in the radio buttons.
      Returns:
      the text color
    • setTextColor

      public final void setTextColor(NanoColor textColor)
      Sets the color of the text in the radio buttons.
      Parameters:
      textColor - the text color
    • getAccentColor

      public final NanoColor getAccentColor()
      Returns the color used to accent the selected radio button.
      Returns:
      the accent color
    • setAccentColor

      public final void setAccentColor(NanoColor accentColor)
      Sets the color used to accent the selected radio button.
      Parameters:
      accentColor - the accent color
    • getCircleColor

      public final NanoColor getCircleColor()
      Returns the color of the circles representing the radio buttons.
      Returns:
      the circle color
    • setCircleColor

      public final void setCircleColor(NanoColor circleColor)
      Sets the color of the circles representing the radio buttons.
      Parameters:
      circleColor - the circle color
    • render

      public void render()
      Renders the Widget. This implementation does not perform rendering; rendering is handled by the nested RadioButtonWidget.RadioValue class.
      Specified by:
      render in class Widget