Is there any way to remove the attribute “type” since the type could be automatically detected based on the Field?
It likely could be done, well… Flloat, Integer, Long, etc may be an issue… but since they never change when editing the files, I’m not sure if the effort would be wirth it.
What were your thoughts behind it?
Hmm… Why would Float, Integer, Long be an issue? If the Integer is bigger then Integer.MaxValue it is a Long. Float you would have to rule out the Integer and Long first then it must be a Float. Or you could rely on the parse/valueOf methods but I wouldn’t.
I didn’t look into how you were doing it, I should’ve though so let me do that and get back to you. It will probably be tomorrow after work. Having a kid doesn’t give you a boat load of time.
Okay quick review of your LayoutParser#parseNodeList. The way you parse the layout is not something I would’ve done. You already store the Class to grab the “type” from instead what I would’ve done is have serializers for those class’s fields. This way you can easily extract the type information from that field when either loading/saving because you have the Class stored.
So the process for loading would go:
- Register classes to a Map (custom controls also) Map will contain [key/value] of [alias(String)/Class]
- For Root Node we will get the element name and look up the different aliases
- If alias found grab the Map value (Class) and proceed to the next node
- With child node grab the element name which should correspond with a field name in the Root Node Class
- The “value” of the element can then be converted based on the corresponding Field#type
For arrays you would just do a check for Class#isArray and check for a “count” attribute.
I could write up a different version that uses reflection but only if you feel it would be beneficial. It earliest I could get it done by is Thursday.
I am always open to suggestions… especially when someone else wants to do the work However, I’m still not sure what benefit this will have. Trust me when I say, you’ll find shit ALL throughout the library you would have done differently… Hell, half of it I would have done differently now =) But! It’s easy to use has very few (if any) show stopping quirks. This isn’t to say I wouldn’t want to improve it… not by any stretch, but I think you’ll find stuff as you go through it that would benefit from change more than how the style map is parsed.
Still! If you have a reason why it would be beneficial… I’m all ear! (Not literally… I have other parts too. Hard to type with ears and such)
EDIT: For instance… lately, I’ve been trying to figure out how I could potentially batch objects, at least for UI’s using a texture atlas. But, considering all objects could be potentially non-static… I’ve been struggling to find a way that would be beneficial. Now this is something I could use some help with! hint, hint!
EDIT 2: Also, keep in mind, the entire library was written over the course of a couple months. And there was no defined “this library will consist of” before starting. Isn’t the best approach to design… I know… but I had a need and this is what I ended up with in the end.
I updated my post see above. I am mostly interested in improving the embedding portion. I have to admit that one of the show stoppers is having to go through a ridiculous amount of XML to figure out what goes where (Nifty, TWL). Class based node parsing is so much easier because you can compare it to the class. Also makes creating UI builders so much more easier.
@squizzle said: I updated my post see above. I am mostly interested in improving the embedding portion. I have to admit that one of the show stoppers is having to go through a ridiculous amount of XML to figure out what goes where (Nifty, TWL). Class based node parsing is so much easier because you can compare it to the class. Also makes creating UI builders so much more easier.
I’ll definitely admit, I HATE having to go look up where I defined something. It’s quite a bit of crap to go through. But, I only find myself doing this when either a) Setting up a new L&F or b) writing a new control. Which (fortunately) is a very small fraction of the time I spend working with the UI library.
Still… if there is a way of simplifying this process that wouldn’t impact people who currently use it, I’m all for it.
EDIT 2: Also, keep in mind, the entire library was written over the course of a couple months. And there was no defined "this library will consist of" before starting. Isn't the best approach to design... I know... but I had a need and this is what I ended up with in the end.Believe it or not that is how most projects get started is because there is a need. There was definitely a need for a faster alternative to bulky Nifty. I don't understand why they thought it was a good choice for JME. It is horribly slow and takes a crap on your FPS.
@t0neg0d said: I'll definitely admit, I HATE having to go look up where I defined something. It's quite a bit of crap to go through. But, I only find myself doing this when either a) Setting up a new L&F or b) writing a new control. Which (fortunately) is a very small fraction of the time I spend working with the UI library.The XML redo I can program to use “OldLayout” and “NewLayout” or something along those lines to keep backwards compatibility. That isn’t a problem.Still… if there is a way of simplifying this process that wouldn’t impact people who currently use it, I’m all for it.
The password control… /sigh I semi-regret the way this was done, but the TextField is some 2000 lines of code (which is partially broke at the moment due to having to disable Clipboard usage because of incompatibility issues with Android. i.e. the entire application crashes if you add the import).
The last thing in the world I wanted was to have to have to versions of the control, so I disabled it for now. Since the password fielld is nothing more than a TextField with a character mask, updating the control would be… a feat… to say the least.
I recently applied a fix to TextField, I’m still having nightmares about tracking down where the problem was
But… I’m rambling, mostly because I have a long list of things that need to be updated, starting with some basics in Element… like how docking is applied is terrible. It works, but I have NO CLUE what I was thinking when I did it. It could have been a simple enum containing the only four options there are, but I had to take the long, difficult, I-can’t-understand-what-I-was-thinking approach.
Eventually all of this will get fixed.
And, yes… Nifty is a bear… much better than it was, but still a big PITA. It was the reason I wrote this in the first place. It actually had more to do with everyone being indecisive as to whether or not JME would allow Nifty to consume all events… and after the 3rd time it changed, I gave up.
SLOW DOWN… one thing at a time… don’t overwhelm yourself. You might get bummed out on it, if you do then progress will suffer.
Sorry… hubby got home from work and wanted to spend some time with him before he went to bed.
Overwhelmed… yep… that about sums it up
So, does this mean I have a real developer that is willing to help me get this under control?
A bit about me, so you have a better understanding of why thing are in the state they are (not that it is ghastly, but why some things are implemented in ways you might find less than desirable):
- I am not a dev by trade… I’m a wife & a mom. (This is my full-time job & likely explains most of it)
- I’m able to spend a lot of time working on different projects when all is well at home (unfortunately, this isn’t always the case and I get dragged away from it for a week-or two at a time. If you’re a parent, then I’m sure you can understand this-many don’t)
Ok… now that you know my… how was it put… “tragic” life-story, I’d REALLY appreciate the help getting this “cleaned up”, especially in any way that might help improve performance.
I’m open to just about any changes, improvements, etc… as long as they follow a couple basic ideas, these are:
- The common constructor idea… to me, this was key in making the library easy to use.
- Any changes/updates do not change the current API in a way that will break peoples existing code. (I, for one, believe backwards capability trumps feature creep… but hey, who am I?)
And those are really the only things I’m interested in preserving.
I know you have a life & are using JME for personal projects… BUT! If you have any time, Isure would appreciate the help.
Oh… also note: You will not become very popular befriending me hahaha. I’m not necessarily “liked” around these parts
Trust me I understand the stress demon spawn can bring into your life. I can contribute, I won’t call myself a partner in crime because I would hate to let you down when personal life demands my time.
I really couldn’t care if I am liked or disliked. I am not here for either. I use JME to squeeze the knowledge out of my brain and into code. I experiment doing things better then other people (open source is wrapped around this ideology) like the AssetManager… I made my own abstract version for JME and libgdx because theirs pissed me off. I HATE assetkeys with a passion they are pointless extra memory objects that add another layer to loading assets. But that is another topic.
You are liked you got your own forum for your gui that should say something. That you are a contributor which is close to being a developer.
@squizzle said: Trust me I understand the stress demon spawn can bring into your life. I can contribute, I won't call myself a partner in crime because I would hate to let you down when personal life demands my time.I really couldn’t care if I am liked or disliked. I am not here for either. I use JME to squeeze the knowledge out of my brain and into code. I experiment doing things better then other people (open source is wrapped around this ideology) like the AssetManager… I made my own abstract version for JME and libgdx because theirs pissed me off. I HATE assetkeys with a passion they are pointless extra memory objects that add another layer to loading assets. But that is another topic.
You are liked you got your own forum for your gui that should say something. That you are a contributor which is close to being a developer.
Actually… I would never put any expectation on you… I’m the last person to not understand when life gets the better of someone.
But, it would be nice have someone else (with a broader set of dev skills than my own) making an effort towards bettering the project!
I’m going to start compiling a list of the thing I am aware of, as a starting point of “places of interest”. This isn’t to say “ake this work better”, it’s just to let know what I am (and am not) aware of.
Patch below for simple performance changes. Some of the files were changed with the “automatic format on save” option.
[java]Index: src/tonegod/gui/core/utils/XMLHelper.java
— src/tonegod/gui/core/utils/XMLHelper.java (revision 448)
+++ src/tonegod/gui/core/utils/XMLHelper.java (working copy)
@@ -1,3 +1,4 @@
+
package tonegod.gui.core.utils;
import org.w3c.dom.Element;
@@ -8,24 +9,35 @@
*
-
@author t0neg0d
*/
-public class XMLHelper {
+public class XMLHelper
+{
- public static String getNodeText(Node parentNode, String nodeName) {
-
Element fstElmnt = (Element) parentNode;
-
NodeList fstNmElmntLst = fstElmnt.getElementsByTagName(nodeName);
-
Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
-
NodeList fstNm = fstNmElmnt.getChildNodes();
-
String ret = ((Node) fstNm.item(0)).getNodeValue();
-
return ret;
- }
- public static String getNodeText(Node parentNode, String nodeName)
- {
- Element fstElmnt = (Element) parentNode;
- NodeList fstNmElmntLst = fstElmnt.getElementsByTagName(nodeName);
- Element fstNmElmnt = (Element) fstNmElmntLst.item(0);
- NodeList fstNm = fstNmElmnt.getChildNodes();
- String ret = ((Node) fstNm.item(0)).getNodeValue();
- return ret;
- }
- public static String getNodeText(Node node) {
-
NodeList fstNm = ((Element)node).getChildNodes();
-
String ret = ((Node) fstNm.item(0)).getNodeValue();
-
return ret;
- public static String getNodeText(Node node)
- {
- NodeList fstNm = ((Element) node).getChildNodes();
- String ret = ((Node) fstNm.item(0)).getNodeValue();
- return ret;
- }
- public static String getNodeAttributeValue(Node node, String attributeName)
- {
- try
- {
-
return ((Element) node).getAttribute(attributeName);
- } catch (Exception ex)
- {
-
}return null;
- }
- public static String getNodeAttributeValue(Node node, String attributeName) {
-
return ((Element)node).getAttribute(attributeName);
- }
}
Index: src/tonegod/gui/style/LayoutParser.java
===================================================================
— src/tonegod/gui/style/LayoutParser.java (revision 448)
+++ src/tonegod/gui/style/LayoutParser.java (working copy)
@@ -2,6 +2,7 @@
- To change this template, choose Tools | Templates
- and open the template in the editor.
*/
package tonegod.gui.style;
import com.jme3.app.state.AbstractAppState;
@@ -64,1067 +65,1711 @@
*
-
@author t0neg0d
*/
-public class LayoutParser {
-
Screen screen;
-
AbstractAppState state;
-
List<Class> controls = new ArrayList();
-
public LayoutParser(Screen screen) {
-
this.screen = screen;
-
controls.add(OSRViewPort.class);
-
controls.add(Indicator.class);
-
controls.add(Slider.class);
-
controls.add(Dial.class);
-
controls.add(CheckBox.class);
-
controls.add(RadioButton.class);
-
controls.add(Button.class);
-
controls.add(ChatBox.class);
-
controls.add(ChatBoxExt.class);
-
controls.add(Panel.class);
-
controls.add(ColorWheel.class);
-
controls.add(LoginBox.class);
-
controls.add(AlertBox.class);
-
controls.add(DialogBox.class);
-
controls.add(Window.class);
-
controls.add(TabControl.class);
-
controls.add(SelectBox.class);
-
controls.add(ComboBox.class);
-
controls.add(Menu.class);
-
controls.add(SelectList.class);
-
controls.add(ScrollArea.class);
-
controls.add(SlideTray.class);
-
controls.add(Spinner.class);
-
controls.add(Label.class);
-
controls.add(Password.class);
-
controls.add(TextField.class);
-
}
-
public void parseLayout(String filePath, AbstractAppState state) {
-
this.state = state;
-
try {
-
// Get Cursors
+public class LayoutParser
+{
+
- Screen screen;
- AbstractAppState state;
- List<Class> controls = new ArrayList();
- public LayoutParser(Screen screen)
- {
- this.screen = screen;
- controls.add(OSRViewPort.class);
- controls.add(Indicator.class);
- controls.add(Slider.class);
- controls.add(Dial.class);
- controls.add(CheckBox.class);
- controls.add(RadioButton.class);
- controls.add(Button.class);
- controls.add(ChatBox.class);
- controls.add(ChatBoxExt.class);
- controls.add(Panel.class);
- controls.add(ColorWheel.class);
- controls.add(LoginBox.class);
- controls.add(AlertBox.class);
- controls.add(DialogBox.class);
- controls.add(Window.class);
- controls.add(TabControl.class);
- controls.add(SelectBox.class);
- controls.add(ComboBox.class);
- controls.add(Menu.class);
- controls.add(SelectList.class);
- controls.add(ScrollArea.class);
- controls.add(SlideTray.class);
- controls.add(Spinner.class);
- controls.add(Label.class);
- controls.add(Password.class);
- controls.add(TextField.class);
- }
- public void parseLayout(String filePath, AbstractAppState state)
- {
- this.state = state;
- try
- {
-
// Get Cursors /*
-
InputStream file = Screen.class.getClassLoader().getResourceAsStream(
-
filePath
-
);
-
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-
DocumentBuilder db = dbf.newDocumentBuilder();
-
Document doc = db.parse(file);
-
doc.getDocumentElement().normalize();
-
*/
-
Document doc = screen.getApplication().getAssetManager().loadAsset(new AssetKey<Document>(filePath));
-
if (doc == null) {
-
throw new AssetNotFoundException(String.format("Could not find style %s", filePath));
-
}
-
NodeList screenNodeLst = doc.getElementsByTagName("screen");
-
org.w3c.dom.Node screenNode = screenNodeLst.item(0);
-
NodeList nodeLst = screenNode.getChildNodes();
-
parseNodeList(nodeLst, null);
-
doc = null;
-
} catch (Exception e) {
-
e.printStackTrace();
-
}
-
}
-
private void parseNodeList(NodeList nodeLst, Element el) {
-
for (int s = 0; s < nodeLst.getLength(); s++) {
-
org.w3c.dom.Node fstNode = nodeLst.item(s);
-
if (fstNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (fstNode.getNodeName().equals("component")) {
-
String type, id, pos, dim, rsb, img, ori, flag;
-
type = XMLHelper.getNodeAttributeValue(fstNode, "type");
-
try { id = XMLHelper.getNodeAttributeValue(fstNode, "id"); } catch (NoSuchElementException ex) { id = UIDUtil.getUID(); }
-
try { pos = XMLHelper.getNodeAttributeValue(fstNode, "position"); } catch (NoSuchElementException ex) { pos = null; }
-
try { dim = XMLHelper.getNodeAttributeValue(fstNode, "dimensions"); } catch (NoSuchElementException ex) { dim = null; }
-
try { rsb = XMLHelper.getNodeAttributeValue(fstNode, "resizeBorders"); } catch (NoSuchElementException ex) { rsb = null; }
-
try { img = XMLHelper.getNodeAttributeValue(fstNode, "defaultImg"); } catch (NoSuchElementException ex) { img = null; }
-
try { ori = XMLHelper.getNodeAttributeValue(fstNode, "orientation"); } catch (NoSuchElementException ex) { ori = null; }
-
try { flag = XMLHelper.getNodeAttributeValue(fstNode, "tracSurroundsThumb"); } catch (NoSuchElementException ex) { flag = null; }
-
if (flag == null) {
-
try { flag = XMLHelper.getNodeAttributeValue(fstNode, "isScrollable"); } catch (NoSuchElementException ex) { flag = null; }
-
}
-
if (flag == null) {
-
try { flag = XMLHelper.getNodeAttributeValue(fstNode, "cycle"); } catch (NoSuchElementException ex) { flag = null; }
-
}
-
NodeList childNodes = fstNode.getChildNodes();
-
Element element = null;
-
Class cl = null;
-
for (Class c : controls) {
-
if (c.getName().substring(c.getName().lastIndexOf(".")+1).equals(type)) {
-
element = createElement(el, c, id, pos, dim, rsb, img, ori, flag, childNodes);
-
cl = c;
-
break;
-
}
-
}
-
parseMethods(childNodes, element, cl);
-
parseNodeList(childNodes, element);
-
parseEffects(childNodes, element);
-
if (el == null) screen.addElement(element);
-
else el.addChild(element);
-
}
-
}
-
}
-
}
-
private void parseMethods(NodeList childNodes, Element el, Class c) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("method")) {
-
String name = XMLHelper.getNodeAttributeValue(childNode, "name");
-
parseParamters(el,c,name,childNode);
-
}
-
}
-
}
-
}
-
private void parseParamters(Element el, Class c, String name, org.w3c.dom.Node childNode) {
-
try {
-
Method method = null;
-
Class<?> clazz = c;
-
while (method == null) {
-
Method[] methods = clazz.getDeclaredMethods();
-
for (Method m : methods) {
-
if (m.getName().equals(name)) {
-
method = m;
-
break;
-
}
-
}
-
clazz = clazz.getSuperclass();
-
if (clazz == Object.class)
-
break;
-
}
-
if (method != null) {
-
method.setAccessible(true);
-
Class<?>[] params = method.getParameterTypes();
-
Object[] finalParams = new Object[params.length];
-
int index = 0;
-
for (Class paramClass : params) {
-
if (paramClass == Integer.class || paramClass == Integer.TYPE) {
-
finalParams[index] = Integer.parseInt(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == Float.class || paramClass == Float.TYPE) {
-
finalParams[index] = Float.parseFloat(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == String.class) {
-
finalParams[index] = XMLHelper.getNodeAttributeValue(childNode, "param" + index);
-
} else if (paramClass == Object.class) {
-
finalParams[index] = (Object)XMLHelper.getNodeAttributeValue(childNode, "param" + index);
-
} else if (paramClass == Boolean.class || paramClass == Boolean.TYPE) {
-
finalParams[index] = Boolean.parseBoolean(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == Menu.class) {
-
finalParams[index] = (Menu)screen.getElementById(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == BitmapFont.Align.class) {
-
finalParams[index] = BitmapFont.Align.valueOf(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == BitmapFont.VAlign.class) {
-
finalParams[index] = BitmapFont.VAlign.valueOf(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == LineWrapMode.class) {
-
finalParams[index] = LineWrapMode.valueOf(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == TextField.Type.class) {
-
finalParams[index] = TextField.Type.valueOf(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == ColorRGBA.class) {
-
finalParams[index] = parseColorRGBA(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == Vector2f.class) {
-
finalParams[index] = parseVector2f(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == Vector3f.class) {
-
finalParams[index] = parseVector3f(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == Vector4f.class) {
-
finalParams[index] = parseVector4f(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
}
-
index++;
-
}
-
method.invoke(c.cast(el), finalParams);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
public Method getMethod(Class<?> clazz, String name) {
-
System.out.println(name + " : " + clazz.getName());
-
Method m = null;
-
try {
-
m = clazz.getDeclaredMethod(name);
-
System.out.println(m);
-
// System.out.println("Hello:");
-
// if (m == null)
-
// m = getMethod(clazz.getSuperclass(), name);
-
// else {
-
// if (clazz == Object.class) {
-
// return null;
-
// } else {
-
// return getMethod(clazz.getSuperclass(), name);
-
// }
-
// }
-
} catch (Exception e) {
-
try {
-
m = getMethod(clazz.getSuperclass(), name);
-
} catch (Exception ex) { }
-
// if (clazz != Object.class)
-
// return getMethod(clazz.getSuperclass(), name);
-
}
-
return m;
-
// Class<?> c = clazz.getSuperclass();
-
// System.out.println(c);
-
// return m;
-
InputStream file = Screen.class.getClassLoader().getResourceAsStream(
-
filePath
-
);
-
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-
DocumentBuilder db = dbf.newDocumentBuilder();
-
Document doc = db.parse(file);
-
doc.getDocumentElement().normalize();
-
*/
-
Document doc = screen.getApplication().getAssetManager().loadAsset(new AssetKey<Document>(filePath));
-
if (doc == null)
-
{
-
throw new AssetNotFoundException(String.format("Could not find style %s", filePath));
-
}
-
NodeList screenNodeLst = doc.getElementsByTagName("screen");
-
org.w3c.dom.Node screenNode = screenNodeLst.item(0);
-
NodeList nodeLst = screenNode.getChildNodes();
-
parseNodeList(nodeLst, null);
-
doc = null;
- } catch (Exception e)
- {
-
e.printStackTrace();
- }
}
-
private Element createElement(Element el, Class c, String id, String pos, String dim, String rsb, String img, String ori, String flag, final NodeList childNodes) {
-
Vector2f position, dimensions;
-
Vector4f resizeBorders;
-
String styleName = "";
-
String className = c.getName().substring(c.getName().lastIndexOf(".")+1);
-
styleName = className;
-
if (className.equals("ComboBox")) styleName = "TextField";
-
if (className.equals("TabControl") ||
-
className.equals("LoginBox") ||
-
className.equals("DialogBox") ||
-
className.equals("AlertBox") ||
-
className.equals("ChatBox") ||
-
className.equals("ChatBoxExt") ||
-
className.equals("OSRViewPort")) styleName = "Window";
-
position = parsePositionalVector2f(pos, el);
-
if (dim == null || dim.equals("")) dimensions = screen.getStyle(styleName).getVector2f("defaultSize");
-
else dimensions = parsePositionalVector2f(dim, el);
-
if (className.equals("ColorWheel")) styleName = "Window";
-
if (rsb == null || rsb.equals("")) try { resizeBorders = screen.getStyle(styleName).getVector4f("resizeBorders"); } catch (Exception e) { resizeBorders = Vector4f.ZERO; }
-
else resizeBorders = parseVector4f(rsb);
-
if (img == null || img.equals("")) try { img = screen.getStyle(styleName).getString("defaultImg"); } catch (Exception e) { img = null; };
-
if (className.equals("Label")) {
-
return new Label(screen, id, position, dimensions, resizeBorders, img);
-
} else if (className.equals("OSRViewPort")) {
-
return new OSRViewPort(screen, id, position, dimensions, resizeBorders, img);
-
} else if (className.equals("Spinner")) {
-
Spinner.Orientation orientation = Spinner.Orientation.valueOf(ori);
-
Boolean bool = Boolean.parseBoolean(flag);
-
return new Spinner(screen, id, position, dimensions, resizeBorders, img, orientation, bool) {
-
@Override
-
public void onChange(int selectedIndex, String value) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), selectedIndex, value);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("Slider")) {
-
Slider.Orientation orientation = Slider.Orientation.valueOf(ori);
-
Boolean bool = Boolean.parseBoolean(flag);
-
return new Slider(screen, id, position, dimensions, resizeBorders, img, orientation, bool) {
-
@Override
-
public void onChange(int selectedIndex, Object value) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), selectedIndex, value);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("Dial")) {
-
return new Dial(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onChange(int selectedIndex, Object value) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), selectedIndex, value);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("TextField")) {
-
return new TextField(screen, id, position, dimensions, resizeBorders, img);
-
} else if (className.equals("Password")) {
-
return new Password(screen, id, position, dimensions, resizeBorders, img);
-
} else if (className.equals("ColorWheel")) {
-
return new ColorWheel(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onChange(ColorRGBA color) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), color);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onComplete(ColorRGBA color) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onComplete")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), color);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("Indicator")) {
-
Indicator.Orientation orientation = Indicator.Orientation.valueOf(ori);
-
return new Indicator(screen, id, position, dimensions, resizeBorders, img, orientation) {
-
@Override
-
public void onChange(float currentValue, float currentPercentage) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), currentValue, currentPercentage);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("Window")) {
-
return new Window(screen, id, position, dimensions, resizeBorders, img);
-
} else if (className.equals("SlideTray")) {
-
SlideTray.Orientation orientation = SlideTray.Orientation.valueOf(ori);
-
return new SlideTray(screen, id, position, dimensions, resizeBorders, img, orientation);
-
} else if (className.equals("Panel")) {
-
return new Panel(screen, id, position, dimensions, resizeBorders, img);
-
} else if (className.equals("TabControl")) {
-
return new TabControl(screen, id, position, dimensions, resizeBorders, img);
-
} else if (className.equals("ChatBox")) {
-
return new ChatBox(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onSendMsg(String msg) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onSendMsg")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), msg);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("ChatBoxExt")) {
-
return new ChatBoxExt(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onSendMsg(Object command, String msg) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onSendMsg")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), command, msg);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("LoginBox")) {
-
return new LoginBox(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onButtonCancelPressed(MouseButtonEvent evt, boolean toggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonCancelPressed")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, toggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonLoginPressed(MouseButtonEvent evt, boolean toggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonLoginPressed")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, toggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("AlertBox")) {
-
return new AlertBox(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onButtonOkPressed(MouseButtonEvent evt, boolean toggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonOkPressed")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, toggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("DialogBox")) {
-
return new DialogBox(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onButtonCancelPressed(MouseButtonEvent evt, boolean toggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonCancelPressed")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, toggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonOkPressed(MouseButtonEvent evt, boolean toggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonOkPressed")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, toggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("SelectBox")) {
-
return new SelectBox(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onChange(int selectedIndex, Object value) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), selectedIndex, value);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("ComboBox")) {
-
return new ComboBox(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onChange(int selectedIndex, Object value) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), selectedIndex, value);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("SelectList")) {
-
return new SelectList(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onChange() {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state));
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("Menu")) {
-
Boolean bool = Boolean.parseBoolean(flag);
-
return new Menu(screen, id, position, dimensions, resizeBorders, img, bool) {
-
@Override
-
public void onMenuItemClicked(int index, Object value, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onMenuItemClicked")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), index, value, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("Button")) {
-
return new ButtonAdapter(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onButtonMouseLeftDown(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftDown")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftUp")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightDown(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightDown")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightUp(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightUp")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonFocus(MouseMotionEvent evt) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonFocus")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonLostFocus(MouseMotionEvent evt) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonLostFocus")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("CheckBox")) {
-
return new CheckBox(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onButtonMouseLeftDown(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftDown")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftUp")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightDown(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightDown")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightUp(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightUp")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonFocus(MouseMotionEvent evt) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonFocus")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonLostFocus(MouseMotionEvent evt) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonLostFocus")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("RadioButton")) {
-
return new RadioButton(screen, id, position, dimensions, resizeBorders, img) {
-
@Override
-
public void onButtonMouseLeftDown(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftDown")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftUp")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightDown(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightDown")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightUp(MouseButtonEvent evt, boolean isToggled) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightUp")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonFocus(MouseMotionEvent evt) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonFocus")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonLostFocus(MouseMotionEvent evt) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("eventMethod")) {
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonLostFocus")) {
-
try {
-
for (Method method : state.getClass().getDeclaredMethods()) {
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
} catch (Exception ex) { ex.printStackTrace(); }
-
}
-
}
-
}
-
}
-
}
-
};
-
} else if (className.equals("ScrollArea")) {
-
return new ScrollAreaAdapter(screen, id, position, dimensions, resizeBorders, img);
-
} else
-
return new Element(screen, id, position, dimensions, resizeBorders, img);
-
}
-
private void parseEffects(NodeList childNodes, Element el) {
-
for (int n = 0; n < childNodes.getLength(); n++) {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
-
if (childNode.getNodeName().equals("effect")) {
-
Effect.EffectType type = Effect.EffectType.valueOf(XMLHelper.getNodeAttributeValue(childNode, "type"));
-
Effect.EffectEvent event = Effect.EffectEvent.valueOf(XMLHelper.getNodeAttributeValue(childNode, "event"));
-
float duration = Float.parseFloat(XMLHelper.getNodeAttributeValue(childNode, "duration"));
-
Effect effect = new Effect(type, event, duration);
-
switch(type) {
-
case ImageSwap:
-
case Pulse:
-
String imagePath = XMLHelper.getNodeAttributeValue(childNode, "blendImage");
-
Texture tex = screen.getApplication().getAssetManager().loadTexture(imagePath);
-
tex.setMagFilter(Texture.MagFilter.Bilinear);
-
tex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
-
tex.setWrap(Texture.WrapMode.Repeat);
-
effect.setBlendImage(tex);
-
break;
-
case ColorSwap:
-
case PulseColor:
-
effect.setColor(parseColorRGBA(XMLHelper.getNodeAttributeValue(childNode, "color")));
-
break;
-
case SlideIn:
-
case SlideOut:
-
effect.setEffectDirection(Effect.EffectDirection.valueOf(XMLHelper.getNodeAttributeValue(childNode, "direction")));
-
break;
-
case SlideTo:
-
effect.setEffectDestination(parseVector2f(XMLHelper.getNodeAttributeValue(childNode, "destination")));
-
break;
-
}
-
String audioFile = XMLHelper.getNodeAttributeValue(childNode, "audioFile");
-
if (!audioFile.equals("")) effect.setAudioFile(audioFile);
-
float audioVolume = 1;
-
try { audioVolume = Float.parseFloat(XMLHelper.getNodeAttributeValue(childNode, "volume")); } catch (Exception exa) { audioVolume = 1; }
-
effect.setAudioVolume(audioVolume);
-
el.addEffect(effect);
-
}
-
}
-
}
-
}
-
private Vector2f parsePositionalVector2f(String str, Element el) {
-
StringTokenizer st;
-
float x, y, z, w;
-
st = new StringTokenizer(str,",");
-
String xComp = st.nextToken();
-
String yComp = st.nextToken();
-
if (el == null) {
-
if (xComp.indexOf("%") != -1) x = screen.getWidth()*(Float.parseFloat(xComp.substring(0,xComp.indexOf("%")))*0.01f);
-
else x = Float.parseFloat(xComp);
-
if (yComp.indexOf("%") != -1) y = screen.getHeight()*(Float.parseFloat(yComp.substring(0,yComp.indexOf("%")))*0.01f);
-
else y = Float.parseFloat(yComp);
-
} else {
-
if (xComp.indexOf("%") != -1) x = el.getWidth()*(Float.parseFloat(xComp.substring(0,xComp.indexOf("%")))*0.01f);
-
else x = Float.parseFloat(xComp);
-
if (yComp.indexOf("%") != -1) y = el.getHeight()*(Float.parseFloat(yComp.substring(0,yComp.indexOf("%")))*0.01f);
-
else y = Float.parseFloat(yComp);
-
}
-
return new Vector2f(x,y);
-
}
-
private Vector2f parseVector2f(String str) {
-
StringTokenizer st;
-
float x, y, z, w;
- private void parseNodeList(NodeList nodeLst, Element el)
- {
- for (int s = 0; s < nodeLst.getLength(); s++)
- {
-
org.w3c.dom.Node fstNode = nodeLst.item(s);
-
if (fstNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (fstNode.getNodeName().equals("component"))
-
{
-
String type, id, pos, dim, rsb, img, ori, flag;
-
type = XMLHelper.getNodeAttributeValue(fstNode, "type");
-
id = XMLHelper.getNodeAttributeValue(fstNode, "id");
-
if (id == null)
-
{
-
id = UIDUtil.getUID();
-
}
-
pos = XMLHelper.getNodeAttributeValue(fstNode, "position");
-
dim = XMLHelper.getNodeAttributeValue(fstNode, "dimensions");
-
rsb = XMLHelper.getNodeAttributeValue(fstNode, "resizeBorders");
-
img = XMLHelper.getNodeAttributeValue(fstNode, "defaultImg");
-
ori = XMLHelper.getNodeAttributeValue(fstNode, "orientation");
-
flag = XMLHelper.getNodeAttributeValue(fstNode, "tracSurroundsThumb");
-
if (flag == null)
-
{
-
try
-
{
-
flag = XMLHelper.getNodeAttributeValue(fstNode, "isScrollable");
-
} catch (NoSuchElementException ex)
-
{
-
flag = null;
-
}
-
}
-
if (flag == null)
-
{
-
flag = XMLHelper.getNodeAttributeValue(fstNode, "cycle");
-
}
-
st = new StringTokenizer(str,",");
-
String xComp = st.nextToken();
-
String yComp = st.nextToken();
-
x = Float.parseFloat(xComp);
-
y = Float.parseFloat(yComp);
-
return new Vector2f(x,y);
-
}
-
private Vector3f parseVector3f(String str) {
-
StringTokenizer st;
-
float x, y, z;
-
NodeList childNodes = fstNode.getChildNodes();
-
Element element = null;
-
Class cl = null;
-
st = new StringTokenizer(str,",");
-
String xComp = st.nextToken();
-
String yComp = st.nextToken();
-
String zComp = st.nextToken();
-
x = Float.parseFloat(xComp);
-
y = Float.parseFloat(yComp);
-
z = Float.parseFloat(zComp);
-
return new Vector3f(x,y,z);
-
}
-
private Vector4f parseVector4f(String str) {
-
StringTokenizer st;
-
float x, y, z, w;
-
for (Class c : controls)
-
{
-
if (c.getName().substring(c.getName().lastIndexOf(".") + 1).equals(type))
-
{
-
element = createElement(el, c, id, pos, dim, rsb, img, ori, flag, childNodes);
-
cl = c;
-
break;
-
}
-
}
-
st = new StringTokenizer(str,",");
-
String xComp = st.nextToken();
-
String yComp = st.nextToken();
-
String zComp = st.nextToken();
-
String wComp = st.nextToken();
-
x = Float.parseFloat(xComp);
-
y = Float.parseFloat(yComp);
-
z = Float.parseFloat(zComp);
-
w = Float.parseFloat(wComp);
-
return new Vector4f(x,y,z,w);
-
}
-
private ColorRGBA parseColorRGBA(String str) {
-
StringTokenizer st;
-
float x, y, z, w;
-
parseMethods(childNodes, element, cl);
-
parseNodeList(childNodes, element);
-
parseEffects(childNodes, element);
-
st = new StringTokenizer(str,",");
-
String xComp = st.nextToken();
-
String yComp = st.nextToken();
-
String zComp = st.nextToken();
-
String wComp = st.nextToken();
-
x = Float.parseFloat(xComp);
-
y = Float.parseFloat(yComp);
-
z = Float.parseFloat(zComp);
-
w = Float.parseFloat(wComp);
-
return new ColorRGBA(x,y,z,w);
-
}
-
if (el == null)
-
{
-
screen.addElement(element);
-
} else
-
{
-
el.addChild(element);
-
}
-
}
-
}
- }
- }
- private void parseMethods(NodeList childNodes, Element el, Class c)
- {
- for (int n = 0; n < childNodes.getLength(); n++)
- {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("method"))
-
{
-
String name = XMLHelper.getNodeAttributeValue(childNode, "name");
-
parseParamters(el, c, name, childNode);
-
}
-
}
- }
- }
- private void parseParamters(Element el, Class c, String name, org.w3c.dom.Node childNode)
- {
- try
- {
-
Method method = null;
-
Class<?> clazz = c;
-
while (method == null)
-
{
-
Method[] methods = clazz.getDeclaredMethods();
-
for (Method m : methods)
-
{
-
if (m.getName().equals(name))
-
{
-
method = m;
-
break;
-
}
-
}
-
clazz = clazz.getSuperclass();
-
if (clazz == Object.class)
-
{
-
break;
-
}
-
}
-
if (method != null)
-
{
-
method.setAccessible(true);
-
Class<?>[] params = method.getParameterTypes();
-
Object[] finalParams = new Object[params.length];
-
int index = 0;
-
for (Class paramClass : params)
-
{
-
if (paramClass == Integer.class || paramClass == Integer.TYPE)
-
{
-
finalParams[index] = Integer.parseInt(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == Float.class || paramClass == Float.TYPE)
-
{
-
finalParams[index] = Float.parseFloat(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == String.class)
-
{
-
finalParams[index] = XMLHelper.getNodeAttributeValue(childNode, "param" + index);
-
} else if (paramClass == Object.class)
-
{
-
finalParams[index] = (Object) XMLHelper.getNodeAttributeValue(childNode, "param" + index);
-
} else if (paramClass == Boolean.class || paramClass == Boolean.TYPE)
-
{
-
finalParams[index] = Boolean.parseBoolean(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == Menu.class)
-
{
-
finalParams[index] = (Menu) screen.getElementById(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == BitmapFont.Align.class)
-
{
-
finalParams[index] = BitmapFont.Align.valueOf(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == BitmapFont.VAlign.class)
-
{
-
finalParams[index] = BitmapFont.VAlign.valueOf(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == LineWrapMode.class)
-
{
-
finalParams[index] = LineWrapMode.valueOf(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == TextField.Type.class)
-
{
-
finalParams[index] = TextField.Type.valueOf(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == ColorRGBA.class)
-
{
-
finalParams[index] = parseColorRGBA(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == Vector2f.class)
-
{
-
finalParams[index] = parseVector2f(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == Vector3f.class)
-
{
-
finalParams[index] = parseVector3f(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
} else if (paramClass == Vector4f.class)
-
{
-
finalParams[index] = parseVector4f(XMLHelper.getNodeAttributeValue(childNode, "param" + index));
-
}
-
index++;
-
}
-
method.invoke(c.cast(el), finalParams);
-
}
- } catch (Exception ex)
- {
-
ex.printStackTrace();
- }
- }
- public Method getMethod(Class<?> clazz, String name)
- {
- System.out.println(name + " : " + clazz.getName());
- Method m = null;
- try
- {
-
m = clazz.getDeclaredMethod(name);
-
//System.out.println(m);
-
// System.out.println("Hello:");
-
// if (m == null)
-
// m = getMethod(clazz.getSuperclass(), name);
-
// else {
-
// if (clazz == Object.class) {
-
// return null;
-
// } else {
-
// return getMethod(clazz.getSuperclass(), name);
-
// }
-
// }
- } catch (Exception e)
- {
-
try
-
{
-
m = getMethod(clazz.getSuperclass(), name);
-
} catch (Exception ex)
-
{
-
}
-
// if (clazz != Object.class)
-
// return getMethod(clazz.getSuperclass(), name);
- }
- return m;
- // Class<?> c = clazz.getSuperclass();
- // System.out.println©;
- // return m;
- }
- private Element createElement(Element el, Class c, String id, String pos, String dim, String rsb, String img, String ori, String flag, final NodeList childNodes)
- {
- Vector2f position, dimensions;
- Vector4f resizeBorders;
- String styleName = “”;
- String className = c.getName().substring(c.getName().lastIndexOf(".") + 1);
- styleName = className;
- if (className.equals(“ComboBox”))
- {
-
styleName = "TextField";
- }
- if (className.equals(“TabControl”)
-
|| className.equals("LoginBox")
-
|| className.equals("DialogBox")
-
|| className.equals("AlertBox")
-
|| className.equals("ChatBox")
-
|| className.equals("ChatBoxExt")
-
|| className.equals("OSRViewPort"))
- {
-
styleName = "Window";
- }
- position = parsePositionalVector2f(pos, el);
- if (dim == null || dim.equals(""))
- {
-
dimensions = screen.getStyle(styleName).getVector2f("defaultSize");
- } else
- {
-
dimensions = parsePositionalVector2f(dim, el);
- }
- if (className.equals(“ColorWheel”))
- {
-
styleName = "Window";
- }
- if (rsb == null || rsb.equals(""))
- {
-
try
-
{
-
resizeBorders = screen.getStyle(styleName).getVector4f("resizeBorders");
-
} catch (Exception e)
-
{
-
resizeBorders = Vector4f.ZERO;
-
}
- } else
- {
-
resizeBorders = parseVector4f(rsb);
- }
- if (img == null || img.equals(""))
- {
-
try
-
{
-
img = screen.getStyle(styleName).getString("defaultImg");
-
} catch (Exception e)
-
{
-
img = null;
-
}
- };
- if (className.equals(“Label”))
- {
-
return new Label(screen, id, position, dimensions, resizeBorders, img);
- } else if (className.equals(“OSRViewPort”))
- {
-
return new OSRViewPort(screen, id, position, dimensions, resizeBorders, img);
- } else if (className.equals(“Spinner”))
- {
-
Spinner.Orientation orientation = Spinner.Orientation.valueOf(ori);
-
Boolean bool = Boolean.parseBoolean(flag);
-
return new Spinner(screen, id, position, dimensions, resizeBorders, img, orientation, bool)
-
{
-
@Override
-
public void onChange(int selectedIndex, String value)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), selectedIndex, value);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“Slider”))
- {
-
Slider.Orientation orientation = Slider.Orientation.valueOf(ori);
-
Boolean bool = Boolean.parseBoolean(flag);
-
return new Slider(screen, id, position, dimensions, resizeBorders, img, orientation, bool)
-
{
-
@Override
-
public void onChange(int selectedIndex, Object value)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), selectedIndex, value);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“Dial”))
- {
-
return new Dial(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onChange(int selectedIndex, Object value)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), selectedIndex, value);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“TextField”))
- {
-
return new TextField(screen, id, position, dimensions, resizeBorders, img);
- } else if (className.equals(“Password”))
- {
-
return new Password(screen, id, position, dimensions, resizeBorders, img);
- } else if (className.equals(“ColorWheel”))
- {
-
return new ColorWheel(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onChange(ColorRGBA color)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), color);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onComplete(ColorRGBA color)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onComplete"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), color);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“Indicator”))
- {
-
Indicator.Orientation orientation = Indicator.Orientation.valueOf(ori);
-
return new Indicator(screen, id, position, dimensions, resizeBorders, img, orientation)
-
{
-
@Override
-
public void onChange(float currentValue, float currentPercentage)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), currentValue, currentPercentage);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“Window”))
- {
-
return new Window(screen, id, position, dimensions, resizeBorders, img);
- } else if (className.equals(“SlideTray”))
- {
-
SlideTray.Orientation orientation = SlideTray.Orientation.valueOf(ori);
-
return new SlideTray(screen, id, position, dimensions, resizeBorders, img, orientation);
- } else if (className.equals(“Panel”))
- {
-
return new Panel(screen, id, position, dimensions, resizeBorders, img);
- } else if (className.equals(“TabControl”))
- {
-
return new TabControl(screen, id, position, dimensions, resizeBorders, img);
- } else if (className.equals(“ChatBox”))
- {
-
return new ChatBox(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onSendMsg(String msg)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onSendMsg"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), msg);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“ChatBoxExt”))
- {
-
return new ChatBoxExt(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onSendMsg(Object command, String msg)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onSendMsg"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), command, msg);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“LoginBox”))
- {
-
return new LoginBox(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onButtonCancelPressed(MouseButtonEvent evt, boolean toggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonCancelPressed"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, toggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonLoginPressed(MouseButtonEvent evt, boolean toggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonLoginPressed"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, toggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“AlertBox”))
- {
-
return new AlertBox(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onButtonOkPressed(MouseButtonEvent evt, boolean toggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonOkPressed"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, toggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“DialogBox”))
- {
-
return new DialogBox(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onButtonCancelPressed(MouseButtonEvent evt, boolean toggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonCancelPressed"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, toggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonOkPressed(MouseButtonEvent evt, boolean toggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonOkPressed"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, toggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“SelectBox”))
- {
-
return new SelectBox(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onChange(int selectedIndex, Object value)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), selectedIndex, value);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“ComboBox”))
- {
-
return new ComboBox(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onChange(int selectedIndex, Object value)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), selectedIndex, value);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“SelectList”))
- {
-
return new SelectList(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onChange()
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onChange"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state));
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“Menu”))
- {
-
Boolean bool = Boolean.parseBoolean(flag);
-
return new Menu(screen, id, position, dimensions, resizeBorders, img, bool)
-
{
-
@Override
-
public void onMenuItemClicked(int index, Object value, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onMenuItemClicked"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), index, value, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“Button”))
- {
-
return new ButtonAdapter(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onButtonMouseLeftDown(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftDown"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftUp"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightDown(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightDown"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightUp(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightUp"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonFocus(MouseMotionEvent evt)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonFocus"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonLostFocus(MouseMotionEvent evt)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonLostFocus"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“CheckBox”))
- {
-
return new CheckBox(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onButtonMouseLeftDown(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftDown"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftUp"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightDown(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightDown"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightUp(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightUp"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonFocus(MouseMotionEvent evt)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonFocus"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonLostFocus(MouseMotionEvent evt)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonLostFocus"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“RadioButton”))
- {
-
return new RadioButton(screen, id, position, dimensions, resizeBorders, img)
-
{
-
@Override
-
public void onButtonMouseLeftDown(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftDown"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseLeftUp(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseLeftUp"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightDown(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightDown"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonMouseRightUp(MouseButtonEvent evt, boolean isToggled)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonMouseRightUp"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt, isToggled);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonFocus(MouseMotionEvent evt)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonFocus"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
@Override
-
public void onButtonLostFocus(MouseMotionEvent evt)
-
{
-
for (int n = 0; n < childNodes.getLength(); n++)
-
{
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("eventMethod"))
-
{
-
if (XMLHelper.getNodeAttributeValue(childNode, "name").equals("onButtonLostFocus"))
-
{
-
try
-
{
-
for (Method method : state.getClass().getDeclaredMethods())
-
{
-
if (method.getName().equals(XMLHelper.getNodeAttributeValue(childNode, "stateMethodName")))
-
{
-
method.invoke(state.getClass().cast(state), evt);
-
}
-
}
-
} catch (Exception ex)
-
{
-
ex.printStackTrace();
-
}
-
}
-
}
-
}
-
}
-
}
-
};
- } else if (className.equals(“ScrollArea”))
- {
-
return new ScrollAreaAdapter(screen, id, position, dimensions, resizeBorders, img);
- } else
- {
-
return new Element(screen, id, position, dimensions, resizeBorders, img);
- }
- }
- private void parseEffects(NodeList childNodes, Element el)
- {
- for (int n = 0; n < childNodes.getLength(); n++)
- {
-
org.w3c.dom.Node childNode = childNodes.item(n);
-
if (childNode.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE)
-
{
-
if (childNode.getNodeName().equals("effect"))
-
{
-
Effect.EffectType type = Effect.EffectType.valueOf(XMLHelper.getNodeAttributeValue(childNode, "type"));
-
Effect.EffectEvent event = Effect.EffectEvent.valueOf(XMLHelper.getNodeAttributeValue(childNode, "event"));
-
float duration = Float.parseFloat(XMLHelper.getNodeAttributeValue(childNode, "duration"));
-
Effect effect = new Effect(type, event, duration);
-
switch (type)
-
{
-
case ImageSwap:
-
case Pulse:
-
String imagePath = XMLHelper.getNodeAttributeValue(childNode, "blendImage");
-
Texture tex = screen.getApplication().getAssetManager().loadTexture(imagePath);
-
tex.setMagFilter(Texture.MagFilter.Bilinear);
-
tex.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
-
tex.setWrap(Texture.WrapMode.Repeat);
-
effect.setBlendImage(tex);
-
break;
-
case ColorSwap:
-
case PulseColor:
-
effect.setColor(parseColorRGBA(XMLHelper.getNodeAttributeValue(childNode, "color")));
-
break;
-
case SlideIn:
-
case SlideOut:
-
effect.setEffectDirection(Effect.EffectDirection.valueOf(XMLHelper.getNodeAttributeValue(childNode, "direction")));
-
break;
-
case SlideTo:
-
effect.setEffectDestination(parseVector2f(XMLHelper.getNodeAttributeValue(childNode, "destination")));
-
break;
-
}
-
String audioFile = XMLHelper.getNodeAttributeValue(childNode, "audioFile");
-
if (!audioFile.equals(""))
-
{
-
effect.setAudioFile(audioFile);
-
}
-
float audioVolume = 1;
-
try
-
{
-
audioVolume = Float.parseFloat(XMLHelper.getNodeAttributeValue(childNode, "volume"));
-
} catch (Exception exa)
-
{
-
audioVolume = 1;
-
}
-
effect.setAudioVolume(audioVolume);
-
el.addEffect(effect);
-
}
-
}
- }
- }
- private Vector2f parsePositionalVector2f(String str, Element el)
- {
- StringTokenizer st;
- float x, y, z, w;
- st = new StringTokenizer(str, “,”);
- String xComp = st.nextToken();
- String yComp = st.nextToken();
- if (el == null)
- {
-
if (xComp.indexOf("%") != -1)
-
{
-
x = screen.getWidth() * (Float.parseFloat(xComp.substring(0, xComp.indexOf("%"))) * 0.01f);
-
} else
-
{
-
x = Float.parseFloat(xComp);
-
}
-
if (yComp.indexOf("%") != -1)
-
{
-
y = screen.getHeight() * (Float.parseFloat(yComp.substring(0, yComp.indexOf("%"))) * 0.01f);
-
} else
-
{
-
y = Float.parseFloat(yComp);
-
}
- } else
- {
-
if (xComp.indexOf("%") != -1)
-
{
-
x = el.getWidth() * (Float.parseFloat(xComp.substring(0, xComp.indexOf("%"))) * 0.01f);
-
} else
-
{
-
x = Float.parseFloat(xComp);
-
}
-
if (yComp.indexOf("%") != -1)
-
{
-
y = el.getHeight() * (Float.parseFloat(yComp.substring(0, yComp.indexOf("%"))) * 0.01f);
-
} else
-
{
-
y = Float.parseFloat(yComp);
-
}
- }
- return new Vector2f(x, y);
- }
- private Vector2f parseVector2f(String str)
- {
- StringTokenizer st;
- float x, y, z, w;
- st = new StringTokenizer(str, “,”);
- String xComp = st.nextToken();
- String yComp = st.nextToken();
- x = Float.parseFloat(xComp);
- y = Float.parseFloat(yComp);
- return new Vector2f(x, y);
- }
- private Vector3f parseVector3f(String str)
- {
- StringTokenizer st;
- float x, y, z;
- st = new StringTokenizer(str, “,”);
- String xComp = st.nextToken();
- String yComp = st.nextToken();
- String zComp = st.nextToken();
- x = Float.parseFloat(xComp);
- y = Float.parseFloat(yComp);
- z = Float.parseFloat(zComp);
- return new Vector3f(x, y, z);
- }
- private Vector4f parseVector4f(String str)
- {
- StringTokenizer st;
- float x, y, z, w;
- st = new StringTokenizer(str, “,”);
- String xComp = st.nextToken();
- String yComp = st.nextToken();
- String zComp = st.nextToken();
- String wComp = st.nextToken();
- x = Float.parseFloat(xComp);
- y = Float.parseFloat(yComp);
- z = Float.parseFloat(zComp);
- w = Float.parseFloat(wComp);
- return new Vector4f(x, y, z, w);
- }
- private ColorRGBA parseColorRGBA(String str)
- {
- StringTokenizer st;
- float x, y, z, w;
- st = new StringTokenizer(str, “,”);
- String xComp = st.nextToken();
- String yComp = st.nextToken();
- String zComp = st.nextToken();
- String wComp = st.nextToken();
- x = Float.parseFloat(xComp);
- y = Float.parseFloat(yComp);
- z = Float.parseFloat(zComp);
- w = Float.parseFloat(wComp);
- return new ColorRGBA(x, y, z, w);
- }
}
\ No newline at end of file
[/java]
I can’t apply the patch due to the interpolateLocal calls. It’s a method that only exsists in nightly.
Updated the patch.
@squizzle said: Updated the patch.
My biggest dislike of the LayoutParser is the beginning where it populates the list of controls from the library.
Is there a way to replace this using reflection and grabbing any class that extends (or is) Element?
Should probably explain why I hate it =)
I forgot it was there >.< And it likely does not have any of the new controls (not sure how many have been added… likely only a few… but still)
Also, Paul Speed mentioned to me that this type of parser doesn’t make much sense without more “friendly” names, like:
[java]
<window width=“200” height=“200” x=“50” y=“40”>
<onClick call=“someMethod(etc, etc)” />
<show effect=“Blink” />
</window>
[/java]
I guess a shorthand, but holy crap… how would you maintain something like this for the amount of crap that is in this library?
EDIT: I can barely remember even a few of the xml tag params in styles =( Nevermind a whole shorthand reference for every control/function/effect/etc in the library.