1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author Alexey A. Petrenko
* @version $Revision$
*/
package java.awt;
/**
* The DisplayMode class containes the bit depth, height, width and
* refresh rate of a GraphicsDevice.
*/
public final class DisplayMode {
/** The width. */
private final int width;
/** The height. */
private final int height;
/** The bit depth. */
private final int bitDepth;
/** The refresh rate. */
private final int refreshRate;
/** The Constant Value BIT_DEPTH_MULTI indicates the bit depth */
public static final int BIT_DEPTH_MULTI = -1;
/** The Constant REFRESH_RATE_UNKNOWN indicates the refresh rate. */
public static final int REFRESH_RATE_UNKNOWN = 0;
/**
* Creates a new DisplayMode object with the specified parameters.
*
* @param width the width of the display.
* @param height the height of the display.
* @param bitDepth the bit depth of the display.
* @param refreshRate the refresh rate of the display.
*/
public DisplayMode(int width, int height, int bitDepth, int refreshRate) {
this.width = width;
this.height = height;
this.bitDepth = bitDepth;
this.refreshRate = refreshRate;
}
/**
* Compares if this DisplayMode is equal to the specified object or not.
*
* @param dm the Object to be compared.
*
* @return true, if the specified object is a DisplayMode with the same
* data values as this DisplayMode, false otherwise.
*/
@Override
public boolean equals(Object dm) {
if (dm instanceof DisplayMode) {
return equals((DisplayMode)dm);
}
return false;
}
/**
* Compares if this DisplayMode is equal to the specified DisplayMode object
* or not.
*
* @param dm the DisplayMode to be compared.
*
* @return true, if all of the data values of this DisplayMode are equal
* to the values of the specified DisplayMode object, false otherwise.
*/
public boolean equals(DisplayMode dm) {
if (dm == null) {
return false;
}
if (dm.bitDepth != bitDepth) {
return false;
}
if (dm.refreshRate != refreshRate) {
return false;
}
if (dm.width != width) {
return false;
}
if (dm.height != height) {
return false;
}
return true;
}
/**
* Gets the bit depth of the DisplayMode, returns BIT_DEPTH_MULTI value
* if multiple bit depths are supported in this display mode.
*
* @return the bit depth of the DisplayMode.
*/
public int getBitDepth() {
return bitDepth;
}
/**
* Gets the height of the DisplayMode.
*
* @return the height of the DisplayMode.
*/
public int getHeight() {
return height;
}
/**
* Gets the refresh rate of the DisplayMode, returns REFRESH_RATE_UNKNOWN
* value if the information is not available.
*
* @return the refresh rate of the DisplayMode.
*/
public int getRefreshRate() {
return refreshRate;
}
/**
* Gets the width of the DisplayMode.
*
* @return the width of the DisplayMode.
*/
public int getWidth() {
return width;
}
}
|