Package org.fife.ui.autocomplete
Class Util
- java.lang.Object
-
- org.fife.ui.autocomplete.Util
-
public final class Util extends java.lang.Object
Utility methods for the auto-complete framework.- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.Object
desktop
private static boolean
desktopCreationAttempted
static java.awt.Color
LIGHT_HYPERLINK_FG
Used for the color of hyperlinks when a LookAndFeel uses light text against a dark background.private static java.lang.Object
LOCK_DESKTOP_CREATION
static java.lang.String
PROPERTY_ALLOW_DECORATED_AUTOCOMPLETE_WINDOWS
If this system property istrue
, then even the "main" two auto-complete windows will allow window decorations viaPopupWindowDecorator
.static java.lang.String
PROPERTY_DONT_USE_SUBSTANCE_RENDERERS
If a system property is defined with this name and set, ignoring case, totrue
, this library will not attempt to use Substance renderers.private static java.util.regex.Pattern
TAG_PATTERN
private static boolean
USE_SUBSTANCE_RENDERERS
-
Constructor Summary
Constructors Modifier Constructor Description private
Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
browse(java.net.URI uri)
Attempts to open a web browser to the specified URI.private static java.lang.Object
getDesktop()
Returns the singletonjava.awt.Desktop
instance, ornull
if it is unsupported on this platform (or the JRE is older than 1.6).(package private) static java.awt.Color
getHyperlinkForeground()
Returns the color to use for hyperlink-style components.static java.awt.Rectangle
getScreenBoundsForPoint(int x, int y)
Returns the screen coordinates for the monitor that contains the specified point.static boolean
getShouldAllowDecoratingMainAutoCompleteWindows()
Give apps a chance to decorate us with drop shadows, etc.static boolean
getUseSubstanceRenderers()
Returns whether we should attempt to use Substance cell renderers and styles for things such as completion choices, if a Substance Look and Feel is installed.static boolean
isLightForeground(java.awt.Color fg)
Returns whether the specified color is "light" to use as a foreground.static boolean
startsWithIgnoreCase(java.lang.String str, java.lang.String prefix)
Returns whether a string starts with a specified prefix, ignoring case.static java.lang.String
stripHtml(java.lang.String text)
Strips any HTML from a string.
-
-
-
Field Detail
-
PROPERTY_DONT_USE_SUBSTANCE_RENDERERS
public static final java.lang.String PROPERTY_DONT_USE_SUBSTANCE_RENDERERS
If a system property is defined with this name and set, ignoring case, totrue
, this library will not attempt to use Substance renderers. Otherwise, if a Substance Look and Feel is installed, we will attempt to use Substance cell renderers in all of our dropdowns.Note that we do not have a build dependency on Substance, so all access to Substance stuff is done via reflection. We will fall back onto default renderers if something goes horribly wrong.
- See Also:
- Constant Field Values
-
PROPERTY_ALLOW_DECORATED_AUTOCOMPLETE_WINDOWS
public static final java.lang.String PROPERTY_ALLOW_DECORATED_AUTOCOMPLETE_WINDOWS
If this system property istrue
, then even the "main" two auto-complete windows will allow window decorations viaPopupWindowDecorator
. If this property is undefined orfalse
, they won't honor such decorations. This is due to certain performance issues with translucent windows (used for drop shadows), even as of Java 7u2.- See Also:
- Constant Field Values
-
LIGHT_HYPERLINK_FG
public static final java.awt.Color LIGHT_HYPERLINK_FG
Used for the color of hyperlinks when a LookAndFeel uses light text against a dark background.
-
TAG_PATTERN
private static final java.util.regex.Pattern TAG_PATTERN
-
USE_SUBSTANCE_RENDERERS
private static final boolean USE_SUBSTANCE_RENDERERS
-
desktopCreationAttempted
private static boolean desktopCreationAttempted
-
desktop
private static java.lang.Object desktop
-
LOCK_DESKTOP_CREATION
private static final java.lang.Object LOCK_DESKTOP_CREATION
-
-
Method Detail
-
browse
public static boolean browse(java.net.URI uri)
Attempts to open a web browser to the specified URI.- Parameters:
uri
- The URI to open. If this isnull
, nothing happens and this method returnsfalse
.- Returns:
- Whether the operation was successful. This will be
false
on JRE's older than 1.6.
-
getDesktop
private static java.lang.Object getDesktop()
Returns the singletonjava.awt.Desktop
instance, ornull
if it is unsupported on this platform (or the JRE is older than 1.6).- Returns:
- The desktop, as an
Object
.
-
getHyperlinkForeground
static java.awt.Color getHyperlinkForeground()
Returns the color to use for hyperlink-style components. This method will returnColor.blue
unless it appears that the current LookAndFeel uses light text on a dark background, in which case a brighter alternative is returned.- Returns:
- The color to use for hyperlinks.
- See Also:
TipUtil.getToolTipHyperlinkForeground()
-
getScreenBoundsForPoint
public static java.awt.Rectangle getScreenBoundsForPoint(int x, int y)
Returns the screen coordinates for the monitor that contains the specified point. This is useful for setups with multiple monitors, to ensure that popup windows are positioned properly.- Parameters:
x
- The x-coordinate, in screen coordinates.y
- The y-coordinate, in screen coordinates.- Returns:
- The bounds of the monitor that contains the specified point.
-
getShouldAllowDecoratingMainAutoCompleteWindows
public static boolean getShouldAllowDecoratingMainAutoCompleteWindows()
Give apps a chance to decorate us with drop shadows, etc. Since very scrolly things such as lists (of e.g. completions) are *very* slow when in per-pixel translucent windows, even as of Java 7u2, we force the user to specify an extra option for the two "main" auto-complete windows.- Returns:
- Whether to allow decorating the main auto-complete windows.
- See Also:
PROPERTY_ALLOW_DECORATED_AUTOCOMPLETE_WINDOWS
-
getUseSubstanceRenderers
public static boolean getUseSubstanceRenderers()
Returns whether we should attempt to use Substance cell renderers and styles for things such as completion choices, if a Substance Look and Feel is installed. If this isfalse
, we'll use our standard rendering for completions, even when Substance is being used.- Returns:
- Whether to use Substance renderers if Substance is installed.
-
isLightForeground
public static boolean isLightForeground(java.awt.Color fg)
Returns whether the specified color is "light" to use as a foreground. Colors that returntrue
indicate that the current Look and Feel probably uses light text colors on a dark background.- Parameters:
fg
- The foreground color.- Returns:
- Whether it is a "light" foreground color.
-
startsWithIgnoreCase
public static boolean startsWithIgnoreCase(java.lang.String str, java.lang.String prefix)
Returns whether a string starts with a specified prefix, ignoring case. This method does not support characters outside the BMP.- Parameters:
str
- The string to check. This cannot benull
.prefix
- The prefix to check for. This cannot benull
.- Returns:
- Whether
str
starts withprefix
, ignoring case.
-
stripHtml
public static java.lang.String stripHtml(java.lang.String text)
Strips any HTML from a string. The string must start with "<html>
" for markup tags to be stripped.- Parameters:
text
- The string.- Returns:
- The string, with any HTML stripped.
-
-