diff options
author | Sven Gothel <[email protected]> | 2023-04-28 12:40:23 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-04-28 12:40:23 +0200 |
commit | 87814f1c86b132a16ddf6822d05b83c3ed091fe2 (patch) | |
tree | 885134dd7398a748a0837b536a26771c933dafd2 /src/graphui/classes/com/jogamp/graph/ui/shapes | |
parent | bd10664189e944699492008776819a28a2d95ecf (diff) |
GraphUI Revise Padding and Border: Padding + Border belong to Shape's bounds. Account for both (seperately) and add border rendering to Group as well.
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui/shapes')
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java index 90433a45e..2b9698e3a 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Rectangle.java @@ -31,42 +31,70 @@ import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.ui.GraphShape; import com.jogamp.opengl.GL2ES2; import com.jogamp.opengl.GLProfile; +import com.jogamp.opengl.math.geom.AABBox; /** - * A GraphUI Rectangle {@link GraphShape} + * A GraphUI rectangle {@link GraphShape} * <p> * GraphUI is GPU based and resolution independent. * </p> */ public class Rectangle extends GraphShape { - private float width, height, lineWidth; + private float minX, minY, zPos; + private float width; + private float height; + private float lineWidth; - public Rectangle(final int renderModes, final float width, final float height, final float linewidth) { + public Rectangle(final int renderModes, final float minX, final float minY, final float width, final float height, final float lineWidth, final float zPos) { super(renderModes); + this.minX = minX; + this.minY = minY; + this.zPos = zPos; this.width = width; this.height = height; - this.lineWidth = linewidth; + this.lineWidth = lineWidth; + } + + public Rectangle(final int renderModes, final AABBox abox, final float lineWidth) { + this( renderModes, abox.getMinX(), abox.getMinY(), abox.getWidth(), abox.getHeight(), lineWidth, abox.getCenter().z()); + } + + public Rectangle(final int renderModes, final float minX, final float minY, final float width, final float height, final float lineWidth) { + this( renderModes, minX, minY, width, height, lineWidth, 0); + } + public Rectangle(final int renderModes, final float width, final float height, final float lineWidth) { + this( renderModes, 0, 0, width, height, lineWidth, 0); } public final float getWidth() { return width; } public final float getHeight() { return height; } public final float getLineWidth() { return lineWidth; } + public void setPosition(final float minX, final float minY, final float zPos) { + this.minX = minX; + this.minY = minY; + this.zPos = zPos; + markShapeDirty(); + } public void setDimension(final float width, final float height, final float lineWidth) { this.width = width; this.height = height; this.lineWidth = lineWidth; markShapeDirty(); } + public void setBounds(final AABBox abox, final float lineWidth) { + setPosition(abox.getMinX(), abox.getMinY(), abox.getCenter().z()); + setDimension(abox.getWidth(), abox.getHeight(), lineWidth); + } @Override protected void addShapeToRegion(final GLProfile glp, final GL2ES2 gl) { final OutlineShape shape = new OutlineShape(); - final float x1 = 0f; - final float y1 = 0f; - final float x2 = getWidth(); - final float y2 = getHeight(); - final float z = 0f; + final float x1 = minX; + final float y1 = minY; + final float x2 = minX + getWidth(); + final float y2 = minY + getHeight(); + final float z = zPos; { // Outer OutlineShape as Winding.CCW. shape.moveTo(x1, y1, z); |