Esempio n. 1
0
    public void mousePressed(MouseEvent evt) {
      requestFocus();

      // Focus events not fired sometimes?
      setCaretVisible(true);
      focusedComponent = JEditTextArea.this;

      if ((evt.getModifiers() & InputEvent.BUTTON3_MASK) != 0 && popup != null) {
        popup.show(painter, evt.getX(), evt.getY());
        return;
      }

      int line = yToLine(evt.getY());
      int offset = xToOffset(line, evt.getX());
      int dot = getLineStartOffset(line) + offset;

      switch (evt.getClickCount()) {
        case 1:
          doSingleClick(evt, line, offset, dot);
          break;
        case 2:
          // It uses the bracket matching stuff, so
          // it can throw a BLE
          try {
            doDoubleClick(evt, line, offset, dot);
          } catch (BadLocationException bl) {
            bl.printStackTrace();
          }
          break;
        case 3:
          doTripleClick(evt, line, offset, dot);
          break;
      }
    }
 /** Select or grow image when clicked. */
 public void mousePressed(MouseEvent e) {
   Dimension size = fComponent.getSize();
   if (e.getX() >= size.width - 7 && e.getY() >= size.height - 7 && getSelectionState() == 2) {
     // Click in selected grow-box:
     if (DEBUG) System.out.println("ImageView: grow!!! Size=" + fWidth + "x" + fHeight);
     Point loc = fComponent.getLocationOnScreen();
     fGrowBase = new Point(loc.x + e.getX() - fWidth, loc.y + e.getY() - fHeight);
     fGrowProportionally = e.isShiftDown();
   } else {
     // Else select image:
     fGrowBase = null;
     JTextComponent comp = (JTextComponent) fContainer;
     int start = fElement.getStartOffset();
     int end = fElement.getEndOffset();
     int mark = comp.getCaret().getMark();
     int dot = comp.getCaret().getDot();
     if (e.isShiftDown()) {
       // extend selection if shift key down:
       if (mark <= start) comp.moveCaretPosition(end);
       else comp.moveCaretPosition(start);
     } else {
       // just select image, without shift:
       if (mark != start) comp.setCaretPosition(start);
       if (dot != end) comp.moveCaretPosition(end);
     }
   }
 }
    public void mouseClicked(MouseEvent e) {
      int selRow = tree.getRowForLocation(e.getX(), e.getY());
      TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());

      if (e.getClickCount() == 2) {
        myDoubleClick(selRow, selPath);
      }
    }
Esempio n. 4
0
 public void mouseDragged(MouseEvent e) {
   int m = e.getModifiers();
   int type = DnDEvent.DND_ONE;
   if (e.isControlDown()) type = DnDEvent.DND_LINE;
   else if (((m & InputEvent.BUTTON2_MASK) != 0) || ((m & InputEvent.BUTTON3_MASK) != 0))
     type = DnDEvent.DND_END;
   if (startPoint == null) startPoint = new Point(e.getX(), e.getY());
   fireDragToolbar(e.getX() - startPoint.x, (e.getY() - startPoint.y), type);
   dragging = true;
 }
    public void mouseMoved(MouseEvent ev) {
      JRootPane root = getRootPane();

      if (root.getWindowDecorationStyle() == JRootPane.NONE) {
        return;
      }

      Window w = (Window) ev.getSource();

      Frame f = null;
      Dialog d = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else if (w instanceof Dialog) {
        d = (Dialog) w;
      }

      // Update the cursor
      int cursor = getCursor(calculateCorner(w, ev.getX(), ev.getY()));

      if (cursor != 0
          && ((f != null && (f.isResizable() && (f.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0))
              || (d != null && d.isResizable()))) {
        w.setCursor(Cursor.getPredefinedCursor(cursor));
      } else {
        w.setCursor(lastCursor);
      }
    }
Esempio n. 6
0
  public void mouseClicked(MouseEvent e) {
    int x;
    int y;

    e.consume();

    if (mouseEventsEnabled) {

      x = Math.round(e.getX() / scale);
      y = Math.round(e.getY() / scale);

      // allow for the canvas margin
      y -= margin;

      // System.out.println("Mouse Click: (" + x + ", " + y + ")");

      if (e.getClickCount() < 2) {
        if (nativeSelectItem(x, y)) {
          parentFTAFrame.updateFrame();
        }
      } else {
        if (nativeSelectItem(x, y)) {
          parentFTAFrame.updateFrame();
        }

        editSelected();
        parentFTAFrame.updateFrame();
      }

      if (focusEventsEnabled) {
        // tell the main Canvas to point to this coordinate
        parentFTAFrame.setCanvasFocus(x, y);
      }
    }
  }
Esempio n. 7
0
 /**
  * Handles mouse moved events.
  *
  * @param e the mouse event
  */
 public void mouseMoved(MouseEvent e) {
   TreePath path = tree.getPathForLocation(e.getX(), e.getY());
   if (path == null) return;
   if (e.getX() > tree.getPathBounds(path).x + hotspot - 3
       || e.getX() < tree.getPathBounds(path).x + 2) tree.setCursor(Cursor.getDefaultCursor());
   else {
     tree.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
   }
 }
Esempio n. 8
0
    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 mouseExited(MouseEvent e) {
    // if the popup menu for is visible, don't register this,
    // because the popup being set visible will fire a mouseExited() event
    if ((popup != null) && popup.isVisible()) return;

    if (state[OPEN] != INACTIVE) {
      setState(OPEN, INACTIVE, true);
    }
    status = "";
    handleMouse(e.getX(), e.getY());
  }
Esempio n. 10
0
  protected void internalDoubleClick(MouseEvent e) {
    if (!(e.getComponent() instanceof JComponent)) return;
    JComponent inComponent = (JComponent) e.getComponent();

    if (inComponent instanceof JTable) {
      JTable thisTable = (JTable) inComponent;
      int rowPoint = thisTable.rowAtPoint(new Point(e.getX(), e.getY()));
      Searcher whichSearch = (Searcher) thisTable.getValueAt(rowPoint, -1);

      whichSearch.execute();
    }
  }
  public void mouseMoved(MouseEvent e) {
    // mouse events before paint();
    if (state == null) return;

    if (state[OPEN] != INACTIVE) {
      // avoid flicker, since there will probably be an update event
      setState(OPEN, INACTIVE, false);
    }
    // System.out.println(e);
    // mouseMove(e);
    handleMouse(e.getX(), e.getY());
  }
 @Override
 public boolean isCellEditable(EventObject e) {
   if (e instanceof MouseEvent && e.getSource() instanceof JTree) {
     MouseEvent me = (MouseEvent) e;
     JTree tree = (JTree) e.getSource();
     TreePath path = tree.getPathForLocation(me.getX(), me.getY());
     Rectangle r = tree.getPathBounds(path);
     if (r == null) {
       return false;
     }
     Dimension d = getPreferredSize();
     r.setSize(new Dimension(d.width, r.height));
     if (r.contains(me.getX(), me.getY())) {
       if (str == null && System.getProperty("java.version").startsWith("1.7.0")) {
         setBounds(new Rectangle(0, 0, d.width, r.height));
       }
       // System.out.println(getBounds());
       return true;
     }
   }
   return false;
 }
Esempio n. 13
0
  public void mousePressed(MouseEvent e) {
    
    // jdf
    if (!isEnabled())
      return;
    
    final int x = e.getX();
    final int y = e.getY();

    int sel = findSelection(x, y);
    ///if (sel == -1) return false;
    if (sel == -1) return;
    currentRollover = -1;

    switch (sel) {
    case RUN:
      editor.handleRun(e.isShiftDown());
      break;

//    case STOP:
//      editor.handleStop();
//      break;
//
    case OPEN:
      popup = menu.getPopupMenu();
      popup.show(EditorToolbar.this, x, y);
      break;

    case NEW:
      if (shiftPressed) {
        editor.base.handleNew();
      } else {
      editor.base.handleNewReplace();
      }
      break;

    case SAVE:
      editor.handleSave(false);
      break;

    case EXPORT:
      boolean t = e.isControlDown();
      editor.handleExport(e.isShiftDown(),autoOpenSerialMonitor ? !t : t); // Control is down if autoOpenSerialMonitor is true in preferences
      break;

    case SERIAL:
      editor.handleSerial();
      handleMouse(e);
      break;
    }
  }
Esempio n. 14
0
  /**
   * Handles mouse click events.
   *
   * @param e the mouse event
   */
  public void mouseClicked(MouseEvent e) {
    TreePath path = tree.getPathForLocation(e.getX(), e.getY());
    if (path == null) return;
    if (e.getX() > tree.getPathBounds(path).x + hotspot) return;

    boolean selected = selectionModel.isAncestorSelected(path);
    try {
      ignoreEvents = true;
      if (selected) {
        selectionModel.removeSelectionPath(path);
      } else {
        selectionModel.addSelectionPath(path);
      }
    } finally {
      ignoreEvents = false;
      tree.treeDidChange();
    }
  }
Esempio n. 15
0
  // process a mouseClicked event
  // select the loop if the mouse was clicked within the edges of
  // the border
  public void mouseClicked(MouseEvent mouseEvent) {
    int x = mouseEvent.getX();
    int y = mouseEvent.getY();

    Rectangle bounds = getBounds();

    // left, top, bottom, right edge
    if ((x >= 0 && x <= SELECT_BORDER_SIZE)
        || (y >= 0 && y <= SELECT_BORDER_SIZE)
        || (y >= bounds.height - SELECT_BORDER_SIZE && y <= bounds.height)
        || (x >= bounds.width - SELECT_BORDER_SIZE && x <= bounds.width)) {
      if (isSelected()) program.setAllSelected(false);
      else {
        program.setAllSelected(false);
        setSelected(true);
        program.updateLoopDialog();
      }
      program.updateState();
      repaint();
    } else super.mouseClicked(mouseEvent);
  }
Esempio n. 16
0
    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());
      }
    }
