JOGL v2.6.0
JOGL, High-Performance Graphics Binding for Java™ (public API).
MonitorDevice.java
Go to the documentation of this file.
1/**
2 * Copyright 2013 JogAmp Community. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without modification, are
5 * permitted provided that the following conditions are met:
6 *
7 * 1. Redistributions of source code must retain the above copyright notice, this list of
8 * conditions and the following disclaimer.
9 *
10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11 * of conditions and the following disclaimer in the documentation and/or other materials
12 * provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
15 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 *
24 * The views and conclusions contained in the software and documentation are those of the
25 * authors and should not be interpreted as representing official policies, either expressed
26 * or implied, of JogAmp Community.
27 */
28
29package com.jogamp.newt;
30
31import java.util.List;
32
33import com.jogamp.nativewindow.ScalableSurface;
34import com.jogamp.nativewindow.util.DimensionImmutable;
35import com.jogamp.nativewindow.util.Dimension;
36import com.jogamp.nativewindow.util.Rectangle;
37import com.jogamp.nativewindow.util.RectangleImmutable;
38import com.jogamp.nativewindow.util.SurfaceSize;
39import com.jogamp.common.util.ArrayHashSet;
40import com.jogamp.common.util.PropertyAccess;
41
42/**
43 * Visual output device, i.e. a CRT, LED ..consisting of it's components:<br>
44 * <ui>
45 * <li>Immutable
46 * <ul>
47 * <li>nativeId</li>
48 * <li>{@link DimensionImmutable} size in [mm]</li>
49 * <li>{@link MonitorMode} original mode</li>
50 * <li><code>List&lt;MonitorMode&gt;</code> supportedModes</li>
51 * </ul></li>
52 * <li>Mutable
53 * <ul>
54 * <li>{@link MonitorMode} current mode</li>
55 * <li>{@link RectangleImmutable} viewport (rotated)</li>
56 * <li>pixel-scale (rotated)</li>
57 * </ul></li>
58 * </ul>
59 * <p>
60 * All values of this interface are represented in pixel units, if not stated otherwise.
61 * </p>
62 *
63 * Default monitor properties: 1920x1080 32bpp @ 60Hz, size 421x237 mm, dpi 93.60 x 93.62
64 * - Pixel size of via property `newt.monitor.pxwidth` and `newt.monitor.pxheight`
65 * - Refresh rate via property `newt.monitor.refresh`
66 * - Bits per pixel via property `newt.monitor.bpp`
67 * - Display size in millimeter via property `newt.monitor.mmwidth`
68 *
69 * The defaults are being used either if value could not be retrieved by the driver
70 * or if they are overridden via properties.
71 */
72public abstract class MonitorDevice {
73 protected final Screen screen; // backref
74 protected final long nativeHandle; // unique monitor device long handle, implementation specific
75 protected final int nativeId; // unique monitor device integer Id, implementation specific
76 protected final String name; // optional monitor name, maybe an empty string
77 protected final DimensionImmutable sizeMM; // in [mm]
78 protected final MonitorMode originalMode;
79 protected final ArrayHashSet<MonitorMode> supportedModes; // FIXME: May need to support mutable mode, i.e. adding modes on the fly!
80 protected final float[] pixelScale;
81 protected final Rectangle viewportPU; // in pixel units
82 protected final Rectangle viewportWU; // in window units
83 protected boolean isClone;
84 protected boolean isPrimary;
86 protected boolean modeChanged;
87
88 /** Pixel size of default Monitor 1920x1080 32bpp @ 60Hz, size 421x237 mm, dpi 93.60 x 93.62. Customizable via property `newt.monitor.pxwidth` and `newt.monitor.pxheight`. */
90 /** True if DEFAULT_MODE_PIXEL_SIZE is set by properties. */
91 public static final boolean DEFAULT_MODE_PIXEL_SIZE_OVERRIDE;
92
93 /** Refresh rate of default Monitor 1920x1080 32bpp @ 60Hz, size 421x237 mm, dpi 93.60 x 93.62. Customizable via property `newt.monitor.refresh`. */
94 public static final int DEFAULT_MODE_REFRESH;
95 /** True if DEFAULT_MODE_REFRESH is set by properties. */
96 public static final boolean DEFAULT_MODE_REFRESH_OVERRIDE;
97
98 /** Bits per pixel of default Monitor 1920x1080 32bpp @ 60Hz, size 421x237 mm, dpi 93.60 x 93.62. Customizable via property `newt.monitor.bpp`. */
99 public static final int DEFAULT_MODE_BPP;
100 /** True if DEFAULT_MODE_BPP is set by properties. */
101 public static final boolean DEFAULT_MODE_BPP_OVERRIDE;
102
103 /** Display size in millimeter of default Monitor 1920x1080 32bpp @ 60Hz, size 421x237 mm, dpi 93.60 x 93.62. Customizable via property `newt.monitor.mmwidth`. */
105 /** True if DEFAULT_SCREEN_MM_SIZE_OVERRIDE is set by properties. */
106 public static final boolean DEFAULT_SCREEN_MM_SIZE_OVERRIDE;
107
108 static {
109 final int mode_px_width = PropertyAccess.getIntProperty("newt.monitor.pxwidth", true, 0);
110 final int mode_px_height = PropertyAccess.getIntProperty("newt.monitor.pxheight", true, 0);
111 final int mode_refresh = PropertyAccess.getIntProperty("newt.monitor.refresh", true, 0);
112 final int mode_bpp = PropertyAccess.getIntProperty("newt.monitor.bpp", true, 0);
113 final int screen_mm_width = PropertyAccess.getIntProperty("newt.monitor.mmwidth", true, 0);
114 final int screen_mm_height = PropertyAccess.getIntProperty("newt.monitor.mmheight", true, 0);
115
116 if( mode_px_width > 0 && mode_px_height > 0 ) {
117 DEFAULT_MODE_PIXEL_SIZE = new Dimension(mode_px_width, mode_px_height);
119 } else {
120 DEFAULT_MODE_PIXEL_SIZE = new Dimension(1920, 1080);
122 }
123 if( mode_refresh > 0 ) {
124 DEFAULT_MODE_REFRESH = mode_refresh;
126 } else {
129 }
130 if( mode_bpp > 0 ) {
131 DEFAULT_MODE_BPP = mode_refresh;
133 } else {
134 DEFAULT_MODE_BPP = 32;
136 }
137 if( screen_mm_width > 0 && screen_mm_height > 0 ) {
138 DEFAULT_SCREEN_MM_SIZE = new Dimension(screen_mm_width, screen_mm_height);
140 } else {
141 DEFAULT_SCREEN_MM_SIZE = new Dimension(521, 293);
143 }
144 }
145
146 public static enum Orientation {
151 above(-2);
152
153 public final int value;
154
155 private Orientation(final int v) {
156 value = v;
157 }
158 }
159
160 /**
161 * Returns the orientation of this monitor to the other
162 * @param other the other monitor
163 * @param move_diff int[2] to store the move delta for each axis from this-monitor to the other.
164 * @return Orientation of this-monitor to the other
165 */
166 public final Orientation getOrientationTo(final MonitorDevice other, final int move_diff[/*2*/]) {
167 Orientation orientation = Orientation.clone;
168 // Move from other -> this
169 if( null != other ) {
170 // Move from vp0 -> vp1
171 final RectangleImmutable vp0 = other.getViewport(); // pixel units
172 final RectangleImmutable vp1 = this.getViewport(); // pixel units
173 if( vp0.getY() == vp1.getY() || vp0.getY() + vp0.getHeight() - 1 == vp1.getY() + vp1.getHeight() - 1 ) {
174 // vp0.y == vp1.y, i.e. horizontal move
175 if( vp1.getX() > vp0.getX() + vp0.getWidth() - 1 ) {
176 // vp1 right-of vp0
177 move_diff[0] = vp1.getX() - ( vp0.getX() + vp0.getWidth() - 1 ); // > 0
178 orientation = Orientation.right_of;
179 } else if( vp1.getX() + vp1.getWidth() - 1 < vp0.getX() ) {
180 // vp1 left-of vp0
181 move_diff[0] = ( vp1.getX() + vp1.getWidth() - 1 ) - vp0.getX(); // < 0
182 orientation = Orientation.left_of;
183 } // else same .. i.e. clone
184 } else if( vp0.getX() == vp1.getX() || vp0.getX() + vp0.getWidth() - 1 == vp1.getX() + vp1.getWidth() - 1 ) {
185 // vp0.x == vp1.x, i.e. vertical move
186 if( vp1.getY() + vp0.getHeight() - 1 < vp0.getY() ) {
187 // vp1 above vp0
188 move_diff[1] = ( vp1.getY() + vp1.getHeight() - 1 ) - vp0.getY() ; // < 0
189 orientation = Orientation.above;
190 } else if( vp1.getY() > vp0.getY() + vp0.getHeight() - 1 ) {
191 // vp1 below vp0
192 move_diff[1] = vp1.getY() - ( vp0.getY() + vp0.getHeight() - 1 ); // > 0
193 orientation = Orientation.below;
194 }
195 }
196 }
197 return orientation;
198 }
199
200 /**
201 * @param screen associated {@link Screen}
202 * @param nativeHandle unique monitor device long handle, implementation specific
203 * @param nativeId unique monitor device integer Id, implementation specific
204 * @param name optional monitor name, maybe null
205 * @param isClone flag
206 * @param isPrimary flag
207 * @param sizeMM size in millimeters
208 * @param currentMode
209 * @param pixelScale pre-fetched current pixel-scale, maybe {@code null} for {@link ScalableSurface#IDENTITY_PIXELSCALE}.
210 * @param viewportPU viewport in pixel-units
211 * @param viewportWU viewport in window-units
212 * @param supportedModes all supported {@link MonitorMode}s
213 */
214 protected MonitorDevice(final Screen screen, final long nativeHandle, final int nativeId,
215 final String name, final boolean isClone,
216 final boolean isPrimary, final DimensionImmutable sizeMM, final MonitorMode currentMode,
217 final float[] pixelScale, final Rectangle viewportPU, final Rectangle viewportWU, final ArrayHashSet<MonitorMode> supportedModes) {
218 this.screen = screen;
219 this.nativeHandle = nativeHandle;
220 this.nativeId = nativeId;
221 this.name = null != name ? name : "";
222 this.sizeMM = sizeMM;
223 this.originalMode = currentMode;
224 this.supportedModes = supportedModes;
225 if( null != pixelScale ) {
226 this.pixelScale = new float[] { pixelScale[0], pixelScale[1] };
227 } else {
228 this.pixelScale = new float[] { ScalableSurface.IDENTITY_PIXELSCALE, ScalableSurface.IDENTITY_PIXELSCALE };
229 }
230 this.viewportPU = viewportPU;
231 this.viewportWU = viewportWU;
232
233 this.isClone = isClone;
234 this.isPrimary = isPrimary;
235 this.currentMode = currentMode;
236 this.modeChanged = false;
237 }
238
239 /** Returns the {@link Screen} owning this monitor. */
240 public final Screen getScreen() {
241 return screen;
242 }
243
244 /**
245 * Tests equality of two <code>MonitorDevice</code> objects
246 * by evaluating equality of it's components:<br>
247 * <ul>
248 * <li><code>nativeID</code></li>
249 * </ul>
250 * <br>
251 */
252 @Override
253 public final boolean equals(final Object obj) {
254 if (this == obj) { return true; }
255 if (obj instanceof MonitorDevice) {
256 final MonitorDevice md = (MonitorDevice)obj;
257 return md.nativeId == nativeId;
258 }
259 return false;
260 }
261
262 /**
263 * Returns a combined hash code of it's elements:<br>
264 * <ul>
265 * <li><code>nativeID</code></li>
266 * </ul>
267 */
268 @Override
269 public final int hashCode() {
270 return nativeId;
271 }
272
273 /** @return the immutable unique native long handle of this monitor device, implementation specific. */
274 public final long getHandle() { return nativeHandle; }
275
276 /** @return the immutable unique native integer Id of this monitor device, implementation specific. */
277 public final int getId() { return nativeId; }
278
279 /** @return optional monitor name, maybe an empty string but never null. */
280 public final String getName() { return name; }
281
282 /** @return {@code true} if this device represents a <i>clone</i>, otherwise return {@code false}. */
283 public final boolean isClone() { return isClone; }
284
285 /**
286 * Returns {@code true} if this device represents the <i>primary device</i>, otherwise return {@code false}.
287 * @see Screen#getPrimaryMonitor()
288 */
289 public final boolean isPrimary() { return isPrimary; }
290
291 /**
292 * @return the immutable monitor size in millimeters.
293 */
295 return sizeMM;
296 }
297
298 /**
299 * Returns the <i>pixels per millimeter</i> value according to the <i>current</i> {@link MonitorMode mode}'s
300 * {@link SurfaceSize#getResolution() surface resolution}.
301 * <p>
302 * To convert the result to <i>dpi</i>, i.e. dots-per-inch, multiply both components with <code>25.4f</code>,
303 * see {@link #mmToInch(float[])}.
304 * </p>
305 * @param ppmmStore float[2] storage for the ppmm result
306 * @return the passed storage containing the ppmm for chaining
307 * @see #mmToInch(float[])
308 */
309 public final float[] getPixelsPerMM(final float[] ppmmStore) {
310 return getPixelsPerMM(getCurrentMode(), ppmmStore);
311 }
312
313 /**
314 * Returns the <i>pixels per millimeter</i> value according to the given {@link MonitorMode mode}'s
315 * {@link SurfaceSize#getResolution() surface resolution}.
316 * <p>
317 * To convert the result to <i>dpi</i>, i.e. dots-per-inch, multiply both components with <code>25.4f</code>.
318 * </p>
319 * @param mode
320 * @param ppmmStore float[2] storage for the ppmm result
321 * @return the passed storage containing the ppmm for chaining
322 */
323 public final float[] getPixelsPerMM(final MonitorMode mode, final float[] ppmmStore) {
324 final DimensionImmutable sdim = getSizeMM();
325 final DimensionImmutable spix = mode.getSurfaceSize().getResolution();
326 ppmmStore[0] = (float)spix.getWidth() / (float)sdim.getWidth();
327 ppmmStore[1] = (float)spix.getHeight() / (float)sdim.getHeight();
328 return ppmmStore;
329 }
330
331 /**
332 * Converts [1/mm] to [1/inch] from ppmm into result.
333 * @param ppmm float[2] [1/mm] value, unmodified
334 * @return return result w/ [1/inch] value
335 */
336 public static float[/*2*/] mmToInch(final float[/*2*/] result, final float[/*2*/] ppmm) {
337 result[0] = ppmm[0] * 25.4f;
338 result[1] = ppmm[1] * 25.4f;
339 return result;
340 }
341 /**
342 * Converts [1/mm] to [1/inch] in place
343 * @param ppmm float[2] [1/mm] value, modified
344 * @return return [1/inch] value
345 */
346 public static float[/*2*/] mmToInch(final float[/*2*/] ppmm) {
347 ppmm[0] *= 25.4f;
348 ppmm[1] *= 25.4f;
349 return ppmm;
350 }
351 /**
352 * Converts [1/mm] to [1/inch]
353 * @param ppmm [1/mm] value
354 * @return return [1/inch] value
355 */
356 public static float mmToInch(final float ppmm) {
357 return ppmm * 25.4f;
358 }
359
360 /**
361 * Converts [1/inch] to [1/mm] in place
362 * @param ppinch float[2] [1/inch] value, unmodified
363 * @return return [1/mm] value
364 */
365 public static float[/*2*/] inchToMM(final float[/*2*/] result, final float[/*2*/] ppinch) {
366 result[0] = ppinch[0] / 25.4f;
367 result[1] = ppinch[1] / 25.4f;
368 return result;
369 }
370 /**
371 * Converts [1/inch] to [1/mm] in place
372 * @param ppinch float[2] [1/inch] value, modified
373 * @return return [1/mm] value
374 */
375 public static float[/*2*/] inchToMM(final float[/*2*/] ppinch) {
376 ppinch[0] /= 25.4f;
377 ppinch[1] /= 25.4f;
378 return ppinch;
379 }
380 /**
381 * Converts [1/inch] to [1/mm]
382 * @param ppinch [1/inch] value
383 * @return return [1/mm] value
384 */
385 public static float inchToMM(final float ppinch) {
386 return ppinch / 25.4f;
387 }
388
389 /**
390 * Returns the immutable original {@link com.jogamp.newt.MonitorMode}, as used at NEWT initialization.
391 * <p>
392 * The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}.
393 * </p>
394 */
396 return originalMode;
397 }
398
399 /**
400 * Returns a list of immutable {@link MonitorMode}s supported by this monitor.
401 * <p>
402 * The list is ordered in descending order,
403 * see {@link MonitorMode#compareTo(MonitorMode)}.
404 * </p>
405 * <p>
406 * Use w/ care, it's not a copy!
407 * </p>
408 */
409 public final List<MonitorMode> getSupportedModes() {
410 return supportedModes.getData();
411 }
412
413 /**
414 * Returns the current {@link RectangleImmutable rectangular} portion
415 * of the <b>rotated</b> virtual {@link Screen} size in pixel units
416 * represented by this monitor, i.e. top-left origin and size.
417 * @see #getPixelScale()
418 * @see Screen#getViewport()
419 */
421 return viewportPU;
422 }
423
424 /**
425 * Returns the current {@link RectangleImmutable rectangular} portion
426 * of the <b>rotated</b> virtual {@link Screen} size in window units
427 * represented by this monitor, i.e. top-left origin and size.
428 * @see #getPixelScale()
429 * @see Screen#getViewportInWindowUnits()
430 */
432 return viewportWU;
433 }
434
435 /**
436 * Returns the current <b>rotated</b> pixel-scale
437 * of this monitor, i.e. horizontal and vertical.
438 * @see #getViewportInWindowUnits()
439 * @see #getViewport()
440 * @see ScalableSurface#getMaximumSurfaceScale(float[])
441 */
442 public float[] getPixelScale(final float[] result) {
443 System.arraycopy(pixelScale, 0, result, 0, 2);
444 return result;
445 }
446
447 /**
448 * Returns <code>true</code> if given screen coordinates in pixel units
449 * are contained by this {@link #getViewport() viewport}, otherwise <code>false</code>.
450 * @param x x-coord in pixel units
451 * @param y y-coord in pixel units
452 */
453 public final boolean contains(final int x, final int y) {
454 return x >= viewportPU.getX() &&
456 y >= viewportPU.getY() &&
458 }
459
460 /**
461 * Calculates the union of the given monitor's {@link #getViewport() viewport} in pixel- and window units.
462 * @param viewport storage for result in pixel units, maybe null
463 * @param viewportInWindowUnits storage for result in window units, maybe null
464 * @param monitors given list of monitors
465 */
466 public static void unionOfViewports(final Rectangle viewport, final Rectangle viewportInWindowUnits, final List<MonitorDevice> monitors) {
467 int x1PU=Integer.MAX_VALUE, y1PU=Integer.MAX_VALUE;
468 int x2PU=Integer.MIN_VALUE, y2PU=Integer.MIN_VALUE;
469 int x1WU=Integer.MAX_VALUE, y1WU=Integer.MAX_VALUE;
470 int x2WU=Integer.MIN_VALUE, y2WU=Integer.MIN_VALUE;
471 for(int i=monitors.size()-1; i>=0; i--) {
472 if( null != viewport ) {
473 final RectangleImmutable viewPU = monitors.get(i).getViewport();
474 x1PU = Math.min(x1PU, viewPU.getX());
475 x2PU = Math.max(x2PU, viewPU.getX() + viewPU.getWidth());
476 y1PU = Math.min(y1PU, viewPU.getY());
477 y2PU = Math.max(y2PU, viewPU.getY() + viewPU.getHeight());
478 }
479 if( null != viewportInWindowUnits ) {
480 final RectangleImmutable viewWU = monitors.get(i).getViewportInWindowUnits();
481 x1WU = Math.min(x1WU, viewWU.getX());
482 x2WU = Math.max(x2WU, viewWU.getX() + viewWU.getWidth());
483 y1WU = Math.min(y1WU, viewWU.getY());
484 y2WU = Math.max(y2WU, viewWU.getY() + viewWU.getHeight());
485 }
486 }
487 if( null != viewport ) {
488 viewport.set(x1PU, y1PU, x2PU - x1PU, y2PU - y1PU);
489 }
490 if( null != viewportInWindowUnits ) {
491 viewportInWindowUnits.set(x1WU, y1WU, x2WU - x1WU, y2WU - y1WU);
492 }
493 }
494
495 public final boolean isOriginalMode() {
496 return currentMode.hashCode() == originalMode.hashCode();
497 }
498
499 /**
500 * Returns <code>true</true> if the {@link MonitorMode}
501 * has been changed programmatic via this API <i>only</i>, otherwise <code>false</code>.
502 * <p>
503 * Note: We cannot guarantee that we won't interfere w/ another running
504 * application's screen mode change or vice versa.
505 * </p>
506 */
507 public final boolean isModeChangedByUs() {
508 return modeChanged && !isOriginalMode();
509 }
510
511 /**
512 * Returns the cached current {@link MonitorMode} w/o native query.
513 * <p>
514 * The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}.
515 * </p>
516 * @see #queryCurrentMode()
517 */
519 return currentMode;
520 }
521
522 /**
523 * Returns the current {@link MonitorMode} resulting from a native query.
524 * <p>
525 * The returned {@link MonitorMode} is element of the lists {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}.
526 * </p>
527 * @throws IllegalStateException if the {@link #getScreen() associated screen} is not {@link Screen#isNativeValid() valid natively}.
528 * @see #getCurrentMode()
529 */
530 public abstract MonitorMode queryCurrentMode() throws IllegalStateException;
531
532 /**
533 * Set the current {@link com.jogamp.newt.MonitorMode}.
534 * <p>This method is <a href="Window.html#lifecycleHeavy">lifecycle heavy</a>.</p>
535 * @param mode to be made current, must be element of the list {@link #getSupportedModes()} and {@link Screen#getMonitorModes()}.
536 * @return true if successful, otherwise false
537 * @throws IllegalStateException if the {@link #getScreen() associated screen} is not {@link Screen#isNativeValid() valid natively}.
538 */
539 public abstract boolean setCurrentMode(MonitorMode mode) throws IllegalStateException;
540
541 @Override
542 public String toString() {
543 boolean preComma = false;
544 final StringBuilder sb = new StringBuilder();
545 sb.append("Monitor[Id ").append(Display.toHexString(nativeId)).append(" [");
546 {
547 if( !name.isEmpty() ) {
548 if( preComma ) {
549 sb.append(", ");
550 }
551 sb.append("name ").append("'").append(name).append("'");
552 preComma = true;
553 }
554 if( nativeHandle != nativeId ) {
555 if( preComma ) {
556 sb.append(", ");
557 }
558 sb.append("handle ").append(Display.toHexString(nativeHandle));
559 preComma = true;
560 }
561 if( isClone() ) {
562 if( preComma ) {
563 sb.append(", ");
564 }
565 sb.append("clone");
566 preComma = true;
567 }
568 if( isPrimary() ) {
569 if( preComma ) {
570 sb.append(", ");
571 }
572 sb.append("primary");
573 }
574 }
575 preComma = false;
576 sb.append("], ").append(sizeMM).append(" mm, pixelScale [").append(pixelScale[0]).append(", ")
577 .append(pixelScale[1]).append("], viewport[pixel ").append(viewportPU).append(", window ").append(viewportWU)
578 .append("], orig ").append(originalMode).append(", curr ")
579 .append(currentMode).append(", modeChanged ").append(modeChanged).append(", modeCount ")
580 .append(supportedModes.size()).append("]");
581 return sb.toString();
582 }
583}
584
final int getX()
x-position, left of rectangle.
Definition: Rectangle.java:68
final int getY()
y-position, top of rectangle.
Definition: Rectangle.java:70
final Rectangle set(final int x, final int y, final int width, final int height)
Definition: Rectangle.java:76
final DimensionImmutable getResolution()
Returns the resolution in pixel units.
static String toHexString(final int hex)
Definition: Display.java:463
Visual output device, i.e.
static final boolean DEFAULT_SCREEN_MM_SIZE_OVERRIDE
True if DEFAULT_SCREEN_MM_SIZE_OVERRIDE is set by properties.
final boolean contains(final int x, final int y)
Returns true if given screen coordinates in pixel units are contained by this viewport,...
final ArrayHashSet< MonitorMode > supportedModes
static float[] mmToInch(final float[] ppmm)
Converts [1/mm] to [1/inch] in place.
static final boolean DEFAULT_MODE_PIXEL_SIZE_OVERRIDE
True if DEFAULT_MODE_PIXEL_SIZE is set by properties.
MonitorDevice(final Screen screen, final long nativeHandle, final int nativeId, final String name, final boolean isClone, final boolean isPrimary, final DimensionImmutable sizeMM, final MonitorMode currentMode, final float[] pixelScale, final Rectangle viewportPU, final Rectangle viewportWU, final ArrayHashSet< MonitorMode > supportedModes)
static void unionOfViewports(final Rectangle viewport, final Rectangle viewportInWindowUnits, final List< MonitorDevice > monitors)
Calculates the union of the given monitor's viewport in pixel- and window units.
static float[] mmToInch(final float[] result, final float[] ppmm)
Converts [1/mm] to [1/inch] from ppmm into result.
final boolean equals(final Object obj)
Tests equality of two MonitorDevice objects by evaluating equality of it's components:
final int hashCode()
Returns a combined hash code of it's elements:
static float[] inchToMM(final float[] result, final float[] ppinch)
Converts [1/inch] to [1/mm] in place.
final DimensionImmutable getSizeMM()
final float[] getPixelsPerMM(final MonitorMode mode, final float[] ppmmStore)
Returns the pixels per millimeter value according to the given mode's surface resolution.
final boolean isPrimary()
Returns true if this device represents the primary device, otherwise return false.
final boolean isModeChangedByUs()
Returns true</true> if the MonitorMode has been changed programmatic via this API only,...
static float mmToInch(final float ppmm)
Converts [1/mm] to [1/inch].
static final DimensionImmutable DEFAULT_SCREEN_MM_SIZE
Display size in millimeter of default Monitor 1920x1080 32bpp @ 60Hz, size 421x237 mm,...
final MonitorMode getCurrentMode()
Returns the cached current MonitorMode w/o native query.
float[] getPixelScale(final float[] result)
Returns the current rotated pixel-scale of this monitor, i.e.
abstract MonitorMode queryCurrentMode()
Returns the current MonitorMode resulting from a native query.
final MonitorMode originalMode
static final int DEFAULT_MODE_BPP
Bits per pixel of default Monitor 1920x1080 32bpp @ 60Hz, size 421x237 mm, dpi 93....
final RectangleImmutable getViewportInWindowUnits()
Returns the current rectangular portion of the rotated virtual Screen size in window units represente...
abstract boolean setCurrentMode(MonitorMode mode)
Set the current com.jogamp.newt.MonitorMode.
static final boolean DEFAULT_MODE_BPP_OVERRIDE
True if DEFAULT_MODE_BPP is set by properties.
final float[] getPixelsPerMM(final float[] ppmmStore)
Returns the pixels per millimeter value according to the current mode's surface resolution.
final List< MonitorMode > getSupportedModes()
Returns a list of immutable MonitorModes supported by this monitor.
final DimensionImmutable sizeMM
final MonitorMode getOriginalMode()
Returns the immutable original com.jogamp.newt.MonitorMode, as used at NEWT initialization.
final RectangleImmutable getViewport()
Returns the current rectangular portion of the rotated virtual Screen size in pixel units represented...
final Screen getScreen()
Returns the Screen owning this monitor.
final Orientation getOrientationTo(final MonitorDevice other, final int move_diff[])
Returns the orientation of this monitor to the other.
static float inchToMM(final float ppinch)
Converts [1/inch] to [1/mm].
static final int DEFAULT_MODE_REFRESH
Refresh rate of default Monitor 1920x1080 32bpp @ 60Hz, size 421x237 mm, dpi 93.60 x 93....
static final DimensionImmutable DEFAULT_MODE_PIXEL_SIZE
Pixel size of default Monitor 1920x1080 32bpp @ 60Hz, size 421x237 mm, dpi 93.60 x 93....
static float[] inchToMM(final float[] ppinch)
Converts [1/inch] to [1/mm] in place.
static final boolean DEFAULT_MODE_REFRESH_OVERRIDE
True if DEFAULT_MODE_REFRESH is set by properties.
Immutable MonitorMode Class, consisting of it's read only components:
final SurfaceSize getSurfaceSize()
Returns the unrotated SurfaceSize.
A screen may span multiple MonitorDevices representing their combined virtual size.
Definition: Screen.java:58
Adding mutable surface pixel scale property to implementing class, usually to a NativeSurface impleme...
static final float IDENTITY_PIXELSCALE
Setting surface-pixel-scale of {@value}, results in same pixel- and window-units.
Immutable Dimension Interface, consisting of it's read only components:
Immutable Rectangle interface, with its position on the top-left.
int getX()
x-position, left of rectangle.
int getY()
y-position, top of rectangle.