Class TLspTextureFont
- Since:
- 2012.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classThis class contains information about a glyph. -
Constructor Summary
ConstructorsConstructorDescriptionTLspTextureFont(Font aFont) Creates a painter for the specified font.TLspTextureFont(Font aFont, Color aTextColor) Creates a painter for the specified font and color.TLspTextureFont(Font aFont, Color aTextColor, Color aHaloColor) Creates a painter for the specified font and color, and with a halo in the specified color. -
Method Summary
Modifier and TypeMethodDescriptionvoidbind(ILcdGLDrawable aGLDrawable) Binds this GL resource for use with the givenILcdGLDrawable.voiddestroy(ILcdGLDrawable aGLDrawable) Destroys the OpenGL resource so that it becomes no longer available nor valid to use.voiddrawString(ILcdGLDrawable aGLDrawable, double aX, double aY, double aZ, double aSize, String aString) Draws a string at the specified location and with the given size.voiddrawString(ILcdGLDrawable aGLDrawable, double aX, double aY, double aZ, String aString) Draws a string at the specified location with the font's native size.voiddrawString(ILcdGLDrawable aGLDrawable, ILcdPoint aLocation, ILcdBounds aBounds, double aSize, String aString, TLspContext aContext) Draws a string at the specified location and with the given size.voiddrawString(ILcdGLDrawable aGLDrawable, ILcdPoint aLocation, String aString) Draws a string at the specified location with the font's native size.voiddrawStrings(ILcdGLDrawable aGLDrawable, List<ILcdPoint> aPositions, List<ILcdBounds> aBounds, double aSize, List<String> aStrings, TLspContext aContext) Returns the color used for filling the background of the rendered text.longgetBytes()Gets the estimated number of bytes this resource occupies in GPU memory.getFont()Returns the current font.Returns the color used for a frame around the rendered textgetGlyphInfo(char aChar, double aSize) Returns the current halo color.intReturns the thickness of the halo around the rendered text.intReturns the height of a single character glyph in the texture font.intReturns the number of blank pixels added around each character glyph in the texture font.doublegetStringWidth(String aString) Returns the width the specified string would have if it were to be drawn with the font's native size.doublegetStringWidth(String aString, double aSize) Returns the width the specified string would have if it were to be drawn with the given size.Returns the current text color.booleanReturns whether or not the background of the text is filled with the background color.booleanReturns whether or not a frame is drawn around the label.booleanReturns whether or not the halo effect is on.voidsetBackgroundColor(Color aBackgroundColor) Sets the color used for filling the background of the rendered text to the given color.voidsetBackgroundEnabled(boolean aBackgroundEnabled) Sets whether or not the background of the text is filled with the background color.voidSets the font to be used for text rendering.voidsetFrameColor(Color aFrameColor) Sets the color used for a frame around the rendered textvoidsetFrameEnabled(boolean aFrameEnabled) Toggles the use of a frame around the rendered text.voidsetHaloColor(Color aHaloColor) Sets the color to be used for halos around rendered text.voidsetHaloEnabled(boolean aHaloEnabled) Toggles the use of a halo effect around rendered text.voidsetHaloThickness(int aHaloThickness) Sets the thickness of the halo around the rendered text.voidsetTextColor(Color aTextColor) Sets the color to be used for text rendering.voidunbind(ILcdGLDrawable aGLDrawable) Unbinds this GL resource from the givenILcdGLDrawable.Methods inherited from class com.luciad.view.lightspeed.services.glcache.ALspGLResource
getSourceString, isBound, toString
-
Constructor Details
-
TLspTextureFont
Creates a painter for the specified font. By default, the font color is white and the halo effect is off.- Parameters:
aFont- an AWT font
-
TLspTextureFont
Creates a painter for the specified font and color. By default, the halo effect is off.- Parameters:
aFont- an AWT fontaTextColor- the font color
-
TLspTextureFont
Creates a painter for the specified font and color, and with a halo in the specified color.- Parameters:
aFont- an AWT fontaTextColor- the font coloraHaloColor- the halo color
-
-
Method Details
-
getFont
Returns the current font.- Returns:
- the current font
- See Also:
-
setFont
Sets the font to be used for text rendering. If this property is changed, a new texture font image will be generated the next time the painter is used, which is a costly operation. Applications should therefore avoid calling this method very frequently.- Parameters:
aFont- the new font to be used
-
getTextColor
Returns the current text color.- Returns:
- the current text color
- See Also:
-
setTextColor
Sets the color to be used for text rendering. If this property is changed, a new texture font image will be generated the next time the painter is used, which is a costly operation. Applications should therefore avoid calling this method very frequently.- Parameters:
aTextColor- the new text color to be used
-
getHaloColor
Returns the current halo color.- Returns:
- the current halo color
- See Also:
-
setHaloColor
Sets the color to be used for halos around rendered text. If this property is changed, a new texture font image will be generated the next time the painter is used, which is a costly operation. Applications should therefore avoid calling this method very frequently.- Parameters:
aHaloColor- the new halo color to be used
-
isHaloEnabled
public boolean isHaloEnabled()Returns whether or not the halo effect is on.- Returns:
- whether or not the halo effect is on
- See Also:
-
setHaloEnabled
public void setHaloEnabled(boolean aHaloEnabled) Toggles the use of a halo effect around rendered text. A halo is an outline of constant width around the text, which ensures that the text is clearly visible on all backgrounds. If this property is changed, a new texture font image will be generated the next time the painter is used, which is a costly operation. Applications should therefore avoid calling this method very frequently.- Parameters:
aHaloEnabled- specifies whether halos should be enabled or disabled
-
getHaloThickness
public int getHaloThickness()Returns the thickness of the halo around the rendered text.- Returns:
- the thickness of the halo around the rendered text.
-
setHaloThickness
public void setHaloThickness(int aHaloThickness) Sets the thickness of the halo around the rendered text. If this property is changed, a new texture font image will be generated the next time the painter is used, which is a costly operation. Applications should therefore avoid calling this method very frequently.- Parameters:
aHaloThickness- the thickness of the halo around the rendered text.
-
isFrameEnabled
public boolean isFrameEnabled()Returns whether or not a frame is drawn around the label.- Returns:
- whether or not a frame is drawn around the label
-
setFrameEnabled
public void setFrameEnabled(boolean aFrameEnabled) Toggles the use of a frame around the rendered text.- Parameters:
aFrameEnabled- a flag indicating whether a frame should be drawn or not
-
getFrameColor
Returns the color used for a frame around the rendered text- Returns:
- the color used for a frame around the rendered text
-
setFrameColor
Sets the color used for a frame around the rendered text- Parameters:
aFrameColor- the new frame color
-
getBackgroundColor
Returns the color used for filling the background of the rendered text.- Returns:
- the color used for filling the background of the rendered text
-
setBackgroundColor
Sets the color used for filling the background of the rendered text to the given color.- Parameters:
aBackgroundColor- the new background color
-
isBackgroundEnabled
public boolean isBackgroundEnabled()Returns whether or not the background of the text is filled with the background color.- Returns:
- whether or not the background of the text is filled with the background color
-
setBackgroundEnabled
public void setBackgroundEnabled(boolean aBackgroundEnabled) Sets whether or not the background of the text is filled with the background color.- Parameters:
aBackgroundEnabled- flag indicating whether the background is filled or not
-
drawString
public void drawString(ILcdGLDrawable aGLDrawable, ILcdPoint aLocation, ILcdBounds aBounds, double aSize, String aString, TLspContext aContext) Draws a string at the specified location and with the given size.- Parameters:
aGLDrawable- the ILcdGLDrawable to draw the string intoaLocation- the location at which the string should be drawnaBounds- the bounds of the text in view coordinates (used for drawing the frame around the text)aSize- the size with which to draw the string, i.e. the height of a line of textaString- the string to be drawn
-
drawString
public void drawString(ILcdGLDrawable aGLDrawable, double aX, double aY, double aZ, double aSize, String aString) Draws a string at the specified location and with the given size. The string is drawn as a strip of quadrilaterals in the XY plane; the coordinates aX, aY and aZ specify the lower left corner of the string. Other than enabling and binding the font texture, this method does not change any OpenGL state. It is up to the application to set up any required transformations before calling this method (e.g. to ensure that the string is drawn aligned to the screen). In other words, the coordinate reference in which aX, aY, aZ and aSize are expressed, is determined by the current OpenGL state at the time this method is called.- Parameters:
aGLDrawable- the ILcdGLDrawable to draw the string intoaX- the X coordinate of the string's locationaY- the Y coordinate of the string's locationaZ- the Z coordinate of the string's locationaSize- the size with which to draw the string, i.e. the height of a line of textaString- the string to be drawn
-
drawStrings
public void drawStrings(ILcdGLDrawable aGLDrawable, List<ILcdPoint> aPositions, List<ILcdBounds> aBounds, double aSize, List<String> aStrings, TLspContext aContext) -
bind
Description copied from class:ALspGLResourceBinds this GL resource for use with the given
ILcdGLDrawable. Implementations should override this method to perform the appropriate OpenGL call, e.g.glBindTexture(). Inheriting classes must also always invokesuper.bind(), as this is required for the correct behavior ofALspGLResource.isBound().If this resource was already destroyed and the
destroyimplementation callssuper.destroy, a runtime exception will be thrown when calling this method.- Overrides:
bindin classALspGLResource- Parameters:
aGLDrawable- the GL drawable in which this resource is to be bound
-
unbind
Description copied from class:ALspGLResourceUnbinds this GL resource from the given
ILcdGLDrawable. Implementations should override this method to perform whatever OpenGL calls are needed to undo the effects ofALspGLResource.bind(com.luciad.view.opengl.binding.ILcdGLDrawable). Inheriting classes must also always invokesuper.unbind(), as this is required for the correct behavior ofALspGLResource.isBound().If this resource was already destroyed and the
destroyimplementation callssuper.destroy, a runtime exception will be thrown when calling this method.- Overrides:
unbindin classALspGLResource- Parameters:
aGLDrawable- the drawable from which the GL resource should be unbound
-
getStringWidth
Returns the width the specified string would have if it were to be drawn with the given size.- Parameters:
aString- the string whose width should be determinedaSize- the text size based on which the string width should be computed- Returns:
- the width of the string if it were drawn with the given size
- See Also:
-
drawString
Draws a string at the specified location with the font's native size.- Parameters:
aGLDrawable- the ILcdGLDrawable to draw the string intoaLocation- the location at which the string should be drawnaString- the string to be drawn- See Also:
-
drawString
Draws a string at the specified location with the font's native size.- Parameters:
aGLDrawable- the ILcdGLDrawable to draw the string intoaX- the X coordinate of the string's locationaY- the Y coordinate of the string's locationaZ- the Z coordinate of the string's locationaString- the string to be drawn- See Also:
-
getNativeSize
public int getNativeSize()Returns the height of a single character glyph in the texture font. When drawing text in view coordinates, this value can be used as the size parameter in calls todrawString(com.luciad.view.opengl.binding.ILcdGLDrawable, com.luciad.shape.ILcdPoint, com.luciad.shape.ILcdBounds, double, String, com.luciad.view.lightspeed.TLspContext)to draw characters without scaling. Since scaling could introduce some artifacts due to texture filtering, drawing text at its native size typically improves the text's visual quality.- Returns:
- the height of a single character glyph in the texture font
-
getStringWidth
Returns the width the specified string would have if it were to be drawn with the font's native size.- Parameters:
aString- the string whose width should be determined- Returns:
- the width of the string if it were drawn with the font's native size
- See Also:
-
getPadding
public int getPadding()Returns the number of blank pixels added around each character glyph in the texture font. Empty borders are added on all four sides of each glyph so that texture filtering would not cause glyphs to "bleed" into their neighbours when the glyphs are drawn strongly minified.The drawString() method already takes this value into account when positioning successive characters in a string, but applications may, for instance, also want to use this method to determine the appropriate amount of spacing between multiple lines of text.
- Returns:
- the amount of padding around each character glyph
-
destroy
Description copied from class:ALspGLResourceDestroys the OpenGL resource so that it becomes no longer available nor valid to use.
You should never call this yourself. The GL resource cache will automatically remove old resources. Alternatively, if you don't need the resource anymore, manually
removeit from the GL resource cache.Extensions of this class should preferably call
super.destroy. Doing so will add extra error checking in thebindandunbindmethods, to make sure that no destroyed resources are used during painting (this may lead to native crashes).- Overrides:
destroyin classALspGLResource- Parameters:
aGLDrawable- the drawable this resource is used for
-
getBytes
public long getBytes()Description copied from class:ALspGLResourceGets the estimated number of bytes this resource occupies in GPU memory.- Specified by:
getBytesin classALspGLResource- Returns:
- the estimated number of bytes
-
getGlyphInfo
-