org.eclipse.ercp.swt.mobile
Class Screen

java.lang.Object
  extended byorg.eclipse.ercp.swt.mobile.Screen

public class Screen
extends java.lang.Object

Instances of this class represent display screens available for application use.

Screen usage types:
PRIMARY
SECONDARY
STATUS
Screen orientation styles:
PORTRAIT
LANDSCAPE

See Also:
MobileDevice, MobileDeviceListener

Field Summary
static int LANDSCAPE
          indicates text is normally written across the longest width
static int PORTRAIT
          indicates text is normally written across the shortest width
static int PRIMARY
          one primary screen may be active at a time
static int SECONDARY
          multiple secondary screens may be simultaneously active
static int STATUS
          sub type of secondary screen that shows minimal content for notification purposes
 
Method Summary
 void addEventListener(ScreenListener listener)
          Adds the listener to the collection of listeners that will be notified when screen events occur by sending it one of the messages defined in the ScreenListener interface.
 Rectangle getBounds()
          Returns the bounds of the screen.
 int getColorDepth()
          Returns the color depth of the screen in bits per pixel.
 int getLocation()
          Returns the location of the screen device.
 int getOrientation()
          Returns the screen orientation.
 int getUsage()
          Returns the usage type of the screen.
 boolean isActive()
          Returns whether the screen is currently active.
 boolean isTouchScreen()
          Returns whether the screen has touch screen capability.
 void removeEventListener(ScreenListener listener)
          Removes the listener from the collection of listeners that will be notified when screen events occur.
 void setOrientation(int orientation)
          Sets the screen orientation if supported on this device.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRIMARY

public static final int PRIMARY
one primary screen may be active at a time

See Also:
Constant Field Values

SECONDARY

public static final int SECONDARY
multiple secondary screens may be simultaneously active

See Also:
Constant Field Values

STATUS

public static final int STATUS
sub type of secondary screen that shows minimal content for notification purposes

See Also:
Constant Field Values

PORTRAIT

public static final int PORTRAIT
indicates text is normally written across the shortest width

See Also:
Constant Field Values

LANDSCAPE

public static final int LANDSCAPE
indicates text is normally written across the longest width

See Also:
Constant Field Values
Method Detail

addEventListener

public void addEventListener(ScreenListener listener)
Adds the listener to the collection of listeners that will be notified when screen events occur by sending it one of the messages defined in the ScreenListener interface.

screenActivated is called when a screen becomes active. That is, the screen is powered and contents are visible to the user.
screenDeactivated is called when a screen is no longer active.

Parameters:
listener - instance called when screen events occur
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
SWTError -
  • ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure
See Also:
ScreenListener, removeEventListener(org.eclipse.ercp.swt.mobile.ScreenListener)

getBounds

public Rectangle getBounds()
Returns the bounds of the screen. Application contents must be within these bounds to be visible on the given device screen. Note, the bounds may not have a 0,0 origin.

Returns:
Rectangle The bounds of the sceen.
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
SWTError -
  • ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure

getColorDepth

public int getColorDepth()
Returns the color depth of the screen in bits per pixel.

Returns:
int the color depth.
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
SWTError -
  • ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure

getLocation

public int getLocation()
Returns the location of the screen device.

Returns:
int The screen location. The value is one of LOCAL, INTERNAL, EXTERNAL, or REMOTE
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
SWTError -
  • ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure
See Also:
MobileDevice.LOCAL, MobileDevice.INTERNAL, MobileDevice.EXTERNAL, MobileDevice.REMOTE

getOrientation

public int getOrientation()
Returns the screen orientation.

Returns:
int The screen orientation. The value must be either PORTRAIT or LANDSCAPE.
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
SWTError -
  • ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure
See Also:
PORTRAIT, LANDSCAPE, setOrientation(int)

getUsage

public int getUsage()
Returns the usage type of the screen.

Returns:
int The type of the screen. The value must be one of PRIMARY, SECONDARY and STATUS
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
SWTError -
  • ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure
See Also:
PRIMARY, SECONDARY, STATUS

isActive

public boolean isActive()
Returns whether the screen is currently active. That is, whether it is powered up and contents are visible to the user.

Returns:
boolean The screen status.
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
SWTError -
  • ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure

isTouchScreen

public boolean isTouchScreen()
Returns whether the screen has touch screen capability.

Returns:
boolean The touch screen capability.
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
SWTError -
  • ERROR_CANNOT_GET_SELECTION - if the operation fails because of an operating system failure

removeEventListener

public void removeEventListener(ScreenListener listener)
Removes the listener from the collection of listeners that will be notified when screen events occur.

Parameters:
listener - instance called when screen events occur
Throws:
java.lang.IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
SWTError -

setOrientation

public void setOrientation(int orientation)
Sets the screen orientation if supported on this device. Note that this feature is implementation-dependent.

Parameters:
orientation - the caller's preferred orientation. Must be one of PORTRAIT and LANDSCAPE.
Throws:
java.lang.IllegalArgumentException -
  • ERROR_INVALID_ARGUMENT - if the argument is not either PORTRAIT or LANDSCAPE
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_CANNOT_SET_SELECTION - if the device could not set the orientation
See Also:
PORTRAIT, LANDSCAPE, getOrientation()