Package com.jogamp.graph.ui.shapes
Class Label
- java.lang.Object
-
- com.jogamp.graph.ui.Shape
-
- com.jogamp.graph.ui.GraphShape
-
- com.jogamp.graph.ui.shapes.Label
-
public class Label extends GraphShape
A GraphUI text labelGraphShape
GraphUI is GPU based and resolution independent.
-
-
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 inherited from class com.jogamp.graph.ui.Shape
ZAscendingComparator, ZDescendingComparator
-
-
Constructor Summary
Constructors Constructor Description Label(int renderModes, Font font, float fontScale, CharSequence text)
Label ctor using a separatefontScale
to scale the em-sized type glyphs.Label(int renderModes, Font font, CharSequence text)
Label ctor using em-size type glyphs
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Font
getFont()
Returns theFont
used to render the textfloat
getFontScale()
Returns the font-scale factor, by which the em-sized type glyphs shall be scaled.float
getLineHeight()
ReturnsFont.getLineHeight()
*getFontScale()
.float
getScaledLineHeight()
String
getSubString()
CharSequence
getText()
Returns the label text.com.jogamp.math.geom.AABBox
getUnscaledGlyphBounds()
Convenient shortcut toFont.getGlyphBounds(CharSequence, AffineTransform, AffineTransform)
usinggetFont()
andgetText()
.static com.jogamp.math.geom.AABBox
getUnscaledGlyphBounds(Font font, CharSequence text)
Convenient shortcut toFont.getGlyphBounds(CharSequence, AffineTransform, AffineTransform)
.boolean
setFont(Font font)
Set theFont
used to render the textboolean
setFontScale(float fontScale)
Sets the font-scale factor, by which the em-sized type glyphs shall be scaled.boolean
setText(GL2ES2 gl, CharSequence text)
Set the text to be rendered and immediately updates the shape if necessary.boolean
setText(GLProfile glp, CharSequence text)
Set the text to be rendered and immediately updates the shape if necessary.boolean
setText(CharSequence text)
Set the text to be rendered.-
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, draw, 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
-
-
-
-
Constructor Detail
-
Label
public Label(int renderModes, Font font, float fontScale, CharSequence text)
Label ctor using a separatefontScale
to scale the em-sized type glyphs.If possible, try using
Label(int, Font, CharSequence)
andShape.scale(float, float, float)
.- Parameters:
renderModes
- Graph'sRegion
render modes, seecreate(..)
.font
-Font
for this labelfontScale
- font-scale factor, by which the em-sized type glyphs shall be scaledtext
- the label text- See Also:
Label(int, Font, CharSequence)
-
Label
public Label(int renderModes, Font font, CharSequence text)
Label ctor using em-size type glyphs- Parameters:
renderModes
- Graph'sRegion
render modes, seecreate(..)
.font
-Font
for this labeltext
- the label text- See Also:
Label(int, Font, float, CharSequence)
-
-
Method Detail
-
getText
public CharSequence getText()
Returns the label text.
-
setText
public boolean setText(CharSequence text)
Set the text to be rendered. Shape update is pending until nextShape.draw(GL2ES2, RegionRenderer)
orShape.validate(GL2ES2)
.- Parameters:
text
- the text to be set.- Returns:
- true if text has been updated, false if unchanged.
-
setText
public boolean setText(GL2ES2 gl, CharSequence text)
Set the text to be rendered and immediately updates the shape if necessary.- Parameters:
gl
-GL2ES2
to issueShape.validate(GL2ES2)
in case text changed to immediately update shape andShape.getBounds()
text
- the text to be set.- Returns:
- true if text has been updated, false if unchanged.
-
setText
public boolean setText(GLProfile glp, CharSequence text)
Set the text to be rendered and immediately updates the shape if necessary.- Parameters:
glp
-GLProfile
to issueShape.validate(GLProfile)
in case text changed to immediately update shape andShape.getBounds()
text
- the text to be set.- Returns:
- true if text has been updated, false if unchanged.
-
setFont
public boolean setFont(Font font)
Set theFont
used to render the text- Parameters:
font
- the font to be set.- Returns:
- true if font has been updated, false if unchanged.
-
getFontScale
public float getFontScale()
Returns the font-scale factor, by which the em-sized type glyphs shall be scaled.
-
getLineHeight
public float getLineHeight()
ReturnsFont.getLineHeight()
*getFontScale()
.
-
getScaledLineHeight
public float getScaledLineHeight()
-
setFontScale
public boolean setFontScale(float fontScale)
Sets the font-scale factor, by which the em-sized type glyphs shall be scaled.This will lead to a recreate the shape's region in case fontScale differs.
Use
Shape.scale(float, float, float)
for non-expensive shape scaling.- Parameters:
fontScale
- font-scale factor, by which the em-sized type glyphs shall be scaled- Returns:
- true if font-scale has been updated, false if unchanged.
-
getUnscaledGlyphBounds
public static com.jogamp.math.geom.AABBox getUnscaledGlyphBounds(Font font, CharSequence text)
Convenient shortcut toFont.getGlyphBounds(CharSequence, AffineTransform, AffineTransform)
.
-
getUnscaledGlyphBounds
public com.jogamp.math.geom.AABBox getUnscaledGlyphBounds()
Convenient shortcut toFont.getGlyphBounds(CharSequence, AffineTransform, AffineTransform)
usinggetFont()
andgetText()
.
-
getSubString
public String getSubString()
- Overrides:
getSubString
in classGraphShape
-
-