public class MonitorMode extends Object implements Comparable<MonitorMode>
MonitorMode.SizeAndRRate
, consist out of non rotated surface size
, refresh rate
and flags
.rotation
, measured counter clockwise (CCW)MonitorDevice
Selection:
MonitorDevice
s is accessible via Screen.getMonitorDevices()
.Window.getMainMonitor()
.Screen.getMainMonitor(RectangleImmutable)
.MonitorDevice.getCurrentMode()
.MonitorDevice.getOriginalMode()
.MonitorMode
Filtering:
MonitorDevice
's MonitorModes is accessible via MonitorDevice.getSupportedModes()
.MonitorModeUtil
to filter and select a desired MonitorMode.MonitorDevice.setCurrentMode(MonitorMode)
to change the current MonitorMode for all Screen
s referenced via the full qualified name (FQN)
.original mode
is restored when
// 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);
Modifier and Type | Class and Description |
---|---|
static class |
MonitorMode.SizeAndRRate
Immutable surfaceSize, flags and refreshRate Class, consisting of it's read only components:
nativeId SurfaceSize surface memory size
flags
refresh rate
|
Modifier and Type | Field and Description |
---|---|
static int |
FLAG_DOUBLESCAN
Lines are doubled.
|
static int |
FLAG_INTERLACE
Frame is split into two fields.
|
static Comparator<MonitorMode> |
monitorModeComparator
Comparator for 2
MonitorMode s, following comparison order as described in compareTo(MonitorMode) , returning the ascending order. |
static Comparator<MonitorMode> |
monitorModeComparatorInv
Comparator for 2
MonitorMode s, following comparison order as described in compareTo(MonitorMode) , returning the descending order. |
static int |
ROTATE_0
zero rotation, compared to normal settings
|
static int |
ROTATE_180
180 degrees CCW rotation
|
static int |
ROTATE_270
270 degrees CCW rotation
|
static int |
ROTATE_90
90 degrees CCW rotation
|
Constructor and Description |
---|
MonitorMode(int nativeId,
MonitorMode.SizeAndRRate sizeAndRRate,
int rotation) |
MonitorMode(SurfaceSize surfaceSize,
float refreshRate,
int flags,
int rotation)
Creates a user instance w/o
identity to filter our matching modes w/ identity. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(MonitorMode mm)
Compares
sizeAndRRate 1st, then rotation . |
boolean |
equals(Object obj)
Tests equality of two
MonitorMode objects
by evaluating equality of it's components:nativeId
sizeAndRRate
rotation
|
int |
getFlags()
Returns bitfield w/ flags, i.e.
|
int |
getId() |
float |
getRefreshRate()
Returns the vertical refresh rate.
|
int |
getRotatedHeight()
Returns the rotated screen height in pixel units,
derived from
getMonitorMode().getSurfaceSize().getResolution()
and getRotation() |
int |
getRotatedWidth()
Returns the rotated screen width in pixel units,
derived from
getMonitorMode().getSurfaceSize().getResolution()
and getRotation() |
int |
getRotation()
Returns the CCW rotation of this mode
|
MonitorMode.SizeAndRRate |
getSizeAndRRate()
Returns the surfaceSize and refreshRate instance.
|
SurfaceSize |
getSurfaceSize()
Returns the unrotated
SurfaceSize |
int |
hashCode()
Returns a combined hash code of it's elements:
nativeId
sizeAndRRate
rotation
|
static boolean |
isRotationValid(int rotation) |
String |
toString() |
public static final Comparator<MonitorMode> monitorModeComparator
MonitorMode
s, following comparison order as described in compareTo(MonitorMode)
, returning the ascending order.public static final Comparator<MonitorMode> monitorModeComparatorInv
MonitorMode
s, following comparison order as described in compareTo(MonitorMode)
, returning the descending order.public static final int ROTATE_0
public static final int ROTATE_90
public static final int ROTATE_180
public static final int ROTATE_270
public static final int FLAG_INTERLACE
getFlags()
.public static final int FLAG_DOUBLESCAN
getFlags()
.public MonitorMode(int nativeId, MonitorMode.SizeAndRRate sizeAndRRate, int rotation)
sizeAndRRate
- the surface size and refresh rate moderotation
- the screen rotation, measured counter clockwise (CCW)public MonitorMode(SurfaceSize surfaceSize, float refreshRate, int flags, int rotation)
identity
to filter our matching modes w/ identity.
See MonitorModeUtil
for filter utilities.
surfaceSize
- refreshRate
- flags
- rotation
- public static boolean isRotationValid(int rotation)
public final int getId()
public final MonitorMode.SizeAndRRate getSizeAndRRate()
public final SurfaceSize getSurfaceSize()
SurfaceSize
public final float getRefreshRate()
public final int getFlags()
FLAG_DOUBLESCAN
, FLAG_INTERLACE
, ..public final int getRotation()
public final int getRotatedWidth()
getMonitorMode().getSurfaceSize().getResolution()
and getRotation()
public final int getRotatedHeight()
getMonitorMode().getSurfaceSize().getResolution()
and getRotation()
public int compareTo(MonitorMode mm)
Compares sizeAndRRate
1st, then rotation
.
Rotation is compared inverted, i.e. 360 - rotation
,
so the lowest rotation reflects a higher value.
Order of comparing MonitorMode:
compareTo
in interface Comparable<MonitorMode>
public final boolean equals(Object obj)
MonitorMode
objects
by evaluating equality of it's components:nativeId
sizeAndRRate
rotation
Copyright 2010 JogAmp Community.