Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.font.StyledString

java.lang.Object
    |
    +----java.awt.font.StyledString

public final class StyledString
extends Object
StyledString is a simple, immutable storage model for styled text. It supports substring and concatenation operations with other StyledStrings.


Constructor Summary
 StyledString()
Constructs a new StyledString with no characters.
 StyledString(String str, AttributeSet attributes)
Allocates a new styled string containing the same characters as the string argument, all styled with the specified attributes.
 StyledString(String str, Font font)
Constructs a new StyledString from the given String using the given Font.
 

Method Summary
char  charAt(int index)
Returns the character at the specified index.
StyledString  concat(StyledString text)
Concatenates the specified styled string to the end of this string.
AttributedCharacterIterator  createIterator()
 
AttributedCharacterIterator  createIterator(int start, int limit, int pos)
 
boolean  equals(Object rhs)
Return true if the strings have the same characters and attribute runs.
Point2D  getAdvanceVector()
Returns the advance vector for the end position of this StyledString.
float  getAscent()
Returns the largest ascent of any font represented in this StyledString.
AttributeSet  getAttributesAt(int index)
Return an attribute set describing the attributes on the character at index.
Rectangle2D  getBounds2D()
Returns the bounding box of this StyledString.
void  getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
Copies characters from this string into the destination character array.
float  getDescent()
Returns the largest descent of any font represented in this StyledString.
Font  getFontAt(int index)
Returns the Font associated with the character at the specified index.
GlyphSet[]  getGlyphSets()
Returns an array of GlyphSet objects associated with this StyledString.
float  getLeading()
Returns the largest leading of any font represented in this StyledString.
int  getRunLimit(int index)
Return the index past the last character of the run of characters containing index sharing equal attributes.
int  getRunStart(int index)
Return the index of the first character of the run of characters containing index sharing equal attributes.
Shape  getStringOutline()
Returns the Shape object for this StyledString, which is the union of all the outlines for glyphs in the StyledString.
int  length()
Returns the length of this styled string.
StyledString  substring(int beginIndex, int endIndex)
Returns a new styled string that is a substring of this styled string.
String  toString()
Return a String containing the characters in this object.
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StyledString

public StyledString()
Constructs a new StyledString with no characters.

StyledString

public StyledString(String str,
                    AttributeSet attributes)
Allocates a new styled string containing the same characters as the string argument, all styled with the specified attributes.

StyledString

public StyledString(String str,
                    Font font)
Constructs a new StyledString from the given String using the given Font.
Parameters:
str - the String object.
font - the Font object.
Method Detail

substring

public StyledString substring(int beginIndex,
                              int endIndex)
Returns a new styled string that is a substring of this styled string. The substring begins at the specified beginIndex and extends to the character at index endIndex - 1.
Parameters:
beginIndex - the beginning index, inclusive.
endIndex - the ending index, exclusive.
Returns:
the specified substring.
Throws:
StringIndexOutOfBoundsException - if the beginIndex or the endIndex is out of range.

getAscent

public float getAscent()
Returns the largest ascent of any font represented in this StyledString. The units are user space coordinates.

getDescent

public float getDescent()
Returns the largest descent of any font represented in this StyledString. The units are user space coordinates.

getLeading

public float getLeading()
Returns the largest leading of any font represented in this StyledString. The units are user space coordinates.

getRunStart

public int getRunStart(int index)
Return the index of the first character of the run of characters containing index sharing equal attributes.
Parameters:
index - the index of the character. Index may be equal to length, in which case the return value is the length of the styled string.
Returns:
the index of the first character in the run
Throws:
StringIndexOutOfBoundsException - if the index is out of range.
See Also:
getRunLimit

getRunLimit

public int getRunLimit(int index)
Return the index past the last character of the run of characters containing index sharing equal attributes.
Parameters:
index - the index of the character. Index may be equal to length, in which case the return value is the length of the styled string.
Returns:
the index past the last character in the run
Throws:
StringIndexOutOfBoundsException - if the index is out of range.
See Also:
getRunStart

getAdvanceVector

public Point2D getAdvanceVector()
Returns the advance vector for the end position of this StyledString.

getBounds2D

public Rectangle2D getBounds2D()
Returns the bounding box of this StyledString.

getGlyphSets

public GlyphSet[] getGlyphSets()
Returns an array of GlyphSet objects associated with this StyledString. REMIND jk . ask ccc to remove this api

getStringOutline

public Shape getStringOutline()
Returns the Shape object for this StyledString, which is the union of all the outlines for glyphs in the StyledString.

toString

public String toString()
Return a String containing the characters in this object.
Returns:
a string containing the characters in this object.
Overrides:
toString in class Object

concat

public StyledString concat(StyledString text)
Concatenates the specified styled string to the end of this string.

If the length of the argument string is 0, then this object is returned.

Parameters:
str - the StyledString that is concatenated to the end of this StyledString.
Returns:
a styled string that represents the concatenation of this object's characters and attributes followed by the string argument's characters and attributes.

charAt

public char charAt(int index)
Returns the character at the specified index. An index ranges from 0 to length() - 1.
Parameters:
index - the index of the character.
Returns:
the character at the specified index of this string. The first character is at index 0.
Throws:
StringIndexOutOfBoundsException - if the index is out of range.

getFontAt

public Font getFontAt(int index)
Returns the Font associated with the character at the specified index. An index ranges from 0 to length() - 1.
Throws:
StringIndexOutOfBoundsException - if the index is not in the range 0 to length()-1.

length

public int length()
Returns the length of this styled string. The length is equal to the number of Unicode characters in the styled string.
Returns:
the length of the sequence of characters represented by this object.

equals

public boolean equals(Object rhs)
Return true if the strings have the same characters and attribute runs. REMIND jk .new api
Overrides:
equals in class Object

createIterator

public AttributedCharacterIterator createIterator()

createIterator

public AttributedCharacterIterator createIterator(int start,
                                                  int limit,
                                                  int pos)

getAttributesAt

public AttributeSet getAttributesAt(int index)
Return an attribute set describing the attributes on the character at index.
Parameters:
index - the index of the character.
Returns:
the attributes of the character at index.
Throws:
StringIndexOutOfBoundsException - if the index is out of range.

getChars

public void getChars(int srcBegin,
                     int srcEnd,
                     char[] dst,
                     int dstBegin)
Copies characters from this string into the destination character array.

The first character to be copied is at index srcBegin; the last character to be copied is at index srcEnd-1 (thus the total number of characters to be copied is srcEnd-srcBegin). The characters are copied into the subarray of dst starting at index dstBegin and ending at index:

     dstbegin + (srcEnd-srcBegin) - 1
 
Parameters:
srcBegin - index of the first character in the string to copy.
srcEnd - index after the last character in the string to copy.
dst - the destination array.
dstBegin - the start offset in the destination array.
Throws:
StringIndexOutOfBoundsException - If srcBegin or srcEnd is out of range, or if srcBegin is greater than the srcEnd.

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.