Пример #1
0
private void Drop (MouseEvent ev)
    {
	switch (state) {
	case stateDrag:
	    state = stateIdle;
	    CheckResize ();
	    break;

	case stateCreate:
	    CGNode node = new CGNode (ev.getX(), ev.getY(), "something",
				      getFontMetrics (getFont()),
				      !curnode.IsConcept());
            curnode.AddChild (node, curarrow);
            node.SetParent (curnode, curarrow);
            ToBottom (curarrow);
            Add (node);

	    if (!node.IsConcept()) {
		int x = ev.getX() + node.Bbox().width + layoutXDist;
		CGNode node2 = new CGNode (x, ev.getY(), "something",
					   getFontMetrics (getFont()),
					   true);
		CGArrow arrow2 = new CGArrow (0, 0, 0, 0);
		node.AddChild (node2, arrow2);
		node2.SetParent (node, arrow2);
		Add (node2);
		Add (arrow2);
                ToBottom (arrow2);
	    }
            state = stateIdle;
            NotifyViewers();
            break;
	}
        ShowStatus (ev.getX(), ev.getY());
    }
Пример #2
0
  @Override
  public void mouseDragged(MouseEvent e) {

    if (_mousedown != null && _up == null) {
      _display_offset[0] += e.getX() - _mousedown[0];
      _display_offset[1] += e.getY() - _mousedown[1];
      _mousedown = new int[] {e.getX(), e.getY()};
    }
    if (_up != null) {
      if (_up.getType() == BoardObject.type.ROAD) {
        if (((Road) _up).oneDown == false) {
          _up.setX(e.getX());
          _up.setY(e.getY());
        } else {
          ((Road) _up).setX2(e.getX());
          ((Road) _up).setY2(e.getY());
        }
      } else {
        _up.setX(e.getX() - _up.getW() / 2);
        _up.setY(e.getY() - _up.getH() / 2);
      }
    }

    repaint();
  }
 /** 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);
     }
   }
 }
Пример #4
0
    private void showJPopupMenu(MouseEvent e) {
      try {
        if (e.isPopupTrigger() && menu != null) {
          if (window == null) {

            if (isWindows) {
              window = new JDialog((Frame) null);
              ((JDialog) window).setUndecorated(true);
            } else {
              window = new JWindow((Frame) null);
            }
            window.setAlwaysOnTop(true);
            Dimension size = menu.getPreferredSize();

            Point centerPoint = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
            if (e.getY() > centerPoint.getY()) window.setLocation(e.getX(), e.getY() - size.height);
            else window.setLocation(e.getX(), e.getY());

            window.setVisible(true);

            menu.show(((RootPaneContainer) window).getContentPane(), 0, 0);

            // popup works only for focused windows
            window.toFront();
          }
        }
      } catch (Exception ignored) {
      }
    }
Пример #5
0
  public void mousePressed(MouseEvent e) {
    System.out.println("mousePressed");
    Point1 p2;
    switch (toolFlag) {
      case 3: // 直线
        x = (int) e.getX();
        y = (int) e.getY();
        p2 = new Point1(x, y, c, toolFlag, con);
        paintInfo.addElement(p2);
        break;

      case 4: // 圆
        x = (int) e.getX();
        y = (int) e.getY();
        p2 = new Point1(x, y, c, toolFlag, con);
        paintInfo.addElement(p2);
        break;

      case 5: // 矩形
        x = (int) e.getX();
        y = (int) e.getY();
        p2 = new Point1(x, y, c, toolFlag, con);
        paintInfo.addElement(p2);
        break;

      default:
    }
  }
Пример #6
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;
      }
    }
Пример #7
0
 public void mouseMoved(MouseEvent e) {
   if ((e.getX() > PADDLE_WIDTH / 2) && (e.getX() < WIDTH - PADDLE_WIDTH / 2)) {
     double x = e.getX() - PADDLE_WIDTH / 2;
     double y = HEIGHT - BRICK_Y_OFFSET - PADDLE_HEIGHT;
     paddle.setLocation(x, y);
   }
 }
Пример #8
0
  public void action(int eventType, MouseEvent e) {
    switch (eventType) {
      case GeDyn.eEvent_MB1Down:
        dyn.comp.setColorInverse(1);
        dyn.repaintNow = true;
        break;
      case GeDyn.eEvent_MB1Up:
        dyn.comp.setColorInverse(0);
        dyn.repaintNow = true;
        break;
      case GeDyn.eEvent_MB3Press:
        if (refObject.startsWith("!")) {
          // Name of an attribute that contains the objid of the reference object
          CdhrObjid reto = dyn.en.gdh.getObjectInfoObjid(refObject.substring(1));

          if (reto.oddSts() && !reto.objid.isNull()) {
            CdhrString rets = dyn.en.gdh.objidToName(reto.objid, Cdh.mName_volumeStrict);
            System.out.println("str: " + rets.str + " " + rets.getSts());
            if (rets.oddSts() && !rets.str.equals(""))
              new JopMethodsMenu(
                  dyn.session,
                  rets.str,
                  JopUtility.GRAPH,
                  (Component) dyn.comp,
                  e.getX(),
                  e.getY());
          }
        } else {
          new JopMethodsMenu(
              dyn.session, refObject, JopUtility.GRAPH, (Component) dyn.comp, e.getX(), e.getY());
        }
        break;
    }
  }
    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);
      }
    }
Пример #10
0
 public void mouseDragged(MouseEvent mme) {
   System.out.println("dragged");
   int x = mme.getX();
   int y = mme.getX();
   int z = mme.getX();
   s1.setValue(x);
   s2.setValue(y);
   s3.setValue(z);
 }
Пример #11
0
 public void mouseMoved(MouseEvent e) { // called during motion when no buttons are down
   //  if (e.getY ==
   if ((e.getX() < appletsize_x - pad.width() / 2) && (e.getX() > (pad.width() / 2))) {
     pad.changeX(e.getX() - (pad.width() / 2));
     ball.moveWithPaddle(pad.xPos + (pad.width() / 2) - (ball.radius()));
   }
   e.consume();
   repaint();
 }
Пример #12
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));
   }
 }
Пример #13
0
 public void mousePressed(MouseEvent e) {
   if ((e.getModifiers() & java.awt.event.MouseEvent.BUTTON1_MASK) != 0) {
     this.startX = e.getX();
     this.startY = e.getY();
     System.out.println(startX);
     System.out.println(startY);
   } else if ((e.getModifiers() & java.awt.event.MouseEvent.BUTTON3_MASK) != 0) {
     panel.popup.show(panel, e.getX(), e.getY());
   }
 }
Пример #14
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;
 }
Пример #15
0
 public void mouseMoved(MouseEvent e) {
   if (isEnabled()) {
     setXY(
         ((double) e.getX() - (double) getWidth() / (double) 2)
             / ((double) (getWidth() + 1) / 2.0),
         -((double) e.getY() - (double) getHeight() / (double) 2)
             / ((double) (getHeight() + 1) / 2.0));
     face.setEmotion(p, a, d, e.getX(), e.getY());
   }
   paint();
 }
Пример #16
0
 /** Handles mouse down events. The event is delegated to the currently active tool. */
 public void mousePressed(MouseEvent e) {
   try {
     requestFocus(); // JDK1.1
     Point p = constrainPoint(new Point(e.getX(), e.getY()));
     setLastClick(new Point(e.getX(), e.getY()));
     tool().mouseDown(e, p.x, p.y);
     checkDamage();
   } catch (Throwable t) {
     handleMouseEventException(t);
   }
 }
