public abstract class CompositeView extends View
CompositeView是一个抽象的View实现,它管理一个或多个子视图。
(请注意, CompositeView旨在用于管理相对较少数量的子视图。) CompositeView旨在用作View起始点,如BoxView ,将包含子级View 。
希望管理孩子View的收藏的子View应该使用replace(int, int, javax.swing.text.View[])方法。
由于View在DocumentListener replace期间调用replace ,通常不需要直接调用replace 。
虽然CompositeView没有对其孩子View施加布局策略,但它确实允许对其将包含的子级View进行加密。 插图可以由setInsets(short, short, short, short)或setParagraphInsets(javax.swing.text.AttributeSet)设置 。
除了View的抽象方法,CompositeView的CompositeView将需要覆盖:
isBefore(int, int, java.awt.Rectangle) -用于测试是否给定View位置是视觉空间之前CompositeView 。 isAfter(int, int, java.awt.Rectangle) - 用于测试给定的View位置是否在View的视觉空间CompositeView 。 getViewAtPoint(int, int, java.awt.Rectangle) - 返回给定视觉位置的视图。 childAllocation(int, java.awt.Rectangle) - 返回特定儿童的界限View 。 getChildAllocation将调用childAllocation由抵减范围后Inset S中的CompositeView 。 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 |
|---|
CompositeView(Element elem)
构造给定元素的
CompositeView 。
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
childAllocation(int index, Rectangle a)
返回给定子项的分配。
|
protected boolean |
flipEastAndWestAtEnds(int position, Position.Bias bias)
确定下一个视图放在哪个方向。
|
protected short |
getBottomInset()
获取底部插图。
|
Shape |
getChildAllocation(int index, Shape a)
获取给定子视图的分配。
|
protected Rectangle |
getInsideAllocation(Shape a)
将给予视图的不可变分配转换为表示内部分配的可变分配(即
|
protected short |
getLeftInset()
得到左边的插图。
|
protected int |
getNextEastWestVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet)
返回光标的下一个视觉位置,以东或西方向。
|
protected int |
getNextNorthSouthVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet)
返回光标的下一个视觉位置,在北或南方向。
|
int |
getNextVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet)
提供一种方法来确定可能放置插入符号的下一个视觉表示的模型位置。
|
protected short |
getRightInset()
获取正确的插图。
|
protected short |
getTopInset()
获得顶级插图。
|
View |
getView(int n)
返回此容器中的第n个视图。
|
protected abstract View |
getViewAtPoint(int x, int y, Rectangle alloc)
在给定坐标处获取子视图。
|
protected View |
getViewAtPosition(int pos, Rectangle a)
获取代表模型中给定位置的子视图。
|
int |
getViewCount()
返回此视图的子视图数。
|
int |
getViewIndex(int pos, Position.Bias b)
返回表示模型中给定位置的子视图索引。
|
protected int |
getViewIndexAtPosition(int pos)
获取代表模型中给定位置的子视图索引。
|
protected abstract boolean |
isAfter(int x, int y, Rectangle alloc)
测试一个点是否在矩形范围之后。
|
protected abstract boolean |
isBefore(int x, int y, Rectangle alloc)
测试点是否在矩形范围之前。
|
protected void |
loadChildren(ViewFactory f)
加载所有的孩子以初始化视图。
|
Shape |
modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a)
提供从文档模型坐标空间映射到映射到它的视图的坐标空间的映射。
|
Shape |
modelToView(int pos, Shape a, Position.Bias b)
提供从文档模型坐标空间映射到映射到它的视图的坐标空间的映射。
|
void |
replace(int offset, int length, View[] views)
代替子视图。
|
protected void |
setInsets(short top, short left, short bottom, short right)
设置视图的插值。
|
protected void |
setParagraphInsets(AttributeSet attr)
从给定属性中指定的段落属性设置插值。
|
void |
setParent(View parent)
设置视图的父级。
|
int |
viewToModel(float x, float y, Shape a, Position.Bias[] bias)
提供从视图坐标空间到模型的逻辑坐标空间的映射。
|
append, breakView, changedUpdate, createFragment, forwardUpdate, forwardUpdateToView, getAlignment, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getParent, getPreferredSpan, getResizeWeight, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, insertUpdate, isVisible, modelToView, paint, preferenceChanged, remove, removeAll, removeUpdate, setSize, updateChildren, updateLayout, viewToModelpublic CompositeView(Element elem)
CompositeView 。
elem - 这个视图负责的元素
protected void loadChildren(ViewFactory f)
f - 视图工厂
setParent(javax.swing.text.View)
public void setParent(View parent)
loadChildren方法。
孩子不应该加载在构造函数中,因为设置父进程的行为可能会导致他们尝试搜索层次结构(例如获取主机Container )。
如果此视图具有子节点(视图正从视图层次结构中的一个位置移动到另一个视图),则不会调用loadChildren方法。
public int getViewCount()
getViewCount在
View
getView(int)
public View getView(int n)
public void replace(int offset,
int length,
View[] views)
null ,并将它们的内部引用移除,以便它们可能被垃圾回收。
public Shape getChildAllocation(int index, Shape a)
getChildAllocation在
View
index - 小孩的索引> = 0 && <getViewCount()
a - 这个视图的分配
public Shape modelToView(int pos, Shape a, Position.Bias b) throws BadLocationException
modelToView在
View
pos - 转换> = 0的位置
a - 要分配的区域
b - 偏差值为
Position.Bias.Forward或
Position.Bias.Backward
BadLocationException - 如果给定的位置不表示相关文档中的有效位置
View.modelToView(int, java.awt.Shape, javax.swing.text.Position.Bias)
public Shape modelToView(int p0, Position.Bias b0, int p1, Position.Bias b1, Shape a) throws BadLocationException
modelToView在
View
p0 - 要转换的位置> = 0
b0 - 在位置是两个视图的边界的情况下,对由p0表示的前一个字符或下一个字符的偏置;
Position.Bias.Forward或Position.Bias.Backward
p1 - 转换> = 0的位置
b1 - 由p1表示的对前一个字符或下一个字符的偏置,在位置是两个视图的边界的情况下
a - 要分配的区域
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[] bias)
viewToModel在
View
x - 要转换的视图位置的x坐标> = 0
y - 要转换的视图位置的y坐标> = 0
a - 要分配的区域
bias -
Position.Bias.Forward或
Position.Bias.Backward
View.viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
public int getNextVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
getNextNorthSouthVisualPositionFrom(int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[])和getNextEastWestVisualPositionFrom(int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[])的方法。
该方法可以指定在> = 0范围内转换的位置。
如果值为-1,则会自动计算一个位置。
如果值<-1,则会抛出BadLocationException 。
getNextVisualPositionFrom在
View
pos - 转换的位置
b - 偏差值为
Position.Bias.Forward或
Position.Bias.Backward
a - 要分配的区域
direction - 当前位置的方向,可以被认为是通常在键盘上找到的箭头键;
这可能是以下之一:
SwingConstants.WEST SwingConstants.EAST SwingConstants.NORTH SwingConstants.SOUTH biasRet - 一个包含检查偏倚的数组
BadLocationException - 给定的位置不是文档中的有效位置
IllegalArgumentException - 如果
direction无效
public int getViewIndex(int pos,
Position.Bias b)
getViewIndexByPosition方法。
getViewIndex在
View类
pos - 位置> = 0
protected abstract boolean isBefore(int x,
int y,
Rectangle alloc)
x - X坐标> = 0
y - Y坐标> = 0
alloc - 矩形
protected abstract boolean isAfter(int x,
int y,
Rectangle alloc)
x - X坐标> = 0
y - Y坐标> = 0
alloc - 矩形
protected abstract View getViewAtPoint(int x, int y, Rectangle alloc)
x - X坐标> = 0
y - Y坐标> = 0
alloc - 父母在入境时的分配,应在退出时更改为小孩的分配
protected abstract void childAllocation(int index,
Rectangle a)
index - 小孩的索引> = 0 && <getViewCount()
a - 条目分配给框内部,并在退出时在索引处分配子视图。
protected View getViewAtPosition(int pos, Rectangle a)
pos - 位置> = 0
a - 进入箱内部的分配,以及包含退出位置的视图分配
null如果没有一个
protected int getViewIndexAtPosition(int pos)
pos - 位置> = 0
protected Rectangle getInsideAllocation(Shape a)
childAllocation方法。
a - 给予视图的分配
null ,则返回值为null
protected void setParagraphInsets(AttributeSet attr)
attr - 属性
protected void setInsets(short top,
short left,
short bottom,
short right)
top - 顶部插图> = 0
left - 左插图> = 0
bottom - 底部插入> = 0
right - 右插入> = 0
protected short getLeftInset()
protected short getRightInset()
protected short getTopInset()
protected short getBottomInset()
protected int getNextNorthSouthVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
pos - 要转换的位置> = 0
b - 偏差值为
Position.Bias.Forward或
Position.Bias.Backward
a - 要分配的区域
direction - 从当前位置的方向,可以被认为是通常在键盘上找到的箭头键;
这可能是以下之一:
SwingConstants.NORTH SwingConstants.SOUTH biasRet - 包含被检查偏倚的数组
BadLocationException
IllegalArgumentException - 如果
direction无效
getNextVisualPositionFrom(int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[])
protected int getNextEastWestVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
pos - 转换> = 0的位置
b - 偏差值为
Position.Bias.Forward或
Position.Bias.Backward
a - 要分配的区域
direction - 当前位置的方向,可以被认为是通常在键盘上找到的箭头键;
这可能是以下之一:
SwingConstants.WEST SwingConstants.EAST biasRet - 包含已检查偏倚的数组
BadLocationException
IllegalArgumentException - 如果
direction无效
getNextVisualPositionFrom(int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[])
protected boolean flipEastAndWestAtEnds(int position,
Position.Bias bias)
View 。
通常View从左到右放置,以便EAST的View将处于索引n + 1,WEST的View将处于索引n - 1。在某些情况下,例如带有双向文本,EAST的View可能不在索引n + 1,而是索引n-1,或WEST的View不在索引n-1,而是索引n + 1。在这种情况下,方法将返回true,表示View以降序排列。
这无条件地返回false,如果有可能按降序布置View ,子类应该覆盖此方法。
position - 进入模型的位置
bias -
Position.Bias.Forward或
Position.Bias.Backward
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.