public abstract class SquidPanelBuilder extends IPanelBuilder.Skeleton
IPanelBuilder
. This class makes
the assumption that font files are only available for square and even sizes.
The only method to implement is fontfile(int)
that must return the
name of the file where a font of a given size lives.
I think this class should be generalized so that it supports cell width and
cell height that are proportional (for example: a height that is the double
of the width), but not to arbitrary combinations. In that case
adjustCellSize(int)
would become impossible to implement.
IPanelBuilder.Skeleton
Modifier and Type | Field and Description |
---|---|
com.badlogic.gdx.assets.AssetManager |
assetManager |
protected com.badlogic.gdx.graphics.Color |
defaultForegroundColor
The color passed to
SquidPanel.setDefaultForeground(Color) when
building a new panel, if non-null . |
protected int |
fontOffset |
protected squidpony.IColorCenter<com.badlogic.gdx.graphics.Color> |
icc |
protected int |
largestFont |
protected int |
smallestFont |
Constructor and Description |
---|
SquidPanelBuilder(int smallestFont,
int largestFont,
int fontOffset,
squidpony.IColorCenter<com.badlogic.gdx.graphics.Color> icc,
com.badlogic.gdx.assets.AssetManager assetManager) |
Modifier and Type | Method and Description |
---|---|
int |
adjustCellSize(int sz) |
SquidPanel |
buildByCells(int hCells,
int vCells,
int cellWidth,
int cellHeight,
TextCellFactory tcf_)
Builds a panel by the number of requested cells.
|
SquidPanel |
buildScreenWide(int screenWidth,
int screenHeight,
int desiredCellSize,
TextCellFactory tcf)
This method builds a panel whose number of cells is such that the cell
size is close to
desiredCellSize . |
boolean |
cellSizeTooBig(int cellSize)
Method to check whether increasing the cell size is possible.
|
boolean |
cellSizeTooSmall(int cellSize)
Method to check whether decreasing the cell size is possible.
|
protected abstract String |
fontfile(int sz) |
int |
fontSizeForCellSize(int cellSize) |
boolean |
hasFontForCellOfSize(int cellSize) |
boolean |
hasFontOfSize(int sz) |
void |
setDefaultForegroundColor(com.badlogic.gdx.graphics.Color c) |
protected final squidpony.IColorCenter<com.badlogic.gdx.graphics.Color> icc
public final com.badlogic.gdx.assets.AssetManager assetManager
protected final int smallestFont
protected final int largestFont
protected final int fontOffset
protected com.badlogic.gdx.graphics.Color defaultForegroundColor
SquidPanel.setDefaultForeground(Color)
when
building a new panel, if non-null
.public SquidPanelBuilder(int smallestFont, int largestFont, int fontOffset, squidpony.IColorCenter<com.badlogic.gdx.graphics.Color> icc, com.badlogic.gdx.assets.AssetManager assetManager)
smallestFont
- The smallest font size available.largestFont
- The largest font size available.fontOffset
- This offset is added to the cell size when computing the font
size for a given cell size.icc
- The color center to give to
SquidPanel.setColorCenter(IColorCenter)
, or
null
not to call this method.assetManager
- public SquidPanel buildScreenWide(int screenWidth, int screenHeight, int desiredCellSize, TextCellFactory tcf)
IPanelBuilder
desiredCellSize
. This method only supports
square cells.screenWidth
- The screen's width, in number of pixels, as given by libgdx.screenHeight
- The screen's height, in number of pixels, as given by libgdx.desiredCellSize
- The cell size that you would like the panel to have. Width and
height cannot be different, because this method supports only
square cells.tcf
- The TextCellFactory
to use. Can be null
to
create the panel.public SquidPanel buildByCells(int hCells, int vCells, int cellWidth, int cellHeight, TextCellFactory tcf_)
IPanelBuilder
hCells
- The number of horizontal cells of the panel to build.vCells
- The number of vertical cells of the panel to build.cellWidth
- The width of a cell (in pixels).cellHeight
- The height of a cell (in pixels).tcf_
- The text cell factory to use, if any.public int adjustCellSize(int sz)
sz
- sz
.public boolean cellSizeTooBig(int cellSize)
IPanelBuilder
true
if cellSize
is too big.public boolean cellSizeTooSmall(int cellSize)
IPanelBuilder
true
if cellSize
is too small.public boolean hasFontForCellOfSize(int cellSize)
hasFontForCellOfSize
in interface IPanelBuilder
hasFontForCellOfSize
in class IPanelBuilder.Skeleton
cellSize
.public int fontSizeForCellSize(int cellSize)
cellSize
.
Generally, it is cellSize
; but it can be less in case
glyphs are too large.public boolean hasFontOfSize(int sz)
sz
is available.public void setDefaultForegroundColor(com.badlogic.gdx.graphics.Color c)
c
- The default foreground color that freshly created panels will
have. Can be null
to use SquidPanel
's default.Copyright © 2012–2016. All rights reserved.