src/java.desktop/share/classes/sun/awt/SunToolkit.java

Print this page




 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();
 872         if (sm != null) {
 873             try {




 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             checkPermissions(filename);
 848             return new File(filename).exists();
 849         }
 850         return false;
 851     }
 852 
 853     @SuppressWarnings("try")
 854     protected static boolean imageExists(URL url) {

 855         if (url != null) {
 856             checkPermissions(url);
 857             try (InputStream is = url.openStream()) {
 858                 return true;
 859             }catch(IOException e){
 860                 return false;
 861             }
 862         }
 863         return false;
 864     }
 865 
 866     private static void checkPermissions(String filename) {
 867         SecurityManager security = System.getSecurityManager();
 868         if (security != null) {
 869             security.checkRead(filename);
 870         }
 871     }
 872 
 873     private static void checkPermissions(URL url) {
 874         SecurityManager sm = System.getSecurityManager();
 875         if (sm != null) {
 876             try {