public class CodeEditorPainter
extends javax.swing.JComponent
implements javax.swing.text.TabExpander
Modifier and Type | Class and Description |
---|---|
static interface |
CodeEditorPainter.Highlight
Highlight interface.
|
javax.swing.JComponent.AccessibleJComponent
Modifier and Type | Field and Description |
---|---|
protected boolean |
blockCaret |
protected boolean |
bracketHighlight |
protected java.awt.Color |
bracketHighlightColor |
protected java.awt.Color |
caretColor |
protected int |
cols |
protected java.awt.Color |
eolMarkerColor |
protected boolean |
eolMarkers |
protected java.awt.FontMetrics |
fm |
protected CodeEditorHighlighter |
highlighter |
protected CodeEditorPainter.Highlight |
highlights |
protected boolean |
lineHighlight |
protected java.awt.Color |
lineHighlightColor |
protected boolean |
paintInvalid |
protected int |
rows |
protected java.awt.Color |
selectionColor |
protected SyntaxStyle[] |
styles |
protected int |
tabSize |
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Constructor and Description |
---|
CodeEditorPainter(JEditor editor,
CodeEditorDefaults defaults)
Creates a new repaint manager.
|
Modifier and Type | Method and Description |
---|---|
void |
addCustomHighlight(CodeEditorPainter.Highlight highlight)
Adds a custom highlight painter.
|
java.awt.Color |
getBracketHighlightColor()
Returns the bracket highlight color.
|
java.awt.Color |
getCaretColor()
Returns the caret color.
|
JEditor |
getEditor()
Return the JEditor.
|
java.awt.Color |
getEOLMarkerColor()
Returns the EOL marker color.
|
boolean |
getEOLMarkersPainted()
Returns true if EOL markers are drawn, false otherwise.
|
java.awt.FontMetrics |
getFontMetrics()
Returns the font metrics used by this component.
|
boolean |
getInvalidLinesPainted()
Returns true if invalid lines are painted as red tildes (~), false otherwise.
|
java.awt.Color |
getLineHighlightColor()
Returns the line highlight color.
|
int |
getMaxWidth()
Return the maximum line width.
|
java.awt.Dimension |
getMinimumSize()
Returns the painter's minimum size.
|
java.awt.Dimension |
getPreferredSize()
Returns the painter preferred size.
|
java.awt.Color |
getSelectionColor()
Returns the selection color.
|
SyntaxStyle[] |
getStyles()
Returns the syntax styles used to paint colorized text.
|
int |
getTabSize() |
java.lang.String |
getToolTipText(java.awt.event.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(java.awt.Graphics gfx)
Repaints the text.
|
protected void |
paintBracketHighlight(java.awt.Graphics gfx,
int line,
int y) |
protected void |
paintCaret(java.awt.Graphics gfx,
int line,
int y) |
protected void |
paintForceHighlight(java.awt.Graphics gfx,
int line,
int y,
CodeEditorHighlighter.Highlight highlight) |
protected void |
paintHighlight(java.awt.Graphics gfx,
int line,
int y) |
protected int |
paintLine(java.awt.Graphics gfx,
TokenMarker tokenMarker,
int line,
int x) |
protected void |
paintLineHighlight(java.awt.Graphics gfx,
int line,
int y) |
protected int |
paintPlainLine(java.awt.Graphics gfx,
int line,
java.awt.Font defaultFont,
java.awt.Color defaultColor,
int x,
int y) |
protected int |
paintSyntaxLine(java.awt.Graphics gfx,
TokenMarker tokenMarker,
int line,
java.awt.Font defaultFont,
java.awt.Color defaultColor,
int x,
int y) |
void |
removeHighlighter()
Remove the highlighter.
|
void |
setBlockCaretEnabled(boolean blockCaret)
Sets if the caret should be drawn as a block, false otherwise.
|
void |
setBracketHighlightColor(java.awt.Color bracketHighlightColor)
Sets the bracket highlight color.
|
void |
setBracketHighlightEnabled(boolean bracketHighlight)
Enables or disables bracket highlighting.
|
void |
setCaretColor(java.awt.Color caretColor)
Sets the caret color.
|
void |
setDefaults(CodeEditorDefaults defaults) |
void |
setEOLMarkerColor(java.awt.Color eolMarkerColor)
Sets the EOL marker color.
|
void |
setEOLMarkersPainted(boolean eolMarkers)
Sets if EOL markers are to be drawn.
|
void |
setFont(java.awt.Font font)
Sets the font for this component.
|
void |
setHighlighter(CodeEditorHighlighter highlighter)
Set the highlighter.
|
void |
setInvalidLinesPainted(boolean paintInvalid)
Sets if invalid lines are to be painted as red tildes.
|
void |
setLineHighlightColor(java.awt.Color lineHighlightColor)
Sets the line highlight color.
|
void |
setLineHighlightEnabled(boolean lineHighlight)
Enables or disables current line highlighting.
|
void |
setSelectionColor(java.awt.Color selectionColor)
Sets the selection color.
|
void |
setStyles(SyntaxStyle[] styles)
Sets the syntax styles used to paint colorized text.
|
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, 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, updateUI
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
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, 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, 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, transferFocusBackward, transferFocusUpCycle
protected SyntaxStyle[] styles
protected java.awt.Color caretColor
protected java.awt.Color selectionColor
protected java.awt.Color lineHighlightColor
protected java.awt.Color bracketHighlightColor
protected java.awt.Color eolMarkerColor
protected boolean blockCaret
protected boolean lineHighlight
protected boolean bracketHighlight
protected boolean paintInvalid
protected boolean eolMarkers
protected int cols
protected int rows
protected int tabSize
protected java.awt.FontMetrics fm
protected CodeEditorPainter.Highlight highlights
protected CodeEditorHighlighter highlighter
public CodeEditorPainter(JEditor editor, CodeEditorDefaults defaults)
editor
- the JEditordefaults
- the defaultspublic void setDefaults(CodeEditorDefaults defaults)
public JEditor getEditor()
public int getTabSize()
public void setHighlighter(CodeEditorHighlighter highlighter)
highlighter
- the highlighterpublic void removeHighlighter()
public final SyntaxStyle[] getStyles()
public final void setStyles(SyntaxStyle[] styles)
styles
- The syntax stylespublic final java.awt.Color getCaretColor()
public final void setCaretColor(java.awt.Color caretColor)
caretColor
- The caret colorpublic final java.awt.Color getSelectionColor()
public final void setSelectionColor(java.awt.Color selectionColor)
selectionColor
- The selection colorpublic final java.awt.Color getLineHighlightColor()
public final void setLineHighlightColor(java.awt.Color lineHighlightColor)
lineHighlightColor
- The line highlight colorpublic final boolean isLineHighlightEnabled()
public final void setLineHighlightEnabled(boolean lineHighlight)
lineHighlight
- True if current line highlight should be enabled, false otherwisepublic final java.awt.Color getBracketHighlightColor()
public final void setBracketHighlightColor(java.awt.Color bracketHighlightColor)
bracketHighlightColor
- The bracket highlight colorpublic final boolean isBracketHighlightEnabled()
public final void setBracketHighlightEnabled(boolean bracketHighlight)
bracketHighlight
- True if bracket highlighting should be
enabled, false otherwisepublic final boolean isBlockCaretEnabled()
public final void setBlockCaretEnabled(boolean blockCaret)
blockCaret
- True if the caret should be drawn as a block, false otherwise.public final java.awt.Color getEOLMarkerColor()
public final void setEOLMarkerColor(java.awt.Color eolMarkerColor)
eolMarkerColor
- The EOL marker colorpublic final boolean getEOLMarkersPainted()
public final void setEOLMarkersPainted(boolean eolMarkers)
eolMarkers
- True if EOL markers should be drawn, false otherwisepublic boolean getInvalidLinesPainted()
public void setInvalidLinesPainted(boolean paintInvalid)
paintInvalid
- True if invalid lines should be drawn, false otherwisepublic void addCustomHighlight(CodeEditorPainter.Highlight highlight)
highlight
- The highlightpublic java.lang.String getToolTipText(java.awt.event.MouseEvent evt)
getToolTipText
in class javax.swing.JComponent
evt
- The mouse eventpublic java.awt.FontMetrics getFontMetrics()
public void setFont(java.awt.Font font)
setFont
in class javax.swing.JComponent
font
- The fontpublic void paint(java.awt.Graphics gfx)
paint
in class javax.swing.JComponent
gfx
- The graphics contextpublic final void invalidateLine(int line)
line
- The line to invalidatepublic final void invalidateLineRange(int firstLine, int lastLine)
firstLine
- The first line to invalidatelastLine
- The last line to invalidatepublic final void invalidateSelectedLines()
public float nextTabStop(float x, int tabOffset)
nextTabStop
in interface javax.swing.text.TabExpander
x
- The x co-ordinatetabOffset
- Ignoredpublic java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
public int getMaxWidth()
protected int paintLine(java.awt.Graphics gfx, TokenMarker tokenMarker, int line, int x)
protected int paintPlainLine(java.awt.Graphics gfx, int line, java.awt.Font defaultFont, java.awt.Color defaultColor, int x, int y)
protected int paintSyntaxLine(java.awt.Graphics gfx, TokenMarker tokenMarker, int line, java.awt.Font defaultFont, java.awt.Color defaultColor, int x, int y)
protected void paintHighlight(java.awt.Graphics gfx, int line, int y)
protected void paintForceHighlight(java.awt.Graphics gfx, int line, int y, CodeEditorHighlighter.Highlight highlight)
protected void paintLineHighlight(java.awt.Graphics gfx, int line, int y)
protected void paintBracketHighlight(java.awt.Graphics gfx, int line, int y)
protected void paintCaret(java.awt.Graphics gfx, int line, int y)
Copyright © 2016, 2017, 2018, 2019, 2023 Herve Girod. All Rights Reserved. Documentation and source under the MIT licence