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 a paragraph element structure (which may reside in some other structure). The style runs break at paragraph boundaries since logical styles are assigned to paragraph boundaries.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.
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 a paragraph element structure (which may reside in some other structure). The style runs break at paragraph boundaries since logical styles are assigned to paragraph boundaries. Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans™ has been added to the java.beans package. Please see XMLEncoder.
Static Constant.
The default size of the initial content buffer.
type: int
Static Constant. The default size of the initial content buffer. type: int
(->default-styled-document)
(->default-styled-document styles)
(->default-styled-document c styles)
Constructor.
Constructs a styled document.
c - the container for the content - javax.swing.text.AbstractDocument$Content
styles - resources and style definitions which may be shared across documents - javax.swing.text.StyleContext
Constructor. Constructs a styled document. c - the container for the content - `javax.swing.text.AbstractDocument$Content` styles - resources and style definitions which may be shared across documents - `javax.swing.text.StyleContext`
(add-document-listener this listener)
Adds a document listener for notification of any changes.
listener - the listener - javax.swing.event.DocumentListener
Adds a document listener for notification of any changes. listener - the listener - `javax.swing.event.DocumentListener`
(add-style this nm parent)
Adds 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.
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. - java.lang.String
parent - the parent style. This may be null if unspecified attributes need not be resolved in some other style. - javax.swing.text.Style
returns: the style - javax.swing.text.Style
Adds 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. 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. - `java.lang.String` parent - the parent style. This may be null if unspecified attributes need not be resolved in some other style. - `javax.swing.text.Style` returns: the style - `javax.swing.text.Style`
(get-background this attr)
Gets the background color from an attribute set.
attr - the attribute set - javax.swing.text.AttributeSet
returns: the color - java.awt.Color
Gets the background color from an attribute set. attr - the attribute set - `javax.swing.text.AttributeSet` returns: the color - `java.awt.Color`
(get-character-element this pos)
Gets a character element based on a position.
pos - the position in the document >= 0 - int
returns: the element - javax.swing.text.Element
Gets a character element based on a position. pos - the position in the document >= 0 - `int` returns: the element - `javax.swing.text.Element`
(get-default-root-element this)
Gets the default root element.
returns: the root - javax.swing.text.Element
Gets the default root element. returns: the root - `javax.swing.text.Element`
(get-font this attr)
Gets the font from an attribute set.
attr - the attribute set - javax.swing.text.AttributeSet
returns: the font - java.awt.Font
Gets the font from an attribute set. attr - the attribute set - `javax.swing.text.AttributeSet` returns: the font - `java.awt.Font`
(get-foreground this attr)
Gets the foreground color from an attribute set.
attr - the attribute set - javax.swing.text.AttributeSet
returns: the color - java.awt.Color
Gets the foreground color from an attribute set. attr - the attribute set - `javax.swing.text.AttributeSet` returns: the color - `java.awt.Color`
(get-logical-style this p)
Fetches the logical style assigned to the paragraph represented by the given position.
p - the location to translate to a paragraph and determine the logical style assigned >= 0. This is an offset from the start of the document. - int
returns: the style, null if none - javax.swing.text.Style
Fetches the logical style assigned to the paragraph represented by the given position. p - the location to translate to a paragraph and determine the logical style assigned >= 0. This is an offset from the start of the document. - `int` returns: the style, null if none - `javax.swing.text.Style`
(get-paragraph-element this pos)
Gets the paragraph element at the offset pos. A paragraph consists of at least one child Element, which is usually a leaf.
pos - the starting offset >= 0 - int
returns: the element - javax.swing.text.Element
Gets the paragraph element at the offset pos. A paragraph consists of at least one child Element, which is usually a leaf. pos - the starting offset >= 0 - `int` returns: the element - `javax.swing.text.Element`
(get-style this nm)
Fetches a named style previously added.
nm - the name of the style - java.lang.String
returns: the style - javax.swing.text.Style
Fetches a named style previously added. nm - the name of the style - `java.lang.String` returns: the style - `javax.swing.text.Style`
(get-style-names this)
Fetches the list of of style names.
returns: all the style names - java.util.Enumeration<?>
Fetches the list of of style names. returns: all the style names - `java.util.Enumeration<?>`
(remove-document-listener this listener)
Removes a document listener.
listener - the listener - javax.swing.event.DocumentListener
Removes a document listener. listener - the listener - `javax.swing.event.DocumentListener`
(remove-element this elem)
Removes an element from this document.
The element is removed from its parent element, as well as the text in the range identified by the element. If the element isn't associated with the document, IllegalArgumentException is thrown.
As empty branch elements are not allowed in the document, if the element is the sole child, its parent element is removed as well, recursively. This means that when replacing all the children of a particular element, new children should be added before removing old children.
Element removal results in two events being fired, the DocumentEvent for changes in element structure and UndoableEditEvent for changes in document content.
If the element contains end-of-content mark (the last "\n" character in document), this character is not removed; instead, preceding leaf element is extended to cover the character. If the last leaf already ends with "\n", it is included in content removal.
If the element is null, NullPointerException is thrown. If the element structure would become invalid after the removal, for example if the element is the document root element, IllegalArgumentException is thrown. If the current element structure is invalid, IllegalStateException is thrown.
elem - the element to remove - javax.swing.text.Element
throws: java.lang.NullPointerException - if the element is null
Removes an element from this document. The element is removed from its parent element, as well as the text in the range identified by the element. If the element isn't associated with the document, IllegalArgumentException is thrown. As empty branch elements are not allowed in the document, if the element is the sole child, its parent element is removed as well, recursively. This means that when replacing all the children of a particular element, new children should be added before removing old children. Element removal results in two events being fired, the DocumentEvent for changes in element structure and UndoableEditEvent for changes in document content. If the element contains end-of-content mark (the last "\n" character in document), this character is not removed; instead, preceding leaf element is extended to cover the character. If the last leaf already ends with "\n", it is included in content removal. If the element is null, NullPointerException is thrown. If the element structure would become invalid after the removal, for example if the element is the document root element, IllegalArgumentException is thrown. If the current element structure is invalid, IllegalStateException is thrown. elem - the element to remove - `javax.swing.text.Element` throws: java.lang.NullPointerException - if the element is null
(remove-style this nm)
Removes a named style previously added to the document.
nm - the name of the style to remove - java.lang.String
Removes a named style previously added to the document. nm - the name of the style to remove - `java.lang.String`
(set-character-attributes this offset length s replace)
Sets attributes for some part of the document. A write lock is held by this operation while changes are being made, and a DocumentEvent is sent to the listeners after the change has been successfully completed.
This method is thread safe, although most Swing methods are not. Please see Concurrency in Swing for more information.
offset - the offset in the document >= 0 - int
length - the length >= 0 - int
s - the attributes - javax.swing.text.AttributeSet
replace - true if the previous attributes should be replaced before setting the new attributes - boolean
Sets attributes for some part of the document. A write lock is held by this operation while changes are being made, and a DocumentEvent is sent to the listeners after the change has been successfully completed. This method is thread safe, although most Swing methods are not. Please see Concurrency in Swing for more information. offset - the offset in the document >= 0 - `int` length - the length >= 0 - `int` s - the attributes - `javax.swing.text.AttributeSet` replace - true if the previous attributes should be replaced before setting the new attributes - `boolean`
(set-logical-style this pos s)
Sets the logical style to use for the paragraph at the given position. If attributes aren't explicitly set for character and paragraph attributes they will resolve through the logical style assigned to the paragraph, which in turn may resolve through some hierarchy completely independent of the element hierarchy in the document.
This method is thread safe, although most Swing methods are not. Please see Concurrency in Swing for more information.
pos - the offset from the start of the document >= 0 - int
s - the logical style to assign to the paragraph, null if none - javax.swing.text.Style
Sets the logical style to use for the paragraph at the given position. If attributes aren't explicitly set for character and paragraph attributes they will resolve through the logical style assigned to the paragraph, which in turn may resolve through some hierarchy completely independent of the element hierarchy in the document. This method is thread safe, although most Swing methods are not. Please see Concurrency in Swing for more information. pos - the offset from the start of the document >= 0 - `int` s - the logical style to assign to the paragraph, null if none - `javax.swing.text.Style`
(set-paragraph-attributes this offset length s replace)
Sets attributes for a paragraph.
This method is thread safe, although most Swing methods are not. Please see Concurrency in Swing for more information.
offset - the offset into the paragraph >= 0 - int
length - the number of characters affected >= 0 - int
s - the attributes - javax.swing.text.AttributeSet
replace - whether to replace existing attributes, or merge them - boolean
Sets attributes for a paragraph. This method is thread safe, although most Swing methods are not. Please see Concurrency in Swing for more information. offset - the offset into the paragraph >= 0 - `int` length - the number of characters affected >= 0 - `int` s - the attributes - `javax.swing.text.AttributeSet` replace - whether to replace existing attributes, or merge them - `boolean`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close