Crossfire JXClient, Trunk
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
com.realtime.crossfire.jxclient.gui.log.Buffer Class Referenceabstract
Inheritance diagram for com.realtime.crossfire.jxclient.gui.log.Buffer:
Inheritance graph
Collaboration diagram for com.realtime.crossfire.jxclient.gui.log.Buffer:
Collaboration graph

Public Member Functions

void addBufferListener (@NotNull final BufferListener listener)
 
void addLine (@NotNull final Line line)
 
void addTextSegment (@NotNull final Line line, @NotNull final String text, final boolean bold, final boolean italic, final boolean underline, @NotNull final FontID fontID, @NotNull final Color color, @NotNull final Color selectionColor)
 
void clear ()
 
int coordinateToPosition (final int x, final int y)
 
int getLastCount ()
 
Line getLine (final int line)
 
Object getSyncObject ()
 
String getText (final int beginSelection, final int endSelection)
 
int getTotalHeight ()
 
Iterable< Linelines (final int line)
 
boolean mergeLines (@NotNull final String text, final int type, final int subtype, @Nullable final Color color)
 
void prune ()
 
void removeBufferListener (@NotNull final BufferListener listener)
 
void replaceLine (@NotNull final Line line)
 
void setRenderWidth (final int renderWidth)
 
void setShowSentCommands (final boolean showSentCommands)
 
void setShowTimestamps (final boolean showTimestamps)
 
int size ()
 

Protected Member Functions

 Buffer (final int maxLines, final int renderWidth)
 
abstract int getSegmentWidth (@NotNull final TextSegment segment, final int characters)
 
abstract TextSegment newTextSegment (@NotNull final String text, final boolean bold, final boolean italic, final boolean underline, @NotNull final FontID fontID, @NotNull final Color color, @NotNull final Color selectionColor)
 

Private Member Functions

void layoutLines ()
 

Private Attributes

Color lastColor
 
int lastCount
 
int lastSubtype = -1
 
String lastText = ""
 
int lastType = -1
 
final List< Linelines = new CopyOnWriteArrayList<>()
 
final EventListenerList2< BufferListenerlisteners = new EventListenerList2<>()
 
final int maxLines
 
int renderWidth
 
boolean showSentCommands
 
boolean showTimestamps
 
final Object sync = new Object()
 
int totalHeight
 

Detailed Description

Manages the contents of the contents of a log window. It consists of a list of Lines.

Author
Andreas Kirschbaum

Definition at line 41 of file Buffer.java.

Constructor & Destructor Documentation

◆ Buffer()

com.realtime.crossfire.jxclient.gui.log.Buffer.Buffer ( final int  maxLines,
final int  renderWidth 
)
protected

Creates a new instance.

Parameters
maxLinesthe maximum number of lines the buffer can hold
renderWidththe width to render

Definition at line 119 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.maxLines, and com.realtime.crossfire.jxclient.gui.log.Buffer.renderWidth.

Member Function Documentation

◆ addBufferListener()

void com.realtime.crossfire.jxclient.gui.log.Buffer.addBufferListener ( @NotNull final BufferListener  listener)

◆ addLine()

void com.realtime.crossfire.jxclient.gui.log.Buffer.addLine ( @NotNull final Line  line)

◆ addTextSegment()

void com.realtime.crossfire.jxclient.gui.log.Buffer.addTextSegment ( @NotNull final Line  line,
@NotNull final String  text,
final boolean  bold,
final boolean  italic,
final boolean  underline,
@NotNull final FontID  fontID,
@NotNull final Color  color,
@NotNull final Color  selectionColor 
)

Appends a TextSegment to the end of a line.

Parameters
linethe line
textthe text to display
boldwhether bold face is enabled
italicwhether italic face is enabled
underlinewhether underlining is enabled
fontIDthe font to use
colorthe color to use
selectionColorthe selection color to use

Definition at line 389 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.newTextSegment().

Here is the call graph for this function:

◆ clear()

void com.realtime.crossfire.jxclient.gui.log.Buffer.clear ( )

◆ coordinateToPosition()

int com.realtime.crossfire.jxclient.gui.log.Buffer.coordinateToPosition ( final int  x,
final int  y 
)

◆ getLastCount()

int com.realtime.crossfire.jxclient.gui.log.Buffer.getLastCount ( )

Returns the number of merged lines. Should not be called unless directly after mergeLines(String, int, int, Color) did return

true

.

Returns
the number of merged lines

Definition at line 360 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.lastCount.

◆ getLine()

Line com.realtime.crossfire.jxclient.gui.log.Buffer.getLine ( final int  line)

Returns one Line by line index. The first line has the index

0

.

Parameters
linethe line index
Returns
the line

Definition at line 265 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.lines, and com.realtime.crossfire.jxclient.gui.log.Buffer.sync.

◆ getSegmentWidth()

