@Test public void testCacheApplicationIcon() { final NSImageIconCache cache = new NSImageIconCache(); final NSImage icon32 = cache.applicationIcon(new Application("com.apple.TextEdit"), 32); assertNotNull(icon32); assertEquals(32, icon32.size().width.intValue()); assertEquals(32, icon32.size().height.intValue()); final NSImage icon16 = cache.applicationIcon(new Application("com.apple.TextEdit"), 16); assertNotNull(icon16); assertEquals(16, icon16.size().width.intValue()); assertEquals(16, icon16.size().height.intValue()); final NSImage icon64 = cache.applicationIcon(new Application("com.apple.TextEdit"), 64); assertNotNull(icon64); assertEquals(64, icon64.size().width.intValue()); assertEquals(64, icon64.size().height.intValue()); }
@Override public NSImage applicationIcon(final Application app, final Integer size) { NSImage icon = this.load(app.getIdentifier(), size); if(null == icon) { final String path = NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(app.getIdentifier()); if(StringUtils.isNotBlank(path)) { return this.cache(app.getIdentifier(), this.convert(app.getIdentifier(), NSWorkspace.sharedWorkspace().iconForFile(path), size), size); } } if(null == icon) { return this.iconNamed("notfound.tiff", size); } return icon; }
NSImageIconCache implements IconCache<NSImage> { @Override public NSImage applicationIcon(final Application app, final Integer size) { NSImage icon = this.load(app.getIdentifier(), size); if(null == icon) { final String path = NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(app.getIdentifier()); if(StringUtils.isNotBlank(path)) { return this.cache(app.getIdentifier(), this.convert(app.getIdentifier(), NSWorkspace.sharedWorkspace().iconForFile(path), size), size); } } if(null == icon) { return this.iconNamed("notfound.tiff", size); } return icon; } }
NSImageIconCache implements IconCache<NSImage> { @Override public NSImage applicationIcon(final Application app, final Integer size) { NSImage icon = this.load(app.getIdentifier(), size); if(null == icon) { final String path = NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(app.getIdentifier()); if(StringUtils.isNotBlank(path)) { return this.cache(app.getIdentifier(), this.convert(app.getIdentifier(), NSWorkspace.sharedWorkspace().iconForFile(path), size), size); } } if(null == icon) { return this.iconNamed("notfound.tiff", size); } return icon; }  }
NSImageIconCache implements IconCache<NSImage> { @Override public NSImage applicationIcon(final Application app, final Integer size) { NSImage icon = this.load(app.getIdentifier(), size); if(null == icon) { final String path = NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(app.getIdentifier()); if(StringUtils.isNotBlank(path)) { return this.cache(app.getIdentifier(), this.convert(app.getIdentifier(), NSWorkspace.sharedWorkspace().iconForFile(path), size), size); } } if(null == icon) { return this.iconNamed("notfound.tiff", size); } return icon; }  @Override NSImage documentIcon(final String extension, final Integer size); @Override NSImage documentIcon(final String extension, final Integer size, final NSImage badge); @Override NSImage folderIcon(final Integer size); @Override NSImage folderIcon(final Integer size, final NSImage badge); @Override NSImage iconNamed(final String name, final Integer width, final Integer height); @Override NSImage fileIcon(final Local file, final Integer size); @Override NSImage applicationIcon(final Application app, final Integer size); @Override NSImage fileIcon(final Path file, final Integer size); @Override NSImage aliasIcon(final String extension, final Integer size); }
NSImageIconCache implements IconCache<NSImage> { @Override public NSImage applicationIcon(final Application app, final Integer size) { NSImage icon = this.load(app.getIdentifier(), size); if(null == icon) { final String path = NSWorkspace.sharedWorkspace().absolutePathForAppBundleWithIdentifier(app.getIdentifier()); if(StringUtils.isNotBlank(path)) { return this.cache(app.getIdentifier(), this.convert(app.getIdentifier(), NSWorkspace.sharedWorkspace().iconForFile(path), size), size); } } if(null == icon) { return this.iconNamed("notfound.tiff", size); } return icon; }  @Override NSImage documentIcon(final String extension, final Integer size); @Override NSImage documentIcon(final String extension, final Integer size, final NSImage badge); @Override NSImage folderIcon(final Integer size); @Override NSImage folderIcon(final Integer size, final NSImage badge); @Override NSImage iconNamed(final String name, final Integer width, final Integer height); @Override NSImage fileIcon(final Local file, final Integer size); @Override NSImage applicationIcon(final Application app, final Integer size); @Override NSImage fileIcon(final Path file, final Integer size); @Override NSImage aliasIcon(final String extension, final Integer size);  }