1 11 package org.eclipse.jface.resource; 12 13 import org.eclipse.swt.graphics.Color; 14 import org.eclipse.swt.graphics.Device; 15 import org.eclipse.swt.graphics.RGB; 16 17 22 class RGBColorDescriptor extends ColorDescriptor { 23 24 private RGB color; 25 26 29 private Color originalColor = null; 30 31 36 public RGBColorDescriptor(RGB color) { 37 this.color = color; 38 } 39 40 47 public RGBColorDescriptor(Color originalColor) { 48 this(originalColor.getRGB()); 49 this.originalColor = originalColor; 50 } 51 52 55 public boolean equals(Object obj) { 56 if (obj instanceof RGBColorDescriptor) { 57 RGBColorDescriptor other = (RGBColorDescriptor) obj; 58 59 return other.color.equals(color) && other.originalColor == originalColor; 60 } 61 62 return false; 63 } 64 65 68 public int hashCode() { 69 return color.hashCode(); 70 } 71 72 75 public Color createColor(Device device) { 76 if (originalColor != null) { 79 if (originalColor.getDevice() == device) { 81 return originalColor; 82 } 83 } 84 85 return new Color(device, color); 86 } 87 88 91 public void destroyColor(Color toDestroy) { 92 if (toDestroy == originalColor) { 93 return; 94 } 95 96 toDestroy.dispose(); 97 } 98 } 99 | Popular Tags |