abstract int com.realtime.crossfire.jxclient.gui.log.Buffer.getSegmentWidth ( @NotNull final TextSegment  segment,
final int  characters 
)
abstractprotected

Returns the width of a prefix of a TextSegment.

Parameters
segmentthe text segment
charactersthe number of characters in the prefix
Returns
the width in pixels

Reimplemented in com.realtime.crossfire.jxclient.gui.log.DefaultBuffer, and com.realtime.crossfire.jxclient.gui.log.TestBuffer.

Referenced by com.realtime.crossfire.jxclient.gui.log.Buffer.coordinateToPosition().

Here is the caller graph for this function:

◆ getSyncObject()

Object com.realtime.crossfire.jxclient.gui.log.Buffer.getSyncObject ( )

Returns the object to synchronize on when calling lines(int).

Returns
the object

Definition at line 327 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.sync.

Referenced by com.realtime.crossfire.jxclient.gui.log.ParserTest.Rec.dumpBuffer(), and com.realtime.crossfire.jxclient.gui.log.GUILog.paintComponent().

Here is the caller graph for this function:

◆ getText()

String com.realtime.crossfire.jxclient.gui.log.Buffer.getText ( final int  beginSelection,
final int  endSelection 
)

Returns the selected text.

Parameters
beginSelectionthe first selected character
endSelectionthe first character after the selection
Returns
the selected text

Definition at line 454 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Line.appendSelection(), com.realtime.crossfire.jxclient.gui.log.Line.getEndPosition(), com.realtime.crossfire.jxclient.gui.log.Line.getStartPosition(), com.realtime.crossfire.jxclient.gui.log.Line.isVisible(), com.realtime.crossfire.jxclient.gui.log.Buffer.lines, com.realtime.crossfire.jxclient.gui.log.Buffer.showSentCommands, and com.realtime.crossfire.jxclient.gui.log.Buffer.sync.

Referenced by com.realtime.crossfire.jxclient.gui.log.GUILog.copy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTotalHeight()

int com.realtime.crossfire.jxclient.gui.log.Buffer.getTotalHeight ( )

◆ layoutLines()

void com.realtime.crossfire.jxclient.gui.log.Buffer.layoutLines ( )
private

◆ lines()

Iterable<Line> com.realtime.crossfire.jxclient.gui.log.Buffer.lines ( final int  line)

Returns an Iterator for the lines in this buffer.

Parameters
linethe initial line index of the list iterator
Returns
the list iterator

Definition at line 287 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.lines, and com.realtime.crossfire.jxclient.gui.log.Buffer.sync.

◆ mergeLines()

boolean com.realtime.crossfire.jxclient.gui.log.Buffer.mergeLines ( @NotNull final String  text,
final int  type,
final int  subtype,
@Nullable final Color  color 
)

Checks whether a new text line should be merged with a preceding line.

Parameters
textthe text line contents
typethe message type
subtypethe message subtype
colorthe text line color
Returns
whether the line should be merged

Definition at line 339 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.lastColor, com.realtime.crossfire.jxclient.gui.log.Buffer.lastCount, com.realtime.crossfire.jxclient.gui.log.Buffer.lastSubtype, com.realtime.crossfire.jxclient.gui.log.Buffer.lastText, and com.realtime.crossfire.jxclient.gui.log.Buffer.lastType.

◆ newTextSegment()

abstract TextSegment com.realtime.crossfire.jxclient.gui.log.Buffer.newTextSegment ( @NotNull final String  text,
final boolean  bold,
final boolean  italic,
final boolean  underline,
@NotNull final FontID  fontID,
@NotNull final Color  color,
@NotNull final Color  selectionColor 
)
abstractprotected

Creates a new segment.

Parameters
textthe text to display
boldwhether bold face is enabled
italicwhether italic face is enabled
underlinewhether underlining is enabled
fontIDthe font to use
colorthe color to use
selectionColorthe selection color to use
Returns
the new segment

Reimplemented in com.realtime.crossfire.jxclient.gui.log.DefaultBuffer, and com.realtime.crossfire.jxclient.gui.log.TestBuffer.

Referenced by com.realtime.crossfire.jxclient.gui.log.Buffer.addTextSegment().

Here is the caller graph for this function:

◆ prune()

void com.realtime.crossfire.jxclient.gui.log.Buffer.prune ( )

◆ removeBufferListener()

void com.realtime.crossfire.jxclient.gui.log.Buffer.removeBufferListener ( @NotNull final BufferListener  listener)

Removes a listener to be notified of changes.

Parameters
listenerthe listener

Definition at line 318 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.listeners.

Referenced by com.realtime.crossfire.jxclient.gui.log.RenderStateManager.dispose(), and com.realtime.crossfire.jxclient.gui.log.GUILog.dispose().

Here is the caller graph for this function:

◆ replaceLine()

void com.realtime.crossfire.jxclient.gui.log.Buffer.replaceLine ( @NotNull final Line  line)

