|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.dtv.ui.Device
public class Device
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 |
---|
protected Device()
getInstance()
.
Method Detail |
---|
public static Device getInstance()
Device
instance representing the
used TV device from the implementation.
public Screen getDefaultScreen()
Screen
for this
device.
Screen
for this
device.public Screen[] getScreens()
Screens
associated
with this Device
.
Screens
associated
with this Device
|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |