833 834 // Must be a ToolkitImage 835 if (!(img instanceof ToolkitImage)) { 836 return true; 837 } 838 839 ToolkitImage tkimg = (ToolkitImage)img; 840 if (tkimg.hasError()) { 841 if (o != null) { 842 o.imageUpdate(img, ImageObserver.ERROR|ImageObserver.ABORT, 843 -1, -1, -1, -1); 844 } 845 return false; 846 } 847 ImageRepresentation ir = tkimg.getImageRep(); 848 return ir.prepare(o) & prepareResolutionVariant(img, w, h, o); 849 } 850 851 private int checkResolutionVariant(Image img, int w, int h, ImageObserver o) { 852 ToolkitImage rvImage = getResolutionVariant(img); 853 // Ignore the resolution variant in case of error 854 return (rvImage == null || rvImage.hasError()) ? 0xFFFF : 855 checkImage(rvImage, 2 * w, 2 * h, MultiResolutionToolkitImage. 856 getResolutionVariantObserver( 857 img, o, w, h, 2 * w, 2 * h)); 858 } 859 860 private boolean prepareResolutionVariant(Image img, int w, int h, 861 ImageObserver o) { 862 863 ToolkitImage rvImage = getResolutionVariant(img); 864 // Ignore the resolution variant in case of error 865 return rvImage == null || rvImage.hasError() || prepareImage( 866 rvImage, 2 * w, 2 * h, 867 MultiResolutionToolkitImage.getResolutionVariantObserver( 868 img, o, w, h, 2 * w, 2 * h)); 869 } 870 871 private static ToolkitImage getResolutionVariant(Image image) { 872 if (image instanceof MultiResolutionToolkitImage) { 873 Image resolutionVariant = ((MultiResolutionToolkitImage) image). 874 getResolutionVariant(); 875 if (resolutionVariant instanceof ToolkitImage) { 876 return (ToolkitImage) resolutionVariant; 877 } 878 } 879 return null; 880 } 881 882 protected static boolean imageCached(Object key) { 883 return imgCache.containsKey(key); 884 } 885 886 protected static boolean imageExists(String filename) { 887 checkPermissions(filename); 888 return filename != null && new File(filename).exists(); | 833 834 // Must be a ToolkitImage 835 if (!(img instanceof ToolkitImage)) { 836 return true; 837 } 838 839 ToolkitImage tkimg = (ToolkitImage)img; 840 if (tkimg.hasError()) { 841 if (o != null) { 842 o.imageUpdate(img, ImageObserver.ERROR|ImageObserver.ABORT, 843 -1, -1, -1, -1); 844 } 845 return false; 846 } 847 ImageRepresentation ir = tkimg.getImageRep(); 848 return ir.prepare(o) & prepareResolutionVariant(img, w, h, o); 849 } 850 851 private int checkResolutionVariant(Image img, int w, int h, ImageObserver o) { 852 ToolkitImage rvImage = getResolutionVariant(img); 853 int rvw = getRVSize(w); 854 int rvh = getRVSize(h); 855 // Ignore the resolution variant in case of error 856 return (rvImage == null || rvImage.hasError()) ? 0xFFFF : 857 checkImage(rvImage, rvw, rvh, MultiResolutionToolkitImage. 858 getResolutionVariantObserver( 859 img, o, w, h, rvw, rvh, true)); 860 } 861 862 private boolean prepareResolutionVariant(Image img, int w, int h, 863 ImageObserver o) { 864 865 ToolkitImage rvImage = getResolutionVariant(img); 866 int rvw = getRVSize(w); 867 int rvh = getRVSize(h); 868 // Ignore the resolution variant in case of error 869 return rvImage == null || rvImage.hasError() || prepareImage( 870 rvImage, rvw, rvh, 871 MultiResolutionToolkitImage.getResolutionVariantObserver( 872 img, o, w, h, rvw, rvh, true)); 873 } 874 875 private static int getRVSize(int size){ 876 return size == -1 ? -1 : 2 * size; 877 } 878 879 private static ToolkitImage getResolutionVariant(Image image) { 880 if (image instanceof MultiResolutionToolkitImage) { 881 Image resolutionVariant = ((MultiResolutionToolkitImage) image). 882 getResolutionVariant(); 883 if (resolutionVariant instanceof ToolkitImage) { 884 return (ToolkitImage) resolutionVariant; 885 } 886 } 887 return null; 888 } 889 890 protected static boolean imageCached(Object key) { 891 return imgCache.containsKey(key); 892 } 893 894 protected static boolean imageExists(String filename) { 895 checkPermissions(filename); 896 return filename != null && new File(filename).exists(); |