⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 display.java

📁 用于移动设备上的java虚拟机源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * ************* package private member variables */    /** Static lock object for LCDUI package */    static final Object LCDUILock = new Object();    /** Static lock object for making calls into application code */    static final Object calloutLock = new Object();    /** horizontal width */    static final int WIDTH;    /** vertical height */    static final int HEIGHT;        /** height available to draw on in normal mode */    static final int ADORNEDHEIGHT;    /** background color for erasing */    static final int ERASE_COLOR;    /** border color for non-highlighted border */    static final int BORDER_COLOR = 0x00AFAFAF; // light gray    /** border color for highlighted border */    static final int BORDER_H_COLOR = 0x00606060; // dark gray    /** pixel depth of display. */    static final int DISPLAY_DEPTH;    /** true, if display supports color. */    static final boolean DISPLAY_IS_COLOR;    /** true, if the device has a pointing device. */    static final boolean POINTER_SUPPORTED;    /** true, if motion events are supported. */    static final boolean MOTION_SUPPORTED;    /** true, if repeating events are supported. */    static final boolean REPEAT_SUPPORTED;    /** true, if the display is double buffered. */    static final boolean IS_DOUBLE_BUFFERED;    /** Standard foreground color */    static final int FG_COLOR;    /** Standard background highlight color */    static final int BG_H_COLOR;    /** Standard foreground highlight color */    static final int FG_H_COLOR;    /** number of alpha levels supported */    static final int ALPHA_LEVELS;    /** keyCode for up arrow */    static final int KEYCODE_UP;    /** keyCode for down arrow */    static final int KEYCODE_DOWN;    /** keyCode for left arrow */    static final int KEYCODE_LEFT;    /** keyCode for right arrow */    static final int KEYCODE_RIGHT;    /** keyCode for select */    static final int KEYCODE_SELECT;/* * ************* private member variables */    /** Display manager with private methods. */    private static DisplayManagerImpl displayManagerImpl;    /** Device Access manager. */    private static DisplayDeviceAccess deviceAccess;    /** event handler for this Display instance. */    private static EventHandler eventHandler;    /**  singleton Graphics object */    private static final Graphics screenGraphics;    /** display accessor helper class */    private DisplayAccessor accessor;    /** MIDlet for this display */    private MIDlet midlet;    /** current displayable instance */    private Displayable current;    /** true, if last setCurrent was non-null */    private boolean wantsForeground;    /** stores key code of the current key pressed at least once */    // caters to the GameCanvas.getKeyStats()    // latching behavior. This latched state is cleared    // when the getKeyStats() is called.    private int stickyKeyMask;      /** stores key code of the current key is currently down */    // sets the key to 1 when the key    // is currently down    private int currentKeyMask;    /** What gets the MIDlet level events. */    private MIDletEventListener midletEventListener;    /** true, if painting operations are suspended. */    private boolean paintSuspended; // = false;    /** true, if the Display is the foreground object. */    private boolean hasForeground; //  = false;    /** first queue of serialized repaint operations. */    private static java.util.Vector queue1 = new java.util.Vector();    /** second queue of serialized repaint operations. */    private static java.util.Vector queue2 = new java.util.Vector();    /** current active queue for serially repainted operations. */    private static java.util.Vector currentQueue = queue1;    /** This class has a different security domain than the MIDlet suite */    private static SecurityToken classSecurityToken;/* * ************* Static initializer, constructor */    static {        /* done this way because native access to static fields is hard */        DeviceCaps c = new DeviceCaps();        WIDTH               = c.width;        HEIGHT              = c.height;        ADORNEDHEIGHT       = c.adornedHeight;        ERASE_COLOR         = c.eraseColor;        DISPLAY_DEPTH       = c.displayDepth;        DISPLAY_IS_COLOR    = c.displayIsColor;        POINTER_SUPPORTED   = c.pointerSupported;        MOTION_SUPPORTED    = c.motionSupported;        REPEAT_SUPPORTED    = c.repeatSupported;        IS_DOUBLE_BUFFERED  = c.isDoubleBuffered;        FG_COLOR            = 0;        BG_H_COLOR          = FG_COLOR;        FG_H_COLOR          = ERASE_COLOR;        Text.FG_COLOR       = FG_COLOR;        Text.FG_H_COLOR     = FG_H_COLOR;        ALPHA_LEVELS        = c.numAlphaLevels;        KEYCODE_UP          = c.keyCodeUp;        KEYCODE_DOWN        = c.keyCodeDown;        KEYCODE_LEFT        = c.keyCodeLeft;        KEYCODE_RIGHT       = c.keyCodeRight;        KEYCODE_SELECT      = c.keyCodeSelect;        c = null; // let the DeviceCaps instance be garbage collected        /* Let com.sun.midp classes call in to this class. */        displayManagerImpl = new DisplayManagerImpl();        DisplayManagerFactory.SetDisplayManagerImpl(displayManagerImpl);        deviceAccess = new DisplayDeviceAccess();        eventHandler = getEventHandler();        screenGraphics = Graphics.getGraphics(null);    }    /**     * initializes the display with an accessor helper class.     *     * @param m MIDlet that owns this display, can be null     */    Display(MIDlet m) {        midlet = m;        accessor = new DisplayAccessor();        drawTrustedIcon(false);    }/* * ************* public methods */    /**     * Gets the <code>Display</code> object that is unique to this     * <code>MIDlet</code>.     * @param m <code>MIDlet</code> of the application     * @return the display object that application can use for its user     * interface     *     * @throws NullPointerException if <code>m</code> is <code>null</code>     */    public static Display getDisplay(MIDlet m) {        MIDletState ms;        Display d;        synchronized (LCDUILock) {            // Find or create if necessary the Display            ms = MIDletStateMap.getState(m);            if (ms != null) {                d = ms.getDisplay();                if (d != null) {                    return d;                }            }            throw new                IllegalStateException("No display created for given MIDlet");        }    }    /**     * Returns one of the colors from the high level user interface     * color scheme, in the form <code>0x00RRGGBB</code> based on the     * <code>colorSpecifier</code> passed in.     *     * @param colorSpecifier the predefined color specifier;     *  must be one of     *  {@link #COLOR_BACKGROUND},     *  {@link #COLOR_FOREGROUND},     *  {@link #COLOR_HIGHLIGHTED_BACKGROUND},     *  {@link #COLOR_HIGHLIGHTED_FOREGROUND},     *  {@link #COLOR_BORDER}, or     *  {@link #COLOR_HIGHLIGHTED_BORDER}     * @return color in the form of <code>0x00RRGGBB</code>     * @throws IllegalArgumentException if <code>colorSpecifier</code>     * is not a valid color specifier     * @since MIDP 2.0      */    public int getColor(int colorSpecifier) {        switch (colorSpecifier) {        case COLOR_BACKGROUND:            return ERASE_COLOR;        case COLOR_FOREGROUND:            return FG_COLOR;        case COLOR_HIGHLIGHTED_BACKGROUND:            return BG_H_COLOR;        case COLOR_HIGHLIGHTED_FOREGROUND:            return FG_H_COLOR;        // REMINDER: COLOR_BORDER color and        // COLOR_HIGHLIGHTED_BORDER color will        // be changed once HI input is avaiable.        case COLOR_BORDER:            return BORDER_COLOR;        case COLOR_HIGHLIGHTED_BORDER:            return BORDER_H_COLOR;        default:            throw new IllegalArgumentException();        }    }    /**     * Returns the stroke style used for border drawing     * depending on the state of the component     * (highlighted/non-highlighted). For example, on a monochrome     * system, the border around a non-highlighted item might be     * drawn with a <code>DOTTED</code> stroke style while the border around a     * highlighted item might be drawn with a <code>SOLID</code> stroke style.     *     * @param highlighted <code>true</code> if the border style being     * requested is for the     * highlighted state, <code>false</code> if the border style being     * requested is for the     * non-highlighted state     * @return {@link Graphics#DOTTED} or {@link Graphics#SOLID}     * @since MIDP 2.0      */    public int getBorderStyle(boolean highlighted) {        return (highlighted == true ? Graphics.SOLID : Graphics.DOTTED);    }    /**     * Gets information about color support of the device.     * @return <code>true</code> if the display supports color,      * <code>false</code> otherwise     */    public boolean isColor() {        return DISPLAY_IS_COLOR;    }    /**     * Gets the number of colors (if <code>isColor()</code> is     * <code>true</code>)     * or graylevels (if <code>isColor()</code> is <code>false</code>)     * that can be     * represented on the device.<P>     * Note that the number of colors for a black and white display is     * <code>2</code>.     * @return number of colors     */    public int numColors() {        return (1 << DISPLAY_DEPTH);    }    /**     * Gets the number of alpha transparency levels supported by this     * implementation.  The minimum legal return value is     * <code>2</code>, which indicates     * support for full transparency and full opacity and no blending.  Return     * values greater than <code>2</code> indicate that alpha blending     * is supported.  For     * further information, see <a href="Image.html#alpha">Alpha     * Processing</a>.     *     * @return number of alpha levels supported     * @since MIDP 2.0     */    public int numAlphaLevels() {        return ALPHA_LEVELS;    }    /**     * Gets the current <code>Displayable</code> object for this     * <code>MIDlet</code>.  The     * <code>Displayable</code> object returned may not actually be     * visible on the display     * if the <code>MIDlet</code> is running in the background, or if     * the <code>Displayable</code> is     * obscured by a system screen.  The {@link Displayable#isShown()     * Displayable.isShown()} method may be called to determine whether the     * <code>Displayable</code> is actually visible on the display.      *     * <p> The value returned by <code>getCurrent()</code> may be     * <code>null</code>. This     * occurs after the application has been initialized but before the first     * call to <code>setCurrent()</code>. </p>     *     * @return the <code>MIDlet's</code> current <code>Displayable</code> object     * @see #setCurrent     */    public Displayable getCurrent() {        return current;    }    /**     * Requests that a different <code>Displayable</code> object be     * made visible on the     * display.  The change will typically not take effect immediately.  It     * may be delayed so that it occurs between event delivery method     * calls, although it is not guaranteed to occur before the next event     * delivery method is called.  The <code>setCurrent()</code> method returns     * immediately, without waiting for the change to take place.  Because of     * this delay, a call to <code>getCurrent()</code> shortly after a

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -