KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > BufferCapabilities


1 /*
2  * @(#)BufferCapabilities.java 1.8 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.awt;
9
10 /**
11  * Capabilities and properties of buffers.
12  *
13  * @see java.awt.image.BufferStrategy#getCapabilities()
14  * @see GraphicsConfiguration#getBufferCapabilities
15  * @author Michael Martak
16  * @since 1.4
17  */

18 public class BufferCapabilities implements Cloneable JavaDoc {
19
20     private ImageCapabilities JavaDoc frontCaps;
21     private ImageCapabilities JavaDoc backCaps;
22     private FlipContents flipContents;
23     
24     /**
25      * Creates a new object for specifying buffering capabilities
26      * @param frontCaps the capabilities of the front buffer; cannot be
27      * <code>null</code>
28      * @param backCaps the capabilities of the back and intermediate buffers;
29      * cannot be <code>null</code>
30      * @param flipContents the contents of the back buffer after page-flipping,
31      * <code>null</code> if page flipping is not used (implies blitting)
32      * @exception IllegalArgumentException if frontCaps or backCaps are
33      * <code>null</code>
34      */

35     public BufferCapabilities(ImageCapabilities JavaDoc frontCaps,
36         ImageCapabilities JavaDoc backCaps, FlipContents flipContents) {
37         if (frontCaps == null || backCaps == null) {
38             throw new IllegalArgumentException JavaDoc(
39                 "Image capabilities specified cannot be null");
40         }
41         this.frontCaps = frontCaps;
42         this.backCaps = backCaps;
43         this.flipContents = flipContents;
44     }
45
46     /**
47      * @return the image capabilities of the front (displayed) buffer
48      */

49     public ImageCapabilities JavaDoc getFrontBufferCapabilities() {
50         return frontCaps;
51     }
52
53     /**
54      * @return the image capabilities of all back buffers (intermediate buffers
55      * are considered back buffers)
56      */

57     public ImageCapabilities JavaDoc getBackBufferCapabilities() {
58         return backCaps;
59     }
60
61     /**
62      * @return whether or not the buffer strategy uses page flipping; a set of
63      * buffers that uses page flipping
64      * can swap the contents internally between the front buffer and one or
65      * more back buffers by switching the video pointer (or by copying memory
66      * internally). A non-flipping set of
67      * buffers uses blitting to copy the contents from one buffer to
68      * another; when this is the case, <code>getFlipContents</code> returns
69      * <code>null</code>
70      */

71     public boolean isPageFlipping() {
72         return (getFlipContents() != null);
73     }
74
75     /**
76      * @return the resulting contents of the back buffer after page-flipping.
77      * This value is <code>null</code> when the <code>isPageFlipping</code>
78      * returns <code>false</code>, implying blitting. It can be one of
79      * <code>FlipContents.UNDEFINED</code>
80      * (the assumed default), <code>FlipContents.BACKGROUND</code>,
81      * <code>FlipContents.PRIOR</code>, or
82      * <code>FlipContents.COPIED</code>.
83      * @see #isPageFlipping
84      * @see FlipContents#UNDEFINED
85      * @see FlipContents#BACKGROUND
86      * @see FlipContents#PRIOR
87      * @see FlipContents#COPIED
88      */

89     public FlipContents getFlipContents() {
90         return flipContents;
91     }
92
93     /**
94      * @return whether page flipping is only available in full-screen mode. If this
95      * is <code>true</code>, full-screen exclusive mode is required for
96      * page-flipping.
97      * @see #isPageFlipping
98      * @see GraphicsDevice#setFullScreenWindow
99      */

100     public boolean isFullScreenRequired() {
101         return false;
102     }
103
104     /**
105      * @return whether or not
106      * page flipping can be performed using more than two buffers (one or more
107      * intermediate buffers as well as the front and back buffer).
108      * @see #isPageFlipping
109      */

110     public boolean isMultiBufferAvailable() {
111         return false;
112     }
113
114     /**
115      * @return a copy of this BufferCapabilities object.
116      */

117     public Object JavaDoc clone() {
118         try {
119             return super.clone();
120         } catch (CloneNotSupportedException JavaDoc e) {
121             // Since we implement Cloneable, this should never happen
122
throw new InternalError JavaDoc();
123         }
124     }
125
126     // Inner class FlipContents
127
/**
128      * A type-safe enumeration of the possible back buffer contents after
129      * page-flipping
130      */

131     public static final class FlipContents extends AttributeValue JavaDoc {
132         
133         private static int I_UNDEFINED = 0;
134         private static int I_BACKGROUND = 1;
135         private static int I_PRIOR = 2;
136         private static int I_COPIED = 3;
137
138         private static final String JavaDoc NAMES[] =
139             { "undefined", "background", "prior", "copied" };
140             
141         /**
142          * When flip contents are <code>UNDEFINED</code>, the
143          * contents of the back buffer are undefined after flipping.
144          * @see #isPageFlipping
145          * @see #getFlipContents
146          * @see #BACKGROUND
147          * @see #PRIOR
148          * @see #COPIED
149          */

150         public static final FlipContents UNDEFINED =
151             new FlipContents(I_UNDEFINED);
152
153         /**
154          * When flip contents are <code>BACKGROUND</code>, the
155          * contents of the back buffer are cleared with the background color after
156          * flipping.
157          * @see #isPageFlipping
158          * @see #getFlipContents
159          * @see #UNDEFINED
160          * @see #PRIOR
161          * @see #COPIED
162          */

163         public static final FlipContents BACKGROUND =
164             new FlipContents(I_BACKGROUND);
165
166         /**
167          * When flip contents are <code>PRIOR</code>, the
168          * contents of the back buffer are the prior contents of the front buffer
169          * (a true page flip).
170          * @see #isPageFlipping
171          * @see #getFlipContents
172          * @see #UNDEFINED
173          * @see #BACKGROUND
174          * @see #COPIED
175          */

176         public static final FlipContents PRIOR =
177             new FlipContents(I_PRIOR);
178
179         /**
180          * When flip contents are <code>COPIED</code>, the
181          * contents of the back buffer are copied to the front buffer when
182          * flipping.
183          * @see #isPageFlipping
184          * @see #getFlipContents
185          * @see #UNDEFINED
186          * @see #BACKGROUND
187          * @see #PRIOR
188          */

189         public static final FlipContents COPIED =
190             new FlipContents(I_COPIED);
191         
192         private FlipContents(int type) {
193             super(type, NAMES);
194         }
195         
196     } // Inner class FlipContents
197

198 }
199
Popular Tags