Commit 3b66016e authored by Jean Meurice's avatar Jean Meurice
Browse files

DataType format update

parent d8192efc
Pipeline #371746 passed with stage
in 44 seconds
......@@ -8,7 +8,7 @@
<groupId>montisim</groupId>
<artifactId>commons</artifactId>
<version>2.0.9</version>
<version>2.0.10</version>
<properties>
......
......@@ -3,6 +3,7 @@ package de.rwth.montisim.commons.dynamicinterface;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.text.DecimalFormat;
import java.util.*;
import de.rwth.montisim.commons.utils.*;
......@@ -26,6 +27,8 @@ public class BasicType extends DataType {
public static final BasicType VEC2 = new BasicType(Type.VEC2);
public static final BasicType VEC3 = new BasicType(Type.VEC3);
static final DecimalFormat df = new DecimalFormat("#.###");
public BasicType(Type basic_type) {
this.base_type = basic_type;
}
......@@ -189,12 +192,16 @@ public class BasicType extends DataType {
case N1:
case Z:
return new ArrayList<String>(Arrays.asList(Integer.toString((Integer) o)));
case Q:
return new ArrayList<String>(Arrays.asList(Double.toString((Double) o)));
case VEC2:
return new ArrayList<String>(Arrays.asList(((Vec2) o).toString()));
case VEC3:
return new ArrayList<String>(Arrays.asList(((Vec3) o).toString()));
case Q:
return new ArrayList<String>(Arrays.asList(df.format((Double) o)));
case VEC2:{
Vec2 v2 = (Vec2) o;
return new ArrayList<String>(Arrays.asList("[" + df.format(v2.x) + ", " + df.format(v2.y) + "]"));
}
case VEC3: {
Vec3 v3 = (Vec3) o;
return new ArrayList<String>(Arrays.asList("[" + df.format(v3.x) + ", " + df.format(v3.y) + ", " + df.format(v3.z)+ "]"));
}
default:
throw new IllegalArgumentException("Missing case");
}
......
......@@ -163,7 +163,7 @@ public class VectorType extends DataType {
for (double d : arr) {
if (first) first = false;
else res += ", ";
res += Double.toString(d);
res += BasicType.df.format(d);
}
res += "]";
return new ArrayList<String>(Arrays.asList(res));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment