Class Button
- java.lang.Object
-
- com.jogamp.graph.ui.Shape
-
- com.jogamp.graph.ui.GraphShape
-
- com.jogamp.graph.ui.shapes.BaseButton
-
- com.jogamp.graph.ui.shapes.Button
-
public class Button extends BaseButton
A GraphUI text labeledBaseButtonGraphShapeGraphUI is GPU based and resolution independent.
This button is rendered with a round oval shape. To render it rectangular,
BaseButton.setCorner(float)to zero.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.jogamp.graph.ui.Shape
Shape.DrawListener, Shape.EventInfo, Shape.ForwardKeyListener, Shape.ForwardMouseListener, Shape.Listener, Shape.MouseGestureAdapter, Shape.MouseGestureListener, Shape.MoveListener, Shape.PointerListener, Shape.Visitor1, Shape.Visitor2
-
-
Field Summary
Fields Modifier and Type Field Description static floatDEFAULT_LABEL_ZOFFSETDefaultZ-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 theBaseButtonfrom theLabel.static floatDEFAULT_SPACING_X0.20000000298023224fstatic floatDEFAULT_SPACING_Y0.46000000834465027f-
Fields inherited from class com.jogamp.graph.ui.shapes.BaseButton
PERP_CORNER, ROUND_CORNER
-
Fields inherited from class com.jogamp.graph.ui.Shape
ZAscendingComparator, ZDescendingComparator
-
-
Constructor Summary
Constructors Constructor Description Button(int renderModes, Font labelFont, CharSequence labelText, float width, float height)Button(int renderModes, Font labelFont, CharSequence labelText, float width, float height, float zOffset)Button(int renderModes, Font labelFont, CharSequence labelTextOff, CharSequence labelTextOn, float width, float height, float zOffset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddraw(GL2ES2 gl, RegionRenderer renderer)Renders the shape.com.jogamp.math.Vec2fgetFixedLabelSize()Returns the current fixed label font size, see andsetSpacing(Vec2f, Vec2f).FontgetFont()Returns the labelFont.com.jogamp.math.Vec4fgetLabelColor()Returns the label color.floatgetLabelZOffset()com.jogamp.math.Vec2fgetSpacing()Returns the current spacing size, see andsetSpacing(Vec2f, Vec2f).StringgetSubString()CharSequencegetText()Returns the text of the current label.ButtonsetFixedLabelSize(float w, float h)Sets fixed label font size clipped to range [0 ..ButtonsetFixedLabelSize(com.jogamp.math.Vec2f v)ButtonsetFont(Font labelFont)Sets the label font.ButtonsetLabelColor(float r, float g, float b, float a)Sets the label color, consider using alpha 1ButtonsetLabelColor(com.jogamp.math.Vec4f c)Sets the label color, consider using alpha 1ButtonsetLabelZOffset(float v)Set the Z-axis offset to the given value, used to separate theBaseButtonfrom theLabel.ButtonsetLabelZOffset(int zBits, float zDist, float zNear)Set the Z-axis offset to the smallest resolvable Z separation at the given range, used to separate theBaseButtonfrom theLabel.ButtonsetSpacing(float spacingX, float spacingY)Sets spacing in percent of text label, clipped to range [0 ..ButtonsetSpacing(com.jogamp.math.Vec2f spacing)Sets spacing in percent of text label, clipped to range [0 ..ButtonsetSpacing(com.jogamp.math.Vec2f spacing, com.jogamp.math.Vec2f fixedLabelSize)Sets spacingsetSpacing(Vec2f)and fixed label font sizesetFixedLabelSize(Vec2f)for convenience.ButtonsetText(Font labelFont, CharSequence labelText)Sets the current label text.ButtonsetText(CharSequence labelText)Sets the current label text.-
Methods inherited from class com.jogamp.graph.ui.shapes.BaseButton
getCorner, getHeight, getWidth, setCorner, setPerp, setSize
-
Methods inherited from class com.jogamp.graph.ui.GraphShape
getRegion, getRenderModes, getRenderModesReq, getSharpness, hasColorChannel, setSharpness, setTextureUnit
-
Methods inherited from class com.jogamp.graph.ui.Shape
addActivationListener, addKeyListener, addMouseListener, applyMatToMv, clear, destroy, drawToSelect, getActiveColorMod, getAdjustedZ, getBorderColor, getBorderThickness, getBounds, getBounds, getColor, getID, getMat, getMat, getName, getPadding, getParent, getPixelPerShapeUnit, getPixelPerShapeUnit, getPixelPerShapeUnit, getPosition, getPressedColorMod, getRotation, getRotationPivot, getScale, getScaledDepth, getScaledHeight, getScaledWidth, getSurfacePort, getSurfaceSize, getSurfaceSize, getSurfaceSize, getToggleOffColorMod, getToggleOnColorMod, getTooltip, hasBorder, hasPadding, isActivable, isActive, isDiscarded, isDraggable, isFixedARatioResize, isGroup, isInteractive, isMatIdentity, isPressed, isResizable, isToggleable, isToggleOn, isVisible, markShapeDirty, markStateDirty, move, move, moveTo, moveTo, onClicked, onDraw, onHover, onMove, onToggle, receiveKeyEvents, receiveMouseEvents, removeActivationListener, removeKeyListener, removeMouseListener, removeToolTip, runSynced, scale, scale, setActivable, setActiveColorMod, setBorder, setBorderColor, setBorderColor, setColor, setColor, setDiscarded, setDragAndResizable, setDraggable, setFixedARatioResize, setID, setInteractive, setName, setPaddding, setPMVMatrix, setPMVMatrix, setPressed, setPressedColorMod, setResizable, setRotation, setRotationPivot, setRotationPivot, setScale, setScale, setToggle, setToggleable, setToggleOffColorMod, setToggleOnColorMod, setToolTip, setVisible, shapeToWinCoord, shapeToWinCoord, shapeToWinCoord, toggle, toString, updateMat, validate, validate, validate, winToShapeCoord, winToShapeCoord, winToShapeCoord
-
-
-
-
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
DefaultZ-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 theBaseButtonfrom theLabel.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)Create a text labeled button Graph basedGLRegionUIShape.Sets the
Z-axis offsetto a default smallest resolvable Z separation rounded value0.000153at 16-bits depth buffer, -1 z-distance and 0.1 z-near, used to separate theBaseButtonfrom theLabel.- Parameters:
renderModes- Graph'sRegionrender modes, seecreate(..).labelFont-Fontfor the labellabelText- the label textwidth- width of the buttonheight- height of the button- See Also:
Button(int, Font, CharSequence, float, float, float)
-
Button
public Button(int renderModes, Font labelFont, CharSequence labelText, float width, float height, float zOffset)- Parameters:
renderModes- Graph'sRegionrender modes, seecreate(..).labelFont-Fontfor the labellabelText- the label textwidth- width of the buttonheight- height of the buttonzOffset- the Z-axis offset, used to separate theBaseButtonfrom theLabel- 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 basedGLRegionUIShape.If
labelTextOnis notnull, constructor enablestoggle-ablemode to automatically switch the labels depending onShape.isToggleOn().- Parameters:
renderModes- Graph'sRegionrender modes, seecreate(..).labelFont-Fontfor the labellabelTextOff- the label text of the toggle-off state (current at creation), seeShape.isToggleOn()labelTextOn- optional label text of the toggle-on state, seeShape.isToggleOn(). If notnull, enablestoggle-ablemode.width- width of the buttonheight- height of the buttonzOffset- the Z-axis offset, used to separate theBaseButtonfrom theLabel- See Also:
FloatUtil.getZBufferEpsilon(int, float, float)
-
-
Method Detail
-
getText
public CharSequence getText()
Returns the text of the current label.
-
draw
public void draw(GL2ES2 gl, RegionRenderer renderer)
Description copied from class:ShapeRenders the shape.Shape.applyMatToMv(PMVMatrix4f)is expected to be completed beforehand.- Overrides:
drawin classShape- Parameters:
gl- the current GL objectrenderer-RegionRendererwhich might be used for Graph Curve Rendering, also source ofRegionRenderer.getMatrix()andRegionRenderer.getViewport().
-
getLabelZOffset
public float getLabelZOffset()
-
setLabelZOffset
public Button setLabelZOffset(float v)
Set the Z-axis offset to the given value, used to separate theBaseButtonfrom theLabel.- 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 theBaseButtonfrom theLabel.- Parameters:
zBits- number of bits of Z precision, i.e. z-buffer depthzDist- distance from the eye to the objectzNear- 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 andsetSpacing(Vec2f, Vec2f).
-
setFixedLabelSize
public final Button setFixedLabelSize(float w, float h)
Sets fixed label font size clipped to range [0 .. 1], defaults to0, 0.Use
w=0, h=1when using single symbols from fixed sized symbol fonts! UsesetSpacing(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 either1to enable using the given font-size for the axis or0to 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 andsetSpacing(Vec2f, Vec2f).
-
setSpacing
public final Button setSpacing(float spacingX, float spacingY)
Sets spacing in percent of text label, clipped to range [0 .. 1].- Parameters:
spacingX- spacing in percent on X, default isDEFAULT_SPACING_XspacingY- spacing in percent on Y, default isDEFAULT_SPACING_Y- See Also:
setSpacing(Vec2f),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 isDEFAULT_SPACING_XspacingY- spacing in percent on Y, default isDEFAULT_SPACING_Y- See Also:
setSpacing(Vec2f, Vec2f)
-
setSpacing
public final Button setSpacing(com.jogamp.math.Vec2f spacing, com.jogamp.math.Vec2f fixedLabelSize)
Sets spacingsetSpacing(Vec2f)and fixed label font sizesetFixedLabelSize(Vec2f)for convenience.- See Also:
setSpacing(Vec2f),setFixedLabelSize(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
-
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.
-
getSubString
public String getSubString()
- Overrides:
getSubStringin classBaseButton
-
-