68 public static List<Screen> getScreens() { 69 if (screens == null) { 70 throw new RuntimeException("Internal graphics not initialized yet"); 71 } 72 73 return screens; 74 } 75 76 private static EventHandler eventHandler; 77 78 private volatile long ptr; 79 private volatile int adapter; 80 81 private final int depth; 82 83 private final int x; 84 private final int y; 85 private final int width; 86 private final int height; 87 88 private final int visibleX; 89 private final int visibleY; 90 private final int visibleWidth; 91 private final int visibleHeight; 92 93 private final int resolutionX; 94 private final int resolutionY; 95 96 private final float uiScale; 97 private final float renderScale; 98 99 protected Screen( 100 long nativePtr, 101 102 int depth, 103 int x, 104 int y, 105 int width, 106 int height, 107 108 int visibleX, 109 int visibleY, 110 int visibleWidth, 111 int visibleHeight, 112 113 int resolutionX, 114 int resolutionY, 115 116 float renderScale 117 ) { 118 this(nativePtr, 119 depth, x, y, width, height, 120 visibleX, visibleY, visibleWidth, visibleHeight, 121 resolutionX, resolutionY, 122 1.0f, renderScale); 123 } 124 125 protected Screen( 126 long nativePtr, 127 128 int depth, 129 int x, 130 int y, 131 int width, 132 int height, 133 134 int visibleX, 135 int visibleY, 136 int visibleWidth, 137 int visibleHeight, 138 139 int resolutionX, 140 int resolutionY, 141 142 float uiScale, 143 float renderScale 144 ) { 145 this.ptr = nativePtr; 146 147 this.depth = depth; 148 149 this.x = x; 150 this.y = y; 151 this.width = width; 152 this.height = height; 153 154 this.visibleX = visibleX; 155 this.visibleY = visibleY; 156 this.visibleWidth = visibleWidth; 157 this.visibleHeight = visibleHeight; 158 159 if (dpiOverride > 0) { 160 this.resolutionX = this.resolutionY = dpiOverride; 161 } else { 162 this.resolutionX = resolutionX; 163 this.resolutionY = resolutionY; 164 } 165 166 this.uiScale = uiScale; 167 this.renderScale = renderScale; 168 } 169 170 /** 171 * Could be called from any thread 172 */ 173 public int getDepth() { 174 return this.depth; 175 } 176 177 /** 178 * Could be called from any thread 179 */ 180 public int getX() { 181 return this.x; 182 } 183 184 /** 185 * Could be called from any thread 186 */ 187 public int getY() { 188 return this.y; 189 } 190 191 /** 192 * Could be called from any thread 193 */ 194 public int getWidth() { 195 return this.width; 196 } 197 198 /** 199 * Could be called from any thread 200 */ 201 public int getHeight() { 202 return this.height; 203 } 204 205 /** 206 * Could be called from any thread 207 */ 208 public int getVisibleX() { 209 return this.visibleX; 210 } 211 212 /** 213 * Could be called from any thread 214 */ 215 public int getVisibleY() { 216 return this.visibleY; 217 } 218 219 /** 220 * Could be called from any thread 221 */ 222 public int getVisibleWidth() { 223 return this.visibleWidth; 224 } 225 226 /** 227 * Could be called from any thread 228 */ 229 public int getVisibleHeight() { 230 return this.visibleHeight; 231 } 232 233 /** 234 * Could be called from any thread 235 */ 236 public int getResolutionX() { 237 return this.resolutionX; 238 } 239 240 /** 241 * Could be called from any thread 242 */ 243 public int getResolutionY() { 244 return this.resolutionY; 245 } 246 247 /** 248 * Returns the scaling of the UI (window sizes and event coordinates) 249 * on the screen. 250 * Could be called from any thread 251 */ 252 public float getUIScale() { 253 return this.uiScale; 254 } 255 256 /** 257 * Returns the recommended scaling for rendering an image for this 258 * screen, potentially larger than {@link #getUIScale()}. 259 * Could be called from any thread 260 */ 261 public float getRenderScale() { 262 return this.renderScale; 263 } 264 265 /** 266 * Could be called from any thread 267 */ 268 public long getNativeScreen() { 269 return this.ptr; 270 } 271 272 private void dispose() { 273 this.ptr = 0L; 274 } 275 276 public int getAdapterOrdinal() { 277 return this.adapter; 278 } 279 280 public void setAdapterOrdinal(int adapter) { 281 this.adapter = adapter; 282 } 283 284 public static void setEventHandler(EventHandler eh) { 285 Application.checkEventThread(); 324 } 325 326 static void initScreens() { 327 Application.checkEventThread(); 328 Screen[] newScreens = Application.GetApplication().staticScreen_getScreens(); 329 if (newScreens == null) { 330 throw new RuntimeException("Internal graphics failed to initialize"); 331 } 332 screens = Collections.unmodifiableList(Arrays.asList(newScreens)); 333 } 334 335 @Override public String toString() { 336 return "Screen:"+"\n"+ 337 " ptr:"+getNativeScreen()+"\n"+ 338 " adapter:"+getAdapterOrdinal()+"\n"+ 339 " depth:"+getDepth()+"\n"+ 340 " x:"+getX()+"\n"+ 341 " y:"+getY()+"\n"+ 342 " width:"+getWidth()+"\n"+ 343 " height:"+getHeight()+"\n"+ 344 " visibleX:"+getVisibleX()+"\n"+ 345 " visibleY:"+getVisibleY()+"\n"+ 346 " visibleWidth:"+getVisibleWidth()+"\n"+ 347 " visibleHeight:"+getVisibleHeight()+"\n"+ 348 " uiScale:"+getUIScale()+"\n"+ 349 " RenderScale:"+getRenderScale()+"\n"+ 350 " resolutionX:"+getResolutionX()+"\n"+ 351 " resolutionY:"+getResolutionY()+"\n"; 352 } 353 354 @Override public boolean equals(Object o) { 355 if (this == o) return true; 356 if (o == null || getClass() != o.getClass()) return false; 357 358 Screen screen = (Screen) o; 359 return ptr == screen.ptr 360 && adapter == screen.adapter 361 && depth == screen.depth 362 && x == screen.x 363 && y == screen.y 364 && width == screen.width 365 && height == screen.height 366 && visibleX == screen.visibleX 367 && visibleY == screen.visibleY 368 && visibleWidth == screen.visibleWidth 369 && visibleHeight == screen.visibleHeight 370 && resolutionX == screen.resolutionX 371 && resolutionY == screen.resolutionY 372 && Float.compare(screen.uiScale, uiScale) == 0 373 && Float.compare(screen.renderScale, renderScale) == 0; 374 } 375 376 @Override public int hashCode() { 377 int result = 17; 378 result = 31 * result + (int) (ptr ^ (ptr >>> 32)); 379 result = 31 * result + adapter; 380 result = 31 * result + depth; 381 result = 31 * result + x; 382 result = 31 * result + y; 383 result = 31 * result + width; 384 result = 31 * result + height; 385 result = 31 * result + visibleX; 386 result = 31 * result + visibleY; 387 result = 31 * result + visibleWidth; 388 result = 31 * result + visibleHeight; 389 result = 31 * result + resolutionX; 390 result = 31 * result + resolutionY; 391 result = 31 * result + (uiScale != +0.0f ? Float.floatToIntBits(uiScale) : 0); 392 result = 31 * result + (renderScale != +0.0f ? Float.floatToIntBits(renderScale) : 0); 393 return result; 394 } 395 } | 68 public static List<Screen> getScreens() { 69 if (screens == null) { 70 throw new RuntimeException("Internal graphics not initialized yet"); 71 } 72 73 return screens; 74 } 75 76 private static EventHandler eventHandler; 77 78 private volatile long ptr; 79 private volatile int adapter; 80 81 private final int depth; 82 83 private final int x; 84 private final int y; 85 private final int width; 86 private final int height; 87 88 private final int platformX; 89 private final int platformY; 90 private final int platformWidth; 91 private final int platformHeight; 92 93 private final int visibleX; 94 private final int visibleY; 95 private final int visibleWidth; 96 private final int visibleHeight; 97 98 private final int resolutionX; 99 private final int resolutionY; 100 101 private final float platformScaleX; 102 private final float platformScaleY; 103 private final float outputScaleX; 104 private final float outputScaleY; 105 106 public Screen( 107 long nativePtr, 108 109 int depth, 110 int x, 111 int y, 112 int width, 113 int height, 114 115 int platformX, 116 int platformY, 117 int platformWidth, 118 int platformHeight, 119 120 int visibleX, 121 int visibleY, 122 int visibleWidth, 123 int visibleHeight, 124 125 int resolutionX, 126 int resolutionY, 127 128 float platformScaleX, 129 float platformScaleY, 130 float outputScaleX, 131 float outputScaleY 132 ) { 133 this.ptr = nativePtr; 134 135 this.depth = depth; 136 137 this.x = x; 138 this.y = y; 139 this.width = width; 140 this.height = height; 141 142 this.platformX = platformX; 143 this.platformY = platformY; 144 this.platformWidth = platformWidth; 145 this.platformHeight = platformHeight; 146 147 this.visibleX = visibleX; 148 this.visibleY = visibleY; 149 this.visibleWidth = visibleWidth; 150 this.visibleHeight = visibleHeight; 151 152 if (dpiOverride > 0) { 153 this.resolutionX = this.resolutionY = dpiOverride; 154 } else { 155 this.resolutionX = resolutionX; 156 this.resolutionY = resolutionY; 157 } 158 159 this.platformScaleX = platformScaleX; 160 this.platformScaleY = platformScaleY; 161 this.outputScaleX = outputScaleX; 162 this.outputScaleY = outputScaleY; 163 } 164 165 /** 166 * Could be called from any thread 167 */ 168 public int getDepth() { 169 return this.depth; 170 } 171 172 /** 173 * Could be called from any thread 174 */ 175 public int getX() { 176 return this.x; 177 } 178 179 /** 180 * Could be called from any thread 181 */ 182 public int getY() { 183 return this.y; 184 } 185 186 /** 187 * Could be called from any thread 188 */ 189 public int getWidth() { 190 return this.width; 191 } 192 193 /** 194 * Could be called from any thread 195 */ 196 public int getHeight() { 197 return this.height; 198 } 199 200 /** 201 * Could be called from any thread 202 */ 203 public int getPlatformX() { 204 return this.platformX; 205 } 206 207 /** 208 * Could be called from any thread 209 */ 210 public int getPlatformY() { 211 return this.platformY; 212 } 213 214 /** 215 * Could be called from any thread 216 */ 217 public int getPlatformWidth() { 218 return this.platformWidth; 219 } 220 221 /** 222 * Could be called from any thread 223 */ 224 public int getPlatformHeight() { 225 return this.platformHeight; 226 } 227 228 /** 229 * Returns the horizontal scaling of the UI (window sizes and event 230 * coordinates) from FX logical units to the platform units. 231 * Could be called from any thread 232 * @return platform X scaling 233 */ 234 public float getPlatformScaleX() { 235 return this.platformScaleX; 236 } 237 238 /** 239 * Returns the vertical scaling of the UI (window sizes and event 240 * coordinates) from FX logical units to the platform units. 241 * Could be called from any thread 242 * @return platform Y scaling 243 */ 244 public float getPlatformScaleY() { 245 return this.platformScaleY; 246 } 247 248 /** 249 * Returns the recommended horizontal scaling for the rendered frames. 250 * Could be called from any thread 251 * @return recommended render X scaling 252 */ 253 public float getRecommendedOutputScaleX() { 254 return this.outputScaleX; 255 } 256 257 /** 258 * Returns the recommended vertical scaling for the rendered frames. 259 * Could be called from any thread 260 * @return recommended render Y scaling 261 */ 262 public float getRecommendedOutputScaleY() { 263 return this.outputScaleY; 264 } 265 266 /** 267 * Could be called from any thread 268 */ 269 public int getVisibleX() { 270 return this.visibleX; 271 } 272 273 /** 274 * Could be called from any thread 275 */ 276 public int getVisibleY() { 277 return this.visibleY; 278 } 279 280 /** 281 * Could be called from any thread 282 */ 283 public int getVisibleWidth() { 284 return this.visibleWidth; 285 } 286 287 /** 288 * Could be called from any thread 289 */ 290 public int getVisibleHeight() { 291 return this.visibleHeight; 292 } 293 294 /** 295 * Could be called from any thread 296 */ 297 public int getResolutionX() { 298 return this.resolutionX; 299 } 300 301 /** 302 * Could be called from any thread 303 */ 304 public int getResolutionY() { 305 return this.resolutionY; 306 } 307 308 /** 309 * Could be called from any thread 310 */ 311 public long getNativeScreen() { 312 return this.ptr; 313 } 314 315 private void dispose() { 316 this.ptr = 0L; 317 } 318 319 public int getAdapterOrdinal() { 320 return this.adapter; 321 } 322 323 public void setAdapterOrdinal(int adapter) { 324 this.adapter = adapter; 325 } 326 327 public static void setEventHandler(EventHandler eh) { 328 Application.checkEventThread(); 367 } 368 369 static void initScreens() { 370 Application.checkEventThread(); 371 Screen[] newScreens = Application.GetApplication().staticScreen_getScreens(); 372 if (newScreens == null) { 373 throw new RuntimeException("Internal graphics failed to initialize"); 374 } 375 screens = Collections.unmodifiableList(Arrays.asList(newScreens)); 376 } 377 378 @Override public String toString() { 379 return "Screen:"+"\n"+ 380 " ptr:"+getNativeScreen()+"\n"+ 381 " adapter:"+getAdapterOrdinal()+"\n"+ 382 " depth:"+getDepth()+"\n"+ 383 " x:"+getX()+"\n"+ 384 " y:"+getY()+"\n"+ 385 " width:"+getWidth()+"\n"+ 386 " height:"+getHeight()+"\n"+ 387 " platformX:"+getPlatformX()+"\n"+ 388 " platformY:"+getPlatformY()+"\n"+ 389 " platformWidth:"+getPlatformWidth()+"\n"+ 390 " platformHeight:"+getPlatformHeight()+"\n"+ 391 " visibleX:"+getVisibleX()+"\n"+ 392 " visibleY:"+getVisibleY()+"\n"+ 393 " visibleWidth:"+getVisibleWidth()+"\n"+ 394 " visibleHeight:"+getVisibleHeight()+"\n"+ 395 " platformScaleX:"+getPlatformScaleX()+"\n"+ 396 " platformScaleY:"+getPlatformScaleY()+"\n"+ 397 " outputScaleX:"+getRecommendedOutputScaleX()+"\n"+ 398 " outputScaleY:"+getRecommendedOutputScaleY()+"\n"+ 399 " resolutionX:"+getResolutionX()+"\n"+ 400 " resolutionY:"+getResolutionY()+"\n"; 401 } 402 403 @Override public boolean equals(Object o) { 404 if (this == o) return true; 405 if (o == null || getClass() != o.getClass()) return false; 406 407 Screen screen = (Screen) o; 408 return ptr == screen.ptr 409 && adapter == screen.adapter 410 && depth == screen.depth 411 && x == screen.x 412 && y == screen.y 413 && width == screen.width 414 && height == screen.height 415 && visibleX == screen.visibleX 416 && visibleY == screen.visibleY 417 && visibleWidth == screen.visibleWidth 418 && visibleHeight == screen.visibleHeight 419 && resolutionX == screen.resolutionX 420 && resolutionY == screen.resolutionY 421 && Float.compare(screen.platformScaleX, platformScaleX) == 0 422 && Float.compare(screen.platformScaleY, platformScaleY) == 0 423 && Float.compare(screen.outputScaleX, outputScaleX) == 0 424 && Float.compare(screen.outputScaleY, outputScaleY) == 0; 425 } 426 427 @Override public int hashCode() { 428 int result = 17; 429 result = 31 * result + (int) (ptr ^ (ptr >>> 32)); 430 result = 31 * result + adapter; 431 result = 31 * result + depth; 432 result = 31 * result + x; 433 result = 31 * result + y; 434 result = 31 * result + width; 435 result = 31 * result + height; 436 result = 31 * result + visibleX; 437 result = 31 * result + visibleY; 438 result = 31 * result + visibleWidth; 439 result = 31 * result + visibleHeight; 440 result = 31 * result + resolutionX; 441 result = 31 * result + resolutionY; 442 result = 31 * result + (platformScaleX != +0.0f ? Float.floatToIntBits(platformScaleX) : 0); 443 result = 31 * result + (platformScaleY != +0.0f ? Float.floatToIntBits(platformScaleY) : 0); 444 result = 31 * result + (outputScaleX != +0.0f ? Float.floatToIntBits(outputScaleX) : 0); 445 result = 31 * result + (outputScaleY != +0.0f ? Float.floatToIntBits(outputScaleY) : 0); 446 return result; 447 } 448 } |