Пример #17
0
 @Override
 public void mouseClicked(MouseEvent e) {
   int col = xToCol(e.getX());
   int row = yToRow(e.getY());
   if (col != -1 && row != -1) {
     setCursorAddress(startAddress + row * 16 + col);
     focusOnHex = (e.getX() - getInsets().left) / charWidth < COL_CHR;
     firstNibble = true;
     repaint();
   }
   if (!hasFocus()) requestFocus();
 }
 /**
  * Hook method which can be overriden by subclasses to provide specialised behaviour in the event
  * of a popup trigger.
  */
 protected void handlePopupMenu(MouseEvent e, int x, int y) {
   Figure figure = drawing().findFigure(e.getX(), e.getY());
   if (figure != null) {
     Object attribute = figure.getAttribute(Figure.POPUP_MENU);
     if (attribute == null) {
       figure = drawing().findFigureInside(e.getX(), e.getY());
     }
     if (figure != null) {
       showPopupMenu(figure, e.getX(), e.getY(), e.getComponent());
     }
   }
 }
Пример #19
0
 public void mouseDragged(MouseEvent e) {
   // System.out.println("Dragged");
   double beatWidth = sp.beatWidth;
   beatWidth += (double) ((double) e.getX() - (double) startX) / 5.0;
   if (beatWidth < 1.0) beatWidth = 1.0;
   if (beatWidth > 256.0) beatWidth = 256.0;
   // System.out.println("beatWidth = "+beatWidth);
   sp.beatWidth = beatWidth;
   startX = e.getX();
   // sp.update();
   this.repaint();
 }
  @Override
  public void mouseReleased(MouseEvent evt) {
    dragLocation = new Point(evt.getX(), evt.getY());
    multicaster.trackEnd(anchor, dragLocation, evt.getModifiersEx(), getView());

    // Note: we must not fire "Tool Done" in this method, because then we can not
    // listen to keyboard events for the handle.

    Rectangle r = new Rectangle(anchor.x, anchor.y, 0, 0);
    r.add(evt.getX(), evt.getY());
    maybeFireBoundsInvalidated(r);
    dragLocation = null;
  }
