Package com.jogamp.newt
Class MonitorMode
java.lang.Object
com.jogamp.newt.MonitorMode
- All Implemented Interfaces:
Comparable<MonitorMode>
Immutable MonitorMode Class, consisting of it's read only components:
Changing MonitorMode
Example for changing the MonitorMode:
- nativeId
MonitorMode.SizeAndRRate
, consist out of non rotatedsurface size
,refresh rate
andflags
.rotation
, measured counter clockwise (CCW)
MonitorDevice
Selection:- A List of all
MonitorDevice
s is accessible viaScreen.getMonitorDevices()
. - The main monitor used by a windows is accessible via
Window.getMainMonitor()
. - The main monitor covering an arbitrary rectangle is accessible via
Screen.getMainMonitor(RectangleImmutable)
.
- A List of all
- The current MonitorMode can be obtained via
MonitorDevice.getCurrentMode()
. - The original MonitorMode can be obtained via
MonitorDevice.getOriginalMode()
. MonitorMode
Filtering:- A
MonitorDevice
's MonitorModes is accessible viaMonitorDevice.getSupportedModes()
. - You may utilize
MonitorModeUtil
to filter and select a desired MonitorMode.
- A
Changing MonitorMode
- Use
MonitorDevice.setCurrentMode(MonitorMode)
to change the current MonitorMode for allScreen
s referenced via thefull qualified name (FQN)
. - The
original mode
is restored when- the last FQN referenced Screen closes.
- the JVM shuts down.
Example for changing the MonitorMode:
// Pick the monitor: // Either the one used by a window .. MonitorDevice monitor = window.getMainMonitor(); // Or arbitrary from the list .. ListallMonitor = getMonitorDevices(); MonitorDevice monitor = allMonitor.get(0); // Current and original modes .. MonitorMode mmCurrent = monitor.queryCurrentMode(); MonitorMode mmOrig = monitor.getOriginalMode(); // Target resolution in pixel units DimensionImmutable res = new Dimension(800, 600); // Target refresh rate shall be similar to current one .. float freq = mmCurrent.getRefreshRate(); // Target rotation shall be similar to current one int rot = mmCurrent.getRotation(); // Filter criterias sequential out of all available MonitorMode of the chosen MonitorDevice List monitorModes = monitor.getSupportedModes(); monitorModes = MonitorModeUtil.filterByFlags(monitorModes, 0); // no interlace, double-scan etc monitorModes = MonitorModeUtil.filterByRotation(monitorModes, rot); monitorModes = MonitorModeUtil.filterByResolution(monitorModes, res); monitorModes = MonitorModeUtil.filterByRate(monitorModes, freq); monitorModes = MonitorModeUtil.getHighestAvailableBpp(monitorModes); // pick 1st one and set to current .. MonitorMode mm = monitorModes.get(0); monitor.setCurrentMode(mm);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Immutable surfaceSize, flags and refreshRate Class, consisting of it's read only components:
nativeIdSurfaceSize
surface memory sizeflags
refresh rate
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Lines are doubled.static final int
Frame is split into two fields.static final Comparator<MonitorMode>
Comparator for 2MonitorMode
s, following comparison order as described incompareTo(MonitorMode)
, returning the ascending order.static final Comparator<MonitorMode>
Comparator for 2MonitorMode
s, following comparison order as described incompareTo(MonitorMode)
, returning the descending order.static final int
zero rotation, compared to normal settingsstatic final int
180 degrees CCW rotationstatic final int
270 degrees CCW rotationstatic final int
90 degrees CCW rotation -
Constructor Summary
ConstructorsConstructorDescriptionMonitorMode
(int nativeId, MonitorMode.SizeAndRRate sizeAndRRate, int rotation) MonitorMode
(SurfaceSize surfaceSize, float refreshRate, int flags, int rotation) Creates a user instance w/oidentity
to filter our matching modes w/ identity. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(MonitorMode mm) ComparessizeAndRRate
1st, thenrotation
.final boolean
Tests equality of twoMonitorMode
objects by evaluating equality of it's components:
nativeId
sizeAndRRate
rotation
final int
getFlags()
Returns bitfield w/ flags, i.e.final int
getId()
final float
Returns the vertical refresh rate.final int
Returns the rotated screen height in pixel units, derived fromgetMonitorMode().getSurfaceSize().getResolution()
andgetRotation()
final int
Returns the rotated screen width in pixel units, derived fromgetMonitorMode().getSurfaceSize().getResolution()
andgetRotation()
final int
Returns the CCW rotation of this modefinal MonitorMode.SizeAndRRate
Returns the surfaceSize and refreshRate instance.final SurfaceSize
Returns the unrotatedSurfaceSize
final int
hashCode()
Returns a combined hash code of it's elements:
nativeId
sizeAndRRate
rotation
static boolean
isRotationValid
(int rotation) final String
toString()
-
Field Details
-
monitorModeComparator
Comparator for 2MonitorMode
s, following comparison order as described incompareTo(MonitorMode)
, returning the ascending order. -
monitorModeComparatorInv
Comparator for 2MonitorMode
s, following comparison order as described incompareTo(MonitorMode)
, returning the descending order. -
ROTATE_0
public static final int ROTATE_0zero rotation, compared to normal settings- See Also:
-
ROTATE_90
public static final int ROTATE_9090 degrees CCW rotation- See Also:
-
ROTATE_180
public static final int ROTATE_180180 degrees CCW rotation- See Also:
-
ROTATE_270
public static final int ROTATE_270270 degrees CCW rotation- See Also:
-
FLAG_INTERLACE
public static final int FLAG_INTERLACEFrame is split into two fields. SeegetFlags()
.- See Also:
-
FLAG_DOUBLESCAN
public static final int FLAG_DOUBLESCANLines are doubled. SeegetFlags()
.- See Also:
-
-
Constructor Details
-
MonitorMode
- Parameters:
sizeAndRRate
- the surface size and refresh rate moderotation
- the screen rotation, measured counter clockwise (CCW)
-
MonitorMode
Creates a user instance w/oidentity
to filter our matching modes w/ identity.See
MonitorModeUtil
for filter utilities.- Parameters:
surfaceSize
-refreshRate
-flags
-rotation
-
-
-
Method Details
-
isRotationValid
public static boolean isRotationValid(int rotation) -
getId
public final int getId()- Returns:
- the immutable native Id of this mode, may not be unique, may be 0.
-
getSizeAndRRate
Returns the surfaceSize and refreshRate instance. -
getSurfaceSize
Returns the unrotatedSurfaceSize
-
getRefreshRate
public final float getRefreshRate()Returns the vertical refresh rate. -
getFlags
public final int getFlags()Returns bitfield w/ flags, i.e.FLAG_DOUBLESCAN
,FLAG_INTERLACE
, .. -
getRotation
public final int getRotation()Returns the CCW rotation of this mode -
getRotatedWidth
public final int getRotatedWidth()Returns the rotated screen width in pixel units, derived fromgetMonitorMode().getSurfaceSize().getResolution()
andgetRotation()
-
getRotatedHeight
public final int getRotatedHeight()Returns the rotated screen height in pixel units, derived fromgetMonitorMode().getSurfaceSize().getResolution()
andgetRotation()
-
toString
-
compareTo
Compares
sizeAndRRate
1st, thenrotation
.Rotation is compared inverted, i.e.
360 - rotation
, so the lowest rotation reflects a higher value.Order of comparing MonitorMode:
- resolution
- bits per pixel
- flags
- refresh rate
- rotation
- Specified by:
compareTo
in interfaceComparable<MonitorMode>
-
equals
Tests equality of twoMonitorMode
objects by evaluating equality of it's components:
nativeId
sizeAndRRate
rotation
-
hashCode
public final int hashCode()Returns a combined hash code of it's elements:
nativeId
sizeAndRRate
rotation
-