com.alee.utils
Class ProprietaryUtils

java.lang.Object
  extended by com.alee.utils.ProprietaryUtils

public final class ProprietaryUtils
extends java.lang.Object

This utility class operates only with proprietary API calls. Their usage is inevitable, otherwise i would have replaced them with something else.

Author:
Mikle Garin

Field Summary
static int HEAVY_WEIGHT_POPUP
           
static int LIGHT_WEIGHT_POPUP
          Key used to indicate a light weight popup should be used.
static int MEDIUM_WEIGHT_POPUP
          Key used to indicate a medium weight Popup should be used.
 
Constructor Summary
ProprietaryUtils()
           
 
Method Summary
static javax.swing.Popup createHeavyweightPopup(java.awt.Component invoker, java.awt.Component content, int x, int y)
          Returns heavyweight popup instance.
static float getWindowOpacity(java.awt.Window window)
          Returns window opacity.
static java.awt.Shape getWindowShape(java.awt.Window window)
          Returns window shape.
static boolean isAllowLinuxTransparency()
          Returns whether per-pixel transparent windows usage is allowed on Linux systems or not.
static boolean isWindowOpaque(java.awt.Window window)
          Returns whether window is opaque or not.
static boolean isWindowShapeAllowed()
          Returns whether window shape is allowed globally or not.
static boolean isWindowTransparencyAllowed()
          Returns whether window transparency is allowed globally or not.
static void setAllowLinuxTransparency(boolean allow)
          Sets whether per-pixel transparent windows usage is allowed on Linux systems or not.
protected static void setupOpacityBackgroundColor(boolean opaque, java.awt.Component component)
          Changes component background color to match opacity.
static void setupUIDefaults(javax.swing.UIDefaults table)
          Installs some proprietary L&F defaults for proper text rendering.
static void setWindowOpacity(java.awt.Window window, float opacity)
          Sets window opacity if that option is supported by the underlying system.
static void setWindowOpaque(java.awt.Window window, boolean opaque)
          Sets window opaque if that option is supported by the underlying system.
static void setWindowShape(java.awt.Window window, java.awt.Shape shape)
          Sets window shape if that option is supported by the underlying system.
static void setWindowShapeAllowed(boolean allowed)
          Sets whether window shape is allowed globally or not.
static void setWindowTransparencyAllowed(boolean allowed)
          Sets whether window transparency is allowed globally or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LIGHT_WEIGHT_POPUP

public static final int LIGHT_WEIGHT_POPUP
Key used to indicate a light weight popup should be used.

See Also:
Constant Field Values

MEDIUM_WEIGHT_POPUP

public static final int MEDIUM_WEIGHT_POPUP
Key used to indicate a medium weight Popup should be used.

See Also:
Constant Field Values

HEAVY_WEIGHT_POPUP

public static final int HEAVY_WEIGHT_POPUP
See Also:
Constant Field Values
Constructor Detail

ProprietaryUtils

public ProprietaryUtils()
Method Detail

isAllowLinuxTransparency

public static boolean isAllowLinuxTransparency()
Returns whether per-pixel transparent windows usage is allowed on Linux systems or not.

Returns:
true if per-pixel transparent windows usage is allowed on Linux systems, false otherwise

setAllowLinuxTransparency

public static void setAllowLinuxTransparency(boolean allow)
Sets whether per-pixel transparent windows usage is allowed on Linux systems or not. This might be an unstable feature so it is disabled by default. Use it at your own risk.

Parameters:
allow - whether per-pixel transparent windows usage is allowed on Linux systems or not

setupUIDefaults

public static void setupUIDefaults(javax.swing.UIDefaults table)
Installs some proprietary L&F defaults for proper text rendering. Basically this method is a workaround for this simple call: table.put ( sun.swing.SwingUtilities2.AA_TEXT_PROPERTY_KEY, sun.swing.SwingUtilities2.AATextInfo.getAATextInfo ( true ) ); but it doesn't directly use any proprietary API.

Parameters:
table - defaults table

isWindowTransparencyAllowed

public static boolean isWindowTransparencyAllowed()
Returns whether window transparency is allowed globally or not. Whether or not it is allowed depends on the settings and current OS type.

Returns:
true if window transparency is allowed globally, false otherwise

setWindowTransparencyAllowed

public static void setWindowTransparencyAllowed(boolean allowed)
Sets whether window transparency is allowed globally or not.

Parameters:
allowed - whether window transparency is allowed globally or not

isWindowShapeAllowed

public static boolean isWindowShapeAllowed()
Returns whether window shape is allowed globally or not. Whether or not it is allowed depends on the settings and current OS type.

Returns:
true if window shape is allowed globally, false otherwise

setWindowShapeAllowed

public static void setWindowShapeAllowed(boolean allowed)
Sets whether window shape is allowed globally or not.

Parameters:
allowed - whether window shape is allowed globally or not

setWindowOpaque

public static void setWindowOpaque(java.awt.Window window,
                                   boolean opaque)
Sets window opaque if that option is supported by the underlying system.

Parameters:
window - window to process
opaque - whether should make window opaque or not

setupOpacityBackgroundColor

protected static void setupOpacityBackgroundColor(boolean opaque,
                                                  java.awt.Component component)
                                           throws java.lang.NoSuchMethodException,
                                                  java.lang.reflect.InvocationTargetException,
                                                  java.lang.IllegalAccessException
Changes component background color to match opacity.

Parameters:
opaque - whether component should should be opaque or not
component - component to process
Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException

isWindowOpaque

public static boolean isWindowOpaque(java.awt.Window window)
Returns whether window is opaque or not.

Parameters:
window - window to process
Returns:
whether window background is opaque or not

setWindowOpacity

public static void setWindowOpacity(java.awt.Window window,
                                    float opacity)
Sets window opacity if that option is supported by the underlying system.

Parameters:
window - window to process
opacity - new window opacity

getWindowOpacity

public static float getWindowOpacity(java.awt.Window window)
Returns window opacity.

Parameters:
window - window to process
Returns:
window opacity

setWindowShape

public static void setWindowShape(java.awt.Window window,
                                  java.awt.Shape shape)
Sets window shape if that option is supported by the underlying system.

Parameters:
window - window to process
shape - new window shape

getWindowShape

public static java.awt.Shape getWindowShape(java.awt.Window window)
Returns window shape.

Parameters:
window - window to process
Returns:
window shape

createHeavyweightPopup

public static javax.swing.Popup createHeavyweightPopup(java.awt.Component invoker,
                                                       java.awt.Component content,
                                                       int x,
                                                       int y)
Returns heavyweight popup instance. By default Swing popups are MEDIUM_WEIGHT_POPUP and there is no convenient way to create popups of other types. Though this can be done by calling similar method on the PopupFactory instance which simply takes the popup type. This method is safe to use and should work on any JDK version.

Parameters:
invoker - invoker component
content - popup content
x - popup initial location X coordinate
y - popup initial location Y coordinate
Returns:
heavyweight popup instance