java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.gjt.sp.jedit.textarea.TextAreaPainter
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,TabExpander
The text area painter is the component responsible for displaying the
text of the current buffer. The only methods in this class that should
be called by plugins are those for adding and removing
text area extensions.
- Version:
- $Id: TextAreaPainter.java 25251 2020-04-15 22:07:47Z kpouer $
- Author:
- Slava Pestov
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBelow selection layer.static final intBelow most extensions layer.static final intBelow selection layer.static final intBlock caret layer.static final intBracket highlight layer.static final intCaret layer.static final intDefault extension layer.static final intHighest possible layer.static final intThe line highlight and collapsed fold highlight layer.static final intThe lowest possible layer.static final intSelection layer.static final intText layer.static final intWrap guide layer.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_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExtension(int layer, TextAreaExtension extension) Adds a text area extension, which can perform custom painting and tool tip handling.voidaddExtension(TextAreaExtension extension) Adds a text area extension, which can perform custom painting and tool tip handling.voidfinal ColorReturns the caret color.final ColorReturns the EOL marker color.final booleanReturns true if EOL markers are drawn, false otherwise.Returns an array of registered text area extensions.booleanMakes the tab key work in Java 1.4.final SyntaxStyle[]Returns the fold line style.intReturns the font height as given by the font metrics.Returns the font metrics used by this component.Returns the font render context.intReturns the number of pixels from the start of the line to the start of text (the extra line spacing).intReturns the line height as given by the font metrics plus the added line spacing.final ColorReturns the line highlight color.Returns the painter's minimum size.final ColorReturns the multiple selection color.Returns the painter's preferred size.Returns the rendering hints used by the Graphics2D class; in this case, for anti-aliasing of text.final ColorReturns the selection color.final ColorReturns the selection foreground color, if one is set.floatgetStringWidth(String str) Returns the width of the given string, in pixels, using the text area's current font.final ColorReturns the structure highlight color.final SyntaxStyle[]Returns the syntax styles used to paint colorized text.getToolTipText(MouseEvent evt) Returns the tool tip to display at the specified location.final ColorReturns the wrap guide color.final booleanReturns true if the caret should be drawn as a block, false otherwise.booleanReturns if fractional font metrics are enabled.final booleanReturns true if line highlight is enabled, false otherwise.final booleanReturns true if selection foreground color is enabled - i.e. a specific color is used for the selection foreground instead of the syntax highlight color.final booleanReturns true if structure highlighting is enabled, false otherwise.final booleanReturns true if the caret should be drawn with a thick line, false otherwise.final booleanReturns true if the wrap guide is drawn, false otherwise.floatnextTabStop(float x, int tabOffset) Implementation of TabExpander interface.voidRepaints the text.voidremoveExtension(TextAreaExtension extension) Removes a text area extension.voidReset the cursor to it's default value.voidsetAntiAlias(AntiAlias newValue) As of jEdit 4.3, subpixel antialias mode is supported.final voidsetBlockCaretEnabled(boolean blockCaret) Sets if the caret should be drawn as a block, false otherwise.voidsetBounds(int x, int y, int width, int height) It is a bad idea to override this, but we need to get the component event before the first repaint.final voidsetCaretColor(Color caretColor) Sets the caret color.voidChange the mouse cursor.voidsetEOLMarkerChar(String emc) final voidsetEOLMarkerColor(Color eolMarkerColor) Sets the EOL marker color.final voidsetEOLMarkersPainted(boolean eolMarkers) Sets if EOL markers are to be drawn.final voidsetFoldLineStyle(SyntaxStyle[] foldLineStyle) Sets the fold line style.voidSets the font for this component.voidsetFractionalFontMetricsEnabled(boolean fracFontMetrics) Sets if fractional font metrics should be enabled.voidsetLineExtraSpacing(int spacing) Sets extra spacing between lines in pixels.final voidsetLineHighlightColor(Color lineHighlightColor) Sets the line highlight color.final voidsetLineHighlightEnabled(boolean lineHighlight) Enables or disables current line highlighting.final voidsetMultipleSelectionColor(Color multipleSelectionColor) Sets the multiple selection color.final voidsetSelectionColor(Color selectionColor) Sets the selection color.final voidsetSelectionFgColor(Color selectionFgColor) Sets the selection foreground color.final voidsetSelectionFgColorEnabled(boolean selectionFg) Enables or disables selection foreground color.final voidsetStructureHighlightColor(Color structureHighlightColor) Sets the structure highlight color.final voidsetStructureHighlightEnabled(boolean structureHighlight) Enables or disables structure highlighting.final voidsetStyles(SyntaxStyle[] styles) Sets the syntax styles used to paint colorized text.final voidsetThickCaretEnabled(boolean thickCaret) Sets if the caret should be drawn with a thick line.final voidsetWrapGuideColor(Color wrapGuideColor) Sets the wrap guide color.final voidsetWrapGuidePainted(boolean wrapGuide) Sets if the wrap guide is to be drawn.voidRepaints the text.Methods inherited from class javax.swing.JComponent
addAncestorListener, 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, updateUIMethods 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, validateTreeMethods 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, 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, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
LOWEST_LAYER
public static final int LOWEST_LAYERThe lowest possible layer.- Since:
- jEdit 4.0pre4
- See Also:
-
BACKGROUND_LAYER
public static final int BACKGROUND_LAYERBelow selection layer. The JDiff plugin will use this.- Since:
- jEdit 4.0pre4
- See Also:
-
LINE_BACKGROUND_LAYER
public static final int LINE_BACKGROUND_LAYERThe line highlight and collapsed fold highlight layer.- Since:
- jEdit 4.0pre7
- See Also:
-
BELOW_SELECTION_LAYER
public static final int BELOW_SELECTION_LAYERBelow selection layer.- Since:
- jEdit 4.0pre4
- See Also:
-
SELECTION_LAYER
public static final int SELECTION_LAYERSelection layer. Most extensions will be above this layer, but some (eg, JDiff) will want to be below the selection.- Since:
- jEdit 4.0pre4
- See Also:
-
WRAP_GUIDE_LAYER
public static final int WRAP_GUIDE_LAYERWrap guide layer. Most extensions will be above this layer.- Since:
- jEdit 4.0pre4
- See Also:
-
BELOW_MOST_EXTENSIONS_LAYER
public static final int BELOW_MOST_EXTENSIONS_LAYERBelow most extensions layer.- Since:
- jEdit 4.0pre4
- See Also:
-
DEFAULT_LAYER
public static final int DEFAULT_LAYERDefault extension layer. This is above the wrap guide but below the structure highlight.- Since:
- jEdit 4.0pre4
- See Also:
-
BLOCK_CARET_LAYER
public static final int BLOCK_CARET_LAYERBlock caret layer. Most extensions will be below this layer.- Since:
- jEdit 4.2pre1
- See Also:
-
BRACKET_HIGHLIGHT_LAYER
public static final int BRACKET_HIGHLIGHT_LAYERBracket highlight layer. Most extensions will be below this layer.- Since:
- jEdit 4.0pre4
- See Also:
-
TEXT_LAYER
public static final int TEXT_LAYERText layer. Most extensions will be below this layer.- Since:
- jEdit 4.2pre1
- See Also:
-
CARET_LAYER
public static final int CARET_LAYERCaret layer. Most extensions will be below this layer.- Since:
- jEdit 4.2pre1
- See Also:
-
HIGHEST_LAYER
public static final int HIGHEST_LAYERHighest possible layer.- Since:
- jEdit 4.0pre4
- See Also:
-
-
Method Details
-
setBounds
public void setBounds(int x, int y, int width, int height) It is a bad idea to override this, but we need to get the component event before the first repaint. -
addNotify
public void addNotify()- Overrides:
addNotifyin classJComponent
-
setCursor
Change the mouse cursor. If the cursor is hiddenCursor or TEXT_CURSOR, it is the default cursor and the cursor will not disappear anymore while typing untilresetCursor()is called. -
resetCursor
public void resetCursor()Reset the cursor to it's default value.- Since:
- jEdit 4.4pre1
-
getFocusTraversalKeysEnabled
public boolean getFocusTraversalKeysEnabled()Makes the tab key work in Java 1.4.- Overrides:
getFocusTraversalKeysEnabledin classComponent- Since:
- jEdit 3.2pre4
-
getStyles
Returns the syntax styles used to paint colorized text. Entry n will be used to paint tokens with id = n.- Returns:
- an array of SyntaxStyles
- 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:
-
getCaretColor
Returns the caret color. -
setCaretColor
Sets the caret color.- Parameters:
caretColor- The caret color
-
getSelectionColor
Returns the selection color. -
setSelectionColor
Sets the selection color.- Parameters:
selectionColor- The selection color
-
getMultipleSelectionColor
Returns the multiple selection color.- Since:
- jEdit 4.2pre1
-
setMultipleSelectionColor
Sets the multiple selection color.- Parameters:
multipleSelectionColor- The multiple selection color- Since:
- jEdit 4.2pre1
-
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
-
getSelectionFgColor
Returns the selection foreground color, if one is set.- Since:
- jEdit 4.4.1
-
setSelectionFgColor
Sets the selection foreground color.- Parameters:
selectionFgColor- The selection foreground color- Since:
- jEdit 4.4.1
-
isSelectionFgColorEnabled
public final boolean isSelectionFgColorEnabled()Returns true if selection foreground color is enabled - i.e. a specific color is used for the selection foreground instead of the syntax highlight color.- Since:
- jEdit 4.4.1
-
setSelectionFgColorEnabled
public final void setSelectionFgColorEnabled(boolean selectionFg) Enables or disables selection foreground color.- Parameters:
selectionFg- True if selection foreground should be enabled, false otherwise- Since:
- jEdit 4.4.1
-
getStructureHighlightColor
Returns the structure highlight color.- Since:
- jEdit 4.2pre3
-
setStructureHighlightColor
Sets the structure highlight color.- Parameters:
structureHighlightColor- The bracket highlight color- Since:
- jEdit 4.2pre3
-
isStructureHighlightEnabled
public final boolean isStructureHighlightEnabled()Returns true if structure highlighting is enabled, false otherwise.- Since:
- jEdit 4.2pre3
-
setStructureHighlightEnabled
public final void setStructureHighlightEnabled(boolean structureHighlight) Enables or disables structure highlighting.- Parameters:
structureHighlight- True if structure highlighting should be enabled, false otherwise- Since:
- jEdit 4.2pre3
-
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.
-
isThickCaretEnabled
public final boolean isThickCaretEnabled()Returns true if the caret should be drawn with a thick line, false otherwise.- Since:
- jEdit 4.3pre15
-
setThickCaretEnabled
public final void setThickCaretEnabled(boolean thickCaret) Sets if the caret should be drawn with a thick line.- Parameters:
thickCaret- True if the caret should be drawn as a block, false otherwise.- Since:
- jEdit 4.3pre15
-
getEOLMarkerChar
-
setEOLMarkerChar
-
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
-
getWrapGuideColor
Returns the wrap guide color. -
setWrapGuideColor
Sets the wrap guide color.- Parameters:
wrapGuideColor- The wrap guide color
-
isWrapGuidePainted
public final boolean isWrapGuidePainted()Returns true if the wrap guide is drawn, false otherwise.- Since:
- jEdit 4.0pre4
-
setWrapGuidePainted
public final void setWrapGuidePainted(boolean wrapGuide) Sets if the wrap guide is to be drawn.- Parameters:
wrapGuide- True if the wrap guide should be drawn, false otherwise
-
getFoldLineStyle
Returns the fold line style. The first element is the style for lines with a fold level greater than 3. The remaining elements are for fold levels 1 to 3. -
setFoldLineStyle
Sets the fold line style. The first element is the style for lines with a fold level greater than 3. The remaining elements are for fold levels 1 to 3.- Parameters:
foldLineStyle- The fold line style
-
setAntiAlias
As of jEdit 4.3, subpixel antialias mode is supported.- Since:
- jEdit 4.2pre4
-
getAntiAlias
- Returns:
- the AntiAlias value that is currently used for TextAreas.
- Since:
- jedit 4.3pre4
-
setFractionalFontMetricsEnabled
public void setFractionalFontMetricsEnabled(boolean fracFontMetrics) Sets if fractional font metrics should be enabled. Has no effect when running on Java 1.1.- Since:
- jEdit 3.2pre6
-
isFractionalFontMetricsEnabled
public boolean isFractionalFontMetricsEnabled()Returns if fractional font metrics are enabled.- Since:
- jEdit 3.2pre6
-
getFontRenderContext
Returns the font render context.- Since:
- jEdit 4.0pre4
-
addExtension
Adds a text area extension, which can perform custom painting and tool tip handling.- Parameters:
extension- The extension- Since:
- jEdit 4.0pre4
-
addExtension
Adds a text area extension, which can perform custom painting and tool tip handling.- Parameters:
layer- The layer to add the extension to. Note that more than extension can share the same layer.extension- The extension- Since:
- jEdit 4.0pre4
-
removeExtension
Removes a text area extension. It will no longer be asked to perform custom painting and tool tip handling.- Parameters:
extension- The extension- Since:
- jEdit 4.0pre4
-
getExtensions
Returns an array of registered text area extensions. Useful for debugging purposes.- Since:
- jEdit 4.1pre5
-
getToolTipText
Returns the tool tip to display at the specified location.- Overrides:
getToolTipTextin classJComponent- Parameters:
evt- The mouse event
-
getFontMetrics
Returns the font metrics used by this component. -
getLineHeight
public int getLineHeight()Returns the line height as given by the font metrics plus the added line spacing. -
getFontHeight
public int getFontHeight()Returns the font height as given by the font metrics. -
getLineExtraSpacing
public int getLineExtraSpacing()Returns the number of pixels from the start of the line to the start of text (the extra line spacing). -
setLineExtraSpacing
public void setLineExtraSpacing(int spacing) Sets extra spacing between lines in pixels. -
setFont
Sets the font for this component. This is overridden to update the cached font metrics and to recalculate which lines are visible.- Overrides:
setFontin classJComponent- Parameters:
font- The font
-
getStringWidth
Returns the width of the given string, in pixels, using the text area's current font.- Since:
- jEdit 4.2final
-
getRenderingHints
Returns the rendering hints used by the Graphics2D class; in this case, for anti-aliasing of text.- Since:
- jEdit 4.5pre1
-
update
Repaints the text.- Overrides:
updatein classJComponent- Parameters:
_gfx- The graphics context
-
paint
Repaints the text.- Overrides:
paintin classJComponent- Parameters:
_gfx- The graphics context
-
nextTabStop
public float nextTabStop(float x, int tabOffset) Implementation of TabExpander interface. Returns next tab stop after a specified point.- Specified by:
nextTabStopin interfaceTabExpander- Parameters:
x- The x co-ordinatetabOffset- Ignored- Returns:
- The next tab stop after x
-
getPreferredSize
Returns the painter's preferred size.- Overrides:
getPreferredSizein classJComponent
-
getMinimumSize
Returns the painter's minimum size.- Overrides:
getMinimumSizein classJComponent
-