1 12 package org.eclipse.jdt.internal.ui.callhierarchy; 13 14 import org.eclipse.core.runtime.Assert; 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 import org.eclipse.jdt.internal.ui.JavaPlugin; 23 import org.eclipse.jdt.internal.ui.JavaPluginImages; 24 25 26 public class CallHierarchyImageDescriptor extends CompositeImageDescriptor { 27 28 29 public final static int RECURSIVE= 0x001; 30 31 32 public final static int MAX_LEVEL= 0x002; 33 34 private ImageDescriptor fBaseImage; 35 private int fFlags; 36 private Point fSize; 37 38 47 public CallHierarchyImageDescriptor(ImageDescriptor baseImage, int flags, Point size) { 48 fBaseImage= baseImage; 49 Assert.isNotNull(fBaseImage); 50 fFlags= flags; 51 Assert.isTrue(fFlags >= 0); 52 fSize= size; 53 Assert.isNotNull(fSize); 54 } 55 56 62 public void setAdornments(int adornments) { 63 Assert.isTrue(adornments >= 0); 64 fFlags= adornments; 65 } 66 67 72 public int getAdronments() { 73 return fFlags; 74 } 75 76 82 public void setImageSize(Point size) { 83 Assert.isNotNull(size); 84 Assert.isTrue(size.x >= 0 && size.y >= 0); 85 fSize= size; 86 } 87 88 94 public Point getImageSize() { 95 return new Point(fSize.x, fSize.y); 96 } 97 98 101 protected Point getSize() { 102 return fSize; 103 } 104 105 108 public boolean equals(Object object) { 109 if (object == null || !CallHierarchyImageDescriptor.class.equals(object.getClass())) 110 return false; 111 112 CallHierarchyImageDescriptor other= (CallHierarchyImageDescriptor)object; 113 return (fBaseImage.equals(other.fBaseImage) && fFlags == other.fFlags && fSize.equals(other.fSize)); 114 } 115 116 119 public int hashCode() { 120 return fBaseImage.hashCode() | fFlags | fSize.hashCode(); 121 } 122 123 126 protected void drawCompositeImage(int width, int height) { 127 ImageData bg= getImageData(fBaseImage); 128 129 drawImage(bg, 0, 0); 130 drawBottomLeft(); 131 } 132 133 private ImageData getImageData(ImageDescriptor descriptor) { 134 ImageData data= descriptor.getImageData(); if (data == null) { 136 data= DEFAULT_IMAGE_DATA; 137 JavaPlugin.logErrorMessage("Image data not available: " + descriptor.toString()); } 139 return data; 140 } 141 142 private void drawBottomLeft() { 143 Point size= getSize(); 144 int x= 0; 145 ImageData data= null; 146 if ((fFlags & RECURSIVE) != 0) { 147 data= getImageData(JavaPluginImages.DESC_OVR_RECURSIVE); 148 drawImage(data, x, size.y - data.height); 149 x+= data.width; 150 } 151 if ((fFlags & MAX_LEVEL) != 0) { 152 data= getImageData(JavaPluginImages.DESC_OVR_MAX_LEVEL); 153 drawImage(data, x, size.y - data.height); 154 x+= data.width; 155 } 156 } 157 } 158 | Popular Tags |