コード例 #1
0
  public void mousePressed(MouseEvent evt) {
    int x = evt.getX();
    int y = evt.getY();

    mx = x;
    my = y;

    omx = mx;
    omy = my;

    startx = x;
    starty = y;

    rectx1 = x;
    recty1 = y;

    rectx2 = -1;
    recty2 = -1;

    AlignSequenceI found = findPoint(x, y);

    if (found != null) {
      if (av != null) {

        if (av.getSelection().contains(found)) {
          av.getSelection().removeElement(found);
        } else {
          av.getSelection().addElement(found);
        }

        fireSequenceSelectionEvent(av.getSelection());

        System.out.println("Selection code not implemented in RotatableCanvas");
        // if (af.tt != null) {
        //  af.tt.tf.p.mc.repaint();
        // }
      }

      System.out.println("Sequence found = " + found.getName());
    }
    redrawneeded = true;
    repaint();
    return;
  }
コード例 #2
0
  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;
  }