Class ACLTextAreaPainter

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, TabExpander

    public class ACLTextAreaPainter
    extends JComponent
    implements TabExpander
    The text area repaint manager. It performs double buffering and paints lines of text.The original file is written by Slava Pestov (www.gjt.org) and altered to fit ACL/SL.
    Author:
    Chris van Aart - Acklin B.V., the Netherlands & Slava Pestov
    See Also:
    Serialized Form
    • Field Detail

      • copyAreaBroken

        protected static boolean copyAreaBroken
      • caretColor

        protected Color caretColor
      • selectionColor

        protected Color selectionColor
      • lineHighlightColor

        protected Color lineHighlightColor
      • bracketHighlightColor

        protected Color bracketHighlightColor
      • eolMarkerColor

        protected Color eolMarkerColor
      • blockCaret

        protected boolean blockCaret
      • lineHighlight

        protected boolean lineHighlight
      • bracketHighlight

        protected boolean bracketHighlight
      • eolMarkers

        protected boolean eolMarkers
      • cols

        protected int cols
      • rows

        protected int rows
      • tabSize

        protected int tabSize
      • offImg

        protected Image offImg
      • firstInvalid

        protected int firstInvalid
      • lastInvalid

        protected int lastInvalid
    • Constructor Detail

      • ACLTextAreaPainter

        public ACLTextAreaPainter​(ACLTextArea textArea)
        Creates a new repaint manager. This should be not be called directly.
        Parameters:
        textArea - Description of Parameter
    • Method Detail

      • isManagingFocus

        public final boolean isManagingFocus()
        Returns if this component can be traversed by pressing the Tab key. This returns false.
        Overrides:
        isManagingFocus in class JComponent
        Returns:
        The ManagingFocus value
      • getStyles

        public final ACLSytntaxStyle[] getStyles()
        Returns the syntax styles used to paint colorized text. Entry n will be used to paint tokens with id = n .
        Returns:
        The Styles value
        See Also:
        org.gjt.sp.jedit.syntax.Token
      • getCaretColor

        public final Color getCaretColor()
        Returns the caret color.
        Returns:
        The CaretColor value
      • getSelectionColor

        public final Color getSelectionColor()
        Returns the selection color.
        Returns:
        The SelectionColor value
      • getLineHighlightColor

        public final Color getLineHighlightColor()
        Returns the line highlight color.
        Returns:
        The LineHighlightColor value
      • isLineHighlightEnabled

        public final boolean isLineHighlightEnabled()
        Returns true if line highlight is enabled, false otherwise.
        Returns:
        The LineHighlightEnabled value
      • getBracketHighlightColor

        public final Color getBracketHighlightColor()
        Returns the bracket highlight color.
        Returns:
        The BracketHighlightColor value
      • isBracketHighlightEnabled

        public final boolean isBracketHighlightEnabled()
        Returns true if bracket highlighting is enabled, false otherwise. When bracket highlighting is enabled, the bracket matching the one before the caret (if any) is highlighted.
        Returns:
        The BracketHighlightEnabled value
      • isBlockCaretEnabled

        public final boolean isBlockCaretEnabled()
        Returns true if the caret should be drawn as a block, false otherwise.
        Returns:
        The BlockCaretEnabled value
      • getEOLMarkerColor

        public final Color getEOLMarkerColor()
        Returns the EOL marker color.
        Returns:
        The EOLMarkerColor value
      • isEOLMarkerEnabled

        public final boolean isEOLMarkerEnabled()
        Returns true if EOL markers are drawn, false otherwise.
        Returns:
        The EOLMarkerEnabled value
      • setStyles

        public final void setStyles​(ACLSytntaxStyle[] styles)
        Sets the syntax styles used to paint colorized text. Entry n will be used to paint tokens with id = n .
        Parameters:
        styles - The syntax styles
        See Also:
        org.gjt.sp.jedit.syntax.Token
      • setCaretColor

        public final void setCaretColor​(Color caretColor)
        Sets the caret color.
        Parameters:
        caretColor - The caret color
      • setSelectionColor

        public final void setSelectionColor​(Color selectionColor)
        Sets the selection color.
        Parameters:
        selectionColor - The selection color
      • setLineHighlightColor

        public final void setLineHighlightColor​(Color lineHighlightColor)
        Sets the line highlight color.
        Parameters:
        lineHighlightColor - The line highlight color
      • setLineHighlightEnabled

        public final void setLineHighlightEnabled​(boolean lineHighlight)
        Enables or disables current line highlighting.
        Parameters:
        lineHighlight - True if current line highlight should be enabled, false otherwise
      • setBracketHighlightColor

        public final void setBracketHighlightColor​(Color bracketHighlightColor)
        Sets the bracket highlight color.
        Parameters:
        bracketHighlightColor - The bracket highlight color
      • setBracketHighlightEnabled

        public final void setBracketHighlightEnabled​(boolean bracketHighlight)
        Enables or disables bracket highlighting. When bracket highlighting is enabled, the bracket matching the one before the caret (if any) is highlighted.
        Parameters:
        bracketHighlight - True if bracket highlighting should be enabled, false otherwise
      • setBlockCaretEnabled

        public final void setBlockCaretEnabled​(boolean blockCaret)
        Sets if the caret should be drawn as a block, false otherwise.
        Parameters:
        blockCaret - True if the caret should be drawn as a block, false otherwise.
      • setEOLMarkerColor

        public final void setEOLMarkerColor​(Color eolMarkerColor)
        Sets the EOL marker color.
        Parameters:
        eolMarkerColor - The EOL marker color
      • setEOLMarkerEnabled

        public final void setEOLMarkerEnabled​(boolean eolMarkers)
        Sets if EOL markers are to be drawn.
        Parameters:
        eolMarkers - True if EOL markers should be dranw, false otherwise
      • fastRepaint

        public final void fastRepaint()
        Queues a repaint of the changed lines only.
      • invalidateLine

        public final void invalidateLine​(int line)
        Repaints the specified line. This is equivalent to calling _invalidateLine() and repaint().
        Parameters:
        line - The line
        See Also:
        _invalidateLine(int)
      • invalidateLineRange

        public final void invalidateLineRange​(int firstLine,
                                              int lastLine)
        Repaints the specified line range. This is equivalent to calling _invalidateLineRange() then repaint().
        Parameters:
        firstLine - The first line to repaint
        lastLine - The last line to repaint
      • invalidateSelectedLines

        public final void invalidateSelectedLines()
        Repaints the lines containing the selection.
      • invalidateOffscreen

        public final void invalidateOffscreen()
        Invalidates the offscreen graphics context. This should not be called directly.
      • getFontMetrics

        public FontMetrics getFontMetrics()
        Returns the font metrics used by this component.
        Returns:
        The FontMetrics value
      • isCopyAreaBroken

        public boolean isCopyAreaBroken()
        Returns if the copyArea() should not be used.
        Returns:
        The CopyAreaBroken value
      • getPreferredSize

        public Dimension getPreferredSize()
        Returns the painter's preferred size.
        Overrides:
        getPreferredSize in class JComponent
        Returns:
        The PreferredSize value
      • getMinimumSize

        public Dimension getMinimumSize()
        Returns the painter's minimum size.
        Overrides:
        getMinimumSize in class JComponent
        Returns:
        The MinimumSize value
      • setFont

        public void setFont​(Font font)
        Sets the font for this component. This is overridden to update the cached font metrics and to recalculate which lines are visible.
        Overrides:
        setFont in class JComponent
        Parameters:
        font - The font
      • setCopyAreaBroken

        public void setCopyAreaBroken​(boolean copyAreaBroken)
        Disables the use of the copyArea() function (which is broken in JDK 1.2).
        Parameters:
        copyAreaBroken - The new CopyAreaBroken value
      • update

        public void update​(Graphics g)
        Paints any lines that changed since the last paint to the offscreen graphics, then repaints the offscreen to the specified graphics context.
        Overrides:
        update in class JComponent
        Parameters:
        g - The graphics context
      • paint

        public void paint​(Graphics g)
        Same as update(g).
        Overrides:
        paint in class JComponent
        Parameters:
        g - Description of Parameter
      • _invalidateLine

        public void _invalidateLine​(int line)
        Marks a line as needing a repaint, but doesn't actually repaint it until repaint() is called manually.
        Parameters:
        line - The line to invalidate
      • _invalidateLineRange

        public void _invalidateLineRange​(int firstLine,
                                         int lastLine)
        Marks a range of lines as needing a repaint, but doesn't actually repaint them until repaint() is called.
        Parameters:
        firstLine - The first line to invalidate
        lastLine - The last line to invalidate
      • scrollRepaint

        public void scrollRepaint​(int oldFirstLine,
                                  int newFirstLine)
        Simulates scrolling from oldFirstLine to newFirstLine by shifting the offscreen graphics and repainting any revealed lines. This should not be called directly; use JEditTextArea.setFirstLine() instead.
        Parameters:
        oldFirstLine - The old first line
        newFirstLine - The new first line
        See Also:
        org.gjt.sp.jedit.textarea.JEditTextArea#setFirstLine(int)
      • nextTabStop

        public float nextTabStop​(float x,
                                 int tabOffset)
        Implementation of TabExpander interface. Returns next tab stop after a specified point.
        Specified by:
        nextTabStop in interface TabExpander
        Parameters:
        x - The x co-ordinate
        tabOffset - Ignored
        Returns:
        The next tab stop after x
      • ensureOffscreenValid

        protected boolean ensureOffscreenValid()
      • offscreenRepaintLineRange

        protected int offscreenRepaintLineRange​(int firstLine,
                                                int lastLine)
      • offscreenRepaintLine

        protected int offscreenRepaintLine​(int line,
                                           int x)
      • paintPlainLine

        protected void paintPlainLine​(int line,
                                      Font defaultFont,
                                      Color defaultColor,
                                      int x,
                                      int y)
      • paintSyntaxLine

        protected void paintSyntaxLine​(ACLSLTokenMarker tokenMarker,
                                       int line,
                                       Font defaultFont,
                                       Color defaultColor,
                                       int x,
                                       int y)
      • paintHighlight

        protected void paintHighlight​(int line,
                                      int y)
      • paintLineHighlight

        protected void paintLineHighlight​(int line,
                                          int y)
      • paintBracketHighlight

        protected void paintBracketHighlight​(int line,
                                             int y)
      • paintCaret

        protected void paintCaret​(int line,
                                  int y)