displayable.java
来自「This is a resource based on j2me embedde」· Java 代码 · 共 502 行 · 第 1/2 页
JAVA
502 行
* affects the set of visible commands, the implementation should update * the display as soon as it is feasible to do so. * If <code>cmd</code> is <code>null</code>, this method * does nothing. * * @param cmd the command to be removed */ public void removeCommand(Command cmd) { synchronized (Display.LCDUILock) { int i = removeCommandImpl(cmd); if (i != -1) { displayableLF.lRemoveCommand(cmd, i); } } } /** * Sets a listener for {@link Command Commands} to this * <code>Displayable</code>, * replacing any previous <code>CommandListener</code>. A * <code>null</code> reference is * allowed and has the effect of removing any existing listener. * * @param l the new listener, or <code>null</code>. */ public void setCommandListener(CommandListener l) { synchronized (Display.LCDUILock) { listener = l; } displayableLF.updateCommandSet(); } /** * Gets the width in pixels of the displayable area available to the * application. The value returned is appropriate for the particular * <code>Displayable</code> subclass. This value may depend * on how the device uses the * display and may be affected by the presence of a title, a ticker, or * commands. * This method returns the proper result at all times, even if the * <code>Displayable</code> object has not yet been shown. * * @return width of the area available to the application */ public int getWidth() { synchronized (Display.LCDUILock) { return displayableLF.lGetWidth(); } } /** * Gets the height in pixels of the displayable area available to the * application. The value returned is appropriate for the particular * <code>Displayable</code> subclass. This value may depend * on how the device uses the * display and may be affected by the presence of a title, a ticker, or * commands. * This method returns the proper result at all times, even if the * <code>Displayable</code> object has not yet been shown. * * @return height of the area available to the application */ public int getHeight() { synchronized (Display.LCDUILock) { return displayableLF.lGetHeight(); } }// ************************************************************// protected methods// ************************************************************ /** * The implementation calls this method when the available area of the * <code>Displayable</code> has been changed. * The "available area" is the area of the display that * may be occupied by * the application's contents, such as <code>Items</code> in a * <code>Form</code> or graphics within * a <code>Canvas</code>. It does not include space occupied * by a title, a ticker, * command labels, scroll bars, system status area, etc. A size change * can occur as a result of the addition, removal, or changed contents of * any of these display features. * * <p> This method is called at least once before the * <code>Displayable</code> is shown for the first time. * If the size of a <code>Displayable</code> changes while * it is visible, * <CODE>sizeChanged</CODE> will be called. If the size of a * <code>Displayable</code> * changes while it is <em>not</em> visible, calls to * <CODE>sizeChanged</CODE> may be deferred. If the size had changed * while the <code>Displayable</code> was not visible, * <CODE>sizeChanged</CODE> will be * called at least once at the time the * <code>Displayable</code> becomes visible once * again.</p> * * <p>The default implementation of this method in <code>Displayable</code> * and its * subclasses defined in this specification must be empty. * This method is intended solely for being overridden by the * application. This method is defined on <code>Displayable</code> * even though applications are prohibited from creating * direct subclasses of <code>Displayable</code>. * It is defined here so that applications can override it in * subclasses of <code>Canvas</code> and <code>Form</code>. * This is useful for <code>Canvas</code> subclasses to tailor * their graphics and for <code>Forms</code> to modify * <code>Item</code> sizes and layout * directives in order to fit their contents within the the available * display area.</p> * * @param w the new width in pixels of the available area * @param h the new height in pixels of the available area */ protected void sizeChanged(int w, int h) { // this method is intended to be overridden by the application }// ************************************************************// package private methods// ************************************************************ /** * Gets look&feel for this Displayable object * This method is implemented in the subclasses. * @return - DisplayableLF for this Displayable object */ DisplayableLF getLF() { return displayableLF; } /** * Called to schedule a call to itemStateChanged() due to * a change in the given Item. * * @param src the Item which has changed */ void itemStateChanged(Item src) { /* * This call could happen on a Displayable that is not currently * visible (either not current, or the Display instance is not * foreground). */ Display.itemStateChanged(src); } /** * Called by the event handler to notify any ItemStateListener * of a change in the given Item. * The default implementation of this function does nothing. * * @param src The Item which has changed */ void uCallItemStateChanged(Item src) { } /** * Add a Command to this Displayable * * @param cmd The Command to add to this Displayable * @return command index */ int addCommandImpl(Command cmd) { for (int i = 0; i < numCommands; ++i) { if (commands[i] == cmd) { return -1; } } if ((commands == null) || (numCommands == commands.length)) { Command[] newCommands = new Command[numCommands + 4]; if (commands != null) { System.arraycopy(commands, 0, newCommands, 0, numCommands); } commands = newCommands; } commands[numCommands] = cmd; ++numCommands; return numCommands-1; } /** * Remove a Command from this Displayable * * @param cmd The Command to remove from this Displayable * @return command index */ int removeCommandImpl(Command cmd) { for (int i = 0; i < numCommands; ++i) { if (commands[i] == cmd) { commands[i] = commands[--numCommands]; commands[numCommands] = null; return i; } } return -1; }// ************************************************************// private methods// ************************************************************ // ************************************************************// package private member variables// ************************************************************ /** An array of Commands added to this Displayable */ Command commands[]; /** The number of Commands added to this Displayable */ int numCommands; /** The CommandListener for Commands added to this Displayable */ CommandListener listener; /** True, if this Displayable is in full screen mode */ boolean isInFullScreenMode; // = false /** True, if this Displayable is rotated */ boolean isRotated; // = false /** The title for this Displayable */ String title; /** The ticker that may be set for this Displayable */ Ticker ticker; /** The Look &s; Feel object associated with this Displayable */ DisplayableLF displayableLF;// ************************************************************// private member variables// ************************************************************// ************************************************************// Static initializer, constructor// ************************************************************} // Displayable
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?