28package com.jogamp.graph.ui.shapes;
30import com.jogamp.graph.curve.Region;
31import com.jogamp.graph.curve.opengl.GLRegion;
32import com.jogamp.graph.ui.Group;
33import com.jogamp.graph.ui.Scene;
34import com.jogamp.graph.ui.Shape;
35import com.jogamp.graph.ui.layout.Alignment;
36import com.jogamp.graph.ui.layout.BoxLayout;
37import com.jogamp.graph.ui.layout.Padding;
38import com.jogamp.math.Vec2f;
39import com.jogamp.math.Vec3f;
40import com.jogamp.math.Vec4f;
41import com.jogamp.math.geom.AABBox;
42import com.jogamp.math.util.PMVMatrix4f;
43import com.jogamp.opengl.GL2ES2;
44import com.jogamp.opengl.GLProfile;
45import com.jogamp.opengl.util.texture.TextureSequence;
47import jogamp.graph.ui.TreeTool;
63 private final boolean hasFrame;
66 private final Vec4f backColor =
new Vec4f(0.9f, 0.9f, 0.9f, 0.9f);
67 private final Vec4f frontColor =
new Vec4f(0.1f, 0.1f, 0.1f, 0.9f);
69 private final Scene scene;
71 private final Shape targetShape;
73 private Shape clientShape;
75 private static final boolean DEBUG =
false;
89 public HUDShape(
final Scene scene,
final float clientWidth,
final float clientHeight,
90 final int renderModes,
final Shape targetShape,
final Shape clientShape) {
91 this(scene, clientWidth, clientHeight,
null,
null, 0,
null, renderModes, targetShape, clientShape);
109 public HUDShape(
final Scene scene,
final float clientWidth,
final float clientHeight,
110 final Vec4f backColor,
final Vec4f borderColor,
final float borderThickness,
111 final Padding padding,
final int renderModes,
final Shape targetShape,
final Shape clientShape) {
113 this.hasFrame =
null != backColor;
114 this.clientSize.
set(clientWidth, clientHeight);
116 this.backColor.
set(backColor);
118 if(
null != frontColor ) {
119 this.frontColor.
set(frontColor);
122 this.targetShape = targetShape;
123 this.clientShape = clientShape;
135 final Group wrapper =
new Group(
"HUD.wrapper",
null,
null, clientShape);
136 if(
null != padding ) {
151 tmpB0.
reset().
setSize(clientPos, tmpV0.
set(clientPos).
add(clientSize.x(), clientSize.y(), 0));
152 final Vec3f hudSize = tmpV0;
153 final Vec3f hudPos = tmpV1;
155 TreeTool.forOne(scene, pmv, targetShape, () -> {
163 if( hudPos.x() < sb.
getMinX() ) {
165 }
else if( hudPos.x() + hudSize.x() > sb.
getMaxX() ) {
168 if( hudPos.y() < sb.
getMinY() ) {
170 }
else if( hudPos.y() + hudSize.y() > sb.
getMaxY() ) {
174 System.err.println(
"HUD validate");
175 System.err.println(
"HUD Target b "+targetShape.
getBounds());
176 System.err.println(
"HUD Scene b "+scene.
getBounds());
179 if( !hudSizeOld.
isEqual(hudSize) ||
null ==
this.getLayout() ) {
181 System.err.println(
"HUD size.1 "+clientSize+
" -> "+hudSize);
184 hudSizeOld.
set(hudSize);
186 System.err.println(
"HUD size.0 "+clientSize+
" -> "+hudSize);
190 super.validateImpl(gl, glp);
192 System.err.println(
"HUD client b "+clientShape.
getBounds());
193 System.err.println(
"HUD this b "+this.
getBounds());
194 System.err.println(
"HUD pos "+clientPos+
" -> "+hudPos);
209 this.clientPos.
set(clientPos);
218 this.clientPos.
add(clientDelta);
225 this.clientSize.
set(clientWidth, clientHeight);
247 final Shape cs = clientShape;
252 System.err.println(
"HUDShape.destroyTip: Warning: ClientShape "+cs.
getName()+
" not contained in "+tipWrapper.
getName()+
"; Internal Group: ");
253 TreeTool.forAll(
this, (
final Shape s) -> {
254 System.err.println(
"- "+s.
getName());
Group of Shapes, optionally utilizing a Group.Layout.
Group()
Create a group of Shapes w/o Group.Layout.
Shape getShapeByIdx(final int id)
void addShape(final Shape s)
Adds a Shape.
Shape removeShape(final Shape s)
Removes given shape, w/o Shape#destroy(GL2ES2, RegionRenderer).
Group setLayout(final Layout l)
Set Group.Layout.
boolean isShapeDirty()
Returns the shape's dirty state, see markShapeDirty().
float getActiveTopLevelZOffsetScale()
Returns the general top-level widget Z-Offset scale, defaults to DEFAULT_ACTIVE_ZOFFSET_SCALE.
static float getZEpsilon(final int zBits, final PMVMatrixSetup setup)
Default Z precision on 16-bit depth buffer using -1 z-position and DEFAULT_ZNEAR.
AABBox getBounds(final PMVMatrix4f pmv, final Shape shape)
Returns AABBox dimension of given Shape from this container's perspective, i.e.
Generic Shape, potentially using a Graph via GraphShape or other means of representing content.
Shape setColor(final float r, final float g, final float b, final float a)
Set base color.
Shape setName(final String name)
Set a symbolic name for this shape for identification.
final String getName()
Return the optional symbolic name for this shape, defaults to noname.
final Shape move(final float dtx, final float dty, final float dtz)
Move about scaled distance.
final Shape setInteractive(final boolean v)
Set whether this shape is interactive in general, i.e.
final Shape moveTo(final float tx, final float ty, final float tz)
Move to scaled position.
final AABBox getBounds()
Returns the unscaled bounding AABBox for this shape, borrowing internal instance.
final Shape validate(final GL2ES2 gl)
Validates the shape's underlying GLRegion.
final void markShapeDirty()
Marks the shape dirty, causing next draw() to recreate the Graph shape and reset the region.
final Shape setPaddding(final Padding padding)
Sets the unscaled padding for this shape, which is included in unscaled getBounds() and also includes...
final Shape setBorderColor(final float r, final float g, final float b, final float a)
Set border color.
final Shape setBorder(final float thickness)
Sets the thickness of the border, which is included in getBounds() and is outside of getPadding().
Immutable layout alignment options, including Bit#Fill.
static final Alignment FillCenter
Bit#Fill, Bit#CenterHoriz and Bit#CenterVert alignment constant.
GraphUI Stack Group.Layout.
GraphUI CSS property Padding, unscaled space belonging to the element and included in the element's s...
A Head Up Display (HUD) Shape for a client Shape using inner size and Mv position to be displayed on ...
void validateImpl(final GL2ES2 gl, final GLProfile glp)
Shape getClientShape()
Returns the client Shape to be presented in the HUD tip.
Vec2f getClientSize()
Returns the client Shape size of this HUD in given targetShape object Mv-space, not Scene.
Shape removeClient()
Removed the user provided client Shape from this HUD.
HUDShape setClientSize(final float clientWidth, final float clientHeight)
Sets the client Shape size of this HUD in given targetShape object Mv-space, not Scene.
Vec3f getClientPos()
Returns the client Shape position of this HUD in given targetShape object Mv-space,...
HUDShape moveHUDPos(final Vec3f clientDelta)
Move about scaled HUD position with given clientDelta in targetShape object Mv-space coordinates.
HUDShape(final Scene scene, final float clientWidth, final float clientHeight, final Vec4f backColor, final Vec4f borderColor, final float borderThickness, final Padding padding, final int renderModes, final Shape targetShape, final Shape clientShape)
Ctor of HUDShape.
HUDShape(final Scene scene, final float clientWidth, final float clientHeight, final int renderModes, final Shape targetShape, final Shape clientShape)
Ctor of HUDShape.
HUDShape moveToHUDPos(final Vec3f clientPos)
Move to scaled HUD position with given clientPos in targetShape object Mv-space coordinates.
Shape getTargetShape()
Returns the target Shape this HUD is put on top, used to resolve the Mv matrix for HUD size and posit...
A GraphUI rectangle GraphShape.
2D Vector based upon two float components.
void set(final Vec2f o)
this = o, returns this.
3D Vector based upon three float components.
boolean isEqual(final Vec3f o, final float epsilon)
Equals check using a given FloatUtil#EPSILON value and FloatUtil#isEqual(float, float,...
Vec3f set(final Vec3f o)
this = o, returns this.
Vec3f add(final float dx, final float dy, final float dz)
this = this + { dx, dy, dz }, returns this.
4D Vector based upon four float components.
Vec4f set(final Vec4f o)
this = o, returns this.
Axis Aligned Bounding Box.
final Vec3f getLow()
Returns the minimum left-bottom-far (xyz) coordinate.
final AABBox reset()
Resets this box to the inverse low/high, allowing the next resize(float, float, float) command to hit...
final AABBox setSize(final float[] low, final float[] high)
Set size of the AABBox specifying the coordinates of the low and high.
AABBox transform(final Matrix4f mat, final AABBox out)
Transform this box using the given Matrix4f into out @endiliteral.
PMVMatrix4f implements the basic computer graphics Matrix4f pack using projection (P),...
final Matrix4f getMv()
Returns the modelview matrix (Mv).
Specifies the the OpenGL profile.