|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.swing.colorchooser.SyntheticImage
A helper class to make computing synthetic images a little easier. All you need to do is define a subclass that overrides computeRow to compute a row of the image. It is passed the y coordinate of the row and an array into which to put the pixels in standard ARGB format.
Normal usage looks something like this:
Image i = createImage(new SyntheticImage(200, 100) {
protected void computeRow(int y, int[] row) {
for(int i = width; --i>=0; ) {
int grey = i*255/(width-1);
row[i] = (255<<24)|(grey<<16)|(grey<<8)|grey;
}
}
}
This creates a image 200 pixels wide and 100 pixels high
that is a horizontal grey ramp, going from black on the left to
white on the right.
If the image is to be a movie, override isStatic to return false, y cycling back to 0 is computeRow's signal that the next frame has started. It is acceptable (expected?) for computeRow(0,r) to pause until the appropriate time to start the next frame.
| Field Summary | |
protected boolean |
aborted
|
(package private) static ColorModel |
cm
|
protected int |
height
|
static int |
pixMask
|
private SyntheticImageGenerator |
root
|
private Thread |
runner
|
protected int |
width
|
| Constructor Summary | |
protected |
SyntheticImage()
|
protected |
SyntheticImage(int w,
int h)
|
| Method Summary | |
void |
addConsumer(ImageConsumer ic)
Registers an ImageConsumer with the
ImageProducer for access to the image data
during a later reconstruction of the Image.
|
protected void |
computeRow(int y,
int[] row)
|
boolean |
isConsumer(ImageConsumer ic)
Determines if a specified ImageConsumer
object is currently registered with this
ImageProducer as one of its consumers. |
protected boolean |
isStatic()
|
void |
nextFrame(int param)
|
void |
removeConsumer(ImageConsumer ic)
Removes the specified ImageConsumer object
from the list of consumers currently registered to
receive image data. |
void |
requestTopDownLeftRightResend(ImageConsumer ic)
Requests, on behalf of the ImageConsumer,
that the ImageProducer attempt to resend
the image data one more time in TOPDOWNLEFTRIGHT order
so that higher quality conversion algorithms which
depend on receiving pixels in order can be used to
produce a better output version of the image. |
void |
startProduction(ImageConsumer ic)
Registers the specified ImageConsumer object
as a consumer and starts an immediate reconstruction of
the image data which will then be delivered to this
consumer and any other consumer which might have already
been registered with the producer. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private SyntheticImageGenerator root
protected int width
protected int height
static final ColorModel cm
public static final int pixMask
private Thread runner
protected volatile boolean aborted
| Constructor Detail |
protected SyntheticImage()
protected SyntheticImage(int w,
int h)
| Method Detail |
protected void computeRow(int y,
int[] row)
public void addConsumer(ImageConsumer ic)
ImageProducerImageConsumer with the
ImageProducer for access to the image data
during a later reconstruction of the Image.
The ImageProducer may, at its discretion,
start delivering the image data to the consumer
using the ImageConsumer interface immediately,
or when the next available image reconstruction is triggered
by a call to the startProduction method.
addConsumer in interface ImageProduceric - the specified ImageConsumerImageProducer.startProduction(java.awt.image.ImageConsumer)public boolean isConsumer(ImageConsumer ic)
ImageProducerImageConsumer
object is currently registered with this
ImageProducer as one of its consumers.
isConsumer in interface ImageProduceric - the specified ImageConsumer
true if the specified
ImageConsumer is registered with
this ImageProducer;
false otherwise.public void removeConsumer(ImageConsumer ic)
ImageProducerImageConsumer object
from the list of consumers currently registered to
receive image data. It is not considered an error
to remove a consumer that is not currently registered.
The ImageProducer should stop sending data
to this consumer as soon as is feasible.
removeConsumer in interface ImageProduceric - the specified ImageConsumerpublic void startProduction(ImageConsumer ic)
ImageProducerImageConsumer object
as a consumer and starts an immediate reconstruction of
the image data which will then be delivered to this
consumer and any other consumer which might have already
been registered with the producer. This method differs
from the addConsumer method in that a reproduction of
the image data should be triggered as soon as possible.
startProduction in interface ImageProduceric - the specified ImageConsumerImageProducer.addConsumer(java.awt.image.ImageConsumer)protected boolean isStatic()
public void nextFrame(int param)
public void requestTopDownLeftRightResend(ImageConsumer ic)
ImageProducerImageConsumer,
that the ImageProducer attempt to resend
the image data one more time in TOPDOWNLEFTRIGHT order
so that higher quality conversion algorithms which
depend on receiving pixels in order can be used to
produce a better output version of the image. The
ImageProducer is free to
ignore this call if it cannot resend the data in that
order. If the data can be resent, the
ImageProducer should respond by executing
the following minimum set of ImageConsumer
method calls:
ic.setHints(TOPDOWNLEFTRIGHT | < otherhints >); ic.setPixels(...); // As many times as needed ic.imageComplete();
requestTopDownLeftRightResend in interface ImageProduceric - the specified ImageConsumerImageConsumer.setHints(int)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||