Example usage for java.awt.image ImageObserver FRAMEBITS

List of usage examples for java.awt.image ImageObserver FRAMEBITS

Introduction

In this page you can find the example usage for java.awt.image ImageObserver FRAMEBITS.

Prototype

int FRAMEBITS

To view the source code for java.awt.image ImageObserver FRAMEBITS.

Click Source Link

Document

This flag in the infoflags argument to imageUpdate indicates that another complete frame of a multi-frame image which was previously drawn is now available to be drawn again.

Usage

From source file:Main.java

/**
 * Decodes the bits of a java.awt.image.ImageObserver infoflag into a human
 * readable string.// ww w  .j  a  v  a2  s.c om
 * 
 * @param infoflag
 *            the flag to decode
 * @return a string describing the flag
 */
public static String imageObserverInfoflagToString(int infoflag) {
    String out = "";
    if ((infoflag & ImageObserver.ABORT) == ImageObserver.ABORT)
        out += "ABORT ";
    if ((infoflag & ImageObserver.ALLBITS) == ImageObserver.ALLBITS)
        out += "ALLBITS ";
    if ((infoflag & ImageObserver.ERROR) == ImageObserver.ERROR)
        out += "ERROR ";
    if ((infoflag & ImageObserver.FRAMEBITS) == ImageObserver.FRAMEBITS)
        out += "FRAMEBITS ";
    if ((infoflag & ImageObserver.HEIGHT) == ImageObserver.HEIGHT)
        out += "HEIGHT ";
    if ((infoflag & ImageObserver.PROPERTIES) == ImageObserver.PROPERTIES)
        out += "PROPERTIES ";
    if ((infoflag & ImageObserver.SOMEBITS) == ImageObserver.SOMEBITS)
        out += "SOMEBITS ";
    if ((infoflag & ImageObserver.WIDTH) == ImageObserver.WIDTH)
        out += "WIDTH ";
    return out;
}

From source file:ImageLoaderApplet.java

/**
 * Verbose version of ImageConsumer's imageUpdate method
 *///from  w ww .  j av  a 2  s. c om
public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height) {
    System.out.print("Flag(s): ");
    if ((flags & ImageObserver.WIDTH) != 0) {
        System.out.print("WIDTH:(" + width + ") ");
    }

    if ((flags & ImageObserver.HEIGHT) != 0) {
        System.out.print("HEIGHT:(" + height + ") ");
    }

    if ((flags & ImageObserver.PROPERTIES) != 0) {
        System.out.print("PROPERTIES ");
    }

    if ((flags & ImageObserver.SOMEBITS) != 0) {
        System.out.print("SOMEBITS(" + x + "," + y + ")->(");
        System.out.print(width + "," + height + ") ");
        repaint();
    }

    if ((flags & ImageObserver.FRAMEBITS) != 0) {
        System.out.print("FRAMEBITS(" + x + "," + y + ")->(");
        System.out.print(width + "," + height + ") ");
        repaint();
    }

    if ((flags & ImageObserver.ALLBITS) != 0) {
        System.out.print("ALLBITS(" + x + "," + y + ")->(");
        System.out.println(width + "," + height + ") ");
        repaint();
        return false;
    }

    if ((flags & ImageObserver.ABORT) != 0) {
        System.out.println("ABORT \n");
        return false;
    }

    if ((flags & ImageObserver.ERROR) != 0) {
        System.out.println("ERROR ");
        return false;
    }

    System.out.println();
    return true;
}

From source file:org.pentaho.reporting.libraries.base.util.WaitingImageObserver.java

/**
 * Callback function used by AWT to inform that more data is available. The observer waits until either all data is
 * loaded or AWT signals that the image cannot be loaded.
 *
 * @param img       the image being observed.
 * @param infoflags the bitwise inclusive OR of the following flags:  <code>WIDTH</code>, <code>HEIGHT</code>,
 *                  <code>PROPERTIES</code>, <code>SOMEBITS</code>, <code>FRAMEBITS</code>, <code>ALLBITS</code>,
 *                  <code>ERROR</code>, <code>ABORT</code>.
 * @param x         the <i>x</i> coordinate.
 * @param y         the <i>y</i> coordinate.
 * @param width     the width./*from w  ww. jav  a2 s .c o m*/
 * @param height    the height.
 * @return <code>false</code> if the infoflags indicate that the image is completely loaded; <code>true</code>
 * otherwise.
 */
public synchronized boolean imageUpdate(final Image img, final int infoflags, final int x, final int y,
        final int width, final int height) {
    if (img == null) {
        throw new NullPointerException();
    }

    lastUpdate = System.currentTimeMillis();
    if ((infoflags & ImageObserver.ALLBITS) == ImageObserver.ALLBITS) {
        this.lock = false;
        this.error = false;
        notifyAll();
        return false;
    } else if ((infoflags & ImageObserver.FRAMEBITS) == ImageObserver.FRAMEBITS) {
        this.lock = false;
        this.error = false;
        notifyAll();
        return false;
    } else if ((infoflags & ImageObserver.ABORT) == ImageObserver.ABORT
            || (infoflags & ImageObserver.ERROR) == ImageObserver.ERROR) {
        this.lock = false;
        this.error = true;
        notifyAll();
        return false;
    }

    // maybe it is enough already to draw the image ..
    notifyAll();
    return true;
}