com.jgoodies.clearlook
Class DefaultClearLookPolicy

java.lang.Object
  extended bycom.jgoodies.clearlook.DefaultClearLookPolicy
All Implemented Interfaces:
ClearLookPolicy
Direct Known Subclasses:
NetBeansClearLookPolicy

public class DefaultClearLookPolicy
extends Object
implements ClearLookPolicy

The default ClearLookPolicy; detects visual clutter and installs better alternatives.

The following situations are detected:

  1. JComponent with a BevelBorder
  2. JScrollPane nested in a JTabbedPane
  3. JScrollPane nested in a JSplitPane
  4. JSplitPane nested in a JSplitPane
  5. JTabbedPane nested in a JSplitPane

Author:
Karsten Lentzsch
See Also:
ClearLookManager, ClearLookPolicy

Field Summary
protected static Border EMPTY_BORDER
           
protected static Border MARKER_BORDER
           
protected static Border PINK1_BORDER
           
protected static Border PINK2_BORDER
           
protected static Border RED1_BORDER
           
protected static Border RED2_BORDER
           
 
Constructor Summary
DefaultClearLookPolicy()
          Constructs the DefaultClearLookPolicy.
 
Method Summary
 Border analyse(JComponent component)
          Detects decorators that are considered to be visual clutter.
 Border analyse(JScrollPane scrollPane)
          Detects if the specified JScrollPane is nested in a JTabbedPane or in a JSplitPane with a non-empty Border.
 Border analyse(JSplitPane splitPane)
          Detects if the specified JSplitPane is nested in another JSplitPane that has a non-empty border.
 Border analyse(JTabbedPane tab)
          Detects if the specified JTabbedPane is a special NetBeans component that is considered to have visual clutter.
protected  Border assignBorder(JComponent c, Border newBorder)
          Assigns the new border to the component - unless the component is a tabbed pane.
protected  Border getDoubleDecorationBorder()
          Answers the Border that will be used to replace a double decorated component.
 String getName()
          Returns the policy's name.
protected  Border getScrollPaneReplacementBorder()
          Answers the Border that will be used to replace the Border of a JScrollPane that is contained in a JSplitPane.
protected  Border getSplitPaneReplacementBorder()
          Answers the replacement Border for SplitPane in SplitPane.
protected  Border getThinBevelBorder(BevelBorder bevelBorder)
          Answers the Border that will be used to replace a BevelBorder.
protected  Border getThinLoweredBevelBorder()
          Answers the replacement Border for lowered BevelBorders.
protected  Border getThinRaisedBevelBorder()
          Answers the replacement Border for raised BevelBorders.
protected  boolean hasEmptyBorder(JComponent component)
          Checks and answers if the given component has an empty border.
protected  boolean isChildDecoration(Border border)
          Checks and answers whether the specified Border wraps childs with a decoration.
protected  boolean isDebug()
          Checks and answers if we are in debug mode.
protected  boolean isDecoratedChild(Component c)
          Returns if the specified JComponent is decorated.
protected  boolean isDecoratedSplitPane(Component c)
          Returns whether the specified Component is a JSplitPane that has a non-empty border.
protected  boolean isDecoratingParent(Component c)
          Returns if the specified JComponent is decorated.
protected  boolean isDecoration(Border border)
          Checks and answers whether the specified Border provides a visual decoration, for example a wrapping line.
protected  boolean isDoubleDecorated(JComponent c)
          Detects and returns if the specified component has double decoration, that is the component has a decorated border and is nested in a container that has a decorating border.
protected  boolean isEmptyBorder(Border b)
          Checks and answers if the specified Border is kind-of empty.
protected  boolean isInternalFrameContent(Component c)
          Checks and answer whether the given component is the content pane of a JInternalFrame.
protected  boolean isKindOfSplitPane(Component component)
          Answers whether the specified is kind-of SplitPane.
protected  boolean isParentDecoration(Border border)
          Checks and answers whether the specified Border wraps childs with a decoration.
protected  void log(String message)
          Logs a message if we are in verbose mode.
 Border replaceBorder(JComponent component)
          Detects and conditionally replaces the Border of the specified JComponent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_BORDER

protected static final Border EMPTY_BORDER

MARKER_BORDER

protected static final Border MARKER_BORDER

RED1_BORDER

protected static final Border RED1_BORDER

RED2_BORDER

protected static final Border RED2_BORDER

PINK1_BORDER

protected static final Border PINK1_BORDER

PINK2_BORDER

protected static final Border PINK2_BORDER
Constructor Detail

DefaultClearLookPolicy

public DefaultClearLookPolicy()
Constructs the DefaultClearLookPolicy.

Method Detail

getName

public String getName()
Description copied from interface: ClearLookPolicy
Returns the policy's name.

Specified by:
getName in interface ClearLookPolicy
Returns:
this policy's name

replaceBorder

public Border replaceBorder(JComponent component)
Detects and conditionally replaces the Border of the specified JComponent. Returns the original Border, or null if we did not replace it.

Specified by:
replaceBorder in interface ClearLookPolicy
Parameters:
component - the component to be inspected
Returns:
the original border in case of a replacement, null otherwise

assignBorder

protected Border assignBorder(JComponent c,
                              Border newBorder)
Assigns the new border to the component - unless the component is a tabbed pane. In the latter case the new border is returned, which in turn will be used by tabbed panes to recognize that the content border shall be hidden.

