A massive organize imports and formatting of the sources using default Eclipse code...
[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.2 2006-10-21 23:13:53 pombredanne 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
23  * {@link Image}.
24  */
25 public class ImageImageDescriptor extends ImageDescriptor {
26
27         // Instance Variables ------------------------------------------------------
28
29         /** The wrapped image. */
30         private Image image;
31
32         // Constructors ------------------------------------------------------------
33
34         /**
35          * Constructor.
36          * 
37          * @param image
38          *            the image to wrap
39          */
40         public ImageImageDescriptor(Image image) {
41                 this.image = image;
42         }
43
44         // ImageDescriptor Implementation ------------------------------------------
45
46         /*
47          * @see ImageDescriptor#getImageData()
48          */
49         public ImageData getImageData() {
50                 return image.getImageData();
51         }
52
53         /*
54          * @see Object#equals(Object)
55          */
56         public boolean equals(Object o) {
57                 if (o instanceof ImageImageDescriptor) {
58                         ImageImageDescriptor other = (ImageImageDescriptor) o;
59                         if (image.equals(other.image)) {
60                                 return true;
61                         }
62                 }
63                 return false;
64         }
65
66         /*
67          * @see Object#hashCode()
68          */
69         public int hashCode() {
70                 return image.hashCode();
71         }
72
73 }