Top Description Inners Fields Constructors Methods
com.jogamp.newt

public Class MonitorMode

extends Object
implements Comparable<MonitorMode>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable
Imports
java.util.Comparator, com.jogamp.nativewindow.util.DimensionImmutable, .RectangleImmutable, .SurfaceSize, com.jogamp.newt.util.MonitorModeUtil

Immutable MonitorMode Class, consisting of it's read only components:
Aquire and filter MonitorMode

Changing MonitorMode

Example for changing the MonitorMode:
       // Pick the monitor:
       // Either the one used by a window ..
       MonitorDevice monitor = window.getMainMonitor();

       // Or arbitrary from the list ..
       List allMonitor = 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 and Inner Type Summary

Modifier and TypeClass and Description
public 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

Field Summary

Modifier and TypeField and Description
public static final int
FLAG_DOUBLESCAN

Lines are doubled.

public static final int
FLAG_INTERLACE

Frame is split into two fields.

private final int
public static final Comparator<MonitorMode>
monitorModeComparator

Comparator for 2 MonitorModes, following comparison order as described in MonitorMode#compareTo(MonitorMode), returning the ascending order.

public static final Comparator<MonitorMode>
monitorModeComparatorInv

Comparator for 2 MonitorModes, following comparison order as described in MonitorMode#compareTo(MonitorMode), returning the descending order.

private final int
nativeId

The immutable native Id of this instance, which may not be unique.

public static final int
ROTATE_0

zero rotation, compared to normal settings

public static final int
ROTATE_180

180 degrees CCW rotation

public static final int
ROTATE_270

270 degrees CCW rotation

public static final int
ROTATE_90

90 degrees CCW rotation

private final int
private final MonitorMode.SizeAndRRate

Constructor Summary

AccessConstructor and Description
public
MonitorMode(final int nativeId, final MonitorMode.SizeAndRRate
the surface size and refresh rate mode
sizeAndRRate
,
final int
the screen rotation, measured counter clockwise (CCW)
rotation
)

public
MonitorMode(final SurfaceSize surfaceSize, final float refreshRate, final int flags, final int rotation)

Creates a user instance w/o identity to filter our matching modes w/ identity.

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(final MonitorMode
the object to be compared.
mm
)

Implements java.lang.Comparable.compareTo.

Compares sizeAndRRate 1st, then rotation.

public final boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Tests equality of two MonitorMode objects by evaluating equality of it's components:
  • nativeId
  • sizeAndRRate
  • rotation
public final int
getFlags()

Returns bitfield w/ flags, i.e. FLAG_DOUBLESCAN, FLAG_INTERLACE, ..

private final int
public final int

Returns:

the immutable native Id of this mode, may not be unique, may be 0.
getId
()

public final float
getRefreshRate()

Returns the vertical refresh rate.

public final int
getRotatedHeight()

Returns the rotated screen height in pixel units, derived from getMonitorMode().getSurfaceSize().getResolution() and getRotation()

private final int
getRotatedWH(final boolean width)

public final int
getRotatedWidth()

Returns the rotated screen width in pixel units, derived from getMonitorMode().getSurfaceSize().getResolution() and getRotation()

public final int
getRotation()

Returns the CCW rotation of this mode

public final MonitorMode.SizeAndRRate
getSizeAndRRate()

Returns the surfaceSize and refreshRate instance.

public final SurfaceSize
getSurfaceSize()

Returns the unrotated SurfaceSize

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a combined hash code of it's elements:
  • nativeId
  • sizeAndRRate
  • rotation
public static boolean
isRotationValid(final int rotation)

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

FLAG_DOUBLESCANback to summary
public static final int FLAG_DOUBLESCAN

Lines are doubled. See getFlags().

FLAG_INTERLACEback to summary
public static final int FLAG_INTERLACE

Frame is split into two fields. See getFlags().

hashCodeback to summary
private final int hashCode
monitorModeComparatorback to summary
public static final Comparator<MonitorMode> monitorModeComparator

Comparator for 2 MonitorModes, following comparison order as described in MonitorMode#compareTo(MonitorMode), returning the ascending order.

monitorModeComparatorInvback to summary
public static final Comparator<MonitorMode> monitorModeComparatorInv

Comparator for 2 MonitorModes, following comparison order as described in MonitorMode#compareTo(MonitorMode), returning the descending order.

nativeIdback to summary
private final int nativeId

The immutable native Id of this instance, which may not be unique.

ROTATE_0back to summary
public static final int ROTATE_0

zero rotation, compared to normal settings

ROTATE_180back to summary
public static final int ROTATE_180

180 degrees CCW rotation

ROTATE_270back to summary
public static final int ROTATE_270

270 degrees CCW rotation

ROTATE_90back to summary
public static final int ROTATE_90

90 degrees CCW rotation

rotationback to summary
private final int rotation
sizeAndRRateback to summary
private final MonitorMode.SizeAndRRate sizeAndRRate

Constructor Detail

MonitorModeback to summary
public MonitorMode(final int nativeId, final MonitorMode.SizeAndRRate sizeAndRRate, final int rotation)
Parameters
sizeAndRRate:MonitorMode.SizeAndRRate

the surface size and refresh rate mode

rotation:int

the screen rotation, measured counter clockwise (CCW)

MonitorModeback to summary
public MonitorMode(final SurfaceSize surfaceSize, final float refreshRate, final int flags, final int rotation)

Creates a user instance w/o identity to filter our matching modes w/ identity.

