Class 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 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.
    • Constructor Detail

      • PainterText

        public PainterText()
        Creates a new
    • Method Detail

      • 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:
        paint in interface Painter
        Specified by:
        paint in class PainterBase
        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 name
        style - The font style
        size - The font size (for 1024 Px width)
        Returns:
        The font.