Class RSyntaxTextAreaUI

  • All Implemented Interfaces:
    ViewFactory

    public class RSyntaxTextAreaUI
    extends RTextAreaUI
    UI used by RSyntaxTextArea. This allows us to implement syntax highlighting.
    • Constructor Detail

      • RSyntaxTextAreaUI

        public RSyntaxTextAreaUI​(JComponent rSyntaxTextArea)
        Constructor.
    • Method Detail

      • createHighlighter

        protected Highlighter createHighlighter()
        Creates the highlighter to use for syntax text areas.
        Overrides:
        createHighlighter in class BasicTextUI
        Returns:
        The highlighter.
      • getActionMapName

        protected String getActionMapName()
        Returns the name to use to cache/fetch the shared action map. This should be overridden by subclasses if the subclass has its own custom editor kit to install, so its actions get picked up.
        Overrides:
        getActionMapName in class RTextAreaUI
        Returns:
        The name of the cached action map.
      • getRTextAreaInputMap

        protected InputMap getRTextAreaInputMap()
        Get the InputMap to use for the UI.

        This method is not named getInputMap() because there is a package-private method in BasicTextAreaUI with that name. Thus, creating a new method with that name causes certain compilers to issue warnings that you are not actually overriding the original method (since it is package-private).

        Overrides:
        getRTextAreaInputMap in class RTextAreaUI
      • paintEditorAugmentations

        protected void paintEditorAugmentations​(Graphics g)
        Description copied from class: RTextAreaUI
        Paints editor augmentations added by RTextArea: highlighted lines, current line highlight, and margin line.
        Overrides:
        paintEditorAugmentations in class RTextAreaUI
        Parameters:
        g - The graphics context with which to paint.
      • paintMatchedBracket

        protected void paintMatchedBracket​(Graphics g)
        Paints the "matched bracket", if any.
        Parameters:
        g - The graphics context.
      • propertyChange

        protected void propertyChange​(PropertyChangeEvent e)
        Gets called whenever a bound property is changed on this UI's RSyntaxTextArea.
        Overrides:
        propertyChange in class BasicTextAreaUI
        Parameters:
        e - The property change event.
      • refreshSyntaxHighlighting

        public void refreshSyntaxHighlighting()
        Updates the view. This should be called when the underlying RSyntaxTextArea changes its syntax editing style.
      • yForLine

        public int yForLine​(int line)
                     throws BadLocationException
        Returns the y-coordinate of the specified line.

        This method is quicker than using traditional modelToView(int) calls, as the entire bounding box isn't computed.

        Overrides:
        yForLine in class RTextAreaUI
        Parameters:
        line - The line number.
        Returns:
        The y-coordinate of the top of the line, or -1 if this text area doesn't yet have a positive size or the line is hidden (i.e. from folding).
        Throws:
        BadLocationException - If line isn't a valid line number for this document.
      • yForLineContaining

        public int yForLineContaining​(int offs)
                               throws BadLocationException
        Returns the y-coordinate of the line containing a specified offset.

        This is faster than calling modelToView(offs).y, so it is preferred if you do not need the actual bounding box.

        Overrides:
        yForLineContaining in class RTextAreaUI
        Parameters:
        offs - The offset info the document.
        Returns:
        The y-coordinate of the top of the offset, or -1 if this text area doesn't yet have a positive size or the line is hidden (i.e. from folding).
        Throws:
        BadLocationException - If offs isn't a valid offset into the document.