public class WrappedPlainView extends BoxView implements TabExpander
线条视图通过drawLine方法完成所有drawLine ,而这又通过drawSelectedText和drawUnselectedText方法进行所有drawUnselectedText 。 这使子类可以轻松地专注于渲染,而不用担心布局方面。
View
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 |
|---|
WrappedPlainView(Element elem)
创建一个新的WrappedPlainView。
|
WrappedPlainView(Element elem, boolean wordWrap)
创建一个新的WrappedPlainView。
|
| Modifier and Type | Method and Description |
|---|---|
protected int |
calculateBreakPosition(int p0, int p1)
这被嵌套的包装线视图调用来确定断点位置。
|
void |
changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
在该视图负责的位置向文档发出属性更改的通知。
|
protected void |
drawLine(int p0, int p1, Graphics g, int x, int y)
渲染一行文本,最终抑制空格并展开任何标签。
|
protected int |
drawSelectedText(Graphics g, int x, int y, int p0, int p1)
将模型中的给定范围渲染为所选文本。
|
protected int |
drawUnselectedText(Graphics g, int x, int y, int p0, int p1)
将模型中的给定范围呈现为正常未选择的文本。
|
protected Segment |
getLineBuffer()
可以访问可用于从相关文档中获取文本的缓冲区。
|
float |
getMaximumSpan(int axis)
确定沿着轴的该视图的最大跨度。
|
float |
getMinimumSpan(int axis)
确定此视图沿轴的最小跨度。
|
float |
getPreferredSpan(int axis)
确定沿着轴的此视图的首选跨度。
|
protected int |
getTabSize()
返回为文档设置的选项卡大小,默认为8。
|
void |
insertUpdate(DocumentEvent e, Shape a, ViewFactory f)
在该视图负责的位置发出通知。
|
protected void |
loadChildren(ViewFactory f)
加载所有的孩子以初始化视图。
|
float |
nextTabStop(float x, int tabOffset)
在给定的参考位置之后返回下一个制表位置的停止位置。
|
void |
paint(Graphics g, Shape a)
渲染使用给定的渲染表面和该表面上的区域。
|
void |
removeUpdate(DocumentEvent e, Shape a, ViewFactory f)
在该视图负责的位置发出文档中已删除某些内容的通知。
|
void |
setSize(float width, float height)
设置视图的大小。
|
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, calculateMinorAxisRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getChildAllocation, getHeight, getOffset, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paintChild, preferenceChanged, replace, setAxis, viewToModelgetBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, getViewIndexAtPosition, modelToView, setInsets, setParagraphInsets, setParentappend, breakView, createFragment, forwardUpdateToView, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, remove, removeAll, updateChildren, updateLayout, viewToModelpublic WrappedPlainView(Element elem)
elem - 视图
elem的元素
public WrappedPlainView(Element elem, boolean wordWrap)
elem - 视图
elem的元素
wordWrap - 应该将字符包裹在字边界?
protected int getTabSize()
protected void drawLine(int p0,
int p1,
Graphics g,
int x,
int y)
drawUnselectedText和drawSelectedText ,以便可以自定义选择和未选择的文本的方式。
p0 - 要使用的起始文档位置> = 0
p1 - 要使用的结束文件位置> = p1
g - 图形上下文
x - 起始X位置> = 0
y - 起始Y位置> = 0
drawUnselectedText(java.awt.Graphics, int, int, int, int) ,
drawSelectedText(java.awt.Graphics, int, int, int, int)
protected int drawUnselectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException
g - 图形上下文
x - 起始X坐标> = 0
y - 起始Y坐标> = 0
p0 - 模型中的开始位置> = 0
p1 - 模型中的结束位置> = p0
BadLocationException - 如果范围无效
protected int drawSelectedText(Graphics g, int x, int y, int p0, int p1) throws BadLocationException
g - 图形上下文
x - 起始X坐标> = 0
y - 起始Y坐标> = 0
p0 - 模型中的起始位置> = 0
p1 - 模型中的结束位置> = p0
BadLocationException - 如果范围无效
protected final Segment getLineBuffer()
protected int calculateBreakPosition(int p0,
int p1)
protected void loadChildren(ViewFactory f)
setParent方法调用的。
子类可以重新实现,以不同的方式初始化其子视图。
默认实现为每个子元素创建一个子视图。
loadChildren在
CompositeView
f - 视图工厂
CompositeView.setParent(javax.swing.text.View)
public float nextTabStop(float x,
int tabOffset)
nextTabStop在接口
TabExpander
x - 当前位置> = 0
tabOffset - 标签出现在> = 0的文本流内的位置。
public void paint(Graphics g, Shape a)
paint在
BoxView
g - 要使用的渲染表面
a - 要分配的区域
View.paint(java.awt.Graphics, java.awt.Shape)
public void setSize(float width,
float height)
public float getPreferredSpan(int axis)
getPreferredSpan在
BoxView
axis - 可以是View.X_AXIS或View.Y_AXIS
View.getPreferredSpan(int)
public float getMinimumSpan(int axis)
getMinimumSpan在
BoxView
axis - 可以是View.X_AXIS或View.Y_AXIS
View.getMinimumSpan(int)
public float getMaximumSpan(int axis)
getMaximumSpan在
BoxView
axis - 可以是View.X_AXIS或View.Y_AXIS
View.getMaximumSpan(int)
public void insertUpdate(DocumentEvent e, Shape a, ViewFactory f)
insertUpdate在
View
e - 相关文件的变更信息
a - 视图的当前分配
f - 工厂用来重建如果视图有孩子
View.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public void removeUpdate(DocumentEvent e, Shape a, ViewFactory f)
removeUpdate在
View
e - 相关文件的更改信息
a - 视图的当前分配
f - 工厂使用重建如果视图有孩子
View.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
changedUpdate在
View类
e - 相关文件的更改信息
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.