Class Utilities
java.lang.Object
org.jdesktop.swingx.util.Utilities
Contribution from NetBeans: Issue #319-swingx.
PENDING: need to reconcile with OS, JVM... added as-is because needed the shortcut handling to fix #
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intreference to map that maps allowed key names to their values (String, Integer) and reference to map for mapping of values to their namesprivate static intstatic final intOperating system is IBM AIX.static final intOperating system is FreeBSDstatic final intOperating system is HP-UX.static final intOperating system is SGI IRIX.static final intOperating system is Linux.static final intOperating system is Mac.static final intOperating system is OS/2.static final intOperating system is unknown.static final intOperating system is Solaris.static final intOperating system is Sun OS.static final intOperating system is Compaq TRU64 Unixstatic final intA mask for Unix platforms.static final intOperating system is Compaq OpenVMSstatic final intOperating system is one of the Windows variants but we don't know which one it isstatic final intOperating system is Windows 2000.static final intOperating system is Windows 95.static final intOperating system is Windows 98.static final intA mask for Windows platforms.static final intOperating system is Windows NT.private static final intA height of the Mac OS X's menustatic final intA height of the windows's taskbar -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanaddModifiers(StringBuffer buf, int modif) Adds characters for modifiers to the buffer.private static GraphicsConfigurationFinds out the monitor where the user currently has the input focus.private static intneed to guard against headlessExceptions when testing.static intGet the operating system on which NetBeans is running.static RectangleReturns the usable area of the screen where applications can place its windows.static RectangleReturns the usable area of the screen where applications can place its windows.private static HashMap[]Initialization of the names and valuesstatic booleanTest whether the operating system supports icons on frames (windows).static booleanisUnix()Test whether NetBeans is running on some variant of Unix.static booleanTest whether NetBeans is running on some variant of Windows.static StringkeyToString(KeyStroke stroke) Converts a Swing key stroke descriptor to a familiar Emacs-like name.private static intReads for modifiers and creates integer with required mask.static KeyStrokeConstruct a new key description from a given universal string description.static KeyStroke[]Convert a space-separated list of Emacs-like key binding names to a list of Swing key strokes.static Object[]toObjectArray(Object array) Convert an array of primitive types to an array of objects.static ObjecttoPrimitiveArray(Object[] array) Convert an array of objects to an array of primitive types.private static StringtrimString(String s) private static booleanusableKeyOnMac(int key, int mask) static String[]wrapStringToArray(String original, int width, BreakIterator breakIterator, boolean removeNewLines) Wrap multi-line strings (and get the individual lines).
-
Field Details
-
CTRL_WILDCARD_MASK
private static final int CTRL_WILDCARD_MASK- See Also:
-
ALT_WILDCARD_MASK
private static final int ALT_WILDCARD_MASK- See Also:
-
OS_WINNT
public static final int OS_WINNTOperating system is Windows NT.- See Also:
-
OS_WIN95
public static final int OS_WIN95Operating system is Windows 95.- See Also:
-
OS_WIN98
public static final int OS_WIN98Operating system is Windows 98.- See Also:
-
OS_SOLARIS
public static final int OS_SOLARISOperating system is Solaris.- See Also:
-
OS_LINUX
public static final int OS_LINUXOperating system is Linux.- See Also:
-
OS_HP
public static final int OS_HPOperating system is HP-UX.- See Also:
-
OS_AIX
public static final int OS_AIXOperating system is IBM AIX.- See Also:
-
OS_IRIX
public static final int OS_IRIXOperating system is SGI IRIX.- See Also:
-
OS_SUNOS
public static final int OS_SUNOSOperating system is Sun OS.- See Also:
-
OS_TRU64
public static final int OS_TRU64Operating system is Compaq TRU64 Unix- See Also:
-
OS_OS2
public static final int OS_OS2Operating system is OS/2.- See Also:
-
OS_MAC
public static final int OS_MACOperating system is Mac.- See Also:
-
OS_WIN2000
public static final int OS_WIN2000Operating system is Windows 2000.- See Also:
-
OS_VMS
public static final int OS_VMSOperating system is Compaq OpenVMS- See Also:
-
OS_WIN_OTHER
public static final int OS_WIN_OTHEROperating system is one of the Windows variants but we don't know which one it is- See Also:
-
OS_OTHER
public static final int OS_OTHEROperating system is unknown.- See Also:
-
OS_FREEBSD
public static final int OS_FREEBSDOperating system is FreeBSD- Since:
- 4.50
- See Also:
-
OS_WINDOWS_MASK
public static final int OS_WINDOWS_MASKA mask for Windows platforms.- See Also:
-
OS_UNIX_MASK
public static final int OS_UNIX_MASKA mask for Unix platforms.- See Also:
-
TYPICAL_WINDOWS_TASKBAR_HEIGHT
public static final int TYPICAL_WINDOWS_TASKBAR_HEIGHTA height of the windows's taskbar- See Also:
-
TYPICAL_MACOSX_MENU_HEIGHT
private static final int TYPICAL_MACOSX_MENU_HEIGHTA height of the Mac OS X's menu- See Also:
-
operatingSystem
private static int operatingSystem -
namesAndValues
-
-
Constructor Details
-
Utilities
private Utilities()
-
-
Method Details
-
getOperatingSystem
public static int getOperatingSystem()Get the operating system on which NetBeans is running.- Returns:
- one of the
OS_*constants (such asOS_WINNT)
-
isWindows
public static boolean isWindows()Test whether NetBeans is running on some variant of Windows.- Returns:
trueif Windows,falseif some other manner of operating system
-
isUnix
public static boolean isUnix()Test whether NetBeans is running on some variant of Unix. Linux is included as well as the commercial vendors, and Mac OS X.- Returns:
truesome sort of Unix,falseif some other manner of operating system
-
isLargeFrameIcons
public static boolean isLargeFrameIcons()Test whether the operating system supports icons on frames (windows).- Returns:
trueif it does not
-
getCurrentGraphicsConfiguration
Finds out the monitor where the user currently has the input focus. This method is usually used to help the client code to figure out on which monitor it should place newly created windows/frames/dialogs.- Returns:
- the GraphicsConfiguration of the monitor which currently has the input focus
-
getUsableScreenBounds
Returns the usable area of the screen where applications can place its windows. The method subtracts from the screen the area of taskbars, system menus and the like. The screen this method applies to is the one which is considered current, ussually the one where the current input focus is.- Returns:
- the rectangle of the screen where one can place windows
- Since:
- 2.5
-
getUsableScreenBounds
Returns the usable area of the screen where applications can place its windows. The method subtracts from the screen the area of taskbars, system menus and the like.- Parameters:
gconf- the GraphicsConfiguration of the monitor- Returns:
- the rectangle of the screen where one can place windows
- Since:
- 2.5
-
initNameAndValues
Initialization of the names and values- Returns:
- array of two hashmaps first maps allowed key names to their values (String, Integer) and second hashtable for mapping of values to their names (Integer, String)
-
keyToString
-
stringToKey
Construct a new key description from a given universal string description. Provides mapping between Emacs-like textual key descriptions and theKeyStrokeobject used in Swing.This format has following form:
[C][A][S][M]-identifierWhere:
-
Cstands for the Control key -
Astands for the Alt key -
Sstands for the Shift key -
Mstands for the Meta key
-
Dstands for the default menu accelerator - the Control key on most platforms, the Command (meta) key on Macintosh -
Ostands for the alternate accelerator - the Alt key on most platforms, the Ctrl key on Macintosh (Macintosh uses Alt as a secondary shift key for composing international characters - if you bind Alt-8 to an action, a mac user with a French keyboard will not be able to type the[character, which is a significant handicap
D-Qwill always map to Control-Q.Every modifier before the hyphen must be pressed. identifier can be any text constant from
KeyEventbut without the leadingVK_characters. SoKeyEvent.VK_ENTERis described asENTER.- Parameters:
s- the string with the description of the key- Returns:
- key description object, or
nullif the string does not represent any valid key
-
-
getMenuShortCutKeyMask
private static int getMenuShortCutKeyMask()need to guard against headlessExceptions when testing.- Returns:
- the acceletor mask for shortcuts.
-
usableKeyOnMac
private static boolean usableKeyOnMac(int key, int mask) -
stringToKeys
-
addModifiers
Adds characters for modifiers to the buffer.- Parameters:
buf- buffer to add tomodif- modifiers to add (KeyEvent.XXX_MASK)- Returns:
- true if something has been added
-
readModifiers
Reads for modifiers and creates integer with required mask.- Parameters:
s- string with modifiers- Returns:
- integer with mask
- Throws:
NoSuchElementException- if some letter is not modifier
-
toPrimitiveArray
Convert an array of objects to an array of primitive types. E.g. anInteger[]would be changed to anint[].- Parameters:
array- the wrapper array- Returns:
- a primitive array
- Throws:
IllegalArgumentException- if the array element type is not a primitive wrapper
-
toObjectArray
Convert an array of primitive types to an array of objects. E.g. anint[]would be turned into anInteger[].- Parameters:
array- the primitive array- Returns:
- a wrapper array
- Throws:
IllegalArgumentException- if the array element type is not primitive
-
wrapStringToArray
public static String[] wrapStringToArray(String original, int width, BreakIterator breakIterator, boolean removeNewLines) Wrap multi-line strings (and get the individual lines).- Parameters:
original- the original string to wrapwidth- the maximum width of linesbreakIterator- breaks original to chars, words, sentences, depending on what instance you provide.removeNewLines- iftrue, any newlines in the original string are ignored- Returns:
- the lines after wrapping
-
trimString
-