Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


oracle.javatools.editor.gutter
Class LineGutterPlugin

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by oracle.javatools.editor.gutter.LineGutterPlugin

All Implemented Interfaces:
java.awt.event.ComponentListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.swing.event.DocumentListener, TextBufferListener, Gutter, EditorPlugin
Direct Known Subclasses:
CodeEditorGutter

public class LineGutterPlugin
extends javax.swing.JComponent
implements java.awt.event.ComponentListener, javax.swing.event.DocumentListener, EditorPlugin, Gutter, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, TextBufferListener

The LineGutterPlugin is a line gutter which also implements the Gutter interface that provides clients with the ability to add or remove icon marks in the gutter associated with an editor pane. Refer to the Gutter interface for more details about its use.

Note that this Gutter implementation is not currently defined to handle the case where the document for the editor is changed after the line gutter has been installed. Unpredictable results WILL happen in such cases.

This gutter implementation does not support the display of a single shared icon column.

See Also:
Gutter, Serialized Form

Nested Class Summary
 class LineGutterPlugin.Column
          This is our implementation of the GutterColumn interface that acts as a container for GutterMarks.
protected static class LineGutterPlugin.MarkComparator
          Comparator for our marks, ordering them by line, then by mark order.

 

Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent

 

Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer

 

Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy

 

Field Summary
protected  boolean _mouseInGutter
          Whether the mouse is in the gutter or not.
protected  GutterMark _mouseInMark
          The mark that the mouse is highlighting (on).
protected static java.util.List<LineGutterPlugin.Column.Mark> _scratchList
          The scratch list we use for painting, calculating, and so on.
protected  int _showLineNumberFlag
          The current value of the show line number policy.
protected static java.util.Comparator<GutterMark> MARK_COMPARATOR
          Singleton comparator for marks.
static int SHOW_LINE_NUMBERS_ALWAYS
          Constant indicating that line numbers should always be visible, regardless of the editor/global property for show line numbers.
static int SHOW_LINE_NUMBERS_DEFAULT
          Constant indicating that this line gutter instance will just follow the editor/global property for show line numbers.
static int SHOW_LINE_NUMBERS_NEVER
          Constant indicating that line numbers should never be visible, regardless of the editor/global property for show line numbers.

 

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.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT

 

Fields inherited from interface oracle.javatools.buffer.TextBufferListener
EDIT_BEGIN_ATTRIBUTE, EDIT_END_ATTRIBUTE, EOL_TYPE_ATTRIBUTE, MODIFIED_ATTRIBUTE, READ_ONLY_ATTRIBUTE, RELOAD_END_ATTRIBUTE, RELOAD_START_ATTRIBUTE

 

Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH

 

Constructor Summary
LineGutterPlugin()
          Constructs a new LineGutterPlugin.

 

Method Summary
 void addGutterClickListener(GutterClickListener listener)
          Registers a GutterClickListener to receive notifications of mouse clicks in this Gutter component.
protected static java.util.List<LineGutterPlugin.Column.Mark> allocateScratchList()
          Utility routine to get a shared scratch list.
protected  boolean allowDragging()
          Utility routine to check whether click-dragging is enabled for making a selection in the editor.
 void attributeUpdate(TextBuffer buffer, int attribute)
          Provides notification regarding a change to one of the buffer attributes.
protected  java.awt.Rectangle calculateRolloverBounds(java.awt.Rectangle bounds, int columnX, int columnWidth, int rowY)
           
 void changedUpdate(javax.swing.event.DocumentEvent event)
          Gives notification that an attribute or set of attributes changed.
 void componentHidden(java.awt.event.ComponentEvent event)
          Invoked when the component has been made invisible.
 void componentMoved(java.awt.event.ComponentEvent event)
          Invoked when the component's position changes.
 void componentResized(java.awt.event.ComponentEvent event)
          Invoked when the component's size changes.
 void componentShown(java.awt.event.ComponentEvent event)
          Invoked when the component has been made visible.
 GutterColumn createGutterColumn(java.lang.String columnName, GutterColumnListener listener)
          Creates a new GutterColumn that can contain GutterMarks for displaying icons in the Gutter.
protected  LineGutterPlugin.Column createGutterColumnImpl(java.lang.String columnName, GutterColumnListener listener)
          Creates the Column instance only.
 void deinstall(BasicEditorPane editor)
          Called when the plugin is being removed from the BasicEditorPane (for example when the editor is closed.) This is used to notify plugins that they should unregister any listeners that were attached.