Пример #21
0
  public void mousePressed(MouseEvent e) {
    // super.mousePressed(e);
    ImageProcessor ip = imp.getProcessor();
    ip.setLineWidth(1);
    if (Toolbar.getToolId() == Toolbar.DROPPER) IJ.setTool(Toolbar.RECTANGLE);

    Rectangle flipperRect = new Rectangle(86, 268, 18, 18);
    Rectangle resetRect = new Rectangle(86, 294, 18, 18);
    Rectangle foreground1Rect = new Rectangle(9, 266, 45, 10);
    Rectangle foreground2Rect = new Rectangle(9, 276, 23, 25);
    Rectangle background1Rect = new Rectangle(33, 302, 45, 10);
    Rectangle background2Rect = new Rectangle(56, 277, 23, 25);
    int x = offScreenX(e.getX());
    int y = offScreenY(e.getY());
    long difference = System.currentTimeMillis() - mouseDownTime;
    boolean doubleClick = (difference <= 250);
    mouseDownTime = System.currentTimeMillis();
    if (flipperRect.contains(x, y)) {
      Color c = Toolbar.getBackgroundColor();
      Toolbar.setBackgroundColor(Toolbar.getForegroundColor());
      Toolbar.setForegroundColor(c);
    } else if (resetRect.contains(x, y)) {
      Toolbar.setForegroundColor(new Color(0x000000));
      Toolbar.setBackgroundColor(new Color(0xffffff));
    } else if ((background1Rect.contains(x, y)) || (background2Rect.contains(x, y))) {
      background = true;
      if (doubleClick) editColor();
      ((ColorGenerator) ip).refreshForeground();
      ((ColorGenerator) ip).refreshBackground();
    } else if ((foreground1Rect.contains(x, y)) || (foreground2Rect.contains(x, y))) {
      background = false;
      if (doubleClick) editColor();
      ((ColorGenerator) ip).refreshBackground();
      ((ColorGenerator) ip).refreshForeground();
    } else {
      // IJ.log(" " + difference + " " + doubleClick);
      if (doubleClick) editColor();
      else {
        setDrawingColor(offScreenX(e.getX()), offScreenY(e.getY()), background);
      }
    }
    if (ip instanceof ColorGenerator) {
      if (background) {
        ((ColorGenerator) ip).refreshForeground();
        ((ColorGenerator) ip).refreshBackground();
      } else {
        ((ColorGenerator) ip).refreshBackground();
        ((ColorGenerator) ip).refreshForeground();
      }
    }
  }
Пример #22
0
  /**
   * Retrieves the word on which the mouse pointer is present
   *
   * @param evt - the MouseEvent which triggered this method
   */
  private String fetchPhrase(MouseEvent evt) {
    Messages.log("--handle Mouse Right Click--");
    int off = xyToOffset(evt.getX(), evt.getY());
    if (off < 0) return null;
    int line = getLineOfOffset(off);
    if (line < 0) return null;
    String s = getLineText(line);
    if (s == null) return null;
    else if (s.length() == 0) return null;
    else {
      int x = xToOffset(line, evt.getX()), x2 = x + 1, x1 = x - 1;
      int xLS = off - getLineStartNonWhiteSpaceOffset(line);
      Messages.log("x=" + x);
      if (x < 0 || x >= s.length()) return null;
      String word = s.charAt(x) + "";
      if (s.charAt(x) == ' ') return null;
      if (!(Character.isLetterOrDigit(s.charAt(x)) || s.charAt(x) == '_' || s.charAt(x) == '$'))
        return null;
      int i = 0;
      while (true) {
        i++;
        if (x1 >= 0 && x1 < s.length()) {
          if (Character.isLetter(s.charAt(x1)) || s.charAt(x1) == '_') {
            word = s.charAt(x1--) + word;
            xLS--;
          } else x1 = -1;
        } else x1 = -1;

        if (x2 >= 0 && x2 < s.length()) {
          if (Character.isLetterOrDigit(s.charAt(x2)) || s.charAt(x2) == '_' || s.charAt(x2) == '$')
            word = word + s.charAt(x2++);
          else x2 = -1;
        } else x2 = -1;

        if (x1 < 0 && x2 < 0) break;
        if (i > 200) {
          // time out!
          break;
        }
      }
      if (Character.isDigit(word.charAt(0))) {
        return null;
      }
      Messages.log("Mouse click, word: " + word.trim());
      ASTGenerator astGenerator = editor.getErrorChecker().getASTGenerator();
      synchronized (astGenerator) {
        astGenerator.setLastClickedWord(line, word, xLS);
      }
      return word.trim();
    }
  }
