Package editor

Class GosuStyleContext.GosuSourceView

All Implemented Interfaces:
SwingConstants, TabExpander
Enclosing class:
GosuStyleContext

class GosuStyleContext.GosuSourceView extends WrappedPlainView
View that uses the lexical information to determine the style characteristics of the text that it renders. This simply colorizes the various tokens and assumes a constant font family and size.
  • Field Details

  • Constructor Details

    • GosuSourceView

      GosuSourceView(Element elem)
      Construct a simple syntax highlight view of gosu source.
  • Method Details

    • paint

      public void paint(Graphics g, Shape a)
      Renders using the given rendering surface and area on that surface. This is implemented to invalidate the lexical scanner after rendering so that the next request to drawUnselectedText will set a new range for the scanner.
      Overrides:
      paint in class WrappedPlainView
      Parameters:
      g - The rendering surface to use
      a - The allocated region to render into
    • drawSelectedText

      protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException
      Renders the given range in the model as normal unselected text. This is implemented to paint colors based upon the token-to-color translations. To reduce the number of calls to the Graphics object, text is batched up until a color change is detected or the entire requested range has been reached.
      Overrides:
      drawSelectedText in class WrappedPlainView
      Parameters:
      g - The graphics context
      x - The starting X coordinate
      y - The starting Y coordinate
      p0 - The beginning position in the model
      p1 - The ending position in the model
      Returns:
      The location of the end of the range
      Throws:
      BadLocationException - if the range is invalid
    • drawUnselectedText

      protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException
      Overrides:
      drawUnselectedText in class WrappedPlainView
      Throws:
      BadLocationException
    • updateScanner

      void updateScanner(int p)
      Update the scanner (if necessary) to point to the appropriate token for the given start position needed for rendering.
    • drawTabbedText

      public final int drawTabbedText(Segment s, Style style, Font font, int x, int y, Graphics2D g, TabExpander e, int startOffset)
    • drawText

      public final void drawText(Graphics2D g2, Style style, Font font, String text, int x, int y)
      Draws text using a TextLayout. This method of drawing text is necessary to support certain attribute esp. TextAttribute.UNDERLINE and TextAttribute.STRIKETHROUGH .