See com.jogamp.newt.util.MonitorModeUtil for filter utilities.

Method Detail

compareToback to summary
public int compareTo(final MonitorMode mm)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

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:

  • resolution
  • bits per pixel
  • flags
  • refresh rate
  • rotation

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
mm:MonitorMode

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
equalsback to summary
public final boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Tests equality of two MonitorMode objects by evaluating equality of it's components:

  • nativeId
  • sizeAndRRate
  • rotation
Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getFlagsback to summary
public final int getFlags()

Returns bitfield w/ flags, i.e. FLAG_DOUBLESCAN, FLAG_INTERLACE, ..

getHashCodeback to summary
private final int getHashCode()
getIdback to summary
public final int getId()
Returns:int

the immutable native Id of this mode, may not be unique, may be 0.

getRefreshRateback to summary
public final float getRefreshRate()

Returns the vertical refresh rate.

getRotatedHeightback to summary
public final int getRotatedHeight()

Returns the rotated screen height in pixel units, derived from getMonitorMode().getSurfaceSize().getResolution() and getRotation()

getRotatedWHback to summary
private final int getRotatedWH(final boolean width)
getRotatedWidthback to summary
public final int getRotatedWidth()

Returns the rotated screen width in pixel units, derived from getMonitorMode().getSurfaceSize().getResolution() and getRotation()

getRotationback to summary
public final int getRotation()

Returns the CCW rotation of this mode

getSizeAndRRateback to summary
public final MonitorMode.SizeAndRRate getSizeAndRRate()

Returns the surfaceSize and refreshRate instance.

getSurfaceSizeback to summary
public final SurfaceSize getSurfaceSize()

Returns the unrotated SurfaceSize

hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Returns a combined hash code of it's elements:

  • nativeId
  • sizeAndRRate
  • rotation
Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

Annotations
@Override
isRotationValidback to summary
public static boolean isRotationValid(final int rotation)
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
com.jogamp.newt back to summary

public Class MonitorMode.SizeAndRRate

extends Object
implements Comparable<MonitorMode.SizeAndRRate>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable

Immutable surfaceSize, flags and refreshRate Class, consisting of it's read only components:

Field Summary

Modifier and TypeField and Description
public final int
flags

Mode bitfield flags, i.e. FLAG_DOUBLESCAN, FLAG_INTERLACE, ..

public final int
public final float
refreshRate

Vertical refresh rate

private static final String
private static final String
private static final String
public final SurfaceSize
surfaceSize

Non rotated surface size in pixel units

Constructor Summary

AccessConstructor and Description
public
SizeAndRRate(final SurfaceSize surfaceSize, final float refreshRate, final int flags)

Method Summary

Modifier and TypeMethod and Description
public int
compareTo(final MonitorMode.SizeAndRRate
the object to be compared.
sszr
)

Implements java.lang.Comparable.compareTo.

Compares surfaceSize 1st, then flags, then refreshRate.

public final boolean
equals(final Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Tests equality of two SizeAndRRate objects by evaluating equality of it's components:
  • surfaceSize
  • refreshRate
  • flags
public static final StringBuilder
flags2String(final int flags)

private final int
public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a combined hash code of it's elements:
  • surfaceSize
  • flags
  • refreshRate
public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

flagsback to summary
public final int flags

Mode bitfield flags, i.e. FLAG_DOUBLESCAN, FLAG_INTERLACE, ..

hashCodeback to summary
public final int hashCode
refreshRateback to summary
public final float refreshRate

Vertical refresh rate

STR_DOUBLESCANback to summary
private static final String STR_DOUBLESCAN
STR_INTERLACEback to summary
private static final String STR_INTERLACE
STR_SEPback to summary
private static final String STR_SEP
surfaceSizeback to summary
public final SurfaceSize surfaceSize

Non rotated surface size in pixel units

Constructor Detail

SizeAndRRateback to summary
public SizeAndRRate(final SurfaceSize surfaceSize, final float refreshRate, final int flags)

Method Detail

compareToback to summary
public int compareTo(final MonitorMode.SizeAndRRate sszr)

Implements java.lang.Comparable.compareTo.

Doc from java.lang.Comparable.compareTo.

Compares surfaceSize 1st, then flags, then refreshRate.

Flags are compared as follows:

  NONE > DOUBLESCAN > INTERLACE

Refresh rate differences of < 0.01 are considered equal (epsilon).

Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

The implementor must ensure signum(x.compareTo(y)) == -signum(y.compareTo(x)) for all x and y. (This implies that x.compareTo(y) must throw an exception if and only if y.compareTo(x) throws an exception.)

The implementor must also ensure that the relation is transitive: (x.compareTo(y) > 0 && y.compareTo(z) > 0) implies x.compareTo(z) > 0.

Finally, the implementor must ensure that x.compareTo(y)==0 implies that signum(x.compareTo(z)) == signum(y.compareTo(z)), for all z.

Parameters
sszr:MonitorMode.SizeAndRRate

the object to be compared.

Returns:int

a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Annotations
@Override
equalsback to summary
public final boolean equals(final Object obj)

Overrides java.lang.Object.equals.

Tests equality of two SizeAndRRate objects by evaluating equality of it's components:

  • surfaceSize
  • refreshRate
  • flags
Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
flags2Stringback to summary
public static final StringBuilder flags2String(final int flags)
getHashCodeback to summary
private final int getHashCode()
hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Returns a combined hash code of it's elements:

  • surfaceSize
  • flags
  • refreshRate
Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object

Annotations
@Override
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override