processing.app.syntax

## Class TextAreaPainter

- Object
- - Component
  - - Container
    - - JComponent
      - - TextAreaPainter

- All Implemented Interfaces:
    ImageObserver, MenuContainer, Printable, Serializable, TabExpander

      public class TextAreaPainter
      extends JComponent
      implements TabExpander, Printable

  The text area repaint manager. It performs double buffering and paints lines of text.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `TextAreaPainter.Highlight` Highlight interface.

    - ### Nested classes/interfaces inherited from class JComponent

      `JComponent.AccessibleJComponent`

    - ### Nested classes/interfaces inherited from class Component

      `Component.BaselineResizeBehavior`

  - ### Field Summary

    - ### Fields inherited from class JComponent

      `TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

    - ### Fields inherited from class Component

      `BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT`

    - ### Fields inherited from interface Printable

      `NO_SUCH_PAGE, PAGE_EXISTS`

    - ### Fields inherited from interface ImageObserver

      `ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TextAreaPainter(JEditTextArea textArea, TextAreaDefaults defaults)` Creates a new repaint manager.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addCustomHighlight(TextAreaPainter.Highlight highlight)` Adds a custom highlight painter.
    `Color` | `getBracketHighlightColor()` Returns the bracket highlight color.
    `Color` | `getCaretColor()` Returns the caret color.
    `CompositionTextPainter` | `getCompositionTextpainter()` Get CompositionTextPainter.
    `Segment` | `getCurrentLine()` Accessor used by tools that want to hook in and grab the formatting.
    `int` | `getCurrentLineIndex()` Accessor used by tools that want to hook in and grab the formatting.
    `Token` | `getCurrentLineTokens()` Accessor used by tools that want to hook in and grab the formatting.
    `Color` | `getEOLMarkerColor()` Returns the EOL marker color.
    `boolean` | `getEOLMarkersPainted()` Returns true if EOL markers are drawn, false otherwise.
    `FontMetrics` | `getFontMetrics()` Returns the font metrics used by this component.
    `Color` | `getLineHighlightColor()` Returns the line highlight color.
    `Dimension` | `getMinimumSize()` Returns the painter's minimum size.
    `Dimension` | `getPreferredSize()` Returns the painter's preferred size.
    `Color` | `getSelectionColor()` Returns the selection color.
    `SyntaxStyle[]` | `getStyles()` Returns the syntax styles used to paint colorized text.
    `String` | `getToolTipText(MouseEvent evt)` Returns the tool tip to display at the specified location.
    `void` | `invalidateLine(int line)` Marks a line as needing a repaint.
    `void` | `invalidateLineRange(int firstLine, int lastLine)` Marks a range of lines as needing a repaint.
    `void` | `invalidateSelectedLines()` Repaints the lines containing the selection.
    `boolean` | `isBlockCaretEnabled()` Returns true if the caret should be drawn as a block, false otherwise.
    `boolean` | `isBracketHighlightEnabled()` Returns true if bracket highlighting is enabled, false otherwise.
    `boolean` | `isLineHighlightEnabled()` Returns true if line highlight is enabled, false otherwise.
    `float` | `nextTabStop(float x, int tabOffset)` Implementation of TabExpander interface.
    `void` | `paint(Graphics gfx)` Repaints the text.
    `int` | `print(Graphics g, PageFormat pageFormat, int pageIndex)`
    `void` | `setAntialias(boolean antialias)`
    `void` | `setBlockCaretEnabled(boolean blockCaret)` Sets if the caret should be drawn as a block, false otherwise.
    `void` | `setBracketHighlightColor(Color bracketHighlightColor)` Sets the bracket highlight color.
    `void` | `setBracketHighlightEnabled(boolean bracketHighlight)` Enables or disables bracket highlighting.
    `void` | `setCaretColor(Color caretColor)` Sets the caret color.
    `void` | `setCurrentLineIndex(int what)` Accessor used by tools that want to hook in and grab the formatting.
    `void` | `setCurrentLineTokens(Token tokens)` Accessor used by tools that want to hook in and grab the formatting.
    `void` | `setDefaults(TextAreaDefaults defaults)`
    `void` | `setEOLMarkerColor(Color eolMarkerColor)` Sets the EOL marker color.
    `void` | `setEOLMarkersPainted(boolean eolMarkers)` Sets if EOL markers are to be drawn.
    `void` | `setFont(Font font)` Sets the font for this component.
    `void` | `setLineHighlightColor(Color lineHighlightColor)` Sets the line highlight color.
    `void` | `setLineHighlightEnabled(boolean lineHighlight)` Enables or disables current line highlighting.
    `void` | `setSelectionColor(Color selectionColor)` Sets the selection color.
    `void` | `setStyles(SyntaxStyle[] styles)` Sets the syntax styles used to paint colorized text.

    - ### Methods inherited from class JComponent

      `addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI`

    - ### Methods inherited from class Container

      `add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate`

    - ### Methods inherited from class Component

      `action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

    - ### Methods inherited from class Object

      `equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### TextAreaPainter

          public TextAreaPainter(JEditTextArea textArea,
                         TextAreaDefaults defaults)

      Creates a new repaint manager. This should be not be called directly.

  - ### Method Detail

    - #### setDefaults

          public void setDefaults(TextAreaDefaults defaults)

    - #### getCompositionTextpainter

          public CompositionTextPainter getCompositionTextpainter()

      Get CompositionTextPainter. if CompositionTextPainter is not created, create it.

    - #### getStyles

          public final SyntaxStyle[] getStyles()

      Returns the syntax styles used to paint colorized text. Entry n will be used to paint tokens with id = n.
      See Also:
        `Token`

    - #### setStyles

          public final void setStyles(SyntaxStyle[] 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:
        `Token`

    - #### getCaretColor

          public final Color getCaretColor()

      Returns the caret color.

    - #### setCaretColor

          public final void setCaretColor(Color caretColor)

      Sets the caret color.
      Parameters:
        `caretColor` - The caret color

    - #### getSelectionColor

          public final Color getSelectionColor()

      Returns the selection color.

    - #### setSelectionColor

          public final void setSelectionColor(Color selectionColor)

      Sets the selection color.
      Parameters:
        `selectionColor` - The selection color

    - #### getLineHighlightColor

          public final Color getLineHighlightColor()

      Returns the line highlight color.

    - #### setLineHighlightColor

          public final void setLineHighlightColor(Color lineHighlightColor)

      Sets the line highlight color.
      Parameters:
        `lineHighlightColor` - The line highlight color

    - #### isLineHighlightEnabled

          public final boolean isLineHighlightEnabled()

      Returns true if line highlight is enabled, false otherwise.

    - #### 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

    - #### getBracketHighlightColor

          public final Color getBracketHighlightColor()

      Returns the bracket highlight color.

    - #### setBracketHighlightColor

          public final void setBracketHighlightColor(Color bracketHighlightColor)

      Sets the bracket highlight color.
      Parameters:
        `bracketHighlightColor` - The bracket highlight color

    - #### 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.

    - #### 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

    - #### isBlockCaretEnabled

          public final boolean isBlockCaretEnabled()

      Returns true if the caret should be drawn as a block, 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.

    - #### getEOLMarkerColor

          public final Color getEOLMarkerColor()

      Returns the EOL marker color.

    - #### setEOLMarkerColor

          public final void setEOLMarkerColor(Color eolMarkerColor)

      Sets the EOL marker color.
      Parameters:
        `eolMarkerColor` - The EOL marker color

    - #### getEOLMarkersPainted

          public final boolean getEOLMarkersPainted()

      Returns true if EOL markers are drawn, false otherwise.

    - #### setEOLMarkersPainted

          public final void setEOLMarkersPainted(boolean eolMarkers)

      Sets if EOL markers are to be drawn.
      Parameters:
        `eolMarkers` - True if EOL markers should be drawn, false otherwise

    - #### setAntialias

          public final void setAntialias(boolean antialias)

    - #### addCustomHighlight

          public void addCustomHighlight(TextAreaPainter.Highlight highlight)

      Adds a custom highlight painter.
      Parameters:
        `highlight` - The highlight

    - #### getToolTipText

          public String getToolTipText(MouseEvent evt)

      Returns the tool tip to display at the specified location.
      Overrides:
        `getToolTipText` in class `JComponent`
      Parameters:
        `evt` - The mouse event

    - #### getFontMetrics

          public FontMetrics getFontMetrics()

      Returns the font metrics used by this component.

    - #### 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

    - #### paint

          public void paint(Graphics gfx)

      Repaints the text.
      Overrides:
        `paint` in class `JComponent`
      Parameters:
        `gfx` - The graphics context

    - #### print

          public int print(Graphics g,
                  PageFormat pageFormat,
                  int pageIndex)

      Specified by:
        `print` in interface `Printable`

    - #### invalidateLine

          public final void invalidateLine(int line)

      Marks a line as needing a repaint.
      Parameters:
        `line` - The line to invalidate

    - #### invalidateLineRange

          public final void invalidateLineRange(int firstLine,
                                 int lastLine)

      Marks a range of lines as needing a repaint.
      Parameters:
        `firstLine` - The first line to invalidate
        `lastLine` - The last line to invalidate

    - #### invalidateSelectedLines

          public final void invalidateSelectedLines()

      Repaints the lines containing the selection.

    - #### 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

    - #### getPreferredSize

          public Dimension getPreferredSize()

      Returns the painter's preferred size.
      Overrides:
        `getPreferredSize` in class `JComponent`

    - #### getMinimumSize

          public Dimension getMinimumSize()

      Returns the painter's minimum size.
      Overrides:
        `getMinimumSize` in class `JComponent`

    - #### getCurrentLineIndex

          public int getCurrentLineIndex()

      Accessor used by tools that want to hook in and grab the formatting.

    - #### setCurrentLineIndex

          public void setCurrentLineIndex(int what)

      Accessor used by tools that want to hook in and grab the formatting.

    - #### getCurrentLineTokens

          public Token getCurrentLineTokens()

      Accessor used by tools that want to hook in and grab the formatting.

    - #### setCurrentLineTokens

          public void setCurrentLineTokens(Token tokens)

      Accessor used by tools that want to hook in and grab the formatting.

    - #### getCurrentLine

          public Segment getCurrentLine()

      Accessor used by tools that want to hook in and grab the formatting.