protected  void deinstallDocument(BasicDocument document)
          Utility routine which takes care of stopping the tracking on the given document.
protected  void discardAllMarks()
          Utility routine to toss all the marks that are in our list and notify our listeners of their removal.
protected static void freeScratchList(java.util.List<LineGutterPlugin.Column.Mark> listToFree)
          Utility routine to free the shared scratch list.
protected  int getClosestRowFromCoordinate(int y)
          Private utility routine to calculate the closest row to a y-offset for purposes of painting.
 BasicEditorPane getEditor()
           
protected  int getLeftPadding()
          Utility routine to calculate how much padding on the left we have where we shouldn't paint.
protected  int getLineFromRow(int row)
          Fetch the first line that occurs on this row.
 GutterMark getMarkAtLocation(int mouseY, int mouseX)
          Return the mark at the given location or null if there is no mark.
 void getMarksOnLine(java.util.Collection<LineGutterPlugin.Column.Mark> collection, int line)
          Utility routine to get all of the marks for a given line, sorting them by mark order.
 java.awt.Dimension getPreferredSize()
          Gets the preferred size of the gutter, computing it if needed.
 java.awt.Rectangle getRolloverRectFor(GutterMark markToFind)
          Utility routine to fetch the paint rect for the given gutter mark.
protected  int getRowCount()
          Get the count of rows in the editor.
protected  int getRowFromCoordinate(int y)
          Private utility routine to calculate the row from a point.
protected  int getRowFromLine(int line)
          Fetch the row that this line occurs on.
 java.lang.String getToolTipText()
          Returns the tooltip string that has been set with setToolTipText().
 java.lang.String getToolTipText(java.awt.event.MouseEvent event)
          Returns the string to be used as the tooltip for event.
protected  int getTopPadding()
          Utility routine to calculate how much padding on top we have where we shouldn't paint.
protected static void incrementNumber(char[] number)
          Utility routine which, given a char array containing the string representation of a number, will increment the number by one.
 void insertUpdate(javax.swing.event.DocumentEvent event)
          Gives notification that there was an insert into the document.
 void insertUpdate(TextBuffer buffer, int offset, int count, char[] insertedData)
          Provides notification about an insertion into the text buffer.
 void install(BasicEditorPane editor)
          Called when this plugin is being installed into the BasicEditorPane.
protected  void installDocument(BasicDocument document)
          Utility routine which takes care of starting to track the given document.
 GutterColumn lookupGutterColumn(java.lang.String columnName)
          Fetches the gutter column by name.
protected  int markWidth(GutterMark mark)
          Gets the width required by a gutter mark (excluding margins).
 void mouseClicked(java.awt.event.MouseEvent event)
          Invoked when the mouse has been clicked on a component.
 void mouseDragged(java.awt.event.MouseEvent event)
          Invoked when a mouse button is pressed on a component and then dragged.
 void mouseEntered(java.awt.event.MouseEvent event)
          Invoked when the mouse enters a component.
 void mouseExited(java.awt.event.MouseEvent event)
          Invoked when the mouse exits a component.
 void mouseMoved(java.awt.event.MouseEvent event)
          Invoked when the mouse button has been moved on a component (with no buttons no down).
 void mousePressed(java.awt.event.MouseEvent event)
          Invoked when a mouse button has been pressed on a component.
 void mouseReleased(java.awt.event.MouseEvent event)
          Invoked when a mouse button has been released on a component.
protected static int numDigits(char[] number)
          Utility routine to compute the number of digits in the specified number.
static int numDigits(int number)
          Utility routine to compute the number of digits in the specified number.
 void paint(java.awt.Graphics graphics)
          Paint the component.
protected  java.awt.Rectangle paintRollover(java.awt.Graphics graphics, GutterMark mark, int columnX, int columnWidth, int rowY)
          Utility routine to paint the rollover effect for the given mark.
protected  void processMousePressed(java.awt.event.MouseEvent event)
           
protected  void processMousePressed(java.awt.event.MouseEvent event, int line, GutterMark mark)
           
 void propertyChange(java.beans.PropertyChangeEvent event)
          This method gets called when a bound property is changed.
protected  int recalculateColumnWidths()
          Utility routine for recalculating the width of all the gutter columns, taking into account width requirements.
protected  int recalculateLineWidths()
          Private utility routine for recalculating the width of the gutter necessary to display the line numbers in the gutter.
 void removeAllGutterColumns()
          Removes all existing columns from the Gutter.
 void removeGutterClickListener(GutterClickListener listener)
          Deregisters a previously-registered GutterClickListener so that it no longer receives notifications of mouse clicks in this Gutter component.
 void removeGutterColumn(GutterColumn column)
          Removes an existing column from the Gutter and all of its marks and icons.
 void removeUpdate(javax.swing.event.DocumentEvent event)
          Gives notification that a portion of the document has been removed.
 void removeUpdate(TextBuffer buffer, int offset, int count, char[] removedData)
          Provides notification about a removal from the text buffer.
protected  void repaintLine(int line)
          Utility routine to invalidate a single line for repainting.
protected  void repaintLine(int line, int extraPixels)
          Utility routine to invalidate a line for repainting plus several extra pixels above and below the line.
protected  int reservedColumnWidth(GutterColumn column)
          Gets the width to be reserved for a column, or 0 if none.
 void revalidate()
           
 void setLocation(int location)
          Set the location of this gutter with respect to the editor.
protected static void setNumber(char[] buffer, int n)
          Utility routine which, given a char array and a n, will convert the n into a char[] representation, and set it into the provided array, left-padding with spaces to fit the width properly.
 void setShowLineNumbers(int showFlag)
          Sets the "show line numbers" policy of this line gutter directly.
protected  void setUI(javax.swing.plaf.ComponentUI newUI)
          Sets the look and feel delegate for this component.
 java.lang.String toString()
           
protected  void updateAllMarkHighlights()
          Utility routine to update all of the highlights for all of the marks for the gutter.
protected  void updateColors()
          Private utility routine to update our background/foreground and border colors.
protected  void updateMetrics()
          Utility routine to update the font and metric information used for repainting this component.
protected  void updateMouseInMark(java.awt.event.MouseEvent event)
          Utility routine to update our information about the mark that the mouse is currently on.
protected  void updateShowLineNumbers()
          Utility routine which will update the current value of the showLineNumbers setting based on the showLineNumberFlag & editor/global property values.

 

Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, 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, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, 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, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, 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, transferFocusBackward, 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, 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, hide, 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, transferFocus, transferFocusUpCycle

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Field Detail

SHOW_LINE_NUMBERS_ALWAYS

public static final int SHOW_LINE_NUMBERS_ALWAYS
Constant indicating that line numbers should always be visible, regardless of the editor/global property for show line numbers.
See Also:
Constant Field Values

SHOW_LINE_NUMBERS_NEVER

public static final int SHOW_LINE_NUMBERS_NEVER
Constant indicating that line numbers should never be visible, regardless of the editor/global property for show line numbers.
See Also:
Constant Field Values

SHOW_LINE_NUMBERS_DEFAULT

public static final int SHOW_LINE_NUMBERS_DEFAULT
Constant indicating that this line gutter instance will just follow the editor/global property for show line numbers.
See Also:
Constant Field Values

_showLineNumberFlag

protected int _showLineNumberFlag
The current value of the show line number policy.

_scratchList

protected static java.util.List<LineGutterPlugin.Column.Mark> _scratchList
The scratch list we use for painting, calculating, and so on.

_mouseInGutter

protected boolean _mouseInGutter
Whether the mouse is in the gutter or not.

_mouseInMark

protected GutterMark _mouseInMark
The mark that the mouse is highlighting (on).

MARK_COMPARATOR

protected static final java.util.Comparator<GutterMark> MARK_COMPARATOR
Singleton comparator for marks.

Constructor Detail

LineGutterPlugin

public LineGutterPlugin()
Constructs a new LineGutterPlugin.

Method Detail

install

public void install(BasicEditorPane editor)
Called when this plugin is being installed into the BasicEditorPane.
Specified by:
install in interface EditorPlugin
Parameters:
editor - the editor pane

installDocument

protected void installDocument(BasicDocument document)
Utility routine which takes care of starting to track the given document.
Parameters:
document - the document to track

deinstall

public void deinstall(BasicEditorPane editor)
Called when the plugin is being removed from the BasicEditorPane (for example when the editor is closed.) This is used to notify plugins that they should unregister any listeners that were attached.
Specified by:
deinstall in interface EditorPlugin
Parameters:
editor - the editor pane

deinstallDocument

protected void deinstallDocument(BasicDocument document)
Utility routine which takes care of stopping the tracking on the given document.
Parameters:
document - the document to stop tracking

getToolTipText

public java.lang.String getToolTipText()
Returns the tooltip string that has been set with setToolTipText(). We currently do not provide tooltip information that does not correspond to a mouse event.
Overrides:
getToolTipText in class javax.swing.JComponent
Returns:
the tooltip text

