/** Factory method for adding menu items created from actions. */
  public JMenuItem add(JalAction action) {

    if (av != null && av.getCommandLog() != null) {
      // action.addListener(av.getCommandLog());
      av.getCommandLog().add(action);
    }
    return super.add(action);
  }
  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;
  }
  public void rectSelect(int x1, int y1, int x2, int y2) {
    boolean changedSel = false;
    for (int i = 0; i < npoint; i++) {
      SequencePoint sp = (SequencePoint) points.elementAt(i);
      int tmp1 = (int) ((sp.coord[0] - centre[0]) * scale + (float) size().width / 2.0);
      int tmp2 = (int) ((sp.coord[1] - centre[1]) * scale + (float) size().height / 2.0);

      if (tmp1 > x1 && tmp1 < x2 && tmp2 > y1 && tmp2 < y2) {
        if (av != null) {
          if (!av.getSelection().contains(sp.sequence)) {
            changedSel = true;
            av.getSelection().addElement(sp.sequence);
          }
        }
      }
    }
    if (changedSel) {
      fireSequenceSelectionEvent(av.getSelection());
    }
  }
  public void drawScene(Graphics g) {
    boolean darker = false;

    int halfwidth = size().width / 2;
    int halfheight = size().height / 2;

    for (int i = 0; i < npoint; i++) {
      SequencePoint sp = (SequencePoint) points.elementAt(i);
      int x = (int) ((float) (sp.coord[0] - centre[0]) * scale) + halfwidth;
      int y = (int) ((float) (sp.coord[1] - centre[1]) * scale) + halfheight;
      float z = sp.coord[1] - centre[2];
      if (sp.sequence instanceof DrawableSequence) {
        if (((DrawableSequence) sp.sequence).color == Color.black) {
          g.setColor(Color.white);
        } else {
          g.setColor(((DrawableSequence) sp.sequence).color);
        }
      } else {
        g.setColor(Color.red);
      }
      if (av != null) {
        if (av.getSelection().contains(((SequencePoint) points.elementAt(i)).sequence)) {
          g.setColor(Color.gray);
        }
      }
      if (z < 0) {
        g.setColor(g.getColor().darker());
      }

      g.fillRect(x - 3, y - 3, 6, 6);
      g.setColor(Color.red);
    }
    //    //Now the rectangle
    //    if (rectx2 != -1 && recty2 != -1) {
    //      g.setColor(Color.white);
    //
    //      g.drawRect(rectx1,recty1,rectx2-rectx1,recty2-recty1);
    //    }
  }