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
DimensionImmutablesize in [mm]MonitorModeoriginal modeList<MonitorMode>supportedModes
- Mutable
MonitorModecurrent modeRectangleImmutableviewport (rotated)- pixel-scale (rotated)
All values of this interface are represented in pixel units, if not stated otherwise.
- Immutable
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMonitorDevice.Orientation
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancontains(int x, int y)Returnstrueif given screen coordinates in pixel units are contained by thisviewport, otherwisefalse.booleanequals(Object obj)Tests equality of twoMonitorDeviceobjects by evaluating equality of it's components:
nativeIDMonitorModegetCurrentMode()Returns the cached currentMonitorModew/o native query.longgetHandle()intgetId()StringgetName()MonitorDevice.OrientationgetOrientationTo(MonitorDevice other, int[] move_diff)Returns the orientation of this monitor to the otherMonitorModegetOriginalMode()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.ScreengetScreen()Returns theScreenowning this monitor.DimensionImmutablegetSizeMM()List<MonitorMode>getSupportedModes()Returns a list of immutableMonitorModes supported by this monitor.RectangleImmutablegetViewport()Returns the currentrectangularportion of the rotated virtualScreensize in pixel units represented by this monitor, i.e.RectangleImmutablegetViewportInWindowUnits()Returns the currentrectangularportion of the rotated virtualScreensize in window units represented by this monitor, i.e.inthashCode()Returns a combined hash code of it's elements:
nativeIDbooleanisClone()booleanisModeChangedByUs()Returnstrue if theMonitorModehas been changed programmatic via this API only, otherwisefalse.booleanisOriginalMode()booleanisPrimary()Returnstrueif this device represents the primary device, otherwise returnfalse.static float[]perMMToPerInch(float[] ppmm)Converts [1/mm] to [1/inch] in placeabstract MonitorModequeryCurrentMode()Returns the currentMonitorModeresulting from a native query.abstract booleansetCurrentMode(MonitorMode mode)Set the currentMonitorMode.StringtoString()static voidunionOfViewports(Rectangle viewport, Rectangle viewportInWindowUnits, List<MonitorDevice> monitors)Calculates the union of the given monitor'sviewportin pixel- and window units.
-
-
-
Method Detail
-
getOrientationTo
public final MonitorDevice.Orientation getOrientationTo(MonitorDevice other, int[] move_diff)
Returns the orientation of this monitor to the other- Parameters:
other- the other monitormove_diff- int[2] to store the move delta for each axis from this-monitor to the other.- Returns:
- Orientation of this-monitor to the other
-
equals
public final boolean equals(Object obj)
Tests equality of twoMonitorDeviceobjects by evaluating equality of it's components:
nativeID
-
hashCode
public final int hashCode()
Returns a combined hash code of it's elements:
nativeID
-
getHandle
public final long getHandle()
- Returns:
- the immutable unique native long handle of this monitor device, implementation specific.
-
getId
public final int getId()
- Returns:
- the immutable unique native integer Id of this monitor device, implementation specific.
-
getName
public final String getName()
- Returns:
- optional monitor name, maybe an empty string but never null.
-
isClone
public final boolean isClone()
- Returns:
trueif this device represents a clone, otherwise returnfalse.
-
isPrimary
public final boolean isPrimary()
Returnstrueif 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, seeperMMToPerInch(float[]).- Parameters:
ppmmStore- float[2] storage for the ppmm result- Returns:
- the passed storage containing the ppmm for chaining
- See Also:
perMMToPerInch(float[])
-
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
-
perMMToPerInch
public static float[] perMMToPerInch(float[] ppmm)
Converts [1/mm] to [1/inch] in place- Parameters:
ppmm- float[2] [1/mm] value- Returns:
- return [1/inch] value
-
getOriginalMode
public final MonitorMode getOriginalMode()
Returns the immutable originalMonitorMode, as used at NEWT initialization.The returned
MonitorModeis element of the listsgetSupportedModes()andScreen.getMonitorModes().
-
getSupportedModes
public final List<MonitorMode> getSupportedModes()
Returns a list of immutableMonitorModes 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 currentrectangularportion of the rotated virtualScreensize 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 currentrectangularportion of the rotated virtualScreensize 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)Returnstrueif 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'sviewportin 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 theMonitorModehas 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 currentMonitorModew/o native query.The returned
MonitorModeis element of the listsgetSupportedModes()andScreen.getMonitorModes().- See Also:
queryCurrentMode()
-
queryCurrentMode
public abstract MonitorMode queryCurrentMode() throws IllegalStateException
Returns the currentMonitorModeresulting from a native query.The returned
MonitorModeis element of the listsgetSupportedModes()andScreen.getMonitorModes().- Throws:
IllegalStateException- if theassociated screenis 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 screenis notvalid natively.
-
-