1 /*
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
42 @Override
43 public Image getResolutionVariant(int width, int height) {
44 return ((width <= getWidth() && height <= getHeight()))
45 ? this : resolutionVariant;
46 }
47
48 public Image getResolutionVariant() {
49 return resolutionVariant;
50 }
51
52 @Override
53 public List<Image> getResolutionVariants() {
54 return Arrays.<Image>asList(this, resolutionVariant);
55 }
56
57 private static final int BITS_INFO = ImageObserver.SOMEBITS
58 | ImageObserver.FRAMEBITS | ImageObserver.ALLBITS;
59
60 private static class ObserverCache {
61
62 static final SoftCache INSTANCE = new SoftCache();
63 }
64
65 public static ImageObserver getResolutionVariantObserver(
66 final Image image, final ImageObserver observer,
67 final int imgWidth, final int imgHeight,
68 final int rvWidth, final int rvHeight) {
69 return getResolutionVariantObserver(image, observer,
70 imgWidth, imgHeight, rvWidth, rvHeight, false);
71 }
72
73 public static ImageObserver getResolutionVariantObserver(
74 final Image image, final ImageObserver observer,
75 final int imgWidth, final int imgHeight,
76 final int rvWidth, final int rvHeight, boolean concatenateInfo) {
77
78 if (observer == null) {
79 return null;
80 }
81
|
1 /*
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
42 @Override
43 public Image getResolutionVariant(int width, int height) {
44 return ((width <= getWidth() && height <= getHeight()))
45 ? this : resolutionVariant;
46 }
47
48 public Image getResolutionVariant() {
49 return resolutionVariant;
50 }
51
52 @Override
53 public List<Image> getResolutionVariants() {
54 return Arrays.<Image>asList(this, resolutionVariant);
55 }
56
57 private static final int BITS_INFO = ImageObserver.SOMEBITS
58 | ImageObserver.FRAMEBITS | ImageObserver.ALLBITS;
59
60 private static class ObserverCache {
61
62 @SuppressWarnings("deprecation")
63 static final SoftCache INSTANCE = new SoftCache();
64 }
65
66 public static ImageObserver getResolutionVariantObserver(
67 final Image image, final ImageObserver observer,
68 final int imgWidth, final int imgHeight,
69 final int rvWidth, final int rvHeight) {
70 return getResolutionVariantObserver(image, observer,
71 imgWidth, imgHeight, rvWidth, rvHeight, false);
72 }
73
74 public static ImageObserver getResolutionVariantObserver(
75 final Image image, final ImageObserver observer,
76 final int imgWidth, final int imgHeight,
77 final int rvWidth, final int rvHeight, boolean concatenateInfo) {
78
79 if (observer == null) {
80 return null;
81 }
82
|