home *** CD-ROM | disk | FTP | other *** search
- package sun.awt.image;
-
- import java.awt.image.ImageConsumer;
- import java.awt.image.ImageProducer;
- import java.util.Hashtable;
-
- public class OffScreenImageSource implements ImageProducer {
- int width;
- int height;
- ImageRepresentation baseIR;
- private ImageConsumer theConsumer;
-
- public OffScreenImageSource(int w, int h) {
- this.width = w;
- this.height = h;
- }
-
- void setImageRep(ImageRepresentation ir) {
- this.baseIR = ir;
- }
-
- public ImageRepresentation getImageRep() {
- return this.baseIR;
- }
-
- public synchronized void addConsumer(ImageConsumer ic) {
- this.theConsumer = ic;
- this.produce();
- }
-
- public synchronized boolean isConsumer(ImageConsumer ic) {
- return ic == this.theConsumer;
- }
-
- public synchronized void removeConsumer(ImageConsumer ic) {
- if (this.theConsumer == ic) {
- this.theConsumer = null;
- }
-
- }
-
- public void startProduction(ImageConsumer ic) {
- this.addConsumer(ic);
- }
-
- public void requestTopDownLeftRightResend(ImageConsumer ic) {
- }
-
- private native void sendPixels();
-
- private void produce() {
- if (this.theConsumer != null) {
- this.theConsumer.setDimensions(this.width, this.height);
- }
-
- if (this.theConsumer != null) {
- this.theConsumer.setProperties(new Hashtable());
- }
-
- this.sendPixels();
- if (this.theConsumer != null) {
- this.theConsumer.imageComplete(2);
- }
-
- }
- }
-