public class TLspTextureFont extends ALspGLResource
Modifier and Type | Class and Description |
---|---|
static class |
TLspTextureFont.GlyphInfo
This class contains information about a glyph.
|
Constructor and Description |
---|
TLspTextureFont(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.
|
Modifier and Type | Method and Description |
---|---|
void |
bind(ILcdGLDrawable aGLDrawable)
Binds this GL resource for use with the given
ILcdGLDrawable . |
void |
destroy(ILcdGLDrawable aGLDrawable)
Destroys the OpenGL resource so that it becomes no longer
available nor valid to use.
|
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.
|
void |
drawString(ILcdGLDrawable aGLDrawable,
double aX,
double aY,
double aZ,
String aString)
Draws a string at the specified location with the font's native size.
|
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.
|
void |
drawString(ILcdGLDrawable aGLDrawable,
ILcdPoint aLocation,
String aString)
Draws a string at the specified location with the font's native size.
|
void |
drawStrings(ILcdGLDrawable aGLDrawable,
List<ILcdPoint> aPositions,
List<ILcdBounds> aBounds,
double aSize,
List<String> aStrings,
TLspContext aContext) |
Color |
getBackgroundColor()
Returns the color used for filling the background of the rendered text.
|
long |
getBytes()
Gets the estimated number of bytes this resource occupies
in GPU memory.
|
Font |
getFont()
Returns the current font.
|
Color |
getFrameColor()
Returns the color used for a frame around the rendered text
|
TLspTextureFont.GlyphInfo |
getGlyphInfo(char aChar,
double aSize) |
Color |
getHaloColor()
Returns the current halo color.
|
int |
getHaloThickness()
Returns the thickness of the halo around the rendered text.
|
int |
getNativeSize()
Returns the height of a single character glyph in the texture font.
|
int |
getPadding()
Returns the number of blank pixels added around each character glyph in
the texture font.
|
double |
getStringWidth(String aString)
Returns the width the specified string would have if it were to be drawn
with the font's native size.
|
double |
getStringWidth(String aString,
double aSize)
Returns the width the specified string would have if it were to be drawn
with the given size.
|
Color |
getTextColor()
Returns the current text color.
|
boolean |
isBackgroundEnabled()
Returns whether or not the background of the text is filled with the background color.
|
boolean |
isFrameEnabled()
Returns whether or not a frame is drawn around the label.
|
boolean |
isHaloEnabled()
Returns whether or not the halo effect is on.
|
void |
setBackgroundColor(Color aBackgroundColor)
Sets the color used for filling the background of the rendered text to the given color.
|
void |
setBackgroundEnabled(boolean aBackgroundEnabled)
Sets whether or not the background of the text is filled with the background color.
|
void |
setFont(Font aFont)
Sets the font to be used for text rendering.
|
void |
setFrameColor(Color aFrameColor)
Sets the color used for a frame around the rendered text
|
void |
setFrameEnabled(boolean aFrameEnabled)
Toggles the use of a frame around the rendered text.
|
void |
setHaloColor(Color aHaloColor)
Sets the color to be used for halos around rendered text.
|
void |
setHaloEnabled(boolean aHaloEnabled)
Toggles the use of a halo effect around rendered text.
|
void |
setHaloThickness(int aHaloThickness)
Sets the thickness of the halo around the rendered text.
|
void |
setTextColor(Color aTextColor)
Sets the color to be used for text rendering.
|
void |
unbind(ILcdGLDrawable aGLDrawable)
Unbinds this GL resource from the given
ILcdGLDrawable . |
getSourceString, isBound, toString
public TLspTextureFont(Font aFont)
aFont
- an AWT fontpublic TLspTextureFont(Font aFont, Color aTextColor)
aFont
- an AWT fontaTextColor
- the font colorpublic Font getFont()
setFont(java.awt.Font)
public void setFont(Font aFont)
aFont
- the new font to be usedpublic Color getTextColor()
setTextColor(java.awt.Color)
public void setTextColor(Color aTextColor)
aTextColor
- the new text color to be usedpublic Color getHaloColor()
setHaloColor(java.awt.Color)
public void setHaloColor(Color aHaloColor)
aHaloColor
- the new halo color to be usedpublic boolean isHaloEnabled()
setHaloEnabled(boolean)
public void setHaloEnabled(boolean aHaloEnabled)
aHaloEnabled
- specifies whether halos should be enabled or disabledpublic int getHaloThickness()
public void setHaloThickness(int aHaloThickness)
aHaloThickness
- the thickness of the halo around the rendered text.public boolean isFrameEnabled()
public void setFrameEnabled(boolean aFrameEnabled)
aFrameEnabled
- a flag indicating whether a frame should be drawn or notpublic Color getFrameColor()
public void setFrameColor(Color aFrameColor)
aFrameColor
- the new frame colorpublic Color getBackgroundColor()
public void setBackgroundColor(Color aBackgroundColor)
aBackgroundColor
- the new background colorpublic boolean isBackgroundEnabled()
public void setBackgroundEnabled(boolean aBackgroundEnabled)
aBackgroundEnabled
- flag indicating whether the background is filled or notpublic void drawString(ILcdGLDrawable aGLDrawable, ILcdPoint aLocation, ILcdBounds aBounds, double aSize, String aString, TLspContext aContext)
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 drawnpublic void drawString(ILcdGLDrawable aGLDrawable, double aX, double aY, double aZ, double aSize, String aString)
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 drawnpublic void drawStrings(ILcdGLDrawable aGLDrawable, List<ILcdPoint> aPositions, List<ILcdBounds> aBounds, double aSize, List<String> aStrings, TLspContext aContext)
public void bind(ILcdGLDrawable aGLDrawable)
ALspGLResource
Binds 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 invoke super.bind()
, as this is required for the correct
behavior of ALspGLResource.isBound()
.
If this resource was already destroyed and the destroy
implementation calls
super.destroy
, a runtime exception will be thrown when calling this method.
bind
in class ALspGLResource
aGLDrawable
- the GL drawable in which this resource is to be boundpublic void unbind(ILcdGLDrawable aGLDrawable)
ALspGLResource
Unbinds this GL resource from the given ILcdGLDrawable
.
Implementations should override this method to perform whatever OpenGL
calls are needed to undo the effects of
ALspGLResource.bind(com.luciad.view.opengl.binding.ILcdGLDrawable)
.
Inheriting classes must also always invoke super.unbind()
, as this
is required for the correct behavior of ALspGLResource.isBound()
.
If this resource was already destroyed and the destroy
implementation calls
super.destroy
, a runtime exception will be thrown when calling this method.
unbind
in class ALspGLResource
aGLDrawable
- the drawable from which the GL resource should be unboundpublic double getStringWidth(String aString, double aSize)
aString
- the string whose width should be determinedaSize
- the text size based on which the string width should be computeddrawString(ILcdGLDrawable, double, double, double, double, String)
public void drawString(ILcdGLDrawable aGLDrawable, ILcdPoint aLocation, String aString)
aGLDrawable
- the ILcdGLDrawable to draw the string intoaLocation
- the location at which the string should be drawnaString
- the string to be drawndrawString(ILcdGLDrawable, double, double, double, double, String)
,
getNativeSize()
public void drawString(ILcdGLDrawable aGLDrawable, double aX, double aY, double aZ, String aString)
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 drawndrawString(ILcdGLDrawable, double, double, double, double, String)
,
getNativeSize()
public int getNativeSize()
drawString(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.public double getStringWidth(String aString)
aString
- the string whose width should be determinedgetStringWidth(String, double)
,
getNativeSize()
public int getPadding()
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.
public void destroy(ILcdGLDrawable aGLDrawable)
ALspGLResource
Destroys 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 remove
it from
the GL resource cache.
Extensions of this class should preferably call super.destroy
. Doing so will add extra error checking
in the bind
and unbind
methods, to make sure that
no destroyed resources are used during painting (this may lead to native crashes).
destroy
in class ALspGLResource
aGLDrawable
- the drawable this resource is used forpublic long getBytes()
ALspGLResource
getBytes
in class ALspGLResource
public TLspTextureFont.GlyphInfo getGlyphInfo(char aChar, double aSize)