diff --git a/sdk/jme3-core/src/com/jme3/gde/core/properties/EmitterShapePropertyEditor.java b/sdk/jme3-core/src/com/jme3/gde/core/properties/EmitterShapePropertyEditor.java index a2ab59a72..f573162bb 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/properties/EmitterShapePropertyEditor.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/properties/EmitterShapePropertyEditor.java @@ -123,7 +123,7 @@ public class EmitterShapePropertyEditor implements PropertyEditor { public void setAsText(String text) throws IllegalArgumentException { text = text.replace('[', ' ').trim(); text = text.replace(']', ' ').trim(); - String[] strings = text.split(","); + String[] strings = text.split("\\s*(,|\\s)\\s*"); EmitterShape old=emitter; if (strings.length == 0) { return; diff --git a/sdk/jme3-core/src/com/jme3/gde/core/properties/QuaternionPropertyEditor.java b/sdk/jme3-core/src/com/jme3/gde/core/properties/QuaternionPropertyEditor.java index d04cf3f28..9d026a746 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/properties/QuaternionPropertyEditor.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/properties/QuaternionPropertyEditor.java @@ -73,26 +73,43 @@ public class QuaternionPropertyEditor implements PropertyEditor { } public String getAsText() { - float[] angles=quaternion.toAngles(new float[3]); - return "[" + (float)Math.toDegrees(angles[0]) + ", " + (float)Math.toDegrees(angles[1]) + ", " + (float)Math.toDegrees(angles[2]) + "]"; + float[] angles = quaternion.toAngles(new float[3]); + return "[" + (float) Math.toDegrees(angles[0]) + ", " + (float) Math.toDegrees(angles[1]) + ", " + (float) Math.toDegrees(angles[2]) + "]"; } - public void setAsText(String text) throws IllegalArgumentException { + private void parseInto(String text, Quaternion res) throws IllegalArgumentException { text = text.replace('[', ' '); - text = text.replace(']', ' '); - String[] values = text.split(","); - if (values.length != 3) { - throw (new IllegalArgumentException("String not correct")); + text = text.replace(']', ' ').trim(); + String[] a = text.split("\\s*(,|\\s)\\s*"); + + + if (a.length == 1) { + if (text.trim().toLowerCase().equals("nan")) { + res.set(Float.NaN, Float.NaN, Float.NaN, Float.NaN); + return; + } + float f = Float.parseFloat(text); + f = (float) Math.toRadians(f); + res.fromAngles(f, f, f); + return; } - float[] floats = new float[3]; - for (int i = 0; i < values.length; i++) { - String string = values[i]; - floats[i] = (float)Math.toRadians(Float.parseFloat(string)); + + if (a.length == 3) { + float[] floats = new float[3]; + for (int i = 0; i < a.length; i++) { + floats[i] = (float) Math.toRadians(Float.parseFloat(a[i])); + } + res.fromAngles(floats); + return; } - Quaternion old=new Quaternion(); + throw new IllegalArgumentException("String not correct"); + } + + public void setAsText(String text) throws IllegalArgumentException { + Quaternion old = new Quaternion(); old.set(quaternion); - quaternion.fromAngles(floats); - notifyListeners(old,quaternion); + parseInto(text, quaternion); + notifyListeners(old, quaternion); } public String[] getTags() { diff --git a/sdk/jme3-core/src/com/jme3/gde/core/properties/Vector2fPropertyEditor.java b/sdk/jme3-core/src/com/jme3/gde/core/properties/Vector2fPropertyEditor.java index 8496b0081..43e0eb9e0 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/properties/Vector2fPropertyEditor.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/properties/Vector2fPropertyEditor.java @@ -75,22 +75,33 @@ public class Vector2fPropertyEditor implements PropertyEditor { public String getAsText() { return "[" + vector.x + ", " + vector.y + "]"; } - - public void setAsText(String text) throws IllegalArgumentException { + + private void parseInto(String text, Vector2f res) throws IllegalArgumentException { text = text.replace('[', ' '); - text = text.replace(']', ' '); - String[] values = text.split(","); - if (values.length != 2) { - throw (new IllegalArgumentException("String not correct")); + text = text.replace(']', ' ').trim(); + String[] a = text.split("\\s*(,|\\s)\\s*"); + + if (a.length == 1) { + if(text.trim().toLowerCase().equals("nan")) { + res.set(new Vector2f(Float.NaN, Float.NaN)); + return; + } + float f = Float.parseFloat(text); + res.set(f, f); + return; } - float[] floats = new float[2]; - for (int i = 0; i < values.length; i++) { - String string = values[i]; - floats[i] = Float.parseFloat(string); + + if (a.length == 2) { + res.set(Float.parseFloat(a[0]), Float.parseFloat(a[1])); + return; } + throw new IllegalArgumentException("String not correct"); + } + + public void setAsText(String text) throws IllegalArgumentException { Vector2f old = new Vector2f(); old.set(vector); - vector.set(floats[0], floats[1]); + parseInto(text, vector); notifyListeners(old, vector); } diff --git a/sdk/jme3-core/src/com/jme3/gde/core/properties/Vector3fPropertyEditor.java b/sdk/jme3-core/src/com/jme3/gde/core/properties/Vector3fPropertyEditor.java index c3886f0f5..03e91718a 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/properties/Vector3fPropertyEditor.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/properties/Vector3fPropertyEditor.java @@ -75,22 +75,33 @@ public class Vector3fPropertyEditor implements PropertyEditor { public String getAsText() { return "[" + vector.x + ", " + vector.y + ", " + vector.z + "]"; } - - public void setAsText(String text) throws IllegalArgumentException { + + private void parseInto(String text, Vector3f res) throws IllegalArgumentException { text = text.replace('[', ' '); - text = text.replace(']', ' '); - String[] values = text.split(","); - if (values.length != 3) { - throw (new IllegalArgumentException("String not correct")); + text = text.replace(']', ' ').trim(); + String[] a = text.split("\\s*(,|\\s)\\s*"); + + if (a.length == 1) { + if(text.trim().toLowerCase().equals("nan")) { + res.set(Vector3f.NAN); + return; + } + float f = Float.parseFloat(text); + res.set(f, f, f); + return; } - float[] floats = new float[3]; - for (int i = 0; i < values.length; i++) { - String string = values[i]; - floats[i] = Float.parseFloat(string); + + if (a.length == 3) { + res.set(Float.parseFloat(a[0]), Float.parseFloat(a[1]), Float.parseFloat(a[2])); + return; } + throw new IllegalArgumentException("String not correct"); + } + + public void setAsText(String text) throws IllegalArgumentException { Vector3f old = new Vector3f(); old.set(vector); - vector.set(floats[0], floats[1], floats[2]); + parseInto(text, vector); notifyListeners(old, vector); }