Esempio n. 1
0
  public void processSectionSpline(boolean shiftDown) {
    mCurrPC.setBatchModeOn();

    if (!shiftDown) mCurrPC.unselectAll();

    // loop on spline pts
    for (int s = 0; s < mSplinePoints.size() - 2; s++) {
      Point p1 = (Point) mSplinePoints.elementAt(s);
      Point p2 = (Point) mSplinePoints.elementAt(s + 1);

      int x1 = p1.x - mLeft - 5;
      int y1 = p1.y - mTop - 5;
      int x2 = p2.x - mLeft - 5;
      int y2 = p2.y - mTop - 5;

      // construct the search polygon
      double dx = x1 - x2;
      double dy = y1 - y2;
      int width1 = ComputeSectionPixelWidth(p1);
      int width2 = ComputeSectionPixelWidth(p2);

      if (dx == 0 && dy == 0) return;
      double dist = (double) Math.pow(dx * dx + dy * dy, 0.5f);

      double p1x = x1 + (double) width1 * (-dy / dist);
      double p1y = y1 + (double) width1 * (dx / dist);

      double p2x = x1 - (double) width1 * (-dy / dist);
      double p2y = y1 - (double) width1 * (dx / dist);

      double p3x = x2 + (double) width2 * (-dy / dist);
      double p3y = y2 + (double) width2 * (dx / dist);

      double p4x = x2 - (double) width2 * (-dy / dist);
      double p4y = y2 - (double) width2 * (dx / dist);

      Polygon srcArea = new Polygon();
      srcArea.addPoint((int) p2x, (int) p2y);
      srcArea.addPoint((int) p1x, (int) p1y);
      srcArea.addPoint((int) p3x, (int) p3y);
      srcArea.addPoint((int) p4x, (int) p4y);

      // search for matches
      byte[] currFilterResults = fdm.getResults();
      double[] yArray1 = getYArray1();
      double[] xArray1 = getXArray1();
      double[] yArray2 = getYArray2();
      double[] xArray2 = getXArray2();
      mCurrPC.setBatchModeOn();
      for (int i = 0; i < mCurrPC.getSize(); i++) {
        if (!mIgnoreFilter
            && (mCurrPC.isDeleted(i) || currFilterResults[i] != 4 || !mCurrPC.isSelectedLayer(i)))
          continue;
        double yi = yArray1[i];
        double xi = xArray1[i];
        double xi2 = Float.NaN;
        double yi2 = Float.NaN;
        double xx2 = Float.NaN;
        double yy2 = Float.NaN;

        // correct the X value if necessary
        xi = correctX(xi);

        double xx1 = (xi - winXOrigin) * winXScale;
        double yy1 = (yi - winYOrigin) * winYScale;

        // correct the Y coordinate if necessary
        yy1 = correctY(yy1);

        if (!isYAxisScaler()) {
          yi2 = yArray2[i];
          yy2 = (yi2 - winYOrigin) * winYScale;
          ;
          yy2 = correctY(yy2);
        } else yy2 = yy1;

        if (!isXAxisScaler()) {
          xi2 = xArray2[i];
          xi2 = correctX(xi2);
          xx2 = (xi2 - winXOrigin) * winXScale;
        } else xx2 = xx1;

        if (srcArea.contains(new Point((int) xx1, (int) yy1))
            || srcArea.contains(new Point((int) xx2, (int) yy2))) {
          mCurrPC.select(i);
        }
      }
    } // for splines

    mSplinePoints.removeAllElements();
    mViewManager.invalidateAllViews();
    mCurrPC.setBatchModeOff();
  }
