Class Button

    • Field Detail

      • DEFAULT_SPACING_X

        public static final float DEFAULT_SPACING_X
        0.20000000298023224f
        See Also:
        Constant Field Values
      • DEFAULT_SPACING_Y

        public static final float DEFAULT_SPACING_Y
        0.46000000834465027f
        See Also:
        Constant Field Values
      • DEFAULT_LABEL_ZOFFSET

        public static final float DEFAULT_LABEL_ZOFFSET
        Default Z-axis offset, using the smallest resolvable Z separation rounded value 1.5300000086426735E-4f at 16-bits depth buffer, -1 z-distance and 0.1 z-near, used to separate the BaseButton from the Label.

        FloatUtil.getZBufferEpsilon(int, float, float)

         1.5256461E-4 = 16 zBits, -0.2 zDist, 0.1 zNear
         6.1033297E-6 = 16 zBits, -1.0 zDist, 0.1 zNear
         

        See Also:
        Constant Field Values
    • Constructor Detail

      • Button

        public Button​(int renderModes,
                      Font labelFont,
                      CharSequence labelText,
                      float width,
                      float height,
                      float zOffset)
        Create a text labeled button Graph based GLRegion UI Shape.
        Parameters:
        renderModes - Graph's Region render modes, see create(..).
        labelFont - Font for the label
        labelText - the label text
        width - width of the button
        height - height of the button
        zOffset - the Z-axis offset, used to separate the BaseButton from the Label
        See Also:
        FloatUtil.getZBufferEpsilon(int, float, float)
      • Button

        public Button​(int renderModes,
                      Font labelFont,
                      CharSequence labelTextOff,
                      CharSequence labelTextOn,
                      float width,
                      float height,
                      float zOffset)
        Create a text labeled button Graph based GLRegion UI Shape.

        If labelTextOn is not null, constructor enables toggle-able mode to automatically switch the labels depending on Shape.isToggleOn().

        Parameters:
        renderModes - Graph's Region render modes, see create(..).
        labelFont - Font for the label
        labelTextOff - the label text of the toggle-off state (current at creation), see Shape.isToggleOn()
        labelTextOn - optional label text of the toggle-on state, see Shape.isToggleOn(). If not null, enables toggle-able mode.
        width - width of the button
        height - height of the button
        zOffset - the Z-axis offset, used to separate the BaseButton from the Label
        See Also:
        FloatUtil.getZBufferEpsilon(int, float, float)
    • Method Detail

      • getFont

        public Font getFont()
        Returns the label Font.
      • getText

        public CharSequence getText()
        Returns the text of the current label.
      • getLabelZOffset

        public float getLabelZOffset()
      • setLabelZOffset

        public Button setLabelZOffset​(float v)
        Set the Z-axis offset to the given value, used to separate the BaseButton from the Label.
        Parameters:
        v - the zoffset
        Returns:
        this instance for chaining
        See Also:
        FloatUtil.getZBufferEpsilon(int, float, float)
      • setLabelZOffset

        public Button setLabelZOffset​(int zBits,
                                      float zDist,
                                      float zNear)
        Set the Z-axis offset to the smallest resolvable Z separation at the given range, used to separate the BaseButton from the Label.
        Parameters:
        zBits - number of bits of Z precision, i.e. z-buffer depth
        zDist - distance from the eye to the object
        zNear - distance from eye to near clip plane
        Returns:
        this instance for chaining
        See Also:
        FloatUtil.getZBufferEpsilon(int, float, float), Scene.getZEpsilon(int, com.jogamp.graph.ui.Scene.PMVMatrixSetup)
      • getFixedLabelSize

        public final com.jogamp.math.Vec2f getFixedLabelSize()
        Returns the current fixed label font size, see and setSpacing(Vec2f, Vec2f).
      • setFixedLabelSize

        public final Button setFixedLabelSize​(float w,
                                              float h)
        Sets fixed label font size clipped to range [0 .. 1], defaults to 0, 0.

        Use w=0, h=1 when using single symbols from fixed sized symbol fonts! Use setSpacing(Vec2f, Vec2f) to also set spacing.

        The fixed label font size is used as the denominator when scaling.max(fixedLabelSize, fontLabelSize), hence reasonable values are either 1 to enable using the given font-size for the axis or 0 to scale up/down the font to match the button box less spacing for the axis.

        See Also:
        setSpacing(Vec2f, Vec2f), setSpacing(Vec2f)
      • setFixedLabelSize

        public final Button setFixedLabelSize​(com.jogamp.math.Vec2f v)
      • getSpacing

        public final com.jogamp.math.Vec2f getSpacing()
        Returns the current spacing size, see and setSpacing(Vec2f, Vec2f).
      • setSpacing

        public final Button setSpacing​(com.jogamp.math.Vec2f spacing)
        Sets spacing in percent of text label, clipped to range [0 .. 1].
        Parameters:
        spacingX - spacing in percent on X, default is DEFAULT_SPACING_X
        spacingY - spacing in percent on Y, default is DEFAULT_SPACING_Y
        See Also:
        setSpacing(Vec2f, Vec2f)
      • getLabelColor

        public final com.jogamp.math.Vec4f getLabelColor()
        Returns the label color.
      • setLabelColor

        public final Button setLabelColor​(com.jogamp.math.Vec4f c)
        Sets the label color, consider using alpha 1
      • setLabelColor

        public final Button setLabelColor​(float r,
                                          float g,
                                          float b,
                                          float a)
        Sets the label color, consider using alpha 1
      • setFont

        public final Button setFont​(Font labelFont)
        Sets the label font.
      • setText

        public final Button setText​(CharSequence labelText)
        Sets the current label text.
      • setText

        public final Button setText​(Font labelFont,
                                    CharSequence labelText)
        Sets the current label text.