public class AsyncBoxView extends View
当访问子视图时,在相关联的文档上获取读取锁定,以便模型在被访问时是稳定的。
| Modifier and Type | Class and Description | 
|---|---|
| class  | AsyncBoxView.ChildLocator
              在本地化区域内进行变更时,可以管理子视图在局部区域中的有效位置。 
             | 
| class  | AsyncBoxView.ChildState
              表示子视图的布局状态的记录。 
             | 
| Modifier and Type | Field and Description | 
|---|---|
| protected AsyncBoxView.ChildLocator | locator
              管理孩子偏移的对象。 
             | 
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXISBOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST| Constructor and Description | 
|---|
| AsyncBoxView(Element elem, int axis)
              构造一个执行异步布局的框视图。 
             | 
| Modifier and Type | Method and Description | 
|---|---|
| protected AsyncBoxView.ChildState | createChildState(View v)
              通过此方法创建新的ChildState记录,以允许子类将ChildState记录扩展为更多 
             | 
| protected void | flushRequirementChanges()
              将首选项向上发布到父视图。 
             | 
| float | getBottomInset()
              获取视图边缘的底部。 
             | 
| Shape | getChildAllocation(int index, Shape a)
              获取给定子视图的分配。 
             | 
| protected AsyncBoxView.ChildState | getChildState(int index)
              在给定索引处获取表示子节点布局状态的对象。 
             | 
| protected boolean | getEstimatedMajorSpan()
              目前估计是主要跨度吗? 
             | 
| protected float | getInsetSpan(int axis)
              沿着由插图占据的轴获取跨度。 
             | 
| protected LayoutQueue | getLayoutQueue()
              获取队列以用于布局。 
             | 
| float | getLeftInset()
              在视图中获取边缘的左边部分。 
             | 
| int | getMajorAxis()
              取长轴(孩子们平行的轴)。 
             | 
| float | getMaximumSpan(int axis)
              确定沿着轴的该视图的最大跨度。 
             | 
| float | getMinimumSpan(int axis)
              确定此视图沿轴的最小跨度。 
             | 
| int | getMinorAxis()
              获取短轴(垂直于平铺轴的轴)。 
             | 
| int | getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet)
              提供一种方法来确定可能放置插入符号的下一个视觉表示的模型位置。 
             | 
| float | getPreferredSpan(int axis)
              确定沿着轴的此视图的首选跨度。 
             | 
| float | getRightInset()
              在视图中获取边缘的正确部分。 
             | 
| float | getTopInset()
              获取视图边缘的顶部。 
             | 
| View | getView(int n)
              获取第n个子视图。 
             | 
| int | getViewCount()
              返回此视图中的视图数。 
             | 
| int | getViewIndex(int pos, Position.Bias b)
              返回表示模型中给定位置的子视图索引。 
             | 
| protected int | getViewIndexAtPosition(int pos, Position.Bias b)
              获取代表模型中给定位置的子视图索引。 
             | 
| protected void | loadChildren(ViewFactory f)
              加载所有的孩子以初始化视图。 
             | 
| protected void | majorRequirementChange(AsyncBoxView.ChildState cs, float delta)
              要求沿主轴变化。 
             | 
| protected void | minorRequirementChange(AsyncBoxView.ChildState cs)
              要求沿着短轴改变。 
             | 
| Shape | modelToView(int pos, Shape a, Position.Bias b)
              提供从文档模型坐标空间映射到映射到它的视图的坐标空间的映射。 
             | 
| void | paint(Graphics g, Shape alloc)
              使用给定的分配和渲染表面渲染视图。 
             | 
| void | preferenceChanged(View child, boolean width, boolean height)
              子视图可以在父项上调用,以表明偏好已更改,应重新考虑布局。 
             | 
| void | replace(int offset, int length, View[] views)
              调用超类更新子视图,并更新子节点的状态记录。 
             | 
| void | setBottomInset(float i)
              将边缘的底部部分设置在视图周围。 
             | 