Esempio n. 2
0
  public void processPolygonSpline(boolean shiftDown) {
    mCurrPC.setBatchModeOn();
    if (!shiftDown) mCurrPC.unselectAll();

    // loop on spline pts to construct a Polygon
    Polygon srcArea = new Polygon();
    for (int s = 0; s < mSplinePoints.size(); s++) {
      Point p = (Point) mSplinePoints.elementAt(s);
      int x = p.x - mLeft - 5;
      int y = p.y - mTop - 5;

      srcArea.addPoint(x, y);
    }

    mSplinePoints.removeAllElements();

    // search for matches
    byte[] currFilterResults = fdm.getResults();
    double[] yArray1 = getYArray1();
    double[] xArray1 = getXArray1();
    double[] yArray2 = getYArray2();
    double[] xArray2 = getXArray2();
    Point p1 = new Point();
    Point p2 = new Point();

    for (int i = 0; i < mCurrPC.getSize(); i++) {
      if (!mIgnoreFilter
          && (mCurrPC.isDeleted(i) || currFilterResults[i] != 4 || !mCurrPC.isSelectedLayer(i)))
        continue;
      double yi = yArray1[i];
      double xi = xArray1[i];
      double xi2 = Float.NaN;
      double yi2 = Float.NaN;
      double xx2 = Float.NaN;
      double yy2 = Float.NaN;

      // correct the X value if necessary
      xi = correctX(xi);

      double xx1 = (xi - winXOrigin) * winXScale;
      double yy1 = (yi - winYOrigin) * winYScale;

      // correct the Y coordinate if necessary
      yy1 = correctY(yy1);

      if (!isYAxisScaler()) {
        yi2 = yArray2[i];
        yy2 = (yi2 - winYOrigin) * winYScale;
        ;
        yy2 = correctY(yy2);
      } else yy2 = yy1;

      if (!isXAxisScaler()) {
        xi2 = xArray2[i];
        xi2 = correctX(xi2);
        xx2 = (xi2 - winXOrigin) * winXScale;
      } else xx2 = xx1;

      p1.setLocation((int) xx1, (int) yy1);
      p2.setLocation((int) xx2, (int) yy2);

      if (srcArea.contains(p1) || srcArea.contains(p2)) {
        mCurrPC.select(i);
      }
    }
    mViewManager.invalidateAllViews();
    mCurrPC.setBatchModeOff();
  }
