Ejemplo n.º 1
0
 public void mousePressed(MouseEvent e) {
   mouseX = e.getX();
   mouseY = e.getY();
   // consume this event so that it will not be processed
   // in the default manner
   e.consume();
 }
Ejemplo n.º 2
0
    public void mouseDragged(MouseEvent e) {
      int mods = e.getModifiersEx();
      Point dragEnd = e.getPoint();
      boolean shift = (mods & MouseEvent.SHIFT_DOWN_MASK) > 0;
      boolean ctrl = (mods & MouseEvent.CTRL_DOWN_MASK) > 0;
      boolean alt = shift & ctrl;
      ctrl = ctrl & (!alt);
      shift = shift & (!alt);
      boolean nomods = !(shift | ctrl | alt);

      if (dragBegin == null) dragBegin = dragEnd;

      nodrag = false;

      if ((mods & InputEvent.BUTTON3_DOWN_MASK) > 0 || true) {
        double dx = dragEnd.getX() - dragBegin.getX();
        double dy = dragEnd.getY() - dragBegin.getY();

        synchronized (JImage.this) {
          t.preConcatenate(AffineTransform.getTranslateInstance(dx, dy));
        }

        dragBegin = dragEnd;
        repaint();
      }
    }
Ejemplo n.º 3
0
 /** This method cannot be called directly. */
 public void mousePressed(MouseEvent e) {
   synchronized (mouseLock) {
     mouseX = StdDraw.userX(e.getX());
     mouseY = StdDraw.userY(e.getY());
     mousePressed = true;
   }
 }
Ejemplo n.º 4
0
 public void mouseMoved(MouseEvent e) {
   // if (ij==null) return;
   int sx = e.getX();
   int sy = e.getY();
   int ox = offScreenX(sx);
   int oy = offScreenY(sy);
   flags = e.getModifiers();
   setCursor(sx, sy, ox, oy);
   IJ.setInputEvent(e);
   Roi roi = imp.getRoi();
   if (roi != null
       && (roi.getType() == Roi.POLYGON
           || roi.getType() == Roi.POLYLINE
           || roi.getType() == Roi.ANGLE)
       && roi.getState() == roi.CONSTRUCTING) {
     PolygonRoi pRoi = (PolygonRoi) roi;
     pRoi.handleMouseMove(ox, oy);
   } else {
     if (ox < imageWidth && oy < imageHeight) {
       ImageWindow win = imp.getWindow();
       // Cursor must move at least 12 pixels before text
       // displayed using IJ.showStatus() is overwritten.
       if ((sx - sx2) * (sx - sx2) + (sy - sy2) * (sy - sy2) > 144) showCursorStatus = true;
       if (win != null && showCursorStatus) win.mouseMoved(ox, oy);
     } else IJ.showStatus("");
   }
 }
Ejemplo n.º 5
0
Archivo: set.java Proyecto: wcyuan/Set
 private Location findloc(MouseEvent e) {
   int i, x = e.getX(), y = e.getY();
   if (button.contains(x, y)) return button;
   for (i = 0; i < NUM_LOCATIONS; i++) {
     if (locs[i].contains(x, y)) return locs[i];
   }
   return null;
 }
Ejemplo n.º 6
0
 /** This method cannot be called directly. */
 public void mousePressed(MouseEvent e) {
   synchronized (mouseLock) {
     mouseX = StdDraw.userX(e.getX());
     mouseY = StdDraw.userY(e.getY());
     mousePressed = true;
     // System.out.println(mouseX+" ,"+mouseY);
   }
 }
Ejemplo n.º 7
0
 static void handleMouseDragged(MouseEvent e) {
   DrawObject L = new DrawObject();
   L.scribbleX = e.getX();
   L.scribbleY = e.getY();
   L.scribbleNum = currentScribbleNum;
   scribbles.add(L);
   drawArea.repaint();
 }
Ejemplo n.º 8
0
  public void mousePressed(MouseEvent e) {
    Point p = e.getPoint();
    int mods = e.getModifiers();

    if (odometer != null) {
      String output = " (" + p.x + ", " + p.y + ")";
      odometer.setText(output);
    }
  }
  /**
   * The user has clicked in the applet. Figure out where and see if a legal move is possible. If it
   * is a legal move, respond with a legal move (if possible).
   */
  public void mouseReleased(MouseEvent e) {
    int x = e.getX();
    int y = e.getY();

    switch (status()) {
      case WIN:
      case LOSE:
      case STALEMATE:
        play(getCodeBase(), "audio/return.au");
        white = black = 0;
        if (first) {
          white |= 1 << (int) (Math.random() * 9);
        }
        first = !first;
        repaint();
        return;
    }

    // Figure out the row/column
    Dimension d = getSize();
    int c = (x * 3) / d.width;
    int r = (y * 3) / d.height;
    if (yourMove(c + r * 3)) {
      repaint();

      switch (status()) {
        case WIN:
          play(getCodeBase(), "audio/yahoo1.au");
          break;
        case LOSE:
          play(getCodeBase(), "audio/yahoo2.au");
          break;
        case STALEMATE:
          break;
        default:
          if (myMove()) {
            repaint();
            switch (status()) {
              case WIN:
                play(getCodeBase(), "audio/yahoo1.au");
                break;
              case LOSE:
                play(getCodeBase(), "audio/yahoo2.au");
                break;
              case STALEMATE:
                break;
              default:
                play(getCodeBase(), "audio/ding.au");
            }
          } else {
            play(getCodeBase(), "audio/beep.au");
          }
      }
    } else {
      play(getCodeBase(), "audio/beep.au");
    }
  }
Ejemplo n.º 10
0
    public void mouseReleased(MouseEvent e) {
      int mods = e.getModifiersEx();

      if (nodrag && e.getButton() == MouseEvent.BUTTON3) {
        popupMenu.show(JImage.this, (int) e.getPoint().getX(), (int) e.getPoint().getY());
      }

      nodrag = true;
      dragBegin = null;
    }
Ejemplo n.º 11
0
 public void mouseDragged(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   tmpMatrix.unit();
   tmpMatrix.xrot(360.0 * (mouseY - y) / getSize().height);
   tmpMatrix.yrot(360.0 * (x - mouseX) / getSize().width);
   viewMatrix.mult(tmpMatrix);
   repaint();
   mouseX = x;
   mouseY = y;
   e.consume();
 }
Ejemplo n.º 12
0
 public void setBorderType(MouseEvent me, int type) {
   if (type == 1) {
     ((JPanel) me.getSource())
         .setBorder(new javax.swing.border.BevelBorder(javax.swing.border.BevelBorder.RAISED));
     setCursor(new Cursor(Cursor.HAND_CURSOR));
   }
   if (type == 2) {
     ((JPanel) me.getSource())
         .setBorder(new javax.swing.border.MatteBorder(0, 0, 0, 0, Color.white));
     setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
   }
 }
Ejemplo n.º 13
0
 protected void handleRoiMouseDown(MouseEvent e) {
   int sx = e.getX();
   int sy = e.getY();
   int ox = offScreenX(sx);
   int oy = offScreenY(sy);
   Roi roi = imp.getRoi();
   int handle = roi != null ? roi.isHandle(sx, sy) : -1;
   boolean multiPointMode =
       roi != null
           && (roi instanceof PointRoi)
           && handle == -1
           && Toolbar.getToolId() == Toolbar.POINT
           && Toolbar.getMultiPointMode();
   if (multiPointMode) {
     imp.setRoi(((PointRoi) roi).addPoint(ox, oy));
     return;
   }
   setRoiModState(e, roi, handle);
   if (roi != null) {
     if (handle >= 0) {
       roi.mouseDownInHandle(handle, sx, sy);
       return;
     }
     Rectangle r = roi.getBounds();
     int type = roi.getType();
     if (type == Roi.RECTANGLE
         && r.width == imp.getWidth()
         && r.height == imp.getHeight()
         && roi.getPasteMode() == Roi.NOT_PASTING
         && !(roi instanceof ImageRoi)) {
       imp.killRoi();
       return;
     }
     if (roi.contains(ox, oy)) {
       if (roi.modState == Roi.NO_MODS) roi.handleMouseDown(sx, sy);
       else {
         imp.killRoi();
         imp.createNewRoi(sx, sy);
       }
       return;
     }
     if ((type == Roi.POLYGON || type == Roi.POLYLINE || type == Roi.ANGLE)
         && roi.getState() == roi.CONSTRUCTING) return;
     int tool = Toolbar.getToolId();
     if ((tool == Toolbar.POLYGON || tool == Toolbar.POLYLINE || tool == Toolbar.ANGLE)
         && !(IJ.shiftKeyDown() || IJ.altKeyDown())) {
       imp.killRoi();
       return;
     }
   }
   imp.createNewRoi(sx, sy);
 }
