/**
   * Converts the specified mouse event's screen point from WebView coordinates to Windows
   * coordinates, and returns a new event who's screen point is in Windows coordinates, with the
   * origin at the upper left corner of the WebView window.
   *
   * @param e The event to convert.
   * @return A new mouse event in the Windows coordinate system.
   */
  protected MouseEvent convertToWindows(MouseEvent e) {
    int x = e.getX();
    int y = e.getY();

    // Translate OpenGL screen coordinates to Windows by moving the Y origin from the lower left
    // corner to
    // the upper left corner and flipping the direction of the Y axis.
    y = this.frameSize.height - y;

    if (e instanceof MouseWheelEvent) {
      return new MouseWheelEvent(
          (Component) e.getSource(),
          e.getID(),
          e.getWhen(),
          e.getModifiers(),
          x,
          y,
          e.getClickCount(),
          e.isPopupTrigger(),
          ((MouseWheelEvent) e).getScrollType(),
          ((MouseWheelEvent) e).getScrollAmount(),
          ((MouseWheelEvent) e).getWheelRotation());
    } else {
      return new MouseEvent(
          (Component) e.getSource(),
          e.getID(),
          e.getWhen(),
          e.getModifiers(),
          x,
          y,
          e.getClickCount(),
          e.isPopupTrigger(),
          e.getButton());
    }
  }
 public void mouseEvt(MouseEvent evt) {
   if (evt.isPopupTrigger()) {
     propDialog.setVisible(true);
     propDialog.toFront();
     evt.consume();
   }
 }
Beispiel #3
0
 private void maybeShowGroupPopup(MouseEvent e, JIDStatusGroup jidStatusGroup) {
   if (e.isPopupTrigger()) {
     currentJIDStatusGroup = jidStatusGroup;
     currentGroup = jidStatusGroup.getName();
     groupPopupMenu.show(e.getComponent(), e.getX(), e.getY());
   }
 }
    private void maybeShowPopup(MouseEvent e) {

      if (e.isPopupTrigger()) {
        popup = new JPopupMenu();
        CalendarCardPanel cc = new CalendarCardPanel(ClientContext.getEventColorTable());
        cc.addPropertyChangeListener(CalendarCardPanel.PICKED_DATE, this);
        cc.setCalendarRange(new int[] {-12, 0});
        popup.insert(cc, 0);
        popup.show(e.getComponent(), e.getX(), e.getY());
      }
    }
    public void mabeShowPopup(MouseEvent e) {

      if (e.isPopupTrigger()) {

        final JPopupMenu contextMenu = new JPopupMenu();

        int row = view.getTable().rowAtPoint(e.getPoint());
        ListTableModel<PatientModel> tModel = getTableModel();
        PatientModel obj = tModel.getObject(row);
        int selected = view.getTable().getSelectedRow();

        if (row == selected && obj != null) {
          contextMenu.add(
              new JMenuItem(new ReflectAction("カルテを開く", PatientSearchImpl.this, "openKarte")));
          contextMenu.addSeparator();
          // s.oh^ 2014/08/19 ID権限
          // contextMenu.add(new JMenuItem(copyAction));
          // contextMenu.add(new JMenuItem(new ReflectAction("受付登録", PatientSearchImpl.this,
          // "addAsPvt")));
          // contextMenu.addSeparator();
          if (!Project.isOtherCare()) {
            contextMenu.add(new JMenuItem(copyAction));
            contextMenu.add(
                new JMenuItem(new ReflectAction("受付登録", PatientSearchImpl.this, "addAsPvt")));
            contextMenu.addSeparator();
          }
          // s.oh$
        }

        JCheckBoxMenuItem item = new JCheckBoxMenuItem("年齢表示");
        contextMenu.add(item);
        item.setSelected(ageDisplay);
        item.addActionListener(
            (ActionListener)
                EventHandler.create(
                    ActionListener.class, PatientSearchImpl.this, "switchAgeDisplay"));

        contextMenu.show(e.getComponent(), e.getX(), e.getY());
      }
    }
 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);
   }
 }
  /**
   * Re-dispatches glass pane mouse events only in case they occur on the security panel.
   *
   * @param glassPane the glass pane
   * @param e the mouse event in question
   */
  private void redispatchMouseEvent(Component glassPane, MouseEvent e) {
    Point glassPanePoint = e.getPoint();

    Point securityPanelPoint =
        SwingUtilities.convertPoint(glassPane, glassPanePoint, securityPanel);

    Component component;
    Point componentPoint;

    if (securityPanelPoint.y > 0) {
      component = securityPanel;
      componentPoint = securityPanelPoint;
    } else {
      Container contentPane =
          callRenderer.getCallContainer().getCallWindow().getFrame().getContentPane();

      Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane);

      component =
          SwingUtilities.getDeepestComponentAt(contentPane, containerPoint.x, containerPoint.y);

      componentPoint = SwingUtilities.convertPoint(contentPane, glassPanePoint, component);
    }

    if (component != null)
      component.dispatchEvent(
          new MouseEvent(
              component,
              e.getID(),
              e.getWhen(),
              e.getModifiers(),
              componentPoint.x,
              componentPoint.y,
              e.getClickCount(),
              e.isPopupTrigger()));

    e.consume();
  }
