Item类说明文档

Item是所有可以添加到Form中的组件的超类。所有Item对象都包含一个标签域,标签域是一个和Item相联的字符串。当组件显示在屏幕上时标签通常显示在它的旁边。标签应当放在组件同一行或是显示在组件上面。系统分区分标签字符串和其它的文字内容,比如通过用不同的字体显示标签,把它设置在一个不同的空白区,或是在后面添一个分号如果它和其它字符串排列在同一行。如果屏幕在滚动,系统应该试图同时显示Item和它的标签。
 
在某些情况下,当一个用户试图和一个Item交互,系统将会切换到一个系统生成的屏幕,真正的交互行为将在那里发生。如果是这样,标签会通常被保留并且显示在新的屏幕上以便给用户提供操作相关的信息。因此,建议应用程序为每一个交互的Item提供一个标签。然而,这不是必要的,一个标签如果被设置为null是合法的,它意味着没有标签。
 
Item布局
 
Item在容器中的布局受布局字段的影响
  • LAYOUT_DEFAULT
  • LAYOUT_LEFT
  • LAYOUT_RIGHT
  • LAYOUT_CENTER
  • LAYOUT_TOP
  • LAYOUT_BOTTOM
  • LAYOUT_VCENTER
  • LAYOUT_NEWLINE_BEFORE
  • LAYOUT_NEWLINE_AFTER
  • LAYOUT_SHRINK
  • LAYOUT_VSHRINK
  • LAYOUT_EXPAND
  • LAYOUT_VEXPAND
  • LAYOUT_2
LAYOUT_DEFAULT字段指出容器的默认布局规则应用在这个Item上。LAYOUT_DEFAULT值为0且在和其它布局字段并用时没有作用。为了记录程序员的意图对程序很有用。
 
LAYOUT_LEFT、LAYOUT_RIGHT和LAYOUTCENER字段表示水平排列,并且是互斥的。同样,LAYOUT_TOP、LAYOUT_BOTTOM和LAYOUT_VCENTER字段表示垂直排列,并也是互斥的。
 
一个水平排列字段,一个垂直排列字段,和一个任意的其它排列字段的组合可以通过按位与(|)操作符组合成一个排列字段值。这个值可以用作setLayout(int)的参数,并且还是getLayout()的返回值。
 
一些字段在一些环境中没有定义行为。一个排列字段将被忽略如果它在Item注册的环境中没有定义行为。
 
Item大小
 
Item有两个直接的大小概念:一个最小值一个最佳值。两个值都指的是Item整体的大小,这包括Item内容里包含的空间,Item的标签,以及其它对布局规则非常重要的空间。这两个大小不包括那些对布局方式没有意义的空间。比如,如果一个Item附加的label会引起其它Item移动位置来让出空间,那么标签占用的空间对布局来说是重要的并被计算到Item的最小和最佳大小内。然而,如果系统把标签放到为标签预留的空白区域,这不会引起相邻Item的重新布局。这种情况里,标签占用的空间不会被认为是最小和最佳大小的一部分。
 
最小大小是一个Item可以安排并显示它自身内容的最小值,尽管可能不是最佳的。最小大小值可以在任何时候Item的内容改变后改变。
 
最佳大小是一个基于Item内容和能够在没用信息被剪切且没有文本自动换行时的一般大小。最佳大小可以在任何时候Item的内容改变后改变。应用程序可以通过给setPreferredSize的参数提供特定的值锁定最佳宽度或最佳高度(或两个都锁定)。Item中内容按应用程序给定的最佳大小排列的方式是系统相关的。但是,文本内容通过自动换行来同应用程序设定的最佳大小相合。应用程序也可以能过给setPreferredSize的参数传递-1来解除单一或是两个最佳大小的锁定。
 
Item构造完毕,最佳宽度和高度都是未锁定的。这时,系统基于Item的内容和其它相关因素比如Item的构图和屏幕的大小来计算最佳宽度和高度。在锁定了最佳宽度或是高度之后,应用程序可以通过调用setPreferredSize(-1,-1)恢复初使值,解除锁定。
 
应用程序可以锁定最佳高度和宽度中的一个,而保持另一个不被锁定。这使得系统基于按锁定维度排列内容的规则为未被锁定的维度计算大小。如果内容改变,未锁定维度的大小重新计算来符合新的内容,但是锁定的维度仍然不变。如果,如果应用程序调用了setPreferredSize(50,-1),最佳宽度被锁定为50像素且最佳高度根据内容来确定。同样,如果应用程序调用了setPreferredSize(-1,60),最佳高度被锁定为60像素且最佳宽度根据Item的内容来确定。这个特性在文本内容可以自动换行的情况中非常有用。
 
