Crossfire JXClient, Trunk
src
gui
src
main
java
com
realtime
crossfire
jxclient
skin
io
GuiElementParser.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-2017,2019-2023 Andreas Kirschbaum
20
* Copyright (C) 2010-2012,2014-2018,2020-2023 Nicolas Weeger
21
*/
22
23
package
com.realtime.crossfire.jxclient.skin.io;
24
25
import
com
.
realtime
.
crossfire
.
jxclient
.
gui
.
gui
.
AbstractGUIElement
;
26
import
com
.
realtime
.
crossfire
.
jxclient
.
gui
.
gui
.
GUIElement
;
27
import
com
.
realtime
.
crossfire
.
jxclient
.
gui
.
label
.
AbstractLabel
;
28
import
com
.
realtime
.
crossfire
.
jxclient
.
gui
.
log
.
GUILabelLog
;
29
import
com
.
realtime
.
crossfire
.
jxclient
.
gui
.
textinput
.
GUIText
;
30
import
com
.
realtime
.
crossfire
.
jxclient
.
skin
.
skin
.
JXCSkinCache
;
31
import
com
.
realtime
.
crossfire
.
jxclient
.
skin
.
skin
.
JXCSkinException
;
32
import
org.jetbrains.annotations.NotNull;
33
38
public
class
GuiElementParser
{
39
43
@NotNull
44
private
final
JXCSkinCache<AbstractGUIElement>
definedGUIElements
;
45
50
public
GuiElementParser
(@NotNull
final
JXCSkinCache<AbstractGUIElement>
definedGUIElements
) {
51
this.definedGUIElements =
definedGUIElements
;
52
}
53
60
@NotNull
61
public
GUIText
lookupTextElement
(@NotNull
final
String name)
throws
JXCSkinException
{
62
final
Object element =
definedGUIElements
.lookup(name);
63
if
(!(element instanceof
GUIText
)) {
64
throw
new
JXCSkinException
(
"element "
+name+
" is not a text field"
);
65
}
66
67
return
(
GUIText
)element;
68
}
69
76
@NotNull
77
public
AbstractLabel
lookupLabelElement
(@NotNull
final
String name)
throws
JXCSkinException
{
78
final
Object element =
definedGUIElements
.lookup(name);
79
if
(!(element instanceof
AbstractLabel
)) {
80
throw
new
JXCSkinException
(
"element "
+name+
" is not a label"
);
81
}
82
83
return
(
AbstractLabel
)element;
84
}
85
92
@NotNull
93
public
GUILabelLog
lookupLabelLogElement
(@NotNull
final
String name)
throws
JXCSkinException
{
94
final
Object element =
definedGUIElements
.lookup(name);
95
if
(!(element instanceof
GUILabelLog
)) {
96
throw
new
JXCSkinException
(
"element "
+name+
" is not a log_label"
);
97
}
98
99
return
(
GUILabelLog
)element;
100
}
101
102
}
com.realtime.crossfire.jxclient
com.realtime.crossfire.jxclient.skin.skin
Definition:
DefaultJXCSkin.java:23
com.realtime.crossfire.jxclient.gui.label.AbstractLabel
Definition:
AbstractLabel.java:43
com.realtime.crossfire.jxclient.skin.io.GuiElementParser.lookupTextElement
GUIText lookupTextElement(@NotNull final String name)
Definition:
GuiElementParser.java:61
com.realtime.crossfire.jxclient.skin
com.realtime.crossfire.jxclient.gui.label
Definition:
AbstractLabel.java:23
com.realtime.crossfire.jxclient.gui.log.GUILabelLog
Definition:
GUILabelLog.java:38
com.realtime.crossfire.jxclient.gui.textinput
Definition:
ActivateCommandInputCommand.java:23
com.realtime.crossfire.jxclient.skin.skin.JXCSkinException
Definition:
JXCSkinException.java:31
com.realtime.crossfire.jxclient.gui.log
Definition:
Buffer.java:23
com.realtime.crossfire.jxclient.skin.io.GuiElementParser.definedGUIElements
final JXCSkinCache< AbstractGUIElement > definedGUIElements
Definition:
GuiElementParser.java:44
com.realtime.crossfire.jxclient.gui
com.realtime.crossfire.jxclient.skin.io.GuiElementParser.GuiElementParser
GuiElementParser(@NotNull final JXCSkinCache< AbstractGUIElement > definedGUIElements)
Definition:
GuiElementParser.java:50
com.realtime.crossfire.jxclient.skin.skin.JXCSkinCache
Definition:
JXCSkinCache.java:40
com.realtime.crossfire.jxclient.skin.io.GuiElementParser
Definition:
GuiElementParser.java:38
com.realtime.crossfire.jxclient.gui.gui.GUIElement
Definition:
GUIElement.java:33
com.realtime.crossfire.jxclient.gui.gui
Definition:
AbstractGUIElement.java:23
com.realtime.crossfire
com.realtime.crossfire.jxclient.gui.textinput.GUIText
Definition:
GUIText.java:61
com.realtime
com
com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement
Definition:
AbstractGUIElement.java:37
com.realtime.crossfire.jxclient.skin.io.GuiElementParser.lookupLabelElement
AbstractLabel lookupLabelElement(@NotNull final String name)
Definition:
GuiElementParser.java:77
com.realtime.crossfire.jxclient.skin.io.GuiElementParser.lookupLabelLogElement
GUILabelLog lookupLabelLogElement(@NotNull final String name)
Definition:
GuiElementParser.java:93
Generated by
1.8.17