-
- All Superinterfaces:
-
Document
- 所有已知实现类:
-
DefaultStyledDocument,HTMLDocument
public interface StyledDocument extends Document
通用样式文档的界面。
-
-
Field Summary
-
Fields inherited from interface javax.swing.text.Document
StreamDescriptionProperty, TitleProperty
-
-
方法摘要
所有方法 接口方法 抽象方法 Modifier and Type 方法 描述 StyleaddStyle(String nm, Style parent)在逻辑样式层次结构中添加新样式。ColorgetBackground(AttributeSet attr)获取一组属性并将其转换为背景颜色规范。ElementgetCharacterElement(int pos)获取表示文档中给定偏移量的字符的元素。FontgetFont(AttributeSet attr)获取一组属性并将其转换为字体规范。ColorgetForeground(AttributeSet attr)获取一组属性,并将其转换为前景颜色规范。StylegetLogicalStyle(int p)获取段落中给定位置的逻辑风格。ElementgetParagraphElement(int pos)获取表示在文档中包含给定偏移量的段落的元素。StylegetStyle(String nm)获取先前添加的命名样式。voidremoveStyle(String nm)删除之前添加到文档的命名样式。voidsetCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)更改用于文档中现有内容的给定范围的内容元素属性。voidsetLogicalStyle(int pos, Style s)设置用于给定位置的段落的逻辑样式。voidsetParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)设置段落属性。-
Methods inherited from interface javax.swing.text.Document
addDocumentListener, addUndoableEditListener, createPosition, getDefaultRootElement, getEndPosition, getLength, getProperty, getRootElements, getStartPosition, getText, getText, insertString, putProperty, remove, removeDocumentListener, removeUndoableEditListener, render
-
-
-
-
方法详细信息
-
addStyle
Style addStyle(String nm, Style parent)
在逻辑样式层次结构中添加新样式。 样式属性从下到上解析,因此在孩子中指定的属性将覆盖父项中指定的属性。- 参数
-
nm- 样式的名称(在命名样式的集合中必须是唯一的)。 如果风格未命名,名称可能为null,但是调用者负责管理返回的引用,因为未命名的样式无法通过名称获取。 一个未命名的样式可能对于诸如字符属性覆盖(例如在样式运行中找到)的事情是有用的。 -
parent- 父样式。 如果未指定的属性不需要以某种其他风格解析,则此值可能为null。 - 结果
- 样式
-
removeStyle
void removeStyle(String nm)
删除之前添加到文档的命名样式。- 参数
-
nm- 要删除的样式的名称
-
setCharacterAttributes
void setCharacterAttributes(int offset, int length, AttributeSet s, boolean replace)更改用于文档中现有内容的给定范围的内容元素属性。 给定的属性参数中定义的所有属性将应用于给定的范围。 此方法可用于通过给出没有定义属性的Attributes参数并将replace替换为true来完全删除给定范围的所有内容级属性。- 参数
-
offset- 更改的开始> = 0 -
length- 更改的长度> = 0 -
s- 要更改的非空属性。 定义的任何属性将被应用于给定范围的文本。 -
replace- 指示在设置新属性之前是否应清除先前的属性。 如果为真,则操作将完全替换以前的属性。 如果为false,则新属性将与先前的属性合并。
-
setParagraphAttributes
void setParagraphAttributes(int offset, int length, AttributeSet s, boolean replace)设置段落属性。- 参数
-
offset- 更改的开始> = 0 -
length- 更改的长度> = 0 -
s- 要更改的非空属性。 定义的任何属性将被应用于给定范围的文本。 -
replace- 指示在设置新属性之前是否应清除先前的属性。 如果为真,则操作将完全替换以前的属性。 如果为false,则新属性将与先前的属性合并。
-
setLogicalStyle
void setLogicalStyle(int pos, Style s)设置用于给定位置的段落的逻辑样式。 如果没有为字符和段落属性明确设置属性,则它们将通过分配给段落的逻辑风格进行解析,而后者又可以通过某些层次结构完全独立于文档中的元素层次结构来解析属性。- 参数
-
pos- 起始位置> = 0 -
s- 设置的样式
-
getLogicalStyle
Style getLogicalStyle(int p)
获取段落中给定位置的逻辑风格。- 参数
-
p- 位置> = 0 - 结果
- 样式
-
getParagraphElement
Element getParagraphElement(int pos)
获取表示在文档中包含给定偏移量的段落的元素。- 参数
-
pos- offset> = 0 - 结果
- 元素
-
getCharacterElement
Element getCharacterElement(int pos)
获取表示文档中给定偏移量的字符的元素。- 参数
-
pos- offset> = 0 - 结果
- 元素
-
getForeground
Color getForeground(AttributeSet attr)
获取一组属性,并将其转换为前景颜色规范。 这可能用于指定更亮,更多色相等的东西。- 参数
-
attr- 属性集 - 结果
- 颜色
-
getBackground
Color getBackground(AttributeSet attr)
获取一组属性并将其转换为背景颜色规范。 这可能用于指定更亮,更多色相等的东西。- 参数
-
attr- 属性集 - 结果
- 颜色
-
getFont
Font getFont(AttributeSet attr)
获取一组属性并将其转换为字体规范。 这可以用来将家庭,风格,大小等的东西转换成系统上当前正在使用的文字。- 参数
-
attr- 属性集 - 结果
- the font
-
-