コード例 #1
0
  public void findWidth() {
    max = new float[3];
    min = new float[3];

    max[0] = (float) -1e30;
    max[1] = (float) -1e30;
    max[2] = (float) -1e30;

    min[0] = (float) 1e30;
    min[1] = (float) 1e30;
    min[2] = (float) 1e30;

    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < npoint; j++) {
        SequencePoint sp = (SequencePoint) points.elementAt(j);
        if (sp.coord[i] >= max[i]) {
          max[i] = sp.coord[i];
        }
        if (sp.coord[i] <= min[i]) {
          min[i] = sp.coord[i];
        }
      }
    }

    //    System.out.println("xmax " + max[0] + " min " + min[0]);
    // System.out.println("ymax " + max[1] + " min " + min[1]);
    // System.out.println("zmax " + max[2] + " min " + min[2]);

    width[0] = Math.abs(max[0] - min[0]);
    width[1] = Math.abs(max[1] - min[1]);
    width[2] = Math.abs(max[2] - min[2]);

    maxwidth = width[0];

    if (width[1] > width[0]) maxwidth = width[1];
    if (width[2] > width[1]) maxwidth = width[2];

    // System.out.println("Maxwidth = " + maxwidth);
  }
コード例 #2
0
  public AlignSequenceI findPoint(int x, int y) {

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

    int found = -1;

    for (int i = 0; i < npoint; i++) {

      SequencePoint sp = (SequencePoint) points.elementAt(i);
      int px = (int) ((float) (sp.coord[0] - centre[0]) * scale) + halfwidth;
      int py = (int) ((float) (sp.coord[1] - centre[1]) * scale) + halfheight;

      if (Math.abs(px - x) < 3 && Math.abs(py - y) < 3) {
        found = i;
      }
    }
    if (found != -1) {
      return ((SequencePoint) points.elementAt(found)).sequence;
    } else {
      return null;
    }
  }