Ejemplo n.º 14
0
 void setRoiModState(MouseEvent e, Roi roi, int handle) {
   if (roi == null || (handle >= 0 && roi.modState == Roi.NO_MODS)) return;
   if (roi.state == Roi.CONSTRUCTING) return;
   int tool = Toolbar.getToolId();
   if (tool > Toolbar.FREEROI && tool != Toolbar.WAND && tool != Toolbar.POINT) {
     roi.modState = Roi.NO_MODS;
     return;
   }
   if (e.isShiftDown()) roi.modState = Roi.ADD_TO_ROI;
   else if (e.isAltDown()) roi.modState = Roi.SUBTRACT_FROM_ROI;
   else roi.modState = Roi.NO_MODS;
   // IJ.log("setRoiModState: "+roi.modState+" "+ roi.state);
 }
  /**
   * Method to display pixel information based on a mouse event
   *
   * @param e a mouse event
   */
  private void displayPixelInformation(MouseEvent e) {

    // get the cursor x and y
    int cursorX = e.getX();
    int cursorY = e.getY();

    // get the x and y in the original (not scaled image)
    int pictureX = (int) (cursorX / zoomFactor + numberBase);
    int pictureY = (int) (cursorY / zoomFactor + numberBase);

    // display the information for this x and y
    displayPixelInformation(pictureX, pictureY);
  }
Ejemplo n.º 16
0
 public void mouseClicked(MouseEvent e) {
   Tile t = (Tile) e.getSource();
   ImageIcon temp = (ImageIcon) t.getIcon();
   currTileImg = new ImageIcon(scaleImage(temp.getImage(), DISPLAY_SCALE));
   currTileDisplay.setIcon(new ImageIcon(scaleImage(temp.getImage(), DISPLAY_SCALE * 2)));
   currTileLoc = t.getSource();
 }
Ejemplo n.º 17
0
 public void mouseDragged(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   xMouse = offScreenX(x);
   yMouse = offScreenY(y);
   flags = e.getModifiers();
   // IJ.log("mouseDragged: "+flags);
   if (flags == 0) // workaround for Mac OS 9 bug
   flags = InputEvent.BUTTON1_MASK;
   if (Toolbar.getToolId() == Toolbar.HAND || IJ.spaceBarDown()) scroll(x, y);
   else {
     IJ.setInputEvent(e);
     Roi roi = imp.getRoi();
     if (roi != null) roi.handleMouseDrag(x, y, flags);
   }
 }
Ejemplo n.º 18
0
  /** Check if a state dialog is to be displayed?? */
  private void handleEventDlg(MouseEvent e) {
    int x = e.getX(), y = e.getY();
    if (y >= allDispHt) return;
    StateInterval cur_state = findState(x, y);
    if (cur_state != null) {
      RecordDialog sd = new RecordDialog(parent, cur_state);

      Point p = getLocationOnScreen();
      int tx = x, ty = y;
      tx += p.x;
      ty += p.y;
      sd.setLocation(tx, ty);

      sd.setVisible(true);
    }
  }
