public void mouseDragged(MouseEvent evt) { mx = evt.getX(); my = evt.getY(); // Check if this is a rectangle drawing drag if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0) { // rectx2 = evt.getX(); // recty2 = evt.getY(); } else { rotmat.setIdentity(); rotmat.rotate((float) (my - omy), 'x'); rotmat.rotate((float) (mx - omx), 'y'); for (int i = 0; i < npoint; i++) { SequencePoint sp = (SequencePoint) points.elementAt(i); sp.coord[0] -= centre[0]; sp.coord[1] -= centre[1]; sp.coord[2] -= centre[2]; // Now apply the rotation matrix sp.coord = rotmat.vectorMultiply(sp.coord); // Now translate back again sp.coord[0] += centre[0]; sp.coord[1] += centre[1]; sp.coord[2] += centre[2]; } for (int i = 0; i < 3; i++) { axes[i] = rotmat.vectorMultiply(axes[i]); } omx = mx; omy = my; redrawneeded = true; paint(this.getGraphics()); } return; }