|
@@ -25,41 +25,225 @@
|
|
*/
|
|
*/
|
|
package com.jme3.system;
|
|
package com.jme3.system;
|
|
|
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* This class holds information about the display that was returned by glfwGetMonitors() calls in
|
|
* This class holds information about the display that was returned by glfwGetMonitors() calls in
|
|
* the context class
|
|
* the context class
|
|
*
|
|
*
|
|
* @author Kevin Bales
|
|
* @author Kevin Bales
|
|
|
|
+ * @author wil
|
|
*/
|
|
*/
|
|
-public class DisplayInfo {
|
|
|
|
|
|
+public final class DisplayInfo {
|
|
|
|
+
|
|
|
|
+ /** displayID - display id that was return from Lwjgl3. */
|
|
|
|
+ private long display;
|
|
|
|
+
|
|
|
|
+ /** width - width that was return from Lwjgl3. */
|
|
|
|
+ private int width;
|
|
|
|
+
|
|
|
|
+ /** height - height that was return from Lwjgl3. */
|
|
|
|
+ private int height;
|
|
|
|
+
|
|
|
|
+ /** rate - refresh rate that was return from Lwjgl3. */
|
|
|
|
+ private int rate;
|
|
|
|
+
|
|
|
|
+ /** primary - indicates if the display is the primary monitor. */
|
|
|
|
+ private boolean primary;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * displayID - display id that was return from Lwjgl3.
|
|
|
|
|
|
+ * name - display name that was return from Lwjgl3.
|
|
*/
|
|
*/
|
|
- public long displayID = 0;
|
|
|
|
|
|
+ private String name;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * width - width that was return from Lwjgl3.
|
|
|
|
|
|
+ * Create a new display mode object with the default values
|
|
*/
|
|
*/
|
|
- public int width = 1080;
|
|
|
|
|
|
+ DisplayInfo() {
|
|
|
|
+ this(0L /*NULL*/, 1080, 1920, 60, false, "Generic Monitor");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Create a new display mode object with the supplied parameters.
|
|
|
|
+ * @param display the monitor pointer (native), the virtual memory
|
|
|
|
+ * address used by lwjgl.
|
|
|
|
+ * @param width the width of the display, provided by lwjgl.
|
|
|
|
+ * @param height the height of the display, provided by lwjgl.
|
|
|
|
+ * @param rate the refresh rate of the display, in hertz.
|
|
|
|
+ * @param primary a logical value that determines whether this display is
|
|
|
|
+ * primary or not; {@code true | false}
|
|
|
|
+ * @param name display name
|
|
|
|
+ */
|
|
|
|
+ DisplayInfo(long display, int width, int height, int rate, boolean primary, String name) {
|
|
|
|
+ this.display = display;
|
|
|
|
+ this.width = width;
|
|
|
|
+ this.height = height;
|
|
|
|
+ this.rate = rate;
|
|
|
|
+ this.primary = primary;
|
|
|
|
+ this.name = name;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ // === ----------------------------------------------------------------- ===
|
|
|
|
+ // === SETTERS ===
|
|
|
|
+ // === ----------------------------------------------------------------- ===
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- * height - height that was return from Lwjgl3.
|
|
|
|
|
|
+ * Sets the monitor pointer (native), the virtual memory address used by lwjgl.
|
|
|
|
+ *
|
|
|
|
+ * @param display the monitor pointer (native), the virtual memory
|
|
|
|
+ * address used by lwjgl
|
|
*/
|
|
*/
|
|
- public int height = 1920;
|
|
|
|
|
|
+ void setDisplay(long display) {
|
|
|
|
+ this.display = display;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
- * rate - refresh rate that was return from Lwjgl3.
|
|
|
|
|
|
+ * Sets the width of the display.
|
|
|
|
+ * @param width the width of the display
|
|
*/
|
|
*/
|
|
- public int rate = 60;
|
|
|
|
|
|
+ void setWidth(int width) {
|
|
|
|
+ this.width = width;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
- * primary - indicates if the display is the primary monitor.
|
|
|
|
|
|
+ * Sets the height of the display.
|
|
|
|
+ * @param height the height of the display
|
|
*/
|
|
*/
|
|
- public boolean primary = false;
|
|
|
|
|
|
+ void setHeight(int height) {
|
|
|
|
+ this.height = height;
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
- * name - display name that was return from Lwjgl3.
|
|
|
|
|
|
+ * Sets the refresh rate of the display, in hertz.
|
|
|
|
+ * @param rate the refresh rate of the display, in hertz
|
|
|
|
+ */
|
|
|
|
+ void setRate(int rate) {
|
|
|
|
+ this.rate = rate;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Set this display as primary or not.
|
|
|
|
+ * @param primary {@code true} if the display is primary, {@code false} otherwise.
|
|
|
|
+ */
|
|
|
|
+ void setPrimary(boolean primary) {
|
|
|
|
+ this.primary = primary;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Set the screen (display) name
|
|
|
|
+ * @param name display name
|
|
|
|
+ */
|
|
|
|
+ void setName(String name) {
|
|
|
|
+ this.name = name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // === ----------------------------------------------------------------- ===
|
|
|
|
+ // === GETTERS ===
|
|
|
|
+ // === ----------------------------------------------------------------- ===
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns the monitor pointer (native), the virtual memory address used by lwjgl.
|
|
|
|
+ * @return the monitor pointer (native), the virtual memory address used by lwjgl
|
|
|
|
+ */
|
|
|
|
+ public long getDisplay() {
|
|
|
|
+ return display;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns the width of the display.
|
|
|
|
+ * @return the width of the display.
|
|
|
|
+ */
|
|
|
|
+ public int getWidth() {
|
|
|
|
+ return width;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns the height of the display.
|
|
|
|
+ * @return the height of the display
|
|
|
|
+ */
|
|
|
|
+ public int getHeight() {
|
|
|
|
+ return height;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns the refresh rate of the display, in hertz.
|
|
|
|
+ * @return the refresh rate of the display, in hertz
|
|
|
|
+ */
|
|
|
|
+ public int getRate() {
|
|
|
|
+ return rate;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Determines if this display belongs to the main monitor.
|
|
|
|
+ * @return {@code true} if the display is primary, {@code false} otherwise.
|
|
|
|
+ */
|
|
|
|
+ public boolean isPrimary() {
|
|
|
|
+ return primary;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns the display name.
|
|
|
|
+ * @return display name
|
|
|
|
+ */
|
|
|
|
+ public String getName() {
|
|
|
|
+ return name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * {@inheritDoc }
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public int hashCode() {
|
|
|
|
+ int hash = 3;
|
|
|
|
+ hash = 97 * hash + (int) (this.display ^ (this.display >>> 32));
|
|
|
|
+ hash = 97 * hash + this.width;
|
|
|
|
+ hash = 97 * hash + this.height;
|
|
|
|
+ hash = 97 * hash + this.rate;
|
|
|
|
+ hash = 97 * hash + (this.primary ? 1 : 0);
|
|
|
|
+ hash = 97 * hash + Objects.hashCode(this.name);
|
|
|
|
+ return hash;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * {@inheritDoc }
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public boolean equals(Object obj) {
|
|
|
|
+ if (this == obj) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ if (obj == null) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (getClass() != obj.getClass()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ final DisplayInfo other = (DisplayInfo) obj;
|
|
|
|
+ if (this.display != other.display) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (this.width != other.width) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (this.height != other.height) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (this.rate != other.rate) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ if (this.primary != other.primary) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ return Objects.equals(this.name, other.name);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * {@inheritDoc }
|
|
*/
|
|
*/
|
|
- public String name = "Generic Monitor";
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public String toString() {
|
|
|
|
+ return getDisplay() == 0L ? "NULL" : ("(" + getName() + "|"
|
|
|
|
+ + getDisplay() + ")" + getWidth() + "x" + getHeight() + "@"
|
|
|
|
+ + (getRate() > 0 ? getRate() + "Hz" : "[Unknown refresh rate]"));
|
|
|
|
+ }
|
|
}
|
|
}
|