JIDE 3.5.15

com.jidesoft.editor
Class CodeEditorPainter

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.jidesoft.editor.CodeEditorPainter
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, TabExpander

public class CodeEditorPainter
extends JComponent
implements TabExpander

The text area repaint manager. It performs double buffering and paints lines of text.

Version:
$Id: TextAreaPainter.java,v 1.24 1999/12/13 03:40:30 sp Exp $
Author:
Slava Pestov
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 int _composedCaretX
           
 TextLayout _composedTextLayout
           
protected  CodeEditor _editor
           
protected  FontMetrics _fm
           
protected  Segment currentLine
           
protected  int currentLineIndex
           
protected  Token currentLineTokens
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
CodeEditorPainter(CodeEditor editor)
          Creates a new repaint manager.
 
Method Summary
protected  int getCaretHeight()
           
protected  int getCaretStartY(int visualLine)
           
 CodeEditor getCodeEditor()
           
 Font getFont()
           
 FontMetrics getFontMetrics()
          Returns the font metrics used by this component.
 int getLineHeight()
           
 String getToolTipText(MouseEvent event)
           
 void invalidateLine(int line)
          Marks a view line as needing a repaint.
 void invalidateLineRange(int firstLine, int lastLine)
          Marks a range of lines as needing a repaint.
 void invalidateRange(int startOffset, int endOffset)
           
 void invalidateSelectedLines()
          Repaints the lines containing the selection.
 boolean isManagingFocus()
          Returns if this component can be traversed by pressing the Tab key.
protected  boolean isSpanSelected(FoldingSpan span, int viewLine, int column, CaretPosition selectionStartVp, CaretPosition selectionEndVp)
          Check if the span is all selected.
 float nextTabStop(float x, int tabOffset)
          Implementation of TabExpander interface.
 int nextTabStop(int column)
           
 void paint(Graphics g)
          Repaints the text.
protected  void paintBracketHighlight(Graphics g, int line, int y)
           
protected  void paintCaret(Graphics g, int visualLine)
           
 void paintColumnGuides(Graphics g, Rectangle rect)
           
 int paintFoldedText(Graphics g, Font font, String text, int x, int y, FontMetrics fm)
           
protected  void paintHighlight(Graphics g, int line, int viewLine, CaretPosition selectionStartVp, CaretPosition selectionEndVp, int y)
           
protected  void paintImeInput(Graphics2D gfx, int screenLine, int physicalLine, int start, int end, int y)
           
protected  void paintLine(Graphics g, TokenMarker tokenMarker, int line, int viewLine, CaretPosition selectionStartVp, CaretPosition selectionEndVp, int x, int y, com.jidesoft.editor.FoldingState state)
           
protected  void paintLineHighlight(Graphics g, int line, int visualLine, CaretPosition selectionStartVp, CaretPosition selectionEndVp, int y)
           
protected  void paintLineSelection(Graphics g, int visualLine, CaretPosition selectionStartVp, CaretPosition selectionEndVp, int y)
           
protected  void paintPlainLine(Graphics g, int line, int visualLine, CaretPosition selectionStartVp, CaretPosition selectionEndVp, Font defaultFont, Color defaultColor, int x, int y)
           
protected  int paintSyntaxLine(Graphics g, TokenMarker tokenMarker, int line, int viewLine, int start, int end, CaretPosition selectionStartVp, CaretPosition selectionEndVp, Font defaultFont, Color defaultColor, int x, int y, boolean paintHighlight)
           
 void setFont(Font font)
          Sets the font for this component.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, 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, hide, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

currentLineIndex

protected int currentLineIndex

currentLineTokens

protected Token currentLineTokens

currentLine

protected Segment currentLine

_editor

protected CodeEditor _editor

_fm

protected FontMetrics _fm

_composedTextLayout

public TextLayout _composedTextLayout

_composedCaretX

public int _composedCaretX
Constructor Detail

CodeEditorPainter

public CodeEditorPainter(CodeEditor editor)
Creates a new repaint manager. This should be not be called directly.

