FileDocCategorySizeDatePackage
AlertLayer.javaAPI DocphoneME MR2 API (J2ME)4938Wed May 02 18:00:20 BST 2007com.sun.midp.chameleon.layers

AlertLayer

public class AlertLayer extends BodyLayer
AlertLayer

Fields Summary
private Alert
alert
The Alert instance which content is currently visible
Constructors Summary
public AlertLayer(com.sun.midp.chameleon.ChamDisplayTunnel tunnel)
The AlertLayer constructor. Initializes background image if there is one set in AlertSkin.

param
tunnel - The ChamDisplayTunnel to do paint calls

        super(AlertSkin.IMAGE_BG, AlertSkin.COLOR_BG, tunnel);
        setVisible(false);
    
Methods Summary
protected voidinitialize()
Initialize the bounds of this AlertLayer. Overrides initialize in superclasses. The dimensions of the specific AlertLayer are specified in AlertSkin. The X and Y coordinates represent the upper left position of this CLayer in the physical display's coordinate space.

        super.initialize();
        setAnchor();
    
public voidsetAlert(boolean alertVisible, Alert alert, int height)
Sets content to be displayed in the Alert Layer. This AlertLayer will be made visible if alertVisible is true and will be hidden - otherwise.

param
alertVisible - true if the AlertLayer should be shown, and false - otherwise
param
alert - The Alert instance that is currently visible
param
height the preferred height for the Alert. This is accepted as long as it is less than AlertSkin.HEIGHT

        this.alert = alert;
        setDirty();
        setVisible(alertVisible);
    
public voidsetAnchor()
Align alert depend on skin


        bounds[W] = AlertSkin.WIDTH;
        bounds[H] = AlertSkin.HEIGHT;
        
        switch (AlertSkin.ALIGN_X) {
            case Graphics.LEFT:
                bounds[X] = 0;
                break;
            case Graphics.RIGHT:
                bounds[X] = ScreenSkin.WIDTH - bounds[W];
                break;
            case Graphics.HCENTER:
            default:
                bounds[X] = (ScreenSkin.WIDTH - bounds[W]) / 2;
                break;
        }
        switch (AlertSkin.ALIGN_Y) {
            case Graphics.TOP:
                bounds[Y] = 0;
                break;
            case Graphics.VCENTER:
                bounds[Y] = (ScreenSkin.HEIGHT - SoftButtonSkin.HEIGHT -
                    bounds[H]) / 2;
                if (alert != null && alert.getTicker() != null) {
                    bounds[Y] -= TickerSkin.HEIGHT;
                }
                break;
            case Graphics.BOTTOM:
            default:
                bounds[Y] = ScreenSkin.HEIGHT - SoftButtonSkin.HEIGHT -
                    bounds[H];
                if (alert != null && alert.getTicker() != null) {
                    bounds[Y] -= TickerSkin.HEIGHT;
                }
                break;
        }
    
public voidsetVisible(boolean visible)
Toggle the visibility state of Alert layer within its containing window.

param
visible if alert should be visible, false otherwise

        super.setVisible(visible);
        setSupportsInput(visible);
    
public voidupdate(com.sun.midp.chameleon.CLayer[] layers)
Update bounds of layer

param
layers - current layer can be dependant on this parameter

        setAnchor();
        if (visible) {
            addDirtyRegion();
        }
        if (scrollInd != null) {
            scrollInd.update(layers);
            if (scrollInd.isVisible()) {
                bounds[W] -= scrollInd.bounds[W];
            }
        }