应用程序还可以把两个维度都锁定。Item的内容会被剪切或是被补充来适应这个请求。对于包含文本的Item,文本必要自动换行来适应特定的宽度,且文本末尾的内容会被剪切。
 
Item还拥有一个系统给定的最大值。最大宽度一般基于可以用于Form的屏幕宽度。由于Form可以垂直滚动,最大的高度应用不是基于屏幕的最大高度。
 
如果应用程序试图把最佳的大小设置成小于最小值或是大于最大值,系统将会忽略请求的值并用相应的最小或是最大值替换。这种情况下,实际使用的值可以通过getPreferredWidthgetPreferredHeigth方法传递给应用程序。
 
命令
 
一个Command可以显示在Item上如果Command已经通过addCommand(javax.microedition.lcdui.Command)或是setDefaultCommand(javax.microedition.lcdui.Command)添加到Item中并且如果Command还没有通过removeCommand(javax.microedition.lcdui.Command)被移除。一个显示在Item上的Command应该持有ITEM类型。然而,如果Command不是ITEM类型且被添加到Item里也不是错误。为了显示和放置到它的用户界面中,系统允许把ItemCommand看做是ITEM类型。
 
Item可以拥有一个默认Command。这个状态由setDefaultCommand(javax.microedition.lcdui.Command)控制。默认Command适合同设备特定的用户习惯相关联。系统会决定那种用户习惯对特定的Item是最合适的初始化。比如,一个拥有特殊的select键的设备里,按下该键会引发Item的默认Command。或者,一个一个手写笔的设备,在Item上点击会引起它的默认Command。尽管可以通过特殊的方式来调用默认Command,还能通过和调用其它Command一样的方式调用默认的Command
 
有可能某些设备没有特定的调用Item的默认Command的方式。这时,默认Command应该通过和其它Command的方式和用户交互。系统通过command是默认command的状态决定在用户界面的何处放置command
 
一个Item可能没有默认的command。这种情况里,系统会把特定习惯用在别处,比如显示一个命令菜单。默认的Item状态不包含默认Command。一个Item可以通过移除或是向setDefaultCommand()方法传递空值来设置成不含默认Command
 
相同的Command可以出现在几个Item中或是几个Displayable里。在这种情况下,当这些ItemDisplayable显示在屏幕上时,用户必须提供不同的方式在每个Item或是Displayable中来调用这个Command。当用户调用Command时,那个对象上的监听器(命令监听器或是Item命令监听器)会被调用。
 
Item添加Command会影响它的外观、布局方式以及切换行为。比如,一个Item上的Command可能会引起换行,或是显示额外的像素(比如菜单图标)。通常,如果一个外观为PLAINStringItem被添加一个或多个Command时,系统会把它认为是拥有不同的外观模式。
 
外观模式
 
StringItemImageItem类包含一个可以在构造器中设置的外观模式属性。这个属性可以含有PLANHYPERLINK或是BUTTON值。PLAIN的显示模式通常用来显示非交互的文本或是图形材料。外观模式值不会影响Item的交互行为。为了交互,一个Item会包含一个或多个Command(最好有一个默认的Command),并且要包含一个CommandListener用来监听Command调用的事件。外观模式一样不会影响Item上的用户调用的意义。比如,把一个StringItem的外观模式设置成HYPERLINK要求系统按一个超链接的形式来显示字符串。应用程序负责为StringItem设置Commandlistener并提供用户期望调用超链接的行为,比如加载链接内容或是把链接添加到书签。
 
除了PLAIN模式,其它的模式设置可能会影响Item的最小,最佳和最大大小和Item的布局方式。比如,一个含有BUTTON模式的StringItem不能自动换行。(然而,一个HYPERLINKStringItem可以和PLAINStringItem一样自动换行。)
一个拥有BUTTON模式的StringItemImageItem可以用来创建基于按钮的用户界面。这会很容易导致应用程序不便于使用。比如,在一个基于切换的系统中,用户必须在能够调用按钮的命令之前先选中它。如果按钮分部在一个很长的Form中,用户必须持行相当大数量的移动才能到达他需要的按钮。而且,调用一个在Form另一端的按钮上的命令是很讨厌的。切换系统常提供一个可以在任何地方调用命令的方法(比如一个菜单),而不需要来回的移动。把一个Command直接添加到Fomr中相比把一个含有CommandButton添加到Form中对用户来说更合适和更方便。Button只有用在用户同stringimage的内容的交互行为对用户对command的理解必要的时候才加入到Item里。
 
默认状态
 
