org.jvnet.substance.painter.utils
Class SubstanceFillBackgroundDelegate

java.lang.Object
  extended by org.jvnet.substance.painter.utils.SubstanceFillBackgroundDelegate

public class SubstanceFillBackgroundDelegate
extends java.lang.Object

Delegate for painting filled backgrounds.

Author:
Kirill Grouchnikov

Field Summary
static SubstanceFillBackgroundDelegate GLOBAL_INSTANCE
          Background delegate.
 
Constructor Summary
SubstanceFillBackgroundDelegate()
          Creates a new opaque fill background delegate.
SubstanceFillBackgroundDelegate(float watermarkAlpha)
          Creates a new translucent fill background delegate.
 
Method Summary
 void fillAndWatermark(java.awt.Graphics g, javax.swing.JComponent c, java.awt.Color fillColor, java.awt.Rectangle rect)
          Updates the background of the specified component on the specified graphic context in the specified rectangle.
 void setWatermarkAlpha(float watermarkAlpha)
          Sets the watermark alpha (translucency) attribute for this delegate.
 void update(java.awt.Graphics g, java.awt.Component c, boolean force)
          Updates the background of the specified component on the specified graphic context.
 void updateIfOpaque(java.awt.Graphics g, java.awt.Component c)
          Updates the background of the specified component on the specified graphic context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GLOBAL_INSTANCE

public static final SubstanceFillBackgroundDelegate GLOBAL_INSTANCE
Background delegate.

Constructor Detail

SubstanceFillBackgroundDelegate

public SubstanceFillBackgroundDelegate()
Creates a new opaque fill background delegate.


SubstanceFillBackgroundDelegate

public SubstanceFillBackgroundDelegate(float watermarkAlpha)
Creates a new translucent fill background delegate.

Parameters:
watermarkAlpha - Alpha composite of this delegate. The default value is 1.0 which results in completely opaque background. However, in some cases, we need to draw partially translucent background, as in menus.
Method Detail

updateIfOpaque

public void updateIfOpaque(java.awt.Graphics g,
                           java.awt.Component c)
Updates the background of the specified component on the specified graphic context. The background is updated only if the component is opaque.

Parameters:
g - Graphic context.
c - Component.

update

public void update(java.awt.Graphics g,
                   java.awt.Component c,
                   boolean force)
Updates the background of the specified component on the specified graphic context. The background is not painted when the force parameter is false and at least one of the following conditions holds:

Parameters:
g - Graphic context.
c - Component.
force - If true, the painting of background is enforced.

fillAndWatermark

public void fillAndWatermark(java.awt.Graphics g,
                             javax.swing.JComponent c,
                             java.awt.Color fillColor,
                             java.awt.Rectangle rect)
Updates the background of the specified component on the specified graphic context in the specified rectangle.

Parameters:
g - Graphic context.
c - Component.
fillColor - Fill color.
rect - The rectangle to fill.

setWatermarkAlpha

public void setWatermarkAlpha(float watermarkAlpha)
Sets the watermark alpha (translucency) attribute for this delegate.

Parameters:
watermarkAlpha - Watermark alpha (translucency) attribute for this delegate.