Class CompletionCellRenderer

    • Constructor Detail

      • CompletionCellRenderer

        public CompletionCellRenderer()
        Constructor.
      • CompletionCellRenderer

        public CompletionCellRenderer​(DefaultListCellRenderer delegate)
        Constructor. This is primarily a hook for Substance, or any other Look and Feel whose renderers look drastically different than standard DefaultListCellRenderers. 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.
        Parameters:
        delegate - The delegate renderer.
        See Also:
        delegateToSubstanceRenderer()
    • Method Detail

      • createEmptyIcon

        protected Icon createEmptyIcon()
        Creates the icon to use if no icon is found for a specific completion. The default implementation returns a 16x16 empty icon.
        Returns:
        The icon.
        See Also:
        getEmptyIcon()
      • getAlternateBackground

        public static Color getAlternateBackground()
        Returns the background color to use on alternating lines.
        Returns:
        The alternate background color. If this is null, alternating colors are not used.
        See Also:
        setAlternateBackground(Color)
      • getDisplayFont

        public Font getDisplayFont()
        Returns the font used when rendering completions.
        Returns:
        The font. If this is null, then the default list font is used.
        See Also:
        setDisplayFont(Font)
      • getEmptyIcon

        protected Icon getEmptyIcon()
        Returns the icon to use if no icon is found for a specific completion. This icon is lazily created if necessary.
        Returns:
        The icon.
        See Also:
        createEmptyIcon()
      • getIcon

        protected Icon getIcon​(String resource)
        Returns an icon.
        Parameters:
        resource - The icon to retrieve. This should either be a file, or a resource loadable by the current ClassLoader.
        Returns:
        The icon.
      • getShowTypes

        public boolean getShowTypes()
        Returns whether the types of fields and return types of methods are shown in the completion text.
        Returns:
        Whether to show the types.
        See Also:
        setShowTypes(boolean)
      • prepareForFunctionCompletion

        protected void prepareForFunctionCompletion​(JList list,
                                                    FunctionCompletion fc,
                                                    int index,
                                                    boolean selected,
                                                    boolean hasFocus)
        Prepares this renderer to display a function completion.
        Parameters:
        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.
      • prepareForMarkupTagCompletion

        protected void prepareForMarkupTagCompletion​(JList list,
                                                     MarkupTagCompletion mc,
                                                     int index,
                                                     boolean selected,
                                                     boolean hasFocus)
        Prepares this renderer to display a markup tag completion.
        Parameters:
        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.
      • prepareForOtherCompletion

        protected void prepareForOtherCompletion​(JList list,
                                                 Completion c,
                                                 int index,
                                                 boolean selected,
                                                 boolean hasFocus)
        Prepares this renderer to display a completion not specifically handled elsewhere.
        Parameters:
        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.
      • prepareForTemplateCompletion

        protected void prepareForTemplateCompletion​(JList list,
                                                    TemplateCompletion tc,
                                                    int index,
                                                    boolean selected,
                                                    boolean hasFocus)
        Prepares this renderer to display a template completion.
        Parameters:
        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.
      • prepareForVariableCompletion

        protected void prepareForVariableCompletion​(JList list,
                                                    VariableCompletion vc,
                                                    int index,
                                                    boolean selected,
                                                    boolean hasFocus)
        Prepares this renderer to display a variable completion.
        Parameters:
        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.
      • setAlternateBackground

        public static void setAlternateBackground​(Color altBG)
        Sets the background color to use on alternating lines.
        Parameters:
        altBG - The new alternate background color. If this is null, alternating lines will not use different background colors.
        See Also:
        getAlternateBackground()
      • setDelegateRenderer

        public void setDelegateRenderer​(DefaultListCellRenderer delegate)
        Sets the delegate renderer. Most users will never use this method; it is primarily a hook for Substance and other Look and Feels whose renderers look drastically different from the standard DefaultListCellRenderer.
        Parameters:
        delegate - The new delegate renderer. If this is null, the default rendering of this component is used.
        See Also:
        getDelegateRenderer(), delegateToSubstanceRenderer()
      • setDisplayFont

        public void setDisplayFont​(Font font)
        Sets the font to use when rendering completion items.
        Parameters:
        font - The font to use. If this is null, then the default list font is used.
        See Also:
        getDisplayFont()
      • setIconWithDefault

        protected void setIconWithDefault​(Completion completion)
        Sets the icon to display based off of a completion, falling back to the empty icon if the completion has no icon.
        Parameters:
        completion - The completion to check.
        See Also:
        setIconWithDefault(Completion, Icon)
      • setIconWithDefault

        protected void setIconWithDefault​(Completion completion,
                                          Icon defaultIcon)
        Sets the icon to display based off of a completion, falling back to a default icon if the completion has no icon.
        Parameters:
        completion - The completion to check.
        defaultIcon - The icon to use if completion does not specify an icon.
        See Also:
        setIconWithDefault(Completion)
      • setParamColor

        public void setParamColor​(Color color)
        Sets the color to use for function arguments.
        Parameters:
        color - The color to use. This is ignored if null.
        See Also:
        setTypeColor(Color)
      • setShowTypes

        public void setShowTypes​(boolean show)
        Sets whether the types of fields and return types of methods are shown in the completion text.
        Parameters:
        show - Whether to show the types.
        See Also:
        getShowTypes()
      • setTypeColor

        public void setTypeColor​(Color color)
        Sets the color to use for function/field types. Note that if getShowTypes() returns false, this property effectively does nothing.
        Parameters:
        color - The color to use for types. This is ignored if null.
        See Also:
        setShowTypes(boolean), setParamColor(Color)
      • updateUI

        public void updateUI()
        Overridden to update our delegate, if necessary.
        Overrides:
        updateUI in class JLabel