getToolTipText

public java.lang.String getToolTipText(java.awt.event.MouseEvent event)
Returns the string to be used as the tooltip for event. By default this returns any string set using setToolTipText(). If a component provides more extensive API to support differing tooltips at different locations, this method should be overridden.
Overrides:
getToolTipText in class javax.swing.JComponent

updateShowLineNumbers

protected void updateShowLineNumbers()
Utility routine which will update the current value of the showLineNumbers setting based on the showLineNumberFlag & editor/global property values.

setShowLineNumbers

public void setShowLineNumbers(int showFlag)
Sets the "show line numbers" policy of this line gutter directly. This will only affect this line gutter instance - if the showFlag is SHOW_LINE_NUMBERS_ALWAYS or SHOW_LINE_NUMBERS_NEVER, then this line gutter will not respond to editor/global property changes for "show line numbers".
Parameters:
showFlag - the show line numbers policy for this line gutter

setLocation

public void setLocation(int location)
Set the location of this gutter with respect to the editor. You can align a gutter to the left or the right of the editor. The default is left.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
This method gets called when a bound property is changed.
Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - A PropertyChangeEvent object describing the event source and the property that has changed.

discardAllMarks

protected void discardAllMarks()
Utility routine to toss all the marks that are in our list and notify our listeners of their removal. This is in response to a document change.

allocateScratchList

protected static java.util.List<LineGutterPlugin.Column.Mark> allocateScratchList()
Utility routine to get a shared scratch list.
Returns:
a scratch list we can use

freeScratchList

protected static void freeScratchList(java.util.List<LineGutterPlugin.Column.Mark> listToFree)
Utility routine to free the shared scratch list.
Parameters:
listToFree - the list to free

setUI

protected void setUI(javax.swing.plaf.ComponentUI newUI)
Sets the look and feel delegate for this component. We override this to set up our colors.
Overrides:
setUI in class javax.swing.JComponent
Parameters:
newUI - the component ui to set

getMarksOnLine

public void getMarksOnLine(java.util.Collection<LineGutterPlugin.Column.Mark> collection,
                           int line)
Utility routine to get all of the marks for a given line, sorting them by mark order.

updateColors

protected void updateColors()
Private utility routine to update our background/foreground and border colors. This is typically in response to a change in the style registry for example.

updateMetrics

protected void updateMetrics()
Utility routine to update the font and metric information used for repainting this component.

revalidate

public void revalidate()
Overrides:
revalidate in class javax.swing.JComponent

getPreferredSize

public java.awt.Dimension getPreferredSize()
Gets the preferred size of the gutter, computing it if needed.
Overrides:
getPreferredSize in class javax.swing.JComponent

repaintLine

protected void repaintLine(int line,
                           int extraPixels)
Utility routine to invalidate a line for repainting plus several extra pixels above and below the line. This is useful for ensuring that the box for rollover gets painted correctly.

repaintLine

protected void repaintLine(int line)
Utility routine to invalidate a single line for repainting. This is typically called when an icon is added to, or removed from the gutter.
Parameters:
line - the line to invalidate (and repaint), 1-based

paint

public void paint(java.awt.Graphics graphics)
Paint the component. This is called when the contents of the component have been changed, damaged, or resized.
Overrides:
paint in class javax.swing.JComponent
Parameters:
graphics - the graphics context to draw to

getRolloverRectFor

public java.awt.Rectangle getRolloverRectFor(GutterMark markToFind)
Utility routine to fetch the paint rect for the given gutter mark. This is used to line up the context menu for example, for subclasses. The rectangle will include the rollover rectangle drawn.
Parameters:
markToFind - the mark to get the rollover rectangle for
Returns:
the rollover rectangle for the given gutter mark, or null if the mark does not or exist or is not visible

calculateRolloverBounds

protected java.awt.Rectangle calculateRolloverBounds(java.awt.Rectangle bounds,
                                                     int columnX,
                                                     int columnWidth,
                                                     int rowY)

markWidth

protected int markWidth(GutterMark mark)
Gets the width required by a gutter mark (excluding margins). The calculation is simple, but centralizing it here make it easy to try variations like fixed column widths or column widths overriding icon widths.

reservedColumnWidth

protected int reservedColumnWidth(GutterColumn column)
Gets the width to be reserved for a column, or 0 if none.

paintRollover

protected java.awt.Rectangle paintRollover(java.awt.Graphics graphics,
                                           GutterMark mark,
                                           int columnX,
                                           int columnWidth,
                                           int rowY)
Utility routine to paint the rollover effect for the given mark.
Parameters:
graphics - the graphics instance
mark - the mark that should get the rollover effect
columnX - the x location where the icon was painted
rowY - the y location of the top of the row
Returns:
the bounds of the painted rollover rectangle, if any.

setNumber

protected static void setNumber(char[] buffer,
                                int n)
Utility routine which, given a char array and a n, will convert the n into a char[] representation, and set it into the provided array, left-padding with spaces to fit the width properly.
Parameters:
buffer - the char array to store the result in
n - the integer to get the representation of

incrementNumber

protected static void incrementNumber(char[] number)
Utility routine which, given a char array containing the string representation of a number, will increment the number by one.
Parameters:
number - the char array to store the result in

numDigits

protected static int numDigits(char[] number)
Utility routine to compute the number of digits in the specified number.
Parameters:
number - the number to calculate the number of digits for
Returns:
the number of digits in the specified number

recalculateLineWidths

protected int recalculateLineWidths()
Private utility routine for recalculating the width of the gutter necessary to display the line numbers in the gutter.
Returns:
what the minimum width requirement to display line numbers in the gutter

getRowCount

protected int getRowCount()
Get the count of rows in the editor.
Returns:
the count of rows in the editor

getLineFromRow

protected int getLineFromRow(int row)
Fetch the first line that occurs on this row. This returns a 1-based line.
Parameters:
row - the row to get the line for
Returns:
the line for this row

getRowFromLine

protected int getRowFromLine(int line)
Fetch the row that this line occurs on. This returns a 1-based row.
Parameters:
line - the line (1-based) to get the row for
Returns:
the row (1-based) for this line

getRowFromCoordinate

protected int getRowFromCoordinate(int y)
Private utility routine to calculate the row from a point. This is typically done, for example, when the user clicks on a point, and we need to deliver a notification event. This returns a 1-based row number.
Parameters:
y - the y-coordinate to translate
Returns:
the line corresponding to the given (x, y) pair, or -1 if it does not correspond with a line

getClosestRowFromCoordinate

protected int getClosestRowFromCoordinate(int y)
Private utility routine to calculate the closest row to a y-offset for purposes of painting. This is used to ensure that we don't try to paint out of bounds. We want to make sure the line is valid though, so that our paint() routine doesn't get too confused. This returns a 1-based line number.
Parameters:
y - the y-coordinate to translate
Returns:
the closet line to the given y coordinate offset

getTopPadding

protected int getTopPadding()
Utility routine to calculate how much padding on top we have where we shouldn't paint. This typically matches the editor insets so that line numbers are aligned properly.

getLeftPadding

protected int getLeftPadding()
Utility routine to calculate how much padding on the left we have where we shouldn't paint.

numDigits

public static int numDigits(int number)
Utility routine to compute the number of digits in the specified number.
Parameters:
number - the number to calculate the number of digits for
Returns:
the number of digits in the specified number

componentResized

public void componentResized(java.awt.event.ComponentEvent event)
Invoked when the component's size changes.
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent event)
Invoked when the component's position changes.
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent event)
Invoked when the component has been made visible.
Specified by:
componentShown in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent event)
Invoked when the component has been made invisible.
Specified by:
componentHidden in interface java.awt.event.ComponentListener

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent event)
Gives notification that there was an insert into the document. The range given by the DocumentEvent bounds the freshly inserted region.
Specified by:
insertUpdate in interface javax.swing.event.DocumentListener
Parameters:
event - the document event

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent event)
Gives notification that a portion of the document has been removed. The range is given in terms of what the view last saw (that is, before updating sticky positions).
Specified by:
removeUpdate in interface javax.swing.event.DocumentListener
Parameters:
event - the document event

changedUpdate

public void changedUpdate(javax.swing.event.DocumentEvent event)
Gives notification that an attribute or set of attributes changed.
Specified by:
changedUpdate in interface javax.swing.event.DocumentListener
Parameters:
event - the document event

insertUpdate

public void insertUpdate(TextBuffer buffer,
                         int offset,
                         int count,
                         char[] insertedData)
Provides notification about an insertion into the text buffer.
Specified by:
insertUpdate in interface TextBufferListener
Parameters:
buffer -
offset - the offset where the insert took place
count - the number of characters inserted (insertedData.length)
insertedData - the contents of the insertion

removeUpdate

public void removeUpdate(TextBuffer buffer,
                         int offset,
                         int count,
                         char[] removedData)
Provides notification about a removal from the text buffer.
Specified by:
removeUpdate in interface TextBufferListener
Parameters:
buffer -
offset - the offset where the removal took place
count - the number of characters removed (removedData.length)
removedData - the contents of the removal

attributeUpdate

public void attributeUpdate(TextBuffer buffer,
                            int attribute)
Provides notification regarding a change to one of the buffer attributes. The possible attributes are defined in this interface.
Specified by:
attributeUpdate in interface TextBufferListener
Parameters:
buffer -
attribute - the attribute that changed

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent event)
Invoked when a mouse button is pressed on a component and then dragged. Mouse drag events will continue to be delivered to the component where the first originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
event - the mouse event

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent event)
Invoked when the mouse button has been moved on a component (with no buttons no down).
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
event - the mouse event

allowDragging

protected boolean allowDragging()
Utility routine to check whether click-dragging is enabled for making a selection in the editor.
Returns:
true if dragging is allowed for making a selection

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent event)
Invoked when the mouse has been clicked on a component.
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent event)
Invoked when a mouse button has been pressed on a component.
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent event)
Invoked when a mouse button has been released on a component.
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent event)
Invoked when the mouse enters a component.
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent event)
Invoked when the mouse exits a component.
Specified by:
mouseExited in interface java.awt.event.MouseListener

updateMouseInMark

protected void updateMouseInMark(java.awt.event.MouseEvent event)
Utility routine to update our information about the mark that the mouse is currently on.
Parameters:
event - the mouse event

getEditor

public BasicEditorPane getEditor()
Returns:
the editor pane associate with this gutter

getMarkAtLocation

public GutterMark getMarkAtLocation(int mouseY,
                                    int mouseX)
Return the mark at the given location or null if there is no mark.

processMousePressed

protected void processMousePressed(java.awt.event.MouseEvent event)

processMousePressed

protected void processMousePressed(java.awt.event.MouseEvent event,
                                   int line,
                                   GutterMark mark)

createGutterColumn

public GutterColumn createGutterColumn(java.lang.String columnName,
                                       GutterColumnListener listener)
Creates a new GutterColumn that can contain GutterMarks for displaying icons in the Gutter. Note that this is a non-visual container only. The specified listener will be used to provide notifications of mark events.
Specified by:
createGutterColumn in interface Gutter
Parameters:
columnName - the name of the column, used only for lookup or debugging purposes
listener - the notification listener to use
Returns:
the column if it was created successfully, null if the already exists

createGutterColumnImpl

protected LineGutterPlugin.Column createGutterColumnImpl(java.lang.String columnName,
                                                         GutterColumnListener listener)
Creates the Column instance only. This allows subclasses to override this with their own column implementation.

lookupGutterColumn

public GutterColumn lookupGutterColumn(java.lang.String columnName)
Fetches the gutter column by name.
Specified by:
lookupGutterColumn in interface Gutter
Parameters:
columnName - the name of the column
Returns:
the column, or null if it does not exist

removeGutterColumn

public void removeGutterColumn(GutterColumn column)
Removes an existing column from the Gutter and all of its marks and icons.
Specified by:
removeGutterColumn in interface Gutter
Parameters:
column - the column to remove

removeAllGutterColumns

public void removeAllGutterColumns()
Removes all existing columns from the Gutter.
Specified by:
removeAllGutterColumns in interface Gutter

updateAllMarkHighlights

protected void updateAllMarkHighlights()
Utility routine to update all of the highlights for all of the marks for the gutter. Potentially this may be expensive, however we don't expect very many marks in the gutter.

recalculateColumnWidths

protected int recalculateColumnWidths()
Utility routine for recalculating the width of all the gutter columns, taking into account width requirements.
Returns:
what the minimum width requirement for the columns is

addGutterClickListener

public void addGutterClickListener(GutterClickListener listener)
Registers a GutterClickListener to receive notifications of mouse clicks in this Gutter component.
Specified by:
addGutterClickListener in interface Gutter
Parameters:
listener - the listener to register

removeGutterClickListener

public void removeGutterClickListener(GutterClickListener listener)
Deregisters a previously-registered GutterClickListener so that it no longer receives notifications of mouse clicks in this Gutter component.
Specified by:
removeGutterClickListener in interface Gutter
Parameters:
listener - the listener to register

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.Component

Skip navigation links

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.2.0)

E17493-03


Copyright © 1997, 2012, Oracle. All rights reserved.