author | serb |
Mon, 31 Aug 2015 16:56:09 +0300 | |
changeset 32493 | 31bd2a308840 |
parent 25859 | 3317bb8137f4 |
child 32865 | f9cb6e427f9e |
permissions | -rw-r--r-- |
2 | 1 |
/* |
25162 | 2 |
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 24 |
*/ |
25 |
||
26 |
package java.awt; |
|
27 |
||
16734
da1901d79073
8000406: change files using @GenerateNativeHeader to use @Native
dxu
parents:
12813
diff
changeset
|
28 |
import java.lang.annotation.Native; |
12813
c10ab96dcf41
7170969: Add @GenerateNativeHeader to classes whose fields need to be exported for JNI
erikj
parents:
5506
diff
changeset
|
29 |
|
2 | 30 |
/** |
31 |
* The <code>DisplayMode</code> class encapsulates the bit depth, height, |
|
32 |
* width, and refresh rate of a <code>GraphicsDevice</code>. The ability to |
|
33 |
* change graphics device's display mode is platform- and |
|
34 |
* configuration-dependent and may not always be available |
|
35 |
* (see {@link GraphicsDevice#isDisplayChangeSupported}). |
|
36 |
* <p> |
|
37 |
* For more information on full-screen exclusive mode API, see the |
|
20455
f6f9a0c2796b
8020688: Broken links in documentation at http://docs.oracle.com/javase/6/docs/api/index.
mcherkas
parents:
16734
diff
changeset
|
38 |
* <a href="http://docs.oracle.com/javase/tutorial/extra/fullscreen/index.html"> |
2 | 39 |
* Full-Screen Exclusive Mode API Tutorial</a>. |
40 |
* |
|
41 |
* @see GraphicsDevice |
|
42 |
* @see GraphicsDevice#isDisplayChangeSupported |
|
43 |
* @see GraphicsDevice#getDisplayModes |
|
44 |
* @see GraphicsDevice#setDisplayMode |
|
45 |
* @author Michael Martak |
|
46 |
* @since 1.4 |
|
47 |
*/ |
|
12813
c10ab96dcf41
7170969: Add @GenerateNativeHeader to classes whose fields need to be exported for JNI
erikj
parents:
5506
diff
changeset
|
48 |
|
2 | 49 |
public final class DisplayMode { |
50 |
||
51 |
private Dimension size; |
|
52 |
private int bitDepth; |
|
53 |
private int refreshRate; |
|
54 |
||
55 |
/** |
|
56 |
* Create a new display mode object with the supplied parameters. |
|
57 |
* @param width the width of the display, in pixels |
|
58 |
* @param height the height of the display, in pixels |
|
59 |
* @param bitDepth the bit depth of the display, in bits per |
|
60 |
* pixel. This can be <code>BIT_DEPTH_MULTI</code> if multiple |
|
61 |
* bit depths are available. |
|
62 |
* @param refreshRate the refresh rate of the display, in hertz. |
|
63 |
* This can be <code>REFRESH_RATE_UNKNOWN</code> if the |
|
64 |
* information is not available. |
|
65 |
* @see #BIT_DEPTH_MULTI |
|
66 |
* @see #REFRESH_RATE_UNKNOWN |
|
67 |
*/ |
|
68 |
public DisplayMode(int width, int height, int bitDepth, int refreshRate) { |
|
69 |
this.size = new Dimension(width, height); |
|
70 |
this.bitDepth = bitDepth; |
|
71 |
this.refreshRate = refreshRate; |
|
72 |
} |
|
73 |
||
74 |
/** |
|
75 |
* Returns the height of the display, in pixels. |
|
76 |
* @return the height of the display, in pixels |
|
77 |
*/ |
|
78 |
public int getHeight() { |
|
79 |
return size.height; |
|
80 |
} |
|
81 |
||
82 |
/** |
|
83 |
* Returns the width of the display, in pixels. |
|
84 |
* @return the width of the display, in pixels |
|
85 |
*/ |
|
86 |
public int getWidth() { |
|
87 |
return size.width; |
|
88 |
} |
|
89 |
||
90 |
/** |
|
91 |
* Value of the bit depth if multiple bit depths are supported in this |
|
92 |
* display mode. |
|
93 |
* @see #getBitDepth |
|
94 |
*/ |
|
16734
da1901d79073
8000406: change files using @GenerateNativeHeader to use @Native
dxu
parents:
12813
diff
changeset
|
95 |
@Native public final static int BIT_DEPTH_MULTI = -1; |
2 | 96 |
|
97 |
/** |
|
98 |
* Returns the bit depth of the display, in bits per pixel. This may be |
|
99 |
* <code>BIT_DEPTH_MULTI</code> if multiple bit depths are supported in |
|
100 |
* this display mode. |
|
101 |
* |
|
102 |
* @return the bit depth of the display, in bits per pixel. |
|
103 |
* @see #BIT_DEPTH_MULTI |
|
104 |
*/ |
|
105 |
public int getBitDepth() { |
|
106 |
return bitDepth; |
|
107 |
} |
|
108 |
||
109 |
/** |
|
110 |
* Value of the refresh rate if not known. |
|
111 |
* @see #getRefreshRate |
|
112 |
*/ |
|
16734
da1901d79073
8000406: change files using @GenerateNativeHeader to use @Native
dxu
parents:
12813
diff
changeset
|
113 |
@Native public final static int REFRESH_RATE_UNKNOWN = 0; |
2 | 114 |
|
115 |
/** |
|
116 |
* Returns the refresh rate of the display, in hertz. This may be |
|
117 |
* <code>REFRESH_RATE_UNKNOWN</code> if the information is not available. |
|
118 |
* |
|
119 |
* @return the refresh rate of the display, in hertz. |
|
120 |
* @see #REFRESH_RATE_UNKNOWN |
|
121 |
*/ |
|
122 |
public int getRefreshRate() { |
|
123 |
return refreshRate; |
|
124 |
} |
|
125 |
||
126 |
/** |
|
127 |
* Returns whether the two display modes are equal. |
|
25162 | 128 |
* |
129 |
* @param dm the display mode to compare to |
|
2 | 130 |
* @return whether the two display modes are equal |
131 |
*/ |
|
132 |
public boolean equals(DisplayMode dm) { |
|
133 |
if (dm == null) { |
|
134 |
return false; |
|
135 |
} |
|
136 |
return (getHeight() == dm.getHeight() |
|
137 |
&& getWidth() == dm.getWidth() |
|
138 |
&& getBitDepth() == dm.getBitDepth() |
|
139 |
&& getRefreshRate() == dm.getRefreshRate()); |
|
140 |
} |
|
141 |
||
142 |
/** |
|
143 |
* {@inheritDoc} |
|
144 |
*/ |
|
145 |
public boolean equals(Object dm) { |
|
146 |
if (dm instanceof DisplayMode) { |
|
147 |
return equals((DisplayMode)dm); |
|
148 |
} else { |
|
149 |
return false; |
|
150 |
} |
|
151 |
} |
|
152 |
||
153 |
/** |
|
154 |
* {@inheritDoc} |
|
155 |
*/ |
|
156 |
public int hashCode() { |
|
157 |
return getWidth() + getHeight() + getBitDepth() * 7 |
|
158 |
+ getRefreshRate() * 13; |
|
159 |
} |
|
160 |
||
161 |
} |