All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.java.swing.text.JStyledDocument
java.lang.Object
|
+----com.sun.java.swing.text.JDocument
|
+----com.sun.java.swing.text.JStyledDocument
- public class JStyledDocument
- extends JDocument
A document that can be marked up with character and paragraph
styles in a manner similar to the Rich Text Format. The element
structure for this document represents style crossings for
style runs. These style runs are mapped into the standard
line/paragraph element structure that is managed by the JDocument
class since logical styles are assigned to paragraph boundries.
- See Also:
- Document, JDocument
-
BUFFER_SIZE_DEFAULT
-
-
styles
-
-
JStyledDocument()
- Construct a default styled document.
-
JStyledDocument(JDocument. Content, StyleContext)
- Construct a styled document.
-
addStyle(String, Style)
- Add a new style into the logical style hierarchy.
-
characterStyleElement(Position)
-
-
createBranchElement(JDocument. ElementBase, JDocument. ElementBase)
-
-
createLargeDocument(StyleContext)
- Create a styled text model that supports undo/redo
and supports relatively large amounts of content.
-
createLeafElement(JDocument. ElementBase, JDocument. ElementBase, Range)
- Hook through which elements are created to represent the
document structure.
-
createLineMap()
- Create the root element to be used to represent the
line/paragraph map.
-
createSmallDocument(StyleContext)
- Create a styled text model that does not support
undo/redo and stores content as a simple string.
-
getLogicalStyle(Position)
-
Fetch the logical style assigned to the paragraph
represented by the given position.
-
getStyle(String)
- Fetch a named style previously added.
-
paragraphStyleElement(Position)
-
-
positionToStyle(Position)
- Fetch the style represented by the given location.
-
removeStyle(String)
- Remove a named style previously added to the document.
-
setLogicalStyle(Position, Style)
- Set the logical style to use for the paragraph at the
given position.
BUFFER_SIZE_DEFAULT
public static final int BUFFER_SIZE_DEFAULT
styles
protected StyleContext styles
JStyledDocument
public JStyledDocument(JDocument. Content c,
StyleContext styles)
- Construct a styled document.
- Parameters:
- c - The container for the content.
- styles - Resources and style definitions which may
be shared across documents.
JStyledDocument
public JStyledDocument()
- Construct a default styled document. This buffers
input content by a size of BUFFER_SIZE_DEFAULT
and has a style context that is scoped by the lifetime
of the document and is not shared with other documents.
createSmallDocument
public static final Document createSmallDocument(StyleContext sc)
- Create a styled text model that does not support
undo/redo and stores content as a simple string.
createLargeDocument
public static final Document createLargeDocument(StyleContext sc)
- Create a styled text model that supports undo/redo
and supports relatively large amounts of content.
addStyle
public Style addStyle(String nm,
Style parent)
- Add a new style into the logical style hierarchy. Style attributes
resolve from bottom up so an attribute specified in a child
will override an attribute specified in the parent.
- Parameters:
- nm - The name of the style (must be unique within the
collection of named styles). The name may be null if the style
is unnamed, but the caller is responsible
for managing the reference returned as an unnamed style can't
be fetched by name. An unnamed style may be useful for things
like character attribute overrides such as found in a style
run.
- parent - The parent style. This may be null if unspecified
attributes need not be resolved in some other style.
removeStyle
public void removeStyle(String nm)
- Remove a named style previously added to the document.
- Parameters:
- nm - The name of the style to remove
getStyle
public Style getStyle(String nm)
- Fetch a named style previously added.
- Parameters:
- nm - The name of the style
setLogicalStyle
public void setLogicalStyle(Position p,
Style s)
- Set the logical style to use for the paragraph at the
given position. If attributes aren't explicity set
for character and paragraph attributes they will resolve
through the logical style assigned to the paragraph, which
in term may resolve through some hierarchy completely
independant of the element hierarchy in the document.
- Parameters:
- s - The logical style to assign to the paragraph.
getLogicalStyle
public Style getLogicalStyle(Position p)
- Fetch the logical style assigned to the paragraph
represented by the given position.
- Parameters:
- p - The location to translate to a paragraph
and determine the logical style assigned.
positionToStyle
public Style positionToStyle(Position pos)
- Fetch the style represented by the given location.
This style overrides the logical style settings.
This method aquires a read lock on the document for
the duration of the method call.
- Parameters:
- pos - The location in the document.
paragraphStyleElement
public Element paragraphStyleElement(Position pos)
characterStyleElement
public Element characterStyleElement(Position pos)
createLineMap
protected JDocument. BranchElement createLineMap()
- Create the root element to be used to represent the
line/paragraph map.
- Overrides:
- createLineMap in class JDocument
createLeafElement
protected JDocument. LeafElement createLeafElement(JDocument. ElementBase parent,
JDocument. ElementBase prototype,
Range rng)
- Hook through which elements are created to represent the
document structure. Because this implementation keeps
structure and content seperate, elements grow automatically
when content is extended so splits of existing elements
follow. The document itself gets to decide how to generate
elements to give flexibility in the type of elements used.
- Overrides:
- createLeafElement in class JDocument
createBranchElement
protected JDocument. BranchElement createBranchElement(JDocument. ElementBase parent,
JDocument. ElementBase prototype)
- Overrides:
- createBranchElement in class JDocument
All Packages Class Hierarchy This Package Previous Next Index