java.lang.Objectcom.realtime.crossfire.jxclient.gui.log.AbstractSegment
com.realtime.crossfire.jxclient.gui.log.TextSegment
public class TextSegment
One segment of a Line which should be displayed without changing
attributes.
| Field Summary | |
|---|---|
private boolean |
bold
Whether bold face is enabled. |
private java.awt.Color |
color
The color to use. |
private FontID |
font
The font to use. |
private boolean |
italic
Whether italic face is enabled. |
private java.lang.String |
text
The text to display. |
private boolean |
underline
Whether underlining is enabled. |
private int |
underlineOffset
The distance of the underline to the base line. |
| Constructor Summary | |
|---|---|
TextSegment(java.lang.String text,
boolean bold,
boolean italic,
boolean underline,
FontID font,
java.awt.Color color)
Create a new segment. |
|
| Method Summary | |
|---|---|
void |
draw(java.awt.Graphics g,
int y,
Fonts fonts)
Draws this segment to a Graphics instance. |
private java.awt.Font |
getFont(Fonts fonts)
Return the Font to use for a given Segment. |
java.awt.geom.RectangularShape |
getSize(Fonts fonts,
java.awt.font.FontRenderContext context)
Returns the size of this segment in pixels. |
java.lang.String |
getText()
Return the text to display. |
boolean |
matches(boolean bold,
boolean italic,
boolean underline,
FontID font,
java.awt.Color color)
Returns whether this segment matches the given attributes. |
java.lang.String |
toString()
|
void |
updateAttributes(Fonts fonts,
java.awt.font.FontRenderContext context)
Updates the cached attributes of this segment. |
| Methods inherited from class com.realtime.crossfire.jxclient.gui.log.AbstractSegment |
|---|
getWidth, getX, getY, setWidth, setX, setY |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private final boolean bold
@Nullable private final java.awt.Color color
null means "default color".
@NotNull private final FontID font
private final boolean italic
@NotNull private final java.lang.String text
private final boolean underline
private int underlineOffset
0 if
unknown.
| Constructor Detail |
|---|
public TextSegment(@NotNull
java.lang.String text,
boolean bold,
boolean italic,
boolean underline,
@NotNull
FontID font,
@Nullable
java.awt.Color color)
text - The text to display.bold - Whether bold face is enabled.italic - Whether italic face is enabled.underline - Whether underlining is enabled.font - The font to use.color - The color to use; null means "default color".| Method Detail |
|---|
public void draw(@NotNull
java.awt.Graphics g,
int y,
@NotNull
Fonts fonts)
Graphics instance.
g - the graphics to draw toy - the y-coordinate to draw tofonts - the fonts to use
@NotNull
private java.awt.Font getFont(@NotNull
Fonts fonts)
Font to use for a given Segment.
fonts - The Fonts instance to use.
@NotNull
public java.awt.geom.RectangularShape getSize(@NotNull
Fonts fonts,
@NotNull
java.awt.font.FontRenderContext context)
fonts - the fonts instance to usecontext - the font render context to use
@NotNull public java.lang.String getText()
public boolean matches(boolean bold,
boolean italic,
boolean underline,
@NotNull
FontID font,
@Nullable
java.awt.Color color)
bold - the bold attributeitalic - the italic attributeunderline - the underline attributefont - the font attributecolor - the color attribute
@NotNull public java.lang.String toString()
toString in class java.lang.Object
public void updateAttributes(@NotNull
Fonts fonts,
@NotNull
java.awt.font.FontRenderContext context)
fonts - the fonts instance to usecontext - the font render context to use