intial source from http://www.sf.net/projects/wdte
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpeclipse / ui / views / util / ImageImageDescriptor.java
1 /*
2  * Copyright (c) 2004 Christopher Lenz and others
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     Christopher Lenz - initial version based on the Eclipse class of the same
10  *                        name in org.eclipse.jdt.internal.ui.viewsupport
11  * 
12  * $Id: ImageImageDescriptor.java,v 1.1 2004-09-02 18:26:28 jsurfer Exp $
13  */
14
15 package net.sourceforge.phpeclipse.ui.views.util;
16
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.eclipse.swt.graphics.Image;
19 import org.eclipse.swt.graphics.ImageData;
20
21 /**
22  * <tt>ImageDescriptor</tt> implementation that wraps an existing {@link Image}.
23  */
24 public class ImageImageDescriptor extends ImageDescriptor {
25
26         // Instance Variables ------------------------------------------------------
27
28         /** The wrapped image. */
29         private Image image;
30
31         // Constructors ------------------------------------------------------------
32
33         /**
34          * Constructor.
35          * 
36          * @param image the image to wrap
37          */
38         public ImageImageDescriptor(Image image) {
39                 this.image= image;
40         }
41
42         // ImageDescriptor Implementation ------------------------------------------
43
44         /*
45          * @see ImageDescriptor#getImageData()
46          */
47         public ImageData getImageData() {
48                 return image.getImageData();
49         }
50
51         /*
52          * @see Object#equals(Object)
53          */
54         public boolean equals(Object o) {
55                 if (o instanceof ImageImageDescriptor) {
56                         ImageImageDescriptor other = (ImageImageDescriptor) o;
57                         if (image.equals(other.image)) {
58                                 return true;
59                         }
60                 }
61                 return false;
62         }
63
64         /*
65          * @see Object#hashCode()
66          */
67         public int hashCode() {
68                 return image.hashCode();
69         }
70
71 }