Package org.jdesktop.swingx.util
Class PaintUtils
- java.lang.Object
-
- org.jdesktop.swingx.util.PaintUtils
-
public class PaintUtils extends java.lang.ObjectA collection of utilties for painting visual effects.
-
-
Field Summary
Fields Modifier and Type Field Description static java.awt.GradientPaintAERITHstatic java.awt.GradientPaintBLUE_EXPERIENCEstatic java.awt.GradientPaintGRAYstatic java.awt.GradientPaintMAC_OSXstatic java.awt.GradientPaintMAC_OSX_SELECTEDstatic java.awt.GradientPaintNIGHT_GRAYstatic java.awt.GradientPaintNIGHT_GRAY_LIGHTstatic java.awt.GradientPaintRED_XP
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.awt.image.BufferedImageconvertToBufferedImage(java.awt.Image img)static java.awt.image.BufferedImagecreateCompatibleImage(int width, int height)static java.awt.image.BufferedImagecreateCompatibleImage(int width, int height, int transparency)static javax.swing.border.BordergetDefaultBorder()static java.awt.RectanglegetTextBounds(java.awt.Graphics g, javax.swing.JLabel label)Returns the bounds that the text of a label will be drawn into.static java.awt.image.BufferedImageloadCompatibleImage(java.io.InputStream in)static java.awt.image.BufferedImageloadCompatibleImage(java.net.URL resource)Loads the image at the URL and makes it compatible with the screen.static voidpaintGradient(java.awt.Graphics g, javax.swing.JComponent comp, java.awt.Color color1, java.awt.Color color2)Paints a top to bottom gradient fill over the component bounds from color1 to color2.static java.awt.PaintresizeGradient(java.awt.Paint p, int width, int height)Resizes a gradient to fill the width and height available.static voidsetBackgroundColor(java.awt.Container cont, java.awt.Color color)Sets the background color for a containment hierarchy.static voidsetFont(java.awt.Container cont, java.awt.Font font)Sets the font for a containment hierarchy.static voidsetForegroundColor(java.awt.Container cont, java.awt.Color color)Sets the foreground color for a containment hierarchy.static java.awt.ShapesetMergedClip(java.awt.Graphics2D g, java.awt.Shape newClip)Sets then clip on a graphics object by merging with the existing clip instead of replacing it.static java.awt.image.BufferedImagetoCompatibleImage(java.awt.image.BufferedImage image)
-
-
-
Field Detail
-
BLUE_EXPERIENCE
public static final java.awt.GradientPaint BLUE_EXPERIENCE
-
MAC_OSX_SELECTED
public static final java.awt.GradientPaint MAC_OSX_SELECTED
-
MAC_OSX
public static final java.awt.GradientPaint MAC_OSX
-
AERITH
public static final java.awt.GradientPaint AERITH
-
GRAY
public static final java.awt.GradientPaint GRAY
-
RED_XP
public static final java.awt.GradientPaint RED_XP
-
NIGHT_GRAY
public static final java.awt.GradientPaint NIGHT_GRAY
-
NIGHT_GRAY_LIGHT
public static final java.awt.GradientPaint NIGHT_GRAY_LIGHT
-
-
Method Detail
-
getDefaultBorder
public static javax.swing.border.Border getDefaultBorder()
-
getTextBounds
public static java.awt.Rectangle getTextBounds(java.awt.Graphics g, javax.swing.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(java.awt.Graphics g, javax.swing.JComponent comp, java.awt.Color color1, java.awt.Color color2)Paints a top to bottom gradient fill over the component bounds from color1 to color2.
-
setBackgroundColor
public static void setBackgroundColor(java.awt.Container cont, java.awt.Color color)Sets the background color for a containment hierarchy.
-
setForegroundColor
public static void setForegroundColor(java.awt.Container cont, java.awt.Color color)Sets the foreground color for a containment hierarchy.
-
setFont
public static void setFont(java.awt.Container cont, java.awt.Font font)Sets the font for a containment hierarchy.
-
createCompatibleImage
public static java.awt.image.BufferedImage createCompatibleImage(int width, int height)- Parameters:
width- the width of the new BufferedImageheight- the height of the new BufferedImage- Returns:
- Creates and returns a BufferedImage that is "compatible" with this machines video card and subsystem
-
createCompatibleImage
public static java.awt.image.BufferedImage createCompatibleImage(int width, int height, int transparency)- Parameters:
width- the width of the new BufferedImageheight- the height of the new BufferedImagetransparency- one of the values in the Transparency interface- Returns:
- Creates and returns a BufferedImage that is "compatible" with this machines video card and subsystem with the given Transparency.
-
convertToBufferedImage
public static java.awt.image.BufferedImage convertToBufferedImage(java.awt.Image img)
-
loadCompatibleImage
public static java.awt.image.BufferedImage loadCompatibleImage(java.net.URL resource) throws java.io.IOExceptionLoads the image at the URL and makes it compatible with the screen. If loading the url fails then this method will either throw an IOException or return null.- Throws:
java.io.IOException
-
loadCompatibleImage
public static java.awt.image.BufferedImage loadCompatibleImage(java.io.InputStream in) throws java.io.IOException- Throws:
java.io.IOException
-
toCompatibleImage
public static java.awt.image.BufferedImage toCompatibleImage(java.awt.image.BufferedImage image)
-
setMergedClip
public static java.awt.Shape setMergedClip(java.awt.Graphics2D g, java.awt.Shape newClip)Sets then clip on a graphics object by merging with the existing clip instead of replacing it. The new clip will be an intersection of the old clip and the passed in clip shape. The old clip shape will be returned
-
resizeGradient
public static java.awt.Paint resizeGradient(java.awt.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.
-
-