org.jdesktop.swingx.util
Class PaintUtils

java.lang.Object
  extended by org.jdesktop.swingx.util.PaintUtils

public class PaintUtils
extends Object

A collection of utilties for painting visual effects.


Field Summary
static GradientPaint AERITH
           
static GradientPaint BLUE_EXPERIENCE
           
static GradientPaint GRAY
           
static GradientPaint MAC_OSX
           
static GradientPaint MAC_OSX_SELECTED
           
static GradientPaint NIGHT_GRAY
           
static GradientPaint NIGHT_GRAY_LIGHT
           
static GradientPaint RED_XP
           
 
Method Summary
static Rectangle getTextBounds(Graphics g, JLabel label)
          Returns the bounds that the text of a label will be drawn into.
static void paintGradient(Graphics g, JComponent comp, Color color1, Color color2)
          Paints a top to bottom gradient fill over the component bounds from color1 to color2.
static Paint resizeGradient(Paint p, int width, int height)
          Resizes a gradient to fill the width and height available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLUE_EXPERIENCE

public static final GradientPaint BLUE_EXPERIENCE

MAC_OSX_SELECTED

public static final GradientPaint MAC_OSX_SELECTED

MAC_OSX

public static final GradientPaint MAC_OSX

AERITH

public static final GradientPaint AERITH

GRAY

public static final GradientPaint GRAY

RED_XP

public static final GradientPaint RED_XP

NIGHT_GRAY

public static final GradientPaint NIGHT_GRAY

NIGHT_GRAY_LIGHT

public static final GradientPaint NIGHT_GRAY_LIGHT
Method Detail

getTextBounds

public static Rectangle getTextBounds(Graphics g,
                                      JLabel label)
Returns the bounds that the text of a label will be drawn into. Takes into account the current font metrics.


paintGradient

public static void paintGradient(Graphics g,
                                 JComponent comp,
                                 Color color1,
                                 Color color2)
Paints a top to bottom gradient fill over the component bounds from color1 to color2.


resizeGradient

public static Paint resizeGradient(Paint p,
                                   int width,
                                   int height)
Resizes a gradient to fill the width and height available. If the gradient is left to right it will be resized to fill the entire width. If the gradient is top to bottom it will be resized to fill the entire height. If the gradient is on an angle it will be resized to go from one corner to the other of the rectangle formed by (0,0 -> width,height). This method can resize java.awt.GradientPaint, java.awt.LinearGradientPaint, and the LinearGradientPaint implementation from Apache's Batik project. Note, this method does not require the MultipleGradientPaint.jar from Apache to compile or to run. MultipleGradientPaint.jar *is* required if you want to resize the LinearGradientPaint from that jar. Any paint passed into this method which is not a kind of gradient paint (like a Color or TexturePaint) will be returned unmodified. It will not throw an exception. If the gradient cannot be resized due to other errors the original paint will be returned unmodified. It will not throw an exception.