com.realtime.crossfire.jxclient.gui.log
Class TextSegment

java.lang.Object
  extended by com.realtime.crossfire.jxclient.gui.log.AbstractSegment
      extended by com.realtime.crossfire.jxclient.gui.log.TextSegment
All Implemented Interfaces:
Segment

public class TextSegment
extends AbstractSegment

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

bold

private final boolean bold
Whether bold face is enabled.


color

@Nullable
private final java.awt.Color color
The color to use. null means "default color".


font

@NotNull
private final FontID font
The font to use.


italic

private final boolean italic
Whether italic face is enabled.


text

@NotNull
private final java.lang.String text
The text to display.


underline

private final boolean underline
Whether underlining is enabled.


underlineOffset

private int underlineOffset
The distance of the underline to the base line. Set to 0 if unknown.

Constructor Detail

TextSegment

public TextSegment(@NotNull
                   java.lang.String text,
                   boolean bold,
                   boolean italic,
                   boolean underline,
                   @NotNull
                   FontID font,
                   @Nullable
                   java.awt.Color color)
Create a new segment.

Parameters:
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

draw

public void draw(@NotNull
                 java.awt.Graphics g,
                 int y,
                 @NotNull
                 Fonts fonts)
Draws this segment to a Graphics instance.

Parameters:
g - the graphics to draw to
y - the y-coordinate to draw to
fonts - the fonts to use

getFont

@NotNull
private java.awt.Font getFont(@NotNull
                                      Fonts fonts)
Return the Font to use for a given Segment.

Parameters:
fonts - The Fonts instance to use.
Returns:
The font.

getSize

@NotNull
public java.awt.geom.RectangularShape getSize(@NotNull
                                                      Fonts fonts,
                                                      @NotNull
                                                      java.awt.font.FontRenderContext context)
Returns the size of this segment in pixels.

Parameters:
fonts - the fonts instance to use
context - the font render context to use
Returns:
the size

getText

@NotNull
public java.lang.String getText()
Return the text to display.

Returns:
The text to display.

matches

public boolean matches(boolean bold,
                       boolean italic,
                       boolean underline,
                       @NotNull
                       FontID font,
                       @Nullable
                       java.awt.Color color)
Returns whether this segment matches the given attributes.

Parameters:
bold - the bold attribute
italic - the italic attribute
underline - the underline attribute
font - the font attribute
color - the color attribute
Returns:
whether all attributes do match

toString

@NotNull
public java.lang.String toString()

Overrides:
toString in class java.lang.Object

updateAttributes

public void updateAttributes(@NotNull
                             Fonts fonts,
                             @NotNull
                             java.awt.font.FontRenderContext context)
Updates the cached attributes of this segment.

Parameters:
fonts - the fonts instance to use
context - the font render context to use