Пример #23
0
  public synchronized void mouseMoved(MouseEvent e) {
    if (centering && center.x == e.getX() && center.y == e.getY()) {
      centering = false;
    } else {
      int dx = e.getX() - mouse.x;
      int dy = e.getY() - mouse.y;
      image.x += dx;
      image.y += dy;
      recenterMouse();
    }

    mouse.x = e.getX();
    mouse.y = e.getY();
  }
Пример #24
0
private void Drag (MouseEvent ev)
    {
	switch (state) {
	case stateDrag:
            curnode.Move (ev.getX() - dragx, ev.getY() - dragy);
            dragx = ev.getX();
            dragy = ev.getY();
	    break;

	case stateCreate:
	    curarrow.MoveHeadTo (ev.getX(), ev.getY());
	    break;
        }
    }
Пример #25
0
 @Override
 public void mouseMoved(MouseEvent me) {
   // No need to forward since the standard MouseMotionListeners are called anyway
   if (me.getX() < Editor.LEFT_GUTTER) {
     if (lastX >= Editor.LEFT_GUTTER) {
       painter.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
     }
   } else {
     if (lastX < Editor.LEFT_GUTTER) {
       painter.setCursor(new Cursor(Cursor.TEXT_CURSOR));
     }
   }
   lastX = me.getX();
 }
Пример #26
0
      @Override
      public void mouseEntered(MouseEvent e) {

        int x = e.getX();
        int y = e.getY();
        // mPt.x = x;
        // mPt.y = y;
        Point p = new Point(hexmech.pxtoHex(e.getX(), e.getY()));
        if (p.x < 0 || p.y < 0 || p.x >= BSIZE || p.y >= BSIZE) return;

        //                boardBiArray[p.x][p.y] = (int)'H';
        System.out.println("Entered in " + p.x + "  and  " + p.y);
        repaint();
      }
Пример #27
0
    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);
      }
    }
Пример #28
0
 /** Handles mouse move events. The event is delegated to the currently active tool. */
 public void mouseMoved(MouseEvent e) {
   try {
     tool().mouseMove(e, e.getX(), e.getY());
   } catch (Throwable t) {
     handleMouseEventException(t);
   }
 }
Пример #29
0
  /** Shows popup with forward history entries */
  private void showForwardHistory(MouseEvent e) {

    JPopupMenu forwardMenu = new JPopupMenu("Forward History");

    if (historyModel == null) {
      return;
    }

    Locale locale = ((JHelp) getControl()).getModel().getHelpSet().getLocale();
    Enumeration items = historyModel.getForwardHistory().elements();
    JMenuItem mi = null;
    int index = historyModel.getIndex() + 1;
    // while(items.hasMoreElements()){
    for (int i = 0; items.hasMoreElements(); i++) {
      HelpModelEvent item = (HelpModelEvent) items.nextElement();
      if (item != null) {
        String title = item.getHistoryName();
        if (title == null) {
          title = HelpUtilities.getString(locale, "history.unknownTitle");
        }
        mi = new JMenuItem(title);
        // mi.setToolTipText(item.getURL().getPath());
        mi.addActionListener(new HistoryActionListener(i + index));
        forwardMenu.add(mi);
      }
    }
    // if(e.isPopupTrigger())
    forwardMenu.show(e.getComponent(), e.getX(), e.getY());
  }
 public void mouseClicked(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   int currentTabIndex = -1;
   int tabCount = tabPane.getTabCount();
   for (int i = 0; i < tabCount; i++) {
     if (rects[i].contains(x, y)) {
       currentTabIndex = i;
       break;
     } // if contains
   } // for i
   if (currentTabIndex >= 0) {
     Rectangle tabRect = rects[currentTabIndex];
     x = x - tabRect.x;
     y = y - tabRect.y;
     if ((x >= 5) && (x <= 15) && (y >= 5) && (y <= 15)) {
       try {
         tabbedPane.remove(currentTabIndex);
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     } // if
   } // if currentTabIndex >= 0
   System.gc();
 } // mouseClicked