Class AbstractTextElement
- java.lang.Object
-
- be.yildizgames.common.util.BaseRegisterable
-
- be.yildizgames.module.graphic.gui.internal.BaseElement
-
- be.yildizgames.module.graphic.gui.element.AbstractTextElement
-
- All Implemented Interfaces:
be.yildizgames.common.util.Registerable,Element
public abstract class AbstractTextElement extends BaseElement
Base element to print text.- Author:
- Grégory Van Den Borre
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface be.yildizgames.module.graphic.gui.internal.Element
Element.Alignment
-
-
Field Summary
-
Fields inherited from class be.yildizgames.module.graphic.gui.internal.BaseElement
MAX_OPACITY, virtualHeight
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractTextElement(be.yildizgames.module.coordinate.BaseCoordinate coordinates, Font textFont)Full constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static AbstractTextElementgetByName(String name)FontgetFont()intgetFontHeight()floatgetLastLineWidth()Compute the last text width, if the text is multi line.StringgetText()intgetTextHeight()intgetTextWidth()Compute the width in pixel of the printed text.protected voidremoveFromRegisterer()Remove the element from registered elements.abstract voidsetColor(be.yildizgames.module.color.Color color)Set the text color.voidsetFont(Font newFont)protected abstract voidsetFontImpl(Font newFont)Internal method, do not use externally.booleansetText(String newText)Overload the setText method to avoid the toString call.protected abstract voidsetTextImpl(String newText)Internal method, do not use externally.-
Methods inherited from class be.yildizgames.module.graphic.gui.internal.BaseElement
addToLeft, addToPosition, addToTop, delete, getBottom, getCoordinates, getHeight, getLeft, getOpacity, getRight, getTop, getWidth, hide, hideImpl, isVisible, multiplySize, resetVirtualHeight, setCoordinates, setHeight, setLeft, setLeft, setLeft, setLeft, setPosition, setPosition, setPositionImpl, setSize, setSize, setSizeImpl, setTop, setTop, setTop, setTop, setVirtualHeight, setVisible, setWidth, show, showImpl, updateAddPositionValue
-
Methods inherited from class be.yildizgames.common.util.BaseRegisterable
equals, getName, hashCode, toString
-
-
-
-
Constructor Detail
-
AbstractTextElement
protected AbstractTextElement(be.yildizgames.module.coordinate.BaseCoordinate coordinates, Font textFont)Full constructor.- Parameters:
coordinates- Text position and size.textFont- Font to use to print the text.
-
-
Method Detail
-
getByName
public static AbstractTextElement getByName(String name)
-
getTextWidth
public final int getTextWidth()
Compute the width in pixel of the printed text.- Returns:
- Current text width in pixel.
-
getLastLineWidth
public final float getLastLineWidth()
Compute the last text width, if the text is multi line.- Returns:
- Current text last line width in pixel.
-
removeFromRegisterer
protected final void removeFromRegisterer()
Remove the element from registered elements.
-
getTextHeight
public final int getTextHeight()
- Returns:
- Current text height in pixel.
-
getText
public final String getText()
- Returns:
- The text.
-
setText
public final boolean setText(String newText)
Overload the setText method to avoid the toString call.- Parameters:
newText- New text to print.- Returns:
trueif the text was updated.
-
getFontHeight
public final int getFontHeight()
- Returns:
- The font height.
-
getFont
public final Font getFont()
- Returns:
- The text font.
-
setFont
public final void setFont(Font newFont)
- Parameters:
newFont- New font.
-
setTextImpl
protected abstract void setTextImpl(String newText)
Internal method, do not use externally. Update the text in graphic engine implementation.- Parameters:
newText- New text to print.
-
setFontImpl
protected abstract void setFontImpl(Font newFont)
Internal method, do not use externally. Update the font in graphic engine implementation.- Parameters:
newFont- New font to use.
-
setColor
public abstract void setColor(be.yildizgames.module.color.Color color)
Set the text color.- Parameters:
color- Color to set to this text.
-
-