Package jade.tools.gui
Class ACLTextAreaPainter
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- jade.tools.gui.ACLTextAreaPainter
-
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,TabExpander
public class ACLTextAreaPainter extends JComponent implements TabExpander
The text area repaint manager. It performs double buffering and paints lines of text.The original file is written by Slava Pestov (www.gjt.org) and altered to fit ACL/SL.- Author:
- Chris van Aart - Acklin B.V., the Netherlands & 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
Fields Modifier and Type Field Description protected booleanblockCaretprotected booleanbracketHighlightprotected ColorbracketHighlightColorprotected ColorcaretColorprotected intcolsprotected static booleancopyAreaBrokenprotected ColoreolMarkerColorprotected booleaneolMarkersprotected intfirstInvalidprotected FontMetricsfmprotected intlastInvalidprotected booleanlineHighlightprotected ColorlineHighlightColorprotected GraphicsoffGfxprotected ImageoffImgprotected introwsprotected ColorselectionColorprotected ACLSytntaxStyle[]stylesprotected inttabSizeprotected ACLTextAreatextArea-
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
Constructors Constructor Description ACLTextAreaPainter(ACLTextArea textArea)Creates a new repaint manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void_invalidateLine(int line)Marks a line as needing a repaint, but doesn't actually repaint it untilrepaint()is called manually.void_invalidateLineRange(int firstLine, int lastLine)Marks a range of lines as needing a repaint, but doesn't actually repaint them untilrepaint()is called.protected booleanensureOffscreenValid()voidfastRepaint()Queues a repaint of the changed lines only.ColorgetBracketHighlightColor()Returns the bracket highlight color.ColorgetCaretColor()Returns the caret color.ColorgetEOLMarkerColor()Returns the EOL marker color.FontMetricsgetFontMetrics()Returns the font metrics used by this component.ColorgetLineHighlightColor()Returns the line highlight color.DimensiongetMinimumSize()Returns the painter's minimum size.DimensiongetPreferredSize()Returns the painter's preferred size.ColorgetSelectionColor()Returns the selection color.ACLSytntaxStyle[]getStyles()Returns the syntax styles used to paint colorized text.voidinvalidateLine(int line)Repaints the specified line.voidinvalidateLineRange(int firstLine, int lastLine)Repaints the specified line range.voidinvalidateOffscreen()Invalidates the offscreen graphics context.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.booleanisCopyAreaBroken()Returns if the copyArea() should not be used.booleanisEOLMarkerEnabled()Returns true if EOL markers are drawn, 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.protected intoffscreenRepaintLine(int line, int x)protected intoffscreenRepaintLineRange(int firstLine, int lastLine)voidpaint(Graphics g)Same asupdate(g).protected voidpaintBracketHighlight(int line, int y)protected voidpaintCaret(int line, int y)protected voidpaintHighlight(int line, int y)protected voidpaintLineHighlight(int line, int y)protected voidpaintPlainLine(int line, Font defaultFont, Color defaultColor, int x, int y)protected voidpaintSyntaxLine(ACLSLTokenMarker tokenMarker, int line, Font defaultFont, Color defaultColor, int x, int y)voidscrollRepaint(int oldFirstLine, int newFirstLine)Simulates scrolling fromoldFirstLinetonewFirstLineby shifting the offscreen graphics and repainting any revealed lines.voidsetBlockCaretEnabled(boolean blockCaret)Sets if the caret should be drawn as a block, false otherwise.voidsetBracketHighlightColor(Color bracketHighlightColor)Sets the bracket highlight color.voidsetBracketHighlightEnabled(boolean bracketHighlight)Enables or disables bracket highlighting.voidsetCaretColor(Color caretColor)Sets the caret color.voidsetCopyAreaBroken(boolean copyAreaBroken)Disables the use of the copyArea() function (which is broken in JDK 1.2).voidsetEOLMarkerColor(Color eolMarkerColor)Sets the EOL marker color.voidsetEOLMarkerEnabled(boolean eolMarkers)Sets if EOL markers are to be drawn.voidsetFont(Font font)Sets the font for this component.voidsetLineHighlightColor(Color lineHighlightColor)Sets the line highlight color.voidsetLineHighlightEnabled(boolean lineHighlight)Enables or disables current line highlighting.voidsetSelectionColor(Color selectionColor)Sets the selection color.voidsetStyles(ACLSytntaxStyle[] styles)Sets the syntax styles used to paint colorized text.voidupdate(Graphics g)Paints any lines that changed since the last paint to the offscreen graphics, then repaints the offscreen to the specified graphics context.-
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, 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, 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
-
copyAreaBroken
protected static boolean copyAreaBroken
-
textArea
protected ACLTextArea textArea
-
styles
protected ACLSytntaxStyle[] styles
-
caretColor
protected Color caretColor
-
selectionColor
protected Color selectionColor
-
lineHighlightColor
protected Color lineHighlightColor
-
bracketHighlightColor
protected Color bracketHighlightColor
-
eolMarkerColor
protected Color eolMarkerColor
-
blockCaret
protected boolean blockCaret
-
lineHighlight
protected boolean lineHighlight
-
bracketHighlight
protected boolean bracketHighlight
-
eolMarkers
protected boolean eolMarkers
-
cols
protected int cols
-
rows
protected int rows
-
tabSize
protected int tabSize
-
fm
protected FontMetrics fm
-
offGfx
protected Graphics offGfx
-
offImg
protected Image offImg
-
firstInvalid
protected int firstInvalid
-
lastInvalid
protected int lastInvalid
-
-
Constructor Detail
-
ACLTextAreaPainter
public ACLTextAreaPainter(ACLTextArea textArea)
Creates a new repaint manager. This should be not be called directly.- Parameters:
textArea- Description of Parameter
-
-
Method Detail
-
isManagingFocus
public final boolean isManagingFocus()
Returns if this component can be traversed by pressing the Tab key. This returns false.- Overrides:
isManagingFocusin classJComponent- Returns:
- The ManagingFocus value
-
getStyles
public final ACLSytntaxStyle[] getStyles()
Returns the syntax styles used to paint colorized text. Entry n will be used to paint tokens with id = n .- Returns:
- The Styles value
- See Also:
org.gjt.sp.jedit.syntax.Token
-
getCaretColor
public final Color getCaretColor()
Returns the caret color.- Returns:
- The CaretColor value
-
getSelectionColor
public final Color getSelectionColor()
Returns the selection color.- Returns:
- The SelectionColor value
-
getLineHighlightColor
public final Color getLineHighlightColor()
Returns the line highlight color.- Returns:
- The LineHighlightColor value
-
isLineHighlightEnabled
public final boolean isLineHighlightEnabled()
Returns true if line highlight is enabled, false otherwise.- Returns:
- The LineHighlightEnabled value
-
getBracketHighlightColor
public final Color getBracketHighlightColor()
Returns the bracket highlight color.- Returns:
- The BracketHighlightColor value
-
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.- Returns:
- The BracketHighlightEnabled value
-
isBlockCaretEnabled
public final boolean isBlockCaretEnabled()
Returns true if the caret should be drawn as a block, false otherwise.- Returns:
- The BlockCaretEnabled value
-
getEOLMarkerColor
public final Color getEOLMarkerColor()
Returns the EOL marker color.- Returns:
- The EOLMarkerColor value
-
isEOLMarkerEnabled
public final boolean isEOLMarkerEnabled()
Returns true if EOL markers are drawn, false otherwise.- Returns:
- The EOLMarkerEnabled value
-
setStyles
public final void setStyles(ACLSytntaxStyle[] 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:
org.gjt.sp.jedit.syntax.Token
-
setCaretColor
public final void setCaretColor(Color caretColor)
Sets the caret color.- Parameters:
caretColor- The caret color
-
setSelectionColor
public final void setSelectionColor(Color selectionColor)
Sets the selection color.- Parameters:
selectionColor- The selection color
-
setLineHighlightColor
public final void setLineHighlightColor(Color lineHighlightColor)
Sets the line highlight color.- Parameters:
lineHighlightColor- The line highlight color
-
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
-
setBracketHighlightColor
public final void setBracketHighlightColor(Color bracketHighlightColor)
Sets the bracket highlight color.- Parameters:
bracketHighlightColor- The bracket highlight color
-
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
-
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.
-
setEOLMarkerColor
public final void setEOLMarkerColor(Color eolMarkerColor)
Sets the EOL marker color.- Parameters:
eolMarkerColor- The EOL marker color
-
setEOLMarkerEnabled
public final void setEOLMarkerEnabled(boolean eolMarkers)
Sets if EOL markers are to be drawn.- Parameters:
eolMarkers- True if EOL markers should be dranw, false otherwise
-
fastRepaint
public final void fastRepaint()
Queues a repaint of the changed lines only.
-
invalidateLine
public final void invalidateLine(int line)
Repaints the specified line. This is equivalent to calling_invalidateLine()andrepaint().- Parameters:
line- The line- See Also:
_invalidateLine(int)
-
invalidateLineRange
public final void invalidateLineRange(int firstLine, int lastLine)Repaints the specified line range. This is equivalent to calling_invalidateLineRange()thenrepaint().- Parameters:
firstLine- The first line to repaintlastLine- The last line to repaint
-
invalidateSelectedLines
public final void invalidateSelectedLines()
Repaints the lines containing the selection.
-
invalidateOffscreen
public final void invalidateOffscreen()
Invalidates the offscreen graphics context. This should not be called directly.
-
getFontMetrics
public FontMetrics getFontMetrics()
Returns the font metrics used by this component.- Returns:
- The FontMetrics value
-
isCopyAreaBroken
public boolean isCopyAreaBroken()
Returns if the copyArea() should not be used.- Returns:
- The CopyAreaBroken value
-
getPreferredSize
public Dimension getPreferredSize()
Returns the painter's preferred size.- Overrides:
getPreferredSizein classJComponent- Returns:
- The PreferredSize value
-
getMinimumSize
public Dimension getMinimumSize()
Returns the painter's minimum size.- Overrides:
getMinimumSizein classJComponent- Returns:
- The MinimumSize value
-
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:
setFontin classJComponent- Parameters:
font- The font
-
setCopyAreaBroken
public void setCopyAreaBroken(boolean copyAreaBroken)
Disables the use of the copyArea() function (which is broken in JDK 1.2).- Parameters:
copyAreaBroken- The new CopyAreaBroken value
-
update
public void update(Graphics g)
Paints any lines that changed since the last paint to the offscreen graphics, then repaints the offscreen to the specified graphics context.- Overrides:
updatein classJComponent- Parameters:
g- The graphics context
-
paint
public void paint(Graphics g)
Same asupdate(g).- Overrides:
paintin classJComponent- Parameters:
g- Description of Parameter
-
_invalidateLine
public void _invalidateLine(int line)
Marks a line as needing a repaint, but doesn't actually repaint it untilrepaint()is called manually.- Parameters:
line- The line to invalidate
-
_invalidateLineRange
public void _invalidateLineRange(int firstLine, int lastLine)Marks a range of lines as needing a repaint, but doesn't actually repaint them untilrepaint()is called.- Parameters:
firstLine- The first line to invalidatelastLine- The last line to invalidate
-
scrollRepaint
public void scrollRepaint(int oldFirstLine, int newFirstLine)Simulates scrolling fromoldFirstLinetonewFirstLineby shifting the offscreen graphics and repainting any revealed lines. This should not be called directly; useJEditTextArea.setFirstLine()instead.- Parameters:
oldFirstLine- The old first linenewFirstLine- The new first line- See Also:
org.gjt.sp.jedit.textarea.JEditTextArea#setFirstLine(int)
-
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
-
ensureOffscreenValid
protected boolean ensureOffscreenValid()
-
offscreenRepaintLineRange
protected int offscreenRepaintLineRange(int firstLine, int lastLine)
-
offscreenRepaintLine
protected int offscreenRepaintLine(int line, int x)
-
paintPlainLine
protected void paintPlainLine(int line, Font defaultFont, Color defaultColor, int x, int y)
-
paintSyntaxLine
protected void paintSyntaxLine(ACLSLTokenMarker tokenMarker, int line, Font defaultFont, Color defaultColor, int x, int y)
-
paintHighlight
protected void paintHighlight(int line, int y)
-
paintLineHighlight
protected void paintLineHighlight(int line, int y)
-
paintBracketHighlight
protected void paintBracketHighlight(int line, int y)
-
paintCaret
protected void paintCaret(int line, int y)
-
-