826 private static int getRVSize(int size){ 827 return size == -1 ? -1 : 2 * size; 828 } 829 830 private static ToolkitImage getResolutionVariant(Image image) { 831 if (image instanceof MultiResolutionToolkitImage) { 832 Image resolutionVariant = ((MultiResolutionToolkitImage) image). 833 getResolutionVariant(); 834 if (resolutionVariant instanceof ToolkitImage) { 835 return (ToolkitImage) resolutionVariant; 836 } 837 } 838 return null; 839 } 840 841 protected static boolean imageCached(Object key) { 842 return imgCache.containsKey(key); 843 } 844 845 protected static boolean imageExists(String filename) { 846 checkPermissions(filename); 847 return filename != null && new File(filename).exists(); 848 } 849 850 @SuppressWarnings("try") 851 protected static boolean imageExists(URL url) { 852 checkPermissions(url); 853 if (url != null) { 854 try (InputStream is = url.openStream()) { 855 return true; 856 }catch(IOException e){ 857 return false; 858 } 859 } 860 return false; 861 } 862 863 private static void checkPermissions(String filename) { 864 SecurityManager security = System.getSecurityManager(); 865 if (security != null) { 866 security.checkRead(filename); 867 } 868 } 869 870 private static void checkPermissions(URL url) { 871 SecurityManager sm = System.getSecurityManager(); | 826 private static int getRVSize(int size){ 827 return size == -1 ? -1 : 2 * size; 828 } 829 830 private static ToolkitImage getResolutionVariant(Image image) { 831 if (image instanceof MultiResolutionToolkitImage) { 832 Image resolutionVariant = ((MultiResolutionToolkitImage) image). 833 getResolutionVariant(); 834 if (resolutionVariant instanceof ToolkitImage) { 835 return (ToolkitImage) resolutionVariant; 836 } 837 } 838 return null; 839 } 840 841 protected static boolean imageCached(Object key) { 842 return imgCache.containsKey(key); 843 } 844 845 protected static boolean imageExists(String filename) { 846 if (filename == null) { 847 return false; 848 } 849 checkPermissions(filename); 850 return filename != null && new File(filename).exists(); 851 } 852 853 @SuppressWarnings("try") 854 protected static boolean imageExists(URL url) { 855 if (url == null) { 856 return false; 857 } 858 checkPermissions(url); 859 if (url != null) { 860 try (InputStream is = url.openStream()) { 861 return true; 862 }catch(IOException e){ 863 return false; 864 } 865 } 866 return false; 867 } 868 869 private static void checkPermissions(String filename) { 870 SecurityManager security = System.getSecurityManager(); 871 if (security != null) { 872 security.checkRead(filename); 873 } 874 } 875 876 private static void checkPermissions(URL url) { 877 SecurityManager sm = System.getSecurityManager(); |