JOGL v2.6.0-rc-20250712
JOGL, High-Performance Graphics Binding for Java™ (public API).
UILayoutGrid01.java
Go to the documentation of this file.
1/**
2 * Copyright 2010-2023 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28package com.jogamp.opengl.demos.graph.ui;
29
30import java.io.IOException;
31
32import com.jogamp.graph.curve.Region;
33import com.jogamp.graph.font.Font;
34import com.jogamp.graph.font.FontFactory;
35import com.jogamp.graph.font.FontSet;
36import com.jogamp.graph.ui.Group;
37import com.jogamp.graph.ui.Scene;
38import com.jogamp.graph.ui.Shape;
39import com.jogamp.graph.ui.layout.Alignment;
40import com.jogamp.graph.ui.layout.Gap;
41import com.jogamp.graph.ui.layout.GridLayout;
42import com.jogamp.graph.ui.layout.Padding;
43import com.jogamp.graph.ui.shapes.Button;
44import com.jogamp.graph.ui.shapes.Label;
45import com.jogamp.math.FloatUtil;
46import com.jogamp.math.Vec3f;
47import com.jogamp.math.Vec4f;
48import com.jogamp.math.geom.AABBox;
49import com.jogamp.math.geom.plane.AffineTransform;
50import com.jogamp.newt.event.MouseEvent;
51import com.jogamp.newt.event.WindowAdapter;
52import com.jogamp.newt.event.WindowEvent;
53import com.jogamp.newt.opengl.GLWindow;
54import com.jogamp.opengl.GL;
55import com.jogamp.opengl.GLCapabilities;
56import com.jogamp.opengl.GLProfile;
57import com.jogamp.opengl.demos.graph.ui.util.Tooltips;
58import com.jogamp.opengl.demos.util.CommandlineOptions;
59import com.jogamp.opengl.util.Animator;
60
61import jogamp.graph.ui.TreeTool;
62
63/**
64 * Res independent {@link Shape}s in a {@link Group} using a {@link GridLayout}, contained within a Scene attached to GLWindow.
65 * <p>
66 * Pass '-keep' to main-function to keep running after animation,
67 * then user can test Shape drag-move and drag-resize w/ 1-pointer.
68 * </p>
69 */
70public class UILayoutGrid01 {
71 static CommandlineOptions options = new CommandlineOptions(1920, 1080, Region.VBAA_RENDERING_BIT);
72
73 static boolean reLayout = true;
74 static final int reLayoutSleep = 500;
75
76 private static final Vec4f groupBorderColor = new Vec4f(0, 0, 1f, 0.6f);
77 private static final float borderThickness = 0.01f;
78
79 public static void main(final String[] args) throws IOException {
80 if( 0 != args.length ) {
81 final int[] idx = { 0 };
82 for (idx[0] = 0; idx[0] < args.length; ++idx[0]) {
83 if( options.parse(args, idx) ) {
84 continue;
85 } else if (args[idx[0]].equals("-no_relayout")) {
86 reLayout = false;
87 }
88 }
89 }
90 System.err.println(options);
91
92 final GLCapabilities reqCaps = options.getGLCaps();
93 System.out.println("Requested: " + reqCaps);
94
95 final Animator animator = new Animator(0 /* w/o AWT */);
96
97 final GLWindow window = GLWindow.create(reqCaps);
98 window.setSize(options.surface_width, options.surface_height);
99 window.setTitle(UILayoutGrid01.class.getSimpleName()+": "+window.getSurfaceWidth()+" x "+window.getSurfaceHeight());
100 window.addWindowListener(new WindowAdapter() {
101 @Override
102 public void windowResized(final WindowEvent e) {
103 window.setTitle(UILayoutGrid01.class.getSimpleName()+": "+window.getSurfaceWidth()+" x "+window.getSurfaceHeight());
104 }
105 @Override
106 public void windowDestroyNotify(final WindowEvent e) {
107 animator.stop();
108 }
109 });
110
111
112 final int zBits = 16;
113 final Scene scene = new Scene(options.graphAASamples);
115 System.err.println("Z16-Precision: default "+Scene.DEFAULT_Z16_EPSILON);
116 System.err.println("Z16-Precision: zDist -1f, zNear 0.1f "+FloatUtil.getZBufferEpsilon(zBits, -1f, 0.1f));
117 System.err.println("Z16-Precision: current "+scene.getZEpsilon(zBits));
118 scene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
119 scene.setPMvCullingEnabled(true);
120 scene.attachInputListenerTo(window);
121 window.addGLEventListener(scene);
122 window.setVisible(true);
123 scene.waitUntilDisplayed();
124
125 animator.setUpdateFPSFrames(1*60, null); // System.err);
126 animator.add(window);
127 animator.start();
128
129 /**
130 * We can share this instance w/ all UI elements,
131 * since only mouse action / gesture is complete for a single one (press, drag, released and click).
132 */
133 final Shape.MouseGestureAdapter dragZoomRotateListener = new Shape.MouseGestureAdapter() {
134 @Override
135 public void mouseWheelMoved(final MouseEvent e) {
136 final Shape.EventInfo shapeEvent = (Shape.EventInfo) e.getAttachment();
137 final Shape shape = shapeEvent.shape;
138 final Vec3f rot = new Vec3f(e.getRotation()).scale( FloatUtil.PI / 180.0f );
139 // swap axis for onscreen rotation matching natural feel
140 final float tmp = rot.x(); rot.setX( rot.y() ); rot.setY( tmp );
141 shape.setRotation( shape.getRotation().rotateByEuler( rot.scale( 2f ) ) );
142 }
143 };
144
145 //
146 // Resolution independent, no screen size
147 //
149 System.err.println("Font: "+font.getFullFamilyName());
150
151 final AABBox sceneBox = scene.getBounds();
152 final float zEps = scene.getZEpsilon(zBits); // Z Epsilon, i.e. minimum recognized delta (resolution)
153 System.err.println("SceneBox "+sceneBox+", zEps "+zEps);
154
155 final float cellGap = 1.1f;
156 // final float sxy = 1/10f * sceneBox.getWidth();
157 final float sxy = 1/12f * sceneBox.getWidth();
158 // final float sxy = 1/4f * sceneBox.getHeight();
159 final Vec3f nextPos = new Vec3f();
160
161 if( true ) {
162 final Group g = setupGroup(new Group(new GridLayout(1, 1f, 1/2f, Alignment.Fill, new Gap(0.10f))),
163 reqCaps.getGLProfile(), scene, zEps,
164 sxy, nextPos, cellGap,
165 font, 11,
166 (final Group gp) -> {
167 gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
168 } );
169 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
170 }
171
172 if( true ) {
173 final Group g = setupGroup(new Group(new GridLayout(1, 1f, 1/2f, Alignment.Fill, new Gap(0.10f))),
174 reqCaps.getGLProfile(), scene, zEps,
175 sxy, nextPos, cellGap,
176 font, 12,
177 (final Group gp) -> {
178 gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
179 gp.addShape( new Button(options.renderModes, font, "r1 r1", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
180 } );
181 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
182 }
183
184 if( true ) {
185 final Group g = setupGroup(new Group(new GridLayout(1f, 1/2f, Alignment.Fill, new Gap(0.10f), 1)),
186 reqCaps.getGLProfile(), scene, zEps,
187 sxy, nextPos, cellGap,
188 font, 13,
189 (final Group gp) -> {
190 gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
191 gp.addShape( new Button(options.renderModes, font, "r1 c1", 1f, 1/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
192 } );
193 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
194 }
195
196 if( true ) {
197 final Group g = setupGroup(new Group(new GridLayout(2, 1f, 1/2f, Alignment.Fill, new Gap(0.10f))),
198 reqCaps.getGLProfile(), scene, zEps,
199 sxy, nextPos, cellGap,
200 font, 14,
201 (final Group gp) -> {
202 gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
203 gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
204 gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
205 gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
206 } );
207 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
208 }
209
210 if( true ) {
211 final Group g = setupGroup(new Group(new GridLayout(2, 1f, 1/2f, Alignment.Fill, new Gap(0.10f))),
212 reqCaps.getGLProfile(), scene, zEps,
213 sxy, nextPos, cellGap,
214 font, 15,
215 (final Group gp) -> {
216 gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
217 gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
218 gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
219 gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
220 gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
221 } );
222 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
223 }
224
225 if( true ) {
226 final Group g = setupGroup(new Group(new GridLayout(2, 1f, 1/2f, Alignment.Fill, new Gap(0.10f), new Padding(0.05f))),
227 reqCaps.getGLProfile(), scene, zEps,
228 sxy, nextPos, cellGap,
229 font, 16,
230 (final Group gp) -> {
231 gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
232 gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
233 gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
234 gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
235 gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
236 } );
237 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
238 }
239
240 //
241 //
242 // next line
243 nextPos.set(0, nextPos.y() + sceneBox.getHeight()/3f, 0 );
244
245 if( true ) {
246 final Group g = setupGroup(new Group(new GridLayout(2, 1f, 1/2f, Alignment.Fill, new Gap(0.10f))),
247 reqCaps.getGLProfile(), scene, zEps,
248 sxy, nextPos, cellGap,
249 font, 21,
250 (final Group gp) -> {
251 gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
252 gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
253 gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
254 gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
255 gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
256 } );
257 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
258 }
259
260 if( true ) {
261 final Group g = setupGroup(new Group(new GridLayout(2, 1f, 1/2f, Alignment.FillCenter, new Gap(0.10f))),
262 reqCaps.getGLProfile(), scene, zEps,
263 sxy, nextPos, cellGap,
264 font, 22,
265 (final Group gp) -> {
266 gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
267 gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
268 gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
269 gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
270 gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
271 } );
272 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
273 }
274
275 if( true ) {
276 final Group g = setupGroup(new Group(new GridLayout(2, 1f, 1/2f, Alignment.FillCenter, new Gap(0.10f), new Padding(0.05f))),
277 reqCaps.getGLProfile(), scene, zEps,
278 sxy, nextPos, cellGap,
279 font, 23,
280 (final Group gp) -> {
281 gp.addShape( new Button(options.renderModes, font, "ro co", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
282 gp.addShape( new Button(options.renderModes, font, "r1 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
283 gp.addShape( new Button(options.renderModes, font, "r2 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
284 gp.addShape( new Button(options.renderModes, font, "r2 c2", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
285 gp.addShape( new Button(options.renderModes, font, "r3 c1", 1f, 1f/2f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
286 } );
287 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
288 }
289
290 if( true ) {
291 final float bw = 0.5f, bh = bw/2f;
292 final Group g = setupGroup(new Group(new GridLayout(2, 1f, 1/2f, new Alignment(Alignment.Bit.CenterHoriz.value),
293 new Gap(0.10f), new Padding(0.05f))),
294 reqCaps.getGLProfile(), scene, zEps,
295 sxy, nextPos, cellGap,
296 font, 24,
297 (final Group gp) -> {
298 gp.addShape( new Button(options.renderModes, font, "ro co", bw, bh, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
299 gp.addShape( new Button(options.renderModes, font, "r1 c2", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
300 gp.addShape( new Button(options.renderModes, font, "r2 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
301 gp.addShape( new Button(options.renderModes, font, "r2 c2", bw, bh, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
302 gp.addShape( new Button(options.renderModes, font, "r3 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
303 } );
304 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
305 }
306 if( true ) {
307 final float bw = 0.5f, bh = bw/2f;
308 final Group g = setupGroup(new Group(new GridLayout(2, 1f, 1/2f, new Alignment(Alignment.Bit.CenterVert.value),
309 new Gap(0.10f), new Padding(0.05f))),
310 reqCaps.getGLProfile(), scene, zEps,
311 sxy, nextPos, cellGap,
312 font, 25,
313 (final Group gp) -> {
314 gp.addShape( new Button(options.renderModes, font, "ro co", bw, bh, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
315 gp.addShape( new Button(options.renderModes, font, "r1 c2", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
316 gp.addShape( new Button(options.renderModes, font, "r2 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
317 gp.addShape( new Button(options.renderModes, font, "r2 c2", bw, bh, zEps).setPerp().setBorder(borderThickness).addMouseListener(dragZoomRotateListener) );
318 gp.addShape( new Button(options.renderModes, font, "r3 c1", bw, bh, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
319 } );
320 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
321 }
322
323 // next line
324 nextPos.set(0, nextPos.y() + sceneBox.getHeight()/3f, 0 );
325
326 if( true ) {
327 final Group g = setupGroup(new Group(new GridLayout(2, 0, 0, Alignment.Fill, new Gap(0.03f))),
328 reqCaps.getGLProfile(), scene, zEps,
329 2*sxy, nextPos, cellGap,
330 font, 31,
331 (final Group gp) -> {
332 final Group glyphGrid = new Group(new GridLayout(2, 0.3f, 0.3f, Alignment.Fill, new Gap(0.3f * 0.10f)));
333 glyphGrid.addShape( new Button(options.renderModes, font, "0.0", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
334 glyphGrid.addShape( new Button(options.renderModes, font, "0.1", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
335 glyphGrid.addShape( new Button(options.renderModes, font, "1.0", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
336 glyphGrid.addShape( new Button(options.renderModes, font, "1.1", 1f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
337 gp.addShape(glyphGrid.setBorder(borderThickness));
338
339 final Group infoGrid = new Group(new GridLayout(1, 1/4f, 1/2.2f, Alignment.Fill, new Gap(0.02f)));
340 // final Group glyphView = new Group();
341 // glyphView.addShape(new Rectangle(options.renderModes, 1f, 1f, 0.005f).setInteractive(false));
342 // glyphView.addShape(new Button(options.renderModes, font, "S", 1f, 1f).setPerp().setBorder(borderThickness).setDragAndResizeable(false) );
343 // infoGrid.addShape(glyphView.setBorder(borderThickness));
344 infoGrid.addShape(new Button(options.renderModes, font, " S ", 1/2f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
345
346 // final Group infoView = new Group();
347 // infoView.addShape(new Button(options.renderModes, font, "Info", 1f, 1f).setPerp().setBorder(borderThickness).setDragAndResizeable(false) );
348 // infoGrid.addShape(infoView.setBorder(borderThickness));
349 infoGrid.addShape(new Button(options.renderModes, font, " Info ", 1/2f, 1f, zEps).setPerp().setBorder(borderThickness).setDragAndResizable(false) );
350 gp.addShape(infoGrid.setBorder(borderThickness));
351 // groupC0.addShape(new Button(options.renderModes, font, "S", 1/4f, 0.5f).setPerp().setBorder(borderThickness).setDragAndResizeable(false) );
352 } );
353 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
354 }
355
356 if( true ) {
357 final float bw = 0.5f, bh = bw/2f;
358 final Group g = setupGroup(new Group(new GridLayout(2, 1, 1/2f, Alignment.Center, new Gap(0.10f), new Padding(0.05f))),
359 reqCaps.getGLProfile(), scene, zEps,
360 sxy, nextPos, cellGap,
361 font, 32,
362 (final Group gp) -> {
363 gp.addShape( new Button(options.renderModes, font, "ro co", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).addMouseListener(dragZoomRotateListener) );
364 gp.addShape( new Button(options.renderModes, font, "r1 c2", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).setDragAndResizable(false) );
365 gp.addShape( new Button(options.renderModes, font, "r2 c1", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).setDragAndResizable(false) );
366 gp.addShape( new Button(options.renderModes, font, "r2 c2", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).addMouseListener(dragZoomRotateListener) );
367 gp.addShape( new Button(options.renderModes, font, "r3 c1", bw, bh, zEps).setPerp().setBorder(sxy*borderThickness).addMouseListener(dragZoomRotateListener) );
368 } );
369 nextPos.setX( nextPos.x() + g.getScaledWidth() * cellGap );
370 }
371 {
372 final AABBox sceneDim = scene.getBounds();
373 final String text = " Press group description to magnify! ";
374 final AABBox textDim = font.getGlyphBounds(text, new AffineTransform(), new AffineTransform());
375 final float l_sxy = 1/4f * sceneDim.getWidth() / textDim.getWidth();
376
377 final Shape label = new Label(options.renderModes, font, text).setColor(0, 0, 0, 1).setInteractive(false)
378 .scale(l_sxy, l_sxy, 1).moveTo(sceneDim.getLow())
379 .move(sceneDim.getWidth() - textDim.getWidth()*l_sxy, sceneDim.getHeight() - textDim.getHeight()*l_sxy, 0);
380 scene.addShape(label);
381 }
382
383 try { Thread.sleep(1000); } catch (final InterruptedException e1) { }
384 scene.screenshot(true, scene.nextScreenshotFile(null, UILayoutGrid01.class.getSimpleName(), options.renderModes, reqCaps, null));
385 if( !options.stayOpen ) {
386 window.destroy();
387 }
388 }
389
390 static interface GroupMod {
391 void mod(Group group);
392 }
393 static Group setupGroup(final Group g, final GLProfile reqGLP, final Scene scene, final float zEps,
394 final float sxy, final Vec3f nextPos, final float cellGap,
395 final Font font, final int id,
396 final GroupMod modImpl) {
397 final String suffix = String.format("%2d", id);
398 g.setID(id);
399 final AABBox sceneBox = scene.getBounds();
400 modImpl.mod(g);
401 g.setBorder(borderThickness).setBorderColor(groupBorderColor);
402 g.scale(sxy, sxy, 1);
403 g.setInteractive(true);
404 g.validate(reqGLP);
405 g.moveTo(sceneBox.getLow()).move(nextPos);
406 System.err.println("Group-"+suffix+" "+g);
407 System.err.println("Group-"+suffix+" Layout "+g.getLayout());
408 TreeTool.forAll(g, (shape) -> { System.err.println("Shape... "+shape); return false; });
409 scene.addShape(g);
410 {
411 final float X_width = font.getGlyph( ' ' ).getAdvanceWidth();
412 /**
413 * ID 23: G 23, size[total 2.1 x 1.7, cell 1.0 x 0.5]
414 * Padding[t 0.05, r 0.05, b 0.05, l 0.05]
415 * Gap[r 0.1, c 0.1], Align [CenterHoriz, CenterVert, Fill]
416 */
417 final String fixed_text = "Gap[r 0.1, c 0.1], Align [CenterHoriz, CenterVert, Fi";
418 final float l_sxy = g.getScaledWidth() / font.getGlyphBounds(fixed_text, new AffineTransform(), new AffineTransform()).getWidth();
419
420 final GridLayout l = (GridLayout)g.getLayout();
421 final String text = String.format("G %2d, size[total %.1f x %.1f, cell %.1f x %.1f]%n%s%n%s, Align %s",
422 id, g.getBounds().getWidth(), g.getBounds().getHeight(), l.getCellSize().x(), l.getCellSize().y(),
423 ( null == l.getPadding() || l.getPadding().zeroSize() ) ? "Padding none" : l.getPadding().toString(),
424 l.getGap().zeroSumSize() ? "Gap none" : l.getGap().toString(),
425 l.getAlignment() );
426 final Shape label = new Label(options.renderModes, font, text).setColor(0, 0, 0, 1).validate(reqGLP);
427 label.scale(l_sxy, l_sxy, 1).moveTo(sceneBox.getLow()).move(nextPos).move(l_sxy*X_width, g.getScaledHeight(), 0)
428 .addMouseListener(new Tooltips.ZoomLabelOnClickListener(scene, options.renderModes, 1/6f)).setDragAndResizable(false);
429 scene.addShape(label);
430 }
431 if( reLayout ) {
432 try { Thread.sleep(reLayoutSleep); } catch (final InterruptedException e1) { }
433 g.markShapeDirty();
434 g.validate(reqGLP);
435 System.err.println("Group-"+suffix+".2 "+g);
436 System.err.println("Group-"+suffix+" Layout.2 "+g.getLayout());
437 TreeTool.forAll(g, (shape) -> { System.err.println("Shape... "+shape); return false; });
438 }
439 return g;
440 }
441
442}
Abstract Outline shape representation define the method an OutlineShape(s) is bound and rendered.
Definition: Region.java:62
static final int VBAA_RENDERING_BIT
Rendering-Mode bit for Region.
Definition: Region.java:115
The optional property jogamp.graph.font.ctor allows user to specify the FontConstructor implementatio...
static final FontSet get(final int font)
static final int UBUNTU
Ubuntu is the default font family, {@value}.
Group of Shapes, optionally utilizing a Group.Layout.
Definition: Group.java:61
Default implementation of Scene.PMVMatrixSetup, implementing Scene.PMVMatrixSetup#set(PMVMatrix4f,...
Definition: Scene.java:1506
GraphUI Scene.
Definition: Scene.java:102
void addShape(final Shape s)
Adds a Shape.
Definition: Scene.java:287
final void setClearParams(final float[] clearColor, final int clearMask)
Sets the clear parameter for glClearColor(..) and glClear(..) to be issued at display(GLAutoDrawable)...
Definition: Scene.java:221
final void setPMvCullingEnabled(final boolean v)
Enable or disable Project-Modelview (PMv) frustum culling per Shape for this container.
Definition: Scene.java:230
void waitUntilDisplayed()
Blocks until first display(GLAutoDrawable) has completed after construction or dispose(GLAutoDrawable...
Definition: Scene.java:584
final void setPMVMatrixSetup(final PMVMatrixSetup setup)
Set a custom PMVMatrixSetup.
Definition: Scene.java:745
static final float DEFAULT_Z16_EPSILON
Default Z precision on 16-bit depth buffer using DEFAULT_SCENE_DIST z-position and DEFAULT_ZNEAR.
Definition: Scene.java:112
static float getZEpsilon(final int zBits, final PMVMatrixSetup setup)
Default Z precision on 16-bit depth buffer using -1 z-position and DEFAULT_ZNEAR.
Definition: Scene.java:126
AABBox getBounds(final PMVMatrix4f pmv, final Shape shape)
Returns AABBox dimension of given Shape from this container's perspective, i.e.
Definition: Scene.java:676
synchronized void attachInputListenerTo(final GLWindow window)
Definition: Scene.java:246
File nextScreenshotFile(final String dir, final String prefix, final int renderModes, final GLCapabilitiesImmutable caps, final String contentDetail)
Return the unique next technical screenshot PNG File instance as follows:
Definition: Scene.java:1434
Shape event info for propagated NEWTEvents containing reference of the intended shape as well as the ...
Definition: Shape.java:1896
Convenient adapter combining dummy implementation for MouseListener and GestureListener.
Definition: Shape.java:1884
Generic Shape, potentially using a Graph via GraphShape or other means of representing content.
Definition: Shape.java:87
Shape setColor(final float r, final float g, final float b, final float a)
Set base color.
Definition: Shape.java:1389
final Shape setInteractive(final boolean v)
Set whether this shape is interactive in general, i.e.
Definition: Shape.java:1711
final float getScaledWidth()
Returns the scaled width of the bounding AABBox for this shape.
Definition: Shape.java:745
final Quaternion getRotation()
Returns Quaternion for rotation.
Definition: Shape.java:595
final Shape setRotation(final Quaternion q)
Sets the rotation Quaternion.
Definition: Shape.java:604
Immutable layout alignment options, including Bit#Fill.
Definition: Alignment.java:35
static final Alignment Fill
Bit#Fill alignment constant.
Definition: Alignment.java:43
static final Alignment Center
Bit#CenterHoriz and Bit#CenterVert alignment constant.
Definition: Alignment.java:39
static final Alignment FillCenter
Bit#Fill, Bit#CenterHoriz and Bit#CenterVert alignment constant.
Definition: Alignment.java:45
GraphUI CSS property Gap, scaled spacing between (grid) cells not belonging to the cell element.
Definition: Gap.java:38
GraphUI Grid Group.Layout.
Definition: GridLayout.java:56
GraphUI CSS property Padding, unscaled space belonging to the element and included in the element's s...
Definition: Padding.java:38
A GraphUI text label GraphShape.
Definition: Label.java:50
Basic Float math utility functions.
Definition: FloatUtil.java:83
static float getZBufferEpsilon(final int zBits, final float z, final float zNear)
Returns resolution of Z buffer of given parameter, see Love Your Z-Buffer.
static final float PI
The value PI, i.e.
final Quaternion rotateByEuler(final Vec3f angradXYZ)
Rotates this quaternion from the given Euler rotation array angradXYZ in radians.
3D Vector based upon three float components.
Definition: Vec3f.java:37
void setX(final float x)
Definition: Vec3f.java:158
Vec3f scale(final float s)
this = this * s, returns this.
Definition: Vec3f.java:218
void setY(final float y)
Definition: Vec3f.java:159
Vec3f set(final Vec3f o)
this = o, returns this.
Definition: Vec3f.java:79
4D Vector based upon four float components.
Definition: Vec4f.java:37
Axis Aligned Bounding Box.
Definition: AABBox.java:54
final float getWidth()
Definition: AABBox.java:879
final Vec3f getLow()
Returns the minimum left-bottom-far (xyz) coordinate.
Definition: AABBox.java:140
final float getHeight()
Definition: AABBox.java:883
Pointer event of type PointerType.
Definition: MouseEvent.java:74
final float[] getRotation()
Returns a 3-component float array filled with the values of the rotational axis in the following orde...
NEWT Window events are provided for notification purposes ONLY.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
Definition: GLWindow.java:121
final int getSurfaceHeight()
Returns the height of this GLDrawable's surface client area in pixel units.
Definition: GLWindow.java:466
final void setTitle(final String title)
Definition: GLWindow.java:297
final int getSurfaceWidth()
Returns the width of this GLDrawable's surface client area in pixel units.
Definition: GLWindow.java:461
final void setSize(final int width, final int height)
Sets the size of the window's client area in window units, excluding decorations.
Definition: GLWindow.java:625
final void setVisible(final boolean visible)
Calls setVisible(true, visible), i.e.
Definition: GLWindow.java:615
final void addWindowListener(final WindowListener l)
Appends the given com.jogamp.newt.event.WindowListener to the end of the list.
Definition: GLWindow.java:882
final void destroy()
Destroys all resources associated with this GLAutoDrawable, inclusive the GLContext.
Definition: GLWindow.java:605
static GLWindow create(final GLCapabilitiesImmutable caps)
Creates a new GLWindow attaching a new Window referencing a new default Screen and default Display wi...
Definition: GLWindow.java:169
Specifies a set of OpenGL capabilities.
final GLProfile getGLProfile()
Returns the GL profile you desire or used by the drawable.
Specifies the the OpenGL profile.
Definition: GLProfile.java:77
Res independent Shapes in a Group using a GridLayout, contained within a Scene attached to GLWindow.
int graphAASamples
Sample count for Graph Region AA render-modes: Region#VBAA_RENDERING_BIT or Region#MSAA_RENDERING_BIT...
final synchronized void add(final GLAutoDrawable drawable)
Adds a drawable to this animator's list of rendering drawables.
final void setUpdateFPSFrames(final int frames, final PrintStream out)
final synchronized boolean start()
Starts this animator, if not running.
Definition: Animator.java:344
final synchronized boolean stop()
Stops this animator.
Definition: Animator.java:368
CenterHoriz
Horizontal center alignment.
Definition: Alignment.java:64
CenterVert
Vertical center alignment.
Definition: Alignment.java:67
static final int FAMILY_LIGHT
Font family LIGHT, {@value}.
Definition: FontSet.java:39
Font get(int family, int stylebits)
static final int STYLE_SERIF
SERIF style/family bit flag.
Definition: FontSet.java:54
float getAdvanceWidth()
Returns advance in font em-size [0..1], sourced from hmtx table.
Interface wrapper for font implementation.
Definition: Font.java:60
Glyph getGlyph(final String name)
Returns the Glyph mapped to given name.
String getFullFamilyName()
Shall return the family and subfamily name, separated a dash.
AABBox getGlyphBounds(final CharSequence string)
Try using getGlyphBounds(CharSequence, AffineTransform, AffineTransform) to reuse AffineTransform ins...
void addGLEventListener(GLEventListener listener)
Adds the given listener to the end of this drawable queue.
static final int GL_DEPTH_BUFFER_BIT
GL_ES_VERSION_2_0, GL_VERSION_1_1, GL_VERSION_1_0, GL_VERSION_ES_1_0 Define "GL_DEPTH_BUFFER_BIT" wit...
Definition: GL.java:738