Java DTV API 1.3
18-Nov-2009

com.sun.dtv.ui
Class Device

java.lang.Object
  extended by com.sun.dtv.ui.Device

public class Device
extends Object

This class is a representation of a TV device. Such a device has at least one Screen, there may be also several screens. UserInputDevices are always bound to screens. Even if there exists physically one user input device (e.g. an RemoteControl) which can be used to control more than one Screen (e.g. as it has a switch enabling the user to switch between screens to be controlled by this device), it will be logically split into one UserInputDevice per Screen.

The following is a code snippet, demonstrating how to work with a device and the associated screens.

 // First, get the Screen.  We'll just use the default screen since 
 // in most cases we will have probably only one.
 device = Device.getInstance();
 screen = device.getDefaultScreen();

 // Now as we have the screen, we will be able to configure several
 // planes on it. As this is a UIDemo, we will concentrate on the
 // graphics plane.
 Plane[] planes = screen.getAllPlanes();
 // search for a plane with graphics capabilities
 for(int i=0; i<planes.length; i++) {
      Capabilities cap = planes[i].getCapabilities();
      if (cap.isGraphicsRenderingSupported()) {
              plane = planes[i];
              break;
              // in this case we take the first plane with graphics 
              // capabilities for further use as graphics plane.
              // of course we could also check for several planes with
              // graphics capabilities, and choose one by checking
              // additional capabilities
      }
 }

 // Create a new template for the graphics
 // setup and start set preferences
 PlaneSetupPattern pattern;
 pattern = new PlaneSetupPattern();

 // We prefer a setup that supports image scaling
 pattern.setPreference(PlaneSetupPattern.IMAGE_SCALING_SUPPORT, 
                           PlaneSetupPattern.PREFERRED);

 // We also need a setup that doesn't affect applications that are 
 // already running
 pattern.setPreference(PlaneSetupPattern.NO_GRAPHICS_IMPACT, 
                            PlaneSetupPattern.REQUIRED);

 // Now get a plane setup that matches our preferences
 PlaneSetup setup;
 setup = plane.getBestSetup(pattern);

 // Finally, we are able to set the setup. Before doing this, we need to 
 // check that our setup is not null (to make sure that our preferences 
 // could actually be met).
 if (setup != null) {
      try {
              // we have to reserve the plane first as a scarce resource
              // as we plan to modify it by setting a new setup
              // we do not force this, i.e. wait until plane is released
              // for us, we do not specify a timeout, and the 
              // ScarceResourceListener is our application (it has to 
              // implement the ScarceResourceListener interface for this
              plane.reserve(false,-1,this);
              plane.setPlaneSetup(setup);
              // after setting the setup, we can release the plane
              plane.release();
      } catch (Exception e) {
              // react if setting of setup did not work
      }
 }
      
 // Now, as the GraphicsPlane is ready configured, we can draw on it
 // First, we need a DTVContainer, the top level component
 DTVContainer container;
 container = DTVContainer.getDTVContainer(plane);
 // Alternatively, we would have been able in this case to take
 // the default DTV container, as we have only one screen with
 // one graphics plane:
 // container = DTVContainer.getDefaultDTVContainer();
 
 // We can now work and draw widgets and graphics within the DTVContainer.
 // ...
 // Once, we may have to know whether our screen supports a TV remote control
 // and - if yes - get it:
 if(screen.isRemoteControlSupported()) {
   RemoteControl rc = screen.getRemoteControl();
   // ...
 }
 // ...
 


Constructor Summary
protected Device()
          There is no intention to enable users to create a device.
 
Method Summary
 Screen getDefaultScreen()
          Returns the default Screen for this device.
static Device getInstance()
          Retrieving the Device instance representing the used TV device from the implementation.
 Screen[] getScreens()
          Returns a list of all Screens associated with this Device.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Device

protected Device()
There is no intention to enable users to create a device. The device instance should be retrieved from the DTV API implementation on a particular device by calling getInstance().

Method Detail

getInstance

public static Device getInstance()
Retrieving the Device instance representing the used TV device from the implementation.

Returns:
the device instance representing the currently used TV device

getDefaultScreen

public Screen getDefaultScreen()
Returns the default Screen for this device.

Returns:
the default Screen for this device.

getScreens

public Screen[] getScreens()
Returns a list of all Screens associated with this Device.

Returns:
list of all Screens associated with this Device

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.