Ejemplo n.º 1
0
  // override me
  public void doZoomIn(Rectangle rbRect) {
    int x = rbRect.x - mLeft - 5;
    int y = rbRect.y - mTop - 5;

    // zoom in
    double xInc = getXZoomIncrement();
    double yInc = getYZoomIncrement();

    // get coordinates of new view center
    // correct the x value if necessary
    double xx = correctX((double) x);

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

    double newXCtr = (xx / winXScale) + winXOrigin;
    double newYCtr = (yy / winYScale) + winYOrigin;

    // compute the deltas for current range
    double xDelta = Math.abs(getMaxXVal() - getMinXVal()) / 2.0;
    double yDelta = Math.abs(getMaxYVal() - getMinYVal()) / 2.0;

    // compute the aspect ratio of the few
    double aspect = xDelta / yDelta;
    // if (aspect > 1.0)
    // xInc *= aspect;
    // else
    // yInc *= aspect;

    double newXMin = newXCtr < 0 ? newXCtr - xDelta + xInc : newXCtr - xDelta + xInc;
    double newXMax = newXCtr < 0 ? newXCtr + xDelta - xInc : newXCtr + xDelta - xInc;
    double newYMin = newYCtr < 0 ? newYCtr - yDelta + yInc : newYCtr - yDelta + yInc;
    double newYMax = newYCtr < 0 ? newYCtr + yDelta - yInc : newYCtr + yDelta - yInc;

    double[] oldYs = {getMinYVal(), getMaxYVal()};
    double[] newYs = {newYMin, newYMax};
    double[] oldXs = {getMinXVal(), getMaxXVal()};
    double[] newXs = {newXMin, newXMax};
    this.zoomDomain(oldYs, newYs, oldXs, newXs);
  }
Ejemplo n.º 2
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();
  }