java.lang.Objectcom.realtime.crossfire.jxclient.gui.log.Buffer
public class Buffer
Manages the contents of the contents of a log window. It consists of a list
 of Lines.
| Field Summary | |
|---|---|
private  java.awt.font.FontRenderContext | 
context
The FontRenderContext to use. | 
private  Fonts | 
fonts
The Fonts instance for looking up fonts. | 
private  java.awt.Color | 
lastColor
The color of the previously added line of text.  | 
private  int | 
lastCount
The number of repetitions of the previously added line of text.  | 
private  java.lang.String | 
lastText
The contents of the previously added line of text.  | 
private  java.util.List<Line> | 
lines
The lines in display order.  | 
private  java.util.Collection<BufferListener> | 
listeners
The listeners to notify about changes.  | 
static int | 
MAX_LINES
The maximum number of lines the buffer can hold.  | 
static int | 
MIN_LINE_HEIGHT
The minimal height of a line in pixels.  | 
private  int | 
renderWidth
The width to render.  | 
private  java.lang.Object | 
sync
Object to synchronized access to lines and totalHeight. | 
private  int | 
totalHeight
The total height of all lines. | 
| Constructor Summary | |
|---|---|
Buffer(Fonts fonts,
       java.awt.font.FontRenderContext context,
       int renderWidth)
Create a new instance.  | 
|
| Method Summary | |
|---|---|
 void | 
addBufferListener(BufferListener listener)
Add a listener to notify of changes.  | 
 void | 
addLine(Line line)
Append a Line to the end of the buffer. | 
private  int | 
calculateHeight(Line line)
Determine the height of a Line in pixels. | 
 void | 
clear()
Clear all lines from the buffer.  | 
 int | 
getLastCount()
Returns the number of merged lines.  | 
 Line | 
getLine(int line)
Return one Line by line index. | 
 java.lang.Object | 
getSyncObject()
Returns the object to synchronize on when calling iterator() or
 listIterator(int). | 
 int | 
getTotalHeight()
Return the total height of all lines.  | 
 java.util.Iterator<Line> | 
iterator()
Return an Iterator for the lines in this buffer. | 
 java.util.ListIterator<Line> | 
listIterator(int line)
Return a ListIterator for the lines in this buffer. | 
 boolean | 
mergeLines(java.lang.String text,
           java.awt.Color color)
Checks whether a new text line should be merged with a preceding line.  | 
 void | 
prune()
Prune excess lines.  | 
 void | 
removeBufferListener(BufferListener listener)
Removes a listener to be notified of changes.  | 
 void | 
replaceLine(Line line)
Replace the last Line of this buffer. | 
 void | 
setRenderWidth(int renderWidth)
Updates the width to render.  | 
 int | 
size()
Return the number of lines.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
@NotNull private final java.awt.font.FontRenderContext context
FontRenderContext to use.
@NotNull private final Fonts fonts
Fonts instance for looking up fonts.
@Nullable private java.awt.Color lastColor
private int lastCount
@NotNull private java.lang.String lastText
@NotNull private final java.util.List<Line> lines
@NotNull private final java.util.Collection<BufferListener> listeners
public static final int MAX_LINES
public static final int MIN_LINE_HEIGHT
private int renderWidth
@NotNull private final java.lang.Object sync
lines and totalHeight.
private int totalHeight
lines.
| Constructor Detail | 
|---|
public Buffer(@NotNull
              Fonts fonts,
              @NotNull
              java.awt.font.FontRenderContext context,
              int renderWidth)
fonts - The Fonts instance for looking up fonts.context - The FontRenderContext to use.renderWidth - The width to render.| Method Detail | 
|---|
public void addBufferListener(@NotNull
                              BufferListener listener)
listener - The listener.
public void addLine(@NotNull
                    Line line)
Line to the end of the buffer.
line - The line to append.
private int calculateHeight(@NotNull
                            Line line)
Line in pixels.
line - The line to process.
public void clear()
public int getLastCount()
mergeLines(String, Color) did freturn true.
@NotNull public Line getLine(int line)
Line by line index. The first line has the index
 0.
line - The line index.
@NotNull public java.lang.Object getSyncObject()
iterator() or
 listIterator(int).
public int getTotalHeight()
@NotNull public java.util.Iterator<Line> iterator()
Iterator for the lines in this buffer. The caller must
 hold sync's lock.
@NotNull public java.util.ListIterator<Line> listIterator(int line)
ListIterator for the lines in this buffer.
line - The initial line index of the list iterator.
public boolean mergeLines(@NotNull
                          java.lang.String text,
                          @Nullable
                          java.awt.Color color)
text - the text line contentscolor - the text line color
public void prune()
public void removeBufferListener(@NotNull
                                 BufferListener listener)
listener - the listener
public void replaceLine(@NotNull
                        Line line)
Line of this buffer.
line - The replacing line.public void setRenderWidth(int renderWidth)
renderWidth - the width to renderpublic int size()