Esempio n. 1
0
 void dispatch() {
   synchronized (events) {
     if (mousemv != null) {
       mousepos = new Coord(mousemv.getX(), mousemv.getY());
       ui.mousemove(mousemv, mousepos);
       mousemv = null;
     }
     InputEvent e = null;
     while ((e = events.poll()) != null) {
       if (e instanceof MouseEvent) {
         MouseEvent me = (MouseEvent) e;
         if (me.getID() == MouseEvent.MOUSE_PRESSED) {
           ui.mousedown(me, new Coord(me.getX(), me.getY()), me.getButton());
         } else if (me.getID() == MouseEvent.MOUSE_RELEASED) {
           ui.mouseup(me, new Coord(me.getX(), me.getY()), me.getButton());
         } else if (me instanceof MouseWheelEvent) {
           ui.mousewheel(
               me, new Coord(me.getX(), me.getY()), ((MouseWheelEvent) me).getWheelRotation());
         }
       } else if (e instanceof KeyEvent) {
         KeyEvent ke = (KeyEvent) e;
         if (ke.getID() == KeyEvent.KEY_PRESSED) {
           ui.keydown(ke);
         } else if (ke.getID() == KeyEvent.KEY_RELEASED) {
           ui.keyup(ke);
         } else if (ke.getID() == KeyEvent.KEY_TYPED) {
           ui.type(ke);
         }
       }
       ui.lastevent = System.currentTimeMillis();
     }
   }
 }
Esempio n. 2
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());
    }
Esempio n. 3
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();
  }
Esempio n. 4
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:
    }
  }
    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. 6
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();
 }
 /** 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);
   }
 }
  @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;
  }
Esempio n. 9
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;
        }
    }
Esempio n. 10
0
private void MenuPopup (MouseEvent ev, CGNode node)
    {
	if (!node.IsConcept())
	    return;

	String menuname = (String)menumap.get (node.GetType(true));
	if (menuname == null)
	    return;
	Hashtable templates = (Hashtable)menus.get (menuname);
	if (templates == null)
	    return;

	if( popup != null )
	  remove( popup );

	popup = new PopupMenu( menuname );
	
        Enumeration e = templates.keys();
        while (e.hasMoreElements()) {
            String key = (String)e.nextElement();
	    MenuItem mi = new MenuItem( key );
	    mi.setActionCommand( key );
	    mi.addActionListener( this );
	    popup.add( mi );
        }
        curnode = node;

	this.add( popup );

	popup.show( this, ev.getX(), ev.getY() );
    }
Esempio n. 11
0
 private void maybeShowGroupPopup(MouseEvent e, JIDStatusGroup jidStatusGroup) {
   if (e.isPopupTrigger()) {
     currentJIDStatusGroup = jidStatusGroup;
     currentGroup = jidStatusGroup.getName();
     groupPopupMenu.show(e.getComponent(), e.getX(), e.getY());
   }
 }
 /** 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);
   }
 }
Esempio n. 13
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("");
   }
 }
 @Override
 public void mousePressed(MouseEvent evt) {
   // handle.mousePressed(evt);
   anchor = new Point(evt.getX(), evt.getY());
   multicaster.trackStart(anchor, evt.getModifiersEx(), getView());
   clearHoverHandles();
 }
    public void mouseClicked(MouseEvent e) {
      JTableHeader h = (JTableHeader) e.getSource();
      TableColumnModel columnModel = h.getColumnModel();
      int viewColumn = columnModel.getColumnIndexAtX(e.getX());
      int column = columnModel.getColumn(viewColumn).getModelIndex();
      if (column != -1) {
        sorting_column = column;

        // 0 == priority icon column
        // 4 == priority text column
        if (column == 0) sorting_column = 4;

        if (e.isControlDown()) sorting_column = -1;
        else opposite = !opposite;

        TaskTable treetable = ((TaskTable) h.getTable());

        // java.util.Collection expanded = treetable.getExpandedTreeNodes();

        treetable.tableChanged();
        // treetable.setExpandedTreeNodes(expanded);
        // h.updateUI();
        h.resizeAndRepaint();
      }
    }
Esempio n. 16
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);
      }
    }
  }
  /**
   * 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());
    }
  }
Esempio n. 18
0
  public void leftMouseReleased(MouseEvent e) {
    double x = e.getX();
    double y = e.getY();

    // If no start vertex selected or start vertex is virtual, do nothing
    if (startVertex == null || startVertex.isVirtual()) {
      displayFrame.controlFrame.updateDisplays(true);
      return;
    }
    endVertex =
        getSelectedVertex(
            x, y, displayFrame.getMainDiagramPanel(), displayFrame.getFreeVertexPanel());
    // If no end vertex selected, still do nothing
    if (endVertex == null) {
      displayFrame.controlFrame.updateDisplays(true);
      return;
    }
    // If mouse pressed and released within the same vertex, print vertex label
    if (endVertex == startVertex) {
      canCreateEdge = false;
      startVertex.setSelected(!startVertex.isSelected());
      displayFrame.controlFrame.updateDisplays(true);
      return;
    } else {
      addNewEdge();
    }
  }
Esempio n. 19
0
File: set.java Progetto: 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;
 }
 @Override
 public void mouseClicked(MouseEvent evt) {
   if (evt.getClickCount() == 2) {
     multicaster.trackDoubleClick(
         new Point(evt.getX(), evt.getY()), evt.getModifiersEx(), getView());
   }
   evt.consume();
 }
Esempio n. 21
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();
 }
Esempio n. 22
0
    /**
     * When do a mouse drag, get coordinates ( X and Y) of the mouse, then send Draw command as a
     * message to member of Group
     */
    public void mouseDragged(MouseEvent e) {
      int x = e.getX(), y = e.getX();
      DrawCommand comm = new DrawCommand(DrawCommand.DRAW, x, y, drawColor.getRGB());

      if (noChannel) {
        drawPoint(comm);
        return;
      }

      try {
        byte[] buf = Util.streamableToByteBuffer(comm);
        if (use_unicasts) sendToAll(buf);
        else channel.send(new Message(null, null, buf));
      } catch (Exception ex) {
        System.err.println(ex);
      }
    }
