Class 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().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract ImagecreateImage(int w, int h, int bgColor) static ImagecreateImage(Component context, int w, int h, int bgColor) Creates an image using the factory at a given context.static ImageFactorygetImageFactory(Component cmp) Gets the image factory for a given component.static ImageFactorysetImageFactory(Component cmp, ImageFactory f) Sets the ImageFactory for the given component.Methods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitModifier and TypeMethodDescriptionprotected Objectclone()booleanIndicates whether some other object is "equal to" this one.final ClassgetClass()Returns the runtime class of an object.inthashCode()Returns a hash code value for the object.final voidnotify()Wakes up a single thread that is waiting on this object's monitor.final voidWakes up all threads that are waiting on this object's monitor.toString()Returns a string representation of the object.final voidwait()Causes current thread to wait until another thread invokes the method or the method for this object.final voidwait(long timeout) Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.final voidwait(long timeout, int nanos) Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
-
Constructor Details
-
ImageFactory
public ImageFactory()
-
-
Method Details
-
getImageFactory
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
cmp: @param cmp The context from which to load the image factory. Use null to get the global default factory.
Returns
An image Factory
-
setImageFactory
Sets the ImageFactory for the given component.
Parameters
-
cmp: @param cmp The component to set the ImageFactory for. If this parameter is null, then this method will set the default global ImageFactory -
f: The ImageFactory to assign to the component.
Returns
The previous image factory that was assigned to the component, or null if none was previously assigned.
-
-
createImage
Creates an image using the factory at a given context.
Parameters
-
context: The context where the ImageFactory should be loaded from. -
w: The width of the image to create. -
h: The height of the image to create. -
bgColor: The background color of the image.
Returns
A mutable Image.
-
-
createImage
-