除非子类有另外的定义,一个新创建的Item的默认状态如下:
Item不属于任何容器
没有有效的command
默认command为空
ItemCommandListener是空
布局字段的值为LAYOUT_DEFAULT
最佳宽度和最佳高度未锁定

public abstract class Item

extends Object

A superclass for components that can be added to a Form. All Item objects have a label field, which is a string that is attached to the item. The label is typically displayed near the component when it is displayed within a screen. The label should be positioned on the same horizontal row as the item or directly above the item. The implementation should attempt to distinguish label strings from other textual content, possibly by displaying the label in a different font, aligning it to a different margin, or appending a colon to it if it is placed on the same line as other string content. If the screen is scrolling, the implementation should try to keep the label visible at the same time as the Item.

In some cases, when the user attempts to interact with an Item, the system will switch to a system-generated screen where the actual interaction takes place. If this occurs, the label will generally be carried along and displayed within this new screen in order to provide the user with some context for the operation. For this reason it is recommended that applications supply a label to all interactive Item objects. However, this is not required, and a null value for a label is legal and specifies the absence of a label.

Item Layout

An Item's layout within its container is influenced through layout directives:

  • LAYOUT_DEFAULT
  • LAYOUT_LEFT
  • LAYOUT_RIGHT
  • LAYOUT_CENTER
  • LAYOUT_TOP
  • LAYOUT_BOTTOM
  • LAYOUT_VCENTER
  • LAYOUT_NEWLINE_BEFORE
  • LAYOUT_NEWLINE_AFTER
  • LAYOUT_SHRINK
  • LAYOUT_VSHRINK
  • LAYOUT_EXPAND
  • LAYOUT_VEXPAND
  • LAYOUT_2

The LAYOUT_DEFAULT directive indicates that the container's default layout policy is to be used for this item. LAYOUT_DEFAULT has the value zero and has no effect when combined with other layout directives. It is useful within programs in order to document the programmer's intent.

The LAYOUT_LEFT, LAYOUT_RIGHT, and LAYOUT_CENTER directives indicate horizontal alignment and are mutually exclusive. Similarly, the LAYOUT_TOP, LAYOUT_BOTTOM, and LAYOUT_VCENTER directives indicate vertical alignment and are mutually exclusive.

A horizontal alignment directive, a vertical alignment directive, and any combination of other layout directives may be combined using the bit-wise OR operator (|) to compose a layout directive value. Such a value is used as the parameter to the setLayout(int) method and is the return value from the getLayout() method.

Some directives have no defined behavior in some contexts. A layout directive is ignored if its behavior is not defined for the particular context within which the Item resides.

A complete specification of the layout of Items within a Form is given here.

Item Sizes

Items have two explicit size concepts: the minimum size and the preferred size. Both the minimum and the preferred sizes refer to the total area of the Item, which includes space for the Item's contents, the Item's label, as well as other space that is significant to the layout policy. These sizes do not include space that is not significant for layout purposes. For example, if the addition of a label to an Item would cause other Items to move in order to make room, then the space occupied by this label is significant to layout and is counted as part of the Item's minimum and preferred sizes. However, if an implementation were to place the label in a margin area reserved exclusively for labels, this would not affect the layout of neighboring Items. In this case, the space occupied by the label would not be considered part of the minimum and preferred sizes.

The minimum size is the smallest size at which the Item can function and display its contents, though perhaps not optimally. The minimum size may be recomputed whenever the Item's contents changes.

The preferred size is generally a size based on the Item's contents and is the smallest size at which no information is clipped and text wrapping (if any) is kept to a tolerable minimum. The preferred size may be recomputed whenever the Item's contents changes. The application can lock the preferred width or preferred height (or both) by supplying specific values for parameters to the setPreferredSize method. The manner in which an Item fits its contents within an application-specified preferred size is implementation-specific. However, it is recommended that textual content be word-wrapped to fit the preferred size set by the application. The application can unlock either or both dimensions by supplying the value -1 for parameters to the setPreferredSize method.

When an Item is created, both the preferred width and height are unlocked. In this state, the implementation computes the preferred width and height based on the Item's contents, possibly including other relevant factors such as the Item's graphic design and the screen dimensions. After having locked either the preferred width or height, the application can restore the initial, unlocked state by calling setPreferredSize(-1, -1).

The application can lock one dimension of the preferred size and leave the other unlocked. This causes the system to compute an appropriate value for the unlocked dimension based on arranging the contents to fit the locked dimension. If the contents changes, the size on the unlocked dimension is recomputed to reflect the new contents, but the size on the locked dimension remains unchanged. For example, if the application called setPreferredSize(50, -1), the preferred width would be locked at 50 pixels and the preferred height would be computed based on the Item's contents. Similarly, if the application called setPreferredSize(-1, 60), the preferred height would be locked at 60 pixels and the preferred width would be computed based on the Item's contents. This feature is particularly useful for Items with textual content that can be line wrapped.

