displayablelfimpl.java

来自「This is a resource based on j2me embedde」· Java 代码 · 共 1,140 行 · 第 1/3 页

JAVA
1,140
字号
    /**     * Get the current vertical scroll proportion.     *     * @return ing The vertical scroll proportion on a scale of 0-100     */    public int getVerticalScrollProportion() {        // SYNC NOTE: return of atomic value        return 100;    }    /**     * Remove this <code>Displayable</code> from physical screen.     * This function calls lCallHide after holding LCDUILock     * and sets this DisplayableLF to HIDDEN state.     */    public void uCallHide() {        synchronized (Display.LCDUILock) {            // Delete native resources and update ticker            lCallHide();            // set state            state = HIDDEN;        }    }    /**     * Some "system modal dialog" takes over physical screen      * buffer and user input now or foreground is lost.     * This function calls lCallHide after holding LCDUILock     * and sets this DisplayableLF to FROZEN state.     */    public void uCallFreeze() {        synchronized (Display.LCDUILock) {            // Delete native resources and update ticker            lCallHide();            // set state            state = FROZEN;        }    }    /**     * Remove this <code>Displayable</code> from physical screen.     * The <code>Displayable</code> should unload any resource that      * was allocated. It is not required to clean the physical screen      * before this function returns.     */    void lCallHide() {        if (state == SHOWN) {            updateNativeTicker(owner.ticker, null);        }        // Delete native resources        deleteNativeResource();            }    /**     * Called by the event handler to perform an invalidation of this      * <code>Displayable</code>.     * Subclass should override to perform re-layout.     * Default implementation does nothing.     */    public void uCallInvalidate() {        synchronized (Display.LCDUILock) {            pendingInvalidate = false;        }    }    /**     * This method is used in repaint, in order to determine the translation     * of the draw coordinates.     *     * @return <code>true</code>, if the scroll responsibility is on      *          the native platform.     *         <code>false</code>, if the scroll is done at Java level.     */    public boolean uIsScrollNative() {        // only native form overrides this and returns true        return false;    }        // ************************************************************    //  package private methods    // ************************************************************    /**     * Create native resource.     * Instance variable {@link #nativeId nativeId} must be set     * to the id of the new resource.     */    abstract void createNativeResource();    /**     * Delete native resource.     * Instance variable {@link #nativeId nativeId} is reset     * to {@link #INVALID_NATIVE_ID INVALID_NATIVE_ID}.     */    void deleteNativeResource() {        if (nativeId != INVALID_NATIVE_ID) {            deleteNativeResource0(nativeId);            nativeId = INVALID_NATIVE_ID;        }    }    /**     * Package private equivalent of sizeChanged().     *     * @param w the new width     * @param h the new height     *     */    public void uCallSizeChanged(int w, int h) {        boolean copyDefferedSizeChange;        synchronized (Display.LCDUILock) {            if (owner instanceof GameCanvas) {                GameCanvasLFImpl gameCanvasLF =                    GameMap.getGameCanvasImpl((GameCanvas)owner);                if (gameCanvasLF != null) {                    gameCanvasLF.lCallSizeChanged(w, h);                }            }            // If there is no Display, or if this Displayable is not            // currently visible, we simply record the fact that the            // size has changed            defferedSizeChange = (state != SHOWN);            copyDefferedSizeChange = defferedSizeChange;            /*             * sizeChangeOccurred is a boolean which (when true) indicates             * that sizeChanged() will be called at a later time. So, if it             * is false after calling super(), we go ahead and notify the             * Canvas now, rather than later             */            width = w;            height = h;            if (!defferedSizeChange) {                lRequestInvalidate();            }        }        if (!copyDefferedSizeChange) {            synchronized (Display.calloutLock) {                try {                    owner.sizeChanged(w, h);                } catch (Throwable t) {                    Display.handleThrowable(t);                }            }        }    }    /**     * This method notify displayable to scroll its content      *     * @param scrollType scrollType     * @param thumbPosition     */    public void uCallScrollContent(int scrollType, int thumbPosition) {        // by default nothing to do     }    /**     * <code>Display</code> calls this method on it's current      * <code>Displayable</code>.     * <code>Displayable</code> uses this opportunity to do necessary stuff     * on the graphics context, this includes, paint Ticker, paint Title      * and translate as necessary.     *     * <p>The target Object of this repaint may be some Object     * initially set by this <code>Displayable</code> when the repaint was     * requested - allowing this <code>Displayable</code> to know exactly     * which Object it needs to call to service this repaint,     * rather than potentially querying all of its Objects to     * determine the one(s) which need painting.     *     * SYNC NOTE: The caller of this method handles synchronization.     *     * @param g the graphics context to paint into.     * @param target the target Object of this repaint     */    public void uCallPaint(Graphics g, Object target) {        // Made obsolete by dsShow, where native title is shown already    }        /**     * Handle a raw key event from <code>Display</code>.     *     * @param type type of event, defined in <code>EventConstants</code>     * @param keyCode code of the key event     */    public void uCallKeyEvent(int type, int keyCode) {        int eventType = -1;        synchronized (Display.LCDUILock) {            switch (type) {                case EventConstants.PRESSED:                    sawKeyPress = true;                    eventType = 0;                    break;                case EventConstants.RELEASED:                    if (sawKeyPress) {                        eventType = 1;                    }                    break;                case EventConstants.REPEATED:                    if (sawKeyPress) {                        eventType = 2;                    }                    break;            }            // used later by getKeyMask()            if (currentKeyMask > -1 && eventType != -1) {                if (eventType == 1) {                    releaseKeyMask(keyCode);                } else {                    // set the mask on key press, repeat or type.                    // don't set the mask when a key was released.                    setKeyMask(keyCode);                }            }        } // synchronized        // SYNC NOTE: Since we may call into application code,        // we do so outside of LCDUILock        switch (eventType) {        case -1:            return;        case 0:            uCallKeyPressed(keyCode);            break;        case 1:            uCallKeyReleased(keyCode);            break;        case 2:            uCallKeyRepeated(keyCode);            break;        default:            /*             * TBD:             *             * Originally severity level was "ERROR".              * But it was reduced to INFO because              * a). it do not harm to the system             * b). some cases,              *     Displayable processes KEY_PRESS events             *     (when in system menu) & cleans all related status flag,              *     while following KEY_REPEAT & KEY_RELEASE event pairs             *     are not processed in the same way and therefore             *     this eror messae was printed or them.             *             * As a temporary solution it was decided to disable messages              * insead of additional event filtering.             */            if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {                Logging.report(Logging.INFORMATION, LogChannels.LC_HIGHUI,                               "DisplayableLFImpl: uCallKeyEvent," +                               "type=" +type+ " keyCode=" +keyCode);            }            break;        }    } // end of dsKeyEvent()    /**     * Set status of screen rotation     * @param newStatus     * @return     */    public boolean uSetRotatedStatus(boolean newStatus) {        synchronized (Display.LCDUILock) {            if (newStatus == owner.isRotated) {                return false;            } else {                owner.isRotated = newStatus;                return true;            }        }    }    /**     * Handle a key press.     *     * @param keyCode The key that was pressed     */    void uCallKeyPressed(int keyCode) { }    /**     * Handle a repeated key press.     *     * @param keyCode The key that was pressed     */    void uCallKeyRepeated(int keyCode) { }    /**     * Handle a key release.     *     * @param keyCode The key that was released     */    void uCallKeyReleased(int keyCode) { }    /**     * Called from the event delivery loop when a pointer event is seen.     *     * @param type kind of pointer event     * @param x x-coordinate of pointer event     * @param y y-coordinate of pointer event     */    public void uCallPointerEvent(int type, int x, int y) {        int eventType = -1;        synchronized (Display.LCDUILock) {            switch (type) {                case EventConstants.PRESSED:                    sawPointerPress = true;                    eventType = 0;                    break;                case EventConstants.RELEASED:                    if (sawPointerPress) {                        eventType = 1;                    }                    break;                case EventConstants.DRAGGED:                    if (sawPointerPress) {                        eventType = 2;                     }                    break;            }        } // synchronized        // SYNC NOTE: Since we may call into application code,        // we do so outside of LCDUILock        switch (eventType) {        case -1:            return;        case 0:            uCallPointerPressed(x, y);            break;        case 1:            uCallPointerReleased(x, y);            break;        case 2:            uCallPointerDragged(x, y);            break;        default:            // this is an error            break;        }    } // uCallPointerEvent()    /**     * Handle a pointer press event.     *     * @param x The x coordinate of the press     * @param y The y coordinate of the press     */    void uCallPointerPressed(int x, int y) { }    /**     * Handle a pointer drag event.     *     * @param x The x coordinate of the drag     * @param y The y coordinate of the drag     */    void uCallPointerDragged(int x, int y) { }    /**     * Handle a pointer release event.     *     * @param x The x coordinate of the release     * @param y The y coordinate of the release     */    void uCallPointerReleased(int x, int y) { }            /**     * Called to commit any pending user interaction for the current item.     */    public void lCommitPendingInteraction() { }

⌨️ 快捷键说明

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