Top Description Inners Fields Constructors Methods
com.jogamp.graph.curve.opengl

public Class TextRegionUtil

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashMap, .Iterator, com.jogamp.opengl.GL2ES2, .GLException, jogamp.graph.geom.plane.AffineTransform, com.jogamp.graph.curve.OutlineShape, .Region, com.jogamp.graph.font.Font, .Font.Glyph, com.jogamp.graph.geom.Vertex, .Vertex.Factory

Text GLRegion Utility Class

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT_CACHE_LIMIT

Default cache limit, see setCacheLimit(int)

public final int
private final ArrayList<String>
private int
private final HashMap<String, GLRegion>
public final AffineTransform
public final AffineTransform

Constructor Summary

AccessConstructor and Description
public
TextRegionUtil(final int renderModes)

Method Summary

Modifier and TypeMethod and Description
protected final void
addCachedRegion(final GL2ES2 gl, final Font font, final CharSequence str, final float pixelSize, final int special, final GLRegion glyphString)

public static void
addStringToRegion(final GLRegion
the GLRegion sink
region
,
final Vertex.Factory<? extends Vertex>
vertex impl factory Factory
vertexFactory
,
final Font
the target Font
font
,
final float
Use Font#getPixelSize(float, float) for resolution correct pixel-size.
pixelSize
,
final CharSequence
string text
str
,
final float[]
if Region#hasColorChannel() RGBA color must be passed, otherwise value is ignored.
rgbaColor
,
final AffineTransform
temporary AffineTransform storage, mandatory
temp1
,
final AffineTransform
temporary AffineTransform storage, mandatory
temp2
)

Add the string in 3D space w.r.t. the font and pixelSize at the end of the GLRegion.

public void
clear(final GL2ES2 gl)

Clear all cached GLRegions.

public void
drawString3D(final GL2ES2
the current GL state
gl
,
final RegionRenderer
TODO
renderer
,
final Font
Font to be used
font
,
final float
Use Font#getPixelSize(float, float) for resolution correct pixel-size.
pixelSize
,
final CharSequence
text to be rendered
str
,
final float[]
if Region#hasColorChannel() RGBA color must be passed, otherwise value is ignored.
rgbaColor
,
final int[]
desired multisampling sample count for msaa-rendering. The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
sampleCount
)

Render the string in 3D space w.r.t. the font and pixelSize using a cached GLRegion for reuse.

public static void
drawString3D(final GL2ES2
the current GL state
gl
,
final int
TODO
renderModes
,
final RegionRenderer renderer, final Font
Font to be used
font
,
final float
Use Font#getPixelSize(float, float) for resolution correct pixel-size.
pixelSize
,
final CharSequence
text to be rendered
str
,
final float[]
if Region#hasColorChannel() RGBA color must be passed, otherwise value is ignored.
rgbaColor
,
final int[]
desired multisampling sample count for msaa-rendering. The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
sampleCount
,
final AffineTransform
temporary AffineTransform storage, mandatory
temp1
,
final AffineTransform
temporary AffineTransform storage, mandatory
temp2
)

Render the string in 3D space w.r.t. the font and pixelSize using a temporary GLRegion, which will be destroyed afterwards.

public static void
drawString3D(final GL2ES2
the current GL state
gl
,
final GLRegion region, final RegionRenderer renderer, final Font
Font to be used
font
,
final float
Use Font#getPixelSize(float, float) for resolution correct pixel-size.
pixelSize
,
final CharSequence
text to be rendered
str
,
final float[]
if Region#hasColorChannel() RGBA color must be passed, otherwise value is ignored.
rgbaColor
,
final int[]
desired multisampling sample count for msaa-rendering. The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
sampleCount
,
final AffineTransform
temporary AffineTransform storage, mandatory
temp1
,
final AffineTransform
temporary AffineTransform storage, mandatory
temp2
)

Render the string in 3D space w.r.t. the font and pixelSize using the given GLRegion, which will cleared beforehand.

protected final GLRegion
getCachedRegion(final Font font, final CharSequence str, final float pixelSize, final int special)

public final int

Returns:

the current cache limit
getCacheLimit
()

public final int

Returns:

the current utilized cache size, <= getCacheLimit()
getCacheSize
()

public static int
getCharCount(final String s, final char c)

protected final String
getKey(final Font font, final CharSequence str, final float pixelSize, final int special)

