Class Screen


  • public abstract class Screen
    extends Object
    A screen may span multiple MonitorDevices representing their combined virtual size.

    All values of this interface are represented in pixel units, if not stated otherwise.

    Coordinate System

    • Screen space has it's origin in the top-left corner, and may not be at 0/0.
    • Virtual viewport covers all MonitorDevices viewports and has it's origin in the top-left corner, and may not be at 0/0.

    • Field Detail

      • SCREEN_MODE_CHANGE_TIMEOUT

        public static final int SCREEN_MODE_CHANGE_TIMEOUT
        A 10s timeout for screen mode change. It is observed, that some platforms need a notable amount of time for this task, especially in case of rotation change.
        See Also:
        Constant Field Values
      • DEBUG

        public static final boolean DEBUG
    • Constructor Detail

      • Screen

        public Screen()
    • Method Detail

      • hashCode

        public abstract int hashCode()
        return precomputed hashCode from FQN getFQName()
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(Object obj)
        return true if obj is of type Display and both FQN getFQName() equals
        Overrides:
        equals in class Object
      • destroy

        public abstract void destroy()
        Manually trigger the destruction, incl. native destruction.

        This method is usually invoke by removeReference()

        This method invokes Display.removeReference() after it's own destruction,
        which will issue Display.destroy() if the reference count becomes 0.

      • isNativeValid

        public abstract boolean isNativeValid()
      • getReferenceCount

        public abstract int getReferenceCount()
        Returns:
        number of references
      • removeReference

        public abstract int removeReference()
        Returns:
        number of references post operation
        See Also:
        addReference(), #setDestroyWhenUnused(boolean), #getDestroyWhenUnused()
      • getIndex

        public abstract int getIndex()
        Returns:
        this Screen index of all Screens of getDisplay().
      • getX

        public abstract int getX()
        Returns:
        the x position of the virtual viewport's top-left origin in pixel units.
      • getY

        public abstract int getY()
        Returns:
        the y position of the virtual viewport's top-left origin in pixel units.
      • getWidth

        public abstract int getWidth()
        Returns:
        the rotated virtual viewport's width in pixel units.
      • getHeight

        public abstract int getHeight()
        Returns:
        the rotated virtual viewport's height in pixel units.
      • getDisplay

        public abstract Display getDisplay()
        Returns:
        the associated Display
      • getFullyEnteredMonitor

        public final MonitorDevice getFullyEnteredMonitor​(RectangleImmutable r)
        Returns the MonitorDevice which completely which viewport completely coverage the given rectangle in window units, which is not a clone.

        If no match is found, null is being returned

        Parameters:
        r - arbitrary rectangle in window units
      • getMonitorById

        public final MonitorDevice getMonitorById​(int monitorId)
        Returns the MonitorDevice which matches the given integer monitorId.

        If no match is found, null is being returned

      • getMonitorByHandle

        public final MonitorDevice getMonitorByHandle​(long monitorHandle)
        Returns the MonitorDevice which matches the given long monitorHandle.

        If no match is found, null is being returned

      • getMonitorByName

        public final MonitorDevice getMonitorByName​(String name)
        Returns the MonitorDevice which matches the given name.

        If no match is found or the given name is null or empty, null is being returned

      • unionOfMonitorViewports

        public final void unionOfMonitorViewports​(Rectangle viewport,
                                                  Rectangle viewportInWindowUnits)
        Calculates the union of all monitor's viewport in pixel- and window units.

        Should be equal to getX(), getY(), getWidth() and getHeight(), however, some native toolkits may choose a different virtual screen area.

        Parameters:
        viewport - storage for result in pixel units, maybe null
        viewportInWindowUnits - storage for result in window units, maybe null
      • getFirstScreenOf

        public static Screen getFirstScreenOf​(Display display,
                                              int idx,
                                              int fromIndex)
        Parameters:
        type -
        name -
        fromIndex - start index, then increasing until found or end of list *
        Returns:
      • getLastScreenOf

        public static Screen getLastScreenOf​(Display display,
                                             int idx,
                                             int fromIndex)
        Parameters:
        type -
        name -
        fromIndex - start index, then decreasing until found or end of list. -1 is interpreted as size - 1.
        Returns:
      • getAllScreens

        public static Collection<Screen> getAllScreens()
        Returns the global screen collection
      • getActiveScreenNumber

        public static int getActiveScreenNumber()