|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectTask.Support.GUISupport.ImageUtils
public class ImageUtils
ImageUtils allows icons stored in jar files on the classpaths to be loaded as ImageIcon objects and caches them
| Field Summary | |
|---|---|
static java.util.HashMap<java.lang.String,java.awt.image.BufferedImage> |
bufferedImageCache
|
static java.util.concurrent.locks.ReadWriteLock |
bufferedImageCacheLock
|
| Constructor Summary | |
|---|---|
ImageUtils()
|
|
| Method Summary | |
|---|---|
java.awt.image.BufferedImage |
createBufferedImage(java.awt.Image image)
Utility method provided to convert Images to BufferedImages. |
static java.awt.image.BufferedImage |
createCompatibleImage(int width,
int height,
boolean opaque)
convenience method for creating an opaque or transparent compatible BufferedImage |
static java.awt.image.BufferedImage |
createCompatibleImage(int width,
int height,
int transparency)
convenience constructor for creating a compatible BufferedImage given the Transparency setting |
static java.awt.image.BufferedImage |
createFastResizedCopy(java.awt.image.BufferedImage originalImage,
int scaledWidth,
int scaledHeight,
boolean keepAspectRatio)
Resizes the originalImage to fit the scaled Width and Height. |
static java.awt.image.BufferedImage |
createHighResThumbnail(java.awt.image.BufferedImage image,
int newWidth,
int newHeight,
boolean keepAspectRatio)
This creates a high quality thumbnail of the given image. |
static java.awt.image.BufferedImage |
decodeBufferedImage(ZipObject<ByteBuffer> zipObject)
Decodes the PNG-encoded-ByteBuffer into a BufferedImage. |
static ZipObject<ByteBuffer> |
encodeBufferedImage(java.awt.image.BufferedImage img)
Encodes the BufferedImage into a PNG file and writes that to a ByteBuffer. |
static java.awt.Graphics2D |
g2(java.awt.image.BufferedImage img)
|
static java.awt.Graphics2D |
g2(java.awt.Graphics g)
|
static java.awt.Graphics2D |
g2(java.awt.SplashScreen img)
|
static java.awt.Graphics2D |
g2plain(java.awt.Graphics g)
|
static java.awt.image.BufferedImage |
getCopyOfBufferedImage(java.awt.image.BufferedImage img)
simply returns a copy of the given BufferedImage |
static java.awt.image.BufferedImage |
getCopyOfBufferedImage(java.awt.image.BufferedImage img,
boolean opaque)
returns a copy of the given buffered image with preferred transparency setting (regardless of whether the orginal BufferedImage has any transparency in it or not. |
static java.awt.image.BufferedImage |
getImageOfComponent(javax.swing.JComponent comp)
|
static java.awt.image.BufferedImage |
getImageOfComponent(javax.swing.JComponent comp,
boolean opaque)
|
static java.awt.image.BufferedImage |
getScaledBufferedImage(java.awt.image.BufferedImage img,
int targetWidth,
int targetHeight)
This returns a scaled version of the original icon image. |
static java.awt.image.BufferedImage |
getScaledBufferedImage(java.awt.image.BufferedImage img,
int targetWidth,
int targetHeight,
boolean blur,
float translucency)
This returns a scaled version of the original icon image. |
static java.awt.image.BufferedImage |
loadBufferedImage(java.lang.String imageName,
boolean blur,
float translucency)
Tries to load the |
static javax.swing.Icon |
loadScaledBufferedIcon(java.lang.String icon,
int width,
int height,
boolean blur,
float transparency)
|
static java.awt.Dimension |
scaleToFit(int sourceW,
int sourceH,
int targetW,
int targetH)
uses scaleToFit(int,int,int,int,boolean) to figure out the final width/height of the
source image that should be fit in the target width/height provided, while maintaining the aspect
ration of the source image. |
static float |
scaleToFit(int sourceW,
int sourceH,
int targetW,
int targetH,
boolean respectSourceAspectRatio)
This method gets a scaling factor that you can apply to a source image to make it fit the bounds of the target W/H, while maintaining the aspect ratio. |
static java.awt.image.BufferedImage |
toCompatibleImage(java.awt.image.BufferedImage image)
returns a copy of a non-compatible BufferedImage as a compatible one |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static java.util.HashMap<java.lang.String,java.awt.image.BufferedImage> bufferedImageCache
public static java.util.concurrent.locks.ReadWriteLock bufferedImageCacheLock
| Constructor Detail |
|---|
public ImageUtils()
| Method Detail |
|---|
public static java.awt.Graphics2D g2(java.awt.Graphics g)
public static java.awt.Graphics2D g2plain(java.awt.Graphics g)
public static java.awt.Graphics2D g2(java.awt.image.BufferedImage img)
public static java.awt.Graphics2D g2(java.awt.SplashScreen img)
public static ZipObject<ByteBuffer> encodeBufferedImage(java.awt.image.BufferedImage img)
throws java.lang.IllegalArgumentException,
java.io.IOException,
ZipObjectException
img - source bufferedimage
java.io.IOException - if there is a problem with encoding the image to PNG, this exception is
thrown
java.lang.IllegalArgumentException
ZipObjectExceptiondecodeBufferedImage(ZipObject)
public static java.awt.image.BufferedImage decodeBufferedImage(ZipObject<ByteBuffer> zipObject)
throws java.lang.IllegalArgumentException,
java.io.IOException,
ZipObjectException
zipObject - PNG encoded bytebuffer
java.io.IOException - if there is a problem with decoding the image from PNG, this exception is
thrown
java.lang.IllegalArgumentException
ZipObjectExceptionencodeBufferedImage(BufferedImage)
public static float scaleToFit(int sourceW,
int sourceH,
int targetW,
int targetH,
boolean respectSourceAspectRatio)
public static java.awt.Dimension scaleToFit(int sourceW,
int sourceH,
int targetW,
int targetH)
scaleToFit(int,int,int,int,boolean) to figure out the final width/height of the
source image that should be fit in the target width/height provided, while maintaining the aspect
ration of the source image.
public static java.awt.image.BufferedImage getImageOfComponent(javax.swing.JComponent comp)
public static java.awt.image.BufferedImage getImageOfComponent(javax.swing.JComponent comp,
boolean opaque)
public static java.awt.image.BufferedImage toCompatibleImage(java.awt.image.BufferedImage image)
public static java.awt.image.BufferedImage createCompatibleImage(int width,
int height,
boolean opaque)
opaque - true = opaque, false = transparent
public static java.awt.image.BufferedImage createCompatibleImage(int width,
int height,
int transparency)
public static java.awt.image.BufferedImage getCopyOfBufferedImage(java.awt.image.BufferedImage img,
boolean opaque)
public static java.awt.image.BufferedImage getCopyOfBufferedImage(java.awt.image.BufferedImage img)
public java.awt.image.BufferedImage createBufferedImage(java.awt.Image image)
public static java.awt.image.BufferedImage loadBufferedImage(java.lang.String imageName,
boolean blur,
float translucency)
throws java.lang.ClassNotFoundException,
java.lang.IllegalArgumentException
imageName - name of image file.
java.lang.ClassNotFoundException - if the imageName.png file could not be found
java.lang.IllegalArgumentException - if the imageName is empty or null
public static java.awt.image.BufferedImage getScaledBufferedImage(java.awt.image.BufferedImage img,
int targetWidth,
int targetHeight)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public static java.awt.image.BufferedImage getScaledBufferedImage(java.awt.image.BufferedImage img,
int targetWidth,
int targetHeight,
boolean blur,
float translucency)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public static java.awt.image.BufferedImage createFastResizedCopy(java.awt.image.BufferedImage originalImage,
int scaledWidth,
int scaledHeight,
boolean keepAspectRatio)
createHighResThumbnail(java.awt.image.BufferedImage, int, int, boolean) for details on creating high res
thumbnails.
public static java.awt.image.BufferedImage createHighResThumbnail(java.awt.image.BufferedImage image,
int newWidth,
int newHeight,
boolean keepAspectRatio)
public static javax.swing.Icon loadScaledBufferedIcon(java.lang.String icon,
int width,
int height,
boolean blur,
float transparency)
throws java.lang.ClassNotFoundException
java.lang.ClassNotFoundException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||