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; }
327 System.arraycopy(
pixelScale, 0, result, 0, 2);
337 public final boolean contains(
final int x,
final int y) {
351 int x1PU=Integer.MAX_VALUE, y1PU=Integer.MAX_VALUE;
352 int x2PU=Integer.MIN_VALUE, y2PU=Integer.MIN_VALUE;
353 int x1WU=Integer.MAX_VALUE, y1WU=Integer.MAX_VALUE;
354 int x2WU=Integer.MIN_VALUE, y2WU=Integer.MIN_VALUE;
355 for(
int i=monitors.size()-1; i>=0; i--) {
356 if(
null != viewport ) {
358 x1PU = Math.min(x1PU, viewPU.
getX());
359 x2PU = Math.max(x2PU, viewPU.
getX() + viewPU.
getWidth());
360 y1PU = Math.min(y1PU, viewPU.
getY());
363 if(
null != viewportInWindowUnits ) {
365 x1WU = Math.min(x1WU, viewWU.
getX());
366 x2WU = Math.max(x2WU, viewWU.
getX() + viewWU.
getWidth());
367 y1WU = Math.min(y1WU, viewWU.
getY());
371 if(
null != viewport ) {
372 viewport.
set(x1PU, y1PU, x2PU - x1PU, y2PU - y1PU);
374 if(
null != viewportInWindowUnits ) {
375 viewportInWindowUnits.
set(x1WU, y1WU, x2WU - x1WU, y2WU - y1WU);
427 boolean preComma =
false;
428 final StringBuilder sb =
new StringBuilder();
431 if( !
name.isEmpty() ) {
435 sb.append(
"name ").append(
"'").append(
name).append(
"'");
456 sb.append(
"primary");
460 sb.append(
"], ").append(
sizeMM).append(
" mm, pixelScale [").append(
pixelScale[0]).append(
", ")
462 .append(
"], orig ").append(
originalMode).append(
", curr ")
465 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
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.
static float[] perMMToPerInch(final float[] ppmm)
Converts [1/mm] to [1/inch] in place.
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.
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()
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.