1 11 package org.eclipse.ui.internal.decorators; 12 13 import java.util.HashSet ; 14 import java.util.Set ; 15 16 import org.eclipse.jface.resource.ImageDescriptor; 17 import org.eclipse.jface.resource.JFaceResources; 18 import org.eclipse.jface.resource.LocalResourceManager; 19 import org.eclipse.jface.viewers.DecorationOverlayIcon; 20 import org.eclipse.swt.graphics.Image; 21 import org.eclipse.swt.graphics.Point; 22 import org.eclipse.swt.graphics.Rectangle; 23 import org.eclipse.ui.PlatformUI; 24 25 29 class OverlayCache { 30 31 37 38 private Set keys = new HashSet (); private LocalResourceManager resourceManager; 42 43 46 public OverlayCache() { 47 super(); 48 resourceManager = new LocalResourceManager(JFaceResources 50 .getResources(PlatformUI.getWorkbench().getDisplay())); 51 } 52 53 60 private Image getImageFor(DecorationOverlayIcon icon) { 61 keys.add(icon); return resourceManager.createImage(icon); 63 } 64 65 68 void disposeAll() { 69 keys.clear(); 70 resourceManager.dispose(); 71 } 72 73 80 81 Image applyDescriptors(Image source, ImageDescriptor[] descriptors) { 82 Rectangle bounds = source.getBounds(); 83 Point size = new Point(bounds.width, bounds.height); 84 DecorationOverlayIcon icon = new DecorationOverlayIcon(source, descriptors, size); 85 return getImageFor(icon); 86 } 87 88 } 89 | Popular Tags |