Ejemplo n.º 19
0
  public final void mouseMoved(MouseEvent e) {
    Point p = e.getPoint();

    if (odometer != null) {
      String output = " (" + p.x + ", " + p.y + ")";
      odometer.setText(output);
    }
  }
Ejemplo n.º 20
0
  /** Check if a message dialog is to be displayed?? */
  private boolean handleMsgDlg(MouseEvent e) {
    int x = e.getX(), y = e.getY();
    if (y >= allDispHt) return false;
    ArrowInfo arrow = findMsg(x, y);
    if (arrow != null) {
      RecordDialog md = new RecordDialog(parent, arrow);

      Point p = getLocationOnScreen();
      int tx = x, ty = y;
      tx += p.x;
      ty += p.y;
      md.setLocation(tx, ty);

      md.setVisible(true);

      return true;
    }
    return false;
  }
Ejemplo n.º 21
0
 public void mouseReleased(MouseEvent e) {
   flags = e.getModifiers();
   flags &= ~InputEvent.BUTTON1_MASK; // make sure button 1 bit is not set
   flags &= ~InputEvent.BUTTON2_MASK; // make sure button 2 bit is not set
   flags &= ~InputEvent.BUTTON3_MASK; // make sure button 3 bit is not set
   Roi roi = imp.getRoi();
   if (roi != null) {
     Rectangle r = roi.getBounds();
     int type = roi.getType();
     if ((r.width == 0 || r.height == 0)
         && !(type == Roi.POLYGON || type == Roi.POLYLINE || type == Roi.ANGLE || type == Roi.LINE)
         && !(roi instanceof TextRoi)
         && roi.getState() == roi.CONSTRUCTING
         && type != roi.POINT) imp.killRoi();
     else {
       roi.handleMouseUp(e.getX(), e.getY());
       if (roi.getType() == Roi.LINE && roi.getLength() == 0.0) imp.killRoi();
     }
   }
 }
Ejemplo n.º 22
0
 protected void handlePopupMenu(MouseEvent e) {
   if (disablePopupMenu) return;
   if (IJ.debugMode) IJ.log("show popup: " + (e.isPopupTrigger() ? "true" : "false"));
   int x = e.getX();
   int y = e.getY();
   Roi roi = imp.getRoi();
   if (roi != null
       && (roi.getType() == Roi.POLYGON
           || roi.getType() == Roi.POLYLINE
           || roi.getType() == Roi.ANGLE)
       && roi.getState() == roi.CONSTRUCTING) {
     roi.handleMouseUp(x, y); // simulate double-click to finalize
     roi.handleMouseUp(x, y); // polygon or polyline selection
     return;
   }
   PopupMenu popup = Menus.getPopupMenu();
   if (popup != null) {
     add(popup);
     if (IJ.isMacOSX()) IJ.wait(10);
     popup.show(this, x, y);
   }
 }
Ejemplo n.º 23
0
        public void mousePressed(MouseEvent e) {
          requestFocus();
          Point p = e.getPoint();
          int size =
              Math.min(
                  MAX_SIZE,
                  Math.min(
                      getWidth() - imagePadding.left - imagePadding.right,
                      getHeight() - imagePadding.top - imagePadding.bottom));
          p.translate(-(getWidth() / 2 - size / 2), -(getHeight() / 2 - size / 2));
          if (mode == ColorPicker.BRI || mode == ColorPicker.SAT) {
            // the two circular views:
            double radius = ((double) size) / 2.0;
            double x = p.getX() - size / 2.0;
            double y = p.getY() - size / 2.0;
            double r = Math.sqrt(x * x + y * y) / radius;
            double theta = Math.atan2(y, x) / (Math.PI * 2.0);

            if (r > 1) r = 1;

            if (mode == ColorPicker.BRI) {
              setHSB((float) (theta + .25f), (float) (r), bri);
            } else {
              setHSB((float) (theta + .25f), sat, (float) (r));
            }
          } else if (mode == ColorPicker.HUE) {
            float s = ((float) p.x) / ((float) size);
            float b = ((float) p.y) / ((float) size);
            if (s < 0) s = 0;
            if (s > 1) s = 1;
            if (b < 0) b = 0;
            if (b > 1) b = 1;
            setHSB(hue, s, b);
          } else {
            int x2 = p.x * 255 / size;
            int y2 = p.y * 255 / size;
            if (x2 < 0) x2 = 0;
            if (x2 > 255) x2 = 255;
            if (y2 < 0) y2 = 0;
            if (y2 > 255) y2 = 255;

            if (mode == ColorPicker.RED) {
              setRGB(red, x2, y2);
            } else if (mode == ColorPicker.GREEN) {
              setRGB(x2, green, y2);
            } else {
              setRGB(x2, y2, blue);
            }
          }
        }