Parameters:
c - the component that shall get a new border
newBorder - the border to be set
Returns:
null if the new border is null, the new border in case of a tabbed pane, otherwise the component's border

analyse

public Border analyse(JComponent component)
Detects decorators that are considered to be visual clutter.

Parameters:
component - the component to analyze
Returns:
the suggested replacement border

analyse

public Border analyse(JScrollPane scrollPane)
Detects if the specified JScrollPane is nested in a JTabbedPane or in a JSplitPane with a non-empty Border. In both cases, returns a replacement border.

Parameters:
scrollPane - the component to analyze
Returns:
the suggested replacement border

analyse

public Border analyse(JSplitPane splitPane)
Detects if the specified JSplitPane is nested in another JSplitPane that has a non-empty border.

Parameters:
splitPane - the component to analyze
Returns:
the suggested replacement border

analyse

public Border analyse(JTabbedPane tab)
Detects if the specified JTabbedPane is a special NetBeans component that is considered to have visual clutter.

Parameters:
tab - the component to analyze
Returns:
the suggested replacement border

isEmptyBorder

protected boolean isEmptyBorder(Border b)
Checks and answers if the specified Border is kind-of empty.

Parameters:
b - the border to inspect
Returns:
true if the border is null or an EmptyBorder

isDecoration

protected boolean isDecoration(Border border)
Checks and answers whether the specified Border provides a visual decoration, for example a wrapping line.

Since the detected border classes are not final, we don't use the #instanceof operator to avoid replacing subclasses, that could be visually improved.

Parameters:
border - the border to check
Returns:
true if the border is considered a decoration, otherwise false

isChildDecoration

protected boolean isChildDecoration(Border border)
Checks and answers whether the specified Border wraps childs with a decoration.

Parameters:
border - the border to check
Returns:
true if the border decorates childs, otherwise false

isParentDecoration

protected boolean isParentDecoration(Border border)
Checks and answers whether the specified Border wraps childs with a decoration.

Parameters:
border - the border to check
Returns:
true if the border decorates childs, otherwise false

hasEmptyBorder

protected boolean hasEmptyBorder(JComponent component)
Checks and answers if the given component has an empty border.

Parameters:
component - the component to inspect
Returns:
true if the component has an empty border

isDecoratedChild

protected boolean isDecoratedChild(Component c)
Returns if the specified JComponent is decorated. This default implementation checks, if the component's border is decorated.

Subclasses may check for special decorators.

Parameters:
c - the component to analyse
Returns:
true if the child is decorated

isDecoratingParent

protected boolean isDecoratingParent(Component c)
Returns if the specified JComponent is decorated. This default implementation checks, if the component's border is decorated.

Subclasses may check for special decorators.

Parameters:
c - the parent component to analyse
Returns:
true if the parent is decorating its child(ren)

isInternalFrameContent

protected boolean isInternalFrameContent(Component c)
Checks and answer whether the given component is the content pane of a JInternalFrame.

Parameters:
c - the component to check
Returns:
true if the component is frame content, false otherwise

isKindOfSplitPane

protected boolean isKindOfSplitPane(Component component)
Answers whether the specified is kind-of SplitPane. Subclasses may override to widen the set of panels, that is considered as candidates to remove child borders.

Parameters:
component - the component to be analysed
Returns:
true if the component is to be treated like a split pane

isDecoratedSplitPane

protected boolean isDecoratedSplitPane(Component c)
Returns whether the specified Component is a JSplitPane that has a non-empty border.

Parameters:
c - the component to be analysed
Returns:
true if the component is a decorated split pane

isDoubleDecorated

protected boolean isDoubleDecorated(JComponent c)
Detects and returns if the specified component has double decoration, that is the component has a decorated border and is nested in a container that has a decorating border.

Parameters:
c - the component to be analysed
Returns:
true if the component is decorated as well as its parent

getDoubleDecorationBorder

protected Border getDoubleDecorationBorder()
Answers the Border that will be used to replace a double decorated component.

Returns:
the border used to replace a double decoration

getScrollPaneReplacementBorder

protected Border getScrollPaneReplacementBorder()
Answers the Border that will be used to replace the Border of a JScrollPane that is contained in a JSplitPane.

Returns:
the border used to replace a scroll pane border

getSplitPaneReplacementBorder

protected Border getSplitPaneReplacementBorder()
Answers the replacement Border for SplitPane in SplitPane.

Returns:
the border used to replace a split pane decoration

getThinBevelBorder

protected Border getThinBevelBorder(BevelBorder bevelBorder)
Answers the Border that will be used to replace a BevelBorder.

Parameters:
bevelBorder - indicates a raised or lowered mode
Returns:
the border used to replace a BevelBorder

getThinLoweredBevelBorder

protected Border getThinLoweredBevelBorder()
Answers the replacement Border for lowered BevelBorders.

Returns:
the thin lowered bevel border to be used

getThinRaisedBevelBorder

protected Border getThinRaisedBevelBorder()
Answers the replacement Border for raised BevelBorders.

Returns:
the thin raised bevel border to be used

log

protected final void log(String message)
Logs a message if we are in verbose mode.

Parameters:
message - the message to be logged

isDebug

protected final boolean isDebug()
Checks and answers if we are in debug mode.

Returns:
true if ClearLook is in debug mode


Copyright © 2001-2004 JGoodies Karsten Lentzsch. All Rights Reserved.