FileDocCategorySizeDatePackage
DisplayDeviceAccess.javaAPI DocphoneME MR2 API (J2ME)5326Wed May 02 18:00:24 BST 2007com.sun.midp.lcdui

DisplayDeviceAccess

public class DisplayDeviceAccess extends Object
Class that allows Display to access Device specific calls in the native code like flashBacklight.

Fields Summary
private static Timer
timerService
The Timer to service TimerTasks.
private TimerTask
task
A TimerTask.
private static int
BLINK_RATE
The interval, in microseconds between backlight toggles (in microseconds)
private int
flashCount
Number of repetitions left in flash duration
private boolean
isLit
We always want this to be false at the end of a flashBacklight call.
Constructors Summary
Methods Summary
private voidcancelTimer()
Cancel any running Timer.

        if (task != null) {
            task.cancel();
            task = null;
        }
        flashCount = 0;
    
public booleanflashBacklight(int displayId, int duration)
Requests a flashing effect for the device's backlight.

param
displayId The display ID associated with this Display
param
duration the number of milliseconds the backlight should be flashed, or zero if the flashing should be stopped
return
true if the backlight can be controlled



                                                      
          

        // Test for negative of duration is in public class

        if (duration == 0) {
            cancelTimer();
            if (isLit) {
                isLit = !isLit;
                return toggleBacklight0(displayId);
            } else {
                return isBacklightSupported0(displayId);
            }
        } else {
            setTimer(displayId, duration);
            isLit = !isLit;
            return toggleBacklight0(displayId);
        }
    
private native booleanisBacklightSupported0(int displayId)
Tests if backlight is supported.

param
displayId The display ID associated with the caller Display
return
true if backlight control is supported, false otherwise

private voidsetTimer(int displayId, int duration)
Set a new timer. Determine flashCount based on duration divided by BLINK_RATE

param
displayId The display ID associated with this Display
param
duration the number of milliseconds the timer should be run

        cancelTimer();
        try {
            task = new TimerClient(displayId);
            /* flash every <tt>BLINK_RATE</tt> miliseconds */
            flashCount = duration / BLINK_RATE;
            timerService.schedule(task, BLINK_RATE, BLINK_RATE);
        } catch (IllegalStateException e) {
            cancelTimer();
        }
    
private native booleantoggleBacklight0(int displayId)
Toggles backlight.

param
displayId The display ID associated with the caller Display
return
true if backlight control is supported, false otherwise