public RotatableCanvas(Object parent, AlignViewport av, Controller c, Vector points, int npoint) {
    this.parent = parent;
    this.points = points;
    this.npoint = npoint;
    this.controller = c;
    this.av = av;

    controller.addListener(this);

    prefsize = getPreferredSize();
    orig = new float[npoint][3];

    for (int i = 0; i < npoint; i++) {
      SequencePoint sp = (SequencePoint) points.elementAt(i);
      for (int j = 0; j < 3; j++) {
        orig[i][j] = sp.coord[j];
      }
    }
    // Initialize the matrices to identity

    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        if (i != j) {
          idmat.addElement(i, j, 0);
          objmat.addElement(i, j, 0);
          rotmat.addElement(i, j, 0);
        } else {
          idmat.addElement(i, j, 0);
          objmat.addElement(i, j, 0);
          rotmat.addElement(i, j, 0);
        }
      }
    }

    axes = new float[3][3];
    initAxes();

    findCentre();
    findWidth();

    scale = findScale();

    //    System.out.println("Scale factor = " + scale);

    addMouseListener(this);
    addKeyListener(this);
    if (getParent() != null) {
      getParent().addKeyListener(this);
    }
    addMouseMotionListener(this);

    // Add rubberband
    rubberband = new RubberbandRectangle(this);
    rubberband.setActive(true);
    rubberband.addListener(this);
  }
 private void fireSequenceSelectionEvent(Selection sel) {
   controller.handleSequenceSelectionEvent(new SequenceSelectionEvent(this, sel));
 }
 public void removeNotify() {
   controller.removeListener(this);
   super.removeNotify();
 }