Parameters:
editor - the code editor instance
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

getFontMetrics

public FontMetrics getFontMetrics()
Returns the font metrics used by this component.

Returns:
the font metrics

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

getToolTipText

public String getToolTipText(MouseEvent event)
Overrides:
getToolTipText in class JComponent

paint

public void paint(Graphics g)
Repaints the text.

Overrides:
paint in class JComponent
Parameters:
g - The graphics context

paintImeInput

protected void paintImeInput(Graphics2D gfx,
                             int screenLine,
                             int physicalLine,
                             int start,
                             int end,
                             int y)

invalidateLine

public final void invalidateLine(int line)
Marks a view line as needing a repaint.

Parameters:
line - the view line index to invalidate

invalidateRange

public final void invalidateRange(int startOffset,
                                  int endOffset)
Parameters:
startOffset - start offset
endOffset - end offset

invalidateLineRange

public final void invalidateLineRange(int firstLine,
                                      int lastLine)
Marks a range of lines as needing a repaint.

Parameters:
firstLine - The first view line index to invalidate
lastLine - The last view line index 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

nextTabStop

public int nextTabStop(int column)

getFont

public Font getFont()
Specified by:
getFont in interface MenuContainer
Overrides:
getFont in class Component

paintLine

protected void paintLine(Graphics g,
                         TokenMarker tokenMarker,
                         int line,
                         int viewLine,
                         CaretPosition selectionStartVp,
                         CaretPosition selectionEndVp,
                         int x,
                         int y,
                         com.jidesoft.editor.FoldingState state)

isSpanSelected

protected boolean isSpanSelected(FoldingSpan span,
                                 int viewLine,
                                 int column,
                                 CaretPosition selectionStartVp,
                                 CaretPosition selectionEndVp)
Check if the span is all selected.

Parameters:
span - the span
viewLine - the view line the span in
column - the view column the span start with
selectionStartVp - the view position of selection start
selectionEndVp - the view position of selection end
Returns:
true if the span is selected. Otherwise false.

paintPlainLine

protected void paintPlainLine(Graphics g,
                              int line,
                              int visualLine,
                              CaretPosition selectionStartVp,
                              CaretPosition selectionEndVp,
                              Font defaultFont,
                              Color defaultColor,
                              int x,
                              int y)

paintSyntaxLine

protected int paintSyntaxLine(Graphics g,
                              TokenMarker tokenMarker,
                              int line,
                              int viewLine,
                              int start,
                              int end,
                              CaretPosition selectionStartVp,
                              CaretPosition selectionEndVp,
                              Font defaultFont,
                              Color defaultColor,
                              int x,
                              int y,
                              boolean paintHighlight)

paintHighlight

protected void paintHighlight(Graphics g,
                              int line,
                              int viewLine,
                              CaretPosition selectionStartVp,
                              CaretPosition selectionEndVp,
                              int y)

paintLineHighlight

protected void paintLineHighlight(Graphics g,
                                  int line,
                                  int visualLine,
                                  CaretPosition selectionStartVp,
                                  CaretPosition selectionEndVp,
                                  int y)

paintLineSelection

protected void paintLineSelection(Graphics g,
                                  int visualLine,
                                  CaretPosition selectionStartVp,
                                  CaretPosition selectionEndVp,
                                  int y)

paintBracketHighlight

protected void paintBracketHighlight(Graphics g,
                                     int line,
                                     int y)

paintCaret

protected void paintCaret(Graphics g,
                          int visualLine)

getCaretStartY

protected int getCaretStartY(int visualLine)

getCaretHeight

protected int getCaretHeight()

getLineHeight

public int getLineHeight()

getCodeEditor

public CodeEditor getCodeEditor()

paintFoldedText

public int paintFoldedText(Graphics g,
                           Font font,
                           String text,
                           int x,
                           int y,
                           FontMetrics fm)

paintColumnGuides

public void paintColumnGuides(Graphics g,
                              Rectangle rect)

JIDE 3.5.15