1 11 package org.eclipse.ltk.internal.ui.refactoring.history; 12 13 import org.eclipse.ltk.internal.ui.refactoring.RefactoringPluginImages; 14 import org.eclipse.ltk.internal.ui.refactoring.RefactoringUIPlugin; 15 16 import org.eclipse.swt.graphics.ImageData; 17 import org.eclipse.swt.graphics.Point; 18 19 import org.eclipse.jface.resource.CompositeImageDescriptor; 20 import org.eclipse.jface.resource.ImageDescriptor; 21 22 27 public final class RefactoringDescriptorImageDescriptor extends CompositeImageDescriptor { 28 29 30 public static final int WORKSPACE= 1 << 1; 31 32 33 private final int fFlags; 34 35 36 private final ImageDescriptor fImage; 37 38 39 private final Point fSize; 40 41 51 public RefactoringDescriptorImageDescriptor(final ImageDescriptor image, final int flags, final Point size) { 52 fImage= image; 53 fFlags= flags; 54 fSize= size; 55 } 56 57 60 private void drawBottomRight() { 61 final Point size= getSize(); 62 int x= size.x; 63 64 if ((fFlags & WORKSPACE) != 0) { 65 ImageData data= getImageData(RefactoringPluginImages.DESC_OVR_WORKSPACE); 66 x-= data.width; 67 drawImage(data, x, size.y - data.height); 68 } 69 } 70 71 74 protected void drawCompositeImage(final int width, final int height) { 75 drawImage(getImageData(fImage), 0, 0); 76 drawBottomRight(); 77 } 78 79 82 public boolean equals(final Object object) { 83 if (object == null || !RefactoringDescriptorImageDescriptor.class.equals(object.getClass())) 84 return false; 85 final RefactoringDescriptorImageDescriptor other= (RefactoringDescriptorImageDescriptor) object; 86 return (fImage.equals(other.fImage) && fFlags == other.fFlags && fSize.equals(other.fSize)); 87 } 88 89 96 private ImageData getImageData(final ImageDescriptor descriptor) { 97 ImageData data= descriptor.getImageData(); 98 if (data == null) { 99 data= DEFAULT_IMAGE_DATA; 100 RefactoringUIPlugin.logErrorMessage("Image data not available: " + descriptor.toString()); } 102 return data; 103 } 104 105 108 protected Point getSize() { 109 return fSize; 110 } 111 112 115 public int hashCode() { 116 return fImage.hashCode() | fFlags | fSize.hashCode(); 117 } 118 } 119 | Popular Tags |