1 /*
2 * Copyright (c) 2002-2026 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit;
16
17 import static org.htmlunit.BrowserVersionFeatures.COLOR_DEPHT_32;
18
19 import java.io.Serializable;
20
21 /**
22 * {@code Screen}.
23 *
24 * @author Mike Bowler
25 * @author Daniel Gredler
26 * @author Chris Erskine
27 * @author Ronald Brill
28 * @author Ahmed Ashour
29 * @author cd alexndr
30 */
31 public class Screen implements Serializable {
32
33 private final int screenHeight_;
34 private final int screenWidth_;
35
36 private final int colorDepth_;
37
38 /**
39 * Creates an instance.
40 * @param webClient the client this belongs to
41 */
42 public Screen(final WebClient webClient) {
43 super();
44 screenHeight_ = webClient.getOptions().getScreenHeight();
45 screenWidth_ = webClient.getOptions().getScreenWidth();
46
47 if (webClient.getBrowserVersion().hasFeature(COLOR_DEPHT_32)) {
48 colorDepth_ = 32;
49 }
50 else {
51 colorDepth_ = 24;
52 }
53 }
54
55 /**
56 * @return the {@code availHeight} property
57 */
58 public int getAvailHeight() {
59 return 1032;
60 }
61
62 /**
63 * Sets the {@code availHeight} property.
64 * @param availHeight the {@code availHeight} property
65 */
66 public void setAvailHeight(final int availHeight) {
67 // ignore
68 }
69
70 /**
71 * @return the {@code availLeft} property
72 */
73 public int getAvailLeft() {
74 return 0;
75 }
76
77 /**
78 * Sets the {@code availLeft} property.
79 * @param availLeft the {@code availLeft} property
80 */
81 public void setAvailLeft(final int availLeft) {
82 // ignore
83 }
84
85 /**
86 * @return the {@code availTop} property
87 */
88 public int getAvailTop() {
89 return 0;
90 }
91
92 /**
93 * Sets the {@code availTop} property.
94 * @param availTop the {@code availTop} property
95 */
96 public void setAvailTop(final int availTop) {
97 // ignore
98 }
99
100 /**
101 * @return the {@code availWidth} property
102 */
103 public int getAvailWidth() {
104 return 1920;
105 }
106
107 /**
108 * Sets the {@code availWidth} property.
109 * @param availWidth the {@code availWidth} property
110 */
111 public void setAvailWidth(final int availWidth) {
112 // ignore
113 }
114
115 /**
116 * @return the {@code colorDepth} property
117 */
118 public int getColorDepth() {
119 return colorDepth_;
120 }
121
122 /**
123 * Sets the {@code colorDepth} property.
124 * @param colorDepth the {@code colorDepth} property
125 */
126 public void setColorDepth(final int colorDepth) {
127 // ignore
128 }
129
130 /**
131 * @return the {@code deviceXDPI} property
132 */
133 public int getDeviceXDPI() {
134 return 96;
135 }
136
137 /**
138 * Sets the {@code deviceXDPI} property.
139 * @param deviceXDPI the {@code deviceXDPI} property
140 */
141 public void setDeviceXDPI(final int deviceXDPI) {
142 // ignore
143 }
144
145 /**
146 * @return the {@code deviceYDPI} property
147 */
148 public int getDeviceYDPI() {
149 return 96;
150 }
151
152 /**
153 * Sets the {@code deviceYDPI} property.
154 * @param deviceYDPI the {@code deviceYDPI} property
155 */
156 public void setDeviceYDPI(final int deviceYDPI) {
157 // ignore
158 }
159
160 /**
161 * @return the {@code height} property
162 */
163 public int getHeight() {
164 return screenHeight_;
165 }
166
167 /**
168 * Sets the {@code height} property.
169 * @param height the {@code height} property
170 */
171 public void setHeight(final int height) {
172 // ignore
173 }
174
175 /**
176 * @return the {@code left} property
177 */
178 public int getLeft() {
179 return 0;
180 }
181
182 /**
183 * Sets the {@code left} property.
184 * @param left the {@code left} property
185 */
186 public void setLeft(final int left) {
187 // ignore
188 }
189
190 /**
191 * @return the {@code pixelDepth} property
192 */
193 public int getPixelDepth() {
194 return colorDepth_;
195 }
196
197 /**
198 * Sets the {@code pixelDepth} property.
199 * @param pixelDepth the {@code pixelDepth} property
200 */
201 public void setPixelDepth(final int pixelDepth) {
202 // ignore
203 }
204
205 /**
206 * @return the {@code top} property
207 */
208 public int getTop() {
209 return 0;
210 }
211
212 /**
213 * Sets the {@code top} property.
214 * @param top the {@code top} property
215 */
216 public void setTop(final int top) {
217 // ignore
218 }
219
220 /**
221 * @return the {@code width} property
222 */
223 public int getWidth() {
224 return screenWidth_;
225 }
226
227 /**
228 * Sets the {@code width} property.
229 * @param width the {@code width} property
230 */
231 public void setWidth(final int width) {
232 // ignore
233 }
234 }