net.infonode.gui.componentpainter
Class GradientComponentPainter

java.lang.Object
  extended by net.infonode.gui.componentpainter.AbstractComponentPainter
      extended by net.infonode.gui.componentpainter.GradientComponentPainter
All Implemented Interfaces:
java.io.Serializable, ComponentPainter

public class GradientComponentPainter
extends AbstractComponentPainter
implements java.io.Serializable

A painter that paints an gradient area specified by four corner colors.

Version:
$Revision: 1.11 $
Author:
$Author: jesper $
See Also:
Serialized Form

Field Summary
private  ColorProvider[] colorProviders
           
private  java.awt.Color[] colors
           
private  boolean hasAlpha
           
private  java.lang.ref.SoftReference[] images
           
private static long serialVersionUID
           
private  int size
           
 
Constructor Summary
GradientComponentPainter(java.awt.Color topLeftColor, java.awt.Color topRightColor, java.awt.Color bottomLeftColor, java.awt.Color bottomRightColor)
          Constructor.
GradientComponentPainter(ColorProvider topLeftColor, ColorProvider topRightColor, ColorProvider bottomLeftColor, ColorProvider bottomRightColor)
          Constructor.
 
Method Summary
private  java.awt.Image createGradientImage(java.awt.Color[] colors)
           
private  java.awt.Color[] fixColors(Direction direction, boolean horizontalFlip, boolean verticalFlip)
           
 java.awt.Color getColor(java.awt.Component component)
          Returns an approximate average color of the pixels painted by this painter.
 boolean isOpaque(java.awt.Component component)
          Returns true if this painter paints the entire area with an opaque color.
 void paint(java.awt.Component component, java.awt.Graphics g, int x, int y, int width, int height, Direction direction, boolean horizontalFlip, boolean verticalFlip)
          Paints an area in a specific direction and optinally flipped horizontally and/or vertically.
private  void updateColors(java.awt.Component component)
           
 
Methods inherited from class net.infonode.gui.componentpainter.AbstractComponentPainter
paint
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

colorProviders

private ColorProvider[] colorProviders

colors

private transient java.awt.Color[] colors

size

private int size

images

private transient java.lang.ref.SoftReference[] images

hasAlpha

private transient boolean hasAlpha
Constructor Detail

GradientComponentPainter

public GradientComponentPainter(java.awt.Color topLeftColor,
                                java.awt.Color topRightColor,
                                java.awt.Color bottomLeftColor,
                                java.awt.Color bottomRightColor)
Constructor.

Parameters:
topLeftColor - the top left corner color
topRightColor - the top right corner color
bottomLeftColor - the bottom left corner color
bottomRightColor - the bottom right corner color

GradientComponentPainter

public GradientComponentPainter(ColorProvider topLeftColor,
                                ColorProvider topRightColor,
                                ColorProvider bottomLeftColor,
                                ColorProvider bottomRightColor)
Constructor.

Parameters:
topLeftColor - the top left corner color provider
topRightColor - the top right corner color provider
bottomLeftColor - the bottom left corner color provider
bottomRightColor - the bottom right corner color provider
Method Detail

paint

public void paint(java.awt.Component component,
                  java.awt.Graphics g,
                  int x,
                  int y,
                  int width,
                  int height,
                  Direction direction,
                  boolean horizontalFlip,
                  boolean verticalFlip)
Description copied from interface: ComponentPainter
Paints an area in a specific direction and optinally flipped horizontally and/or vertically. The flips are performed before the rotation is applied.

Specified by:
paint in interface ComponentPainter
Overrides:
paint in class AbstractComponentPainter
Parameters:
component - the component to paint on
g - the graphics to paint on
x - the x-coordinate
y - the y-coordinate
width - the width
height - the height
direction - the direction, Direction.RIGHT is the normal direction
horizontalFlip - flip the painted graphics horizontally
verticalFlip - flip the painted graphics vertically

fixColors

private java.awt.Color[] fixColors(Direction direction,
                                   boolean horizontalFlip,
                                   boolean verticalFlip)

createGradientImage

private java.awt.Image createGradientImage(java.awt.Color[] colors)

updateColors

private void updateColors(java.awt.Component component)

isOpaque

public boolean isOpaque(java.awt.Component component)
Description copied from interface: ComponentPainter
Returns true if this painter paints the entire area with an opaque color.

Specified by:
isOpaque in interface ComponentPainter
Overrides:
isOpaque in class AbstractComponentPainter
Parameters:
component - the component to paint on
Returns:
true if this painter paints the entire area with an opaque color

getColor

public java.awt.Color getColor(java.awt.Component component)
Description copied from interface: ComponentPainter
Returns an approximate average color of the pixels painted by this painter.

Specified by:
getColor in interface ComponentPainter
Parameters:
component - the component to paint on
Returns:
an approximate average color of the pixels painted by this painter