|
|||||||||
| Home >> All >> jsource >> [ gui overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
jsource.gui
Class Gutter

java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JLabel
jsource.gui.Gutter
- All Implemented Interfaces:
- javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.swing.SwingConstants
- public class Gutter
- extends javax.swing.JLabel
- implements javax.swing.SwingConstants
- extends javax.swing.JLabel
Gutter is the component that displays line numbers to the left of the text area.
Based on jEdit's Gutter component by Mike Dillon and Slava Pestov.
| Nested Class Summary | |
(package private) class |
Gutter.MouseHandler
|
| Nested classes inherited from class javax.swing.JLabel |
javax.swing.JLabel.AccessibleJLabel |
| Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
private int |
alignment
|
private int |
baseline
|
private boolean |
collapsed
|
private java.awt.Dimension |
collapsedSize
|
private javax.swing.JPopupMenu |
context
|
private java.awt.Color |
currentLineHighlight
|
private boolean |
currentLineHighlightEnabled
|
(package private) static java.awt.Color |
DEFAULT_BG_COLOUR
Internal Gutter color constants |
(package private) static java.awt.Color |
DEFAULT_CURRENT_LINE_COLOUR
|
(package private) static java.awt.Color |
DEFAULT_DIVIDER_COLOUR
|
(package private) static java.awt.Color |
DEFAULT_FG_COLOUR
|
(package private) static java.awt.Color |
DEFAULT_INTERVAL_COLOUR
|
private java.awt.Color |
dividerColour
|
private JSEditor |
editor
A reference to the JSEditor object where the Gutter is attached |
private java.awt.FontMetrics |
fm
|
private java.awt.Dimension |
gutterSize
|
private int |
ileft
|
private int |
interval
|
private java.awt.Color |
intervalHighlight
|
private boolean |
lineNumberingEnabled
|
private int |
mMinWidth
|
| Fields inherited from class javax.swing.JLabel |
labelFor |
| Fields inherited from class javax.swing.JComponent |
accessibleContext, 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.Container |
|
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields 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 |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
Gutter(JSEditor editor)
|
|
| Method Summary | |
javax.swing.JPopupMenu |
getContextMenu()
|
java.awt.Color |
getCurrentLineForeground()
|
java.awt.Color |
getDividerColour()
|
int |
getGutterWidth()
Get the width of the expanded gutter |
java.awt.Color |
getHighlightedForeground()
Get the foreground color for highlighted line numbers |
int |
getHighlightInterval()
Sets the number of lines between highlighted line numbers. |
int |
getLineNumberAlignment()
Identifies whether the horizontal alignment of the line numbers. |
java.awt.Dimension |
getMinimumSize()
Get the component's minimum size. |
java.awt.Dimension |
getPreferredSize()
Get the component's preferred size. |
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. |
boolean |
isCollapsed()
Identifies whether the gutter is collapsed or expanded. |
boolean |
isCurrentLineHighlightEnabled()
|
boolean |
isLineNumberingEnabled()
Identifies whether or not the line numbers are drawn in the gutter |
void |
paint(java.awt.Graphics gfx)
Paint the component. |
void |
paintComponent(java.awt.Graphics gfx)
Paint the component's body. |
private void |
paintLineNumbers(java.awt.Graphics gfx)
|
void |
setCollapsed(boolean collapsed)
Sets whether the gutter is collapsed or expanded and force the text area to update its layout if there is a change. |
void |
setContextMenu(javax.swing.JPopupMenu context)
|
void |
setCurrentLineForeground(java.awt.Color highlight)
|
void |
setCurrentLineHighlightEnabled(boolean enabled)
|
void |
setDividerColour(java.awt.Color c)
|
void |
setFont(java.awt.Font font)
This method overrides setFont so that we can call for a repaint after the font is changed. |
void |
setGutterWidth(int width)
Set the width of the expanded gutter |
void |
setHighlightedForeground(java.awt.Color highlight)
|
void |
setHighlightInterval(int interval)
Sets the number of lines between highlighted line numbers. |
void |
setLineNumberAlignment(int alignment)
Sets the horizontal alignment of the line numbers. |
void |
setLineNumberingEnabled(boolean enabled)
Turns the line numbering on or off and causes the gutter to be repainted. |
void |
toggleCollapsed()
Toggles whether the gutter is collapsed or expanded. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
DEFAULT_BG_COLOUR
static final java.awt.Color DEFAULT_BG_COLOUR
- Internal
Guttercolor constants
DEFAULT_FG_COLOUR
static final java.awt.Color DEFAULT_FG_COLOUR
DEFAULT_DIVIDER_COLOUR
static final java.awt.Color DEFAULT_DIVIDER_COLOUR
DEFAULT_CURRENT_LINE_COLOUR
static final java.awt.Color DEFAULT_CURRENT_LINE_COLOUR
DEFAULT_INTERVAL_COLOUR
static final java.awt.Color DEFAULT_INTERVAL_COLOUR
editor
private JSEditor editor
- A reference to the
JSEditorobject where theGutteris attached
context
private javax.swing.JPopupMenu context
baseline
private int baseline
ileft
private int ileft
mMinWidth
private int mMinWidth
gutterSize
private java.awt.Dimension gutterSize
collapsedSize
private java.awt.Dimension collapsedSize
intervalHighlight
private java.awt.Color intervalHighlight
currentLineHighlight
private java.awt.Color currentLineHighlight
dividerColour
private java.awt.Color dividerColour
fm
private java.awt.FontMetrics fm
alignment
private int alignment
interval
private int interval
lineNumberingEnabled
private boolean lineNumberingEnabled
currentLineHighlightEnabled
private boolean currentLineHighlightEnabled
collapsed
private boolean collapsed
| Constructor Detail |
Gutter
public Gutter(JSEditor editor)
| Method Detail |
paintComponent
public void paintComponent(java.awt.Graphics gfx)
- Description copied from class:
javax.swing.JComponent - Paint the component's body. This usually means calling ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)>
ComponentUI.update(java.awt.Graphics, javax.swing.JComponent)55 on the JComponent.ui>JComponent.ui55 property of the component, if it is non-null. You may override this if you wish to customize the component's body-painting behavior. The component's body is painted first, before the border and children.
paint
public void paint(java.awt.Graphics gfx)
- Description copied from class:
javax.swing.JComponent Paint the component. This is a delicate process, and should only be called from the repaint thread, under control of the javax.swing.RepaintManager. Client code should usually call Component.repaint()>
Component.repaint()55 to trigger painting.The body of the
paintcall involves calling JComponent.paintComponent(java.awt.Graphics)>JComponent.paintComponent(java.awt.Graphics)55 , JComponent.paintBorder(java.awt.Graphics)>JComponent.paintBorder(java.awt.Graphics)55 , and JComponent.paintChildren(java.awt.Graphics)>JComponent.paintChildren(java.awt.Graphics)55 in order. If you want to customize painting behavior, you should override one of these methods rather thanpaint.For more details on the painting sequence, see this article.
paintLineNumbers
private void paintLineNumbers(java.awt.Graphics gfx)
invalidateLine
public final void invalidateLine(int line)
- Marks a line as needing a repaint.
invalidateLineRange
public final void invalidateLineRange(int firstLine,
int lastLine)
- Marks a range of lines as needing a repaint.
setFont
public void setFont(java.awt.Font font)
- Description copied from class:
javax.swing.JLabel - This method overrides setFont so that we can call for a repaint after the
font is changed.
getHighlightedForeground
public java.awt.Color getHighlightedForeground()
- Get the foreground color for highlighted line numbers
setHighlightedForeground
public void setHighlightedForeground(java.awt.Color highlight)
getCurrentLineForeground
public java.awt.Color getCurrentLineForeground()
setCurrentLineForeground
public void setCurrentLineForeground(java.awt.Color highlight)
setGutterWidth
public void setGutterWidth(int width)
- Set the width of the expanded gutter
getGutterWidth
public int getGutterWidth()
- Get the width of the expanded gutter
getPreferredSize
public java.awt.Dimension getPreferredSize()
- Description copied from class:
javax.swing.JComponent - Get the component's preferred size. If the JComponent.preferredSize>
JComponent.preferredSize55 property has been explicitly set, it is returned. If the JComponent.preferredSize>JComponent.preferredSize55 property has not been set but the JComponent.ui>JComponent.ui55 property has been, the result of ComponentUI.getPreferredSize(javax.swing.JComponent)>ComponentUI.getPreferredSize(javax.swing.JComponent)55 is returned. If neither property has been set, the result of Container.getPreferredSize()>Container.getPreferredSize()55 is returned.
getMinimumSize
public java.awt.Dimension getMinimumSize()
- Description copied from class:
javax.swing.JComponent - Get the component's minimum size. If the JComponent.minimumSize>
JComponent.minimumSize55 property has been explicitly set, it is returned. If the JComponent.minimumSize>JComponent.minimumSize55 property has not been set but the JComponent.ui>JComponent.ui55 property has been, the result of ComponentUI.getMinimumSize(javax.swing.JComponent)>ComponentUI.getMinimumSize(javax.swing.JComponent)55 is returned. If neither property has been set, the result of Container.getMinimumSize()>Container.getMinimumSize()55 is returned.
isLineNumberingEnabled
public boolean isLineNumberingEnabled()
- Identifies whether or not the line numbers are drawn in the gutter
setLineNumberingEnabled
public void setLineNumberingEnabled(boolean enabled)
- Turns the line numbering on or off and causes the gutter to be
repainted.
getLineNumberAlignment
public int getLineNumberAlignment()
- Identifies whether the horizontal alignment of the line numbers.
setLineNumberAlignment
public void setLineNumberAlignment(int alignment)
- Sets the horizontal alignment of the line numbers.
isCollapsed
public boolean isCollapsed()
- Identifies whether the gutter is collapsed or expanded.
setCollapsed
public void setCollapsed(boolean collapsed)
- Sets whether the gutter is collapsed or expanded and force the text
area to update its layout if there is a change.
toggleCollapsed
public void toggleCollapsed()
- Toggles whether the gutter is collapsed or expanded.
getHighlightInterval
public int getHighlightInterval()
- Sets the number of lines between highlighted line numbers.
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.
setDividerColour
public void setDividerColour(java.awt.Color c)
getDividerColour
public java.awt.Color getDividerColour()
isCurrentLineHighlightEnabled
public boolean isCurrentLineHighlightEnabled()
setCurrentLineHighlightEnabled
public void setCurrentLineHighlightEnabled(boolean enabled)
getContextMenu
public javax.swing.JPopupMenu getContextMenu()
setContextMenu
public void setContextMenu(javax.swing.JPopupMenu context)
|
|||||||||
| Home >> All >> jsource >> [ gui overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC