29package com.jogamp.newt;
33import com.jogamp.nativewindow.ScalableSurface;
34import com.jogamp.nativewindow.util.DimensionImmutable;
35import com.jogamp.nativewindow.util.Rectangle;
36import com.jogamp.nativewindow.util.RectangleImmutable;
37import com.jogamp.nativewindow.util.SurfaceSize;
38import com.jogamp.common.util.ArrayHashSet;
65 protected final String
name;
100 if(
null != other ) {
152 this.name =
null !=
name ?
name :
"";
167 this.modeChanged =
false;
184 public final boolean equals(
final Object obj) {
185 if (
this == obj) {
return true; }
267 public static float[]
mmToInch(
final float[] ppmm) {
287 public static float[]
inchToMM(
final float[] ppinch) {
356 System.arraycopy(
pixelScale, 0, result, 0, 2);
366 public final boolean contains(
final int x,
final int y) {
380 int x1PU=Integer.MAX_VALUE, y1PU=Integer.MAX_VALUE;
381 int x2PU=Integer.MIN_VALUE, y2PU=Integer.MIN_VALUE;
382 int x1WU=Integer.MAX_VALUE, y1WU=Integer.MAX_VALUE;
383 int x2WU=Integer.MIN_VALUE, y2WU=Integer.MIN_VALUE;
384 for(
int i=monitors.size()-1; i>=0; i--) {
385 if(
null != viewport ) {
387 x1PU = Math.min(x1PU, viewPU.
getX());
388 x2PU = Math.max(x2PU, viewPU.
getX() + viewPU.
getWidth());
389 y1PU = Math.min(y1PU, viewPU.
getY());
392 if(
null != viewportInWindowUnits ) {
394 x1WU = Math.min(x1WU, viewWU.
getX());
395 x2WU = Math.max(x2WU, viewWU.
getX() + viewWU.
getWidth());
396 y1WU = Math.min(y1WU, viewWU.
getY());
400 if(
null != viewport ) {
401 viewport.
set(x1PU, y1PU, x2PU - x1PU, y2PU - y1PU);
403 if(
null != viewportInWindowUnits ) {
404 viewportInWindowUnits.
set(x1WU, y1WU, x2WU - x1WU, y2WU - y1WU);
456 boolean preComma =
false;
457 final StringBuilder sb =
new StringBuilder();
460 if( !
name.isEmpty() ) {
464 sb.append(
"name ").append(
"'").append(
name).append(
"'");
485 sb.append(
"primary");
489 sb.append(
"], ").append(
sizeMM).append(
" mm, pixelScale [").append(
pixelScale[0]).append(
", ")
491 .append(
"], orig ").append(
originalMode).append(
", curr ")
494 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.
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.
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.
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:
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,...
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
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.
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.
static float mmToInch(float ppmm)
Converts [1/mm] to [1/inch].
static float inchToMM(float ppinch)
Converts [1/inch] to [1/mm].
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.
final boolean isOriginalMode()
static float[] inchToMM(final float[] ppinch)
Converts [1/inch] to [1/mm] in place.
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.