Esempio n. 17
0
  public void handleMouse(MouseEvent e) {
    int x = e.getX();
    int y = e.getY();

    if (currentRollover != -1) {
      if ((x > x1[currentRollover]) && (y > y1) &&
          (x < x2[currentRollover]) && (y < y2)) {
        return;

      } else {
        setState(currentRollover, INACTIVE, true);
        currentRollover = -1;
      }
    }
    int sel = findSelection(x, y);
    if (sel == -1) return;

    if (state[sel] != ACTIVE) {
      setState(sel, ROLLOVER, true);
      currentRollover = sel;
    }
  }
Esempio n. 18
0
    public void mousePressed(MouseEvent event) {

      // Point selectedPoint = event.getPoint();
      int xPos = event.getX() - 20;
      int yPos = event.getY() - 50;
      int col = (int) (xPos / 50);
      int row = (int) (yPos / 50);
      // If left mouse is clicked, reveal
      // Get the coordinates of the click and use cascade on square

      if (event.getButton() == MouseEvent.BUTTON1) {

        if (xPos > 0 && xPos < 800 && yPos > 0 && yPos < 800) {

          if (!board[row][col].isReveal() && !board[row][col].isFlag()) cascade(board[row][col]);
        }
      }
      // If right mouse button is clicked, place flag
      else if (event.getButton() == MouseEvent.BUTTON3) {
        if (xPos > 0 && xPos < 800 && yPos > 0 && yPos < 800) {

          if (!board[row][col].isFlag && !board[row][col].isReveal() && currentFlags < maxFlags) {
            board[row][col].addFlag();
            currentFlags++;
            if (board[row][col].isBear()) {
              bearsCovered++;
              checkWin();
            }
          } else if (board[row][col].isFlag) {
            board[row][col].removeFlag();
            currentFlags--;
            if (board[row][col].isBear()) {
              bearsCovered--;
            }
          }
        }
      }
      repaint();
    }
  /** Resize image if initial click was in grow-box: */
  public void mouseDragged(MouseEvent e) {
    if (fGrowBase != null) {
      Point loc = fComponent.getLocationOnScreen();
      int width = Math.max(2, loc.x + e.getX() - fGrowBase.x);
      int height = Math.max(2, loc.y + e.getY() - fGrowBase.y);

      if (e.isShiftDown() && fImage != null) {
        // Make sure size is proportional to actual image size:
        float imgWidth = fImage.getWidth(this);
        float imgHeight = fImage.getHeight(this);
        if (imgWidth > 0 && imgHeight > 0) {
          float prop = imgHeight / imgWidth;
          float pwidth = height / prop;
          float pheight = width * prop;
          if (pwidth > width) width = (int) pwidth;
          else height = (int) pheight;
        }
      }

      resize(width, height);
    }
  }
