javax.swing.text
Class DefaultStyledDocument
- Document, Serializable, StyledDocument
Style | addStyle(String nm, Style parent) - Adds a style into the style hierarchy.
|
protected void | create(DefaultStyledDocument.ElementSpec[] data) - Initializes the
DefaultStyledDocument with the specified
data.
|
protected AbstractDocument.AbstractElement | createDefaultRoot() - Create the default root element for this kind of
Document .
|
Color | getBackground(AttributeSet attributes) - Extracts a background color from a set of attributes.
|
Element | getCharacterElement(int position) - Returns the
Element that corresponds to the character at the
specified position.
|
Element | getDefaultRootElement() - Returns the default root element.
|
Font | getFont(AttributeSet attributes) - Extracts a font from a set of attributes.
|
Color | getForeground(AttributeSet attributes) - Extracts a foreground color from a set of attributes.
|
Style | getLogicalStyle(int position) - Returns the logical
Style for the specified position.
|
Element | getParagraphElement(int position) - Returns the paragraph element for the specified position.
|
Style | getStyle(String nm) - Looks up and returns a named
Style .
|
Enumeration> | getStyleNames() - Returns an enumeration of all style names.
|
protected void | insert(int offset, DefaultStyledDocument.ElementSpec[] data) - Inserts a bulk of structured content at once.
|
protected void | insertUpdate(AbstractDocument.DefaultDocumentEvent ev, AttributeSet attr) - Called in response to content insert actions.
|
void | removeStyle(String nm) - Removes a named
Style from the style hierarchy.
|
protected void | removeUpdate(AbstractDocument.DefaultDocumentEvent ev) - Updates the document structure in response to text removal.
|
void | setCharacterAttributes(int offset, int length, AttributeSet attributes, boolean replace) - Sets text attributes for the fragment specified by
offset
and length .
|
void | setLogicalStyle(int position, Style style) - Sets the logical style for the paragraph at the specified position.
|
void | setParagraphAttributes(int offset, int length, AttributeSet attributes, boolean replace) - Sets text attributes for the paragraph at the specified fragment.
|
protected void | styleChanged(Style style) - Called when any of this document's styles changes.
|
Object> getDocumentProperties , addDocumentListener , addUndoableEditListener , createBranchElement , createLeafElement , createPosition , dump , extends EventListener> T[] getListeners , fireChangedUpdate , fireInsertUpdate , fireRemoveUpdate , fireUndoableEditUpdate , getAsynchronousLoadPriority , getAttributeContext , getBidiRootElement , getContent , getCurrentWriter , getDefaultRootElement , getDocumentFilter , getDocumentListeners , getEndPosition , getLength , getParagraphElement , getProperty , getRootElements , getStartPosition , getText , getText , getUndoableEditListeners , insertString , insertUpdate , postRemoveUpdate , putProperty , readLock , readUnlock , remove , removeDocumentListener , removeUndoableEditListener , removeUpdate , render , replace , setAsynchronousLoadPriority , setDocumentFilter , setDocumentProperties , writeLock , writeUnlock |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
BUFFER_SIZE_DEFAULT
public static final int BUFFER_SIZE_DEFAULT
The default size to use for new content buffers.
addStyle
public Style addStyle(String nm,
Style parent)
Adds a style into the style hierarchy. Unspecified style attributes can be
resolved in the parent
style, if one is specified. While it
is legal to add nameless styles (nm == null
- addStyle in interface StyledDocument
nm
- the name of the style or null
if the style should
be unnamedparent
- the parent in which unspecified style attributes are
resolved, or null
if that is not necessary
create
protected void create(DefaultStyledDocument.ElementSpec[] data)
Initializes the DefaultStyledDocument
with the specified
data.
data
- the specification of the content with which the document is
initialized
getCharacterElement
public Element getCharacterElement(int position)
Returns the Element
that corresponds to the character at the
specified position.
- getCharacterElement in interface StyledDocument
position
- the position of which we query the corresponding
Element
- the
Element
that corresponds to the character at the
specified position
getFont
public Font getFont(AttributeSet attributes)
Extracts a font from a set of attributes.
- getFont in interface StyledDocument
attributes
- the attributes from which to get a font
- the font that correspond to the attributes
getLogicalStyle
public Style getLogicalStyle(int position)
Returns the logical Style
for the specified position.
- getLogicalStyle in interface StyledDocument
position
- the position from which to query to logical style
- the logical
Style
for the specified position
getParagraphElement
public Element getParagraphElement(int position)
Returns the paragraph element for the specified position. If the position
is outside the bounds of the document's root element, then the closest
element is returned. That is the last paragraph if
position >= endIndex
or the first paragraph if
position <32startIndex
.
- getParagraphElement in interface StyledDocument
- getParagraphElement in interface AbstractDocument
position
- the position for which to query the paragraph element
- the paragraph element for the specified position
getStyleNames
public Enumeration> getStyleNames()
Returns an enumeration of all style names.
- an enumeration of all style names
setCharacterAttributes
public void setCharacterAttributes(int offset,
int length,
AttributeSet attributes,
boolean replace)
Sets text attributes for the fragment specified by offset
and length
.
- setCharacterAttributes in interface StyledDocument
offset
- the start offset of the fragmentlength
- the length of the fragmentattributes
- the text attributes to setreplace
- if true
, the attributes of the current selection
are overridden, otherwise they are merged
setLogicalStyle
public void setLogicalStyle(int position,
Style style)
Sets the logical style for the paragraph at the specified position.
- setLogicalStyle in interface StyledDocument
position
- the position at which the logical style is addedstyle
- the style to set for the current paragraph
setParagraphAttributes
public void setParagraphAttributes(int offset,
int length,
AttributeSet attributes,
boolean replace)
Sets text attributes for the paragraph at the specified fragment.
- setParagraphAttributes in interface StyledDocument
offset
- the beginning of the fragmentlength
- the length of the fragmentattributes
- the text attributes to setreplace
- if true
, the attributes of the current selection
are overridden, otherwise they are merged
styleChanged
protected void styleChanged(Style style)
Called when any of this document's styles changes.
style
- the style that changed
DefaultStyledDocument.java --
Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.