Summary: The classes on this page provide the convenient methods for handling the
java.text.AttributedString and java.text.AttributedCharacterIterator.
|
Relevant major classes of Java SE: java.awt.font.TextAttribute, java.text.AttributedString, java.text.AttributedCharacterIterator
|
Classes on this page: FontStyle, AttributedStringUtil, AttributedInterval, Interval, CommittedTextContainer |
1. Class FontStyle
return=>page top
This class represents a set of the text attributes like a font family,
font size, bold, italic, under line, super script and font color. Moreover
this class provides the method of setting font attributes to a selected text,
the method of retrieveing font attributes from a text, the method of setting font attributes to the
font menu, the method of retrieving font attributes from the
font menu, and so on.
=>
java.awt.font.TextAttribute,
Reflecting font style to the Font menu
Field |
Description |
fontFamily
|
public String fontFamily
Name of the font family.
|
bold
|
private int bold
Plain: 0, Bold:1
|
italic
|
private int italic
Regular: 0, Italic: 1
|
fontSize
|
public int fontSize
Font size.
|
underLine
|
private int underLine
Under line on: TextAttribute.UNDERLINE_ON,
Under line off: -1.
|
superScript
|
private int superScript
Supercript: TextAttribute.SUPERSCRIPT_SUPER(1~7),
Subscript: TextAttribute.SUPERSCRIPT_SUB(-1~-7),
Regular: 0.
|
fontColor
|
public Color fontColor
Font color.
|
UNDEF_String
|
public static final String UNDEF_String="UNDEF”
If the string-type attribute isn't set to the text, then set "UNDEF to the text.
|
UNDEF_int
|
public static final int UNDEF_int=-99
If the integer-type attribute isn't set to the text, then sets -99 to the text.
|
Method |
Description |
Constructor
|
public FontStyle(String fontFamily, int bold, int italic, int fontSize,
int underLine, int superScript, Color fontColor)
Sets the parameters to the corresponding fields.
|
setFontFamily
|
public void setFontFamily(String fontFamily)
Sets the parameter to the fontFamily.
|
getFontFamily
|
public String getFontFamily()
Returns the fontFamily.
|
setBold
|
public void setBold(int bold)
Sets the parameter to the bold.
|
getBold
|
public int getBold()
Returns the bold.
|
setItalic
|
public void setItalic(int italic)
Sets the parameter to the italic.
|
getItalic
|
public int getItalic()
Returns the italic.
|
setFontSize
|
public void setFontSize(int fontSize)
Sets the parameter to the fontSize.
|
getFontSize
|
public int getFontSize()
Returns the fontSize.
|
setUnderLine
|
public void setUnderLine(int underLine)
Sets the parameter to the underLine.
|
getUnderLine
|
public int getUnderLine()
Returns the underLine.
|
setSuperScript
|
public void setSuperScript(int superScript)
Sets the parameter to the superScript.
|
getSuperScript
|
public int getSuperScript()
Returns the superScript.
|
setFontColor
|
public void setFontColor(Color fontColor)
Sets the parameter to the fontColor.
|
getFontColor
|
public int getFontColor()
Returns the fontColor.
|
setTo |
public AttributedCharacterIterator setTo(AttributedCharacterIterator iterator,
int selStart, int selEnd)
Parameters:
iterator - The attributed string to which the attributes of this object are added.
selStart - The start index of the range to which the attributes are added.
selEnd - The end index of the range to which the attributes are added.
Returns:
The AttributedCharacterIterator object to which the attributes of this
object were added .
Processing:
The attributes of this object are added to the AttributedCharacterIterator
as follows.
∙ Font family
Adds the value of the fontFamily field using the key of TextAttribute.FAMILY.
∙ Bold, Italic
Adds the value of the bold field using the key of TextAttribute.WEIGHT
and the values of TextAttribute.WEIGHT_BOLD (bold) or TextAttribute.WEIGHT_REGULAR
(plain).
Adds the value of the italic field using the key of TextAttribute.POSTURE
and the values of TextAttribute.POSTURE_OBLIQUE (italic) or TextAttribute.POSTURE_REGULAR
(regular).
∙ Font size
Adds the value of the fontSize field using the key of TextAttribute.SIZE.
∙ Under line
Adds the value of the underLine field using the key of TextAttribute.UNDERLINE
and the values of TextAttribute.UNDERLINE_ON and -1(not underlined).
∙ SuperScript, subscript
Adds the value of the superScript field using the key of TextAttribute.SUPERSCRIPT
and the values of the TextAttribute.SUPERSCRIPT_SUPER and TextAttribute.SUPERSCRIPT_SUB.
∙ Font color
Adds the value of the fontColor using the key of TextAttribute.FOREGROUND.
Attributes =>
java.awt.font.TextAttribute
|
toString
|
public String toString()
Returns the string representing this object.
|
getDefaultFontStyle
(static)
|
public static FontStyle getDefaultFontStyle()
Returns the default FontStyle object.
fontSize=12, bold=0, italic=0, underline=-1, superScript=0, fontColor=Color.black
|
getFontStyleFromMenu
(static)
|
public static FontStyle getFontStyleFromMenu()
Creates a FontStyle object from the status of the Font menu and returns
the FontStyle object.
Font menu
|
setFontStyleToMenu
(static)
|
public static FontStyle setFontStyleToMenu(TextBox textBox)
Parameter:
textBox - The TextBox object.
Returns:
The FontStyle object created by referring the attributes of
the committed text in the text box.
Processing:
∙ Creates a new object of the FontStyle
If the selected text exists in the text box, then this method calls the
getCommonFontStyle method
with the parameter of the range of the selected text.
If the selected text doesn't exists,
then this method calls the getCommonFontStyle method
with the parameter of the range of the one character before thtext cursor.
Returns the returned value from the getCommonFontStyle method.
The getCommonFontStyle method
extracts common attributes from the specified range of the committed text.
∙ Calls the updateFontMenu method
to reflect the created FontStyle to the Font menu.
=>
Reflecting font style to the Font menu
|
setFontStyleToMenu
(static)
|
public static FontStyle setFontStyleToMenu(ShapeContainer[] containers)
This method called from the execSelection method of the
SelectionLS
to reflect the common attributes of the texts in the selected shapes to the Font menu.
To do this, this method calls the getCommonFontStyle
and the updateFontMenu methods.
|
updateFontMenu
(static)
|
private static void updateFontMenu(FontStyle fontStyle)
Gets the objects of the buttons, the combo boxes and the color chooser
by the getMenuComponent of the MenuUtil and changes the state of the objects.
As the result, the appearance of the button, the selected items of the
combo boxes and the selected color of the color chooser are changed as follows.
∙ The buttons
Changes the appearance of the buttons of the bold, italic, under line and
superscript/subscript attributes by using the setSelected method.
∙ The combo boxes
Changes the item in the combo boxes of the font family and font size attributes
by using the setSelectedItem method.
∙ The color chooser
Changes the selected color of the color chooser by using the
CustomColorChooserDialog.setPreviewColor method.
=>
Reflecting font style to the Font menu
|
getCommonFontStyle
(static)
|
private static FontStyle getCommonFontStyle(AttributedCharacterIterator
text, int start, int end)
Parameters:
text - The attributed string
start - The start of the range.
end - The end of the range.
Returns:
The FontStyle object storing the common attributes and values of the
specified range (start, end) of the text.
Processing:
This method extracts the attributes and their intervals from the [start,
end] interval of the text by the
AttributedStringUtil.createAttributedIntervals method.
If the extracted attribute values are the same for each attribute key,
then the common attribute is found for the key.
After collecting the common attributes, this method creates a new object
of the FontStyle with the parameters of the common attributes and returns
the the new FontStyle object.
=>
Reflecting font style to the Font menu
|
getCommonFontStyle
(static)
|
private static FontStyle getCommonFontStyle(TextBox[] textBoxes)
Returns the FontStyle object storing the common attributes of the committed
texts in the specified text boxes.
|
getFontStyleAt
(static) |
public static FontStyle getFontStyleAt(AttributedCharacterIterator text,
int position)
Parameters:
text - The attributed string
position - The position in the text.
Returns:
A FontStyle object retrieved from a character which is located ahead of the
specified position.
Processing:
This method is called from the TextBox.insertText method and returns attributes of a character before the specified
position. The returned attributes is represented by the FontStyle.
The rules retrieving attributes are as follows:
(1) If the character before the specified position is "\n" (line feed), this method tries to find a non-"\n"
character by repeating to check a character before the current character.
If a non-"\n" character is found, this method returns attributes
of the character.
(2) If the position equals 0, that means the top position of the text, this method tries to find a non-"\n" character from the top
position. If a non-"\n" character is found, this method returns
attributes of the character.
(3) If a non-"\n" character is not found in the above (1) or(2), this method returns the default FontStyle object which is given by
the FontStyle.getDefaultFontStyle method.
|
isFontStyle |
public static boolean isFontStyle(AttributedCharacterIterator text, int
start, int end)
Parameters:
text - The attributed string
start - The start of the range.
end - The end of the range.
Returns:
Return true, if the font interval specified by start, end of the text is set with a FontStyle.
|
isDefaultFontStyle |
public static boolean isDefaultFontStyle(AttributedCharacterIterator text,
int start, int end)
Parameters:
text - The attributed string
start - The start of the range.
end - The end of the range.
Returns:
Return true, if the font interval specified by start, end of the text is a default font.
|
:
Reflecting font style to the Font menu
return=>page top
"Reflecting" means to change the appearance of the Font menu by
shadowing and lowering the button or changing the item in the combo box
etc.
In the Figure_(a), the attributes of the selected text (mtDNA) is bold
and italic, so the corresponding buttons in the Font menu are shadowed and lowered.
Font menu
|
Font menu
|
Figure_(a) Reflecting the font style (bold, italic) of the selected text
to the Font menu.
|
Figure_(b) Reflecting the font style (superscript) of the character before the text cursor
to the Font menu.
|
:
java.awt.font.TextAttribute
(The extract from “JavaTM Platform, Standard Edition 6.
API")
return=>page top
Summary of attributes
Key
|
Value Type
|
Principal Constants
|
Default Value
|
FAMILY
|
String
|
See Font DIALOG, DIALOG_INPUT,
SERIF, SANS_SERIF, and MONOSPACED.
|
"Default" (use platform default)
|
WEIGHT
|
Number
|
WEIGHT_REGULAR, WEIGHT_BOLD
|
WEIGHT_REGULAR
|
WIDTH
|
Number
|
WIDTH_CONDENSED, WIDTH_REGULAR,
WIDTH_EXTENDED
|
WIDTH_REGULAR
|
POSTURE
|
Number
|
POSTURE_REGULAR, POSTURE_OBLIQUE
|
POSTURE_REGULAR
|
SIZE
|
Number
|
none
|
12.0
|
TRANSFORM
|
TransformAttribute
|
See TransformAttribute IDENTITY
|
TransformAttribute.IDENTITY
|
SUPERSCRIPT
|
Integer
|
SUPERSCRIPT_SUPER, SUPERSCRIPT_SUB
|
0 (use the standard glyphs and metrics)
|
FONT
|
Font
|
none
|
null (do not override font resolution)
|
CHAR_REPLACEMENT
|
GraphicAttribute
|
none
|
null (draw text using font glyphs)
|
FOREGROUND
|
Paint
|
none
|
null (use current graphics paint)
|
BACKGROUND
|
Paint
|
none
|
null (do not render background)
|
UNDERLINE
|
Integer
|
UNDERLINE_ON
|
-1 (do not render underline)
|
STRIKETHROUGH
|
Boolean
|
STRIKETHROUGH_ON
|
false (do not render strikethrough)
|
RUN_DIRECTION
|
Boolean
|
RUN_DIRECTION_LTR
RUN_DIRECTION_RTL
|
null (use Bidi standard default)
|
BIDI_EMBEDDING
|
Integer
|
none
|
0 (use base line direction)
|
JUSTIFICATION
|
Number
|
JUSTIFICATION_FULL
|
JUSTIFICATION_FULL
|
INPUT_METHOD_HIGHLIGHT
|
InputMethodHighlight,
Annotation
|
(see class)
|
null (do not apply input highlighting)
|
INPUT_METHOD_UNDERLINE
|
Integer
|
UNDERLINE_LOW_ONE_PIXEL,
UNDERLINE_LOW_TWO_PIXEL
|
-1 (do not render underline)
|
SWAP_COLORS
|
Boolean
|
SWAP_COLORS_ON
|
false (do not swap colors)
|
NUMERIC_SHAPING
|
NumericShaper
|
none
|
null (do not shape digits)
|
KERNING
|
Integer
|
KERNING_ON
|
0 (do not request kerning)
|
LIGATURES
|
Integer
|
LIGATURES_ON
|
0 (do not form optional ligatures)
|
TRACKING
|
Number
|
TRACKING_LOOSE, TRACKING_TIGHT
|
0 (do not add tracking)
|
2. Class AttributedStringUtil
return=>page top
public class AttributedStringUtil implements Serializable
The AttributedString object represents a string or text on which multiple
text attributes are defined, so it can be decomposed to a simple string,
text attributes and their intervals. The the set of a text attribute and
its interval is represented by the AttributedInterval class.
The AttributedStringUtil class provides the convenient methods
to handle the AttributedString object using the AttributedInterval.
=>
TextAttribute
Field |
Description |
iterator
|
AttributedCharacterIterator iterator
The attributed string (styled text) of the AttributedCharacterIterator form.
|
arrayList
|
ArrayList arrayList
The array storing the AttributedInterval objects.
|
Method |
Description |
Constructor
|
public AttributedStringUtil(AttributedCharacterIterator iterator)
∙ Sets the parameter to the iterator field.
∙ Calls the createAttributedIntervalList method
to decompose the iterator and store its attributes to the
arrayList.
|
rangeError |
private boolean rangeError(int start, int end, String errMessage)
Checks if the start and the end parameters are within the start index and
the end index of the field variable iterator. If not, outputs the errMessage and the values of the start and
end, and returns true. |
getBeginIndex |
public int getBeginIndex()
If the field variable iterator is null, returns -1. If it is not null, returns the the start index of the text. |
getEndIndex |
public int getEndIndex()
If the field variable iterator is null, returns -1. If it is not null,
returns the the end index of the text. |
setAttributedString
|
public void setAttributedString(AttributedCharacterIterator iterator)
Performs the same processing as the constructor.
|
createAttributedIntervalList
|
private void createAttributedIntervalList(AttributedCharacterIterator iterator)
Parameter:
iterator - The attributed string (styled text).
Processing:
This method is called by the constructor,
addAttribute
and removeAttribute methods.
∙ Gets all the keys from t h iterator.
Set<AttributedCharacterIterator.Attribute> keys=iterator.getAllAttributeKeys();
∙ Calls the createAttributedIntervalList method
for each key to create a AttributedInterval object
and saves it to the arrayList.
|
createAttributedIntervals
|
private AttributedInterval[] createAttributedIntervals(AttributedCharacterIterator.Attribute key)
Parameter:
key - The key of the TextAttribute.
iterator - The attributed string (styled text).
Returns:
The array of the AttributedInterval objects.
Processing:
Creates AttributedInterval objects from the iterator for the specified key.
The attribute of the key may be set to multiple intervals of the iterator with the same (attribute) value or different values, therefore generally
multiple AttributedInterval objects will be created.
∙ Gets the interval by the getRunStart and getRunLimit methods of the AttributedCharacterIterator
and gets the value by the getAttribute method of the AttributedCharacterIterator.
int runStart=this.iterator.getRunStart(key);
int runLimit=this.iterator.getRunLimit(key);
value=this.iterator.getAttribute(key);
∙ To find the next interval, updates the index of the
iterator by the setIndex method of the CharacterIterator.
this.iterator.setIndex(runLimit);
<Code>
private AttributedInterval[] createAttributedIntervalList(AttributedCharacterIterator.Attribute key){
Vector vector=new Vector();
Object value;
char c=iterator.first();
while(c!=CharacterIterator.DONE) {
int runStart=iterator.getRunStart(key);
int runLimit=iterator.getRunLimit(key);
value=iterator.getAttribute(key);
if( value!=null) {
AttributedInterval attribInterval=new AttributedInterval(runStart, runLimit,
key, value);
vector.add(attribInterval);
}
c=iterator.setIndex(runLimit);
} //end of while
AttributedInterval[] intervals=new AttributedInterval[vector.size()];
for(int i=0;i<vector.size();i++){
intervals[i]=(AttributedInterval)vector.get(i);
}
return intervals;
}
|
getAttributedIntervalList |
public ArrayList createAttributedIntervalList()
Returns the arrayList. |
getString
|
public String getString()
Returns the string of the iterator.
Gets the first character of the iterator by the first method of the CharacterIterator and gets the next character
by the next method of the CharacterIterator.
|
getString
|
public String getString(int start, int end)
Return the string of the specified range of the
iterator by using the
getString method and the substring method of the String.
|
getAttributedString
|
public AttributedString getAttributedString()
Return the AttributedString object of the iterator.
Gets the string from the iterator
by the getString method
and creates a new object of the AttributedString with the parameter of the string.
Then this method sets the attributes saved in the arrayList
to the new object by the addAttribute method of the AttributedString and finally returns the object.
|
getAttributedSubString
|
public AttributedString getAttributedSubString(int start, int end)
Return the AttributedString object of the iterator.
|
getTextLayoutString
|
public AttributedString getTextLayoutString(int start, int end, String
escapeChar,
String replaceChar)
This method is called from the LineBreaker.createMultipleLines method.
The processing of this method is almost same as that of the above getAttributedSubString method.
The different point is that this method replaces the escapeChar with the replaceChar.
Currently the escapeCharis "\n" (line feed) and the escapeCharis " " (space) or "↲"".
|
createAttributedIntervals
|
public AttributedInterval[] createAttributedIntervals()
Return the array of the AttributedInterval objects
from the arrayList.
|
createAttributedIntervals
|
public AttributedInterval[] createAttributedIntervals(int start, int end)
Paremeters:
start, end - The range of the iterator.
Returns:
Return the array of the AttributedInterval objects whose intervals are within [start, end].
Processing:
To calculate the intersection of the [start, end] interval and the intervals
of the AttributedInterval objects,
the intersection method of the Interval is used.
|
createAttributedIntervals
|
public AttributedInterval[] createAttributedIntervals(AttributedCharacterIterator.Attribute
key, int start, int end)
Paremeters:
key - The attribute key.
start, end - The range of the iterator.
Returns:
Return the array of the AttributedInterval objects whose key coincides with the parameter and whose intervals are
within [start, end].
Processing:
Similar to the createAttributedIntervals method.
|
addAttribute
|
public void addAttribute(AttributedCharacterIterator.Attribute key, Object value, int start, int end)
Paremeters:
key - The attribute key.
value - The attribute value.
start, end - The range of the iterator.
Processing:
Adds the attribute given by the parameters to the iterator.
∙ Gets the AttributedString object from the iterator
by the getAttributedString method.
∙ Adds the attribute given by the parameters to the AttributedString object
by the addAttribute method of the AttributedString.
attribStr.addAttribute(key, value, start, end);
∙ Calls the createAttributedIntervalList
to update this object (AttributedStringUtil).
|
removeAttribute
|
public void removeAttribute(AttributedCharacterIterator.Attribute key,
int start, int end)
Paremeters:
key - The key of the attribute to be removed.
start, end - The range of the iterator.
Processing:
Removes the attribute from the iterator.
∙ Gets the AttributedString object from the iterator
by the getAttributedString method.
∙ Adds the attribute given by the parameters to the AttributedString object
by the addAttribute method of the AttributedString.
attribStr.addAttribute(key, value, start, end);
∙ Calls the createAttributedIntervalList
to update this object (AttributedStringUtil).
|
removeAttribute
|
public void removeAttribute(AttributedCharacterIterator.Attribute key)
Paremeters:
key - The key of the attribute to be removed.
Processing:
Removes the attribute from the iterator.
∙ Gets the string from the iterator
by the getString method.
∙ Creates a new AttributedString object with the parameter of the string.
∙ Adds the attribute saved in the arrayList
to the new AttributedString object by the addAttribute method
of this class, if the key of the attribute isn't equals to the parameter.
:
It is impossible to remove the attribute directly from the
iterator. So,
adds the saved attributes to the new AttributedString which has no attribute initially.
|
hasAttribute
|
public boolean hasAttribute(AttributedCharacterIterator.Attribute key)
Returns true if the iterator has the specified attribute.
|
toString
|
public String toString()
Return the string representing this object.
|
getString
(static)
|
public static String getString(AttributedCharacterIterator iterator)
Returns the string of the AttributedCharacterIterator specified by the parameter.
|
getAttributedString
(static)
|
public static AttributedString getAttributedString(AttributedCharacterIterator
iterator)
Returns the AttributedString of the AttributedCharacterIterator specified
by the parameter.
|
createCompositeText
(static)
|
public static AttributedCharacterIterator createCompositeText(AttributedCharacterIterator
iterator1, AttributedCharacterIterator iterator2, int insertionPosition,
boolean highLight)
Paremeters:
iterator1 - The first AttributedString.
iterator2 - The second AttributedString.
insertionPosition - The insertion position of the second AttributedString to the first AttributedString.
highLight - If true, then adds the TextAttribute.INPUT_METHOD_HIGHLIGHT to the second
AttributedString.
=>
java.awt.font.TextAttribute
Returns:
Return the composite attributed string.
Processing:
This method is used to combine the composed text with the committed text.
=>
Composed text and committed text.
∙ Creates new two AttributedStringUtil objects from the iterator1 and the iterator2.
∙ Gets the two strings from the two AttributedStringUtil objects and combines the two strings.
∙ Adds the attributes to the combined string to create a composite attributed string.
The attributes and their ranges (intervals) are given by the
createAttributedIntervals method
of the AttributedStringUtil.
To add the attributes to the combined string,
the addAttribute method is used.
∙ Returns the composite attributed string.
|
3. AttributedInterval
return=>page top
This class represents the interval on which a text attribute is defined.
Field
|
Description
|
start
|
protected int start
The start position of the interval.
:
The position is defined such as the forward position of the k-th character
of the text is k-1 and the the backward position of the k-th character is k.
|
end
|
protected int end
The end position of the interval.
|
key
|
protected AttributedCharacterIterator.Attribute key
The attribute key of the interval.
=>
java.awt.font.TextAttribute
|
value
|
protected Object value
The attribute value of the interval.
|
Method |
Description |
Constructor
|
public AttributedInterval(int start, int end, AttributedCharacterIterator.Attribute
key, Object value)
Sets the parameters to the corresponding fields.
|
getStart
|
public int getStart()
Returns the start field.
|
getEnd
|
public int getEnd()
Returns the end field.
|
getKey
|
public AttributedCharacterIterator.Attribute getKey()
Returns the key field.
|
getValue
|
public Object getValue()
Returns the value field.
|
clone
|
public Object clone()
Returns a clone object.
|
toString
|
public String toString()
Returns the string representing this object.
|
4. Class Interval
return=>page top
This class provides the methods for the set operation of intervals.
>Field
|
Description
|
start
|
public int start
The start position of the interval.
|
end
|
public int end
The end position of the interval.
|
Method |
Description |
Constructor
|
public Interval(int start, int end)
Sets the parameters to the corresponding fields.
|
getStart
|
public int getStart()
Returns the start field.
|
getEnd
|
public int getEnd()
Returns the end field.
|
length
|
public int length()
Returns the length of the interval (this.end-this.start).
|
toString
|
public String toString()
Returns the string representing this object.
|
add
(static)
|
public static Interval[] add(Interval interval1, Interval interval2)
Adds the two intervals and returns the added intervals.
|
sub
(static)
|
public static Interval[] sub(Interval interval1, Interval interval2)
Subtract the interval2 from the interval1 and return the subtracted intervals.
If there is no subtracted interval, then returns the array of 0 length.
|
intersection
(static)
|
public static Interval intersection(Interval interval1, Interval interval2)
Returns the intersection of the two intervals. If there is no intersection,
then return null.
|
del
(static)
|
public static Interval del(Interval interval, Interval delInterval)
Parameters:
interval - The interval
delInterval - The interval to be deleted.
Returns:
The changed interval after the interval of the delInterval was deleted.
Processing:
This method calculates how the interval is changed about its position and width,
if the delInterval deleted from the interval.
The figure below shows the cases of this. The newInterval is an interval to be returned.
|
5. Class CommittedTextContainer
return=>page top
public class CommittedTextContainer
This class is used in the TextBox object to manage the committed text,
i.e. inserting a new text to this container or deleting text from this
container.
Field |
Description |
committedText
|
private AttributedCharacterIterator committedText
The committed text (Composed text and committed text).
|
DefaultFont
|
private final Font DefaultFont=new Font(Font.DIALOG, Font.PLAIN, 12)
The default font before text attributes are set to the committed text.
|
Method |
Description
|
getCommittedText
|
public AttributedCharacterIterator getCommittedText()
Returns the committedText.
|
setCommittedText
|
public void setCommittedText(AttributedCharacterIterator committedText)
Sets the parameter to the committedText.
If the TextAttribute.INPUT_METHOD_HIGHLIGHT attribute is added to the parameters,
removes its attribute.
|
getBeginIndex
|
public int getBeginIndex()
Returns the start index of thecommittedText.
|
getEndIndex
|
public int getEndIndex()
Returns the start index of the committedText.
|
getString
|
public String getString()
Returns the string of the committedText.
|
getString
|
public String getString(int start, int end)
Returns the substring of the committedText.
|
getAttributedString
|
public AttributedString getAttributedString()
Returns the AttributedString object of the
committedText.
|
getAttributedSubString
|
public AttributedString getAttributedSubString(int start, int end)
Returns the AttributedString object of the substring of the
committedText.
|
getDisplayText
|
public AttributedCharacterIterator getDisplayText(int insertionPosition,
AttributedCharacterIterator composedText)
Parameter:
insertionPosition - The insertion position of the composed text into the
committedText.
composedText - The composed text (Composed text and committed text)
Returns:
The composite text of the committedText and the composed text.
Processing:
To create the composite text, the createCompositeText of the AttributedStringUtil is used.
|
insertText
|
public void insertText(int insertionPosition, AttributedCharacterIterator
string)
Parameter:
insertionPosition - The insertion position of the string into the committedText.
string - The string to be inserted.
Processing:
To insert the string, the createCompositeText of the
AttributedStringUtil is used.
∙ Removes the TextAttribute.INPUT_METHOD_HIGHLIGHT attribute from the
committedText
by the removeAttribute method
of the AttributeStringUtil.
∙ Removes the TextAttribute.LANGUAGE, READING, INPUT_METHOD_SEGMENT attributes
from the string to be inserted by the removeAttribute method
of the AttributeStringUtil.
|
deleteText
|
public void deleteText(int delStart, int delEnd)
Deletes text in the [delStart, delEnd] from the
committedText.
|
getSerializable
AttributedString
|
public SerializableAttributedString getSerializableAttributedString()
Returns the SerializableAttributedString object
of the committedText.
|
setSerializable
AttributedString
|
public void setSerializableAttributedString(SerializableAttributedString data)
Sets the SerializableAttributedString object
to the committedText.
|
|