1 /*
2  * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.  Oracle designates this
8  * particular file as subject to the "Classpath" exception as provided
9  * by Oracle in the LICENSE file that accompanied this code.
10  *
11  * This code is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14  * version 2 for more details (a copy is included in the LICENSE file that
15  * accompanied this code).
16  *
17  * You should have received a copy of the GNU General Public License version
18  * 2 along with this work; if not, write to the Free Software Foundation,
19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20  *
21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22  * or visit www.oracle.com if you need additional information or have any
23  * questions.
24  */
25 
26 package java.awt;
27 
28 import java.io.*;
29 
30 /**
31  * The <code>GraphicsConfigTemplate</code> class is used to obtain a valid
32  * {@link GraphicsConfiguration}.  A user instantiates one of these
33  * objects and then sets all non-default attributes as desired.  The
34  * {@link GraphicsDevice#getBestConfiguration} method found in the
35  * {@link GraphicsDevice} class is then called with this
36  * <code>GraphicsConfigTemplate</code>.  A valid
37  * <code>GraphicsConfiguration</code> is returned that meets or exceeds
38  * what was requested in the <code>GraphicsConfigTemplate</code>.
39  * @see GraphicsDevice
40  * @see GraphicsConfiguration
41  *
42  * @since       1.2
43  */
44 public abstract class GraphicsConfigTemplate implements Serializable {
45     /*
46      * serialVersionUID
47      */
48     private static final long serialVersionUID = -8061369279557787079L;
49 
50     /**
51      * This class is an abstract class so only subclasses can be
52      * instantiated.
53      */
GraphicsConfigTemplate()54     public GraphicsConfigTemplate() {
55     }
56 
57     /**
58      * Value used for "Enum" (Integer) type.  States that this
59      * feature is required for the <code>GraphicsConfiguration</code>
60      * object.  If this feature is not available, do not select the
61      * <code>GraphicsConfiguration</code> object.
62      */
63     public static final int REQUIRED    = 1;
64 
65     /**
66      * Value used for "Enum" (Integer) type.  States that this
67      * feature is desired for the <code>GraphicsConfiguration</code>
68      * object.  A selection with this feature is preferred over a
69      * selection that does not include this feature, although both
70      * selections can be considered valid matches.
71      */
72     public static final int PREFERRED   = 2;
73 
74     /**
75      * Value used for "Enum" (Integer) type.  States that this
76      * feature is not necessary for the selection of the
77      * <code>GraphicsConfiguration</code> object.  A selection
78      * without this feature is preferred over a selection that
79      * includes this feature since it is not used.
80      */
81     public static final int UNNECESSARY = 3;
82 
83     /**
84      * Returns the "best" configuration possible that passes the
85      * criteria defined in the <code>GraphicsConfigTemplate</code>.
86      * @param gc the array of <code>GraphicsConfiguration</code>
87      * objects to choose from.
88      * @return a <code>GraphicsConfiguration</code> object that is
89      * the best configuration possible.
90      * @see GraphicsConfiguration
91      */
92     public abstract GraphicsConfiguration
getBestConfiguration(GraphicsConfiguration[] gc)93       getBestConfiguration(GraphicsConfiguration[] gc);
94 
95     /**
96      * Returns a <code>boolean</code> indicating whether or
97      * not the specified <code>GraphicsConfiguration</code> can be
98      * used to create a drawing surface that supports the indicated
99      * features.
100      * @param gc the <code>GraphicsConfiguration</code> object to test
101      * @return <code>true</code> if this
102      * <code>GraphicsConfiguration</code> object can be used to create
103      * surfaces that support the indicated features;
104      * <code>false</code> if the <code>GraphicsConfiguration</code> can
105      * not be used to create a drawing surface usable by this Java(tm)
106      * API.
107      */
108     public abstract boolean
isGraphicsConfigSupported(GraphicsConfiguration gc)109       isGraphicsConfigSupported(GraphicsConfiguration gc);
110 
111 }
112