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

📄 customitem.java

📁 用于移动设备上的java虚拟机源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
    /**     * Get the preferred height of this Item, including the preferred     * content height and room for the label. This is the callback     * for Item's public getPreferredHeight() method.     *     * @param w the width to base the height size on     * @return the preferred height     */    int callPreferredHeight(int w) {        try {            synchronized (Display.calloutLock) {                return this.getPrefContentHeight(w) + getLabelHeight(w);            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }        return -1;    }    /**     * Get the minimum width of this Item, including the minimum     * content width and room for the label. This is the callback     * for Item's public getMinimumWidth() method.     *     * @return the minimum width     */    int callMinimumWidth() {        try {            synchronized (Display.calloutLock) {                return this.getMinContentWidth();            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }        return -1;    }    /**     * Get the minimum height of this Item, including the minimum     * content height and room for the label. This is the callback     * for Item's public getMinimumHeight() method.     *     * @return the minimum height     */    int callMinimumHeight() {        try {            synchronized (Display.calloutLock) {                return this.getMinContentHeight() + getLabelHeight(-1);            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }        return -1;    }    /**     * Called by the system to indicate the size available to this Item     * has changed     *     * @param w the new width of the item's content area     * @param h the new height of the item's content area     */    void callSizeChanged(int w, int h) {        labelHeight = getLabelHeight(w);        try {            synchronized (Display.calloutLock) {                this.sizeChanged(w, h - labelHeight);            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }    }    /**     * Called to paint this CustomItem     *     * @param g the <code>Graphics</code> object to be used for     * rendering the item     * @param w current width of the item in pixels     * @param h current height of the item in pixels     */    void callPaint(Graphics g, int w, int h) {        // We need to check the clip to determine if        // the label needs painting        super.paintLabel(g, w);        g.clipRect(0, labelHeight, w, h - labelHeight);        g.translate(0, labelHeight);        try {            synchronized (Display.calloutLock) {                this.paint(g, w, h - labelHeight);            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }        g.translate(0, -labelHeight);    }    /**     * Traverse this CustomItem     *     * @param dir the direction of traversal     * @param viewportWidth the width of the container's viewport     * @param viewportHeight the height of the container's viewport     * @param visRect_inout passes the visible rectangle into the method, and     * returns the updated traversal rectangle from the method     * @return true if internal traversal had occurred, false if traversal     * should proceed out     */    boolean callTraverse(int dir, int viewportWidth, int viewportHeight,                         int[] visRect_inout) {        super.callTraverse(dir, viewportWidth, viewportHeight, visRect_inout);        try {            synchronized (Display.calloutLock) {                // We shave off the label height from the overall                // item viewport                visRect_inout[HEIGHT] -= labelHeight;                boolean t = this.traverse(dir, viewportWidth,                                          viewportHeight - labelHeight,                                          visRect_inout);                // We shift the return value from the item's traverse                // by the label height to give the real location                visRect_inout[Y] += labelHeight;                return t;            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }        return false;    }    /**     * Called by the system to indicate traversal has left this Item     *     * @see #getInteractionModes     * @see #traverse     * @see #TRAVERSE_HORIZONTAL     * @see #TRAVERSE_VERTICAL     */    void callTraverseOut() {        super.callTraverseOut();        try {            synchronized (Display.calloutLock) {                this.traverseOut();            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }    }    /**     * Called by the system to signal a key press     *     * @param keyCode the key code of the key that has been pressed     * @see #getInteractionModes     */    void callKeyPressed(int keyCode) {        ItemCommandListener cl = null;	Command defaultCmd = null;        synchronized (Display.LCDUILock) {            cl = commandListener;	    defaultCmd = defaultCommand;        } // synchronized        // SYNC NOTE: The call to the listener must occur outside        // of the lock	try {	    // SYNC NOTE: We lock on calloutLock around any calls	    // into application code	    synchronized (Display.calloutLock) {		if ((cl != null)                    && (defaultCmd != null)                    && (keyCode == Display.KEYCODE_SELECT)) {		    cl.commandAction(defaultCmd, this);		} else {		  this.keyPressed(keyCode);		}	    }	} catch (Throwable thr) {	    Display.handleThrowable(thr);	}    }    /**     * Called by the system to signal a key release     *     * @param keyCode the key code of the key that has been released     * @see #getInteractionModes     */    void callKeyReleased(int keyCode) {        try {            synchronized (Display.calloutLock) {                this.keyReleased(keyCode);            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }    }    /**     * Called by the system to signal a key repeat     *     * @param keyCode the key code of the key that has been repeated     * @see #getInteractionModes     */    void callKeyRepeated(int keyCode) {        try {            synchronized (Display.calloutLock) {                this.keyRepeated(keyCode);            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }    }    /**     * Called by the system to signal a pointer press     *     * @param x the x coordinate of the pointer down     * @param y the y coordinate of the pointer down     *     * @see #getInteractionModes     */    void callPointerPressed(int x, int y) {        try {            synchronized (Display.calloutLock) {                this.pointerPressed(x, y - labelHeight);            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }    }    /**     * Called by the system to signal a pointer release     *     * @param x the x coordinate of the pointer up     * @param y the x coordinate of the pointer up     *     * @see #getInteractionModes     */    void callPointerReleased(int x, int y) {        try {            synchronized (Display.calloutLock) {                this.pointerReleased(x, y - labelHeight);            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }    }    /**     * Called by the system to signal a pointer drag     *     * @param x the x coordinate of the pointer drag     * @param y the x coordinate of the pointer drag     *     * @see #getInteractionModes     */    void callPointerDragged(int x, int y) {        try {            synchronized (Display.calloutLock) {                this.pointerDragged(x, y - labelHeight);            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }    }    /**     * Called by the system to notify this Item it is being shown     *     * <p>The default implementation of this method does nothing.</p>     */    void callShowNotify() {        super.callShowNotify();        try {            synchronized (Display.calloutLock) {                this.showNotify();            }        } catch (Throwable thr) {            Display.handleThrowable(thr);        }    }    /**     * Called by the system to notify this Item it is being hidden     *     * <p>The default implementation of this me

⌨️ 快捷键说明

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