Class TextAreaPainter
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- com.inductiveautomation.ignition.client.jedittextarea.TextAreaPainter
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.swing.text.TabExpander
public class TextAreaPainter extends javax.swing.JComponent implements javax.swing.text.TabExpanderThe 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 Description static interfaceTextAreaPainter.HighlightHighlight interface.-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description protected booleanblockCaretprotected booleanbracketHighlightprotected java.awt.ColorbracketHighlightColorprotected java.awt.ColorcaretColorprotected intcolsprotected java.awt.ColoreolMarkerColorprotected booleaneolMarkersprotected java.awt.FontMetricsfmprotected TextAreaPainter.Highlighthighlightsprotected booleanlineHighlightprotected java.awt.ColorlineHighlightColorprotected booleanpaintInvalidprotected introwsprotected java.awt.ColorselectionColorprotected SyntaxStyle[]stylesprotected inttabSizeprotected JEditTextAreatextArea-
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
-
-
Constructor Summary
Constructors Constructor Description TextAreaPainter(JEditTextArea textArea, TextAreaDefaults defaults)Creates a new repaint manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddCustomHighlight(TextAreaPainter.Highlight highlight)Adds a custom highlight painter.java.awt.ColorgetBracketHighlightColor()Returns the bracket highlight color.java.awt.ColorgetCaretColor()Returns the caret color.java.awt.ColorgetEOLMarkerColor()Returns the EOL marker color.booleangetEOLMarkersPainted()Returns true if EOL markers are drawn, false otherwise.java.awt.FontMetricsgetFontMetrics()Returns the font metrics used by this component.booleangetInvalidLinesPainted()Returns true if invalid lines are painted as red tildes (~), false otherwise.java.awt.ColorgetLineHighlightColor()Returns the line highlight color.java.awt.DimensiongetPreferredSize()Returns the painter's preferred size.java.awt.ColorgetSelectionColor()Returns the selection color.SyntaxStyle[]getStyles()Returns the syntax styles used to paint colorized text.java.lang.StringgetToolTipText(java.awt.event.MouseEvent evt)Returns the tool tip to display at the specified location.voidinvalidateLine(int line)Marks a line as needing a repaint.voidinvalidateLineRange(int firstLine, int lastLine)Marks a range of lines as needing a repaint.voidinvalidateSelectedLines()Repaints the lines containing the selection.booleanisBlockCaretEnabled()Returns true if the caret should be drawn as a block, false otherwise.booleanisBracketHighlightEnabled()Returns true if bracket highlighting is enabled, false otherwise.booleanisLineHighlightEnabled()Returns true if line highlight is enabled, false otherwise.booleanisManagingFocus()Returns if this component can be traversed by pressing the Tab key.floatnextTabStop(float x, int tabOffset)Implementation of TabExpander interface.voidpaint(java.awt.Graphics gfx)Repaints the text.protected voidpaintBracketHighlight(java.awt.Graphics gfx, int line, int y)protected voidpaintCaret(java.awt.Graphics gfx, int line, int y)protected voidpaintHighlight(java.awt.Graphics gfx, int line, int y)protected voidpaintLine(java.awt.Graphics gfx, TokenMarker tokenMarker, int line, int x)protected voidpaintLineHighlight(java.awt.Graphics gfx, int line, int y)protected voidpaintPlainLine(java.awt.Graphics gfx, int line, java.awt.Font defaultFont, java.awt.Color defaultColor, int x, int y)protected voidpaintSyntaxLine(java.awt.Graphics gfx, TokenMarker tokenMarker, int line, java.awt.Font defaultFont, java.awt.Color defaultColor, int x, int y)voidsetBlockCaretEnabled(boolean blockCaret)Sets if the caret should be drawn as a block, false otherwise.voidsetBracketHighlightColor(java.awt.Color bracketHighlightColor)Sets the bracket highlight color.voidsetBracketHighlightEnabled(boolean bracketHighlight)Enables or disables bracket highlighting.voidsetCaretColor(java.awt.Color caretColor)Sets the caret color.voidsetEOLMarkerColor(java.awt.Color eolMarkerColor)Sets the EOL marker color.voidsetEOLMarkersPainted(boolean eolMarkers)Sets if EOL markers are to be drawn.voidsetFont(java.awt.Font font)Sets the font for this component.voidsetInvalidLinesPainted(boolean paintInvalid)Sets if invalid lines are to be painted as red tildes.voidsetLineHighlightColor(java.awt.Color lineHighlightColor)Sets the line highlight color.voidsetLineHighlightEnabled(boolean lineHighlight)Enables or disables current line highlighting.voidsetSelectionColor(java.awt.Color selectionColor)Sets the selection color.voidsetStyles(SyntaxStyle[] styles)Sets the syntax styles used to paint colorized text.-
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, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, 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
-
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 Detail
-
textArea
protected JEditTextArea textArea
-
styles
protected SyntaxStyle[] styles
-
caretColor
protected java.awt.Color caretColor
-
selectionColor
protected java.awt.Color selectionColor
-
lineHighlightColor
protected java.awt.Color lineHighlightColor
-
bracketHighlightColor
protected java.awt.Color bracketHighlightColor
-
eolMarkerColor
protected java.awt.Color 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
-
fm
protected java.awt.FontMetrics fm
-
highlights
protected TextAreaPainter.Highlight highlights
-
-
Constructor Detail
-
TextAreaPainter
public TextAreaPainter(JEditTextArea textArea, TextAreaDefaults defaults)
Creates a new repaint manager. This should be not be called directly.
-
-
Method Detail
-
isManagingFocus
public final boolean isManagingFocus()
Returns if this component can be traversed by pressing the Tab key. This returns false.- Overrides:
isManagingFocusin classjavax.swing.JComponent
-
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:
com.inductiveautomation.ignition.client.jedittextarea.gjt.sp.jedit.syntax.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:
com.inductiveautomation.ignition.client.jedittextarea.gjt.sp.jedit.syntax.Token
-
getCaretColor
public final java.awt.Color getCaretColor()
Returns the caret color.
-
setCaretColor
public final void setCaretColor(java.awt.Color caretColor)
Sets the caret color.- Parameters:
caretColor- The caret color
-
getSelectionColor
public final java.awt.Color getSelectionColor()
Returns the selection color.
-
setSelectionColor
public final void setSelectionColor(java.awt.Color selectionColor)
Sets the selection color.- Parameters:
selectionColor- The selection color
-
getLineHighlightColor
public final java.awt.Color getLineHighlightColor()
Returns the line highlight color.
-
setLineHighlightColor
public final void setLineHighlightColor(java.awt.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 java.awt.Color getBracketHighlightColor()
Returns the bracket highlight color.
-
setBracketHighlightColor
public final void setBracketHighlightColor(java.awt.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 java.awt.Color getEOLMarkerColor()
Returns the EOL marker color.
-
setEOLMarkerColor
public final void setEOLMarkerColor(java.awt.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
-
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
public void addCustomHighlight(TextAreaPainter.Highlight highlight)
Adds a custom highlight painter.- Parameters:
highlight- The highlight
-
getToolTipText
public java.lang.String getToolTipText(java.awt.event.MouseEvent evt)
Returns the tool tip to display at the specified location.- Overrides:
getToolTipTextin classjavax.swing.JComponent- Parameters:
evt- The mouse event
-
getFontMetrics
public java.awt.FontMetrics getFontMetrics()
Returns the font metrics used by this component.
-
setFont
public void setFont(java.awt.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:
setFontin classjavax.swing.JComponent- Parameters:
font- The font
-
paint
public void paint(java.awt.Graphics gfx)
Repaints the text.- Overrides:
paintin classjavax.swing.JComponent- Parameters:
gfx- 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:
nextTabStopin interfacejavax.swing.text.TabExpander- Parameters:
x- The x co-ordinatetabOffset- Ignored- Returns:
- The next tab stop after x
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
Returns the painter's preferred size.- Overrides:
getPreferredSizein classjavax.swing.JComponent
-
paintLine
protected void paintLine(java.awt.Graphics gfx, TokenMarker tokenMarker, int line, int x)
-
paintPlainLine
protected void paintPlainLine(java.awt.Graphics gfx, int line, java.awt.Font defaultFont, java.awt.Color defaultColor, int x, int y)
-
paintSyntaxLine
protected void paintSyntaxLine(java.awt.Graphics gfx, TokenMarker tokenMarker, int line, java.awt.Font defaultFont, java.awt.Color defaultColor, int x, int y)
-
paintHighlight
protected void paintHighlight(java.awt.Graphics gfx, int line, int y)
-
paintLineHighlight
protected void paintLineHighlight(java.awt.Graphics gfx, int line, int y)
-
paintBracketHighlight
protected void paintBracketHighlight(java.awt.Graphics gfx, int line, int y)
-
paintCaret
protected void paintCaret(java.awt.Graphics gfx, int line, int y)
-
-