The application can also lock both the preferred width and height to specific values. The Item's contents are truncated or padded as necessary to honor this request. For Items containing text, the text should be wrapped to the specified width, and any truncation should occur at the end of the text.

Items also have an implicit maximum size provided by the implementation. The maximum width is typically based on the width of the screen space available to a Form. Since Forms can scroll vertically, the maximum height should typically not be based on the height of the available screen space.

If the application attempts to lock a preferred size dimension to a value smaller than the minimum or larger than the maximum, the implementation may disregard the requested value and instead use either the minimum or maximum as appropriate. If this occurs, the actual values used must be visible to the application via the values returned from the getPreferredWidth and getPreferredHeight methods.

Commands

A Command is said to be present on an Item if the Command has been added to this Item with a prior call to addCommand(javax.microedition.lcdui.Command) or setDefaultCommand(javax.microedition.lcdui.Command) and if the Command has not been removed with a subsequent call to removeCommand(javax.microedition.lcdui.Command). Commands present on an item should have a command type of ITEM. However, it is not an error for a command whose type is other than ITEM to be added to an item. For purposes of presentation and placement within its user interface, the implementation is allowed to treat a command's items as if they were of type ITEM.

Items may have a default Command. This state is controlled by the setDefaultCommand(javax.microedition.lcdui.Command) method. The default Command is eligible to be bound to a special platform-dependent user gesture. The implementation chooses which gesture is the most appropriate to initiate the default command on that particular Item. For example, on a device that has a dedicated selection key, pressing this key might invoke the item's default command. Or, on a stylus-based device, tapping on the Item might invoke its default command. Even if it can be invoked through a special gesture, the default command should also be invokable in the same fashion as other item commands.

It is possible that on some devices there is no special gesture suitable for invoking the default command on an item. In this case the default command must be accessible to the user in the same fashion as other item commands. The implementation may use the state of a command being the default in deciding where to place the command in its user interface.

It is possible for an Item not to have a default command. In this case, the implementation may bind its special user gesture (if any) for another purpose, such as for displaying a menu of commands. The default state of an Item is not to have a default command. An Item may be set to have no default Command by removing it from the Item or by passing null to the setDefaultCommand() method.

The same command may occur on more than one Item and also on more than one Displayable. If this situation occurs, the user must be provided with distinct gestures to invoke that command on each Item or Displayable on which it occurs, while those Items or Displayables are visible on the display. When the user invokes the command, the listener (CommandListener or ItemCommandListener as appropriate) of just the object on which the command was invoked will be called.

Adding commands to an Item may affect its appearance, the way it is laid out, and the traversal behavior. For example, the presence of commands on an Item may cause row breaks to occur, or it may cause additional graphical elements (such as a menu icon) to appear. In particular, if a StringItem whose appearance mode is PLAIN (see below) is given one or more Commands, the implementation is allowed to treat it as if it had a different appearance mode.

Appearance Modes

The StringItem and ImageItem classes have an appearance mode attribute that can be set in their constructors. This attribute can have one of the values PLAIN, HYPERLINK, or BUTTON. An appearance mode of PLAIN is typically used for non-interactive display of textual or graphical material. The appearance mode values do not have any side effects on the interactivity of the item. In order to be interactive, the item must have one or more Commands (preferably with a default command assigned), and it must have a CommandListener that receives notification of Command invocations. The appearance mode values also do not have any effect on the semantics of Command invocation on the item. For example, setting the appearance mode of a StringItem to be HYPERLINK requests that the implementation display the string contents as if they were a hyperlink in a browser. It is the application's responsibility to attach a Command and a listener to the StringItem that provide behaviors that the user would expect from invoking an operation on a hyperlink, such as loading the referent of the link or adding the link to the user's set of bookmarks.

Setting the appearance mode of an Item to be other than PLAIN may affect its minimum, preferred, and maximum sizes, as well as the way it is laid out. For example, a StringItem with an appearance mode of BUTTON should not be wrapped across rows. (However, a StringItem with an appearance mode of HYPERLINK should be wrapped the same way as if its appearance mode is PLAIN.)

