Crossfire JXClient, Trunk  R20561
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-2011 Andreas Kirschbaum.
20  */
21 
22 package com.realtime.crossfire.jxclient.skin.io;
23 
31 import org.jetbrains.annotations.NotNull;
32 
37 public class GuiElementParser {
38 
42  @NotNull
44 
49  public GuiElementParser(@NotNull final JXCSkinCache<AbstractGUIElement> definedGUIElements) {
50  this.definedGUIElements = definedGUIElements;
51  }
52 
59  @NotNull
60  public GUIText lookupTextElement(@NotNull final String name) throws JXCSkinException {
61  final Object element = definedGUIElements.lookup(name);
62  if (!(element instanceof GUIText)) {
63  throw new JXCSkinException("element "+name+" is not a text field");
64  }
65 
66  return (GUIText)element;
67  }
68 
75  @NotNull
76  public AbstractLabel lookupLabelElement(@NotNull final String name) throws JXCSkinException {
77  final Object element = definedGUIElements.lookup(name);
78  if (!(element instanceof AbstractLabel)) {
79  throw new JXCSkinException("element "+name+" is not a label");
80  }
81 
82  return (AbstractLabel)element;
83  }
84 
91  @NotNull
92  public GUILabelLog lookupLabelLogElement(@NotNull final String name) throws JXCSkinException {
93  final Object element = definedGUIElements.lookup(name);
94  if (!(element instanceof GUILabelLog)) {
95  throw new JXCSkinException("element "+name+" is not a log_label");
96  }
97 
98  return (GUILabelLog)element;
99  }
100 
101 }
Abstract base class for all label classes.
GUIText lookupTextElement(@NotNull final String name)
Returns a GUIText by element name.
final JXCSkinCache< AbstractGUIElement > definedGUIElements
The defined GUIElements.
A gui element implementing a static text field which may contain media tags.
Interface defining an abstract GUI element.
Definition: GUIElement.java:32
GuiElementParser(@NotNull final JXCSkinCache< AbstractGUIElement > definedGUIElements)
Creates a new instance.
AbstractLabel lookupLabelElement(@NotNull final String name)
Returns a AbstractLabel by element name.
Implements a cache for elements identified by name.
Exception thrown if a skin related problem occurs.
Abstract base class for GUI elements to be shown in Guis.
Creates gui element instances from string representations.
GUILabelLog lookupLabelLogElement(@NotNull final String name)
Returns a AbstractLabel by element name.
T lookup(@NotNull final String name)
Looks up an element by name.
Abstract base class for text input fields.
Definition: GUIText.java:57