bibliothek.util
Class Workarounds

java.lang.Object
  extended by bibliothek.util.Workarounds

public class Workarounds
extends Object

Utility class providing help for bugs or specialities present in some versions of the JRE or in some libraries. Workarounds is implemented as singleton, as there is only one JRE and usually libraries are not loaded multiple times as well.

Author:
Benjamin Sigg

Constructor Summary
Workarounds()
           
 
Method Summary
 void addWorkaround(Workaround workaround)
          Adds a new workaround to this Workarounds.
static Workarounds getDefault()
          Gets access to the currently used Workaroundss.
 Workaround[] getWorkarounds()
          Gets all the Workarounds that are currently active.
 void markAsGlassPane(Component component)
          This method is necessary since 1.6.14, it marks a component as transparent.
 void removeWorkaround(Workaround workaround)
          Removes a workaround from this Workarounds.
static void setDefault(Workarounds workarounds)
          Seets the Workarounds that should be used.
 boolean setTranslucent(Window window)
          Makes window translucent, meaning that the opacity of each pixel is defined by the alpha value or the Color that was used to paint over that pixel.
 boolean setTransparent(Window window, Shape shape)
          Makes window transparent, any pixel not inside shape is not painted.
 void setup(DockController controller)
          Calls the Workaround.setup(DockController) method of all installed Workarounds, in the order of which the workarounds were installed.
 boolean supportsTranslucency(Window window)
          Tells whether there is a least one Workaround that supports perpixel translucency.
 boolean supportsTransparency(Window window)
          Tells whether there is at least one Workaround that supports perpixel transparency.
static boolean tryAddWorkaround(String className)
          Tries first to call Class.forName(String) with className as argument, then creates a new object, casts it to a Workaround, and finally installs that workaround
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Workarounds

public Workarounds()
Method Detail

getDefault

public static Workarounds getDefault()
Gets access to the currently used Workaroundss.

Returns:
the current workarounds

tryAddWorkaround

public static boolean tryAddWorkaround(String className)
Tries first to call Class.forName(String) with className as argument, then creates a new object, casts it to a Workaround, and finally installs that workaround

Parameters:
className - the name of the class to install
Returns:
true if a new Workaround was installed

setDefault

@ClientOnly
public static void setDefault(Workarounds workarounds)
Seets the Workarounds that should be used. This method will never be called from the framework itself. Calling this method has no effect on workarounds that are already applied.
Please note that this method is not thread safe!

Parameters:
workarounds - the new workarounds, not null

addWorkaround

public void addWorkaround(Workaround workaround)
Adds a new workaround to this Workarounds.

Parameters:
workaround - the new workaround, not null

removeWorkaround

public void removeWorkaround(Workaround workaround)
Removes a workaround from this Workarounds.

Parameters:
workaround - the workaround to remove

getWorkarounds

public Workaround[] getWorkarounds()
Gets all the Workarounds that are currently active.

Returns:
all the workarounds

markAsGlassPane

public void markAsGlassPane(Component component)
This method is necessary since 1.6.14, it marks a component as transparent. If not marked then AWT components behind component are not visible.

Parameters:
component - the component to mark completely transparent

supportsTransparency

public boolean supportsTransparency(Window window)
Tells whether there is at least one Workaround that supports perpixel transparency. Transparency means that some pixels are visible, while others are not.

Parameters:
window - the window to test
Returns:
whether transparency is supported

setTransparent

public boolean setTransparent(Window window,
                              Shape shape)
Makes window transparent, any pixel not inside shape is not painted.

Parameters:
window - the window that should be transparent
shape - the visible part of the window, null if the entire window should be visible
Returns:
true if the window was made transparent

supportsTranslucency

public boolean supportsTranslucency(Window window)
Tells whether there is a least one Workaround that supports perpixel translucency. Translucency means that some pixels may have another alpha value than others.

Parameters:
window - the window to test
Returns:
whether translucency is supported

setTranslucent

public boolean setTranslucent(Window window)
Makes window translucent, meaning that the opacity of each pixel is defined by the alpha value or the Color that was used to paint over that pixel.

Parameters:
window - the window that should be translucent
Returns:
true if the winodw is now translucent

setup

public void setup(DockController controller)
Calls the Workaround.setup(DockController) method of all installed Workarounds, in the order of which the workarounds were installed.

Parameters:
controller - a newly created controller