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

java.lang.Object
  extended by com.realtime.crossfire.jxclient.gui.log.Line
All Implemented Interfaces:
java.lang.Iterable<Segment>

public class Line
extends java.lang.Object
implements java.lang.Iterable<Segment>

Manages the contents of one text line. A text line consists of a sequence of Segments.


Field Summary
private  int height
          The total height of this line.
private  java.util.List<Segment> segments
          The segments this line consists of.
 
Constructor Summary
Line()
           
 
Method Summary
 void addSegment(java.lang.String text, boolean bold, boolean italic, boolean underline, FontID font, java.awt.Color color)
          Appends a Segment to the end of the line.
 int getHeight()
          Return the height of this line.
 Segment getLastSegment()
          Returns the last segment.
 java.util.Iterator<Segment> iterator()
          
 void removeLastSegment()
          Remove the last segment.
 void setHeight(int height)
          Return the height of this line.
 void updateAttributes(int begin, int end, int y, Fonts fonts, java.awt.font.FontRenderContext context)
          Update the cached attributes of some Segments.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

height

private int height
The total height of this line. Set to -1 if unknown.


segments

@NotNull
private final java.util.List<Segment> segments
The segments this line consists of. The first segment should be displayed first; subsequent segments are to be displayed without padding.

Constructor Detail

Line

public Line()
Method Detail

addSegment

public void addSegment(@NotNull
                       java.lang.String text,
                       boolean bold,
                       boolean italic,
                       boolean underline,
                       @NotNull
                       FontID font,
                       @Nullable
                       java.awt.Color color)
Appends a Segment to the end of the line.

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"

getHeight

public int getHeight()
Return the height of this line. Returns -1 until setHeight(int) was called.

Returns:
The height of this line.

getLastSegment

@Nullable
public Segment getLastSegment()
Returns the last segment.

Returns:
the last segment or null if the line is empty

iterator

@NotNull
public java.util.Iterator<Segment> iterator()

Specified by:
iterator in interface java.lang.Iterable<Segment>

removeLastSegment

public void removeLastSegment()
Remove the last segment. The line must not be empty.


setHeight

public void setHeight(int height)
Return the height of this line.

Parameters:
height - The height.

updateAttributes

public void updateAttributes(int begin,
                             int end,
                             int y,
                             @NotNull
                             Fonts fonts,
                             @NotNull
                             java.awt.font.FontRenderContext context)
Update the cached attributes of some Segments.

Parameters:
begin - The index of the first segment to update.
end - The index of the first segment not to update.
y - The top border of the line's bounding box.
fonts - the fonts instance to use
context - the font render context to use