Class MonitorDevice
- java.lang.Object
-
- com.jogamp.newt.MonitorDevice
-
public abstract class MonitorDevice extends Object
Visual output device, i.e. a CRT, LED ..consisting of it's components:
- Immutable
- nativeId
DimensionImmutable
size in [mm]MonitorMode
original modeList<MonitorMode>
supportedModes
- Mutable
MonitorMode
current modeRectangleImmutable
viewport (rotated)- pixel-scale (rotated)
All values of this interface are represented in pixel units, if not stated otherwise.
- Immutable
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
contains(int x, int y)
Returnstrue
if given screen coordinates in pixel units are contained by thisviewport
, otherwisefalse
.boolean
equals(Object obj)
Tests equality of twoMonitorDevice
objects by evaluating equality of it's components:
nativeID
MonitorMode
getCurrentMode()
Returns the cached currentMonitorMode
w/o native query.int
getId()
MonitorMode
getOriginalMode()
Returns the immutable originalMonitorMode
, as used at NEWT initialization.float[]
getPixelScale(float[] result)
Returns the current rotated pixel-scale of this monitor, i.e.float[]
getPixelsPerMM(float[] ppmmStore)
Returns the pixels per millimeter value according to the currentmode
'ssurface resolution
.float[]
getPixelsPerMM(MonitorMode mode, float[] ppmmStore)
Returns the pixels per millimeter value according to the givenmode
'ssurface resolution
.Screen
getScreen()
Returns theScreen
owning this monitor.DimensionImmutable
getSizeMM()
List<MonitorMode>
getSupportedModes()
Returns a list of immutableMonitorMode
s supported by this monitor.RectangleImmutable
getViewport()
Returns the currentrectangular
portion of the rotated virtualScreen
size in pixel units represented by this monitor, i.e.RectangleImmutable
getViewportInWindowUnits()
Returns the currentrectangular
portion of the rotated virtualScreen
size in window units represented by this monitor, i.e.int
hashCode()
Returns a combined hash code of it's elements:
nativeID
boolean
isClone()
boolean
isModeChangedByUs()
Returnstrue if the
MonitorMode
has been changed programmatic via this API only, otherwisefalse
.boolean
isOriginalMode()
boolean
isPrimary()
Returnstrue
if this device represents the primary device, otherwise returnfalse
.abstract MonitorMode
queryCurrentMode()
Returns the currentMonitorMode
resulting from a native query.abstract boolean
setCurrentMode(MonitorMode mode)
Set the currentMonitorMode
.String
toString()
static void
unionOfViewports(Rectangle viewport, Rectangle viewportInWindowUnits, List<MonitorDevice> monitors)
Calculates the union of the given monitor'sviewport
in pixel- and window units.
-
-
-
Method Detail
-
equals
public final boolean equals(Object obj)
Tests equality of twoMonitorDevice
objects by evaluating equality of it's components:
nativeID
-
hashCode
public final int hashCode()
Returns a combined hash code of it's elements:
nativeID
-
getId
public final int getId()
- Returns:
- the immutable unique native Id of this monitor device.
-
isClone
public final boolean isClone()
- Returns:
true
if this device represents a clone, otherwise returnfalse
.
-
isPrimary
public final boolean isPrimary()
Returnstrue
if this device represents the primary device, otherwise returnfalse
.- See Also:
Screen.getPrimaryMonitor()
-
getSizeMM
public final DimensionImmutable getSizeMM()
- Returns:
- the immutable monitor size in millimeters.
-
getPixelsPerMM
public final float[] getPixelsPerMM(float[] ppmmStore)
Returns the pixels per millimeter value according to the currentmode
'ssurface resolution
.To convert the result to dpi, i.e. dots-per-inch, multiply both components with
25.4f
.- Parameters:
ppmmStore
- float[2] storage for the ppmm result- Returns:
- the passed storage containing the ppmm for chaining
-
getPixelsPerMM
public final float[] getPixelsPerMM(MonitorMode mode, float[] ppmmStore)
Returns the pixels per millimeter value according to the givenmode
'ssurface resolution
.To convert the result to dpi, i.e. dots-per-inch, multiply both components with
25.4f
.- Parameters:
mode
-ppmmStore
- float[2] storage for the ppmm result- Returns:
- the passed storage containing the ppmm for chaining
-
getOriginalMode
public final MonitorMode getOriginalMode()
Returns the immutable originalMonitorMode
, as used at NEWT initialization.The returned
MonitorMode
is element of the listsgetSupportedModes()
andScreen.getMonitorModes()
.
-
getSupportedModes
public final List<MonitorMode> getSupportedModes()
Returns a list of immutableMonitorMode
s supported by this monitor.The list is ordered in descending order, see
MonitorMode.compareTo(MonitorMode)
.Use w/ care, it's not a copy!
-
getViewport
public final RectangleImmutable getViewport()
Returns the currentrectangular
portion of the rotated virtualScreen
size in pixel units represented by this monitor, i.e. top-left origin and size.- See Also:
#getPixelScale()
,Screen.getViewport()
-
getViewportInWindowUnits
public final RectangleImmutable getViewportInWindowUnits()
Returns the currentrectangular
portion of the rotated virtualScreen
size in window units represented by this monitor, i.e. top-left origin and size.- See Also:
#getPixelScale()
,Screen.getViewportInWindowUnits()
-
getPixelScale
public float[] getPixelScale(float[] result)
Returns the current rotated pixel-scale of this monitor, i.e. horizontal and vertical.
-
contains
public final boolean contains(int x, int y)
Returnstrue
if given screen coordinates in pixel units are contained by thisviewport
, otherwisefalse
.- Parameters:
x
- x-coord in pixel unitsy
- y-coord in pixel units
-
unionOfViewports
public static void unionOfViewports(Rectangle viewport, Rectangle viewportInWindowUnits, List<MonitorDevice> monitors)
Calculates the union of the given monitor'sviewport
in pixel- and window units.- Parameters:
viewport
- storage for result in pixel units, maybe nullviewportInWindowUnits
- storage for result in window units, maybe nullmonitors
- given list of monitors
-
isOriginalMode
public final boolean isOriginalMode()
-
isModeChangedByUs
public final boolean isModeChangedByUs()
Returnstrue if the
MonitorMode
has been changed programmatic via this API only, otherwisefalse
.Note: We cannot guarantee that we won't interfere w/ another running application's screen mode change or vice versa.
-
getCurrentMode
public final MonitorMode getCurrentMode()
Returns the cached currentMonitorMode
w/o native query.The returned
MonitorMode
is element of the listsgetSupportedModes()
andScreen.getMonitorModes()
.- See Also:
queryCurrentMode()
-
queryCurrentMode
public abstract MonitorMode queryCurrentMode() throws IllegalStateException
Returns the currentMonitorMode
resulting from a native query.The returned
MonitorMode
is element of the listsgetSupportedModes()
andScreen.getMonitorModes()
.- Throws:
IllegalStateException
- if theassociated screen
is notvalid natively
.- See Also:
getCurrentMode()
-
setCurrentMode
public abstract boolean setCurrentMode(MonitorMode mode) throws IllegalStateException
Set the currentMonitorMode
.This method is lifecycle heavy.
- Parameters:
mode
- to be made current, must be element of the listgetSupportedModes()
andScreen.getMonitorModes()
.- Returns:
- true if successful, otherwise false
- Throws:
IllegalStateException
- if theassociated screen
is notvalid natively
.
-
-