Java Code Examples for java.awt.image.ImageObserver#WIDTH
The following examples show how to use
java.awt.image.ImageObserver#WIDTH .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageRepresentation.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void setDimensions(int w, int h) { if (src != null) { src.checkSecurity(null, false); } image.setDimensions(w, h); newInfo(image, (ImageObserver.WIDTH | ImageObserver.HEIGHT), 0, 0, w, h); if (w <= 0 || h <= 0) { imageComplete(ImageConsumer.IMAGEERROR); return; } if (width != w || height != h) { // dimension mismatch => trigger recreation of the buffer bimage = null; } width = w; height = h; availinfo |= ImageObserver.WIDTH | ImageObserver.HEIGHT; }
Example 2
Source File: MultiResolutionImageTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
@Override public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { if (image != img) { throw new RuntimeException("Original image is not passed to the observer"); } if ((infoflags & ImageObserver.WIDTH) != 0) { if (width != IMAGE_WIDTH) { throw new RuntimeException("Original width is not passed to the observer"); } } if ((infoflags & ImageObserver.HEIGHT) != 0) { if (height != IMAGE_HEIGHT) { throw new RuntimeException("Original height is not passed to the observer"); } } return (infoflags & ALLBITS) == 0; }
Example 3
Source File: MultiResolutionImageTest.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { if (image != img) { throw new RuntimeException("Original image is not passed to the observer"); } if ((infoflags & ImageObserver.WIDTH) != 0) { if (width != IMAGE_WIDTH) { throw new RuntimeException("Original width is not passed to the observer"); } } if ((infoflags & ImageObserver.HEIGHT) != 0) { if (height != IMAGE_HEIGHT) { throw new RuntimeException("Original height is not passed to the observer"); } } return (infoflags & ALLBITS) == 0; }
Example 4
Source File: ToolkitImage.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Return the width of the original image source. * If the width isn't known, then the image is reconstructed. */ public int getWidth() { if (src != null) { src.checkSecurity(null, false); } if ((availinfo & ImageObserver.WIDTH) == 0) { reconstruct(ImageObserver.WIDTH); } return width; }
Example 5
Source File: ToolkitImage.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
synchronized void infoDone(int status) { if (status == ImageConsumer.IMAGEERROR || ((~availinfo) & (ImageObserver.WIDTH | ImageObserver.HEIGHT)) != 0) { addInfo(ImageObserver.ERROR); } else if ((availinfo & ImageObserver.PROPERTIES) == 0) { setProperties(null); } }
Example 6
Source File: ToolkitImage.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
synchronized void infoDone(int status) { if (status == ImageConsumer.IMAGEERROR || ((~availinfo) & (ImageObserver.WIDTH | ImageObserver.HEIGHT)) != 0) { addInfo(ImageObserver.ERROR); } else if ((availinfo & ImageObserver.PROPERTIES) == 0) { setProperties(null); } }
Example 7
Source File: ToolkitImage.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public int check(ImageObserver iw) { if (src != null) { src.checkSecurity(null, false); } if ((availinfo & ImageObserver.ERROR) == 0 && ((~availinfo) & (ImageObserver.WIDTH | ImageObserver.HEIGHT | ImageObserver.PROPERTIES)) != 0) { addWatcher(iw, false); } return availinfo; }
Example 8
Source File: ToolkitImage.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
synchronized void infoDone(int status) { if (status == ImageConsumer.IMAGEERROR || ((~availinfo) & (ImageObserver.WIDTH | ImageObserver.HEIGHT)) != 0) { addInfo(ImageObserver.ERROR); } else if ((availinfo & ImageObserver.PROPERTIES) == 0) { setProperties(null); } }
Example 9
Source File: ToolkitImage.java From hottub with GNU General Public License v2.0 | 5 votes |
public int check(ImageObserver iw) { if (src != null) { src.checkSecurity(null, false); } if ((availinfo & ImageObserver.ERROR) == 0 && ((~availinfo) & (ImageObserver.WIDTH | ImageObserver.HEIGHT | ImageObserver.PROPERTIES)) != 0) { addWatcher(iw, false); } return availinfo; }
Example 10
Source File: ToolkitImage.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Return the width of the original image source. * If the width isn't known, then the ImageObserver object will be * notified when the data is available. */ public synchronized int getWidth(ImageObserver iw) { if (src != null) { src.checkSecurity(null, false); } if ((availinfo & ImageObserver.WIDTH) == 0) { addWatcher(iw, true); if ((availinfo & ImageObserver.WIDTH) == 0) { return -1; } } return width; }
Example 11
Source File: ToolkitImage.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public int check(ImageObserver iw) { if (src != null) { src.checkSecurity(null, false); } if ((availinfo & ImageObserver.ERROR) == 0 && ((~availinfo) & (ImageObserver.WIDTH | ImageObserver.HEIGHT | ImageObserver.PROPERTIES)) != 0) { addWatcher(iw, false); } return availinfo; }
Example 12
Source File: ToolkitImage.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public int check(ImageObserver iw) { if (src != null) { src.checkSecurity(null, false); } if ((availinfo & ImageObserver.ERROR) == 0 && ((~availinfo) & (ImageObserver.WIDTH | ImageObserver.HEIGHT | ImageObserver.PROPERTIES)) != 0) { addWatcher(iw, false); } return availinfo; }
Example 13
Source File: ImageView.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
public boolean imageUpdate(Image img, int flags, int x, int y, int newWidth, int newHeight ) { if (img != image && img != disabledImage || image == null || getParent() == null) { return false; } // Bail out if there was an error: if ((flags & (ABORT|ERROR)) != 0) { repaint(0); synchronized(ImageView.this) { if (image == img) { // Be sure image hasn't changed since we don't // initialy synchronize image = null; if ((state & WIDTH_FLAG) != WIDTH_FLAG) { width = DEFAULT_WIDTH; } if ((state & HEIGHT_FLAG) != HEIGHT_FLAG) { height = DEFAULT_HEIGHT; } } else { disabledImage = null; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process // of loading. return false; } } updateAltTextView(); safePreferenceChanged(); return false; } if (image == img) { // Resize image if necessary: short changed = 0; if ((flags & ImageObserver.HEIGHT) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.HEIGHT)) { changed |= 1; } if ((flags & ImageObserver.WIDTH) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.WIDTH)) { changed |= 2; } synchronized(ImageView.this) { if ((changed & 1) == 1 && (state & WIDTH_FLAG) == 0) { width = newWidth; } if ((changed & 2) == 2 && (state & HEIGHT_FLAG) == 0) { height = newHeight; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process of // loading. return true; } } if (changed != 0) { // May need to resize myself, asynchronously: safePreferenceChanged(); return true; } } // Repaint when done or when new pixels arrive: if ((flags & (FRAMEBITS|ALLBITS)) != 0) { repaint(0); } else if ((flags & SOMEBITS) != 0 && sIsInc) { repaint(sIncRate); } return ((flags & ALLBITS) == 0); }
Example 14
Source File: ImageView.java From hottub with GNU General Public License v2.0 | 4 votes |
public boolean imageUpdate(Image img, int flags, int x, int y, int newWidth, int newHeight ) { if (img != image && img != disabledImage || image == null || getParent() == null) { return false; } // Bail out if there was an error: if ((flags & (ABORT|ERROR)) != 0) { repaint(0); synchronized(ImageView.this) { if (image == img) { // Be sure image hasn't changed since we don't // initialy synchronize image = null; if ((state & WIDTH_FLAG) != WIDTH_FLAG) { width = DEFAULT_WIDTH; } if ((state & HEIGHT_FLAG) != HEIGHT_FLAG) { height = DEFAULT_HEIGHT; } } else { disabledImage = null; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process // of loading. return false; } } updateAltTextView(); safePreferenceChanged(); return false; } if (image == img) { // Resize image if necessary: short changed = 0; if ((flags & ImageObserver.HEIGHT) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.HEIGHT)) { changed |= 1; } if ((flags & ImageObserver.WIDTH) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.WIDTH)) { changed |= 2; } synchronized(ImageView.this) { if ((changed & 1) == 1 && (state & WIDTH_FLAG) == 0) { width = newWidth; } if ((changed & 2) == 2 && (state & HEIGHT_FLAG) == 0) { height = newHeight; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process of // loading. return true; } } if (changed != 0) { // May need to resize myself, asynchronously: safePreferenceChanged(); return true; } } // Repaint when done or when new pixels arrive: if ((flags & (FRAMEBITS|ALLBITS)) != 0) { repaint(0); } else if ((flags & SOMEBITS) != 0 && sIsInc) { repaint(sIncRate); } return ((flags & ALLBITS) == 0); }
Example 15
Source File: ImageView.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
public boolean imageUpdate(Image img, int flags, int x, int y, int newWidth, int newHeight ) { if (img != image && img != disabledImage || image == null || getParent() == null) { return false; } // Bail out if there was an error: if ((flags & (ABORT|ERROR)) != 0) { repaint(0); synchronized(ImageView.this) { if (image == img) { // Be sure image hasn't changed since we don't // initialy synchronize image = null; if ((state & WIDTH_FLAG) != WIDTH_FLAG) { width = DEFAULT_WIDTH; } if ((state & HEIGHT_FLAG) != HEIGHT_FLAG) { height = DEFAULT_HEIGHT; } } else { disabledImage = null; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process // of loading. return false; } } updateAltTextView(); safePreferenceChanged(); return false; } if (image == img) { // Resize image if necessary: short changed = 0; if ((flags & ImageObserver.HEIGHT) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.HEIGHT)) { changed |= 1; } if ((flags & ImageObserver.WIDTH) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.WIDTH)) { changed |= 2; } /** * If the image properties (height and width) have been loaded, * tehn figure out if scaling is necessary based on the * specified HTML attributes. */ if (((flags & ImageObserver.HEIGHT) != 0) && ((flags & ImageObserver.WIDTH) != 0)) { Dimension d = adjustWidthHeight(newWidth, newHeight); newWidth = d.width; newHeight = d.height; changed |= 3; } synchronized(ImageView.this) { if ((changed & 1) == 1 && (state & HEIGHT_FLAG) == 0) { height = newHeight; } if ((changed & 2) == 2 && (state & WIDTH_FLAG) == 0) { width = newWidth; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process of // loading. return true; } } if (changed != 0) { // May need to resize myself, asynchronously: safePreferenceChanged(); return true; } } // Repaint when done or when new pixels arrive: if ((flags & (FRAMEBITS|ALLBITS)) != 0) { repaint(0); } else if ((flags & SOMEBITS) != 0 && sIsInc) { repaint(sIncRate); } return ((flags & ALLBITS) == 0); }
Example 16
Source File: MultiResolutionToolkitImage.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
public static ImageObserver getResolutionVariantObserver( final Image image, final ImageObserver observer, final int imgWidth, final int imgHeight, final int rvWidth, final int rvHeight, boolean concatenateInfo) { if (observer == null) { return null; } synchronized (ObserverCache.INSTANCE) { ImageObserver o = (ImageObserver) ObserverCache.INSTANCE.get(observer); if (o == null) { o = (Image resolutionVariant, int flags, int x, int y, int width, int height) -> { if ((flags & (ImageObserver.WIDTH | BITS_INFO)) != 0) { width = (width + 1) / 2; } if ((flags & (ImageObserver.HEIGHT | BITS_INFO)) != 0) { height = (height + 1) / 2; } if ((flags & BITS_INFO) != 0) { x /= 2; y /= 2; } if(concatenateInfo){ flags &= ((ToolkitImage) image). getImageRep().check(null); } return observer.imageUpdate( image, flags, x, y, width, height); }; ObserverCache.INSTANCE.put(observer, o); } return o; } }
Example 17
Source File: ImageView.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
public boolean imageUpdate(Image img, int flags, int x, int y, int newWidth, int newHeight ) { if (img != image && img != disabledImage || image == null || getParent() == null) { return false; } // Bail out if there was an error: if ((flags & (ABORT|ERROR)) != 0) { repaint(0); synchronized(ImageView.this) { if (image == img) { // Be sure image hasn't changed since we don't // initialy synchronize image = null; if ((state & WIDTH_FLAG) != WIDTH_FLAG) { width = DEFAULT_WIDTH; } if ((state & HEIGHT_FLAG) != HEIGHT_FLAG) { height = DEFAULT_HEIGHT; } } else { disabledImage = null; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process // of loading. return false; } } updateAltTextView(); safePreferenceChanged(); return false; } if (image == img) { // Resize image if necessary: short changed = 0; if ((flags & ImageObserver.HEIGHT) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.HEIGHT)) { changed |= 1; } if ((flags & ImageObserver.WIDTH) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.WIDTH)) { changed |= 2; } synchronized(ImageView.this) { if ((changed & 1) == 1 && (state & WIDTH_FLAG) == 0) { width = newWidth; } if ((changed & 2) == 2 && (state & HEIGHT_FLAG) == 0) { height = newHeight; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process of // loading. return true; } } if (changed != 0) { // May need to resize myself, asynchronously: safePreferenceChanged(); return true; } } // Repaint when done or when new pixels arrive: if ((flags & (FRAMEBITS|ALLBITS)) != 0) { repaint(0); } else if ((flags & SOMEBITS) != 0 && sIsInc) { repaint(sIncRate); } return ((flags & ALLBITS) == 0); }
Example 18
Source File: ImageView.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
public boolean imageUpdate(Image img, int flags, int x, int y, int newWidth, int newHeight ) { if (img != image && img != disabledImage || image == null || getParent() == null) { return false; } // Bail out if there was an error: if ((flags & (ABORT|ERROR)) != 0) { repaint(0); synchronized(ImageView.this) { if (image == img) { // Be sure image hasn't changed since we don't // initialy synchronize image = null; if ((state & WIDTH_FLAG) != WIDTH_FLAG) { width = DEFAULT_WIDTH; } if ((state & HEIGHT_FLAG) != HEIGHT_FLAG) { height = DEFAULT_HEIGHT; } } else { disabledImage = null; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process // of loading. return false; } } updateAltTextView(); safePreferenceChanged(); return false; } if (image == img) { // Resize image if necessary: short changed = 0; if ((flags & ImageObserver.HEIGHT) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.HEIGHT)) { changed |= 1; } if ((flags & ImageObserver.WIDTH) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.WIDTH)) { changed |= 2; } synchronized(ImageView.this) { if ((changed & 1) == 1 && (state & WIDTH_FLAG) == 0) { width = newWidth; } if ((changed & 2) == 2 && (state & HEIGHT_FLAG) == 0) { height = newHeight; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process of // loading. return true; } } if (changed != 0) { // May need to resize myself, asynchronously: safePreferenceChanged(); return true; } } // Repaint when done or when new pixels arrive: if ((flags & (FRAMEBITS|ALLBITS)) != 0) { repaint(0); } else if ((flags & SOMEBITS) != 0 && sIsInc) { repaint(sIncRate); } return ((flags & ALLBITS) == 0); }
Example 19
Source File: ImageView.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
public boolean imageUpdate(Image img, int flags, int x, int y, int newWidth, int newHeight ) { if (img != image && img != disabledImage || image == null || getParent() == null) { return false; } // Bail out if there was an error: if ((flags & (ABORT|ERROR)) != 0) { repaint(0); synchronized(ImageView.this) { if (image == img) { // Be sure image hasn't changed since we don't // initialy synchronize image = null; if ((state & WIDTH_FLAG) != WIDTH_FLAG) { width = DEFAULT_WIDTH; } if ((state & HEIGHT_FLAG) != HEIGHT_FLAG) { height = DEFAULT_HEIGHT; } } else { disabledImage = null; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process // of loading. return false; } } updateAltTextView(); safePreferenceChanged(); return false; } if (image == img) { // Resize image if necessary: short changed = 0; if ((flags & ImageObserver.HEIGHT) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.HEIGHT)) { changed |= 1; } if ((flags & ImageObserver.WIDTH) != 0 && !getElement(). getAttributes().isDefined(HTML.Attribute.WIDTH)) { changed |= 2; } /** * If the image properties (height and width) have been loaded, * then figure out if scaling is necessary based on the * specified HTML attributes. */ if (((flags & ImageObserver.HEIGHT) != 0) && ((flags & ImageObserver.WIDTH) != 0)) { Dimension d = adjustWidthHeight(newWidth, newHeight); newWidth = d.width; newHeight = d.height; changed |= 3; } synchronized(ImageView.this) { if ((changed & 1) == 1 && (state & HEIGHT_FLAG) == 0) { height = newHeight; } if ((changed & 2) == 2 && (state & WIDTH_FLAG) == 0) { width = newWidth; } if ((state & LOADING_FLAG) == LOADING_FLAG) { // No need to resize or repaint, still in the process of // loading. return true; } } if (changed != 0) { // May need to resize myself, asynchronously: safePreferenceChanged(); return true; } } // Repaint when done or when new pixels arrive: if ((flags & (FRAMEBITS|ALLBITS)) != 0) { repaint(0); } else if ((flags & SOMEBITS) != 0 && sIsInc) { repaint(sIncRate); } return ((flags & ALLBITS) == 0); }
Example 20
Source File: MultiResolutionToolkitImage.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static ImageObserver getResolutionVariantObserver( final Image image, final ImageObserver observer, final int imgWidth, final int imgHeight, final int rvWidth, final int rvHeight, boolean concatenateInfo) { if (observer == null) { return null; } synchronized (ObserverCache.INSTANCE) { ImageObserver o = (ImageObserver) ObserverCache.INSTANCE.get(observer); if (o == null) { o = (Image resolutionVariant, int flags, int x, int y, int width, int height) -> { if ((flags & (ImageObserver.WIDTH | BITS_INFO)) != 0) { width = (width + 1) / 2; } if ((flags & (ImageObserver.HEIGHT | BITS_INFO)) != 0) { height = (height + 1) / 2; } if ((flags & BITS_INFO) != 0) { x /= 2; y /= 2; } if(concatenateInfo){ flags &= ((ToolkitImage) image). getImageRep().check(null); } return observer.imageUpdate( image, flags, x, y, width, height); }; ObserverCache.INSTANCE.put(observer, o); } return o; } }