public final List<Cube> cubes;
public final List<Face> faces;
public final List<Strip> strips;
+
+ public final Map<String, Cube> cubeTable;
private final Cube[] _cubes;
List<Cube> cubeList = new ArrayList<Cube>();
List<Face> faceList = new ArrayList<Face>();
List<Strip> stripList = new ArrayList<Strip>();
+ Map<String, Cube> _cubeTable = new HashMap<String, Cube>();
for (Cube cube : _cubes) {
if (cube != null) {
+ _cubeTable.put(cube.id, cube);
cubeList.add(cube);
for (Face face : cube.faces) {
faceList.add(face);
this.cubes = Collections.unmodifiableList(cubeList);
this.faces = Collections.unmodifiableList(faceList);
this.strips = Collections.unmodifiableList(stripList);
+ this.cubeTable = Collections.unmodifiableMap(_cubeTable);
}
private static class Fixture extends LXAbstractFixture {
public Cube getCubeByRawIndex(int index) {
return _cubes[index];
}
+
+ public Cube getCubeById(String id) {
+ return this.cubeTable.get(id);
+ }
}
/**
* Model of a set of cubes stacked in a tower
*/
public static class Tower extends LXModel {
+
+ /**
+ * Tower id
+ */
+ public final String id;
+
/**
* Immutable list of cubes
*/
*
* @param cubes Array of cubes
*/
- public Tower(List<Cube> cubes) {
+ public Tower(String id, List<Cube> cubes) {
super(cubes.toArray(new Cube[] {}));
+ this.id = id;
+
List<Cube> cubeList = new ArrayList<Cube>();
List<Face> faceList = new ArrayList<Face>();
List<Strip> stripList = new ArrayList<Strip>();
new Strip.Metrics(EDGE_HEIGHT, POINTS_PER_STRIP)
);
+ public final String id;
+
/**
* Immutable list of all cube faces
*/
*/
public final float rz;
- public Cube(double x, double y, double z, double rx, double ry, double rz) {
- this((float) x, (float) y, (float) z, (float) rx, (float) ry, (float) rz);
- }
-
- public Cube(float x, float y, float z, float rx, float ry, float rz) {
+ public Cube(String id, float x, float y, float z, float rx, float ry, float rz) {
super(new Fixture(x, y, z, rx, ry, rz));
Fixture fixture = (Fixture) this.fixtures.get(0);
+ this.id = id;
+
while (rx < 0) rx += 360;
while (ry < 0) ry += 360;
while (rz < 0) rz += 360;