public class CompletionCellRenderer
extends javax.swing.DefaultListCellRenderer
Completion
types, like Eclipse and NetBeans do. Specifically,
this renderer handles:
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
构造器和说明 |
---|
CompletionCellRenderer()
Constructor.
|
CompletionCellRenderer(javax.swing.DefaultListCellRenderer delegate)
Constructor.
|
限定符和类型 | 方法和说明 |
---|---|
void |
delegateToSubstanceRenderer()
Attempts to delegate rendering to a Substance cell renderer.
|
static java.awt.Color |
getAlternateBackground()
Returns the background color to use on alternating lines.
|
javax.swing.DefaultListCellRenderer |
getDelegateRenderer()
Returns the delegate renderer, or
null if there is none. |
java.awt.Font |
getDisplayFont()
Returns the font used when rendering completions.
|
java.awt.Component |
getListCellRendererComponent(javax.swing.JList list,
java.lang.Object value,
int index,
boolean selected,
boolean hasFocus)
Returns the renderer.
|
boolean |
getShowTypes()
Returns whether the types of fields and return types of methods are
shown in the completion text.
|
protected void |
paintComponent(java.awt.Graphics g) |
protected void |
prepareForFunctionCompletion(javax.swing.JList list,
FunctionCompletion fc,
int index,
boolean selected,
boolean hasFocus)
Prepares this renderer to display a function completion.
|
protected void |
prepareForMarkupTagCompletion(javax.swing.JList list,
MarkupTagCompletion mc,
int index,
boolean selected,
boolean hasFocus)
Prepares this renderer to display a markup tag completion.
|
protected void |
prepareForOtherCompletion(javax.swing.JList list,
Completion c,
int index,
boolean selected,
boolean hasFocus)
Prepares this renderer to display a completion not specifically handled
elsewhere.
|
protected void |
prepareForTemplateCompletion(javax.swing.JList list,
TemplateCompletion tc,
int index,
boolean selected,
boolean hasFocus)
Prepares this renderer to display a template completion.
|
protected void |
prepareForVariableCompletion(javax.swing.JList list,
VariableCompletion vc,
int index,
boolean selected,
boolean hasFocus)
Prepares this renderer to display a variable completion.
|
static void |
setAlternateBackground(java.awt.Color altBG)
Sets the background color to use on alternating lines.
|
void |
setDelegateRenderer(javax.swing.DefaultListCellRenderer delegate)
Sets the delegate renderer.
|
void |
setDisplayFont(java.awt.Font font)
Sets the font to use when rendering completion items.
|
protected void |
setIconWithDefault(Completion completion,
javax.swing.Icon defaultIcon)
Sets the icon to display based off of a completion, falling back to a
default icon if the completion has no icon.
|
void |
setParamColor(java.awt.Color color)
Sets the color to use for function arguments.
|
void |
setShowTypes(boolean show)
Sets whether the types of fields and return types of methods are
shown in the completion text.
|
void |
setTypeColor(java.awt.Color color)
Sets the color to use for function/field types.
|
void |
updateUI()
Overridden to update our delegate, if necessary.
|
firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, invalidate, isOpaque, repaint, repaint, repaint, revalidate, validate
checkHorizontalKey, checkVerticalKey, getAccessibleContext, getDisabledIcon, getDisplayedMnemonic, getDisplayedMnemonicIndex, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextGap, getLabelFor, getText, getUI, getUIClassID, getVerticalAlignment, getVerticalTextPosition, imageUpdate, paramString, setDisabledIcon, setDisplayedMnemonic, setDisplayedMnemonic, setDisplayedMnemonicIndex, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextGap, setLabelFor, setText, setUI, setVerticalAlignment, setVerticalTextPosition
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, 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, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
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, 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, validateTree
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, 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, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
public CompletionCellRenderer()
public CompletionCellRenderer(javax.swing.DefaultListCellRenderer delegate)
DefaultListCellRenderer
s. Everything except for the text
rendering will be done by the delegate. In almost all scenarios, you
will want to use the no-argument constructor instead of this one.delegate
- The delegate renderer.delegateToSubstanceRenderer()
public void delegateToSubstanceRenderer() throws java.lang.Exception
java.lang.Exception
- If Substance is not on the classpath, or some other
error occurs creating the Substance cell renderer.Util.getUseSubstanceRenderers()
,
setDelegateRenderer(DefaultListCellRenderer)
public static java.awt.Color getAlternateBackground()
null
,
alternating colors are not used.setAlternateBackground(Color)
public javax.swing.DefaultListCellRenderer getDelegateRenderer()
null
if there is none.setDelegateRenderer(DefaultListCellRenderer)
public java.awt.Font getDisplayFont()
null
, then the default list
font is used.setDisplayFont(Font)
public java.awt.Component getListCellRendererComponent(javax.swing.JList list, java.lang.Object value, int index, boolean selected, boolean hasFocus)
getListCellRendererComponent
在接口中 javax.swing.ListCellRenderer<java.lang.Object>
getListCellRendererComponent
在类中 javax.swing.DefaultListCellRenderer
list
- The list of choices being rendered.value
- The Completion
being rendered.index
- The index into list
being rendered.selected
- Whether the item is selected.hasFocus
- Whether the item has focus.public boolean getShowTypes()
setShowTypes(boolean)
protected void paintComponent(java.awt.Graphics g)
paintComponent
在类中 javax.swing.JComponent
protected void prepareForFunctionCompletion(javax.swing.JList list, FunctionCompletion fc, int index, boolean selected, boolean hasFocus)
list
- The list of choices being rendered.fc
- The completion to render.index
- The index into list
being rendered.selected
- Whether the item is selected.hasFocus
- Whether the item has focus.protected void prepareForMarkupTagCompletion(javax.swing.JList list, MarkupTagCompletion mc, int index, boolean selected, boolean hasFocus)
list
- The list of choices being rendered.mc
- The completion to render.index
- The index into list
being rendered.selected
- Whether the item is selected.hasFocus
- Whether the item has focus.protected void prepareForOtherCompletion(javax.swing.JList list, Completion c, int index, boolean selected, boolean hasFocus)
list
- The list of choices being rendered.c
- The completion to render.index
- The index into list
being rendered.selected
- Whether the item is selected.hasFocus
- Whether the item has focus.protected void prepareForTemplateCompletion(javax.swing.JList list, TemplateCompletion tc, int index, boolean selected, boolean hasFocus)
list
- The list of choices being rendered.tc
- The completion to render.index
- The index into list
being rendered.selected
- Whether the item is selected.hasFocus
- Whether the item has focus.protected void prepareForVariableCompletion(javax.swing.JList list, VariableCompletion vc, int index, boolean selected, boolean hasFocus)
list
- The list of choices being rendered.vc
- The completion to render.index
- The index into list
being rendered.selected
- Whether the item is selected.hasFocus
- Whether the item has focus.public static void setAlternateBackground(java.awt.Color altBG)
altBG
- The new alternate background color. If this is
null
, alternating lines will not use different
background colors.getAlternateBackground()
public void setDelegateRenderer(javax.swing.DefaultListCellRenderer delegate)
DefaultListCellRenderer
.delegate
- The new delegate renderer. If this is null
,
the default rendering of this component is used.getDelegateRenderer()
,
delegateToSubstanceRenderer()
public void setDisplayFont(java.awt.Font font)
font
- The font to use. If this is null
, then
the default list font is used.getDisplayFont()
protected void setIconWithDefault(Completion completion, javax.swing.Icon defaultIcon)
completion
- The completion to check.defaultIcon
- The icon to use if completion
does not
specify an icon.public void setParamColor(java.awt.Color color)
color
- The color to use. This is ignored if null
.setTypeColor(Color)
public void setShowTypes(boolean show)
show
- Whether to show the types.getShowTypes()
public void setTypeColor(java.awt.Color color)
getShowTypes()
returns false
, this property
effectively does nothing.color
- The color to use for types. This is ignored if
null
.setShowTypes(boolean)
,
setParamColor(Color)
public void updateUI()
updateUI
在类中 javax.swing.JLabel