public static void
processString(final TextRegionUtil.ShapeVisitor visitor, final AffineTransform
optional given transform
transform
,
final Font
the target Font
font
,
final float
Use Font#getPixelSize(float, float) for resolution correct pixel-size.
pixelSize
,
final CharSequence
string text
str
,
final AffineTransform
temporary AffineTransform storage, mandatory, will be passed to ShapeVisitor#visit(OutlineShape, AffineTransform) and can be modified.
temp1
,
final AffineTransform
temporary AffineTransform storage, mandatory, can be re-used in ShapeVisitor#visit(OutlineShape, AffineTransform) by user code.
temp2
)

Visit each Font.Glyph's OutlineShape with the given ShapeVisitor additionally passing the progressed AffineTransform.

protected final void
removeCachedRegion(final GL2ES2 gl, final Font font, final CharSequence str, final int pixelSize, final int special)

protected final void
removeCachedRegion(final GL2ES2 gl, final int idx)

public final void
setCacheLimit(final int
new cache size
newLimit
)

Sets the cache limit for reusing GlyphString's and their Region.

public final void
setCacheLimit(final GL2ES2
current GL used to remove cached objects if required
gl
,
final int
new cache size
newLimit
)

Sets the cache limit, see setCacheLimit(int) and validates the cache.

protected final void
validateCache(final GL2ES2 gl, final int space)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_CACHE_LIMITback to summary
public static final int DEFAULT_CACHE_LIMIT

Default cache limit, see setCacheLimit(int)

renderModesback to summary
public final int renderModes
stringCacheArrayback to summary
private final ArrayList<String> stringCacheArray
stringCacheLimitback to summary
private int stringCacheLimit
stringCacheMapback to summary
private final HashMap<String, GLRegion> stringCacheMap
tempT1back to summary
public final AffineTransform tempT1
tempT2back to summary
public final AffineTransform tempT2

Constructor Detail

TextRegionUtilback to summary
public TextRegionUtil(final int renderModes)

Method Detail

addCachedRegionback to summary
protected final void addCachedRegion(final GL2ES2 gl, final Font font, final CharSequence str, final float pixelSize, final int special, final GLRegion glyphString)
addStringToRegionback to summary
public static void addStringToRegion(final GLRegion region, final Vertex.Factory<? extends Vertex> vertexFactory, final Font font, final float pixelSize, final CharSequence str, final float[] rgbaColor, final AffineTransform temp1, final AffineTransform temp2)

Add the string in 3D space w.r.t. the font and pixelSize at the end of the GLRegion.

Parameters
region:GLRegion

the GLRegion sink

vertexFactory:Vertex.Factory<? extends Vertex>

vertex impl factory Factory

font:Font

the target Font

pixelSize:float

Use Font#getPixelSize(float, float) for resolution correct pixel-size.

str:CharSequence

string text

rgbaColor:float[]

if Region#hasColorChannel() RGBA color must be passed, otherwise value is ignored.

temp1:AffineTransform

temporary AffineTransform storage, mandatory

temp2:AffineTransform

temporary AffineTransform storage, mandatory

clearback to summary
public void clear(final GL2ES2 gl)

Clear all cached GLRegions.

drawString3Dback to summary
public void drawString3D(final GL2ES2 gl, final RegionRenderer renderer, final Font font, final float pixelSize, final CharSequence str, final float[] rgbaColor, final int[] sampleCount)

Render the string in 3D space w.r.t. the font and pixelSize using a cached GLRegion for reuse.

Cached GLRegions will be destroyed w/ clear(GL2ES2) or to free memory.

Parameters
gl:GL2ES2

the current GL state

renderer:RegionRenderer

TODO

font:Font

Font to be used

pixelSize:float

Use Font#getPixelSize(float, float) for resolution correct pixel-size.

str:CharSequence

text to be rendered

rgbaColor:float[]

if Region#hasColorChannel() RGBA color must be passed, otherwise value is ignored.

sampleCount:int[]

desired multisampling sample count for msaa-rendering. The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.

Exceptions
Exception:
if TextRenderer not initialized
drawString3Dback to summary
public static void drawString3D(final GL2ES2 gl, final int renderModes, final RegionRenderer renderer, final Font font, final float pixelSize, final CharSequence str, final float[] rgbaColor, final int[] sampleCount, final AffineTransform temp1, final AffineTransform temp2)

Render the string in 3D space w.r.t. the font and pixelSize using a temporary GLRegion, which will be destroyed afterwards.

In case of a multisampling region renderer, i.e. Region#VBAA_RENDERING_BIT, recreating the GLRegion is a huge performance impact. In such case better use drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, float, CharSequence, float[], int[], AffineTransform, AffineTransform) instead.

Parameters
gl:GL2ES2

the current GL state

renderModes:int

TODO

font:Font

Font to be used

pixelSize:float

Use Font#getPixelSize(float, float) for resolution correct pixel-size.

str:CharSequence