◆ setRenderWidth()

void com.realtime.crossfire.jxclient.gui.log.Buffer.setRenderWidth ( final int  renderWidth)

Updates the width to render.

Parameters
renderWidththe width to render

Definition at line 132 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.layoutLines(), com.realtime.crossfire.jxclient.gui.log.Buffer.renderWidth, and com.realtime.crossfire.jxclient.gui.log.Buffer.sync.

Referenced by com.realtime.crossfire.jxclient.gui.log.GUILog.setBounds().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setShowSentCommands()

void com.realtime.crossfire.jxclient.gui.log.Buffer.setShowSentCommands ( final boolean  showSentCommands)

Sets whether commands sent to the server are shown.

Parameters
showSentCommandswhether commands sent to the server are shown

Definition at line 147 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.layoutLines(), com.realtime.crossfire.jxclient.gui.log.Buffer.showSentCommands, and com.realtime.crossfire.jxclient.gui.log.Buffer.sync.

Referenced by com.realtime.crossfire.jxclient.gui.log.GUILog.setShowSentCommands().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setShowTimestamps()

void com.realtime.crossfire.jxclient.gui.log.Buffer.setShowTimestamps ( final boolean  showTimestamps)

Sets whether timestamps are shown.

Parameters
showTimestampswhether timestamps are shown

Definition at line 162 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.layoutLines(), com.realtime.crossfire.jxclient.gui.log.Buffer.showTimestamps, and com.realtime.crossfire.jxclient.gui.log.Buffer.sync.

Referenced by com.realtime.crossfire.jxclient.gui.log.RenderStateTestRec.RenderStateTestRec(), and com.realtime.crossfire.jxclient.gui.log.GUILog.setShowTimestamps().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

int com.realtime.crossfire.jxclient.gui.log.Buffer.size ( )

Returns the number of lines.

Returns
the number of lines

Definition at line 300 of file Buffer.java.

References com.realtime.crossfire.jxclient.gui.log.Buffer.lines, and com.realtime.crossfire.jxclient.gui.log.Buffer.sync.

Referenced by com.realtime.crossfire.jxclient.gui.log.DefaultBuffer.newTextSegment().

Here is the caller graph for this function:

Member Data Documentation

◆ lastColor

Color com.realtime.crossfire.jxclient.gui.log.Buffer.lastColor
private

The color of the previously added line of text.

Definition at line 96 of file Buffer.java.

Referenced by com.realtime.crossfire.jxclient.gui.log.Buffer.clear(), and com.realtime.crossfire.jxclient.gui.log.Buffer.mergeLines().

◆ lastCount

int com.realtime.crossfire.jxclient.gui.log.Buffer.lastCount
private

◆ lastSubtype

int com.realtime.crossfire.jxclient.gui.log.Buffer.lastSubtype = -1
private

The message subtype of the previously added line of text.

Definition at line 90 of file Buffer.java.

Referenced by com.realtime.crossfire.jxclient.gui.log.Buffer.clear(), and com.realtime.crossfire.jxclient.gui.log.Buffer.mergeLines().

◆ lastText

String com.realtime.crossfire.jxclient.gui.log.Buffer.lastText = ""
private

The contents of the previously added line of text.

Definition at line 102 of file Buffer.java.

Referenced by com.realtime.crossfire.jxclient.gui.log.Buffer.clear(), and com.realtime.crossfire.jxclient.gui.log.Buffer.mergeLines().

◆ lastType

int com.realtime.crossfire.jxclient.gui.log.Buffer.lastType = -1
private

The message type of the previously added line of text.

Definition at line 85 of file Buffer.java.

Referenced by com.realtime.crossfire.jxclient.gui.log.Buffer.clear(), and com.realtime.crossfire.jxclient.gui.log.Buffer.mergeLines().

◆ lines

final List<Line> com.realtime.crossfire.jxclient.gui.log.Buffer.lines = new CopyOnWriteArrayList<>()
private

◆ listeners

final EventListenerList2<BufferListener> com.realtime.crossfire.jxclient.gui.log.Buffer.listeners = new EventListenerList2<>()
private

◆ maxLines

final int com.realtime.crossfire.jxclient.gui.log.Buffer.maxLines
private

◆ renderWidth

int com.realtime.crossfire.jxclient.gui.log.Buffer.renderWidth
private

◆ showSentCommands

boolean com.realtime.crossfire.jxclient.gui.log.Buffer.showSentCommands
private

◆ showTimestamps

boolean com.realtime.crossfire.jxclient.gui.log.Buffer.showTimestamps
private

◆ sync

final Object com.realtime.crossfire.jxclient.gui.log.Buffer.sync = new Object()
private

◆ totalHeight

int com.realtime.crossfire.jxclient.gui.log.Buffer.totalHeight
private

The documentation for this class was generated from the following file: