public class TextCellFactory
extends java.lang.Object
implements com.badlogic.gdx.utils.Disposable
Modifier and Type | Class and Description |
---|---|
class |
TextCellFactory.Glyph
A kind of Actor for one char (with one color) that is innately drawn with a specific TextCellFactory, and will
match the layout behavior of that TextCellFactory when it is used for other purposes.
|
Modifier and Type | Field and Description |
---|---|
float |
actualCellHeight |
float |
actualCellWidth |
protected com.badlogic.gdx.assets.AssetManager |
assetManager
The
AssetManager from where to load the font. |
protected com.badlogic.gdx.graphics.g2d.TextureRegion |
block |
com.badlogic.gdx.graphics.g2d.BitmapFont |
bmpFont |
protected int |
bottomPadding |
static java.lang.String |
DEFAULT_FITTING
The commonly used symbols in roguelike games.
|
protected float |
descent |
protected char |
directionGlyph |
protected com.badlogic.gdx.graphics.g2d.TextureRegion |
dirMarker |
protected boolean |
distanceField |
protected float |
distanceFieldScaleX |
protected float |
distanceFieldScaleY |
protected java.lang.String |
fitting |
protected squidpony.squidmath.OrderedMap<java.lang.Character,com.badlogic.gdx.graphics.g2d.TextureRegion> |
glyphTextures |
protected float |
height |
protected boolean |
initialized |
protected boolean |
initializedByFont |
protected boolean |
initializedBySize |
protected int |
leftPadding |
protected float |
lineHeight |
protected boolean |
msdf |
protected java.lang.StringBuilder |
mut |
protected int |
rightPadding |
protected squidpony.IColorCenter<com.badlogic.gdx.graphics.Color> |
scc |
com.badlogic.gdx.graphics.glutils.ShaderProgram |
shader
For distance field and MSDF fonts, this is the ShaderProgram that will produce the intended effect.
|
protected float |
smoothingMultiplier |
static java.lang.String |
SQUID_FITTING
All symbols that squidlib-util permits itself to generate; this is a shared subset across most of the larger
fonts in
DefaultResources . |
protected com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle |
style |
protected regexodus.ds.CharCharMap |
swap |
protected int |
topPadding |
protected float |
width |
Constructor and Description |
---|
TextCellFactory()
Creates a default valued factory.
|
TextCellFactory(com.badlogic.gdx.assets.AssetManager assetManager)
A default valued factory that uses the given
AssetManager to load
the font file. |
Modifier and Type | Method and Description |
---|---|
TextCellFactory |
addFit(java.lang.String fit)
Adds the code points in the string to the list of characters that will be
guaranteed to fit as fixed-width.
|
TextCellFactory |
addSwap(char find,
char replace)
Adds a pair of chars as a replacement pair, so when the find char is requested to be drawn, the replace char is
used instead.
|
TextCellFactory |
addSwap(java.lang.String find,
java.lang.String replace)
Adds a pair of Strings (typically both with length 1) as a replacement pair, so when the find String is requested
to be drawn, the replace String is used instead.
|
TextCellFactory |
addSwaps(squidpony.squidmath.OrderedMap<java.lang.Character,java.lang.Character> swaps)
Appends to the mapping of replacement pairs, adding or replacing any entries in the current mapping with the
entries in a Map of Character keys to String values.
|
boolean |
antialias()
Returns whether this factory is currently set to do antialiasing on the
characters rendered, which is always true.
|
TextCellFactory |
antialias(boolean antialias)
Deprecated.
AA is the wave of the future!
|
int |
bottomPadding()
Returns the padding on the bottom side.
|
TextCellFactory |
bottomPadding(int padding)
Sets the amount of padding on the bottom side to the provided value.
|
TextCellFactory |
clearSwaps()
Clears all replacement pairs this has been told to swap.
|
void |
configureShader(com.badlogic.gdx.graphics.g2d.Batch batch)
If using a distance field font, you MUST call this at some point while the batch has begun, or use code that
calls it for you (which is now much of SquidLib).
|
TextCellFactory |
copy() |
TextCellFactory |
defaultDistanceFieldFont()
Sets the TextCellFactory to use a square distance field font that will resize to whatever size you request.
|
TextCellFactory |
defaultFont()
Sets this factory to use a default 12x24 font that supports Latin, Greek, Cyrillic, and many more, including
box-drawing characters, zodiac signs, playing-card suits, and chess piece symbols.
|
TextCellFactory |
defaultNarrowDistanceFieldFont()
Sets the TextCellFactory to use a half-square distance field font that will resize to whatever size you request.
|
TextCellFactory |
defaultNarrowFont()
Sets this factory to use a default 12x24 font that renders very accurately, with no gaps between box-drawing
characters and very geometric lines.
|
TextCellFactory |
defaultSquareFont()
Sets this factory to use a default 12x12 font, which...
|
void |
dispose()
Releases all resources of this object.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
char c,
com.badlogic.gdx.graphics.Color color,
float x,
float y)
Use the specified Batch to draw a char in the specified libGDX Color, with x and y
determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
char c,
float x,
float y)
Use the specified Batch to draw a char with the default color (white), with x and y determining the world-space
coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
char c,
float encodedColor,
float x,
float y)
Use the specified Batch to draw a String (often just one char long) in the specified libGDX Color, with x and y
determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
java.lang.CharSequence s,
com.badlogic.gdx.graphics.Color color,
float x,
float y)
Use the specified Batch to draw a String or other CharSequence (often just one char long) in the specified libGDX
Color, with x and y
determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
java.lang.CharSequence s,
float x,
float y)
Use the specified Batch to draw a String or other CharSequence (often just one char long) with the default color
(white), with x and y determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
java.lang.CharSequence s,
float encodedColor,
float x,
float y)
Use the specified Batch to draw a String or other CharSequence (often just one char long) in the specified libGDX
Color, with x and y determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
java.lang.CharSequence s,
float r,
float g,
float b,
float a,
float x,
float y)
Use the specified Batch to draw a String or other CharSequence (often just one char long) in the specified rgba
color, with x and y determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
float[][] encodedColors,
float x,
float y)
Draws a 2D array of floats that represent encoded colors, with each float used for a block of color the size of
one character cell (it will be
actualCellWidth by actualCellHeight in size, using world units). |
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
float[][] encodedColors,
float x,
float y,
int xSubCells,
int ySubCells)
Draws a 2D array of floats that represent encoded colors, with each float used for a block of color that will be
a fraction of the size of one character cell (it will be
actualCellWidth divided by xSubCells by
actualCellHeight divided by ySubCells in size, using world units). |
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.graphics.g2d.TextureRegion tr,
com.badlogic.gdx.graphics.Color color,
float x,
float y)
Use the specified Batch to draw a TextureRegion tinted with the specified libGDX Color, with x and y
determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.graphics.g2d.TextureRegion tr,
com.badlogic.gdx.graphics.Color color,
float x,
float y,
float width,
float height)
Use the specified Batch to draw a TextureRegion tinted with the specified libGDX Color, with x and y
determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.graphics.g2d.TextureRegion tr,
float x,
float y)
Use the specified Batch to draw a TextureRegion with the default tint color (white, so un-tinted), with x and y
determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.graphics.g2d.TextureRegion tr,
float encodedColor,
float x,
float y)
Use the specified Batch to draw a TextureRegion tinted with the specified encoded color as a float, with x and y
determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.graphics.g2d.TextureRegion tr,
float x,
float y,
float width,
float height)
Use the specified Batch to draw a TextureRegion with the default tint color (white, so un-tinted), with x and y
determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.graphics.g2d.TextureRegion tr,
float encodedColor,
float x,
float y,
float width,
float height)
Use the specified Batch to draw a TextureRegion tinted with the specified libGDX Color, with x and y
determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.graphics.g2d.TextureRegion tr,
float r,
float g,
float b,
float a,
float x,
float y)
Use the specified Batch to draw a TextureRegion tinted with the specified rgba color, with x and y
determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.g2d.Batch batch,
com.badlogic.gdx.graphics.g2d.TextureRegion tr,
float r,
float g,
float b,
float a,
float x,
float y,
float width,
float height)
Use the specified Batch to draw a TextureRegion tinted with the specified rgba color, with x and y
determining the world-space coordinates for the upper-left corner.
|
void |
draw(com.badlogic.gdx.graphics.Pixmap pixmap,
float[][] encodedColors)
Given a Pixmap and a 2D float array, uses each float in the array as an encoded color for a pixel in the Pixmap
at a location determined by the float's position in the array.
|
java.lang.String |
fit()
Returns the current String that is used for sizing the cells.
|
TextCellFactory |
fit(java.lang.String fit)
Sets the characters that will be guaranteed to fit as fixed-width to the provided ones.
|
TextCellFactory |
fitAll()
Sets all valid characters to be guaranteed to fit as fixed-width.
|
com.badlogic.gdx.graphics.g2d.BitmapFont |
font()
Returns the
BitmapFont used by this factory. |
TextCellFactory |
font(com.badlogic.gdx.graphics.g2d.BitmapFont bitmapFont)
Sets this factory to use the provided BitmapFont as its font without re-constructing anything.
|
TextCellFactory |
font(java.lang.String fontpath)
Sets this factory to use the provided font.
|
TextCellFactory |
fontDistanceField(java.lang.String fontPath,
java.lang.String texturePath)
Sets the font to a distance field font with the given String path to a .fnt file and String path to a texture.
|
TextCellFactory |
fontMultiDistanceField(java.lang.String fontPath,
java.lang.String texturePath) |
regexodus.ds.CharCharMap |
getAllSwaps()
Gets the current mapping of "swaps", or replacement pairs, to replace keys requested for drawing with their
values in the
CharCharMap . |
float |
getDescent()
Gets the descent of this TextCellFactory's BitmapFont, which may be useful for layout outside this class.
|
char |
getDirectionGlyph() |
float |
getDistanceFieldScaleX() |
float |
getDistanceFieldScaleY() |
static java.lang.String |
getGlyphs(com.badlogic.gdx.graphics.g2d.BitmapFont font)
Returns a String containing all chars in the font (not considering the missing glyph).
|
float |
getSmoothingMultiplier()
If this uses a distance field font, the smoothing multiplier affects how crisp or blurry lines are, with higher
numbers generally resulting in more crisp fonts, but numbers that are too high cause jagged aliasing.
|
com.badlogic.gdx.graphics.g2d.TextureRegion |
getSolid()
Returns a solid block of white, 1x1 pixel in size; can be drawn at other sizes by Batch.
|
TextCellFactory.Glyph |
glyph(char shown,
com.badlogic.gdx.graphics.Color color,
float x,
float y)
Gets a Glyph with the given char to show, libGDX Color, and position as x and y in world coordinates.
|
TextCellFactory.Glyph |
glyph(char shown,
float encodedColor,
float x,
float y)
Gets a Glyph with the given char to show, color as a packed float, and position as x and y in world coordinates.
|
float |
height()
Returns the height of a single cell.
|
TextCellFactory |
height(float height)
Sets the factory's cell height to the provided value.
|
TextCellFactory |
includedFont()
Sets this factory to use the one font included with libGDX, which is Liberation Sans at size 15 px.
|
TextCellFactory |
initByFont()
Initializes the factory to then be able to create text cells on demand.
|
TextCellFactory |
initBySize()
Initializes the factory to then be able to create text cells on demand.
|
boolean |
initialized()
Returns true if this factory is fully initialized and ready to build text cells.
|
TextCellFactory |
initVerbatim()
Identical to
initBySize() . |
boolean |
isDistanceField() |
boolean |
isMultiDistanceField() |
int |
leftPadding()
Returns the padding on the left side.
|
TextCellFactory |
leftPadding(int padding)
Sets the amount of padding on the left side to the provided value.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(char c,
java.util.Collection<com.badlogic.gdx.graphics.Color> colors)
Converts a char into a ColorChangeLabel, or if the argument c is '\0', creates a ColorChangeImage of a solid
block.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(char c,
java.util.Collection<com.badlogic.gdx.graphics.Color> colors,
float loopTime)
Converts a char into a ColorChangeLabel, or if the argument c is '\0', creates a ColorChangeImage of a solid
block.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(char c,
java.util.Collection<com.badlogic.gdx.graphics.Color> colors,
float loopTime,
boolean doubleWidth)
Converts a char into a ColorChangeLabel, or if the argument c is '\0', creates a ColorChangeImage of a solid
block.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(char c,
com.badlogic.gdx.graphics.Color color)
Converts a char into a Label, or if the argument c is '\0', creates an Image of a solid block.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(char c,
float encodedColor)
Converts a char into a Label, or if the argument c is '\0', creates an Image of a solid block.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(java.lang.String s,
java.util.Collection<com.badlogic.gdx.graphics.Color> colors)
Converts a String into a ColorChangeLabel, or if the argument s is null, creates a ColorChangeImage of a solid
block.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(java.lang.String s,
java.util.Collection<com.badlogic.gdx.graphics.Color> colors,
float loopTime)
Converts a String into a ColorChangeLabel, or if the argument s is null, creates a ColorChangeImage of a solid
block.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(java.lang.String s,
java.util.Collection<com.badlogic.gdx.graphics.Color> colors,
float loopTime,
boolean doubleWidth)
Converts a String into a ColorChangeLabel, or if the argument s is null, creates a ColorChangeImage of a solid
block.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(java.lang.String s,
com.badlogic.gdx.graphics.Color color)
Converts a String into a Label, or if the argument s is null, creates an Image of a solid block.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr,
java.util.Collection<com.badlogic.gdx.graphics.Color> colors) |
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr,
java.util.Collection<com.badlogic.gdx.graphics.Color> colors,
float loopTime) |
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr,
java.util.Collection<com.badlogic.gdx.graphics.Color> colors,
float loopTime,
boolean doubleWidth)
Converts a TextureRegion into a ColorChangeImage that will cycle through the given colors.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr,
java.util.Collection<com.badlogic.gdx.graphics.Color> colors,
float loopTime,
boolean doubleWidth,
float width,
float height)
Converts a TextureRegion into a ColorChangeImage that will cycle through the given colors.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr,
com.badlogic.gdx.graphics.Color color)
Converts a TextureRegion into an Image, or if the argument s is null, creates an Image of a solid block.
|
com.badlogic.gdx.scenes.scene2d.Actor |
makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr,
com.badlogic.gdx.graphics.Color color,
float width,
float height)
Converts a TextureRegion into an Image, or if the argument s is null, creates an Image of a solid block.
|
com.badlogic.gdx.scenes.scene2d.ui.Image |
makeDirectionMarker(java.util.Collection<com.badlogic.gdx.graphics.Color> colors,
float loopTime,
boolean doubleWidth)
Creates a ColorChangeImage Actor that should look like the glyph '^' in this font, but will be rotate-able.
|
com.badlogic.gdx.scenes.scene2d.ui.Image |
makeDirectionMarker(com.badlogic.gdx.graphics.Color color)
Creates a Image Actor that should look like the glyph '^' in this font, but will be rotate-able.
|
ColorChangeImage |
makeGlyphImage(char glyph,
java.util.Collection<com.badlogic.gdx.graphics.Color> colors,
float loopTime,
boolean doubleWidth)
Given a char and a Collection of Color (such as a List that might be produced by
SquidColorCenter.gradient(Color, Color) ), makes a ColorChangeImage of that char so it can be rotated and
so on. |
ColorChangeImage |
makeGlyphImage(char glyph,
com.badlogic.gdx.graphics.Color color)
Given a char and a Color, makes a ColorChangeImage of that colored char so it can be rotated and so on.
|
ColorChangeImage |
makeGlyphImage(char glyph,
com.badlogic.gdx.graphics.Color color,
boolean doubleWidth)
Given a char and a Color, makes a ColorChangeImage of that colored char so it can be rotated and so on.
|
com.badlogic.gdx.scenes.scene2d.ui.Label |
makeWrappingString(java.lang.String s)
Converts a String into a Label, or if the argument s is null, creates an Image of a solid block.
|
TextCellFactory |
padding(int padding)
Sets the amount of padding on all sides to the provided value.
|
TextCellFactory |
removeSwap(char find)
Removes the replacement pair, if present, that searches for the given key, find.
|
TextCellFactory |
removeSwap(java.lang.String find)
Removes the replacement pair, if present, that searches for the given key, find.
|
TextCellFactory |
resetSize()
Acts like calling
initBySize() , but doesn't create new ShaderPrograms or other objects if this has
already been initialized. |
TextCellFactory |
resetSize(float newWidth,
float newHeight)
Acts like calling
width(float) , height(float) , and initBySize() in succession, but
doesn't create new ShaderPrograms or other objects if this has already been initialized. |
int |
rightPadding()
Returns the padding on the right side.
|
TextCellFactory |
rightPadding(int padding)
Sets the amount of padding on the right side to the provided value.
|
static java.lang.String |
setAllFixedWidth(com.badlogic.gdx.graphics.g2d.BitmapFont font)
Sets all glyphs in the given BitmapFont to be fixed-width and have an xadvance
equal to the largest width for any glyph in the font.
|
TextCellFactory |
setAllSwaps(squidpony.squidmath.OrderedMap<java.lang.Character,java.lang.Character> swaps)
Sets the mapping of replacement pairs to a different one as a Map of Character keys to String values.
|
TextCellFactory |
setColorCenter(squidpony.IColorCenter<com.badlogic.gdx.graphics.Color> icc) |
TextCellFactory |
setDirectionGlyph(char directionGlyph) |
TextCellFactory |
setSmoothingMultiplier(float smoothingMultiplier)
If this uses a distance field font, the smoothing multiplier affects how crisp or blurry lines are, with higher
numbers generally resulting in more crisp fonts, but numbers that are too high cause jagged aliasing.
|
void |
setStyle(int style)
Not implemented in this class; in subclasses that do, this should change the currently-used font style, such as
from regular to italic or bold.
|
int |
supportedStyles()
How many styles are supported by this TextCellFactory; always 1 unless changed in a subclass.
|
int |
topPadding()
Returns the padding on the top side.
|
TextCellFactory |
topPadding(int padding)
Sets the amount of padding on the top side to the provided value.
|
TextCellFactory |
tweakHeight(float height)
Sets the factory's height used for text to the provided value, but does not change the size of a cell.
|
TextCellFactory |
tweakWidth(float width)
Sets the factory's height used for text to the provided value, but does not change the size of a cell.
|
float |
width()
Returns the width of a single cell.
|
TextCellFactory |
width(float width)
Sets the factory's cell width to the provided value.
|
boolean |
willFit(int codepoint)
Returns true if the given character will fit inside the current cell
dimensions with the current font.
|
public static final java.lang.String DEFAULT_FITTING
public static final java.lang.String SQUID_FITTING
DefaultResources
.protected com.badlogic.gdx.assets.AssetManager assetManager
AssetManager
from where to load the font. Use it to share
loading of a font's file across multiple factories.public com.badlogic.gdx.graphics.g2d.BitmapFont bmpFont
protected com.badlogic.gdx.graphics.g2d.TextureRegion block
protected com.badlogic.gdx.graphics.g2d.TextureRegion dirMarker
protected java.lang.String fitting
protected squidpony.IColorCenter<com.badlogic.gdx.graphics.Color> scc
protected int leftPadding
protected int rightPadding
protected int topPadding
protected int bottomPadding
protected float width
protected float height
public float actualCellWidth
public float actualCellHeight
protected float distanceFieldScaleX
protected float distanceFieldScaleY
protected boolean initialized
protected boolean initializedByFont
protected boolean initializedBySize
protected boolean distanceField
protected boolean msdf
public com.badlogic.gdx.graphics.glutils.ShaderProgram shader
protected float smoothingMultiplier
protected float descent
protected float lineHeight
protected com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle style
protected regexodus.ds.CharCharMap swap
protected char directionGlyph
protected squidpony.squidmath.OrderedMap<java.lang.Character,com.badlogic.gdx.graphics.g2d.TextureRegion> glyphTextures
protected java.lang.StringBuilder mut
public TextCellFactory()
public TextCellFactory(com.badlogic.gdx.assets.AssetManager assetManager)
AssetManager
to load
the font file. Use this constructor if you are likely to load the same
font over and over (recall that, without an AssetManager
, each
instance of TextCellFactory
will load its font from disk). This
primarily matters if you are using fonts not bundled with SquidLib, since
accessing a BitmapFont with a method (not a String) from DefaultResources
caches the BitmapFont already.assetManager
- an ordinary libGDX AssetManagerpublic int supportedStyles()
public TextCellFactory copy()
public static java.lang.String getGlyphs(com.badlogic.gdx.graphics.g2d.BitmapFont font)
font
- a BitmapFont that will not be changedpublic static java.lang.String setAllFixedWidth(com.badlogic.gdx.graphics.g2d.BitmapFont font)
font
- a BitmapFont that will be modified in-placepublic TextCellFactory initByFont()
initBySize()
is used
almost always instead of this method. This can be used when you don't
care what size the font actually will be, and are fine delegating that
responsibility to any initial configuration in the given BitmapFont.
initBySize()
.
fit()
) to a String
containing all chars in the font, and makes all chars fixed-width.public TextCellFactory initBySize()
resetSize()
,
which does not allocate new objects if this was already initialized, and
will just delegate to this method if this wasn't initialized.
fit(String)
or fitAll()
to ensure
that chars are rendered with fixed-width, which mostly affects any gaps at
the left side of a char. Using fitAll() either before or after calling
this is recommended.public TextCellFactory resetSize()
initBySize()
, but doesn't create new ShaderPrograms or other objects if this has
already been initialized. If this has not been initialized, simply returns initBySize(). This method is safe to
call every frame if the font size continually changes, where initBySize() is not.public TextCellFactory resetSize(float newWidth, float newHeight)
width(float)
, height(float)
, and initBySize()
in succession, but
doesn't create new ShaderPrograms or other objects if this has already been initialized. If this has not been
initialized, calls width() and height() and then simply returns initBySize(). This method is safe to call every
frame if the font size continually changes, where initBySize() is not.newWidth
- the new width of a single cell, as a float that usually corresponds to pixelsnewHeight
- the new height of a single cell, as a float that usually corresponds to pixelspublic TextCellFactory initVerbatim()
initBySize()
.The docs for initBySize() apply here.
public com.badlogic.gdx.graphics.g2d.BitmapFont font()
BitmapFont
used by this factory.public TextCellFactory font(java.lang.String fontpath)
DefaultResources.getDefaultFont()
= "Zodiac-Square-12x12.fnt"DefaultResources.getDefaultNarrowFont()
= "Rogue-Zodiac-6x12.fnt"DefaultResources.getDefaultUnicodeFont()
= "Mandrill-6x16.fnt"DefaultResources.getSmoothFont()
= "Inconsolata-LGC-8x18.fnt"DefaultResources.getLargeFont()
= "Zodiac-Square-24x24.fnt"DefaultResources.getLargeNarrowFont()
= "Rogue-Zodiac-12x24.fnt"DefaultResources.getLargeUnicodeFont()
= "Mandrill-12x32.fnt"DefaultResources.getLargeSmoothFont()
= "Inconsolata-LGC-12x24.fnt"DefaultResources.getExtraLargeNarrowFont()
= "Rogue-Zodiac-18x36.fnt"fontpath
- the path to the font to usepublic TextCellFactory font(com.badlogic.gdx.graphics.g2d.BitmapFont bitmapFont)
DefaultResources.getDefaultFont()
or any other variable
with BitmapFont as its type. The bitmap font will not be loaded from file with this method, which it would be if
you called the overload of font() that takes a String more than once. These BitmapFont resources are already
known by SquidLib, but may need separate downloads (detailed in the linked DefaultResources documentation):
DefaultResources.getDefaultFont()
= "Zodiac-Square-12x12.fnt"DefaultResources.getDefaultNarrowFont()
= "Rogue-Zodiac-6x12.fnt"DefaultResources.getDefaultUnicodeFont()
= "Mandrill-6x16.fnt"DefaultResources.getSmoothFont()
= "Inconsolata-LGC-8x18.fnt"DefaultResources.getLargeFont()
= "Zodiac-Square-24x24.fnt"DefaultResources.getLargeNarrowFont()
= "Rogue-Zodiac-12x24.fnt"DefaultResources.getLargeUnicodeFont()
= "Mandrill-12x32.fnt"DefaultResources.getLargeSmoothFont()
= "Inconsolata-LGC-12x24.fnt"DefaultResources.getExtraLargeNarrowFont()
= "Rogue-Zodiac-18x36.fnt"bitmapFont
- the BitmapFont this should usepublic TextCellFactory fontDistanceField(java.lang.String fontPath, java.lang.String texturePath)
fontPath
- the path to a .fnt bitmap font file with distance field effects applied, which requires a complex
process to create.texturePath
- the path to the texture used by the bitmap fontpublic TextCellFactory fontMultiDistanceField(java.lang.String fontPath, java.lang.String texturePath)
fontPath
- the path to a .fnt bitmap font file with multi-channel distance field effects applied, which
requires a complex process to create.texturePath
- the path to the texture used by the bitmap fontpublic TextCellFactory includedFont()
font(String)
, fontDistanceField(String, String)
, or
fontMultiDistanceField(String, String)
.
bmpFont
, so when the appropriate init method (initByFont()
or
initBySize()
) is called, lsans-15 will be loaded using DefaultResources.getIncludedFont()
.public TextCellFactory defaultFont()
public TextCellFactory defaultNarrowFont()
public TextCellFactory defaultSquareFont()
public TextCellFactory defaultDistanceFieldFont()
public TextCellFactory defaultNarrowDistanceFieldFont()
public float width()
public TextCellFactory width(float width)
width
- the desired widthpublic float height()
public TextCellFactory height(float height)
height
- the desired widthpublic TextCellFactory tweakWidth(float width)
width
- the desired widthpublic TextCellFactory tweakHeight(float height)
height
- the desired heightpublic java.lang.String fit()
fitAll()
, this will include every char in
the font. If instead you have called fit(String)
(potentially
with addFit(String)
), then this will typically be a smaller
String and may not include all chars in the font. If no method has set
the fitting, it will default to SQUID_FITTING
.public TextCellFactory fit(java.lang.String fit)
fit
- the String of code points to size topublic TextCellFactory fitAll()
public TextCellFactory addFit(java.lang.String fit)
fit
- the String of code points to size topublic boolean antialias()
@Deprecated public TextCellFactory antialias(boolean antialias)
antialias
- ignored, will always use antialiasingpublic TextCellFactory padding(int padding)
padding
- how much padding in pixelspublic int leftPadding()
public TextCellFactory leftPadding(int padding)
padding
- how much padding in pixelspublic int rightPadding()
public TextCellFactory rightPadding(int padding)
padding
- how much padding in pixelspublic int topPadding()
public TextCellFactory topPadding(int padding)
padding
- how much padding in pixelspublic int bottomPadding()
public TextCellFactory bottomPadding(int padding)
padding
- how much padding in pixelspublic TextCellFactory setColorCenter(squidpony.IColorCenter<com.badlogic.gdx.graphics.Color> icc)
icc
- The color center to use. Should not be null
.this
java.lang.NullPointerException
- If icc
is null
.public boolean initialized()
public boolean willFit(int codepoint)
codepoint
- the codepoint of the char in questionpublic void draw(com.badlogic.gdx.graphics.g2d.Batch batch, java.lang.CharSequence s, float x, float y)
batch
- the libGDX Batch to do the drawings
- the string to draw, often but not necessarily one char. Can be null to draw a solid block instead.x
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, char c, float x, float y)
'\0'
, will draw a solid white block instead.batch
- the libGDX Batch to do the drawingc
- the char to draw. Can be '\0'
to draw a solid block instead.x
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, java.lang.CharSequence s, float r, float g, float b, float a, float x, float y)
batch
- the libGDX Batch to do the drawings
- the string to draw, often but not necessarily one char. Can be null to draw a solid block instead.r
- 0.0f to 1.0f red valueg
- 0.0f to 1.0f green valueb
- 0.0f to 1.0f blue valuea
- 0.0f to 1.0f alpha valuex
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, java.lang.CharSequence s, com.badlogic.gdx.graphics.Color color, float x, float y)
batch
- the libGDX Batch to do the drawings
- the string to draw, often but not necessarily one char. Can be null to draw a solid block instead.color
- the libGDX Color to draw the char(s) with, all the same colorx
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, java.lang.CharSequence s, float encodedColor, float x, float y)
batch
- the libGDX Batch to do the drawings
- the string to draw, often but not necessarily one char. Can be null to draw a solid block instead.encodedColor
- the libGDX Color to use, converted to float as by Color.toFloatBits()
x
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, char c, com.badlogic.gdx.graphics.Color color, float x, float y)
batch
- the libGDX Batch to do the drawingc
- the char to draw. Can be '\0'
to draw a solid block instead.color
- the libGDX Color (or SquidLib SColor) to use, as an objectx
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, char c, float encodedColor, float x, float y)
batch
- the libGDX Batch to do the drawingc
- the char to draw. Can be '\0'
to draw a solid block instead.encodedColor
- the libGDX Color to use, converted to float as by Color.toFloatBits()
x
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.graphics.g2d.TextureRegion tr, float x, float y)
batch
- the libGDX Batch to do the drawingtr
- the TextureRegion to draw. Can be null to draw a solid block instead.x
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.graphics.g2d.TextureRegion tr, float r, float g, float b, float a, float x, float y)
batch
- the libGDX Batch to do the drawingtr
- the TextureRegion to draw. Can be null to draw a solid block instead.r
- 0.0 to 0.1 red valueg
- 0.0 to 0.1 green valueb
- 0.0 to 0.1 blue valuea
- 0.0 to 0.1 alpha valuex
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.graphics.g2d.TextureRegion tr, com.badlogic.gdx.graphics.Color color, float x, float y)
batch
- the libGDX Batch to do the drawingtr
- the TextureRegion to draw. Can be null to draw a solid block instead.color
- the libGDX Color to draw the char(s) with, all the same colorx
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.graphics.g2d.TextureRegion tr, float encodedColor, float x, float y)
SColor.floatGet(float, float, float, float)
,
SColor.toFloatBits()
, SColor.colorFromFloat(Color, float)
, and
SColor.lerpFloatColors(float, float, float)
.batch
- the libGDX Batch to do the drawingtr
- the TextureRegion to draw. Can be null to draw a solid block instead.encodedColor
- the float encoding a color (as ABGR8888; SColor can produce these) to draw the image withx
- x of the upper-left corner of the image in world coordinates.y
- y of the upper-left corner of the image in world coordinates.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.graphics.g2d.TextureRegion tr, float x, float y, float width, float height)
batch
- the libGDX Batch to do the drawingtr
- the TextureRegion to draw. Can be null to draw a solid block instead.x
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.width
- the width of the TextureRegion or solid block in pixels.height
- the height of the TextureRegion or solid block in pixels.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.graphics.g2d.TextureRegion tr, float r, float g, float b, float a, float x, float y, float width, float height)
batch
- the libGDX Batch to do the drawingtr
- the TextureRegion to draw. Can be null to draw a solid block instead.r
- 0.0 to 0.1 red valueg
- 0.0 to 0.1 green valueb
- 0.0 to 0.1 blue valuea
- 0.0 to 0.1 alpha valuex
- x of the upper-left corner of the region of text in world coordinates.y
- y of the upper-left corner of the region of text in world coordinates.width
- the width of the TextureRegion or solid block in pixels.height
- the height of the TextureRegion or solid block in pixels.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.graphics.g2d.TextureRegion tr, com.badlogic.gdx.graphics.Color color, float x, float y, float width, float height)
batch
- the libGDX Batch to do the drawingtr
- the TextureRegion to draw. Can be null to draw a solid block instead.color
- the libGDX Color to draw the image with, all the same colorx
- x of the upper-left corner of the image in world coordinates.y
- y of the upper-left corner of the image in world coordinates.width
- the width of the TextureRegion or solid block in pixels.height
- the height of the TextureRegion or solid block in pixels.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, com.badlogic.gdx.graphics.g2d.TextureRegion tr, float encodedColor, float x, float y, float width, float height)
batch
- the libGDX Batch to do the drawingtr
- the TextureRegion to draw. Can be null to draw a solid block instead.encodedColor
- the float encoding a color (as ABGR8888; SColor can produce these) to draw the image withx
- x of the upper-left corner of the image in world coordinates.y
- y of the upper-left corner of the image in world coordinates.width
- the width of the TextureRegion or solid block in pixels.height
- the height of the TextureRegion or solid block in pixels.public void draw(com.badlogic.gdx.graphics.g2d.Batch batch, float[][] encodedColors, float x, float y)
actualCellWidth
by actualCellHeight
in size, using world units).batch
- the libGDX Batch to do the drawingencodedColors
- a 2D float array of encoded colors, each usually produced by Color.toFloatBits()
or an SColor methodx
- the x-position where this should render the block of many colorsy
- the y-position where this should render the block of many colorspublic void draw(com.badlogic.gdx.graphics.g2d.Batch batch, float[][] encodedColors, float x, float y, int xSubCells, int ySubCells)
actualCellWidth
divided by xSubCells
by
actualCellHeight
divided by ySubCells
in size, using world units). Typically the 2D float array
should be larger than the 2D storage for text drawn over the colorful blocks (such as a 2D char array), since
more than one subcell may be drawn in the space of one character cell.batch
- the libGDX Batch to do the drawingencodedColors
- a 2D float array of encoded colors, each usually produced by Color.toFloatBits()
or an SColor methodx
- the x-position where this should render the block of many colorsy
- the y-position where this should render the block of many colorsxSubCells
- how many blocks of color should fit across the span of actualCellWidth
, each one float; must not be 0ySubCells
- how many blocks of color should fit across the span of actualCellHeight
, each one float; must not be 0public void draw(com.badlogic.gdx.graphics.Pixmap pixmap, float[][] encodedColors)
actualCellWidth
and actualCellHeight
of this TextCellFactory.
draw(Batch, float[][], float, float)
, so if you
need to draw backgrounds then prefer that method (as SparseLayers does). It also doesn't work with a FilterBatch,
so if you want to use FloatFilter to adjust colors, you would need to use the other draw method for backgrounds.pixmap
- a non-null Pixmap that will be modifiedencodedColors
- a 2D float array that must be non-null and non-empty, and contains packed colorspublic com.badlogic.gdx.scenes.scene2d.ui.Label makeWrappingString(java.lang.String s)
s
- a String to make into an Actor, which can be null for a solid block.public com.badlogic.gdx.scenes.scene2d.Actor makeActor(java.lang.String s, com.badlogic.gdx.graphics.Color color)
s
- a String to make into an Actor, which can be null for a solid block.color
- a Color to tint s with.public com.badlogic.gdx.scenes.scene2d.Actor makeActor(java.lang.String s, java.util.Collection<com.badlogic.gdx.graphics.Color> colors)
s
- a String to make into an Actor, which can be null for a solid block.colors
- a List of Color to tint s with, looping through all elements in the list each secondpublic com.badlogic.gdx.scenes.scene2d.Actor makeActor(java.lang.String s, java.util.Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
s
- a String to make into an Actor, which can be null for a solid block.colors
- a List of Color to tint s with, looping through all elements in the list each secondloopTime
- the amount of time, in seconds, to spend looping through all colors in the listpublic com.badlogic.gdx.scenes.scene2d.Actor makeActor(java.lang.String s, java.util.Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime, boolean doubleWidth)
s
- a String to make into an Actor, which can be null for a solid block.colors
- a List of Color to tint s with, looping through all elements in the list each secondloopTime
- the amount of time, in seconds, to spend looping through all colors in the listpublic com.badlogic.gdx.scenes.scene2d.Actor makeActor(char c, com.badlogic.gdx.graphics.Color color)
c
- a char to make into an Actor, which can be the character with Unicode value 0 for a solid block.color
- a Color to tint c with.public com.badlogic.gdx.scenes.scene2d.Actor makeActor(char c, float encodedColor)
SColor.floatGet(float, float, float, float)
or Color.toFloatBits()
.c
- a char to make into an Actor, which can be the character with Unicode value 0 for a solid block.encodedColor
- an ABGR packed float (as produced by SColor.floatGet(float, float, float, float)
) to use as c's colorpublic com.badlogic.gdx.scenes.scene2d.Actor makeActor(char c, java.util.Collection<com.badlogic.gdx.graphics.Color> colors)
c
- a char to make into an Actor, which can be the character with Unicode value 0 for a solid block.colors
- a List of Color to tint c with, looping through all elements in the list each secondpublic com.badlogic.gdx.scenes.scene2d.Actor makeActor(char c, java.util.Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
c
- a char to make into an Actor, which can be the character with Unicode value 0 for a solid block.colors
- a List of Color to tint c with, looping through all elements in the list each secondloopTime
- the amount of time, in seconds, to spend looping through all colors in the listpublic com.badlogic.gdx.scenes.scene2d.Actor makeActor(char c, java.util.Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime, boolean doubleWidth)
c
- a char to make into an Actor, which can be the character with Unicode value 0 for a solid block.colors
- a List of Color to tint c with, looping through all elements in the list each secondloopTime
- the amount of time, in seconds, to spend looping through all colors in the listpublic com.badlogic.gdx.scenes.scene2d.Actor makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr, java.util.Collection<com.badlogic.gdx.graphics.Color> colors)
public com.badlogic.gdx.scenes.scene2d.Actor makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr, java.util.Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime)
public com.badlogic.gdx.scenes.scene2d.Actor makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr, java.util.Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime, boolean doubleWidth)
tr
- a TextureRegion to make into an Actor, which can be null for a solid block.colors
- a List of Color to tint c with, looping through all elements in the list each secondloopTime
- the amount of time, in seconds, to spend looping through all colors in the listpublic com.badlogic.gdx.scenes.scene2d.Actor makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr, java.util.Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime, boolean doubleWidth, float width, float height)
tr
- a TextureRegion to make into an Actor, which can be null for a solid block.colors
- a List of Color to tint c with, looping through all elements in the list each secondloopTime
- the amount of time, in seconds, to spend looping through all colors in the listpublic com.badlogic.gdx.scenes.scene2d.ui.Image makeDirectionMarker(java.util.Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime, boolean doubleWidth)
colors
- a List of Color to tint the '^' with, looping through all elements in the list each secondloopTime
- the amount of time, in seconds, to spend looping through all colors in the listpublic com.badlogic.gdx.scenes.scene2d.ui.Image makeDirectionMarker(com.badlogic.gdx.graphics.Color color)
color
- a Color to tint the '^' withpublic ColorChangeImage makeGlyphImage(char glyph, com.badlogic.gdx.graphics.Color color)
glyph
- a char; should probably be visible, so not space or tabcolor
- a Color to use for the image; will not change even though ColorChangeImage permits thispublic ColorChangeImage makeGlyphImage(char glyph, com.badlogic.gdx.graphics.Color color, boolean doubleWidth)
glyph
- a char; should probably be visible, so not space or tabcolor
- a Color to use for the image; will not change even though ColorChangeImage permits thisdoubleWidth
- true if layout uses two chars of width per logical cell, false otherwisepublic ColorChangeImage makeGlyphImage(char glyph, java.util.Collection<com.badlogic.gdx.graphics.Color> colors, float loopTime, boolean doubleWidth)
SquidColorCenter.gradient(Color, Color)
), makes a ColorChangeImage of that char so it can be rotated and
so on. The colors will cycle through the given collection onceper loopTime
seconds. You can specify
double-width mode if you use it, probably in SquidPanel or SquidLayers.glyph
- a char; should probably be visible, so not space or tabcolors
- a Collection of Colors to use for the image; the image will cycle through them in orderloopTime
- the amount of time, in seconds, it should take for all colors to be cycled throughdoubleWidth
- true if layout uses two chars of width per logical cell, false otherwisepublic com.badlogic.gdx.scenes.scene2d.Actor makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr, com.badlogic.gdx.graphics.Color color)
tr
- a TextureRegion to make into an Actor, which can be null for a solid block.color
- a Color to tint tr with.public com.badlogic.gdx.scenes.scene2d.Actor makeActor(com.badlogic.gdx.graphics.g2d.TextureRegion tr, com.badlogic.gdx.graphics.Color color, float width, float height)
tr
- a TextureRegion to make into an Actor, which can be null for a solid block.color
- a Color to tint tr with.public com.badlogic.gdx.graphics.g2d.TextureRegion getSolid()
public TextCellFactory.Glyph glyph(char shown, com.badlogic.gdx.graphics.Color color, float x, float y)
shown
- char to show; if this is the char with codepoint 0, then this will show a solid blockcolor
- the color as a libGDX Color; can also be an SColor or some other subclass of Colorx
- the x position of the Glyph in world coordinates, as would be passed to draw()y
- the y position of the Glyph in world coordinates, as would be passed to draw()public TextCellFactory.Glyph glyph(char shown, float encodedColor, float x, float y)
shown
- char to show; if this is the char with codepoint 0, then this will show a solid blockencodedColor
- the encoded color as a float, as produced by Color.toFloatBits()
x
- the x position of the Glyph in world coordinates, as would be passed to draw()y
- the y position of the Glyph in world coordinates, as would be passed to draw()public boolean isMultiDistanceField()
public boolean isDistanceField()
public float getDistanceFieldScaleX()
public float getDistanceFieldScaleY()
public float getSmoothingMultiplier()
DefaultResources
notes when a different value is used).public TextCellFactory setSmoothingMultiplier(float smoothingMultiplier)
DefaultResources
notes when other values are used.smoothingMultiplier
- the new value for the smoothing multiplier as a float; should be fairly close to 1f.public void configureShader(com.badlogic.gdx.graphics.g2d.Batch batch)
batch
- the Batch, such as a FilterBatch
, to configure to render distance field fonts if necessary.public void dispose()
dispose
in interface com.badlogic.gdx.utils.Disposable
public float getDescent()
public char getDirectionGlyph()
public TextCellFactory setDirectionGlyph(char directionGlyph)
public TextCellFactory addSwap(java.lang.String find, java.lang.String replace)
addSwap("^", ",")
and also
addSwap(",", ":")
, then a requested '^' will be drawn as ',', not ':', but a requested ',' will be drawn
as ':' (only one swap will be performed). Typically you want a different TextCellFactory for UI elements that use
swapping, like a top-down char-based map, and elements that should not, like those that display normal text.find
- the requested String that will be changedreplace
- the replacement String that will be used in place of findpublic TextCellFactory addSwap(char find, char replace)
addSwap('^', ',')
and also
addSwap(',', ':')
, then a requested '^' will be drawn as ',', not ':', but a requested ',' will be drawn
as ':' (only one swap will be performed). Typically you want a different TextCellFactory for UI elements that use
swapping, like a top-down char-based map, and elements that should not, like those that display normal text.find
- the requested char that will be changed (converted to a length-1 String)replace
- the replacement char that will be used in place of find (converted to a length-1 String)public TextCellFactory removeSwap(java.lang.String find)
addSwap('^', ',')
and also
addSwap(',', ':')
, then a requested '^' will be drawn as ',', not ':', but a requested ',' will be drawn
as ':' (only one swap will be performed). Typically you want a different TextCellFactory for UI elements that use
swapping, like a top-down char-based map, and elements that should not, like those that display normal text.find
- the String that would be changed in the replacement pairpublic TextCellFactory removeSwap(char find)
addSwap('^', ',')
and also
addSwap(',', ':')
, then a requested '^' will be drawn as ',', not ':', but a requested ',' will be drawn
as ':' (only one swap will be performed). Typically you want a different TextCellFactory for UI elements that use
swapping, like a top-down char-based map, and elements that should not, like those that display normal text.public regexodus.ds.CharCharMap getAllSwaps()
CharCharMap
. CharCharMap is a class from RegExodus (a dependency of squidlib-util that is
used for text matching and Unicode support), which is used here to avoid making yet another primitive-backed
collection class.
addSwap('^', ',')
and also
addSwap(',', ':')
, then a requested '^' will be drawn as ',', not ':', but a requested ',' will be drawn
as ':' (only one swap will be performed). Typically you want a different TextCellFactory for UI elements that use
swapping, like a top-down char-based map, and elements that should not, like those that display normal text.public TextCellFactory setAllSwaps(squidpony.squidmath.OrderedMap<java.lang.Character,java.lang.Character> swaps)
addSwap('^', ',')
and also
addSwap(',', ':')
, then a requested '^' will be drawn as ',', not ':', but a requested ',' will be drawn
as ':' (only one swap will be performed). Typically you want a different TextCellFactory for UI elements that use
swapping, like a top-down char-based map, and elements that should not, like those that display normal text.swaps
- the Map of replacement pairs; keys requested for drawing will be replaced with their valuespublic TextCellFactory addSwaps(squidpony.squidmath.OrderedMap<java.lang.Character,java.lang.Character> swaps)
addSwap('^', ',')
and also
addSwap(',', ':')
, then a requested '^' will be drawn as ',', not ':', but a requested ',' will be drawn
as ':' (only one swap will be performed). Typically you want a different TextCellFactory for UI elements that use
swapping, like a top-down char-based map, and elements that should not, like those that display normal text.swaps
- the Map of replacement pairs to add; keys requested for drawing will be replaced with their valuespublic TextCellFactory clearSwaps()
addSwap('^', ',')
and also
addSwap(',', ':')
, then a requested '^' will be drawn as ',', not ':', but a requested ',' will be drawn
as ':' (only one swap will be performed). Typically you want a different TextCellFactory for UI elements that use
swapping, like a top-down char-based map, and elements that should not, like those that display normal text.public void setStyle(int style)
style
- an int, typically a constant in a class that implements this, that determines what style to use.Copyright © Eben Howard 2012–2022. All rights reserved.