29package com.jogamp.newt;
31import java.util.Comparator;
33import com.jogamp.nativewindow.util.DimensionImmutable;
34import com.jogamp.nativewindow.util.RectangleImmutable;
35import com.jogamp.nativewindow.util.SurfaceSize;
37import com.jogamp.newt.util.MonitorModeUtil;
149 throw new IllegalArgumentException(
"surfaceSize must be set ("+
surfaceSize+
")");
154 this.hashCode = getHashCode();
157 private final static String STR_INTERLACE =
"Interlace";
158 private final static String STR_DOUBLESCAN =
"DoubleScan";
159 private final static String STR_SEP =
", ";
162 final StringBuilder sb =
new StringBuilder();
165 sb.append(STR_INTERLACE);
172 sb.append(STR_DOUBLESCAN);
203 final int tflags = 0 ==
flags ? Integer.MAX_VALUE :
flags;
204 final int xflags = 0 == sszr.flags ? Integer.MAX_VALUE : sszr.
flags;
205 if( tflags == xflags ) {
206 final float refreshEpsilon = 0.01f;
208 if( Math.abs(drate) < refreshEpsilon ) {
210 }
else if( drate > refreshEpsilon ) {
216 if(tflags > xflags) {
218 }
else if(tflags < xflags) {
235 public final boolean equals(
final Object obj) {
236 if (
this == obj) {
return true; }
258 private final int getHashCode() {
261 hash = ((hash << 5) - hash) +
flags;
262 hash = ((hash << 5) - hash) + (int)(
refreshRate*100.0f);
286 private final int nativeId;
288 private final int rotation;
289 private final int hashCode;
292 return rotation == MonitorMode.ROTATE_0 || rotation == MonitorMode.ROTATE_90 ||
293 rotation == MonitorMode.ROTATE_180 || rotation == MonitorMode.ROTATE_270 ;
302 throw new RuntimeException(
"invalid rotation: "+rotation);
304 this.nativeId = nativeId;
305 this.sizeAndRRate = sizeAndRRate;
306 this.rotation = rotation;
307 this.hashCode = getHashCode();
321 this(0,
new SizeAndRRate(surfaceSize, refreshRate, flags), rotation);
325 public final int getId() {
return nativeId; }
344 return sizeAndRRate.
flags;
357 return getRotatedWH(
true);
365 return getRotatedWH(
false);
370 return "[Id "+
Display.
toHexString(nativeId)+
", " + sizeAndRRate +
", " + rotation +
" degr]";
395 final int c = sizeAndRRate.
compareTo(mm.sizeAndRRate);
399 final int trot = 360 - rotation;
400 final int xrot = 360 - mm.rotation;
403 }
else if(trot < xrot) {
419 public final boolean equals(
final Object obj) {
420 if (
this == obj) {
return true; }
423 return sm.nativeId == this.nativeId &&
424 sm.sizeAndRRate.
equals(sizeAndRRate) &&
425 sm.rotation == this.rotation ;
442 private final int getHashCode() {
444 int hash = 31 +
getId();
445 hash = ((hash << 5) - hash) + sizeAndRRate.
hashCode();
450 private final int getRotatedWH(
final boolean width) {
452 final boolean swap = MonitorMode.ROTATE_90 == rotation || MonitorMode.ROTATE_270 == rotation ;
453 if ( ( width && swap ) || ( !width && !swap ) ) {
Immutable SurfaceSize Class, consisting of it's read only components:
final boolean equals(final Object obj)
Checks whether two size objects are equal.
final DimensionImmutable getResolution()
Returns the resolution in pixel units.
int compareTo(final SurfaceSize ssz)
static String toHexString(final int hex)
Immutable surfaceSize, flags and refreshRate Class, consisting of it's read only components:
final int hashCode()
Returns a combined hash code of it's elements:
final int flags
Mode bitfield flags, i.e.
SizeAndRRate(final SurfaceSize surfaceSize, final float refreshRate, final int flags)
int compareTo(final SizeAndRRate sszr)
final SurfaceSize surfaceSize
Non rotated surface size in pixel units.
static final StringBuilder flags2String(final int flags)
final boolean equals(final Object obj)
Tests equality of two SizeAndRRate objects by evaluating equality of it's components:
final float refreshRate
Vertical refresh rate.
Immutable MonitorMode Class, consisting of it's read only components:
static final int FLAG_DOUBLESCAN
Lines are doubled.
static final int ROTATE_90
90 degrees CCW rotation
final int getFlags()
Returns bitfield w/ flags, i.e.
final boolean equals(final Object obj)
Tests equality of two MonitorMode objects by evaluating equality of it's components:
static final Comparator< MonitorMode > monitorModeComparatorInv
Comparator for 2 MonitorModes, following comparison order as described in MonitorMode#compareTo(Monit...
final SizeAndRRate getSizeAndRRate()
Returns the surfaceSize and refreshRate instance.
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.
static final int FLAG_INTERLACE
Frame is split into two fields.
MonitorMode(final int nativeId, final SizeAndRRate sizeAndRRate, final int rotation)
final SurfaceSize getSurfaceSize()
Returns the unrotated SurfaceSize.
static boolean isRotationValid(final int rotation)
static final Comparator< MonitorMode > monitorModeComparator
Comparator for 2 MonitorModes, following comparison order as described in MonitorMode#compareTo(Monit...
final int getRotatedHeight()
Returns the rotated screen height in pixel units, derived from getMonitorMode().getSurfaceSize()....
final int hashCode()
Returns a combined hash code of it's elements:
final int getRotatedWidth()
Returns the rotated screen width in pixel units, derived from getMonitorMode().getSurfaceSize()....
final int getRotation()
Returns the CCW rotation of this mode.
static final int ROTATE_0
zero rotation, compared to normal settings
int compareTo(final MonitorMode mm)
final float getRefreshRate()
Returns the vertical refresh rate.
static final int ROTATE_270
270 degrees CCW rotation
static final int ROTATE_180
180 degrees CCW rotation