net.sourceforge.mlf.metouia
Class MetouiaGradients

java.lang.Object
  extended bynet.sourceforge.mlf.metouia.MetouiaGradients
All Implemented Interfaces:
java.awt.Paint, java.awt.Transparency

public class MetouiaGradients
extends java.lang.Object
implements java.awt.Paint

This class represents the basic gradient used through the Metouia look & feel and presents some helpful static method for drawing standard gradients.


Field Summary
 
Fields inherited from interface java.awt.Transparency
BITMASK, OPAQUE, TRANSLUCENT
 
Constructor Summary
MetouiaGradients(java.awt.Color start, java.awt.Color end, boolean isVertical, boolean isAscending)
          Creates a new Metouia gradient.
 
Method Summary
 java.awt.PaintContext createContext(java.awt.image.ColorModel cm, java.awt.Rectangle r, java.awt.geom.Rectangle2D r2d, java.awt.geom.AffineTransform xform, java.awt.RenderingHints hints)
          Creates and returns a PaintContext used to generate the color pattern.
static void drawGradient(java.awt.Graphics g, java.awt.Color start, java.awt.Color end, java.awt.Rectangle rectangle, boolean isVertical, boolean isAscending)
          Draws a gradient on the given rectangle.
static void drawHighlight(java.awt.Graphics graphics, java.awt.Rectangle rectangle, boolean isVertical, boolean isAscending)
          Draws a highlight gradient on the given rectangle.
static void drawHorizontalHighlight(java.awt.Graphics g, java.awt.Component c)
          Draws a horizontal highlight on the given component.
static void drawHorizontalShadow(java.awt.Graphics g, java.awt.Component c)
          Draws a horizontal shadow on the given component.
static void drawShadow(java.awt.Graphics graphics, java.awt.Rectangle rectangle, boolean isVertical, boolean isAscending)
          Draws a shadow gradient on the given rectangle.
static void drawVerticalHighlight(java.awt.Graphics g, java.awt.Component c)
          Draws a vertical highlight on the given component.
static void drawVerticalShadow(java.awt.Graphics g, java.awt.Component c)
          Draws a vertical shadow on the given component.
 int getTransparency()
          Gets the transparency of this gradient.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetouiaGradients

public MetouiaGradients(java.awt.Color start,
                        java.awt.Color end,
                        boolean isVertical,
                        boolean isAscending)
Creates a new Metouia gradient.

Parameters:
start - The start color of the gradient.
end - The end color of the gradient.
isVertical - If the gradient should be vertical or horizontal.
isAscending - If the gradient's transparency should be ascending.
Method Detail

createContext

public java.awt.PaintContext createContext(java.awt.image.ColorModel cm,
                                           java.awt.Rectangle r,
                                           java.awt.geom.Rectangle2D r2d,
                                           java.awt.geom.AffineTransform xform,
                                           java.awt.RenderingHints hints)
Creates and returns a PaintContext used to generate the color pattern.

Specified by:
createContext in interface java.awt.Paint
Parameters:
cm - The ColorModel that receives the Paint data. This is used only as a hint.
r - The device space bounding box of the graphics primitive being rendered.
r2d - The user space bounding box of the graphics primitive being rendered.
xform - The AffineTransform from user space into device space.
hints - The hint that the context object uses to choose between rendering alternatives.
Returns:
The PaintContext for generating color patterns.

getTransparency

public int getTransparency()
Gets the transparency of this gradient.

Specified by:
getTransparency in interface java.awt.Transparency
Returns:
TRANSLUCENT id the end and start colors have an alpha channel otherwise OPAQUE.

drawGradient

public static final void drawGradient(java.awt.Graphics g,
                                      java.awt.Color start,
                                      java.awt.Color end,
                                      java.awt.Rectangle rectangle,
                                      boolean isVertical,
                                      boolean isAscending)
Draws a gradient on the given rectangle.

Parameters:
g - The graphics context.
start - The start color of the gradient.
end - The end color of the gradient.
rectangle - The rectagle on which the gradient will be painted.
isVertical - If the gradient should be vertical or horizontal.
isAscending - If the gradient's transparency should be ascending.

drawHighlight

public static final void drawHighlight(java.awt.Graphics graphics,
                                       java.awt.Rectangle rectangle,
                                       boolean isVertical,
                                       boolean isAscending)
Draws a highlight gradient on the given rectangle.

Parameters:
graphics - The graphics context.
rectangle - The rectagle on which the gradient will be painted.
isVertical - If the gradient should be vertical or horizontal.
isAscending - If the gradient's transparency should be ascending.

drawShadow

public static final void drawShadow(java.awt.Graphics graphics,
                                    java.awt.Rectangle rectangle,
                                    boolean isVertical,
                                    boolean isAscending)
Draws a shadow gradient on the given rectangle.

Parameters:
graphics - The graphics context.
rectangle - The rectagle on which the gradient will be painted.
isVertical - If the gradient should be vertical or horizontal.
isAscending - If the gradient's transparency should be ascending.

drawHorizontalHighlight

public static final void drawHorizontalHighlight(java.awt.Graphics g,
                                                 java.awt.Component c)
Draws a horizontal highlight on the given component.

Parameters:
g - The graphics context.
c - The component ob wich the gradient will be painted.

drawHorizontalShadow

public static final void drawHorizontalShadow(java.awt.Graphics g,
                                              java.awt.Component c)
Draws a horizontal shadow on the given component.

Parameters:
g - The graphics context.
c - The component ob wich the gradient will be painted.

drawVerticalHighlight

public static final void drawVerticalHighlight(java.awt.Graphics g,
                                               java.awt.Component c)
Draws a vertical highlight on the given component.

Parameters:
g - The graphics context.
c - The component ob wich the gradient will be painted.

drawVerticalShadow

public static final void drawVerticalShadow(java.awt.Graphics g,
                                            java.awt.Component c)
Draws a vertical shadow on the given component.

Parameters:
g - The graphics context.
c - The component ob wich the gradient will be painted.