29package com.jogamp.newt;
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;
76 protected final String
name;
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);
116 if( mode_px_width > 0 && mode_px_height > 0 ) {
123 if( mode_refresh > 0 ) {
137 if( screen_mm_width > 0 && screen_mm_height > 0 ) {
169 if(
null != other ) {
221 this.name =
null !=
name ?
name :
"";
236 this.modeChanged =
false;
253 public final boolean equals(
final Object obj) {
254 if (
this == obj) {
return true; }
336 public static float[]
mmToInch(
final float[] result,
final float[] ppmm) {
337 result[0] = ppmm[0] * 25.4f;
338 result[1] = ppmm[1] * 25.4f;
346 public static float[]
mmToInch(
final float[] ppmm) {
365 public static float[]
inchToMM(
final float[] result,
final float[] ppinch) {
366 result[0] = ppinch[0] / 25.4f;
367 result[1] = ppinch[1] / 25.4f;
375 public static float[]
inchToMM(
final float[] ppinch) {
386 return ppinch / 25.4f;
443 System.arraycopy(
pixelScale, 0, result, 0, 2);
453 public final boolean contains(
final int x,
final int y) {
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 ) {
474 x1PU = Math.min(x1PU, viewPU.
getX());
475 x2PU = Math.max(x2PU, viewPU.
getX() + viewPU.
getWidth());
476 y1PU = Math.min(y1PU, viewPU.
getY());
479 if(
null != viewportInWindowUnits ) {
481 x1WU = Math.min(x1WU, viewWU.
getX());
482 x2WU = Math.max(x2WU, viewWU.
getX() + viewWU.
getWidth());
483 y1WU = Math.min(y1WU, viewWU.
getY());
487 if(
null != viewport ) {
488 viewport.
set(x1PU, y1PU, x2PU - x1PU, y2PU - y1PU);
490 if(
null != viewportInWindowUnits ) {
491 viewportInWindowUnits.
set(x1WU, y1WU, x2WU - x1WU, y2WU - y1WU);
543 boolean preComma =
false;
544 final StringBuilder sb =
new StringBuilder();
547 if( !
name.isEmpty() ) {
551 sb.append(
"name ").append(
"'").append(
name).append(
"'");
572 sb.append(
"primary");
576 sb.append(
"], ").append(
sizeMM).append(
" mm, pixelScale [").append(
pixelScale[0]).append(
", ")
578 .append(
"], orig ").append(
originalMode).append(
", curr ")
581 return sb.toString();
final int getX()
x-position, left of rectangle.
final int getY()
y-position, top of rectangle.
final Rectangle set(final int x, final int y, final int width, final int height)
final DimensionImmutable getResolution()
Returns the resolution in pixel units.
static String toHexString(final int hex)
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 Rectangle viewportPU
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 Rectangle viewportWU
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....
final boolean isOriginalMode()
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.
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.