public abstract class ImageFactory
- Object
- ImageFactory
A factory class for creating mutable images. This can be used to override how mutable images are generated. You can use this to implement, for example, a LRU cache for images so that they can be reused to conserve memory.
There is a default static image factory that can be assigned by calling:
`ImageFactory.setImageFactory(null, new ImageFactory() {
public Image createImage(int w, int h, int bgColor) {
// create an image
// The Default would be just to call
return Image.createImage(w, h, bgColor);`
});
}
You can also assign a factory whose scope is limited to a particular Form, Container,
or Component, by setting the context argument in setImageFactory().
Constructors
public ImageFactory() |
Methods
Inherited methods
Constructor details
ImageFactory
public ImageFactory()Method details
getImageFactory
public static ImageFactory getImageFactory(Component cmp)Gets the image factory for a given component. If the component doesn’t have an ImageFactory assigned, then it will check the parent container, and its descendants, until it finds a Component with an ImageFactory.
If none of the component’s descendants have an ImageFactory, then it will use the default global ImageFactory.
Parameters
cmpComponent- The context from which to load the image factory. Use null to get the global default factory.
Returns
setImageFactory
public static ImageFactory setImageFactory(Component cmp, ImageFactory f)Parameters
cmpComponent- The component to set the ImageFactory for. If this parameter is null, then this method will set the default global ImageFactory
fImageFactory- The ImageFactory to assign to the component.
Returns
createImage
public static Image createImage(Component context, int w, int h, int bgColor)Parameters
contextComponent- The context where the ImageFactory should be loaded from.
wint- The width of the image to create.
hint- The height of the image to create.
bgColorint- The background color of the image.
Returns
createImage
public abstract Image createImage(int w, int h, int bgColor)