text to be rendered

rgbaColor:float[]

if Region#hasColorChannel() RGBA color must be passed, otherwise value is ignored.

sampleCount:int[]

desired multisampling sample count for msaa-rendering. The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.

temp1:AffineTransform

temporary AffineTransform storage, mandatory

temp2:AffineTransform

temporary AffineTransform storage, mandatory

Exceptions
Exception:
if TextRenderer not initialized
drawString3Dback to summary
public static void drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer, final Font font, final float pixelSize, final CharSequence str, final float[] rgbaColor, final int[] sampleCount, final AffineTransform temp1, final AffineTransform temp2)

Render the string in 3D space w.r.t. the font and pixelSize using the given GLRegion, which will cleared beforehand.

Parameters
gl:GL2ES2

the current GL state

font:Font

Font to be used

pixelSize:float

Use Font#getPixelSize(float, float) for resolution correct pixel-size.

str:CharSequence

text to be rendered

rgbaColor:float[]

if Region#hasColorChannel() RGBA color must be passed, otherwise value is ignored.

sampleCount:int[]

desired multisampling sample count for msaa-rendering. The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.

temp1:AffineTransform

temporary AffineTransform storage, mandatory

temp2:AffineTransform

temporary AffineTransform storage, mandatory

Exceptions
Exception:
if TextRenderer not initialized
getCachedRegionback to summary
protected final GLRegion getCachedRegion(final Font font, final CharSequence str, final float pixelSize, final int special)
getCacheLimitback to summary
public final int getCacheLimit()
Returns:int

the current cache limit

getCacheSizeback to summary
public final int getCacheSize()
Returns:int

the current utilized cache size, <= getCacheLimit()

getCharCountback to summary
public static int getCharCount(final String s, final char c)
getKeyback to summary
protected final String getKey(final Font font, final CharSequence str, final float pixelSize, final int special)
processStringback to summary
public static void processString(final TextRegionUtil.ShapeVisitor visitor, final AffineTransform transform, final Font font, final float pixelSize, final CharSequence str, final AffineTransform temp1, final AffineTransform temp2)

Visit each Font.Glyph's OutlineShape with the given ShapeVisitor additionally passing the progressed AffineTransform. The latter reflects the given font metric, pixelSize and hence character position.

Parameters
transform:AffineTransform

optional given transform

font:Font

the target Font

pixelSize:float

Use Font#getPixelSize(float, float) for resolution correct pixel-size.

str:CharSequence

string text

temp1:AffineTransform

temporary AffineTransform storage, mandatory, will be passed to ShapeVisitor#visit(OutlineShape, AffineTransform) and can be modified.

temp2:AffineTransform

temporary AffineTransform storage, mandatory, can be re-used in ShapeVisitor#visit(OutlineShape, AffineTransform) by user code.

removeCachedRegionback to summary
protected final void removeCachedRegion(final GL2ES2 gl, final Font font, final CharSequence str, final int pixelSize, final int special)
removeCachedRegionback to summary
protected final void removeCachedRegion(final GL2ES2 gl, final int idx)
setCacheLimitback to summary
public final void setCacheLimit(final int newLimit)

Sets the cache limit for reusing GlyphString's and their Region. Default is DEFAULT_CACHE_LIMIT, -1 unlimited, 0 turns cache off, >0 limited

The cache will be validate when the next string rendering happens.

Parameters
newLimit:int

new cache size

See Also
DEFAULT_CACHE_LIMIT
setCacheLimitback to summary
public final void setCacheLimit(final GL2ES2 gl, final int newLimit)

Sets the cache limit, see setCacheLimit(int) and validates the cache.

Parameters
gl:GL2ES2

current GL used to remove cached objects if required

newLimit:int

new cache size

See Also
setCacheLimit(int)
validateCacheback to summary
protected final void validateCache(final GL2ES2 gl, final int space)
com.jogamp.graph.curve.opengl back to summary

public Interface TextRegionUtil.ShapeVisitor


Method Summary

Modifier and TypeMethod and Description
public void
visit(final OutlineShape
may be used as is, otherwise a copy shall be made if intended to be modified.
shape
,
final AffineTransform
may be used immediately as is, otherwise a copy shall be made if stored.
t
)

Visiting the given OutlineShape with it's corresponding AffineTransform.

Method Detail

visitback to summary
public void visit(final OutlineShape shape, final AffineTransform t)

Visiting the given OutlineShape with it's corresponding AffineTransform.

Parameters
shape:OutlineShape

may be used as is, otherwise a copy shall be made if intended to be modified.

t:AffineTransform

may be used immediately as is, otherwise a copy shall be made if stored.