Esempio n. 3
0
  public void rubberbandEnded(Rubberband rb, boolean shiftDown) {
    // get the limits and zoom the plot
    if (mCurrPC == null) return;
    Rectangle rbRect = rb.getBounds();
    if (rbRect.width == 0 || rbRect.height == 0) {
      // click selection
      if (toolMode == Constants.SELECT_MODE) {
        // find any matches at the mouseclick location
        int x = rbRect.x - mLeft - 5;
        int y = rbRect.y - mTop - 5;

        // construct a search region;
        int[] xpoints = {x - 1, x + 1, x + 1, x - 1, x - 1};
        int[] ypoints = {y - 1, y - 1, y + 1, y + 1, y - 1};
        Polygon sr = new Polygon(xpoints, ypoints, 5);

        if (!shiftDown) mCurrPC.unselectAll();

        mCurrPC.setBatchModeOn();

        byte[] currFilterResults = fdm.getResults();
        double[] yArray1 = getYArray1();
        double[] xArray1 = getXArray1();
        double[] yArray2 = getYArray2();
        double[] xArray2 = getXArray2();

        for (int i = 0; i < mCurrPC.getSize(); i++) {
          if (!mIgnoreFilter && (mCurrPC.isDeleted(i) || currFilterResults[i] != 4)
              || !mCurrPC.isSelectedLayer(i)) continue;

          // search for matches
          double yi = yArray1[i];
          double xi = xArray1[i];
          double xi2 = Float.NaN;
          double yi2 = Float.NaN;
          double x2 = Float.NaN;
          double y2 = Float.NaN;

          // correct the X value if necessary
          xi = correctX(xi);

          double x1 = (xi - winXOrigin) * winXScale;
          double y1 = (yi - winYOrigin) * winYScale;

          // correct the Y coordinate if necessary
          y1 = correctY(y1);

          if (!isYAxisScaler()) {
            yi2 = yArray2[i];
            y2 = (yi2 - winYOrigin) * winYScale;
            y2 = correctY(y2);
          } else y2 = y1;

          if (!isXAxisScaler()) {
            xi2 = xArray2[i];
            xi2 = correctX(xi2);
            x2 = (xi2 - winXOrigin) * winXScale;
          } else x2 = x1;

          if (sr.contains(new Point((int) x1, (int) y1))
              || sr.contains(new Point((int) x2, (int) y2))) {
            mCurrPC.select(i);
          }
        }
        mViewManager.invalidateAllViews();
        mCurrPC.setBatchModeOff();
      } else if (toolMode == Constants.ZOOM_MODE) {
        if (!shiftDown) {
          doZoomIn(rbRect);
        } else {
          // zoom out
          double xInc = getXZoomIncrement();
          double yInc = getYZoomIncrement();
          double[] oldYs = {getMaxYVal(), getMinYVal()};
          double[] newYs = {
            getMinYVal() < 0 ? getMinYVal() - yInc : getMinYVal() + yInc,
            getMaxYVal() < 0 ? getMaxYVal() - yInc : getMaxYVal() + yInc
          };
          double[] oldXs = {getMinXVal(), getMaxXVal()};
          double[] newXs = {
            getMinXVal() < 0 ? getMinXVal() - xInc : getMinXVal() + xInc,
            getMaxXVal() < 0 ? getMaxXVal() - xInc : getMaxXVal() + xInc
          };
          this.zoomDomain(oldYs, newYs, oldXs, newXs);
        }
        mViewManager.invalidateAllViews();
      }
    } else {
      // region selected
      int x = rbRect.x - mLeft - 5;
      int y = rbRect.y - mTop - 5;
      int x2 = x + rbRect.width;
      int y2 = y + rbRect.height;
      Point p1 = new Point();
      Point p2 = new Point();

      if (toolMode == Constants.SELECT_MODE) {
        if (!shiftDown) mCurrPC.unselectAll();

        // construct a search region;
        int[] xpoints = {x, x2, x2, x, x};
        int[] ypoints = {y, y, y2, y2, y};
        Polygon sr = new Polygon(xpoints, ypoints, 5);

        // search for matches
        byte[] currFilterResults = fdm.getResults();
        double[] yArray1 = getYArray1();
        double[] xArray1 = getXArray1();
        double[] yArray2 = getYArray2();
        double[] xArray2 = getXArray2();

        mCurrPC.setBatchModeOn();
        for (int i = 0; i < mCurrPC.getSize(); i++) {
          if (!mIgnoreFilter
              && (mCurrPC.isDeleted(i) || currFilterResults[i] != 4 || !mCurrPC.isSelectedLayer(i)))
            continue;

          double yi = yArray1[i];
          double xi = xArray1[i];
          double xi2 = Float.NaN;
          double yi2 = Float.NaN;
          double xx2 = Float.NaN;
          double yy2 = Float.NaN;

          // correct the X value if necessary
          xi = correctX(xi);

          double xx1 = (xi - winXOrigin) * winXScale;
          double yy1 = (yi - winYOrigin) * winYScale;

          // correct the Y coordinate if necessary
          yy1 = correctY(yy1);

          if (!isYAxisScaler()) {
            yi2 = yArray2[i];
            yy2 = (yi2 - winYOrigin) * winYScale;
            yy2 = correctY(yy2);
          } else yy2 = yy1;

          if (!isXAxisScaler()) {
            xi2 = xArray2[i];
            xi2 = correctX(xi2);
            xx2 = (xi2 - winXOrigin) * winXScale;
          } else xx2 = xx1;

          p1.setLocation((int) xx1, (int) yy1);
          p2.setLocation((int) xx2, (int) yy2);

          if (sr.contains(p1) || sr.contains(p2)) {
            mCurrPC.select(i);
          }
        }
        mViewManager.invalidateAllViews();
        mCurrPC.setBatchModeOff();
      } else if (toolMode == Constants.ZOOM_MODE) {
        // correct the x value if necessary
        double xx = correctX((double) x);
        double xx2 = correctX((double) x2);

        // correct the Y coordinate if necessary
        double yy = correctY((double) y);
        double yy2 = correctY((double) y2);

        double newX = (xx / winXScale) + winXOrigin;
        double newX2 = (xx2 / winXScale) + winXOrigin;
        double newY = (yy / winYScale) + winYOrigin;
        double newY2 = (yy2 / winYScale) + winYOrigin;

        double[] oldYs = {getMaxYVal(), getMinYVal()};
        if (this.toString().indexOf("Depth") >= 0) {
          double temp = newY2;
          newY2 = newY;
          newY = temp;
        }
        double[] newYs = {newY2, newY};

        double[] oldXs = {getMinXVal(), getMaxXVal()};
        double[] newXs = {newX, newX2};
        this.zoomDomain(oldYs, newYs, oldXs, newXs);
        mViewManager.invalidateAllViews();
      }
    }
  }