00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 package com.realtime.crossfire.jxclient.skin.io;
00023
00024 import com.realtime.crossfire.jxclient.gui.gui.AbstractGUIElement;
00025 import com.realtime.crossfire.jxclient.gui.gui.GUIElement;
00026 import com.realtime.crossfire.jxclient.gui.label.AbstractLabel;
00027 import com.realtime.crossfire.jxclient.gui.textinput.GUIText;
00028 import com.realtime.crossfire.jxclient.skin.skin.JXCSkinCache;
00029 import com.realtime.crossfire.jxclient.skin.skin.JXCSkinException;
00030 import org.jetbrains.annotations.NotNull;
00031
00036 public class GuiElementParser {
00037
00041 @NotNull
00042 private final JXCSkinCache<AbstractGUIElement> definedGUIElements;
00043
00048 public GuiElementParser(@NotNull final JXCSkinCache<AbstractGUIElement> definedGUIElements) {
00049 this.definedGUIElements = definedGUIElements;
00050 }
00051
00058 @NotNull
00059 public GUIText lookupTextElement(@NotNull final String name) throws JXCSkinException {
00060 final Object element = definedGUIElements.lookup(name);
00061 if (!(element instanceof GUIText)) {
00062 throw new JXCSkinException("element "+name+" is not a text field");
00063 }
00064
00065 return (GUIText)element;
00066 }
00067
00074 @NotNull
00075 public AbstractLabel lookupLabelElement(@NotNull final String name) throws JXCSkinException {
00076 final Object element = definedGUIElements.lookup(name);
00077 if (!(element instanceof AbstractLabel)) {
00078 throw new JXCSkinException("element "+name+" is not a label");
00079 }
00080
00081 return (AbstractLabel)element;
00082 }
00083
00084 }