public class ParagraphView extends FlowView implements TabExpander
breakView方法来尝试将视图划分成适合的部分。
View
FlowView.FlowStrategy| Modifier and Type | Field and Description |
|---|---|
protected int |
firstLineIndent
第一行缩进,从左边插入。
|
layoutPool, layoutSpan, strategyBadBreakWeight, 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 |
|---|
ParagraphView(Element elem)
构造给定元素的
ParagraphView 。
|
| Modifier and Type | Method and Description |
|---|---|
View |
breakView(int axis, float len, Shape a)
以给定长度在给定轴上打破此视图。
|
protected SizeRequirements |
calculateMinorAxisRequirements(int axis, SizeRequirements r)
计算沿着短轴的段落的需要。
|
void |
changedUpdate(DocumentEvent changes, Shape a, ViewFactory f)
在该视图负责的位置向文档发出属性更改的通知。
|
protected View |
createRow()
创建一个
View ,应该用来持有一行的孩子流。
|
protected int |
findOffsetToCharactersInString(char[] string, int start)
在string中找到一个字符的文档中的下一个
string ,从偏移
start开始。
|
protected boolean |
flipEastAndWestAtEnds(int position, Position.Bias bias)
确定下一个视图放在哪个方向。
|
float |
getAlignment(int axis)
确定沿着轴的该视图的所需对准。
|
int |
getBreakWeight(int axis, float len)
获得给定位置的重量。
|
protected int |
getClosestPositionTo(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet, int rowIndex, int x)
返回最接近的模型位置为
x 。
|
int |
getFlowSpan(int index)
为给定的子索引获取约束跨度。
|
int |
getFlowStart(int index)
获取沿着流动轴线开始流动跨度的位置。
|
protected View |
getLayoutView(int index)
在给定的
index返回视图。
|
protected int |
getLayoutViewCount()
返回此视图负责的视图数。
|
protected int |
getNextNorthSouthVisualPositionFrom(int pos, Position.Bias b, Shape a, int direction, Position.Bias[] biasRet)
返回光标的下一个视觉位置,以东或西方向。
|
protected float |
getPartialSize(int startOffset, int endOffset)
返回
startOffset和
endOffset之间的视图使用的大小。
|
protected float |
getTabBase()
返回从中计算制表符的位置。
|
protected TabSet |
getTabSet()
获取
Tabset在计算选项卡中使用。
|
float |
nextTabStop(float x, int tabOffset)
返回给定参考位置的下一个制表位置位置。
|
void |
paint(Graphics g, Shape a)
渲染使用给定的渲染表面和该表面上的区域。
|
protected void |
setFirstLineIndent(float fi)
设置第一行的缩进。
|
protected void |
setJustification(int j)
设置对齐的类型。
|
protected void |
setLineSpacing(float ls)
设置行距。
|
protected void |
setPropertiesFromAttributes()
从属性设置缓存的属性。
|
getFlowAxis, getViewIndexAtPosition, insertUpdate, layout, loadChildren, removeUpdate, setParentbaselineLayout, baselineRequirements, calculateMajorAxisRequirements, childAllocation, forwardUpdate, getAxis, getChildAllocation, getHeight, getMaximumSpan, getMinimumSpan, getOffset, getPreferredSpan, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paintChild, preferenceChanged, replace, setAxis, setSize, viewToModelgetBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, modelToView, setInsets, setParagraphInsetsappend, breakView, createFragment, forwardUpdateToView, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, remove, removeAll, updateChildren, updateLayout, viewToModelpublic ParagraphView(Element elem)
ParagraphView 。
elem - 该视图负责的元素
protected void setJustification(int j)
j - 以下值之一:
StyleConstants.ALIGN_LEFT StyleConstants.ALIGN_CENTER StyleConstants.ALIGN_RIGHT protected void setLineSpacing(float ls)
ls - 该值是线高的因素
protected void setFirstLineIndent(float fi)
fi - 分数值
protected void setPropertiesFromAttributes()
protected int getLayoutViewCount()
View s的行。
这是平铺在二维中的视图数,应等于该视图负责的元素的子元素数。
ParagraphView的意见的数量
protected View getLayoutView(int index)
index返回视图。
该段的孩子意见已被用于安排件行Views代表的子元素。
此方法返回负责子元素索引(断开之前)的视图。
这些是从工厂生产的(用于表示子元素)并用于布局的视图。
index - 所需视图的
index
index
protected int getNextNorthSouthVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
CompositeView 。
getNextNorthSouthVisualPositionFrom在类
CompositeView
pos - 进入模型的位置
b -
Position.Bias.Forward或
Position.Bias.Backward
a - 要分配的区域
direction -
SwingConstants.NORTH或
SwingConstants.SOUTH
biasRet - 包含在此方法中检查的偏差的数组
BadLocationException
CompositeView.getNextVisualPositionFrom(int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[])
protected int getClosestPositionTo(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet,
int rowIndex,
int x)
throws BadLocationException
x 。
rowIndex给出了应该查看对应的视图的索引。
pos - 进入模型的位置
a - 要分配的区域
direction - 以下值之一:
SwingConstants.NORTH SwingConstants.SOUTH biasRet - 包含在此方法中检查的偏差的数组
rowIndex - 视图的索引
x - 感兴趣的x坐标
x
BadLocationException
protected boolean flipEastAndWestAtEnds(int position,
Position.Bias bias)
View 。
通常View是View布局的,所以EAST的View将处于索引n + 1,而WEST的View将处于索引n - 1。在某些情况下,例如双向文本,EAST的View可能不在索引n + 1,而是索引n-1,或者WEST的View不在索引n-1,而是索引n + 1。在这种情况下,方法将返回true,表示View以降序排列。
如果文本从右到左放置在位置,则返回true,否则为false。
flipEastAndWestAtEnds在类
BoxView
position - 进入模型的位置
bias -
Position.Bias.Forward或
Position.Bias.Backward
public int getFlowSpan(int index)
getFlowSpan在
FlowView
index - 要查询的视图的索引
index
FlowView.getFlowStart(int)
public int getFlowStart(int index)
getFlowStart在
FlowView
index - 被查询的视图的索引
index
FlowView.getFlowSpan(int)
protected View createRow()
View应该被用来持有一行的孩子的流。
public float nextTabStop(float x,
int tabOffset)
getTabbedSpan逻辑子节点,以确定孩子的期望跨度。
逻辑上的孩子可以将它们的扩展名向上扩展到知道如何扩展标签的段落。
LabelView是将其标签扩展需求向上委托给该段落的视图的示例。
这是实现在段落元素的属性集中尝试找到一个TabSet 。 如果找到,将使用其设置,否则将提供默认扩展。 用于标签扩展的基本位置是最近分配的段落(这是孩子的布局基于什么)的左侧插入。
nextTabStop在接口
TabExpander
x - X参考位置
tabOffset - 标签出现在> = 0的文本流内的位置
TabSet , TabStop , LabelView
protected TabSet getTabSet()
Tabset在计算选项卡中使用。
TabSet
protected float getPartialSize(int startOffset,
int endOffset)
startOffset和endOffset之间的视图使用的大小。
如果子视图实现TabableView接口,则使用getPartialView计算大小。
如果需要一个大小,并且View没有实现TabableView接口, preferredSpan将使用preferredSpan 。
startOffset - 起始文档offset> = 0
endOffset - 结束文件offset> = startOffset
protected int findOffsetToCharactersInString(char[] string,
int start)
string ,从偏移start开始。
如果没有找到字符,则返回-1。
string - 字符串
start - 从哪里开始模型> = 0
protected float getTabBase()
public void paint(Graphics g, Shape a)
paint在
BoxView
g - 要使用的渲染表面
a - 要分配的区域
View.paint(java.awt.Graphics, java.awt.Shape)
public float getAlignment(int axis)
getAlignment在
BoxView
axis - 可以是
View.X_AXIS或
View.Y_AXIS
public View breakView(int axis, float len, Shape a)
ParagraphView只能在Y_AXIS发生Y_AXIS ,只有len是第一行之后。
axis - 可能是
View.X_AXIS或
View.Y_AXIS
len - 指定在给定轴> = 0处希望潜在断点的位置
a - 当前分配的视图
View.breakView(int, int, float, float)
public int getBreakWeight(int axis,
float len)
ParagraphView只能在Y_AXIS发生Y_AXIS ,只有len是第一行后。 如果长度小于一行,则返回值BadBreakWeight 。
axis - 可能是
View.X_AXIS或
View.Y_AXIS
len - 指定希望潜在的中断时间> = 0
GoodBreakWeight或BadBreakWeight
View.getBreakWeight(int, float, float)
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r)
这使用超类的大小要求,修改为考虑相邻视图边缘的不可破坏区域。 这种视图的最小尺寸要求应不小于所有相邻碎片的总和。
如果axis参数既不是View.X_AXIS也不是View.Y_AXIS ,则抛出IllegalArgumentException 。 如果r参数为null, ,则会创建一个新的SizeRequirements对象,否则返回提供的SizeRequirements对象。
calculateMinorAxisRequirements在类
FlowView
axis - 短轴
r - 输入
SizeRequirements对象
SizeRequirements对象
IllegalArgumentException - 如果
axis参数无效
SizeRequirements
public void changedUpdate(DocumentEvent changes, Shape a, ViewFactory f)
changedUpdate在
FlowView
changes - 相关文件的变更信息
a - 当前分配的视图
f - 工厂使用重建如果视图有孩子
View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
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.