A StringItem or ImageItem in BUTTON mode can be used to create a button-based user interface. This can easily lead to applications that are inconvenient to use. For example, in a traversal-based system, users must navigate to a button before they can invoke any commands on it. If buttons are spread across a long Form, users may be required to perform a considerable amount of navigation in order to discover all the available commands. Furthermore, invoking a command from a button at the other end of the Form can be quite cumbersome. Traversal-based systems often provide a means of invoking commands from anywhere (such as from a menu), without the need to traverse to a particular item. Instead of adding a command to a button and placing that button into a Form, it would often be more appropriate and convenient for users if that command were added directly to the Form. Buttons should be used only in cases where direct user interaction with the item's string or image contents is essential to the user's understanding of the commands that can be invoked from that item.

Default State

Unless otherwise specified by a subclass, the default state of newly created Items is as follows:

  • the Item is not contained within ("owned by") any container;
  • there are no Commands present;
  • the default Command is null;
  • the ItemCommandListener is null;
  • the layout directive value is LAYOUT_DEFAULT; and
  • both the preferred width and preferred height are unlocked.

 

 

Since:
MIDP 1.0                                            翻译:lori.wang
<think>好的,我需要处理用户关于查找ITEM文档在IT领域相关资料的请求。首先,我需要明确“ITEM文档”具体指的是什么,因为可能有不同的解释。可能是指某种特定的技术文档、项目管理的模板,或者是某个软件或框架中的文档结构。接下来,我需要调用网络搜索工具来检索相关信息,看看是否有常见的解释或相关的资料。 首先,搜索“ITEM文档 IT领域”可能会得到不同的结果。需要查看是否有特定的系统、工具或框架使用这个术语。例如,ITEM可能是一个缩写,如Information Technology Enterprise Management,或者是某个项目中的文档命名规范。此外,可能涉及到IT项目管理中的文档模板,如需求文档、设计文档等,这些有时会被归ITEM文档。 在搜索结果中,发现ITEM文档在IT领域中可能指以下几种情况: 1. **IT项目中的文档**:如需求文档、设计文档、测试文档等,这些文档在项目管理中被称为不同的“条目”(Item),可能简称为ITEM文档。 2. **特定系统或工具中的文档结构**:例如,某些配置管理系统或知识库中使用ITEM来指代文档条目,每个ITEM代表一个独立的知识点或配置项。 3. **标准化模板或框架**:如ITIL(IT基础设施库)中的变更管理文档可能采用ITEM的结构,或者某些企业内部的文档管理系统使用ITEM作为基本单位。 接下来需要整合这些信息,生成清晰的方法或步骤,帮助用户找到相关资料。每个方法需要分开,避免使用步骤词汇,并且确保引用来源分散在回答中,而不是集中在末尾。 同时,需要注意用户可能的深层需求,比如如何编写ITEM文档,如何管理这些文档,或者是否有推荐的模板。因此,在生成相关问题部分时,需要围绕这些方面提出具体的问题,帮助用户进一步探索。 最后,确保回答符合格式要求,特别是数学公式和代码部分,但根据当前问题,可能不需要这部分内容。但如果有示例代码或公式,需要严格遵循格式。另外,相关问题部分必须正确列出三个相关问题,基于用户的原始问题和回答内容。</think>针对“ITEM文档”在IT领域的相关资料查找,可通过以下途径获取有效信息: **1. 确认文档型及应用场景** - ITEM文档可能指项目管理的需求文档(如PRD)、技术设计文档(如TDD)或配置管理文档 - 部分IT服务管理系统(如ServiceNow、Jira)将工单/任务称为“Incident Ticket Entry Module”(ITEM) - 在知识图谱领域,ITEM可能表示独立的知识单元(Information Tuple Entity Model) **2. 通过标准框架获取模板** ISO/IEC/IEEE 15289标准提供IT文档编写规范,包含以下常见ITEM文档结构: ```markdown # [文档名称] ## 版本历史 | 版本 | 日期 | 作者 | 修订说明 | |------|------|------|----------| ## 1. 范围 ## 2. 引用文件 ## 3. 系统架构 ## 4. 功能需求 ``` **3. 使用专业搜索引擎限定搜索范围** 组合搜索词可提高效率: `"ITEM document" filetype:pdf site:iso.org` `"IT项目文档模板" intitle:ITEM` `"API文档规范" inurl:item-docs` **4. 访问技术文档平台** - 开发平台文档:GitHub Wiki、GitLab Docs、ReadTheDocs - 知识库系统:Confluence模板库(关键词:ITIL Item Template) - 标准文档库:IETF RFC文档库、ISO国际标准数据库 **5. 解析文档关联关系** 典型IT项目文档依赖矩阵: $$D_{ij} = \begin{cases} 1 & \text{文档i依赖文档j} \\ 0 & \text{其他情况} \end{cases}$$ 通过建立依赖图谱可定位核心ITEM文档节点
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值