chrriis.common
Class UIUtils

java.lang.Object
  extended by chrriis.common.UIUtils

public class UIUtils
extends Object

Author:
Christopher Deckers

Method Summary
static Rectangle getBounds(Rectangle[] rectangles)
          Get the bounds containing all the rectangles.
static Rectangle[] getComponentVisibleArea(Component component, Filter<Component> filter, boolean traverseChildren)
          Get the area that is not covered by components obeying the condition imposed by the visitor.
static boolean isComponentTransparent(Component c)
          Get the actual transparent state, which considers the opacity and the transparency hint that may have been set with the setComponentTransparencyHint(xxx) method.
static void revalidate(Component c)
           
static void setComponentTransparencyHint(Component c, Boolean isTransparent)
          Set a transparency hint for the getComponentVisibleArea(xxx) method to decide whether a component is visible.
static void setPreferredLookAndFeel()
           
static Rectangle[] subtract(Rectangle[] rects, Rectangle rect)
          Subtracts the area specified by the rectangle rect from each of the areas specified by the rectangles in rects.
static Rectangle[] subtract(Rectangle[] rects1, Rectangle[] rects2)
          Subtracts the area specified by the rectangles in rects2 from each of the areas specified by the rectangles in rects1.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

subtract

public static Rectangle[] subtract(Rectangle[] rects,
                                   Rectangle rect)
Subtracts the area specified by the rectangle rect from each of the areas specified by the rectangles in rects.

Parameters:
rects - The rectangles to substract from.
rect - The rectangle to substract.
Returns:
an array of rectangles, which may not have the same number of rectangles as in rects.

subtract

public static Rectangle[] subtract(Rectangle[] rects1,
                                   Rectangle[] rects2)
Subtracts the area specified by the rectangles in rects2 from each of the areas specified by the rectangles in rects1.

Parameters:
rects1 - The rectangles to substract from.
rects2 - The rectangles to substract.
Returns:
an array of rectangles, which may not have the same number of rectangles as in rects1.

getComponentVisibleArea

public static Rectangle[] getComponentVisibleArea(Component component,
                                                  Filter<Component> filter,
                                                  boolean traverseChildren)
Get the area that is not covered by components obeying the condition imposed by the visitor. Usually, the filter focuses on all components, or opaque components.

Parameters:
component - the component for which to find the visible areas.
filter - the filter to consider when determining if an area is hidden.
traverseChildren - true if children that are not captured by the filter should look into their own children recursively.
Returns:
an array of rectangles specify the visible area.

setComponentTransparencyHint

public static void setComponentTransparencyHint(Component c,
                                                Boolean isTransparent)
Set a transparency hint for the getComponentVisibleArea(xxx) method to decide whether a component is visible.

Parameters:
c - The component for which to set the transparency hint.
isTransparent - which is true/false/null, where null removes any hint: glass panes of JRootPanes are considered transparent by default for example.

isComponentTransparent

public static boolean isComponentTransparent(Component c)
Get the actual transparent state, which considers the opacity and the transparency hint that may have been set with the setComponentTransparencyHint(xxx) method.


getBounds

public static Rectangle getBounds(Rectangle[] rectangles)
Get the bounds containing all the rectangles.

Parameters:
rectangles - the rectangles to get the bounds for.
Returns:
a rectangle that contains all the rectangles, potentially an empty rectangle.

setPreferredLookAndFeel

public static void setPreferredLookAndFeel()

revalidate

public static void revalidate(Component c)