Esempio n. 23
0
 @FXML
 void seek(MouseEvent evt) {
   if (player != null) {
     Duration d = player.getMedia().getDuration();
     double millis = (evt.getX() / loadProgressBar.getWidth()) * d.toMillis();
     Duration s = new Duration(millis);
     player.seek(s);
   }
 }
 /** Handles mouse drag events. The event is delegated to the currently active tool. */
 public void mouseDragged(MouseEvent e) {
   try {
     Point p = constrainPoint(new Point(e.getX(), e.getY()));
     tool().mouseDrag(e, p.x, p.y);
     checkDamage();
   } catch (Throwable t) {
     handleMouseEventException(t);
   }
 }
Esempio n. 25
0
 public void mouseDragged(MouseEvent e) {
   mx = e.getX();
   my = e.getY();
   // Buttons
   pauseClicked();
   resumeClicked();
   musicClicked();
   menuClicked();
 }
Esempio n. 26
0
 public void mousePressed(MouseEvent e) {
   int x = e.getX(), y = e.getY();
   pressX = lastX = x;
   pressY = lastY = y;
   first = findFigureElement(x, y);
   if (first == null) {
     point1 = addPoint(x, y);
   }
 }
Esempio n. 27
0
  public void mouseReleased(MouseEvent e) {
    System.out.println("mouseReleased");
    Point1 p3;
    switch (toolFlag) {
      case 0: // 画笔
        paintInfo.addElement(cutflag);
        break;

      case 1: // eraser
        paintInfo.addElement(cutflag);
        break;

      case 3: // 直线
        x = (int) e.getX();
        y = (int) e.getY();
        p3 = new Point1(x, y, c, toolFlag, con);
        paintInfo.addElement(p3);
        paintInfo.addElement(cutflag);
        repaint();
        break;

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

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

      default:
    }
  }
Esempio n. 28
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());
      }
    }
Esempio n. 29
0
  public String getToolTipText(MouseEvent ev) {
    if (ev == null) return null;
    TreePath path = getPathForLocation(ev.getX(), ev.getY());
    if (path != null) {
      JIDStatus jidStatus = null;
      Object o = path.getLastPathComponent();
      if (o instanceof PrimaryJIDStatus) {
        jidStatus = ((PrimaryJIDStatus) o).getJIDPrimaryStatus();
      }
      if (o instanceof JIDStatus) {
        jidStatus = ((JIDStatus) o);
      } else {
        return null;
      }
      String statusMsg;
      if (jidStatus.getStatus() != null) {
        statusMsg =
            I18N.gettext("main.main.statusmenu.Status_message:")
                + " "
                + jidStatus.getStatus()
                + "</p><p>";
      } else {
        statusMsg = "";
      }

      String waitingStatus = jidStatus.getWaiting();
      if (jidStatus.getWaiting() != null) {
        waitingStatus =
            "<p>"
                + I18N.gettext("main.main.roster.Waiting_Status:")
                + " "
                + jidStatus.getWaiting()
                + "</p>";
      } else {
        waitingStatus = "";
      }
      return "<HTML><P>"
          + I18N.gettext("main.main.roster.Status:")
          + " "
          + Presence.toLongShow(jidStatus.getShow())
          + "</p><p>"
          + statusMsg
          + "JID: "
          + jidStatus.getCompleteJID()
          + "</p><p>"
          + I18N.gettext("main.main.roster.Subscription:")
          + " "
          + jidStatus.getSubscription()
          + "</p>"
          + waitingStatus
          + "</p></HTML>";
    }
    return null;
  }
Esempio n. 30
0
 public void mousePressed(MouseEvent e) {
   if (e.getButton() == 3 && !(currentTool instanceof CursorTool)) {
     setTool(cursorTool, cursorButton);
   } else {
     Point p = new Point(e.getX(), e.getY());
     WorkingView.this.getTool().mouseDown(p.x, p.y, e);
   }
   if (currentTool instanceof ArrowTool || currentTool instanceof TextBoxTool) {
     setTool(cursorTool, cursorButton);
   }
   board.requestFocus();
 }