org.netbeans.modules.editor.completion/1 1.6.22

org.netbeans.spi.editor.completion.support
Class CompletionUtilities

java.lang.Object
  extended by org.netbeans.spi.editor.completion.support.CompletionUtilities

public final class CompletionUtilities
extends Object

Various code completion utilities including completion item contents rendering.


Method Summary
static int getPreferredWidth(String leftHtmlText, String rightHtmlText, Graphics g, Font defaultFont)
          Get preferred width of the item by knowing its left and right html texts.
static void renderHtml(ImageIcon icon, String leftHtmlText, String rightHtmlText, Graphics g, Font defaultFont, Color defaultColor, int width, int height, boolean selected)
          Render a completion item using the provided icon and left and right html texts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getPreferredWidth

public static int getPreferredWidth(String leftHtmlText,
                                    String rightHtmlText,
                                    Graphics g,
                                    Font defaultFont)
Get preferred width of the item by knowing its left and right html texts.
It is supposed that the item will have an icon 16x16 and an appropriate space is reserved for it.

Parameters:
leftHtmlText - html text displayed on the left side of the item next to the icon. It may be null which means no left text will be displayed.
rightHtmlText - html text aligned on the right edge of the item's rendering area. It may be null which means no right text will be displayed.
Returns:
>=0 preferred rendering width of the item.

renderHtml

public static void renderHtml(ImageIcon icon,
                              String leftHtmlText,
                              String rightHtmlText,
                              Graphics g,
                              Font defaultFont,
                              Color defaultColor,
                              int width,
                              int height,
                              boolean selected)
Render a completion item using the provided icon and left and right html texts.

Parameters:
icon - icon 16x16 that will be displayed on the left. It may be null which means that no icon will be displayed but the space for the icon will still be reserved (to properly align with other items that will provide an icon).
leftHtmlText - html text that will be displayed on the left side of the item's rendering area next to the icon.
It may be null which indicates that no left text will be displayed.
If there's not enough horizontal space in the rendering area the text will be shrinked and "..." will be displayed at the end.
rightHtmlText - html text that will be aligned to the right edge of the item's rendering area.
It may be null which means that no right text will be displayed.
The right text is always attempted to be fully displayed unlike the left text that may be shrinked if there's not enough rendering space in the horizontal direction.
If there's not enough space even for the right text it will be shrinked and "..." will be displayed at the end of the rendered string.
g - non-null graphics through which the rendering happens.
defaultFont - non-null default font to be used for rendering.
defaultColor - non-null default color to be used for rendering.
width - >=0 available width for rendering.
height - >=0 available height for rendering.
selected - whether the item being rendered is currently selected in the completion's JList. If selected the foreground color is forced to be black for all parts of the rendered strings.

org.netbeans.modules.editor.completion/1 1.6.22

Built on July 11 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.