Ejemplo n.º 24
0
 public void mousePressed(MouseEvent e) {
   // #if (tar)
   // @    		if (e.getButton() == 1){
   // @	            if (current_Player.isMo() && current_Player.getSch().getStart_X() == 0 &&
   // current_Player.getSch().isIsActive() == false){
   // @	                current_Player.getSch().setIsActive(true);
   // @	                current_Player.getSch().setStart_X(e.getX());
   // @	                current_Player.getSch().setStart_Y(e.getY());
   // @	                current_Player.getSch().setStart_time();
   // @	            }
   // @	        }
   // #else
   if (e.getButton() == 3) {
     TankInfo ti = new TankInfo();
     System.out.println("ISIDE");
   }
   // #endif
 }
Ejemplo n.º 25
0
 public void mouseClicked(MouseEvent e) {
   if (e.getClickCount() == 2) invertCM();
   updateColors();
 }
Ejemplo n.º 26
0
 /** Handles the event when the mouse is pressed or released */
 public void processMouseEvent(MouseEvent e) {
   if (e.getID() == MouseEvent.MOUSE_PRESSED && parent.dtype == CONST.TIMELINES) {
     message = handleMsgDlg(e);
     if (!message) handleEventDlg(e);
   } else super.processMouseEvent(e);
 }
Ejemplo n.º 27
0
 /** Handles the event when the mouse is moved */
 public void processMouseMotionEvent(MouseEvent e) {
   if (e.getID() == MouseEvent.MOUSE_MOVED) {
     adjustTimeField(e.getX());
     adjustElTimeField();
   } else super.processMouseMotionEvent(e);
 }
Ejemplo n.º 28
0
 public void mouseDragged(MouseEvent e) {
   translateCM((e.getY() - cbstarty) * attrSize / height);
   updateColors();
   cbstarty = e.getY();
 }
Ejemplo n.º 29
0
 static void handleMouseClick(MouseEvent e) {
   double midX = (maxX + minX) / 2;
   double midXDist = midX - minX;
   double midY = (maxY + minY) / 2;
   double midYDist = midY - minY;
   // See if any of the navigation icons were under the mouse.
   if (withinBounds(e.getX(), e.getY(), D.width - 20, D.width - 15, 10, 20)) {
     // Plus.
     setXYRange(minX, midX, minY, midY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 20, D.width - 15, 40, 50)) {
     // Minus.
     setXYRange(minX, 2 * maxX, minY, 2 * maxY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 75, D.width - 65, 0, 20)) {
     //
     setXYRange(minX, maxX, minY + midYDist, maxY + midYDist);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 75, D.width - 65, 30, 50)) {
     //
     setXYRange(minX, maxX, minY - midYDist, maxY - midYDist);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 65, D.width - 45, 20, 30)) {
     //
     setXYRange(minX + midXDist, maxX + midXDist, minY, maxY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 95, D.width - 75, 20, 30)) {
     //
     setXYRange(minX - midXDist, maxX - midXDist, minY, maxY);
   }
   drawArea.repaint();
 }
Ejemplo n.º 30
0
 public void mouseDragged(MouseEvent e) {
   mDrag(e.getX(), e.getY());
 }