]> gerrit.simantics Code Review - simantics/3d.git/blobdiff - org.simantics.g3d/src/org/simantics/g3d/property/DoublePropertyManipulator.java
Eliminate rounding errors in property tabs.
[simantics/3d.git] / org.simantics.g3d / src / org / simantics / g3d / property / DoublePropertyManipulator.java
index 47f6ca7d21fb93066971e9982c93485bad242573..46f892f3c849b3c0171981c56965f0f6d7dcf523 100644 (file)
@@ -11,6 +11,8 @@
  *******************************************************************************/
 package org.simantics.g3d.property;
 
+import org.simantics.g3d.math.MathTools;
+
 public class DoublePropertyManipulator implements PropertyManipulator {
        
        ValueProvider provider;
@@ -41,7 +43,11 @@ public class DoublePropertyManipulator implements PropertyManipulator {
                if (editMode)
                        return editValue;
                try {
-                       return provider.getValue(input).toString();
+                       Object value = provider.getValue(input);
+                       if (value == null) return null;
+                       if (value instanceof Double)
+                               return Double.toString(MathTools.round((Double)value, 10));
+                       return value.toString();
                } catch (Exception e) {
                        return null;
                }
@@ -68,7 +74,8 @@ public class DoublePropertyManipulator implements PropertyManipulator {
                editMode = b;
                if (editMode) {
                        try {
-                               editValue = provider.getValue(input).toString();
+                               Object value = provider.getValue(input);
+                               editValue = value.toString();
                        } catch (Exception e) {
                                
                        }