+ /**
+ * Resets the view to initial state (no rotation)
+ */
+ public void resetView()
+ {
+ img = null;
+ resetAxes();
+ }
+
+ @Override
+ public void zoom(float factor)
+ {
+ if (factor > 0f)
+ {
+ scalefactor *= factor;
+ }
+ scale = findScale();
+ }
+
+ @Override
+ public void rotate(float x, float y)
+ {
+ if (x == 0f && y == 0f)
+ {
+ return;
+ }
+
+ /*
+ * get the identity transformation...
+ */
+ RotatableMatrix rotmat = new RotatableMatrix();
+
+ /*
+ * rotate around the X axis for change in Y
+ * (mouse movement up/down); note we are equating a
+ * number of pixels with degrees of rotation here!
+ */
+ if (y != 0)
+ {
+ rotmat.rotate(y, Axis.X);
+ }
+
+ /*
+ * rotate around the Y axis for change in X
+ * (mouse movement left/right)
+ */
+ if (x != 0)
+ {
+ rotmat.rotate(x, Axis.Y);
+ }
+
+ /*
+ * apply the composite transformation to sequence points
+ */
+ for (int i = 0; i < npoint; i++)
+ {
+ SequencePoint sp = points.get(i);
+ sp.translate(-centre.x, -centre.y, -centre.z);
+
+ // Now apply the rotation matrix
+ sp.coord = rotmat.vectorMultiply(sp.coord);
+
+ // Now translate back again
+ sp.translate(centre.x, centre.y, centre.z);
+ }
+
+ /*
+ * rotate the x/y/z axis positions
+ */
+ for (int i = 0; i < DIMS; i++)
+ {
+ axisEndPoints[i] = rotmat.vectorMultiply(axisEndPoints[i]);
+ }
+ }
+