Class MonitorMode

java.lang.Object
com.jogamp.newt.MonitorMode
All Implemented Interfaces:
Comparable<MonitorMode>

public class MonitorMode extends Object implements Comparable<MonitorMode>
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);
 
  • Field Details

  • Constructor Details

    • MonitorMode

      public MonitorMode(int nativeId, MonitorMode.SizeAndRRate sizeAndRRate, int rotation)
      Parameters:
      sizeAndRRate - the surface size and refresh rate mode
      rotation - the screen rotation, measured counter clockwise (CCW)
    • MonitorMode

      public MonitorMode(SurfaceSize surfaceSize, float refreshRate, int flags, int rotation)
      Creates a user instance w/o identity 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

      public final MonitorMode.SizeAndRRate getSizeAndRRate()
      Returns the surfaceSize and refreshRate instance.
    • getSurfaceSize

      public final SurfaceSize getSurfaceSize()
      Returns the unrotated SurfaceSize
    • 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 from getMonitorMode().getSurfaceSize().getResolution() and getRotation()
    • getRotatedHeight

      public final int getRotatedHeight()
      Returns the rotated screen height in pixel units, derived from getMonitorMode().getSurfaceSize().getResolution() and getRotation()
    • toString

      public final String toString()
      Overrides:
      toString in class Object
    • compareTo

      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:

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

      Specified by:
      compareTo in interface Comparable<MonitorMode>
    • equals

      public final boolean equals(Object obj)
      Tests equality of two MonitorMode objects by evaluating equality of it's components:
      • nativeId
      • sizeAndRRate
      • rotation
      Overrides:
      equals in class Object
    • hashCode

      public final int hashCode()
      Returns a combined hash code of it's elements:
      • nativeId
      • sizeAndRRate
      • rotation
      Overrides:
      hashCode in class Object