| protected void | setEstimatedMajorSpan(boolean isEstimated)
              设置估计的主要属性,以确定主要跨度是否应被视为估计。 
             | 
| void | setLeftInset(float i)
              设置边缘左边的视图。 
             | 
| void | setParent(View parent)
              设置视图的父级。 
             | 
| void | setRightInset(float i)
              在视图周围设置边框的正确部分。 
             | 
| void | setSize(float width, float height)
              设置视图的大小。 
             | 
| void | setTopInset(float i)
              围绕视图设置边距的顶部。 
             | 
| protected void | updateLayout(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a)
              响应于从模型接收到更改的通知更新布局。 
             | 
| int | viewToModel(float x, float y, Shape a, Position.Bias[] biasReturn)
              提供从视图坐标空间到模型的逻辑坐标空间的映射。 
             | 
append, breakView, changedUpdate, createFragment, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getResizeWeight, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, insertUpdate, isVisible, modelToView, modelToView, remove, removeAll, removeUpdate, updateChildren, viewToModelprotected AsyncBoxView.ChildLocator locator
public AsyncBoxView(Element elem, int axis)
elem - 要表示的模型的元素 
           axis - 平铺的轴。 
            这可以是X_AXIS或Y_AXIS。 
           public int getMajorAxis()
public int getMinorAxis()
public float getTopInset()
public void setTopInset(float i)
i - 插图的值 
           public float getBottomInset()
public void setBottomInset(float i)
i - 插图的值 
           public float getLeftInset()
public void setLeftInset(float i)
i - 插图的值 
           public float getRightInset()
public void setRightInset(float i)
i - 插图的值 
           protected float getInsetSpan(int axis)
axis - 用于确定X_AXIS或Y_AXIS的总 
            axis的轴。 
           protected void setEstimatedMajorSpan(boolean isEstimated)
protected boolean getEstimatedMajorSpan()
protected AsyncBoxView.ChildState getChildState(int index)
index - 子索引。 
            这应该是一个值> = 0和<getViewCount()。 
           protected LayoutQueue getLayoutQueue()
protected AsyncBoxView.ChildState createChildState(View v)
protected void majorRequirementChange(AsyncBoxView.ChildState cs, float delta)
这是为了将主轴标记为已更改,以便将来检查以查看要求是否需要发布到父视图将会考虑主轴。 如果长轴上的跨度未被估计,则会通过给定的增量更新以反映增量变化。 如果估计大跨度,则忽略增量。
protected void minorRequirementChange(AsyncBoxView.ChildState cs)
protected void flushRequirementChanges()
public void replace(int offset,
                    int length,
                    View[] views) 
          protected void loadChildren(ViewFactory f)
setParent方法调用的。 
           子类可以重新实现,以不同的方式初始化其子视图。 
           默认实现为每个子元素创建一个子视图。 
           通常,当孩子被更改时,文档上保留一个写锁定,这保持了渲染和布局线程的安全。 例外情况是当视图被初始化以表示现有元素(通过此方法)时,因此在初始化时将同步以排除preferenceChanged。
f - 视图工厂 
           setParent(javax.swing.text.View) 
           protected int getViewIndexAtPosition(int pos,
                                     Position.Bias b) 
          pos - 位置> = 0 
           protected void updateLayout(DocumentEvent.ElementChange ec, DocumentEvent e, Shape a)
updateLayout在 
            View 
           ec - 对此视图负责的元素的更改(如果没有更改则可以为null)。 
           e - 相关文件的变更信息 
           a - 视图的当前分配 
           View.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory) , 
            View.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory) , 
            View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory) 
           public void setParent(View parent)
loadChildren方法。 
           孩子不应该加载在构造函数中,因为设置父进程的行为可能会导致他们尝试搜索层次结构(例如获取主机容器)。 
           如果此视图具有子视图(视图正从视图层次结构中的一个位置移动到另一个视图),则不会调用loadChildren方法。 
          public void preferenceChanged(View child, boolean width, boolean height)
