com.webcab.chat.gui
Class ImageCache
java.lang.Object
|
+--java.awt.Image
|
+--com.webcab.chat.gui.ImageCache
- All Implemented Interfaces:
- java.awt.image.ImageConsumer
- public class ImageCache
- extends java.awt.Image
- implements java.awt.image.ImageConsumer
This class encapsulates all data a java.awt.Image holds, by
caching it into memory. It is an alternative to the way Images created
with java.awt.Toolkit.getImage are drawn.
When an image is created with awt's methods, the bytes loaded from the
specified image URL might suffer from low band width. ImageCache
has a very stable loading method, which ensures no data losses occur. This
prevents errors like missing chunks or mismatched colors.
- Author:
- WebCab Components
|
Field Summary |
static int |
ANIMATED
The image is an animated gif. |
static int |
DUNNO
The state of the image is unknown |
static int |
SINGLE
The image is a static one (no frames). |
| Fields inherited from class java.awt.Image |
SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty |
| Fields inherited from interface java.awt.image.ImageConsumer |
COMPLETESCANLINES, IMAGEABORTED, IMAGEERROR, RANDOMPIXELORDER, SINGLEFRAME, SINGLEFRAMEDONE, SINGLEPASS, STATICIMAGEDONE, TOPDOWNLEFTRIGHT |
|
Constructor Summary |
ImageCache(java.lang.String s,
java.awt.Component component)
This constructor loads the image data into memory. |
|
Method Summary |
void |
flush()
|
java.awt.Graphics |
getGraphics()
|
int |
getHeight(java.awt.image.ImageObserver o)
|
java.awt.Image |
getImage()
|
java.lang.Object |
getProperty(java.lang.String name,
java.awt.image.ImageObserver observer)
|
java.awt.Image |
getScaledInstance(int w,
int h,
int hints)
|
java.awt.image.ImageProducer |
getSource()
|
int |
getType()
Returns any of the three available known, out of which you can test whether the
image is an animated frame-by-frame or is static. |
int |
getWidth(java.awt.image.ImageObserver o)
|
void |
imageComplete(int status)
|
static java.awt.Image |
readImage(java.lang.String imageFile,
java.awt.Component component)
A static method provided by this class as a convenience. |
static java.awt.Image |
readImage(java.net.URL imageURL,
java.awt.Component component)
A static method provided by this class as a convenience. |
void |
setColorModel(java.awt.image.ColorModel model)
|
void |
setDimensions(int w,
int h)
|
void |
setHints(int hints)
|
void |
setPixels(int x,
int y,
int w,
int h,
java.awt.image.ColorModel c,
byte[] pixels,
int off,
int scansize)
|
void |
setPixels(int x,
int y,
int w,
int h,
java.awt.image.ColorModel c,
int[] pixels,
int off,
int scansize)
|
void |
setProperties(java.util.Hashtable h)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DUNNO
public static final int DUNNO
- The state of the image is unknown
SINGLE
public static final int SINGLE
- The image is a static one (no frames).
ANIMATED
public static final int ANIMATED
- The image is an animated gif.
ImageCache
public ImageCache(java.lang.String s,
java.awt.Component component)
- This constructor loads the image data into memory.
- Parameters:
imageURL - The URL base where the image is locatedcomp - The component to render with- See Also:
readImage(URL, Component)
readImage
public static java.awt.Image readImage(java.lang.String imageFile,
java.awt.Component component)
- A static method provided by this class as a convenience. The functionality
is similar to that of
java.awt.Toolkit.getImage, offering
a more secure transfer and less data loss.
- Parameters:
imageFile - the name of the URL where the image to be loaded is locatedcomponent - the Component which is going to encapsulate the Image (for
example a java.awt.Canvas)- Returns:
- The image which gets its data from the specified resource, ready to
be deployed inside the
component. - See Also:
readImage(URL, Component)
readImage
public static java.awt.Image readImage(java.net.URL imageURL,
java.awt.Component component)
- A static method provided by this class as a convenience. The functionality
is similar to that of
java.awt.Toolkit.getImage, offering
a more secure transfer and less data loss.
- Parameters:
imageURl - the URL base of the image locationimageFile - the name of the imagecomponent - the Component which is going to encapsulate the Image (for
example a java.awt.Canvas)- Returns:
- The image which gets its data from the specified resource, ready to
be deployed inside the
component. - See Also:
readImage(URL, Component),
readImage(String, Component)
imageComplete
public void imageComplete(int status)
- Specified by:
imageComplete in interface java.awt.image.ImageConsumer
setColorModel
public void setColorModel(java.awt.image.ColorModel model)
- Specified by:
setColorModel in interface java.awt.image.ImageConsumer
setDimensions
public void setDimensions(int w,
int h)
- Specified by:
setDimensions in interface java.awt.image.ImageConsumer
setHints
public void setHints(int hints)
- Specified by:
setHints in interface java.awt.image.ImageConsumer
setPixels
public void setPixels(int x,
int y,
int w,
int h,
java.awt.image.ColorModel c,
byte[] pixels,
int off,
int scansize)
- Specified by:
setPixels in interface java.awt.image.ImageConsumer
setPixels
public void setPixels(int x,
int y,
int w,
int h,
java.awt.image.ColorModel c,
int[] pixels,
int off,
int scansize)
- Specified by:
setPixels in interface java.awt.image.ImageConsumer
setProperties
public void setProperties(java.util.Hashtable h)
- Specified by:
setProperties in interface java.awt.image.ImageConsumer
flush
public void flush()
- Overrides:
flush in class java.awt.Image
getGraphics
public java.awt.Graphics getGraphics()
- Overrides:
getGraphics in class java.awt.Image
getHeight
public int getHeight(java.awt.image.ImageObserver o)
- Overrides:
getHeight in class java.awt.Image
getWidth
public int getWidth(java.awt.image.ImageObserver o)
- Overrides:
getWidth in class java.awt.Image
getProperty
public java.lang.Object getProperty(java.lang.String name,
java.awt.image.ImageObserver observer)
- Overrides:
getProperty in class java.awt.Image
getScaledInstance
public java.awt.Image getScaledInstance(int w,
int h,
int hints)
- Overrides:
getScaledInstance in class java.awt.Image
getSource
public java.awt.image.ImageProducer getSource()
- Overrides:
getSource in class java.awt.Image
getImage
public java.awt.Image getImage()
getType
public int getType()
- Returns any of the three available known, out of which you can test whether the
image is an animated frame-by-frame or is static.
- See Also:
ANIMATED,
SINGLE