Overview | Package | Class | Tree | Deprecated | Index | Help Java Platform
1.1.7
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class com.sun.java.swing.SyntheticImage

java.lang.Object
  |
  +--com.sun.java.swing.SyntheticImage

public abstract class SyntheticImage
extends java.lang.Object
implements java.awt.image.ImageProducer
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 = new Image(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
int height
           
static int pixMask
           
int width
           
 
Constructor Summary
SyntheticImage()
           
SyntheticImage(int w, int h)
           
 
Method Summary
void addConsumer(java.awt.image.ImageConsumer ic)
           
void computeRow(int y, int[] row)
           
boolean isConsumer(java.awt.image.ImageConsumer ic)
           
boolean isStatic()
           
void nextFrame(int param)
           
void removeConsumer(java.awt.image.ImageConsumer ic)
           
void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
           
void startProduction(java.awt.image.ImageConsumer ic)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

width

protected int width

height

protected int height

pixMask

public static final int pixMask
Constructor Detail

SyntheticImage

protected SyntheticImage()

SyntheticImage

protected SyntheticImage(int w,
                         int h)
Method Detail

computeRow

protected void computeRow(int y,
                          int[] row)

addConsumer

public void addConsumer(java.awt.image.ImageConsumer ic)
Description copied from interface:
 
Specified by:
addConsumer(java.awt.image.ImageConsumer) in interface java.awt.image.ImageProducer

isConsumer

public boolean isConsumer(java.awt.image.ImageConsumer ic)
Description copied from interface:
 
Specified by:
isConsumer(java.awt.image.ImageConsumer) in interface java.awt.image.ImageProducer

removeConsumer

public void removeConsumer(java.awt.image.ImageConsumer ic)
Description copied from interface:
 
Specified by:
removeConsumer(java.awt.image.ImageConsumer) in interface java.awt.image.ImageProducer

startProduction

public void startProduction(java.awt.image.ImageConsumer ic)
Description copied from interface:
 
Specified by:
startProduction(java.awt.image.ImageConsumer) in interface java.awt.image.ImageProducer

isStatic

protected boolean isStatic()

nextFrame

public void nextFrame(int param)

requestTopDownLeftRightResend

public void requestTopDownLeftRightResend(java.awt.image.ImageConsumer ic)
Description copied from interface:
 
Specified by:
requestTopDownLeftRightResend(java.awt.image.ImageConsumer) in interface java.awt.image.ImageProducer

Overview | Package | Class | Tree | Deprecated | Index | Help Java Platform
1.1.7
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Submit a bug or feature
Submit comments/suggestions about javadoc
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.