preferenceChanged在 
            View 
           child - 子视图 
           width - 如果宽度首选项已更改,则为true 
           height - 如果高度偏好已更改,则为true 
           JComponent.revalidate() 
           public void setSize(float width,
                    float height) 
          由于主轴是异步更新,应该是平铺的小孩的总和,所以长轴将忽略调用。 由于短轴是灵活的,所以如果小跨度发生变化,则排队等待孩子调整大小。
public void paint(Graphics g, Shape alloc)
这被实现以确定要渲染的期望区域(即,未剪切区域)是否是最新的。 如果最新的孩子被渲染。 如果不是最新的,则将构建所需区域的任务作为高优先级任务放置在布局队列中。 这通过事件线程通过呈现准备就可以移动,并且如果没有准备就推迟到更晚的时间(因为绘制请求可以重新安排)。
paint在 
            View 
           g - 要使用的渲染表面 
           alloc - 要分配的区域 
           View.paint(java.awt.Graphics, java.awt.Shape) 
           public float getPreferredSpan(int axis)
getPreferredSpan在 
            View 
           axis - 可以是View.X_AXIS或View.Y_AXIS 
           IllegalArgumentException - 对于无效的轴类型 
           View.getPreferredSpan(int) 
           public float getMinimumSpan(int axis)
getMinimumSpan在 
            View 
           axis - 可以是View.X_AXIS或View.Y_AXIS 
           IllegalArgumentException - 对于无效的轴类型 
           View.getPreferredSpan(int) 
           public float getMaximumSpan(int axis)
getMaximumSpan在 
            View 
           axis - 可以是View.X_AXIS或View.Y_AXIS 
           IllegalArgumentException - 对于无效的轴类型 
           View.getPreferredSpan(int) 
           public int getViewCount()
getViewCount在 
            View 
           View.getViewCount() 
           public View getView(int n)
public Shape getChildAllocation(int index, Shape a)
getChildAllocation在 
            View 
           index - 小孩的索引> = 0 && <getViewCount() 
           a - 这个视图的分配。 
           public int getViewIndex(int pos,
                        Position.Bias b) 
          getViewIndex在 
            View 
           pos - 位置> = 0 
           public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException
modelToView在 
            View 
           pos - 转换> = 0的位置 
           a - 要分配的区域 
           b - 在位置是两个视图的边界的情况下,偏移朝向前一个字符或由偏移表示的下一个字符。 
           BadLocationException - 如果给定的位置不表示相关文档中的有效位置 
           IllegalArgumentException - 一个无效的偏差参数 
           View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[]) 
           public int viewToModel(float x,
                       float y,
                       Shape a,
                       Position.Bias[] biasReturn) 
          这被GUI线程预期调用,在关联的模型上保持一个读锁定。 它被实现以定位子视图并使用ChildLocator对象上的锁来确定它的分配,并且在子视图上调用ViewToModel,使用ChildState对象上的锁来避免与布局线程的交互。
viewToModel在 
            View 
           x - X坐标> = 0 
           y - Y坐标> = 0 
           a - 要分配的区域 
           public int getNextVisualPositionFrom(int pos,
                                     Position.Bias b,
                                     Shape a,
                                     int direction,
                                     Position.Bias[] biasRet)
                              throws BadLocationException 
          BadLocationException 。 
          getNextVisualPositionFrom在类 
            View 
           pos - 转换的位置 
           a - 要分配的区域 
           direction - 从当前位置的方向,可以被认为是通常在键盘上找到的箭头键; 
            这可能是以下之一: 
            SwingConstants.WEST SwingConstants.EAST SwingConstants.NORTH SwingConstants.SOUTH biasRet - 数组包含已检查的偏差 
           BadLocationException - 给定的位置不是文档中有效的位置 
           IllegalArgumentException - 如果 
            direction无效 
            Submit a bug or feature 
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
 Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.