Crossfire JXClient, Trunk  R20561
GUILabelLog.java
Go to the documentation of this file.
1 /*
2  * This file is part of JXClient, the Fullscreen Java Crossfire Client.
3  *
4  * JXClient is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * JXClient is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with JXClient; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * Copyright (C) 2005-2008 Yann Chachkoff.
19  * Copyright (C) 2006-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.gui.log;
23 
26 import java.awt.Color;
27 import java.awt.Image;
28 import org.jetbrains.annotations.NotNull;
29 import org.jetbrains.annotations.Nullable;
30 
35 public class GUILabelLog extends GUILog {
36 
40  private static final long serialVersionUID = 1;
41 
45  @NotNull
46  private final Parser parser = new Parser();
47 
51  @NotNull
52  private final Color defaultColor;
53 
65  public GUILabelLog(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @Nullable final Image backgroundImage, @NotNull final Fonts fonts, @NotNull final Color defaultColor) {
66  super(tooltipManager, elementListener, name, backgroundImage, fonts);
67  this.defaultColor = defaultColor;
68  }
69 
74  public void updateText(@NotNull final CharSequence string) {
75  final Buffer buffer = getBuffer();
76  buffer.clear();
77  parser.parse(string, defaultColor, buffer);
78  scrollTo(0);
79  }
80 
81 }
void scrollTo(final int pos)
Scrolls to the given location.The possible range is given by a previous notification through a listen...
Definition: GUILog.java:226
final Color defaultColor
The default color to use for text message not specifying a color.
GUILabelLog(@NotNull final TooltipManager tooltipManager, @NotNull final GUIElementListener elementListener, @NotNull final String name, @Nullable final Image backgroundImage, @NotNull final Fonts fonts, @NotNull final Color defaultColor)
Creates a new instance.
final TooltipManager tooltipManager
The TooltipManager to update.
static final long serialVersionUID
The serial version UID.
void clear()
Clears all lines from the buffer.
Definition: Buffer.java:147
Parser for parsing drawextinfo messages received from a Crossfire server to update a Buffer instance...
Definition: Parser.java:37
final GUIElementListener elementListener
The GUIElementListener to notify.
void updateText(@NotNull final CharSequence string)
Sets the displayed text by parsing a string.
A gui element implementing a static text field which may contain media tags.
final Image backgroundImage
The background image drawn below the text contents.
Definition: GUILog.java:77
final Fonts fonts
The Fonts instance for looking up fonts.
Definition: GUILog.java:83
Buffer getBuffer()
Returns the Buffer instance containing the text messages.
Definition: GUILog.java:251
Manages the contents of the contents of a log window.
Definition: Buffer.java:41
final Buffer buffer
The Buffer containing all received text messages.
Definition: GUILog.java:70
void parse(@NotNull final CharSequence text, @Nullable final Color defaultColor, @NotNull final Buffer buffer)
Parses a text message.
Definition: Parser.java:111
final Parser parser
The Parser instance for parsing drawextinfo messages.
Abstract base class for gui elements implementing text fields.
Definition: GUILog.java:48