示例#1
0
  @Override
  public final void mousePressed(final MouseEvent e) {
    if (!isEnabled() || !isFocusable()) return;

    requestFocusInWindow();
    cursor(true);

    if (SwingUtilities.isMiddleMouseButton(e)) copy();

    final boolean marking = e.isShiftDown();
    final boolean nomark = !text.marked();
    if (SwingUtilities.isLeftMouseButton(e)) {
      final int c = e.getClickCount();
      if (c == 1) {
        // selection mode
        if (marking && nomark) text.startMark();
        rend.select(scroll.pos(), e.getPoint(), marking);
      } else if (c == 2) {
        text.selectWord();
      } else {
        text.selectLine();
      }
    } else if (nomark) {
      rend.select(scroll.pos(), e.getPoint(), false);
    }
  }
示例#2
0
  @Override
  public final void mousePressed(final MouseEvent e) {
    if (!isEnabled() || !isFocusable()) return;

    requestFocusInWindow();
    caret(true);

    if (SwingUtilities.isMiddleMouseButton(e)) copy();

    final boolean shift = e.isShiftDown();
    final boolean selected = editor.selected();
    if (SwingUtilities.isLeftMouseButton(e)) {
      final int c = e.getClickCount();
      if (c == 1) {
        // selection mode
        if (shift) editor.startSelection(true);
        select(e.getPoint(), !shift);
      } else if (c == 2) {
        editor.selectWord();
      } else {
        editor.selectLine();
      }
    } else if (!selected) {
      select(e.getPoint(), true);
    }
  }
  /**
   * A chat room was selected. Opens the chat room in the chat window.
   *
   * @param e the <tt>MouseEvent</tt> instance containing details of the event that has just
   *     occurred.
   */
  public void mousePressed(MouseEvent e) {
    // Select the object under the right button click.
    if ((e.getModifiers() & InputEvent.BUTTON2_MASK) != 0
        || (e.getModifiers() & InputEvent.BUTTON3_MASK) != 0
        || (e.isControlDown() && !e.isMetaDown())) {
      int ix = this.chatRoomList.rowAtPoint(e.getPoint());

      if (ix != -1) {
        this.chatRoomList.setRowSelectionInterval(ix, ix);
      }
    }

    Object o = this.chatRoomsTableModel.getValueAt(this.chatRoomList.getSelectedRow());

    Point selectedCellPoint = e.getPoint();

    SwingUtilities.convertPointToScreen(selectedCellPoint, chatRoomList);

    if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) {
      JPopupMenu rightButtonMenu;

      if (o instanceof ChatRoomWrapper)
        rightButtonMenu = new ChatRoomRightButtonMenu((ChatRoomWrapper) o);
      else return;

      rightButtonMenu.setInvoker(this);
      rightButtonMenu.setLocation(selectedCellPoint);
      rightButtonMenu.setVisible(true);
    }
  }
  public void mouseReleased(MouseEvent e) {
    lastInteractionTime = System.currentTimeMillis();
    if (enabled && !readOnly && lastPressEvent != null && dragInProgress) {

      if (enableMouseDrags && !e.getPoint().equals(lastPressEvent.getPoint())) {

        dragInProgress = false;

        // Generate the command string
        String s = "Mouse " + MouseCommand.MOUSE_DRAG;

        // Insert the button identifier if other than left button was pressed
        if (e.getButton() != MouseEvent.BUTTON1) {
          s += " " + MouseCommand.PARAM_BUTTON_SHORT + "=" + parser.buttonToString(e.getButton());
        }

        // Insert modifiers if there are any
        String modifiers = parser.modifiersToString(e.getModifiers());
        if (modifiers.length() > 0) {
          s += " " + MouseCommand.PARAM_MODIFIER + "=" + modifiers;
        }

        // Generate coordinates
        s += " " + MouseCommand.PARAM_FROM + "=" + parser.pointToString(lastPressEvent.getPoint());
        s += " " + MouseCommand.PARAM_TO + "=" + parser.pointToString(e.getPoint());

        // Insert the command to the current editor
        insertLine(s, false, true, false);
        insertEvent(e);
      }
    }
  }
  private void updateRolloverColumn(MouseEvent e) {
    if (header.getDraggedColumn() == null && header.contains(e.getPoint())) {

      int col = header.columnAtPoint(e.getPoint());
      if (col != rolloverColumn) {
        rolloverColumn = col;
        header.repaint();
      }
    }
  }
示例#6
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;
    }
示例#7
0
  private void hovered(final MouseEvent e, final boolean entered) {

    hoveredIndex = myList.locationToIndex(e.getPoint());
    if (!entered
        || hoveredIndex != -1
            && !myList.getCellBounds(hoveredIndex, hoveredIndex).contains(e.getPoint()))
      hoveredIndex = -1;

    myList.repaint();
  }
示例#8
0
 public void mousePressed(MouseEvent e) {
   if (ctx != null) {
     // save the current selection set operator
     prevSetOp = ctx.getSetOperator(tm).getSetOperator();
     // set the selection set operator
     ctx.getSetOperator(tm).setFromInputEventMask(e.getModifiers());
   }
   start = e.getPoint();
   current = e.getPoint();
   selecting = true;
   repaint();
 }
 private boolean isOnNextStepButton(MouseEvent e) {
   final int index = myList.getSelectedIndex();
   final Rectangle bounds = myList.getCellBounds(index, index);
   final Point point = e.getPoint();
   return bounds != null
       && point.getX() > bounds.width + bounds.getX() - AllIcons.Icons.Ide.NextStep.getIconWidth();
 }
示例#10
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();
      }
    }
示例#11
0
 @Override
 public void mouseClicked(MouseEvent me) {
   Element el = doc.getCharacterElement(viewToModel(me.getPoint()));
   if (el == null) return;
   AttributeSet as = el.getAttributes();
   if (as.isDefined("ip")) {
     String ip = (String) as.getAttribute("ip");
     ScriptException se = (ScriptException) as.getAttribute("exception");
     Node node = net.getAtIP(ip);
     if (node == null) {
       Utility.displayError("Error", "Computer does not exist");
       return;
     }
     String errorString =
         "--ERROR--\n"
             + "Error at line number "
             + se.getLineNumber()
             + " and column number "
             + se.getColumnNumber()
             + "\n"
             + se.getMessage();
     new ScriptDialog(
             parentFrame,
             str -> {
               if (str != null) {
                 node.setScript(str);
               }
             },
             node.getScript(),
             errorString)
         .setVisible(true);
   }
 }
      @Override
      public void mouseDragged(MouseEvent e) {
        if (!myDragging) return;
        MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, MyDivider.this);
        final ToolWindowAnchor anchor = myInfo.getAnchor();
        final Point point = event.getPoint();
        final Container windowPane = InternalDecorator.this.getParent();
        myLastPoint = SwingUtilities.convertPoint(MyDivider.this, point, windowPane);
        myLastPoint.x = Math.min(Math.max(myLastPoint.x, 0), windowPane.getWidth());
        myLastPoint.y = Math.min(Math.max(myLastPoint.y, 0), windowPane.getHeight());

        final Rectangle bounds = InternalDecorator.this.getBounds();
        if (anchor == ToolWindowAnchor.TOP) {
          InternalDecorator.this.setBounds(0, 0, bounds.width, myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.LEFT) {
          InternalDecorator.this.setBounds(0, 0, myLastPoint.x, bounds.height);
        } else if (anchor == ToolWindowAnchor.BOTTOM) {
          InternalDecorator.this.setBounds(
              0, myLastPoint.y, bounds.width, windowPane.getHeight() - myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.RIGHT) {
          InternalDecorator.this.setBounds(
              myLastPoint.x, 0, windowPane.getWidth() - myLastPoint.x, bounds.height);
        }
        InternalDecorator.this.validate();
        e.consume();
      }
示例#13
0
 public void mouseReleased(MouseEvent e) {
   current = e.getPoint();
   // intersect with graph
   Rectangle selrect =
       new Rectangle(start.x, start.y, current.x - start.x, current.y - start.y);
   int[] gi = gs.getIndicesAt(selrect, graph.getXAxis(), graph.getYAxis());
   DefaultListSelectionModel rsm = new DefaultListSelectionModel();
   if (gi != null) {
     rsm.setValueIsAdjusting(true);
     for (int j = 0; j < gi.length; j++) {
       // find node and select segs for node and all descendents
       int nodeidx = gi[j] / 2;
       TreeNode tn = nodemap[nodeidx];
       selectTraverse(tn, rsm);
     }
     rsm.setValueIsAdjusting(false);
   }
   if (ctx != null) {
     // Merge this selection with the table selection list
     // using the current set selection operator
     ColumnMap cmap = ctx.getColumnMap(tm, 0);
     if (cmap != null) {
       cmap.selectValues(rsm);
     }
   }
   if (ctx != null) {
     // restore the original selection set operator
     ctx.getSetOperator(tm).setSetOperator(prevSetOp);
   }
   repaint();
 }
示例#14
0
文件: LinkTool.java 项目: WU-ARL/RLI
 public void mouseDragged(MouseEvent e) {
   if (isEnabled()) {
     // System.out.println("LinkTool::mouseDragged");
     if (e.getSource() instanceof ONLGraphic)
       buttonAction.setIntermediate(e.getPoint(), (ONLGraphic) e.getSource());
   }
 }
示例#15
0
 public void mouseMoved(MouseEvent e) {
   int k = html.viewToModel(e.getPoint());
   if (html.hasFocus() && html.getSelectionStart() <= k && k < html.getSelectionEnd()) {
     setMessage("(on selection)", MOVE);
     return;
   }
   String s = text.getText(); // "";
   int m = s.length(); // html.getDocument().getLength();
   /*try {
          s = html.getText(0, m);
      } catch (BadLocationException x) {
   setMessage("BadLocation "+m, TEXT); return;
      } */
   if (!Character.isLetter(s.charAt(k))) {
     setMessage("(not a letter)", TEXT);
     return;
   }
   selB = k;
   selE = k + 1;
   while (!Character.isWhitespace(s.charAt(selB - 1))) selB--;
   while (!Character.isWhitespace(s.charAt(selE))) selE++;
   setMessage(selB + "-" + selE, HAND);
   word = "";
   for (int i = selB; i < selE; i++) if (Character.isLetter(s.charAt(i))) word += s.charAt(i);
   html.setToolTipText(word);
 }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   PickerTableModel model = getDataModel();
   ICFInternetISOCountryObj o =
       (ICFInternetISOCountryObj) model.getValueAt(row, COLID_ROW_HEADER);
   invokeWhenChosen.choseISOCountry(o);
   try {
     Container cont = getParent();
     while ((cont != null) && (!(cont instanceof JInternalFrame))) {
       cont = cont.getParent();
     }
     if (cont != null) {
       ((JInternalFrame) cont).setClosed(true);
     }
   } catch (Exception x) {
   }
 }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   FinderTableModel model = getDataModel();
   ICFSecurityISOTimezoneObj o =
       (ICFSecurityISOTimezoneObj) model.getValueAt(row, COLID_ROW_HEADER);
   if (o == null) {
     return;
   }
   JInternalFrame frame = swingSchema.getISOTimezoneFactory().newViewEditJInternalFrame(o);
   ((ICFSecuritySwingISOTimezoneJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   if (frame == null) {
     return;
   }
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame myInternalFrame = (JInternalFrame) cont;
     myInternalFrame.getDesktopPane().add(frame);
     frame.setVisible(true);
     frame.show();
   }
 }
    public void mouseClicked(MouseEvent ev) {
      Window w = (Window) ev.getSource();
      Frame f = null;

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

      Point convertedPoint = SwingUtilities.convertPoint(w, ev.getPoint(), getTitlePane());

      int state = f.getExtendedState();
      if (getTitlePane() != null && getTitlePane().contains(convertedPoint)) {
        if ((ev.getClickCount() % 2) == 0 && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {
          if (f.isResizable()) {
            if ((state & Frame.MAXIMIZED_BOTH) != 0) {
              f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH);
            } else {
              f.setExtendedState(state | Frame.MAXIMIZED_BOTH);
            }
            return;
          }
        }
      }
    }
  protected void processMouseEvent(final MouseEvent e) {
    if (e.isPopupTrigger() && e.getComponent().isShowing()) {
      super.processMouseEvent(e);
      return;
    }

    if (UIUtil.isCloseClick(e)) {
      myDecorator.fireHiddenSide();
      return;
    }

    if (e.getButton() == MouseEvent.BUTTON1) {
      if (MouseEvent.MOUSE_PRESSED == e.getID()) {
        myPressedPoint = e.getPoint();
        myPressedWhenSelected = isSelected();
        myDragCancelled = false;
      } else if (MouseEvent.MOUSE_RELEASED == e.getID()) {
        finishDragging();
        myPressedPoint = null;
        myDragButtonImage = null;
      }
    }

    super.processMouseEvent(e);
  }
    private void adjustFocusAndSelection(MouseEvent e) {
      if (shouldIgnore(e)) {
        return;
      }

      Point p = e.getPoint();
      int row = grid.rowAtPoint(p);
      int column = grid.columnAtPoint(p);

      // The autoscroller can generate drag events outside range.
      if ((column == -1) || (row == -1)) {
        System.err.println("Out of bounds");
        return;
      }

      if (grid.editCellAt(row, column, e)) {
        setDispatchComponent(e);
        repostEvent(e);
      } else {
        grid.requestFocus();
      }

      GridCellEditor editor = grid.getCurrentCellEditor();
      if (editor == null || editor.shouldSelectCell(e)) {
        // Update selection model
        setValueIsAdjusting(true);
        grid.changeSelection(row, column, e.isControlDown(), e.isShiftDown());
      }
    }
示例#21
0
 @Override
 public void mouseMoved(MouseEvent e) {
   Point pt = e.getPoint();
   int prevRow = row;
   int prevCol = col;
   row = table.rowAtPoint(pt);
   col = table.columnAtPoint(pt);
   if (row < 0 || col < 0) {
     row = -1;
     col = -1;
   }
   // >>>> HyperlinkCellRenderer.java
   // @see
   // http://java.net/projects/swingset3/sources/svn/content/trunk/SwingSet3/src/com/sun/swingset3/demos/table/HyperlinkCellRenderer.java
   if (row == prevRow && col == prevCol) {
     return;
   }
   Rectangle repaintRect;
   if (row >= 0 && col >= 0) {
     Rectangle r = table.getCellRect(row, col, false);
     if (prevRow >= 0 && prevCol >= 0) {
       repaintRect = r.union(table.getCellRect(prevRow, prevCol, false));
     } else {
       repaintRect = r;
     }
   } else {
     repaintRect = table.getCellRect(prevRow, prevCol, false);
   }
   table.repaint(repaintRect);
   // <<<<
   // table.repaint();
 }
示例#22
0
    public void mousePressed(MouseEvent e) {
      if (e.getButton() == e.BUTTON3) {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(2);
        int index = list.locationToIndex(e.getPoint());
        GetImageFile gif = new GetImageFile(files[index]);

        JTextArea area =
            new JTextArea(
                "File: "
                    + gif.getImageString()
                    + "\n"
                    + "Score: "
                    + nf.format(scores[index])
                    + "\n"
                    + "Pairs: "
                    + nrpairs[index]);
        area.setEditable(false);
        area.setBorder(BorderFactory.createLineBorder(Color.black));
        area.setFont(new Font("times", Font.PLAIN, 12));
        PopupFactory factory = PopupFactory.getSharedInstance();
        popup =
            factory.getPopup(
                null,
                area,
                (int) e.getComponent().getLocationOnScreen().getX() + e.getX() + 25,
                (int) e.getComponent().getLocationOnScreen().getY() + e.getY());
        popup.show();
      }
    }
示例#23
0
  public final void mouseMoved(MouseEvent e) {
    Point p = e.getPoint();

    if (odometer != null) {
      String output = " (" + p.x + ", " + p.y + ")";
      odometer.setText(output);
    }
  }
示例#24
0
  /**
   * @param aEvent the event to test, may be <code>null</code>.
   * @return
   */
  private boolean isCursorHover(final MouseEvent aEvent) {
    if (!isCursorPopupTrigger(aEvent)) {
      return false;
    }

    final Point point = aEvent.getPoint();
    return (findCursor(point) != null);
  }
示例#25
0
 void profileList_mouseClicked(MouseEvent e) {
   JList theList = (JList) e.getSource();
   ListModel aModel = theList.getModel();
   int index = theList.locationToIndex(e.getPoint());
   if (index < 0) return;
   UniProfile aProfile = (UniProfile) aModel.getElementAt(index);
   nameTextField.setText(aProfile.toString());
 }
    public void mousePressed(MouseEvent e) {
      if (e.getClickCount() == 2) {
        JList list = (JList) e.getSource();
        int index = list.locationToIndex(e.getPoint());

        optionPane.setInputValue(list.getModel().getElementAt(index));
      }
    }
示例#27
0
 private void onMouseClick(MouseEvent event) {
   Point point = event.getPoint();
   BoundableRenderable r = this.rblock.getRenderable(point);
   if (r != null) {
     Rectangle bounds = r.getBounds();
     r.onMouseClick(event, point.x - bounds.x, point.y - bounds.y);
   }
 }
    private boolean withinPopup(final AWTEvent event) {
      if (!myContent.isShowing()) return false;

      final MouseEvent mouse = (MouseEvent) event;
      final Point point = mouse.getPoint();
      SwingUtilities.convertPointToScreen(point, mouse.getComponent());
      return new Rectangle(myContent.getLocationOnScreen(), myContent.getSize()).contains(point);
    }
示例#29
0
文件: LinkTool.java 项目: WU-ARL/RLI
 public void mouseDragged(MouseEvent e) {
   if (ltool.isEnabled()) {
     // System.out.println("LinkTool.ComponentListener::mouseDragged");
     // translate point to real coordinates since point is in relation to the source component
     setIntermediate(
         e.getPoint(), ((ONLComponentButton) e.getSource()).getONLComponent().getGraphic());
   }
 }
示例#30
0
  /** {@inheritDoc} */
  @Override
  public void mouseDragged(final MouseEvent aEvent) {
    final MouseEvent event = convertEvent(aEvent);
    final Point point = event.getPoint();

    // Update the selected channel while dragging...
    this.controller.setSelectedChannel(point);

    if (getModel().isCursorMode() && (this.movingCursor >= 0)) {
      this.controller.moveCursor(this.movingCursor, getCursorDropPoint(point));

      aEvent.consume();
    } else {
      if ((this.lastClickPosition == null)
          && ((aEvent.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0)) {
        this.lastClickPosition = new Point(point);
      }

      final JScrollPane scrollPane =
          getAncestorOfClass(JScrollPane.class, (Component) aEvent.getSource());
      if ((scrollPane != null) && (this.lastClickPosition != null)) {
        final JViewport viewPort = scrollPane.getViewport();
        final Component signalView = this.controller.getSignalDiagram().getSignalView();

        boolean horizontalOnly = (aEvent.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0;
        boolean verticalOnly =
            horizontalOnly && ((aEvent.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0);

        int dx = aEvent.getX() - this.lastClickPosition.x;
        int dy = aEvent.getY() - this.lastClickPosition.y;

        Point scrollPosition = viewPort.getViewPosition();
        int newX = scrollPosition.x;
        if (!verticalOnly) {
          newX -= dx;
        }
        int newY = scrollPosition.y;
        if (verticalOnly || !horizontalOnly) {
          newY -= dy;
        }

        int diagramWidth = signalView.getWidth();
        int viewportWidth = viewPort.getWidth();
        int maxX = diagramWidth - viewportWidth - 1;
        scrollPosition.x = Math.max(0, Math.min(maxX, newX));

        int diagramHeight = signalView.getHeight();
        int viewportHeight = viewPort.getHeight();
        int maxY = diagramHeight - viewportHeight;
        scrollPosition.y = Math.max(0, Math.min(maxY, newY));

        viewPort.setViewPosition(scrollPosition);
      }

      // Use UNCONVERTED/ORIGINAL mouse event!
      handleZoomRegion(aEvent, this.lastClickPosition);
    }
  }