28package com.jogamp.opengl.test.junit.graph;
30import com.jogamp.graph.font.Font;
31import com.jogamp.graph.font.FontScale;
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.Gap;
38import com.jogamp.graph.ui.layout.GridLayout;
39import com.jogamp.graph.ui.shapes.GlyphShape;
40import com.jogamp.math.Vec3f;
41import com.jogamp.math.geom.AABBox;
42import com.jogamp.newt.event.MouseEvent;
43import com.jogamp.newt.opengl.GLWindow;
44import com.jogamp.opengl.GL;
45import com.jogamp.opengl.GL2ES2;
46import com.jogamp.opengl.GLAutoDrawable;
47import com.jogamp.opengl.GLEventListener;
53 private float mmPerCell = 8.0f;
54 private int pixelPerCell = 30;
55 private boolean useDPI =
false;
57 private final int renderModes;
58 private final char startCharSymbol;
59 private final Font font;
60 private final Scene scene;
63 public FontViewListener01(
final int renderModes,
final int graphAAQuality,
final int graphSampleCount,
final Font font,
final char startCharSymbol) {
64 this.renderModes = renderModes;
65 this.startCharSymbol = startCharSymbol;
68 scene =
new Scene(graphSampleCount);
75 this.mmPerCell = mmPerCell;
79 this.pixelPerCell = pixelPerCell;
109 scene.
reshape(drawable, x, y, width, height);
110 System.err.println(
"Reshape "+width+
" x "+height+
", "+scene.
getViewport());
117 final int gridCols, gridRows;
118 if( useDPI && drawable instanceof
GLWindow ) {
123 System.err.println(
"DPI "+dpi[0]+
" x "+dpi[1]+
", "+ppmm[0]+
" x "+ppmm[1]+
" pixel/mm");
126 System.err.println(
"HiDPI PixelScale: "+hasSurfacePixelScale1[0]+
"x"+hasSurfacePixelScale1[1]+
" (has)");
127 System.err.println(
"mmPerCell "+mmPerCell);
129 gridCols = (int)( 0.90f * ( width / ppmm[0] ) / mmPerCell );
130 gridRows = (int)( 0.90f * ( height / ppmm[1] ) / mmPerCell );
132 gridCols = (int)( 0.90f * width / pixelPerCell );
133 gridRows = (int)( 0.90f * height / pixelPerCell );
135 final int cellCount = gridCols * gridRows;
136 final float netGridSize = gridCols > gridRows ? 1f/gridCols : 1f/gridRows;
137 System.err.println(
"Reshape Grid "+gridCols+
" x "+gridRows+
", "+cellCount+
" cells, netGridSize "+netGridSize);
142 for(
int idx=0; idx<Character.MAX_VALUE && grid.
getShapeCount() < cellCount ; ++idx) {
143 final char codepoint = (char)(startCharSymbol+idx);
144 final Font.Glyph glyph = font.
getGlyph( codepoint );
145 if( glyph.isNonContour() ) {
149 glyphShape.
setColor(0.1f, 0.1f, 0.1f, 1);
152 System.err.println( ((
GlyphShape)shape).getGlyph().toString() );
171 final float sxy = Math.min(sx, sy);
173 System.err.println(
"SceneBox "+sceneBox);
174 System.err.println(
"GridBox "+gridBox);
175 System.err.println(
"scale sx "+sx+
", sy "+sy+
", sxy "+sxy);
176 System.err.println(
"Grid "+grid);
177 System.err.println(
"Grid "+grid.
getLayout());
178 System.err.println(
"Grid[0] "+grid.
getShapes().get(0));
Simple static font scale methods for unit conversions.
static float[] ppmmToPPI(final float[] ppmm)
Converts [1/mm] to [1/inch] in place.
Group of Shapes, optionally utilizing a Group.Layout.
int getShapeCount()
Returns number of Shapes, see getShapes().
void addShape(final Shape s)
Adds a Shape.
List< Shape > getShapes()
Returns added Shapes.
Layout getLayout()
Return current Group.Layout.
AABBox getBounds(final PMVMatrix4f pmv, final Shape shape)
Returns AABBox dimension of given Shape from this container's perspective, i.e.
void addShape(final Shape s)
Adds a Shape.
final void setClearParams(final float[] clearColor, final int clearMask)
Sets the clear parameter for glClearColor(..) and glClear(..) to be issued at display(GLAutoDrawable)...
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
Shape removeShape(final Shape s)
Removes given shape, w/o Shape#destroy(GL2ES2, RegionRenderer).
final void setPMvCullingEnabled(final boolean v)
Enable or disable Project-Modelview (PMv) frustum culling per Shape for this container.
int setAAQuality(final int v)
Sets RegionRenderer#setAAQuality(int).
void dispose(final GLAutoDrawable drawable)
Disposes all added Shapes.
final Recti getViewport(final Recti target)
Copies the current int[4] viewport in given target and returns it for chaining.
AABBox getBounds(final PMVMatrix4f pmv, final Shape shape)
Returns AABBox dimension of given Shape from this container's perspective, i.e.
synchronized void attachInputListenerTo(final GLWindow window)
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height)
Reshape scene using setupMatrix(PMVMatrix4f, int, int, int, int) using PMVMatrixSetup.
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:
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.
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 void onClicked(final PointerListener l)
Set user callback to be notified when shape is clicked.
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 setDragAndResizable(final boolean v)
Set whether this shape is draggable and resizable.
final Shape validate(final GL2ES2 gl)
Validates the shape's underlying GLRegion.
final Shape scale(final Vec3f s)
Multiply current scale factor by given scale.
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 Center
Bit#CenterHoriz and Bit#CenterVert alignment constant.
static final Alignment FillCenter
Bit#Fill, Bit#CenterHoriz and Bit#CenterVert alignment constant.
GraphUI Stack Group.Layout.
GraphUI CSS property Gap, scaled spacing between (grid) cells not belonging to the cell element.
GraphUI Grid Group.Layout.
Representing a single Font.Glyph as a GraphShape.
3D Vector based upon three float components.
Vec3f mul(final float val)
Returns this * val; creates new vector.
Axis Aligned Bounding Box.
final Vec3f getLow()
Returns the minimum left-bottom-far (xyz) coordinate.
Pointer event of type PointerType.
An implementation of GLAutoDrawable and Window interface, using a delegated Window instance,...
final float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter of this window's NativeSurface according to the main monitor's curr...
final float[] getCurrentSurfaceScale(final float[] result)
Returns the current pixel scale of the associated NativeSurface.
Glyph Grid using GraphUI.
void printScreenOnGLThread(final GLAutoDrawable drawable, final String dir, final String prefix, final String objName, final boolean exportAlpha)
void reshape(final GLAutoDrawable drawable, final int x, final int y, final int width, final int height)
Called by the drawable during the first repaint after the component has been resized.
void display(final GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.
void attachInputListenerTo(final GLWindow window)
void setMMPerCell(final float mmPerCell)
void init(final GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.
void setPixelPerCell(final int pixelPerCell)
FontViewListener01(final int renderModes, final int graphAAQuality, final int graphSampleCount, final Font font, final char startCharSymbol)
void dispose(final GLAutoDrawable drawable)
Notifies the listener to perform the release of all OpenGL resources per GLContext,...
Interface wrapper for font implementation.
Glyph getGlyph(final String name)
Returns the Glyph mapped to given name.
String getFullFamilyName()
Shall return the family and subfamily name, separated a dash.
A higher-level abstraction than GLDrawable which supplies an event based mechanism (GLEventListener) ...
GL getGL()
Returns the GL pipeline object this GLAutoDrawable uses.
GL2ES2 getGL2ES2()
Casts this object to the GL2ES2 interface.
GLCapabilitiesImmutable getChosenGLCapabilities()
Fetches the GLCapabilitiesImmutable corresponding to the chosen OpenGL capabilities (pixel format / v...
Declares events which client code can use to manage OpenGL rendering into a GLAutoDrawable.
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...