Example usage for java.awt.image ImageObserver HEIGHT

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

Introduction

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

Prototype

int HEIGHT

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

Click Source Link

Document

This flag in the infoflags argument to imageUpdate indicates that the height of the base image is now available and can be taken from the height argument to the imageUpdate callback method.

Usage

From source file:Main.java

/**
 * Decodes the bits of a java.awt.image.ImageObserver infoflag into a human
 * readable string.// w ww.j a  va2 s.  co  m
 * 
 * @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:ImageSize.java

public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
    if ((infoflags & ImageObserver.ERROR) != 0) {
        System.out.println("Error loading image!");
        System.exit(-1);/*from  www  . j  a v  a  2 s  .co m*/
    }
    if ((infoflags & ImageObserver.WIDTH) != 0 && (infoflags & ImageObserver.HEIGHT) != 0)
        rightSize();
    if ((infoflags & ImageObserver.SOMEBITS) != 0)
        repaint();
    if ((infoflags & ImageObserver.ALLBITS) != 0) {
        rightSize();
        repaint();
        return false;
    }
    return true;
}

From source file:ImageLoaderApplet.java

/**
 * Verbose version of ImageConsumer's imageUpdate method
 *///w  w  w.j  a v a  2s .c o  m
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:com.hexidec.ekit.component.RelativeImageView.java

public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height) {
    if ((fImage == null) || (fImage != img)) {
        return false;
    }// ww w  . j  a  v a  2 s.  c  o m

    // Bail out if there was an error
    if ((flags & (ABORT | ERROR)) != 0) {
        fImage = null;
        repaint(0);
        return false;
    }

    // Resize image if necessary
    short changed = 0;
    if ((flags & ImageObserver.HEIGHT) != 0) {
        if (!getElement().getAttributes().isDefined(HTML.Attribute.HEIGHT)) {
            changed |= 1;
        }
    }
    if ((flags & ImageObserver.WIDTH) != 0) {
        if (!getElement().getAttributes().isDefined(HTML.Attribute.WIDTH)) {
            changed |= 2;
        }
    }

    synchronized (this) {
        if ((changed & 1) == 1) {
            fWidth = width;
        }
        if ((changed & 2) == 2) {
            fHeight = height;
        }
        if (bLoading) {
            // No need to resize or repaint, still in the process of loading
            return true;
        }
    }

    if (changed != 0) {
        // May need to resize myself, asynchronously
        Document doc = getDocument();
        try {
            if (doc instanceof AbstractDocument) {
                ((AbstractDocument) doc).readLock();
            }
            preferenceChanged(this, true, true);
        } finally {
            if (doc instanceof AbstractDocument) {
                ((AbstractDocument) doc).readUnlock();
            }
        }
        return true;
    }

    // Repaint when done or when new pixels arrive
    if ((flags & (FRAMEBITS | ALLBITS)) != 0) {
        repaint(0);
    } else if ((flags & SOMEBITS) != 0) {
        if (sIsInc) {
            repaint(sIncRate);
        }
    }
    return ((flags & ALLBITS) == 0);
}

From source file:org.pmedv.core.components.RelativeImageView.java

/**
 * updates the image.//from   w w w  .  j av a  2 s.c  om
 * 
 * @param img
 *            the image to update to
 * @param flags
 *            flags to set
 * @param x
 *            y-coordinate
 * @param y
 *            y-coordinate
 * @param width
 *            image width
 * @param height
 *            image height
 * @return returns true if update was successful, false otherwise.
 */
public boolean imageUpdate(Image img, int flags, int x, int y, int width, int height) {

    if ((fImage == null) || (fImage != img)) {
        return false;
    }

    // Bail out if there was an error
    if ((flags & (ABORT | ERROR)) != 0) {
        fImage = null;
        repaint(0);
        return false;
    }

    // Resize image if necessary
    short changed = 0;
    if ((flags & ImageObserver.HEIGHT) != 0) {
        if (!getElement().getAttributes().isDefined(HTML.Attribute.HEIGHT)) {
            changed |= 1;
        }
    }

    if ((flags & ImageObserver.WIDTH) != 0) {
        if (!getElement().getAttributes().isDefined(HTML.Attribute.WIDTH)) {
            changed |= 2;
        }
    }

    synchronized (this) {
        if ((changed & 1) == 1) {
            fWidth = width;
        }

        if ((changed & 2) == 2) {
            fHeight = height;
        }

        if (bLoading) {
            // No need to resize or repaint, still in the process of loading
            return true;
        }
    }

    if (changed != 0) {
        // May need to resize myself, asynchronously
        Document doc = getDocument();
        try {
            if (doc instanceof AbstractDocument) {
                ((AbstractDocument) doc).readLock();
            }
            preferenceChanged(this, true, true);
        } finally {
            if (doc instanceof AbstractDocument) {
                ((AbstractDocument) doc).readUnlock();
            }
        }
        return true;
    }

    // Repaint when done or when new pixels arrive
    if ((flags & (FRAMEBITS | ALLBITS)) != 0) {
        repaint(0);
    } else if ((flags & SOMEBITS) != 0) {
        if (sIsInc) {
            repaint(sIncRate);
        }
    }
    return ((flags & ALLBITS) == 0);
}