Package com.starpoints.painter
Class PainterText
- java.lang.Object
-
- com.starpoints.painter.PainterBase
-
- com.starpoints.painter.PainterText
-
- All Implemented Interfaces:
Painter
- Direct Known Subclasses:
PainterEditorHelp,PainterLevelIntro,PainterTutorial
public class PainterText extends PainterBase
Painter for text display. Capable of displaying a list of text pages. The text my contain format strings, identified by a leading '#'-sign (which itself cannot be display in the text (yet). The following format strings are supported:## : Line break.
#* : Paragraph
#T : Tab
#X100; : Pixel Tab (steps to the given x position)
#Cred; : Text color change. The color (between 'C' and ';' are restricted to the color constants defined in Colors
#S16; : Text size.
#FSansSerif; : Text font.
#Icredits.png;: Image display in front of text (must contain filename from imge in /pics-folder).
#P : Pauses text display.
-
-
Field Summary
Fields Modifier and Type Field Description protected intcurrentColorThe current color during painting.protected FontcurrentFontThe current font during painting.protected intcurrentOpacityThe current color opacity for painting.protected intindexThe text index during painting.protected intlineIndexIndex of displayed line.protected intpaintCountCounter for painting.protected booleanshadowOnFlag if text is drawn with shadow.protected booleansideCompleteFlag if the current text page is fully displayed.protected booleanswitchImmediateFlag, if the text should immediatly switch to the next page.protected java.lang.StringtextThe current text.protected java.util.ArrayList<java.lang.String>textBufferThe list of texts to display.protected intxposPosition during painting.protected intyposPosition during painting.-
Fields inherited from class com.starpoints.painter.PainterBase
area, areas, bigFont, controller, gameInfo, medFont, mouseArea, offset, oldMouseArea, options, smallFont, state, verysmallFont, xfactor, yfactor
-
-
Constructor Summary
Constructors Constructor Description PainterText()Creates a new
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidchangeColorFromFormatString()Changes the text color according to a format string.protected voidchangeFontFromFormatString()Changes the text font according to a format string.protected voidchangeSizeFromFormatString()Changes the text size according to a format string.protected voiddisplayImageFromFormatString(Graphics g)Displays an image according to a format string.voiddisplayText(java.lang.String text)Adds the text to the list.intgetBaseHeight()Gets the base height of this painter.intgetBaseWidth()Gets the base width of this painter.protected FontgetFont(java.lang.String name, int style, int size)Gets the font by fontname, style and size by regarding the scaling factor.voidinititialize(java.lang.Object[] params)Initializes the text painter fx with the given parameters.voidpaint(Graphics g, GameState state)Paints the text to the screen.protected voidpauseFromFormatString()Pauses text display according to a format string.voidsetColor(int c)Sets the color (until it is switched by the displayed text).voidsetFont(Font f)Sets the font (until it is switched by the displayed text).voidsetText(java.lang.String text)Sets the current text to display.protected voidstepToStrongTabFromFormatString()Steps to the next tab.protected voidstepToTabFromFormatString()Steps to the next tab.protected voidstepYFromFormatString()protected voidswitchShadowFromFormatString()Switches shadow text mode from a format string.booleanswitchToNext()Completes the current text page immediatly, or switches to the next text (if there is another one).-
Methods inherited from class com.starpoints.painter.PainterBase
draw, drawShaded, drawShaded, getArea, getEditor, getHeight, getIndent, getRepaintFactor, getWidth, getXFactor, getYFactor, isActive, isInputController, onStartGame, setArea, setController, setFontSize, setLevel, setOptions, setState
-
-
-
-
Field Detail
-
index
protected transient int index
The text index during painting.
-
text
protected transient java.lang.String text
The current text.
-
sideComplete
protected boolean sideComplete
Flag if the current text page is fully displayed.
-
switchImmediate
protected transient boolean switchImmediate
Flag, if the text should immediatly switch to the next page.
-
lineIndex
protected transient int lineIndex
Index of displayed line.
-
xpos
protected transient int xpos
Position during painting.
-
ypos
protected transient int ypos
Position during painting.
-
paintCount
protected int paintCount
Counter for painting.
-
currentFont
protected transient Font currentFont
The current font during painting.
-
currentColor
protected transient int currentColor
The current color during painting.
-
currentOpacity
protected transient int currentOpacity
The current color opacity for painting.
-
textBuffer
protected java.util.ArrayList<java.lang.String> textBuffer
The list of texts to display.
-
shadowOn
protected boolean shadowOn
Flag if text is drawn with shadow.
-
-
Method Detail
-
getBaseWidth
public int getBaseWidth()
Gets the base width of this painter.- Specified by:
getBaseWidthin interfacePainter- Overrides:
getBaseWidthin classPainterBase- Returns:
- 910.
-
getBaseHeight
public int getBaseHeight()
Gets the base height of this painter.- Specified by:
getBaseHeightin interfacePainter- Overrides:
getBaseHeightin classPainterBase- Returns:
- 961.
-
displayText
public void displayText(java.lang.String text)
Adds the text to the list.- Parameters:
text- The text to display.
-
inititialize
public void inititialize(java.lang.Object[] params)
Initializes the text painter fx with the given parameters.- Parameters:
params- The initialization parameters.
-
setFont
public void setFont(Font f)
Sets the font (until it is switched by the displayed text).- Parameters:
f- The new font
-
setColor
public void setColor(int c)
Sets the color (until it is switched by the displayed text).- Parameters:
c- The new color
-
setText
public void setText(java.lang.String text)
Sets the current text to display.- Parameters:
text- The new text.
-
switchToNext
public boolean switchToNext()
Completes the current text page immediatly, or switches to the next text (if there is another one).- Returns:
- true, if the page was not yet complete, or if there was another page to switch to.
-
paint
public void paint(Graphics g, GameState state)
Paints the text to the screen.- Specified by:
paintin interfacePainter- Specified by:
paintin classPainterBase- Parameters:
g- The graphics.state- The game state.
-
stepYFromFormatString
protected void stepYFromFormatString()
-
displayImageFromFormatString
protected void displayImageFromFormatString(Graphics g)
Displays an image according to a format string.- Parameters:
g- The graphics
-
stepToStrongTabFromFormatString
protected void stepToStrongTabFromFormatString()
Steps to the next tab.
-
stepToTabFromFormatString
protected void stepToTabFromFormatString()
Steps to the next tab.
-
changeColorFromFormatString
protected void changeColorFromFormatString()
Changes the text color according to a format string.
-
changeSizeFromFormatString
protected void changeSizeFromFormatString()
Changes the text size according to a format string.
-
pauseFromFormatString
protected void pauseFromFormatString()
Pauses text display according to a format string.
-
switchShadowFromFormatString
protected void switchShadowFromFormatString()
Switches shadow text mode from a format string.
-
changeFontFromFormatString
protected void changeFontFromFormatString()
Changes the text font according to a format string.
-
getFont
protected Font getFont(java.lang.String name, int style, int size)
Gets the font by fontname, style and size by regarding the scaling factor.- Parameters:
name- The font namestyle- The font stylesize- The font size (for 1024 Px width)- Returns:
- The font.
-
-