java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
org.gjt.sp.jedit.textarea.Gutter
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,SwingConstants
The gutter is the component that displays folding indicators and line
numbers to the left of the text area. The only methods in this class
that should be called by plugins are those for adding and removing
text area extensions.
- Version:
- $Id: Gutter.java 25033 2020-03-25 23:22:26Z kpouer $
- Author:
- Mike Dillon and 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 Stringstatic final intDefault extension layer.static final StringFold painter service.static final Stringstatic final intHighest possible layer.static final intThe lowest possible 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, WIDTHFields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST -
Constructor Summary
Constructors -
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.Returns an array of registered text area extensions.Get the foreground color for highlighted line numbersintSets the number of lines between highlighted line numbers.intIdentifies whether the horizontal alignment of the line numbers.final ColorReturns the structure highlight color.getToolTipText(MouseEvent evt) Returns the tool tip to display at the specified location.booleanbooleanIdentifies whether the gutter is collapsed or expanded.booleanfinal booleanReturns true if structure highlighting is enabled, false otherwise.voidpaintComponent(Graphics _gfx) voidremoveExtension(TextAreaExtension extension) Removes a text area extension.voidConvenience method for setting a default matte border on the right with the specified border width and colorvoidvoidsetCurrentLineForeground(Color highlight) voidsetCurrentLineHighlightEnabled(boolean enabled) voidsetExpanded(boolean expanded) Sets whether the gutter is collapsed or expanded and force the text area to update its layout if there is a change.voidsetFoldColor(Color foldColor) voidsetFoldPainter(FoldPainter painter) voidvoidsetGutterEnabled(boolean enabled) voidsetHighlightedForeground(Color highlight) voidsetHighlightInterval(int interval) Sets the number of lines between highlighted line numbers.voidsetLineNumberAlignment(int alignment) Sets the horizontal alignment of the line numbers.voidsetMinLineNumberDigitCount(int min) voidsetMouseActionsProvider(MouseActionsProvider mouseActionsProvider) voidsetSelectionAreaBackground(Color bgColor) voidsetSelectionAreaEnabled(boolean enabled) voidsetSelectionAreaWidth(int width) voidfinal voidsetStructureHighlightColor(Color structureHighlightColor) Sets the structure highlight color.final voidsetStructureHighlightEnabled(boolean structureHighlight) Enables or disables structure highlighting.voidToggles whether the gutter is collapsed or expanded.voidSets the border differently if the text area has focus or not.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, paint, paintBorder, paintChildren, 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, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, 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, 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
-
LOWEST_LAYER
public static final int LOWEST_LAYERThe lowest possible 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 bracket highlight.- Since:
- jEdit 4.0pre4
- See Also:
-
HIGHEST_LAYER
public static final int HIGHEST_LAYERHighest possible layer.- Since:
- jEdit 4.0pre4
- See Also:
-
FOLD_PAINTER_PROPERTY
Fold painter service.- Since:
- jEdit 4.3pre16
- See Also:
-
FOLD_PAINTER_SERVICE
- See Also:
-
DEFAULT_FOLD_PAINTER_SERVICE
- See Also:
-
-
Constructor Details
-
Gutter
-
-
Method Details
-
setFoldPainter
-
paintComponent
- Overrides:
paintComponentin classJComponent
-
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
-
setBorder
Convenience method for setting a default matte border on the right with the specified border width and color- Parameters:
width- The border width (in pixels)color1- The focused border colorcolor2- The unfocused border colorcolor3- The gutter/text area gap color
-
updateBorder
public void updateBorder()Sets the border differently if the text area has focus or not. -
setBorder
- Overrides:
setBorderin classJComponent
-
setMinLineNumberDigitCount
public void setMinLineNumberDigitCount(int min) -
setFont
- Overrides:
setFontin classJComponent
-
setGutterEnabled
public void setGutterEnabled(boolean enabled) -
isSelectionAreaEnabled
public boolean isSelectionAreaEnabled() -
setSelectionAreaEnabled
public void setSelectionAreaEnabled(boolean enabled) -
setSelectionAreaBackground
-
setSelectionAreaWidth
public void setSelectionAreaWidth(int width) -
getHighlightedForeground
Get the foreground color for highlighted line numbers- Returns:
- The highlight color
-
setHighlightedForeground
-
getCurrentLineForeground
-
setCurrentLineForeground
-
getFoldColor
-
setFoldColor
-
getPreferredSize
- Overrides:
getPreferredSizein classJComponent
-
getMinimumSize
- Overrides:
getMinimumSizein classJComponent
-
getLineNumberAlignment
public int getLineNumberAlignment()Identifies whether the horizontal alignment of the line numbers.- Returns:
- Gutter.RIGHT, Gutter.CENTER, Gutter.LEFT
-
setLineNumberAlignment
public void setLineNumberAlignment(int alignment) Sets the horizontal alignment of the line numbers.- Parameters:
alignment- Gutter.RIGHT, Gutter.CENTER, Gutter.LEFT
-
isExpanded
public boolean isExpanded()Identifies whether the gutter is collapsed or expanded.- Returns:
- true if the gutter is expanded, false if it is collapsed
-
setExpanded
public void setExpanded(boolean expanded) Sets whether the gutter is collapsed or expanded and force the text area to update its layout if there is a change.- Parameters:
expanded- true if the gutter is expanded, false if it is collapsed
-
toggleExpanded
public void toggleExpanded()Toggles whether the gutter is collapsed or expanded. -
getHighlightInterval
public int getHighlightInterval()Sets the number of lines between highlighted line numbers.- Returns:
- The number of lines between highlighted line numbers or zero if highlighting is disabled
-
setHighlightInterval
public void setHighlightInterval(int interval) Sets the number of lines between highlighted line numbers. Any value less than or equal to one will result in highlighting being disabled.- Parameters:
interval- The number of lines between highlighted line numbers
-
isCurrentLineHighlightEnabled
public boolean isCurrentLineHighlightEnabled() -
setCurrentLineHighlightEnabled
public void setCurrentLineHighlightEnabled(boolean enabled) -
getStructureHighlightColor
Returns the structure highlight color.- Since:
- jEdit 4.2pre3
-
setStructureHighlightColor
Sets the structure highlight color.- Parameters:
structureHighlightColor- The structure 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
-
setSelectionPopupHandler
-
getSelectionPopupHandler
-
setMouseActionsProvider
-