Hello, my name is Thomas Enebo. I am a co-lead for JRuby project and I have been playing with JMonkeyEngine for a little while now. I am really enjoying myself too
You can look at progress of some of my experiments of using JME from JRuby here: http://kenai.com/projects/jrme
So one issue I had was that some of the API's are using a HashMap for their interfaces rather than a Map. Using a Map makes it much easier to integrate with JRuby and I suspect it probably makes a more flexible API since then you can use any Map implementation for properties. I think this change will have zero-impact on existing JME2 code since HashMaps are Maps…patch below:
Index: src/com/jme/input/thirdperson/ThirdPersonMouseLook.java
===================================================================
— src/com/jme/input/thirdperson/ThirdPersonMouseLook.java (revision 4361)
+++ src/com/jme/input/thirdperson/ThirdPersonMouseLook.java (working copy)
@@ -32,7 +32,7 @@
package com.jme.input.thirdperson;
-import java.util.HashMap;
+import java.util.Map;
import com.jme.input.ChaseCamera;
import com.jme.input.InputHandler;
@@ -127,7 +127,7 @@
* <code>updateProperties</code>
* @param props
/
- public void updateProperties(HashMap<String, Object> props) {
+ public void updateProperties(Map<String, Object> props) {
maxAscent = InputHandler.getFloatProp(props, PROP_MAXASCENT, DEFAULT_MAXASCENT);
minAscent = InputHandler.getFloatProp(props, PROP_MINASCENT, DEFAULT_MINASCENT);
maxRollOut = InputHandler.getFloatProp(props, PROP_MAXROLLOUT, DEFAULT_MAXROLLOUT);
Index: src/com/jme/input/ChaseCamera.java
===================================================================
— src/com/jme/input/ChaseCamera.java (revision 4361)
+++ src/com/jme/input/ChaseCamera.java (working copy)
@@ -32,7 +32,7 @@
package com.jme.input;
-import java.util.HashMap;
+import java.util.Map;
import com.jme.input.thirdperson.ThirdPersonMouseLook;
import com.jme.math.FastMath;
@@ -121,7 +121,7 @@
/**
* More involved constructor allowing the setting of all member fields in
- ChaseCamera and its associated ThirdPersonMouseLook object via a HashMap
+ * ChaseCamera and its associated ThirdPersonMouseLook object via a Map
* of properties.
*
* @param cam
@@ -133,7 +133,7 @@
* from the statics ChaseCamera.PROP_XXXX and
* ThirdPersonMouseLook.PROP_XXXX
*/
- public ChaseCamera(Camera cam, Spatial target, HashMap<String, Object> props) {
+ public ChaseCamera(Camera cam, Spatial target, Map<String, Object> props) {
super();
this.cam = cam;
this.target = target;
@@ -163,7 +163,7 @@
*
* @param props
*/
- public void updateProperties(HashMap<String, Object> props) {
+ public void updateProperties(Map<String, Object> props) {
if (mouseLook != null)
mouseLook.updateProperties(props);
Index: src/com/jme/input/InputHandler.java
===================================================================
— src/com/jme/input/InputHandler.java (revision 4361)
+++ src/com/jme/input/InputHandler.java (working copy)
@@ -443,7 +443,7 @@
}
- public static float getFloatProp( HashMap<String, Object> props, String key, float defaultVal ) {
+ public static float getFloatProp( Map<String, Object> props, String key, float defaultVal ) {
if ( props == null || props.get( key ) == null ) {
return defaultVal;
}
@@ -451,7 +451,7 @@
return Float.parseFloat( props.get( key ).toString() );
}
- public static int getIntProp( HashMap<String, Object> props, String key, int defaultVal ) {
+ public static int getIntProp( Map<String, Object> props, String key, int defaultVal ) {
if ( props == null || props.get( key ) == null ) {
return defaultVal;
}
@@ -459,7 +459,7 @@
return Integer.parseInt( props.get( key ).toString() );
}
- public static boolean getBooleanProp( HashMap<String, Object> props, String key, boolean defaultVal ) {
+ public static boolean getBooleanProp( Map<String, Object> props, String key, boolean defaultVal ) {
if ( props == null || props.get( key ) == null ) {
return defaultVal;
}
@@ -467,7 +467,7 @@
return "true".equalsIgnoreCase( props.get( key ).toString() );
}
- public static Object getObjectProp( HashMap<String, Object> props, String key, Object defaultVal ) {
+ public static Object getObjectProp( Map<String, Object> props, String key, Object defaultVal ) {
if ( props == null || props.get( key ) == null ) {
return defaultVal;
}
i guess that can't hurt
Can someone apply this patch?
-Tom
this is committed.
please add a [committed] to the threads topic.