|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.wordhoard.model.text.TextRun
public class TextRun
A styled run of text.
A run is a string of text plus character set, font size, and style attributes.
The style attributes are:
Runs can also contain font information, which is set and used in
the client to facilitate word wrapping and presentation. See
WrappedText
and
FontManager
for more details.
Runs can also contain color information, which is also set and used in the client.
Field Summary | |
---|---|
static int |
BOLD
Bold style mask. |
static int |
EXTENDED
Extended style mask. |
static int |
ITALIC
Italic style mask. |
static int |
MONOSPACED
Monospaced style mask. |
static int |
OVERLINE
Overline style mask. |
static int |
SUBSCRIPT
Subscript style mask. |
static int |
SUPERSCRIPT
Superscript style mask. |
static int |
UNDERLINE
Underline style mask. |
Constructor Summary | |
---|---|
TextRun()
Creates a new empty run. |
|
TextRun(java.lang.String text,
byte charset)
Creates a new run. |
|
TextRun(java.lang.String text,
byte charset,
byte size)
Creates a new run. |
|
TextRun(java.lang.String text,
byte charset,
byte size,
boolean bold,
boolean italic)
Creates a new run. |
|
TextRun(java.lang.String text,
FontInfo fontInfo)
Creates a new run with font information. |
Method Summary | |
---|---|
java.lang.Object |
clone()
Clones the run. |
(package private) void |
draw(DrawingContext context,
int x,
int y,
int selStartOffsetInRun,
int selEndOffsetInRun)
Draws the run. |
byte |
getCharset()
Gets the character set. |
java.awt.Color |
getColor()
Gets the color of the run. |
FontInfo |
getFontInfo()
Gets the font information for the run. |
int |
getLength()
Gets the length of the run in characters. |
byte |
getSize()
Gets the font size. |
int |
getStyle()
Gets the style attributes. |
int |
getSubstringWidth(int start,
int end)
Gets the width of a substring of the run. |
java.lang.String |
getText()
Gets the text of the run. |
int |
getWidth()
Gets the width of the the run in pixels. |
boolean |
isBold()
Returns true if bold. |
boolean |
isEmpty()
Returns true if the run is empty. |
boolean |
isExtended()
Returns true if extended. |
boolean |
isItalic()
Returns true if italic. |
boolean |
isMonospaced()
Returns true if monospaced. |
boolean |
isOverline()
Returns true if overline. |
boolean |
isSubscript()
Returns true if subscript. |
boolean |
isSuperscript()
Returns true if superscript. |
boolean |
isUnderline()
Returns true if underline. |
void |
readExternal(java.io.ObjectInput in)
Reads the run from an object input stream (deserializes the object). |
void |
setBold()
Sets the bold style attribute. |
void |
setCharset(byte charset)
Sets the character set. |
void |
setColor(java.awt.Color color)
Sets the color of the run. |
void |
setExtended()
Sets the extended style attribute. |
void |
setFontInfo(FontInfo fontInfo)
Sets the font information for the run. |
void |
setItalic()
Sets the italic style attribute. |
void |
setMonospaced()
Sets the monospaced style attribute. |
void |
setOverline()
Sets the overline style attribute. |
void |
setSize(byte size)
Sets the font size. |
void |
setStyle(int style)
Sets the style attributes. |
void |
setSubscript()
Sets the subscript style attribute. |
void |
setSuperscript()
Sets the superscript style attribute. |
void |
setText(java.lang.String text)
Sets the text of the run. |
void |
setUnderline()
Sets the underline style attribute. |
void |
setXOffset(int xOffset)
Sets the X offset of the run. |
void |
setYOffset(int yOffset)
Sets the Y offset of the run. |
(package private) int |
viewToModel(DrawingContext context,
int x)
Converts a point to a character offset. |
void |
writeExternal(java.io.ObjectOutput out)
Writes the run to an object output stream (serializes the object). |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BOLD
public static final int ITALIC
public static final int EXTENDED
public static final int UNDERLINE
public static final int OVERLINE
public static final int SUPERSCRIPT
public static final int SUBSCRIPT
public static final int MONOSPACED
Constructor Detail |
---|
public TextRun(java.lang.String text, byte charset, byte size)
The new run is plain (no style attributes).
text
- Text.charset
- Character set.size
- Font size. public TextRun(java.lang.String text, byte charset, byte size, boolean bold, boolean italic)
text
- Text.charset
- Character set.size
- Font size.bold
- True if bold.italic
- True if italic. public TextRun(java.lang.String text, byte charset)
The new run has size 0 and is plain.
text
- Text.charset
- Character set. public TextRun(java.lang.String text, FontInfo fontInfo)
The new run has size 0, is plain, and uses the Roman character set.
text
- Text.fontInfo
- Font information. public TextRun()
Method Detail |
---|
public java.lang.String getText()
public void setText(java.lang.String text)
text
- The text of the run. public byte getCharset()
public void setCharset(byte charset)
charset
- The character set. public byte getSize()
public void setSize(byte size)
size
- The font size. public boolean isBold()
public void setBold()
public boolean isItalic()
public void setItalic()
public boolean isExtended()
public void setExtended()
public boolean isUnderline()
public void setUnderline()
public boolean isOverline()
public void setOverline()
public boolean isSuperscript()
public void setSuperscript()
public boolean isSubscript()
public void setSubscript()
public boolean isMonospaced()
public void setMonospaced()
public boolean isEmpty()
public int getStyle()
public void setStyle(int style)
style
- Style attributes. public int getLength()
public FontInfo getFontInfo()
public void setFontInfo(FontInfo fontInfo)
This method also computes and sets the width of the run.
fontInfo
- The font information. public int getSubstringWidth(int start, int end)
start
- Start index of substring.end
- End index of substring. public java.awt.Color getColor()
public void setColor(java.awt.Color color)
color
- The color of the run. public int getWidth()
public void setXOffset(int xOffset)
xOffset
- Offset from left edge in pixels. public void setYOffset(int yOffset)
yOffset
- Offset from baseline in pixels. public java.lang.Object clone()
The clone is shallow - the font information is not cloned.
clone
in class java.lang.Object
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
out
- Object output stream.
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
in
- Object input stream.
java.io.IOException
java.lang.ClassNotFoundException
void draw(DrawingContext context, int x, int y, int selStartOffsetInRun, int selEndOffsetInRun)
The font information must be set.
context
- Drawing context.x
- X coordinate of left edge of run.y
- Y coordinate of baseline of run.selStartOffsetInRun
- Selection start offset in run.selEndOffsetInRun
- Selection end offset in run. int viewToModel(DrawingContext context, int x)
context
- Drawing context.x
- X coordinate of point in run.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |