Class MonitorDevice

java.lang.Object
com.jogamp.newt.MonitorDevice

public abstract class MonitorDevice extends Object
Visual output device, i.e. a CRT, LED ..consisting of it's components:
  • Immutable
  • Mutable
  • All values of this interface are represented in pixel units, if not stated otherwise.

    • Method Details

      • getScreen

        public final Screen getScreen()
        Returns the Screen owning this monitor.
      • equals

        public final boolean equals(Object obj)
        Tests equality of two MonitorDevice objects by evaluating equality of it's components:
        • nativeID

        Overrides:
        equals in class Object
      • hashCode

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

        public final int getId()
        Returns:
        the immutable unique native Id of this monitor device.
      • isClone

        public final boolean isClone()
        Returns:
        true if this device represents a clone, otherwise return false.
      • isPrimary

        public final boolean isPrimary()
        Returns true if this device represents the primary device, otherwise return false.
        See Also:
      • getSizeMM

        public final DimensionImmutable getSizeMM()
        Returns:
        the immutable monitor size in millimeters.
      • getPixelsPerMM

        public final float[] getPixelsPerMM(float[] ppmmStore)
        Returns the pixels per millimeter value according to the current mode's surface resolution.

        To convert the result to dpi, i.e. dots-per-inch, multiply both components with 25.4f.

        Parameters:
        ppmmStore - float[2] storage for the ppmm result
        Returns:
        the passed storage containing the ppmm for chaining
      • getPixelsPerMM

        public final float[] getPixelsPerMM(MonitorMode mode, float[] ppmmStore)
        Returns the pixels per millimeter value according to the given mode's surface resolution.

        To convert the result to dpi, i.e. dots-per-inch, multiply both components with 25.4f.

        Parameters:
        mode -
        ppmmStore - float[2] storage for the ppmm result
        Returns:
        the passed storage containing the ppmm for chaining
      • getOriginalMode

        public final MonitorMode getOriginalMode()
        Returns the immutable original MonitorMode, as used at NEWT initialization.

        The returned MonitorMode is element of the lists getSupportedModes() and Screen.getMonitorModes().

      • getSupportedModes

        public final List<MonitorMode> getSupportedModes()
        Returns a list of immutable MonitorModes supported by this monitor.

        The list is ordered in descending order, see MonitorMode.compareTo(MonitorMode).

        Use w/ care, it's not a copy!

      • getViewport

        public final RectangleImmutable getViewport()
        Returns the current rectangular portion of the rotated virtual Screen size in pixel units represented by this monitor, i.e. top-left origin and size.
        See Also:
      • getViewportInWindowUnits

        public final RectangleImmutable getViewportInWindowUnits()
        Returns the current rectangular portion of the rotated virtual Screen size in window units represented by this monitor, i.e. top-left origin and size.
        See Also:
      • getPixelScale

        public float[] getPixelScale(float[] result)
        Returns the current rotated pixel-scale of this monitor, i.e. horizontal and vertical.
        See Also:
      • contains

        public final boolean contains(int x, int y)
        Returns true if given screen coordinates in pixel units are contained by this viewport, otherwise false.
        Parameters:
        x - x-coord in pixel units
        y - y-coord in pixel units
      • unionOfViewports

        public static void unionOfViewports(Rectangle viewport, Rectangle viewportInWindowUnits, List<MonitorDevice> monitors)
        Calculates the union of the given monitor's viewport in pixel- and window units.
        Parameters:
        viewport - storage for result in pixel units, maybe null
        viewportInWindowUnits - storage for result in window units, maybe null
        monitors - given list of monitors
      • isOriginalMode

        public final boolean isOriginalMode()
      • isModeChangedByUs

        public final boolean isModeChangedByUs()
        Returns true if the MonitorMode has been changed programmatic via this API only, otherwise false.

        Note: We cannot guarantee that we won't interfere w/ another running application's screen mode change or vice versa.

      • getCurrentMode

        public final MonitorMode getCurrentMode()
        Returns the cached current MonitorMode w/o native query.

        The returned MonitorMode is element of the lists getSupportedModes() and Screen.getMonitorModes().

        See Also:
      • queryCurrentMode

        public abstract MonitorMode queryCurrentMode() throws IllegalStateException
        Returns the current MonitorMode resulting from a native query.

        The returned MonitorMode is element of the lists getSupportedModes() and Screen.getMonitorModes().

        Throws:
        IllegalStateException - if the associated screen is not valid natively.
        See Also:
      • setCurrentMode

        public abstract boolean setCurrentMode(MonitorMode mode) throws IllegalStateException
        Set the current MonitorMode.

        This method is lifecycle heavy.

        Parameters:
        mode - to be made current, must be element of the list getSupportedModes() and Screen.getMonitorModes().
        Returns:
        true if successful, otherwise false
        Throws:
        IllegalStateException - if the associated screen is not valid natively.
      • toString

        public String toString()
        Overrides:
        toString in class Object