Package mars.venus.editor.jeditsyntax
Class TextAreaPainter
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
mars.venus.editor.jeditsyntax.TextAreaPainter
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,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:
-
Nested Class Summary
Nested ClassesNested 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
FieldsModifier and TypeFieldDescriptionprotected boolean
protected boolean
protected Color
protected Color
protected int
protected Color
protected boolean
protected FontMetrics
protected TextAreaPainter.Highlight
protected boolean
protected Color
protected boolean
protected int
protected Color
protected SyntaxStyle[]
protected int
protected int
protected JEditTextArea
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
ConstructorsConstructorDescriptionTextAreaPainter
(JEditTextArea textArea, TextAreaDefaults defaults) Creates a new repaint manager. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addCustomHighlight
(TextAreaPainter.Highlight highlight) Adds a custom highlight painter.final Color
Returns the bracket highlight color.final Color
Returns the caret color.final Color
Returns the EOL marker color.final boolean
Returns true if EOL markers are drawn, false otherwise.Returns the font metrics used by this component.boolean
Returns true if invalid lines are painted as red tildes (~), false otherwise.final Color
Returns the line highlight color.Returns the painter's minimum size.Returns the painter's preferred size.final Color
Returns the selection color.final SyntaxStyle[]
Returns the syntax styles used to paint colorized text.int
Fetch the tab size in characters.getToolTipText
(MouseEvent event) Returns the tool tip to display at the specified location.final void
invalidateLine
(int line) Marks a line as needing a repaint.final void
invalidateLineRange
(int firstLine, int lastLine) Marks a range of lines as needing a repaint.final void
Repaints the lines containing the selection.final boolean
Returns true if the caret should be drawn as a block, false otherwise.final boolean
Returns true if bracket highlighting is enabled, false otherwise.final boolean
Returns true if line highlight is enabled, false otherwise.float
nextTabStop
(float x, int tabOffset) Implementation of TabExpander interface.void
Repaints the text.protected void
paintBracketHighlight
(Graphics graphics, int line, float y) protected void
paintCaret
(Graphics graphics, int line, float y) protected void
paintHighlight
(Graphics graphics, int line, float y) protected void
paintLine
(Graphics graphics, TokenMarker tokenMarker, int line, float x) protected void
paintLineHighlight
(Graphics graphics, int line, float y) protected void
paintPlainLine
(Graphics graphics, int line, Font defaultFont, Color defaultColor, float x, float y) protected void
paintSyntaxLine
(Graphics graphics, TokenMarker tokenMarker, int line, Font defaultFont, Color defaultColor, float x, float y) final void
setBlockCaretEnabled
(boolean blockCaret) Sets if the caret should be drawn as a block, false otherwise.final void
setBracketHighlightColor
(Color bracketHighlightColor) Sets the bracket highlight color.final void
setBracketHighlightEnabled
(boolean bracketHighlight) Enables or disables bracket highlighting.final void
setCaretForeground
(Color caretForeground) Sets the caret color.final void
setEOLMarkerColor
(Color eolMarkerColor) Sets the EOL marker color.final void
setEOLMarkersPainted
(boolean eolMarkers) Sets if EOL markers are to be drawn.void
Sets the font for this component.void
setInvalidLinesPainted
(boolean paintInvalid) Sets if invalid lines are to be painted as red tildes.final void
setLineHighlightColor
(Color lineHighlightColor) Sets the line highlight color.final void
setLineHighlightEnabled
(boolean lineHighlight) Enables or disables current line highlighting.final void
setSelectionBackground
(Color selectionBackground) Sets the selection color.final void
setStyles
(SyntaxStyle[] styles) Sets the syntax styles used to paint colorized text.void
setTabSize
(int size) Set the tab size in characters.void
updateUI()
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, 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, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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
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, 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, getAccessibleContext, 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, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
textArea
-
styles
-
caretForeground
-
selectionBackground
-
lineHighlightColor
-
bracketHighlightColor
-
eolMarkerColor
-
blockCaret
protected boolean blockCaret -
lineHighlight
protected boolean lineHighlight -
bracketHighlight
protected boolean bracketHighlight -
paintInvalid
protected boolean paintInvalid -
eolMarkers
protected boolean eolMarkers -
cols
protected int cols -
rows
protected int rows -
tabSize
protected int tabSize -
tabSizeChars
protected int tabSizeChars -
fontMetrics
-
highlights
-
-
Constructor Details
-
TextAreaPainter
Creates a new repaint manager. This should be not be called directly.
-
-
Method Details
-
getTabSize
public int getTabSize()Fetch the tab size in characters. DPS 12-May-2010.- Returns:
- int tab size in characters
-
setTabSize
public void setTabSize(int size) Set the tab size in characters. DPS 12-May-2010. Originally it was fixed at PlainDocument property value (8).- Parameters:
size
- tab size in characters
-
getStyles
Returns the syntax styles used to paint colorized text. Entry n will be used to paint tokens with id = n.- See Also:
-
setStyles
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:
-
getCaretForeground
Returns the caret color. -
setCaretForeground
Sets the caret color.- Parameters:
caretForeground
- The caret color
-
getSelectionBackground
Returns the selection color. -
setSelectionBackground
Sets the selection color.- Parameters:
selectionBackground
- The selection color
-
getLineHighlightColor
Returns the line highlight color. -
setLineHighlightColor
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
Returns the bracket highlight color. -
setBracketHighlightColor
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
Returns the EOL marker color. -
setEOLMarkerColor
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
-
getInvalidLinesPainted
public boolean getInvalidLinesPainted()Returns true if invalid lines are painted as red tildes (~), false otherwise. -
setInvalidLinesPainted
public void setInvalidLinesPainted(boolean paintInvalid) Sets if invalid lines are to be painted as red tildes.- Parameters:
paintInvalid
- True if invalid lines should be drawn, false otherwise
-
addCustomHighlight
Adds a custom highlight painter.- Parameters:
highlight
- The highlight
-
getToolTipText
Returns the tool tip to display at the specified location.- Overrides:
getToolTipText
in classJComponent
- Parameters:
event
- The mouse event
-
getFontMetrics
Returns the font metrics used by this component. -
setFont
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 classJComponent
- Parameters:
font
- The font
-
paint
Repaints the text.- Overrides:
paint
in classJComponent
- Parameters:
graphics
- The graphics context
-
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 invalidatelastLine
- 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 interfaceTabExpander
- Parameters:
x
- The x coordinate.tabOffset
- Ignored.- Returns:
- The next tab stop after
x
.
-
getPreferredSize
Returns the painter's preferred size.- Overrides:
getPreferredSize
in classJComponent
-
getMinimumSize
Returns the painter's minimum size.- Overrides:
getMinimumSize
in classJComponent
-
paintLine
-
paintPlainLine
-
paintSyntaxLine
protected void paintSyntaxLine(Graphics graphics, TokenMarker tokenMarker, int line, Font defaultFont, Color defaultColor, float x, float y) -
paintHighlight
-
paintLineHighlight
-
paintBracketHighlight
-
paintCaret
-
updateUI
public void updateUI()- Overrides:
updateUI
in classJComponent
-