Esempio n. 20
0
 private void move(ASDEditNode eNode, MouseEvent e) {
   eNode.getContext().remove(eNode);
   eNode.getContext().add(eNode, 0);
   int newX = eNode.getX() + e.getX();
   int newY = eNode.getY() + e.getY();
   eNode.setLocation(newX, newY);
   // inherited from java.awt.Component
   ASDGrammarNode gNode = eNode.getGrammarNode();
   gNode.setXCoordinate((short) newX);
   gNode.setYCoordinate((short) newY);
   RightLabel rightLabel = eNode.getRightLabel();
   if (rightLabel != null) {
     eNode.getContext().remove(rightLabel);
     eNode.getContext().add(rightLabel, 0);
     rightLabel.setLocation(
         newX + eNode.getWidth() + RightLabel.SEPARATION, newY + eNode.getInsets().top);
   }
   ASDDigraphNode dNode = eNode.getDigraphNode();
   Iterator it;
   for (it = dNode.getInEdges().iterator(); it.hasNext(); )
     ((ASDDigraphEdge) it.next()).getEditEdge().setDefaultCoordinates();
   for (it = dNode.getOutEdges().iterator(); it.hasNext(); )
     ((ASDDigraphEdge) it.next()).getEditEdge().setDefaultCoordinates();
 }
Esempio n. 21
0
 public void mousePressed(MouseEvent e) {
   startPoint = new Point(e.getX(), e.getY());
 }
Esempio n. 22
0
    public void mouseDragged(MouseEvent evt) {
      if (popup != null && popup.isVisible()) return;

      setSelectionRectangular((evt.getModifiers() & InputEvent.CTRL_MASK) != 0);
      select(getMarkPosition(), xyToOffset(evt.getX(), evt.getY()));
    }
  public void mousePressed(MouseEvent e) {
    final int x = e.getX();
    final int y = e.getY();

    int sel = findSelection(x, y);
    /// if (sel == -1) return false;
    if (sel == -1) return;
    currentRollover = -1;
    // int currentSelection = sel;
    // if (!(disableRun && ((sel == RUN) || (sel == STOP)))) {
    // moving the handling of this over into the editor
    // setState(sel, ACTIVE, true);
    // }

    // if (currentSelection == OPEN) {
    // switch (currentSelection) {
    switch (sel) {
      case RUN:
        // if (!disableRun) {
        editor.handleRun(e.isShiftDown());
        // }
        break;

      case STOP:
        // if (!disableRun) {
        // setState(RUN, INACTIVE, true);
        // setInactive();
        editor.handleStop();
        // }
        break;

      case OPEN:
        if (popup == null) {
          // popup = new JPopupMenu();
          popup = editor.sketchbook.getPopupMenu();
          // no events properly being fired, so nevermind
          /*
          popup.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                System.out.println("action " + e);
              }
            });
          popup.addComponentListener(new ComponentAdapter() {
              public void componentHidden(ComponentEvent e) {
                System.out.println("hidden " + e);
              }
            });
          */
          add(popup);
        }
        // activate(OPEN);
        // SwingUtilities.invokeLater(new Runnable() {
        // public void run() {
        popup.show(EditorButtons.this, x, y);
        // }});
        break;

      case NEW:
        editor.handleNew(e.isShiftDown());
        break;

      case SAVE:
        editor.handleSave(false);
        break;

      case EXPORT:
        editor.handleExport();
        break;

      case SERIAL:
        editor.handleSerial();
        break;
    }
  }
Esempio n. 24
0
 /** Checks to see if the event was to show the popup menu */
 private void maybeShowPopup(MouseEvent e) {
   if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {
     popup.show(userList, e.getX(), e.getY());
   }
 }
 public void mouseEntered(MouseEvent e) {
   // mouseMove(e);
   handleMouse(e.getX(), e.getY());
 }
Esempio n. 26
0
 public void mouseReleased(MouseEvent e) {
   if (e.isPopupTrigger()) {
     Popup popup = new Popup();
     popup.show(e.getComponent(), e.getX(), e.getY());
   }
 }
Esempio n. 27
0
 public void mouseDragged(MouseEvent e) {
   translateCM((e.getY() - cbstarty) * attrSize / height);
   updateColors();
   cbstarty = e.getY();
 }
Esempio n. 28
0
 public void mousePressed(MouseEvent e) {
   if (e.getButton() == e.BUTTON3) cbpm.show(e.getComponent(), e.getX(), e.getY());
   cbstarty = e.getY();
 }
 private void maybeShowPopup(MouseEvent e) {
   if (e.isPopupTrigger()) {
     popup.show(e.getComponent(), e.getX(), e.getY());
     isPopupOnScreen(popup, fullScreenBounds);
   }
 }
Esempio n. 30
0
 public void mouseReleased(MouseEvent e) {
   if (dragging) {
     fireDropToolbar(e.getX() - startPoint.x, e.getY() - startPoint.y, DnDEvent.DND_ONE);
     dragging = false;
   }
 }