Class DefaultTokenPainter

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.awt.geom.Rectangle2D.Float bgRect
      Rectangle used for filling token backgrounds.
      private static char[] tabBuf
      Micro-optimization; buffer used to compute tab width.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float paint​(Token token, java.awt.Graphics2D g, float x, float y, RSyntaxTextArea host, javax.swing.text.TabExpander e)
      Paints this token.
      float paint​(Token token, java.awt.Graphics2D g, float x, float y, RSyntaxTextArea host, javax.swing.text.TabExpander e, float clipStart)
      Paints this token.
      float paint​(Token token, java.awt.Graphics2D g, float x, float y, RSyntaxTextArea host, javax.swing.text.TabExpander e, float clipStart, boolean paintBG)
      Paints this token.
      protected void paintBackground​(float x, float y, float width, float height, java.awt.Graphics2D g, int fontAscent, RSyntaxTextArea host, java.awt.Color color)
      Paints the background of a token.
      protected float paintImpl​(Token token, java.awt.Graphics2D g, float x, float y, RSyntaxTextArea host, javax.swing.text.TabExpander e, float clipStart, boolean selected, boolean useSTC)
      Does the dirty-work of actually painting the token.
      float paintSelected​(Token token, java.awt.Graphics2D g, float x, float y, RSyntaxTextArea host, javax.swing.text.TabExpander e, boolean useSTC)
      Paints this token as it should appear in a selected region of text (assuming painting with a selection-foreground color is enabled in the parent RSyntaxTextArea).
      float paintSelected​(Token token, java.awt.Graphics2D g, float x, float y, RSyntaxTextArea host, javax.swing.text.TabExpander e, float clipStart, boolean useSTC)
      Paints this token as it should appear in a selected region of text (assuming painting with a selection-foreground color is enabled in the parent RSyntaxTextArea).
      protected void paintTabLines​(Token token, int x, int y, int endX, java.awt.Graphics2D g, javax.swing.text.TabExpander e, RSyntaxTextArea host)
      Paints dotted "tab" lines; that is, lines that show where your caret would go to on the line if you hit "tab".
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • bgRect

        private java.awt.geom.Rectangle2D.Float bgRect
        Rectangle used for filling token backgrounds.
      • tabBuf

        private static char[] tabBuf
        Micro-optimization; buffer used to compute tab width. If the width is correct it's not re-allocated, to prevent lots of very small garbage. Only used when painting tab lines.
    • Constructor Detail

      • DefaultTokenPainter

        DefaultTokenPainter()
    • Method Detail

      • paint

        public final float paint​(Token token,
                                 java.awt.Graphics2D g,
                                 float x,
                                 float y,
                                 RSyntaxTextArea host,
                                 javax.swing.text.TabExpander e)
        Description copied from interface: TokenPainter
        Paints this token.
        Specified by:
        paint in interface TokenPainter
        Parameters:
        token - The token to render.
        g - The graphics context in which to paint.
        x - The x-coordinate at which to paint.
        y - The y-coordinate at which to paint.
        host - The text area this token is in.
        e - How to expand tabs.
        Returns:
        The x-coordinate representing the end of the painted text.
      • paint

        public float paint​(Token token,
                           java.awt.Graphics2D g,
                           float x,
                           float y,
                           RSyntaxTextArea host,
                           javax.swing.text.TabExpander e,
                           float clipStart)
        Description copied from interface: TokenPainter
        Paints this token.
        Specified by:
        paint in interface TokenPainter
        Parameters:
        token - The token to render.
        g - The graphics context in which to paint.
        x - The x-coordinate at which to paint.
        y - The y-coordinate at which to paint.
        host - The text area this token is in.
        e - How to expand tabs.
        clipStart - The left boundary of the clip rectangle in which we're painting. This optimizes painting by allowing us to not paint when this token is "to the left" of the clip rectangle.
        Returns:
        The x-coordinate representing the end of the painted text.
      • paint

        public float paint​(Token token,
                           java.awt.Graphics2D g,
                           float x,
                           float y,
                           RSyntaxTextArea host,
                           javax.swing.text.TabExpander e,
                           float clipStart,
                           boolean paintBG)
        Description copied from interface: TokenPainter
        Paints this token.
        Specified by:
        paint in interface TokenPainter
        Parameters:
        token - The token to render.
        g - The graphics context in which to paint.
        x - The x-coordinate at which to paint.
        y - The y-coordinate at which to paint.
        host - The text area this token is in.
        e - How to expand tabs.
        clipStart - The left boundary of the clip rectangle in which we're painting. This optimizes painting by allowing us to not paint when this token is "to the left" of the clip rectangle.
        paintBG - Whether to paint the background.
        Returns:
        The x-coordinate representing the end of the painted text.
      • paintBackground

        protected void paintBackground​(float x,
                                       float y,
                                       float width,
                                       float height,
                                       java.awt.Graphics2D g,
                                       int fontAscent,
                                       RSyntaxTextArea host,
                                       java.awt.Color color)
        Paints the background of a token.
        Parameters:
        x - The x-coordinate of the token.
        y - The y-coordinate of the token.
        width - The width of the token (actually, the width of the part of the token to paint).
        height - The height of the token.
        g - The graphics context with which to paint.
        fontAscent - The ascent of the token's font.
        host - The text area.
        color - The color with which to paint.
      • paintImpl

        protected float paintImpl​(Token token,
                                  java.awt.Graphics2D g,
                                  float x,
                                  float y,
                                  RSyntaxTextArea host,
                                  javax.swing.text.TabExpander e,
                                  float clipStart,
                                  boolean selected,
                                  boolean useSTC)
        Does the dirty-work of actually painting the token.
      • paintSelected

        public float paintSelected​(Token token,
                                   java.awt.Graphics2D g,
                                   float x,
                                   float y,
                                   RSyntaxTextArea host,
                                   javax.swing.text.TabExpander e,
                                   boolean useSTC)
        Description copied from interface: TokenPainter
        Paints this token as it should appear in a selected region of text (assuming painting with a selection-foreground color is enabled in the parent RSyntaxTextArea).
        Specified by:
        paintSelected in interface TokenPainter
        Parameters:
        token - The token to render.
        g - The graphics context in which to paint.
        x - The x-coordinate at which to paint.
        y - The y-coordinate at which to paint.
        host - The text area this token is in.
        e - How to expand tabs.
        useSTC - Whether to use the text area's "selected text color."
        Returns:
        The x-coordinate representing the end of the painted text.
      • paintSelected

        public float paintSelected​(Token token,
                                   java.awt.Graphics2D g,
                                   float x,
                                   float y,
                                   RSyntaxTextArea host,
                                   javax.swing.text.TabExpander e,
                                   float clipStart,
                                   boolean useSTC)
        Description copied from interface: TokenPainter
        Paints this token as it should appear in a selected region of text (assuming painting with a selection-foreground color is enabled in the parent RSyntaxTextArea).
        Specified by:
        paintSelected in interface TokenPainter
        Parameters:
        token - The token to render.
        g - The graphics context in which to paint.
        x - The x-coordinate at which to paint.
        y - The y-coordinate at which to paint.
        host - The text area this token is in.
        e - How to expand tabs.
        clipStart - The left boundary of the clip rectangle in which we're painting. This optimizes painting by allowing us to not paint when this token is "to the left" of the clip rectangle.
        useSTC - Whether to use the text area's "selected text color."
        Returns:
        The x-coordinate representing the end of the painted text.
      • paintTabLines

        protected void paintTabLines​(Token token,
                                     int x,
                                     int y,
                                     int endX,
                                     java.awt.Graphics2D g,
                                     javax.swing.text.TabExpander e,
                                     RSyntaxTextArea host)
        Paints dotted "tab" lines; that is, lines that show where your caret would go to on the line if you hit "tab". This visual effect is usually done in the leading whitespace token(s) of lines.
        Parameters:
        token - The token to render.
        x - The starting x-offset of this token. It is assumed that this is the left margin of the text area (may be non-zero due to insets), since tab lines are only painted for leading whitespace.
        y - The baseline where this token was painted.
        endX - The ending x-offset of this token.
        g - The graphics context.
        e - Used to expand tabs.
        host - The text area.