Beispiel #8
0
 public void mouseReleased(MouseEvent e) {
   if (e.isPopupTrigger()) {
     Popup popup = new Popup();
     popup.show(e.getComponent(), e.getX(), e.getY());
   }
 }
  public void mousePressed(MouseEvent e) {
    // if (ij==null) return;
    showCursorStatus = true;
    int toolID = Toolbar.getToolId();
    ImageWindow win = imp.getWindow();
    if (win != null && win.running2 && toolID != Toolbar.MAGNIFIER) {
      if (win instanceof StackWindow) ((StackWindow) win).setAnimate(false);
      else win.running2 = false;
      return;
    }

    int x = e.getX();
    int y = e.getY();
    flags = e.getModifiers();
    // IJ.log("Mouse pressed: " + e.isPopupTrigger() + "  " + ij.modifiers(flags));
    // if (toolID!=Toolbar.MAGNIFIER && e.isPopupTrigger()) {
    if (toolID != Toolbar.MAGNIFIER
        && (e.isPopupTrigger() || (!IJ.isMacintosh() && (flags & Event.META_MASK) != 0))) {
      handlePopupMenu(e);
      return;
    }

    int ox = offScreenX(x);
    int oy = offScreenY(y);
    xMouse = ox;
    yMouse = oy;
    if (IJ.spaceBarDown()) {
      // temporarily switch to "hand" tool of space bar down
      setupScroll(ox, oy);
      return;
    }
    if (showAllROIs) {
      Roi roi = imp.getRoi();
      if (!(roi != null && (roi.contains(ox, oy) || roi.isHandle(x, y) >= 0))
          && roiManagerSelect(x, y)) return;
    }
    if (customRoi && overlay != null) return;

    switch (toolID) {
      case Toolbar.MAGNIFIER:
        if (IJ.shiftKeyDown()) zoomToSelection(ox, oy);
        else if ((flags & (Event.ALT_MASK | Event.META_MASK | Event.CTRL_MASK)) != 0) {
          // IJ.run("Out");
          zoomOut(x, y);
          if (getMagnification() < 1.0) imp.repaintWindow();
        } else {
          // IJ.run("In");
          zoomIn(x, y);
          if (getMagnification() <= 1.0) imp.repaintWindow();
        }
        break;
      case Toolbar.HAND:
        setupScroll(ox, oy);
        break;
      case Toolbar.DROPPER:
        setDrawingColor(ox, oy, IJ.altKeyDown());
        break;
      case Toolbar.WAND:
        Roi roi = imp.getRoi();
        if (roi != null && roi.contains(ox, oy)) {
          Rectangle r = roi.getBounds();
          if (r.width == imageWidth && r.height == imageHeight) imp.killRoi();
          else if (!e.isAltDown()) {
            handleRoiMouseDown(e);
            return;
          }
        }
        if (roi != null) {
          int handle = roi.isHandle(x, y);
          if (handle >= 0) {
            roi.mouseDownInHandle(handle, x, y);
            return;
          }
        }
        setRoiModState(e, roi, -1);
        String mode = WandToolOptions.getMode();
        double tolerance = WandToolOptions.getTolerance();
        int npoints = IJ.doWand(ox, oy, tolerance, mode);
        if (Recorder.record && npoints > 0) {
          if (tolerance == 0.0 && mode.equals("Legacy")) Recorder.record("doWand", ox, oy);
          else
            Recorder.recordString(
                "doWand(" + ox + ", " + oy + ", " + tolerance + ", \"" + mode + "\");\n");
        }
        break;
      case Toolbar.OVAL:
        if (Toolbar.getBrushSize() > 0) new RoiBrush();
        else handleRoiMouseDown(e);
        break;
      case Toolbar.SPARE1:
      case Toolbar.SPARE2:
      case Toolbar.SPARE3:
      case Toolbar.SPARE4:
      case Toolbar.SPARE5:
      case Toolbar.SPARE6:
      case Toolbar.SPARE7:
      case Toolbar.SPARE8:
      case Toolbar.SPARE9:
        Toolbar.getInstance().runMacroTool(toolID);
        break;
      default: // selection tool
        handleRoiMouseDown(e);
    }
  }
  /**
   * When a MenuElement receives an event from a MouseListener, it should never process the event
   * directly. Instead all MenuElements should call this method with the event.
   *
   * @param event a MouseEvent object
   */
  public void processMouseEvent(MouseEvent event) {
    int screenX, screenY;
    Point p;
    int i, c, j, d;
    Component mc;
    Rectangle r2;
    int cWidth, cHeight;
    MenuElement menuElement;
    MenuElement subElements[];
    MenuElement path[];
    Vector<MenuElement> tmp;
    int selectionSize;
    p = event.getPoint();

    Component source = event.getComponent();

    if ((source != null) && !source.isShowing()) {
      // This can happen if a mouseReleased removes the
      // containing component -- bug 4146684
      return;
    }

    int type = event.getID();
    int modifiers = event.getModifiers();
    // 4188027: drag enter/exit added in JDK 1.1.7A, JDK1.2
    if ((type == MouseEvent.MOUSE_ENTERED || type == MouseEvent.MOUSE_EXITED)
        && ((modifiers
                & (InputEvent.BUTTON1_MASK | InputEvent.BUTTON2_MASK | InputEvent.BUTTON3_MASK))
            != 0)) {
      return;
    }

    if (source != null) {
      SwingUtilities.convertPointToScreen(p, source);
    }

    screenX = p.x;
    screenY = p.y;

    tmp = (Vector<MenuElement>) selection.clone();
    selectionSize = tmp.size();
    boolean success = false;
    for (i = selectionSize - 1; i >= 0 && success == false; i--) {
      menuElement = (MenuElement) tmp.elementAt(i);
      subElements = menuElement.getSubElements();

      path = null;
      for (j = 0, d = subElements.length; j < d && success == false; j++) {
        if (subElements[j] == null) continue;
        mc = subElements[j].getComponent();
        if (!mc.isShowing()) continue;
        if (mc instanceof JComponent) {
          cWidth = mc.getWidth();
          cHeight = mc.getHeight();
        } else {
          r2 = mc.getBounds();
          cWidth = r2.width;
          cHeight = r2.height;
        }
        p.x = screenX;
        p.y = screenY;
        SwingUtilities.convertPointFromScreen(p, mc);

        /**
         * Send the event to visible menu element if menu element currently in the selected path or
         * contains the event location
         */
        if ((p.x >= 0 && p.x < cWidth && p.y >= 0 && p.y < cHeight)) {
          int k;
          if (path == null) {
            path = new MenuElement[i + 2];
            for (k = 0; k <= i; k++) path[k] = (MenuElement) tmp.elementAt(k);
          }
          path[i + 1] = subElements[j];
          MenuElement currentSelection[] = getSelectedPath();

          // Enter/exit detection -- needs tuning...
          if (currentSelection[currentSelection.length - 1] != path[i + 1]
              && (currentSelection.length < 2
                  || currentSelection[currentSelection.length - 2] != path[i + 1])) {
            Component oldMC = currentSelection[currentSelection.length - 1].getComponent();

            MouseEvent exitEvent =
                new MouseEvent(
                    oldMC,
                    MouseEvent.MOUSE_EXITED,
                    event.getWhen(),
                    event.getModifiers(),
                    p.x,
                    p.y,
                    event.getXOnScreen(),
                    event.getYOnScreen(),
                    event.getClickCount(),
                    event.isPopupTrigger(),
                    MouseEvent.NOBUTTON);
            currentSelection[currentSelection.length - 1].processMouseEvent(exitEvent, path, this);

            MouseEvent enterEvent =
                new MouseEvent(
                    mc,
                    MouseEvent.MOUSE_ENTERED,
                    event.getWhen(),
                    event.getModifiers(),
                    p.x,
                    p.y,
                    event.getXOnScreen(),
                    event.getYOnScreen(),
                    event.getClickCount(),
                    event.isPopupTrigger(),
                    MouseEvent.NOBUTTON);
            subElements[j].processMouseEvent(enterEvent, path, this);
          }
          MouseEvent mouseEvent =
              new MouseEvent(
                  mc,
                  event.getID(),
                  event.getWhen(),
                  event.getModifiers(),
                  p.x,
                  p.y,
                  event.getXOnScreen(),
                  event.getYOnScreen(),
                  event.getClickCount(),
                  event.isPopupTrigger(),
                  MouseEvent.NOBUTTON);
          subElements[j].processMouseEvent(mouseEvent, path, this);
          success = true;
          event.consume();
        }
      }
    }
  }