Ejemplo n.º 1
0
  private void showSliderMenu() {
    Point location = new Point(getX(), getY() + getHeight());

    SwingUtilities.convertPointToScreen(location, InputVolumeControlButton.this.getParent());

    if (isFullScreen()) {
      location.setLocation(
          location.getX(),
          location.getY() - sliderMenu.getPreferredSize().getHeight() - getHeight());
    }

    sliderMenu.setLocation(location);

    sliderMenu.addPopupMenuListener(
        new PopupMenuListener() {
          public void popupMenuWillBecomeVisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = true;
          }

          public void popupMenuWillBecomeInvisible(PopupMenuEvent ev) {
            sliderMenuIsVisible = false;
          }

          public void popupMenuCanceled(PopupMenuEvent ev) {}
        });

    sliderMenu.setVisible(!sliderMenu.isVisible());
  }
Ejemplo n.º 2
0
  /**
   * Set the scroll position.
   *
   * @param x coordinate of upper left corner.
   * @param y coordinate of upper left corner.
   */
  public void setScrollPosition(int x, int y) {
    final DjVuImage image = getImage();
    if ((image != null) && ((x != scrollPosition.x) || (y != scrollPosition.y))) {
      final Dimension imageSize = image.getSize();
      final Dimension viewportSize = getViewportSize();
      x = Math.max(0, Math.min(imageSize.width - viewportSize.width, x));
      y = Math.max(0, Math.min(imageSize.height - viewportSize.height, y));

      if ((x != scrollPosition.x) || (y != scrollPosition.y)) {
        scrollPosition.setLocation(x, y);
        updateScrollbars();
        repaint(50L);
      }
    }
  }
Ejemplo n.º 3
0
    private void updatePipette() {
      Dialog pickerDialog = getPickerDialog();
      if (pickerDialog != null && pickerDialog.isShowing()) {
        Point mouseLoc = updateLocation();
        if (mouseLoc == null) return;
        final Color c = getPixelColor(mouseLoc);
        if (!c.equals(getColor()) || !mouseLoc.equals(myPreviousLocation)) {
          setColor(c);
          myPreviousLocation.setLocation(mouseLoc);
          myCaptureRect.setBounds(
              mouseLoc.x - HOT_SPOT.x + SIZE / 2 - 2, mouseLoc.y - HOT_SPOT.y + SIZE / 2 - 2, 5, 5);

          BufferedImage capture = myRobot.createScreenCapture(myCaptureRect);

          // Clear the cursor graphics
          myGraphics.setComposite(AlphaComposite.Src);
          myGraphics.setColor(UIUtil.TRANSPARENT_COLOR);
          myGraphics.fillRect(0, 0, myImage.getWidth(), myImage.getHeight());

          myGraphics.drawImage(
              capture, myZoomRect.x, myZoomRect.y, myZoomRect.width, myZoomRect.height, this);

          // cropping round image
          myGraphics.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OUT));
          myGraphics.drawImage(
              myMaskImage, myZoomRect.x, myZoomRect.y, myZoomRect.width, myZoomRect.height, this);

          // paint magnifier
          myGraphics.setComposite(AlphaComposite.SrcOver);

          UIUtil.drawImage(
              myGraphics, myPipetteImage, SIZE - AllIcons.Ide.Pipette.getIconWidth(), 0, this);

          pickerDialog.setCursor(
              myParent.getToolkit().createCustomCursor(myImage, HOT_SPOT, "ColorPicker"));
          notifyListener(c, 300);
        }
      }
    }
Ejemplo n.º 4
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();
  }
Ejemplo n.º 5
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();
      }
    }
  }
Ejemplo n.º 6
0
 public void mouseMoved(MouseEvent e) {
   mouse.setLocation(e.getX(), e.getY());
   changeArea();
   changeDisplay();
 }