KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > graphics > Resource


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.swt.graphics;
12
13 import org.eclipse.swt.*;
14
15 /**
16  * This class is the abstract superclass of all graphics resource objects.
17  * Resources created by the application must be disposed.
18  * <p>
19  * IMPORTANT: This class is intended to be subclassed <em>only</em>
20  * within the SWT implementation. However, it has not been marked
21  * final to allow those outside of the SWT development team to implement
22  * patched versions of the class in order to get around specific
23  * limitations in advance of when those limitations can be addressed
24  * by the team. Any class built using subclassing to access the internals
25  * of this class will likely fail to compile or run between releases and
26  * may be strongly platform specific. Subclassing should not be attempted
27  * without an intimate and detailed understanding of the workings of the
28  * hierarchy. No support is provided for user-written classes which are
29  * implemented as subclasses of this class.
30  * </p>
31  *
32  * @see #dispose
33  * @see #isDisposed
34  *
35  * @since 3.1
36  */

37 public abstract class Resource {
38     
39     /**
40      * the device where this resource was created
41      */

42     Device device;
43
44 /**
45  * Disposes of the operating system resources associated with
46  * this resource. Applications must dispose of all resources
47  * which they allocate.
48  */

49 public abstract void dispose();
50
51 /**
52  * Returns the <code>Device</code> where this resource was
53  * created.
54  *
55  * @return <code>Device</code> the device of the receiver
56  *
57  * @since 3.2
58  */

59 public Device getDevice() {
60     Device device = this.device;
61     if (device == null || isDisposed ()) SWT.error (SWT.ERROR_GRAPHIC_DISPOSED);
62     return device;
63 }
64
65 /**
66  * Returns <code>true</code> if the resource has been disposed,
67  * and <code>false</code> otherwise.
68  * <p>
69  * This method gets the dispose state for the resource.
70  * When a resource has been disposed, it is an error to
71  * invoke any other method using the resource.
72  *
73  * @return <code>true</code> when the resource is disposed and <code>false</code> otherwise
74  */

75 public abstract boolean isDisposed();
76
77 }
78
Popular Tags